LibreOffice Module sw (master) 1
calcmove.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 <memory>
21#include <rootfrm.hxx>
22#include <pagefrm.hxx>
23#include <viewopt.hxx>
24#include <frmatr.hxx>
25#include <frmtool.hxx>
26#include <txtftn.hxx>
27#include <fmtftn.hxx>
28#include <ndtxt.hxx>
29#include <editeng/ulspitem.hxx>
30#include <editeng/keepitem.hxx>
31#include <osl/diagnose.h>
32#include <svx/sdtaitm.hxx>
33
34#include <fmtfsize.hxx>
35#include <fmtanchr.hxx>
36#include <fmtclbl.hxx>
37
38#include <tabfrm.hxx>
39#include <ftnfrm.hxx>
40#include <txtfrm.hxx>
41#include <sectfrm.hxx>
42#include <dbg_lay.hxx>
43
44#include <sortedobjs.hxx>
45#include <layouter.hxx>
46#include <flyfrms.hxx>
47
50
51// Move methods
52
55{
56 if ( SwFlowFrame::IsMoveBwdJump() || !IsPrevObjMove() )
57 {
58 // Floating back a frm uses a bit of time unfortunately.
59 // The most common case is the following: The Frame wants to float to
60 // somewhere where the FixSize is the same that the Frame itself has already.
61 // In that case it's pretty easy to check if the Frame has enough space
62 // for its VarSize. If this is NOT the case, we already know that
63 // we don't need to move.
64 // The Frame checks itself whether it has enough space - respecting the fact
65 // that it could possibly split itself if needed.
66 // If, however, the FixSize differs from the Frame or Flys are involved
67 // (either in the old or the new position), checking is pointless,
68 // and we have to move the Frame just to see what happens - if there's
69 // some space available to do it, that is.
70
71 // The FixSize of the containers of Contents is always the width.
72
73 // If we moved more than one sheet back (for example jumping over empty
74 // pages), we have to move either way. Otherwise, if the Frame doesn't fit
75 // into the page, empty pages wouldn't be respected anymore.
76 sal_uInt8 nMoveAnyway = 0;
77 SwPageFrame * const pNewPage = pNewUpper->FindPageFrame();
78 SwPageFrame *pOldPage = FindPageFrame();
79
80 if ( SwFlowFrame::IsMoveBwdJump() )
81 return true;
82
83 if( IsInFootnote() && IsInSct() )
84 {
86 SwSectionFrame* pMySect = pFootnote->FindSctFrame();
87 if( pMySect && pMySect->IsFootnoteLock() )
88 {
89 SwSectionFrame *pSect = pNewUpper->FindSctFrame();
90 while( pSect && pSect->IsInFootnote() )
91 pSect = pSect->GetUpper()->FindSctFrame();
92 OSL_ENSURE( pSect, "Escaping footnote" );
93 if( pSect != pMySect )
94 return false;
95 }
96 }
97 SwRectFnSet aRectFnSet(this);
98 SwRectFnSet fnRectX(pNewUpper);
99 if( std::abs( fnRectX.GetWidth(pNewUpper->getFramePrintArea()) -
100 aRectFnSet.GetWidth(GetUpper()->getFramePrintArea()) ) > 1 ) {
101 // In this case, only a WouldFit_ with test move is possible
102 nMoveAnyway = 2;
103 }
104
105 // Do *not* move backward, if <nMoveAnyway> equals 3 and no space is left in new upper.
106 nMoveAnyway |= BwdMoveNecessary( pOldPage, getFrameArea() );
107 {
108 const IDocumentSettingAccess& rIDSA = pNewPage->GetFormat()->getIDocumentSettingAccess();
109 SwTwips nSpace = 0;
110 SwRect aRect( pNewUpper->getFramePrintArea() );
111 aRect.Pos() += pNewUpper->getFrameArea().Pos();
112 const SwFrame *pPrevFrame = pNewUpper->Lower();
113 while ( pPrevFrame )
114 {
115 SwTwips nNewTop = fnRectX.GetBottom(pPrevFrame->getFrameArea());
116 // Consider lower spacing of last frame in a table cell
117 {
118 // Check if last frame is inside table and if it includes its lower spacing.
119 if ( !pPrevFrame->GetNext() && pPrevFrame->IsInTab() &&
121 {
122 const SwFrame* pLastFrame = pPrevFrame;
123 // if last frame is a section, take its last content
124 if ( pPrevFrame->IsSctFrame() )
125 {
126 pLastFrame = static_cast<const SwSectionFrame*>(pPrevFrame)->FindLastContent();
127 if ( pLastFrame &&
128 pLastFrame->FindTabFrame() != pPrevFrame->FindTabFrame() )
129 {
130 pLastFrame = pLastFrame->FindTabFrame();
131 }
132 }
133
134 if ( pLastFrame )
135 {
136 SwBorderAttrAccess aAccess( SwFrame::GetCache(), pLastFrame );
137 const SwBorderAttrs& rAttrs = *aAccess.Get();
138 nNewTop -= rAttrs.GetULSpace().GetLower();
140 {
141 nNewTop -= rAttrs.CalcLineSpacing();
142 }
143 }
144 }
145 }
146 fnRectX.SetTop( aRect, nNewTop );
147
148 pPrevFrame = pPrevFrame->GetNext();
149 }
150
151 nMoveAnyway |= BwdMoveNecessary( pNewPage, aRect);
152
153 //determine space left in new upper frame
154 nSpace = fnRectX.GetHeight(aRect);
155 const SwViewShell *pSh = pNewUpper->getRootFrame()->GetCurrShell();
156 if ( IsInFootnote() ||
157 (pSh && pSh->GetViewOptions()->getBrowseMode()) ||
158 pNewUpper->IsCellFrame() ||
159 ( pNewUpper->IsInSct() && ( pNewUpper->IsSctFrame() ||
160 ( pNewUpper->IsColBodyFrame() &&
161 !pNewUpper->GetUpper()->GetPrev() &&
162 !pNewUpper->GetUpper()->GetNext() ) ) ) )
163 nSpace += pNewUpper->Grow( LONG_MAX, true );
164
165 if ( nMoveAnyway < 3 )
166 {
167 if ( nSpace )
168 {
169 // Do not notify footnotes which are stuck to the paragraph:
170 // This would require extremely confusing code, taking into
171 // account the widths
172 // and Flys, that in turn influence the footnotes, ...
173
174 // WouldFit_ can only be used if the width is the same and
175 // ONLY self-anchored Flys are present.
176
177 // WouldFit_ can also be used if ONLY Flys anchored
178 // somewhere else are present.
179 // In this case, the width doesn't even matter,
180 // because we're running a TestFormat in the new upper.
181 const sal_uInt8 nBwdMoveNecessaryResult =
182 BwdMoveNecessary( pNewPage, aRect);
183 const bool bObjsInNewUpper( nBwdMoveNecessaryResult == 2 ||
184 nBwdMoveNecessaryResult == 3 );
185
186 return WouldFit_( nSpace, pNewUpper, nMoveAnyway == 2,
187 bObjsInNewUpper );
188 }
189 // It's impossible for WouldFit_ to return a usable result if
190 // we have a fresh multi-column section - so we really have to
191 // float back unless there is no space.
192 return pNewUpper->IsInSct() && pNewUpper->IsColBodyFrame() &&
193 !fnRectX.GetWidth(pNewUpper->getFramePrintArea()) &&
194 ( pNewUpper->GetUpper()->GetPrev() ||
195 pNewUpper->GetUpper()->GetNext() );
196 }
197
198 // Check for space left in new upper
199 return nSpace != 0;
200 }
201 }
202 return false;
203}
204
205// Calc methods
206
207// Two little friendships form a secret society
208inline void PrepareLock( SwFlowFrame *pTab )
209{
210 pTab->LockJoin();
211}
212inline void PrepareUnlock( SwFlowFrame *pTab )
213{
214 pTab->UnlockJoin();
215
216}
217
218// hopefully, one day this function simply will return 'false'
219static bool lcl_IsCalcUpperAllowed( const SwFrame& rFrame )
220{
221 return !rFrame.GetUpper()->IsSctFrame() &&
222 !rFrame.GetUpper()->IsFooterFrame() &&
223 // No format of upper Writer fly frame
224 !rFrame.GetUpper()->IsFlyFrame() &&
225 !( rFrame.GetUpper()->IsTabFrame() && rFrame.GetUpper()->GetUpper()->IsInTab() ) &&
226 !( rFrame.IsTabFrame() && rFrame.GetUpper()->IsInTab() );
227}
228
247{
248 StackHack aHack;
249 if ( GetUpper() )
250 {
251 SwFrameDeleteGuard aDeleteGuard(this);
252 if ( lcl_IsCalcUpperAllowed( *this ) )
253 GetUpper()->Calc(pRenderContext);
254 OSL_ENSURE( GetUpper(), ":-( Layout unstable (Upper gone)." );
255 if ( !GetUpper() )
256 return;
257
258 const bool bCnt = IsContentFrame();
259 const bool bTab = IsTabFrame();
260 bool bNoSect = IsInSct();
261 bool bOldTabLock = false, bFoll = false;
262 SwFlowFrame* pThis = bCnt ? static_cast<SwContentFrame*>(this) : nullptr;
263
264 if ( bTab )
265 {
266 pThis = static_cast<SwTabFrame*>(this);
267 bOldTabLock = static_cast<SwTabFrame*>(this)->IsJoinLocked();
268 ::PrepareLock( static_cast<SwTabFrame*>(this) );
269 bFoll = pThis->IsFollow();
270 }
271 else if( IsSctFrame() )
272 {
273 pThis = static_cast<SwSectionFrame*>(this);
274 bFoll = pThis->IsFollow();
275 bNoSect = false;
276 }
277 else if ( bCnt )
278 {
279 bFoll = pThis->IsFollow();
280 if ( bFoll && GetPrev() )
281 {
282 // Do not follow the chain when we need only one instance
283 const SwTextFrame* pMaster = static_cast<SwContentFrame*>(this)->FindMaster();
284 if ( pMaster && pMaster->IsLocked() )
285 {
286 MakeAll(pRenderContext);
287 return;
288 }
289 }
290 }
291
292 // There is no format of previous frame, if current frame is a table
293 // frame and its previous frame wants to keep with it.
294 const bool bFormatPrev = !bTab ||
295 !GetPrev() ||
296 !GetPrev()->GetAttrSet()->GetKeep().GetValue();
297 if ( bFormatPrev )
298 {
299 SwFrame *pFrame = GetUpper()->Lower();
300 while ( pFrame != this )
301 {
302 OSL_ENSURE( pFrame, ":-( Layout unstable (this not found)." );
303 if ( !pFrame )
304 return; //Oioioioi ...
305
306 if ( !pFrame->isFrameAreaDefinitionValid() )
307 {
308 // A small interference that hopefully improves on the stability:
309 // If I'm Follow AND neighbor of a Frame before me, it would delete
310 // me when formatting. This as you can see could easily become a
311 // confusing situation that we want to avoid.
312 if ( bFoll && pFrame->IsFlowFrame() &&
313 SwFlowFrame::CastFlowFrame(pFrame)->IsAnFollow( pThis ) )
314 break;
315
316 bool const isLast(pFrame->GetNext() == this);
317 // note: this seems obvious but does *not* hold, a MakeAll()
318 // could move more than 1 frame backwards!
319 // that's why FindNext() is used below
320 // assert(pFrame->GetUpper() == GetUpper());
321 pFrame->MakeAll(pRenderContext);
322 if( IsSctFrame() && !static_cast<SwSectionFrame*>(this)->GetSection() )
323 break;
324 if (isLast && pFrame->GetUpper() != GetUpper())
325 {
326 assert(GetUpper()->Lower() == this
327 // empty section frames are created all the time...
328 || GetUpper()->Lower()->IsSctFrame()
329 // tab frame/section frame may split multiple times
330 || ( SwFlowFrame::CastFlowFrame(pFrame)
331 && SwFlowFrame::CastFlowFrame(GetUpper()->Lower())
332 && SwFlowFrame::CastFlowFrame(pFrame)->IsAnFollow(
333 SwFlowFrame::CastFlowFrame(GetUpper()->Lower()))
334 && (GetUpper()->Lower()->GetNext() == this
335 // if it's more than 10 pages long...
336 || (SwFlowFrame::CastFlowFrame(GetUpper()->Lower())->GetFollow()
337 == SwFlowFrame::CastFlowFrame(GetUpper()->Lower()->GetNext())
338 && GetUpper()->Lower()->GetNext()->GetNext() == this)
339 // pre-existing empty section frames may end up between them...
340 || GetUpper()->Lower()->GetNext()->IsSctFrame())));
341 break; // tdf#119109 frame was moved backward, prevent
342 // FindNext() returning a frame inside this if
343 } // this is a table!
344 }
345 // With ContentFrames, the chain may be broken while walking through
346 // it. Therefore we have to figure out the next frame in a bit more
347 // complicated way. However, I'll HAVE to get back to myself
348 // sometime again.
349 pFrame = pFrame->FindNext();
350
351 // If we started out in a SectionFrame, it might have happened that
352 // we landed in a Section Follow via the MakeAll calls.
353 // FindNext only gives us the SectionFrame, not it's content - we
354 // won't find ourselves anymore!
355 if( bNoSect && pFrame && pFrame->IsSctFrame() )
356 {
357 SwFrame* pCnt = static_cast<SwSectionFrame*>(pFrame)->ContainsAny();
358 if( pCnt )
359 pFrame = pCnt;
360 }
361 }
362 OSL_ENSURE( GetUpper(), "Layout unstable (Upper gone II)." );
363 if ( !GetUpper() )
364 return;
365
366 if ( lcl_IsCalcUpperAllowed( *this ) )
367 GetUpper()->Calc(pRenderContext);
368
369 OSL_ENSURE( GetUpper(), "Layout unstable (Upper gone III)." );
370 }
371
372 if ( bTab && !bOldTabLock )
373 ::PrepareUnlock( static_cast<SwTabFrame*>(this) );
374 }
375 MakeAll(pRenderContext);
376}
377
379{
380 // #i23129#, #i36347# - no format of upper Writer fly frame
381 if ( GetUpper() && !GetUpper()->IsFooterFrame() &&
382 !GetUpper()->IsFlyFrame() )
383 {
384 {
385 SwFrameDeleteGuard aDeleteGuard(this);
386 GetUpper()->Calc(getRootFrame()->GetCurrShell() ? getRootFrame()->GetCurrShell()->GetOut() : nullptr);
387 }
388 OSL_ENSURE( GetUpper(), ":-( Layout unstable (Upper gone)." );
389 if ( !GetUpper() )
390 return;
391 }
393 {
394 PrepareMake(getRootFrame()->GetCurrShell() ? getRootFrame()->GetCurrShell()->GetOut() : nullptr);
395 }
396 else
397 {
398 StackHack aHack;
399 MakeAll(IsRootFrame() ? nullptr : getRootFrame()->GetCurrShell()->GetOut());
400 }
401}
402
404{
405 StackHack aHack;
406 if( GetUpper() && !GetUpper()->IsSctFrame() )
407 {
408 const bool bCnt = IsContentFrame();
409 const bool bTab = IsTabFrame();
410 bool bNoSect = IsInSct();
411
412 std::optional<FlowFrameJoinLockGuard> tabGuard;
413 std::optional<SwFrameDeleteGuard> rowGuard;
414 SwFlowFrame* pThis = bCnt ? static_cast<SwContentFrame*>(this) : nullptr;
415
416 if ( bTab )
417 {
418 tabGuard.emplace(static_cast<SwTabFrame*>(this)); // tdf#125741
419 pThis = static_cast<SwTabFrame*>(this);
420 }
421 else if (IsRowFrame())
422 {
423 rowGuard.emplace(this); // tdf#125741 keep this alive
424 }
425 else if( IsSctFrame() )
426 {
427 pThis = static_cast<SwSectionFrame*>(this);
428 bNoSect = false;
429 }
430
432 GetUpper()->Calc(getRootFrame()->GetCurrShell() ? getRootFrame()->GetCurrShell()->GetOut() : nullptr);
433
434 OSL_ENSURE( GetUpper(), ":-( Layout unstable (Upper gone)." );
435 if ( !GetUpper() )
436 return;
437
438 bool const bFoll = pThis && pThis->IsFollow();
439
440 SwFrame *pFrame = GetUpper()->Lower();
441 while ( pFrame != this )
442 {
443 OSL_ENSURE( pFrame, ":-( Layout unstable (this not found)." );
444 if ( !pFrame )
445 return; //Oioioioi ...
446
447 if ( !pFrame->isFrameAreaDefinitionValid() )
448 {
449 // A small interference that hopefully improves on the stability:
450 // If I'm Follow AND neighbor of a Frame before me, it would delete
451 // me when formatting. This as you can see could easily become a
452 // confusing situation that we want to avoid.
453 if ( bFoll && pFrame->IsFlowFrame() &&
454 SwFlowFrame::CastFlowFrame(pFrame)->IsAnFollow( pThis ) )
455 break;
456
457 bool const isLast(pFrame->GetNext() == this);
458 pFrame->MakeAll(getRootFrame()->GetCurrShell()->GetOut());
459 if (isLast && pFrame->GetUpper() != GetUpper())
460 {
461 assert(GetUpper()->Lower() == this
462 // empty section frames are created all the time...
463 || GetUpper()->Lower()->IsSctFrame()
464 // tab frame/section frame may split multiple times
465 || ( SwFlowFrame::CastFlowFrame(pFrame)
466 && SwFlowFrame::CastFlowFrame(GetUpper()->Lower())
467 && SwFlowFrame::CastFlowFrame(pFrame)->IsAnFollow(
468 SwFlowFrame::CastFlowFrame(GetUpper()->Lower()))
469 && (GetUpper()->Lower()->GetNext() == this
470 // if it's more than 10 pages long...
471 || (SwFlowFrame::CastFlowFrame(GetUpper()->Lower())->GetFollow()
472 == SwFlowFrame::CastFlowFrame(GetUpper()->Lower()->GetNext())
473 && GetUpper()->Lower()->GetNext()->GetNext() == this)
474 // pre-existing empty section frames may end up between them...
475 || GetUpper()->Lower()->GetNext()->IsSctFrame())));
476 break; // tdf#119109 frame was moved backward, prevent
477 // FindNext() returning a frame inside this if
478 } // this is a table!
479 }
480 // With ContentFrames, the chain may be broken while walking through
481 // it. Therefore we have to figure out the next frame in a bit more
482 // complicated way. However, I'll HAVE to get back to myself
483 // sometime again.
484 pFrame = pFrame->FindNext();
485 if( bNoSect && pFrame && pFrame->IsSctFrame() )
486 {
487 SwFrame* pCnt = static_cast<SwSectionFrame*>(pFrame)->ContainsAny();
488 if( pCnt )
489 pFrame = pCnt;
490 }
491 }
492 OSL_ENSURE( GetUpper(), "Layout unstable (Upper gone II)." );
493 if ( !GetUpper() )
494 return;
495
496 GetUpper()->Calc(getRootFrame()->GetCurrShell()->GetOut());
497
498 OSL_ENSURE( GetUpper(), "Layout unstable (Upper gone III)." );
499 }
500 Calc(getRootFrame()->GetCurrShell() ? getRootFrame()->GetCurrShell()->GetOut() : nullptr);
501}
502
503// Here we return GetPrev(); however we will ignore empty SectionFrames
504static SwFrame* lcl_Prev( SwFrame* pFrame, bool bSectPrv = true )
505{
506 SwFrame* pRet = pFrame->GetPrev();
507 if( !pRet && pFrame->GetUpper() && pFrame->GetUpper()->IsSctFrame() &&
508 bSectPrv && !pFrame->IsColumnFrame() )
509 pRet = pFrame->GetUpper()->GetPrev();
510 while( pRet && pRet->IsSctFrame() &&
511 !static_cast<SwSectionFrame*>(pRet)->GetSection() )
512 pRet = pRet->GetPrev();
513 return pRet;
514}
515
517{
518 SwFrame *pRet = pFrame;
519 do
520 {
521 pRet = lcl_Prev( pRet );
522 } while ( pRet && pRet->IsTextFrame() && static_cast<SwTextFrame*>(pRet)->IsHiddenNow() );
523 return pRet;
524}
525
527{
529 return;
530
532 bool bUseUpper = false;
533 SwFrame* pPrv = lcl_Prev( this );
534 if ( pPrv &&
535 ( !pPrv->IsContentFrame() ||
536 ( static_cast<SwContentFrame*>(pPrv)->GetFollow() != this ) )
537 )
538 {
539 if ( !StackHack::IsLocked() &&
540 ( !IsInSct() || IsSctFrame() ) &&
541 !pPrv->IsSctFrame() &&
542 !pPrv->GetAttrSet()->GetKeep().GetValue()
543 )
544 {
545 pPrv->Calc(getRootFrame()->GetCurrShell() ? getRootFrame()->GetCurrShell()->GetOut() : nullptr); // This may cause Prev to vanish!
546 }
547 else if ( pPrv->getFrameArea().Top() == 0 )
548 {
549 bUseUpper = true;
550 }
551 }
552
553 pPrv = lcl_Prev( this, false );
554 const SwFrameType nMyType = GetType();
555 SwRectFnSet aRectFnSet((IsCellFrame() && GetUpper() ? GetUpper() : this));
556 if ( !bUseUpper && pPrv )
557 {
559 aFrm.Pos( pPrv->getFrameArea().Pos() );
560
561 if( FRM_NEIGHBOUR & nMyType )
562 {
563 const bool bR2L = IsRightToLeft();
564
565 if( bR2L )
566 {
567 aRectFnSet.SetPosX( aFrm, aRectFnSet.GetLeft(aFrm) - aRectFnSet.GetWidth(aFrm) );
568 }
569 else
570 {
571 aRectFnSet.SetPosX( aFrm, aRectFnSet.GetLeft(aFrm) + aRectFnSet.GetWidth(pPrv->getFrameArea()) );
572 }
573
574 // cells may now leave their uppers
575 if( aRectFnSet.IsVert() && SwFrameType::Cell & nMyType )
576 {
577 aFrm.Pos().setX(aFrm.Pos().getX() - aFrm.Width() + pPrv->getFrameArea().Width());
578 }
579 }
580 else if( aRectFnSet.IsVert() && FRM_NOTE_VERT & nMyType )
581 {
582 if ( aRectFnSet.IsVertL2R() )
583 {
584 aFrm.Pos().setX(aFrm.Pos().getX() + pPrv->getFrameArea().Width());
585 }
586 else
587 {
588 aFrm.Pos().setX(aFrm.Pos().getX() - aFrm.Width());
589 }
590 }
591 else
592 {
593 aFrm.Pos().setY(aFrm.Pos().getY() + pPrv->getFrameArea().Height());
594 }
595 }
596 else if ( GetUpper() )
597 {
598 // If parent frame is a footer frame and its <ColLocked()>, then
599 // do *not* calculate it.
600 // NOTE: Footer frame is <ColLocked()> during its
601 // <FormatSize(..)>, which is called from <Format(..)>, which
602 // is called from <MakeAll()>, which is called from <Calc()>.
603 // #i56850#
604 // - no format of upper Writer fly frame, which is anchored
605 // at-paragraph or at-character.
606 if ( !GetUpper()->IsTabFrame() &&
607 !( IsTabFrame() && GetUpper()->IsInTab() ) &&
608 !GetUpper()->IsSctFrame() &&
609 !dynamic_cast<SwFlyAtContentFrame*>(GetUpper()) &&
610 !( GetUpper()->IsFooterFrame() &&
611 GetUpper()->IsColLocked() )
612 )
613 {
614 GetUpper()->Calc(getRootFrame()->GetCurrShell()->GetOut());
615 }
616 pPrv = lcl_Prev( this, false );
617 if ( !bUseUpper && pPrv )
618 {
620 aFrm.Pos( pPrv->getFrameArea().Pos() );
621
622 if( FRM_NEIGHBOUR & nMyType )
623 {
624 const bool bR2L = IsRightToLeft();
625
626 if( bR2L )
627 {
628 aRectFnSet.SetPosX( aFrm, aRectFnSet.GetLeft(aFrm) - aRectFnSet.GetWidth(aFrm) );
629 }
630 else
631 {
632 aRectFnSet.SetPosX( aFrm, aRectFnSet.GetLeft(aFrm) + aRectFnSet.GetWidth(pPrv->getFrameArea()) );
633 }
634
635 // cells may now leave their uppers
636 if( aRectFnSet.IsVert() && SwFrameType::Cell & nMyType )
637 {
638 aFrm.Pos().setX(aFrm.Pos().getX() - aFrm.Width() + pPrv->getFrameArea().Width());
639 }
640 }
641 else if( aRectFnSet.IsVert() && FRM_NOTE_VERT & nMyType )
642 {
643 aFrm.Pos().setX(aFrm.Pos().getX() - aFrm.Width());
644 }
645 else
646 {
647 aFrm.Pos().setY(aFrm.Pos().getY() + pPrv->getFrameArea().Height());
648 }
649 }
650 else
651 {
653 aFrm.Pos( GetUpper()->getFrameArea().Pos() );
654
655 if( GetUpper()->IsFlyFrame() )
656 {
657 aFrm.Pos() += static_cast<SwFlyFrame*>(GetUpper())->ContentPos();
658 }
659 else
660 {
661 aFrm.Pos() += GetUpper()->getFramePrintArea().Pos();
662 }
663
664 if( FRM_NEIGHBOUR & nMyType && IsRightToLeft() )
665 {
666 if( aRectFnSet.IsVert() )
667 {
668 aFrm.Pos().setY(aFrm.Pos().getY() + GetUpper()->getFramePrintArea().Height() - aFrm.Height());
669 }
670 else
671 {
672 aFrm.Pos().setX(aFrm.Pos().getX() + GetUpper()->getFramePrintArea().Width() - aFrm.Width());
673 }
674 }
675 else if( aRectFnSet.IsVert() && !aRectFnSet.IsVertL2R() && FRM_NOTE_VERT & nMyType )
676 {
677 aFrm.Pos().setX(aFrm.Pos().getX() - aFrm.Width() + GetUpper()->getFramePrintArea().Width());
678 }
679 }
680 }
681 else
682 {
684 aFrm.Pos().setX(0);
685 aFrm.Pos().setY(0);
686 }
687
688 if( IsBodyFrame() && aRectFnSet.IsVert() && !aRectFnSet.IsVertL2R() && GetUpper() )
689 {
691 aFrm.Pos().setX(aFrm.Pos().getX() + GetUpper()->getFramePrintArea().Width() - aFrm.Width());
692 }
693
695}
696
697// #i28701# - new type <SwSortedObjs>
698static void lcl_CheckObjects(SwSortedObjs& rSortedObjs, const SwFrame* pFrame, tools::Long& rBot)
699{
700 // And then there can be paragraph anchored frames that sit below their paragraph.
701 tools::Long nMax = 0;
702 for (SwAnchoredObject* pObj : rSortedObjs)
703 {
704 // #i28701# - consider changed type of <SwSortedObjs>
705 // entries.
706 tools::Long nTmp = 0;
707 if ( auto pFly = pObj->DynCastFlyFrame() )
708 {
709 if( pFly->getFrameArea().Top() != FAR_AWAY &&
710 ( pFrame->IsPageFrame() ? pFly->IsFlyLayFrame() :
711 ( pFly->IsFlyAtContentFrame() &&
712 ( pFrame->IsBodyFrame() ? pFly->GetAnchorFrame()->IsInDocBody() :
713 pFly->GetAnchorFrame()->IsInFootnote() ) ) ) )
714 {
715 nTmp = pFly->getFrameArea().Bottom();
716 }
717 }
718 else
719 nTmp = pObj->GetObjRect().Bottom();
720 nMax = std::max( nTmp, nMax );
721 }
722 ++nMax; // Lower edge vs. height!
723 rBot = std::max( rBot, nMax );
724}
725
726size_t SwPageFrame::GetContentHeight(const tools::Long nTop, const tools::Long nBottom) const
727{
728 OSL_ENSURE(!(FindBodyCont() && FindBodyCont()->Lower() && FindBodyCont()->Lower()->IsColumnFrame()),
729 "SwPageFrame::GetContentHeight(): No support for columns.");
730
731 // In pages without columns, the content defines the size.
732 tools::Long nBot = getFrameArea().Top() + nTop;
733 const SwFrame *pFrame = Lower();
734 while (pFrame)
735 {
736 tools::Long nTmp = 0;
737 const SwFrame *pCnt = static_cast<const SwLayoutFrame*>(pFrame)->ContainsAny();
738 while (pCnt && (pCnt->GetUpper() == pFrame ||
739 static_cast<const SwLayoutFrame*>(pFrame)->IsAnLower(pCnt)))
740 {
741 nTmp += pCnt->getFrameArea().Height();
742 if (pCnt->IsTextFrame() &&
743 static_cast<const SwTextFrame*>(pCnt)->IsUndersized())
744 {
745 // This TextFrame would like to be a bit bigger.
746 nTmp += static_cast<const SwTextFrame*>(pCnt)->GetParHeight()
747 - pCnt->getFramePrintArea().Height();
748 }
749 else if (pCnt->IsSctFrame())
750 {
751 // Grow if undersized, but don't shrink if oversized.
752 const auto delta = static_cast<const SwSectionFrame*>(pCnt)->CalcUndersize();
753 if (delta > 0)
754 nTmp += delta;
755 }
756
757 pCnt = pCnt->FindNext();
758 }
759 // Consider invalid body frame properties
760 if (pFrame->IsBodyFrame() &&
761 (!pFrame->isFrameAreaSizeValid() ||
762 !pFrame->isFramePrintAreaValid()) &&
763 (pFrame->getFrameArea().Height() < pFrame->getFramePrintArea().Height())
764 )
765 {
766 nTmp = std::min(nTmp, pFrame->getFrameArea().Height());
767 }
768 else
769 {
770 // Assert invalid lower property
771 OSL_ENSURE(!(pFrame->getFrameArea().Height() < pFrame->getFramePrintArea().Height()),
772 "SwPageFrame::GetContentHeight(): Lower with frame height < printing height");
773 nTmp += pFrame->getFrameArea().Height() - pFrame->getFramePrintArea().Height();
774 }
775 if (!pFrame->IsBodyFrame())
776 nTmp = std::min(nTmp, pFrame->getFrameArea().Height());
777 nBot += nTmp;
778 // Here we check whether paragraph anchored objects
779 // protrude outside the Body/FootnoteCont.
780 if (m_pSortedObjs && !pFrame->IsHeaderFrame() &&
781 !pFrame->IsFooterFrame())
782 lcl_CheckObjects(*m_pSortedObjs, pFrame, nBot);
783 pFrame = pFrame->GetNext();
784 }
785 nBot += nBottom;
786 // And the page anchored ones
787 if (m_pSortedObjs)
788 lcl_CheckObjects(*m_pSortedObjs, this, nBot);
789 nBot -= getFrameArea().Top();
790
791 return nBot;
792}
793
795{
797
798 const SwRect aOldRect( getFrameArea() ); // Adjust root size
799 const SwLayNotify aNotify( this ); // takes care of the notification in the dtor
800 std::optional<SwBorderAttrAccess> oAccess;
801 const SwBorderAttrs*pAttrs = nullptr;
802
804 {
806 {
807 setFrameAreaPositionValid(true); // positioning of the pages is taken care of by the root frame
808 }
809
811 {
812 if ( IsEmptyPage() )
813 {
815 aFrm.Width( 0 );
816 aFrm.Height( 0 );
817
819 aPrt.Width( 0 );
820 aPrt.Height( 0 );
821 aPrt.Left( 0 );
822 aPrt.Top( 0 );
823
826 }
827 else
828 {
829 if (!oAccess)
830 {
831 oAccess.emplace(SwFrame::GetCache(), this);
832 pAttrs = oAccess->Get();
833 }
834 assert(pAttrs);
835
836 SwRootFrame* pRootFrame = getRootFrame();
837 SwViewShell* pSh = pRootFrame->GetCurrShell();
838 if (pSh && pSh->GetViewOptions()->getBrowseMode())
839 {
840 // In BrowseView, we use fixed settings
841 const Size aBorder = pRenderContext->PixelToLogic( pSh->GetBrowseBorder() );
842 const tools::Long nTop = pAttrs->CalcTopLine() + aBorder.Height();
843 const tools::Long nBottom = pAttrs->CalcBottomLine()+ aBorder.Height();
844
845 tools::Long nWidth = GetUpper() ? static_cast<SwRootFrame*>(GetUpper())->GetBrowseWidth() : 0;
846 const auto nDefWidth = pSh->GetBrowseWidth();
847 if (nWidth < nDefWidth)
848 nWidth = nDefWidth;
849 nWidth += + 2 * aBorder.Width();
850
851 constexpr tools::Long constTwips_2cm = o3tl::toTwips(2, o3tl::Length::cm);
852 nWidth = std::max(nWidth, 2L * aBorder.Width() + constTwips_2cm);
853
854 {
856 aFrm.Width( nWidth );
857
858 SwLayoutFrame *pBody = FindBodyCont();
859 if ( pBody && pBody->Lower() && pBody->Lower()->IsColumnFrame() )
860 {
861 // Columns have a fixed height
862 aFrm.Height( pAttrs->GetSize().Height() );
863 }
864 else
865 {
866 // In pages without columns, the content defines the size.
867 tools::Long nBot = GetContentHeight(nTop, nBottom);
868
869 // #i35143# - If second page frame
870 // exists, the first page doesn't have to fulfill the
871 // visible area.
872 if ( !GetPrev() && !GetNext() )
873 {
874 nBot = std::max( nBot, pSh->VisArea().Height() );
875 }
876 // #i35143# - Assure, that the page
877 // doesn't exceed the defined browse height.
878 aFrm.Height( std::min( nBot, BROWSE_HEIGHT ) );
879 }
880 }
881
882 {
884 aPrt.Left ( pAttrs->CalcLeftLine() + aBorder.Width() );
885 aPrt.Top ( nTop );
886 aPrt.Width( getFrameArea().Width() - ( aPrt.Left() + pAttrs->CalcRightLine() + aBorder.Width() ) );
887 aPrt.Height( getFrameArea().Height() - (nTop + nBottom) );
888 }
889
892 continue;
893 }
894 else if (pSh && pSh->GetViewOptions()->IsWhitespaceHidden() && pRootFrame->GetLastPage() != this)
895 {
896 tools::Long height = 0;
897 SwLayoutFrame *pBody = FindBodyCont();
898 if ( pBody && pBody->Lower() && pBody->Lower()->IsColumnFrame() )
899 {
900 // Columns have a fixed height
901 height = pAttrs->GetSize().Height();
902 }
903 else
904 {
905 // No need for borders.
906 height = GetContentHeight(0, 0);
907 }
908
909 if (height > 0)
910 {
911 ChgSize(Size(getFrameArea().Width(), height));
913 aPrt.Top(0);
914 aPrt.Height(height);
917 continue;
918 }
919
920 // Fallback to default formatting. Especially relevant
921 // when loading a doc when Hide Whitespace is enabled.
922 // Heights are zero initially.
923 }
924
925 // Set FixSize. For pages, this is not done from Upper, but from
926 // the attribute.
927 //FIXME: This resets the size when (isFrameAreaSizeValid() && !isFramePrintAreaValid()).
928 {
930 aFrm.SSize( pAttrs->GetSize() );
931 }
932 Format( pRenderContext, pAttrs );
933 }
934 }
935 } //while ( !isFrameAreaPositionValid() || !isFrameAreaSizeValid() || !isFramePrintAreaValid() )
936
937 if ( getFrameArea() != aOldRect && GetUpper() )
938 static_cast<SwRootFrame*>(GetUpper())->CheckViewLayout( nullptr, nullptr );
939
940 OSL_ENSURE( !GetUpper() || GetUpper()->getFramePrintArea().Width() >= getFrameArea().Width(),
941 "Upper (Root) must be wide enough to contain the widest page");
942}
943
945{
947
948 // takes care of the notification in the dtor
949 const SwLayNotify aNotify( this );
950 bool bVert = IsVertical();
951
953
954 std::optional<SwBorderAttrAccess> oAccess;
955 const SwBorderAttrs*pAttrs = nullptr;
956
958 {
960 MakePos();
961
962 if ( GetUpper() )
963 {
964 // NEW TABLES
965 if ( IsLeaveUpperAllowed() )
966 {
967 if ( !isFrameAreaSizeValid() )
968 {
970 }
971 }
972 else
973 {
974 if ( !isFrameAreaSizeValid() )
975 {
976 // Set FixSize; VarSize is set by Format() after calculating the PrtArea
979
980 if (IsNeighbourFrame() && !bVert)
981 {
982 SwTwips nPrtHeight = (GetUpper()->getFramePrintArea().*fnRect->fnGetHeight)();
983 const tools::Long nDiff = nPrtHeight - (getFrameArea().*fnRect->fnGetHeight)();
984 (aFrm.*fnRect->fnAddBottom)( nDiff );
985 }
986 else
987 {
988 SwTwips nPrtWidth = (GetUpper()->getFramePrintArea().*fnRect->fnGetWidth)();
989 if( bVert && ( IsBodyFrame() || IsFootnoteContFrame() ) )
990 {
991 SwFrame* pNxt = GetPrev();
992 while( pNxt && !pNxt->IsHeaderFrame() )
993 pNxt = pNxt->GetPrev();
994 if( pNxt )
995 nPrtWidth -= pNxt->getFrameArea().Height();
996 pNxt = GetNext();
997 while( pNxt && !pNxt->IsFooterFrame() )
998 pNxt = pNxt->GetNext();
999 if( pNxt )
1000 nPrtWidth -= pNxt->getFrameArea().Height();
1001 }
1002
1003 const tools::Long nDiff = nPrtWidth - (getFrameArea().*fnRect->fnGetWidth)();
1004 if(IsRightToLeft() )
1005 (aFrm.*fnRect->fnSubLeft)( nDiff );
1006 else
1007 (aFrm.*fnRect->fnAddRight)( nDiff );
1008 }
1009 }
1010 else
1011 {
1012 // Don't leave your upper
1013 const SwTwips nDeadLine = (GetUpper()->*fnRect->fnGetPrtBottom)();
1014 if( (getFrameArea().*fnRect->fnOverStep)( nDeadLine ) )
1015 {
1016 setFrameAreaSizeValid(false);
1017 }
1018 }
1019 }
1020 }
1021
1023 {
1024 if ( !oAccess )
1025 {
1026 oAccess.emplace(SwFrame::GetCache(), this);
1027 pAttrs = oAccess->Get();
1028 }
1029 Format( getRootFrame()->GetCurrShell()->GetOut(), pAttrs );
1030 }
1031 } //while ( !isFrameAreaPositionValid() || !isFrameAreaSizeValid() || !isFramePrintAreaValid() )
1032}
1033
1035{
1036 if (GetDoc().GetDocumentSettingManager().get( DocumentSettingId::COLLAPSE_EMPTY_CELL_PARA )
1037 && GetText().isEmpty())
1038 {
1039 SwNodeOffset nIdx=GetIndex();
1040 const SwEndNode *pNdBefore=GetNodes()[nIdx-1]->GetEndNode();
1041 const SwEndNode *pNdAfter=GetNodes()[nIdx+1]->GetEndNode();
1042
1043 // The paragraph is collapsed only if the NdAfter is the end of a cell
1044 bool bInTable = FindTableNode( ) != nullptr;
1045
1046 SwSortedObjs* pObjs = getLayoutFrame( GetDoc().getIDocumentLayoutAccess().GetCurrentLayout() )->GetDrawObjs( );
1047 const size_t nObjs = ( pObjs != nullptr ) ? pObjs->size( ) : 0;
1048
1049 return pNdBefore!=nullptr && pNdAfter!=nullptr && nObjs == 0 && bInTable;
1050 }
1051
1052 return false;
1053}
1054
1056{
1057 if (!IsTextFrame())
1058 return false;
1059
1060 const SwTextFrame *pTextFrame = static_cast<const SwTextFrame*>(this);
1061 const SwTextNode *pTextNode = pTextFrame->GetTextNodeForParaProps();
1062 // TODO this SwTextNode function is pointless and should be merged in here
1063 return pTextFrame->GetText().isEmpty() && pTextNode && pTextNode->IsCollapse();
1064}
1065
1067{
1068 if ( isFramePrintAreaValid() )
1069 return;
1070
1072 SwRectFnSet aRectFnSet(this);
1073 const bool bTextFrame = IsTextFrame();
1074 SwTwips nUpper = 0;
1075 if ( bTextFrame && static_cast<SwTextFrame*>(this)->IsHiddenNow() )
1076 {
1077 if ( static_cast<SwTextFrame*>(this)->HasFollow() )
1078 static_cast<SwTextFrame*>(this)->JoinFrame();
1079
1080 if( aRectFnSet.GetHeight(getFramePrintArea()) )
1081 {
1082 static_cast<SwTextFrame*>(this)->HideHidden();
1083 }
1084
1085 {
1087 aPrt.Pos().setX(0);
1088 aPrt.Pos().setY(0);
1089 aRectFnSet.SetWidth( aPrt, aRectFnSet.GetWidth(getFrameArea()) );
1090 aRectFnSet.SetHeight( aPrt, 0 );
1091 }
1092
1093 nUpper = -( aRectFnSet.GetHeight(getFrameArea()) );
1094 }
1095 else
1096 {
1097 // Simplification: ContentFrames are always variable in height!
1098
1099 // At the FixSize, the surrounding Frame enforces the size;
1100 // the borders are simply subtracted.
1101 const tools::Long nLeft = rAttrs.CalcLeft( this );
1102 const tools::Long nRight = rAttrs.CalcRight( this );
1103 aRectFnSet.SetXMargins( *this, nLeft, nRight );
1104
1106 SwTwips nWidthArea;
1107 if( pSh && 0!=(nWidthArea=aRectFnSet.GetWidth(pSh->VisArea())) &&
1108 GetUpper()->IsPageBodyFrame() && // but not for BodyFrames in Columns
1109 pSh->GetViewOptions()->getBrowseMode() )
1110 {
1111 // Do not protrude the edge of the visible area. The page may be
1112 // wider, because there may be objects with excess width
1113 // (RootFrame::ImplCalcBrowseWidth())
1114 tools::Long nMinWidth = 0;
1115
1116 for (size_t i = 0; GetDrawObjs() && i < GetDrawObjs()->size(); ++i)
1117 {
1118 // #i28701# - consider changed type of
1119 // <SwSortedObjs> entries
1120 SwAnchoredObject* pObj = (*GetDrawObjs())[i];
1121 const SwFrameFormat& rFormat = pObj->GetFrameFormat();
1122 const bool bFly = pObj->DynCastFlyFrame() != nullptr;
1123 if ((bFly && (FAR_AWAY == pObj->GetObjRect().Width()))
1124 || rFormat.GetFrameSize().GetWidthPercent())
1125 {
1126 continue;
1127 }
1128
1129 if ( RndStdIds::FLY_AS_CHAR == rFormat.GetAnchor().GetAnchorId() )
1130 {
1131 nMinWidth = std::max( nMinWidth,
1132 bFly ? rFormat.GetFrameSize().GetWidth()
1133 : pObj->GetObjRect().Width() );
1134 }
1135 }
1136
1137 const Size aBorder = pSh->GetOut()->PixelToLogic( pSh->GetBrowseBorder() );
1138 tools::Long nWidth = nWidthArea - 2 * ( IsVertical() ? aBorder.Height() : aBorder.Width() );
1139 nWidth -= aRectFnSet.GetLeft(getFramePrintArea());
1140 nWidth -= rAttrs.CalcRightLine();
1141 nWidth = std::max( nMinWidth, nWidth );
1142
1144 aRectFnSet.SetWidth( aPrt, std::min( nWidth, aRectFnSet.GetWidth(aPrt) ) );
1145 }
1146
1147 if ( aRectFnSet.GetWidth(getFramePrintArea()) <= MINLAY )
1148 {
1149 // The PrtArea should already be at least MINLAY wide, matching the
1150 // minimal values of the UI
1152 aRectFnSet.SetWidth( aPrt, std::min( tools::Long(MINLAY), aRectFnSet.GetWidth(getFrameArea()) ) );
1153 SwTwips nTmp = aRectFnSet.GetWidth(getFrameArea()) - aRectFnSet.GetWidth(aPrt);
1154
1155 if( aRectFnSet.GetLeft(aPrt) > nTmp )
1156 {
1157 aRectFnSet.SetLeft( aPrt, nTmp );
1158 }
1159 }
1160
1161 // The following rules apply for VarSize:
1162 // 1. The first entry of a chain has no top border
1163 // 2. There is never a bottom border
1164 // 3. The top border is the maximum of the distance
1165 // of Prev downwards and our own distance upwards
1166 // Those three rules apply when calculating spacings
1167 // that are given by UL- and LRSpace. There might be a spacing
1168 // in all directions however; this may be caused by borders
1169 // and / or shadows.
1170 // 4. The spacing for TextFrames corresponds to the interline lead,
1171 // at a minimum.
1172
1173 nUpper = CalcUpperSpace( &rAttrs );
1174
1175 SwTwips nLower = CalcLowerSpace( &rAttrs );
1176 if (IsCollapse()) {
1177 nUpper=0;
1178 nLower=0;
1179 }
1180
1181 {
1183 aRectFnSet.SetPosY( aPrt, !aRectFnSet.IsVert() ? nUpper : nLower);
1184 }
1185
1186 nUpper += nLower;
1187 nUpper -= aRectFnSet.GetHeight(getFrameArea()) - aRectFnSet.GetHeight(getFramePrintArea());
1188 }
1189 // If there's a difference between old and new size, call Grow() or
1190 // Shrink() respectively.
1191 if ( nUpper )
1192 {
1193 if ( nUpper > 0 )
1194 GrowFrame( nUpper );
1195 else
1196 ShrinkFrame( -nUpper );
1197 }
1198}
1199
1200#define STOP_FLY_FORMAT 10
1201// - loop prevention
1202const int cnStopFormat = 15;
1203
1204inline void ValidateSz( SwFrame *pFrame )
1205{
1206 if ( pFrame )
1207 {
1208 pFrame->setFrameAreaSizeValid(true);
1209 pFrame->setFramePrintAreaValid(true);
1210 }
1211}
1212
1214{
1215 OSL_ENSURE( GetUpper(), "no Upper?" );
1216 OSL_ENSURE( IsTextFrame(), "MakeAll(), NoText" );
1217
1218 if ( !IsFollow() && StackHack::IsLocked() )
1219 return;
1220
1221 if ( IsJoinLocked() )
1222 return;
1223
1224 OSL_ENSURE( !static_cast<SwTextFrame*>(this)->IsSwapped(), "Calculation of a swapped frame" );
1225
1226 StackHack aHack;
1227
1228 if ( static_cast<SwTextFrame*>(this)->IsLocked() )
1229 {
1230 OSL_FAIL( "Format for locked TextFrame." );
1231 return;
1232 }
1233
1234 std::optional<SwFrameDeleteGuard> oDeleteGuard(std::in_place, this);
1235 LockJoin();
1236 tools::Long nFormatCount = 0;
1237 // - loop prevention
1238 int nConsecutiveFormatsWithoutChange = 0;
1240
1241 // takes care of the notification in the dtor
1242 std::optional<SwContentNotify> oNotify( std::in_place, this );
1243
1244 // as long as bMakePage is true, a new page can be created (exactly once)
1245 bool bMakePage = true;
1246 // bMovedBwd gets set to true when the frame flows backwards
1247 bool bMovedBwd = false;
1248 // as long as bMovedFwd is false, the Frame may flow backwards (until
1249 // it has been moved forward once)
1250 bool bMovedFwd = false;
1251 sal_Bool bFormatted = false; // For the widow/orphan rules, we encourage the
1252 // last ContentFrame of a chain to format. This only
1253 // needs to happen once. Every time the Frame is
1254 // moved, the flag will have to be reset.
1255 bool bMustFit = false; // Once the emergency brake is pulled,
1256 // no other prepares will be triggered
1257 bool bFitPromise = false; // If a paragraph didn't fit, but promises
1258 // with WouldFit that it would adjust accordingly,
1259 // this flag is set. If it turns out that it
1260 // didn't keep it's promise, we can act in a
1261 // controlled fashion.
1262 const bool bFly = IsInFly();
1263 const bool bTab = IsInTab();
1264 const bool bFootnote = IsInFootnote();
1265 const bool bSct = IsInSct();
1266 Point aOldFramePos; // This is so we can compare with the last pos
1267 Point aOldPrtPos; // and determine whether it makes sense to Prepare
1268
1269 SwBorderAttrAccess aAccess( SwFrame::GetCache(), this );
1270 const SwBorderAttrs &rAttrs = *aAccess.Get();
1271
1272 if ( !IsFollow() && rAttrs.JoinedWithPrev( *(this) ) )
1273 {
1274 oNotify->SetBordersJoinedWithPrev();
1275 }
1276
1277 const bool bKeep = IsKeep(rAttrs.GetAttrSet().GetKeep(), GetBreakItem());
1278
1279 std::unique_ptr<SwSaveFootnoteHeight> pSaveFootnote;
1280 if ( bFootnote )
1281 {
1282 SwFootnoteFrame *pFootnote = FindFootnoteFrame();
1283 SwSectionFrame* pSct = pFootnote->FindSctFrame();
1284 if ( !static_cast<SwTextFrame*>(pFootnote->GetRef())->IsLocked() )
1285 {
1286 SwFootnoteBossFrame* pBoss = pFootnote->GetRef()->FindFootnoteBossFrame(
1287 pFootnote->GetAttr()->GetFootnote().IsEndNote() );
1288 if( !pSct || pSct->IsColLocked() || !pSct->Growable() )
1289 pSaveFootnote.reset( new SwSaveFootnoteHeight( pBoss,
1290 static_cast<SwTextFrame*>(pFootnote->GetRef())->GetFootnoteLine( pFootnote->GetAttr() ) ) );
1291 }
1292 }
1293
1294 if ( GetUpper()->IsSctFrame() &&
1295 HasFollow() && !GetFollow()->IsDeleteForbidden() &&
1296 &GetFollow()->GetFrame() == GetNext() )
1297 {
1298 static_cast<SwTextFrame&>(*this).JoinFrame();
1299 }
1300
1301 // #i28701# - move master forward, if it has to move,
1302 // because of its object positioning.
1303 if ( !static_cast<SwTextFrame*>(this)->IsFollow() )
1304 {
1305 sal_uInt32 nToPageNum = 0;
1306 const bool bMoveFwdByObjPos = SwLayouter::FrameMovedFwdByObjPos(
1307 *(GetAttrSet()->GetDoc()),
1308 *static_cast<SwTextFrame*>(this),
1309 nToPageNum );
1310 // #i58182#
1311 // Also move a paragraph forward, which is the first one inside a table cell.
1312 if ( bMoveFwdByObjPos &&
1313 FindPageFrame()->GetPhyPageNum() < nToPageNum &&
1314 ( lcl_Prev( this ) ||
1315 GetUpper()->IsCellFrame() ||
1316 ( GetUpper()->IsSctFrame() &&
1317 GetUpper()->GetUpper()->IsCellFrame() ) ) &&
1318 IsMoveable() )
1319 {
1320 bMovedFwd = true;
1321 MoveFwd( bMakePage, false );
1322 }
1323 }
1324
1325 // If a Follow sits next to its Master and doesn't fit, we know it can
1326 // be moved right now.
1327 if ( lcl_Prev( this ) && static_cast<SwTextFrame*>(this)->IsFollow() && IsMoveable() )
1328 {
1329 bMovedFwd = true;
1330 // If follow frame is in table, its master will be the last in the
1331 // current table cell. Thus, invalidate the printing area of the master.
1332 if ( IsInTab() )
1333 {
1334 lcl_Prev( this )->InvalidatePrt();
1335 }
1336 MoveFwd( bMakePage, false );
1337 }
1338
1339 // Check footnote content for forward move.
1340 // If a content of a footnote is on a prior page/column as its invalid
1341 // reference, it can be moved forward.
1343 {
1344 SwFootnoteFrame* pFootnote = FindFootnoteFrame();
1345 SwContentFrame* pRefCnt = pFootnote ? pFootnote->GetRef() : nullptr;
1346
1347 if ( pRefCnt && !pRefCnt->isFrameAreaDefinitionValid() )
1348 {
1349 SwFootnoteBossFrame* pFootnoteBossOfFootnote = pFootnote->FindFootnoteBossFrame();
1350 SwFootnoteBossFrame* pFootnoteBossOfRef = pRefCnt->FindFootnoteBossFrame();
1351 //<loop of movefwd until condition held or no move>
1352 if ( pFootnoteBossOfFootnote && pFootnoteBossOfRef &&
1353 pFootnoteBossOfFootnote != pFootnoteBossOfRef &&
1354 pFootnoteBossOfFootnote->IsBefore( pFootnoteBossOfRef ) )
1355 {
1356 bMovedFwd = true;
1357 MoveFwd( bMakePage, false );
1358 }
1359 }
1360 }
1361
1362 SwRectFnSet aRectFnSet(this);
1363
1364 SwFrame const* pMoveBwdPre(nullptr);
1365 bool isMoveBwdPreValid(false);
1366
1367 SwRect aOldFrame_StopFormat, aOldFrame_StopFormat2;
1368 SwRect aOldPrt_StopFormat, aOldPrt_StopFormat2;
1369
1371 {
1372 // - loop prevention
1373 aOldFrame_StopFormat2 = aOldFrame_StopFormat;
1374 aOldPrt_StopFormat2 = aOldPrt_StopFormat;
1375 aOldFrame_StopFormat = getFrameArea();
1376 aOldPrt_StopFormat = getFramePrintArea();
1377
1378 bool bMoveable = IsMoveable();
1379 if (bMoveable)
1380 {
1381 SwFrame *pPre = GetIndPrev();
1382 if ( CheckMoveFwd( bMakePage, bKeep, bMovedBwd ) )
1383 {
1384 aRectFnSet.Refresh(this);
1385 bMovedFwd = true;
1386 if ( bMovedBwd )
1387 {
1388 // While flowing back, the Upper was encouraged to
1389 // completely re-paint itself. We can skip this now after
1390 // flowing back and forth.
1392 // The predecessor was invalidated, so this is obsolete as well now.
1393 assert(pPre);
1394 if ((pPre == pMoveBwdPre && isMoveBwdPreValid) && !pPre->IsSctFrame())
1395 ::ValidateSz( pPre );
1396 }
1397 bMoveable = IsMoveable();
1398 }
1399 }
1400
1401 aOldFramePos = aRectFnSet.GetPos(getFrameArea());
1402 aOldPrtPos = aRectFnSet.GetPos(getFramePrintArea());
1403
1404 if ( !isFrameAreaPositionValid() )
1405 MakePos();
1406
1407 //Set FixSize. VarSize is being adjusted by Format().
1408 if ( !isFrameAreaSizeValid() )
1409 {
1410 // invalidate printing area flag, if the following conditions are hold:
1411 // - current frame width is 0.
1412 // - current printing area width is 0.
1413 // - frame width is adjusted to a value greater than 0.
1414 // - printing area flag is true.
1415 // Thus, it's assured that the printing area is adjusted, if the
1416 // frame area width changes its width from 0 to something greater
1417 // than 0.
1418 // Note: A text frame can be in such a situation, if the format is
1419 // triggered by method call <SwCursorShell::SetCursor()> after
1420 // loading the document.
1421 const SwTwips nNewFrameWidth = aRectFnSet.GetWidth(GetUpper()->getFramePrintArea());
1422
1423 if ( isFramePrintAreaValid() &&
1424 nNewFrameWidth > 0 &&
1425 aRectFnSet.GetWidth(getFrameArea()) == 0 &&
1426 aRectFnSet.GetWidth(getFramePrintArea()) == 0 )
1427 {
1429 }
1430
1431 {
1433 aRectFnSet.SetWidth( aFrm, nNewFrameWidth );
1434 }
1435
1436 // When a lower of a vertically aligned fly frame changes its size we need to recalculate content pos.
1437 if( GetUpper() && GetUpper()->IsFlyFrame() &&
1438 GetUpper()->GetFormat()->GetTextVertAdjust().GetValue() != SDRTEXTVERTADJUST_TOP )
1439 {
1440 static_cast<SwFlyFrame*>(GetUpper())->InvalidateContentPos();
1442 }
1443 }
1444 if ( !isFramePrintAreaValid() )
1445 {
1446 const tools::Long nOldW = aRectFnSet.GetWidth(getFramePrintArea());
1447 // #i34730# - keep current frame height
1448 const SwTwips nOldH = aRectFnSet.GetHeight(getFrameArea());
1449 MakePrtArea( rAttrs );
1450 if ( nOldW != aRectFnSet.GetWidth(getFramePrintArea()) )
1452 // #i34730# - check, if frame height has changed.
1453 // If yes, send a PrepareHint::AdjustSizeWithoutFormatting and invalidate the size flag to
1454 // force a format. The format will check in its method
1455 // <SwTextFrame::CalcPreps()>, if the already formatted lines still
1456 // fit and if not, performs necessary actions.
1457 // #i40150# - no check, if frame is undersized.
1458 if ( isFrameAreaSizeValid() && !IsUndersized() && nOldH != aRectFnSet.GetHeight(getFrameArea()) )
1459 {
1460 // #115759# - no PrepareHint::AdjustSizeWithoutFormatting and size
1461 // invalidation, if height decreases only by the additional
1462 // lower space as last content of a table cell and an existing
1463 // follow containing one line exists.
1464 const SwTwips nHDiff = nOldH - aRectFnSet.GetHeight(getFrameArea());
1465 const bool bNoPrepAdjustFrame =
1466 nHDiff > 0 && IsInTab() && GetFollow() &&
1467 (1 == static_cast<SwTextFrame*>(GetFollow())->GetLineCount(TextFrameIndex(COMPLETE_STRING))
1468 || aRectFnSet.GetWidth(static_cast<SwTextFrame*>(GetFollow())->getFrameArea()) < 0) &&
1469 GetFollow()->CalcAddLowerSpaceAsLastInTableCell() == nHDiff;
1470 if ( !bNoPrepAdjustFrame )
1471 {
1473 setFrameAreaSizeValid(false);
1474 }
1475 }
1476 }
1477
1478 // To make the widow and orphan rules work, we need to notify the ContentFrame.
1479 // Criteria:
1480 // - It needs to be movable (otherwise, splitting doesn't make sense)
1481 // - It needs to overlap with the lower edge of the PrtArea of the Upper
1482 if ( !bMustFit )
1483 {
1484 bool bWidow = true;
1485 const SwTwips nDeadLine = aRectFnSet.GetPrtBottom(*GetUpper());
1486 if( bMoveable && !bFormatted &&
1487 ( GetFollow() || aRectFnSet.OverStep( getFrameArea(), nDeadLine ) ) )
1488 {
1489 Prepare( PrepareHint::WidowsOrphans, nullptr, false );
1490 setFrameAreaSizeValid(false);
1491 bWidow = false;
1492 }
1493 if( aRectFnSet.GetPos(getFrameArea()) != aOldFramePos ||
1494 aRectFnSet.GetPos(getFramePrintArea()) != aOldPrtPos )
1495 {
1496 // In this Prepare, an InvalidateSize_() might happen.
1497 // isFrameAreaSizeValid() becomes false and Format() gets called.
1498 Prepare( PrepareHint::FramePositionChanged, static_cast<const void*>(&bFormatted), false );
1499 if ( bWidow && GetFollow() )
1500 {
1501 Prepare( PrepareHint::WidowsOrphans, nullptr, false );
1502 setFrameAreaSizeValid(false);
1503 }
1504 }
1505 }
1506 if ( !isFrameAreaSizeValid() )
1507 {
1509 bFormatted = true;
1510 ++nFormatCount;
1511 if( nFormatCount > STOP_FLY_FORMAT )
1512 SetFlyLock( true );
1513 // - loop prevention
1514 // No format any longer, if <cnStopFormat> consecutive formats
1515 // without change occur.
1516 if ( nConsecutiveFormatsWithoutChange <= cnStopFormat )
1517 {
1518 Format(getRootFrame()->GetCurrShell()->GetOut());
1519 }
1520#if OSL_DEBUG_LEVEL > 0
1521 else
1522 {
1523 OSL_FAIL( "debug assertion: <SwContentFrame::MakeAll()> - format of text frame suppressed by fix b6448963" );
1524 }
1525#endif
1526 }
1527
1528 // If this is the first one in a chain, check if this can flow
1529 // backwards (if this is movable at all).
1530 // To prevent oscillations/loops, check that this has not just
1531 // flowed forwards.
1532 bool bDummy;
1533 auto const pTemp(GetIndPrev());
1534 auto const bTemp(pTemp && pTemp->isFrameAreaSizeValid()
1535 && pTemp->isFramePrintAreaValid());
1536 if ( !lcl_Prev( this ) &&
1537 !bMovedFwd &&
1538 ( bMoveable || ( bFly && !bTab ) ) &&
1540 && MoveBwd( bDummy ) )
1541 {
1542 aRectFnSet.Refresh(this);
1543 pMoveBwdPre = pTemp;
1544 isMoveBwdPreValid = bTemp;
1545 bMovedBwd = true;
1546 bFormatted = false;
1547 if ( bKeep && bMoveable )
1548 {
1549 if( CheckMoveFwd( bMakePage, false, bMovedBwd ) )
1550 {
1551 bMovedFwd = true;
1552 bMoveable = IsMoveable();
1553 aRectFnSet.Refresh(this);
1554 }
1555 Point aOldPos = aRectFnSet.GetPos(getFrameArea());
1556 MakePos();
1557 if( aOldPos != aRectFnSet.GetPos(getFrameArea()) )
1558 {
1559 Prepare( PrepareHint::FramePositionChanged, static_cast<const void*>(&bFormatted), false );
1560 if ( !isFrameAreaSizeValid() )
1561 {
1562 {
1564 aRectFnSet.SetWidth( aFrm, aRectFnSet.GetWidth(GetUpper()->getFramePrintArea()) );
1565 }
1566
1567 if ( !isFramePrintAreaValid() )
1568 {
1569 const tools::Long nOldW = aRectFnSet.GetWidth(getFramePrintArea());
1570 MakePrtArea( rAttrs );
1571 if( nOldW != aRectFnSet.GetWidth(getFramePrintArea()) )
1572 Prepare( PrepareHint::FixSizeChanged, nullptr, false );
1573 }
1574 if( GetFollow() )
1575 {
1576 Prepare( PrepareHint::WidowsOrphans, nullptr, false );
1577 }
1578
1580 bFormatted = true;
1581 Format(getRootFrame()->GetCurrShell()->GetOut());
1582 }
1583 }
1584 SwFrame *pNxt = HasFollow() ? nullptr : FindNext();
1585 while( pNxt && pNxt->IsSctFrame() )
1586 { // Leave empty sections out, go into the other ones.
1587 if( static_cast<SwSectionFrame*>(pNxt)->GetSection() )
1588 {
1589 SwFrame* pTmp = static_cast<SwSectionFrame*>(pNxt)->ContainsAny();
1590 if( pTmp )
1591 {
1592 pNxt = pTmp;
1593 break;
1594 }
1595 }
1596 pNxt = pNxt->FindNext();
1597 }
1598 if ( pNxt )
1599 {
1600 pNxt->Calc(getRootFrame()->GetCurrShell()->GetOut());
1602 {
1603 SwSectionFrame *pSct = FindSctFrame();
1604 if( pSct && !pSct->isFrameAreaSizeValid() )
1605 {
1606 SwSectionFrame* pNxtSct = pNxt->FindSctFrame();
1607 if( pNxtSct && pSct->IsAnFollow( pNxtSct ) )
1608 {
1610 }
1611 }
1612 else
1613 {
1615 }
1616 }
1617 }
1618 }
1619 }
1620
1621 // In footnotes, the TextFrame may validate itself, which can lead to the
1622 // situation that it's position is wrong despite being "valid".
1624 {
1625 // #i59341#
1626 // Workaround for inadequate layout algorithm:
1627 // suppress invalidation and calculation of position, if paragraph
1628 // has formatted itself at least STOP_FLY_FORMAT times and
1629 // has anchored objects.
1630 // Thus, the anchored objects get the possibility to format itself
1631 // and this probably solve the layout loop.
1632 if ( bFootnote &&
1633 nFormatCount <= STOP_FLY_FORMAT &&
1634 !GetDrawObjs() )
1635 {
1637 MakePos();
1638 aOldFramePos = aRectFnSet.GetPos(getFrameArea());
1639 aOldPrtPos = aRectFnSet.GetPos(getFramePrintArea());
1640 }
1641 }
1642
1643 // - loop prevention
1644 {
1645 if ( (aOldFrame_StopFormat == getFrameArea() || aOldFrame_StopFormat2 == getFrameArea() ) &&
1646 (aOldPrt_StopFormat == getFramePrintArea() || aOldPrt_StopFormat2 == getFramePrintArea()))
1647 {
1648 ++nConsecutiveFormatsWithoutChange;
1649 }
1650 else
1651 {
1652 nConsecutiveFormatsWithoutChange = 0;
1653 }
1654 }
1655
1656 // Yet again an invalid value? Repeat from the start...
1658 continue;
1659
1660 // Done?
1661 // Attention: because height == 0, it's better to use Top()+Height() instead of
1662 // Bottom(). This might happen with undersized TextFrames on the lower edge of a
1663 // multi-column section
1664 const tools::Long nPrtBottom = aRectFnSet.GetPrtBottom(*GetUpper());
1665 tools::Long nBottomDist = aRectFnSet.BottomDist(getFrameArea(), nPrtBottom);
1666
1667 // Hide whitespace may require not to insert a new page.
1668 SwPageFrame* pPageFrame = FindPageFrame();
1669 const bool bHeightValid = pPageFrame->CheckPageHeightValidForHideWhitespace(nBottomDist);
1670 if (!bHeightValid)
1671 {
1672 pPageFrame->InvalidateSize();
1673 nBottomDist = 0;
1674 }
1675
1676 if( nBottomDist >= 0 )
1677 {
1678 if ( bKeep && bMoveable )
1679 {
1680 // We make sure the successor will be formatted the same.
1681 // This way, we keep control until (almost) everything is stable,
1682 // allowing us to avoid endless loops caused by ever repeating
1683 // retries.
1684
1685 // bMoveFwdInvalid is required for #38407#. This was originally solved
1686 // in flowfrm.cxx rev 1.38, but broke the above schema and
1687 // preferred to play towers of hanoi (#43669#).
1688 SwFrame *pNxt = HasFollow() ? nullptr : FindNext();
1689 // For sections we prefer the content, because it can change
1690 // the page if required.
1691 while( pNxt && pNxt->IsSctFrame() )
1692 {
1693 if( static_cast<SwSectionFrame*>(pNxt)->GetSection() )
1694 {
1695 pNxt = static_cast<SwSectionFrame*>(pNxt)->ContainsAny();
1696 break;
1697 }
1698 pNxt = pNxt->FindNext();
1699 }
1700 if ( pNxt )
1701 {
1702 const bool bMoveFwdInvalid = nullptr != GetIndNext();
1703 const bool bNxtNew =
1704 ( 0 == aRectFnSet.GetHeight(pNxt->getFramePrintArea()) ) &&
1705 (!pNxt->IsTextFrame() ||!static_cast<SwTextFrame*>(pNxt)->IsHiddenNow());
1706
1707 pNxt->Calc(getRootFrame()->GetCurrShell()->GetOut());
1708
1709 if ( !bMovedBwd &&
1710 ((bMoveFwdInvalid && !GetIndNext()) ||
1711 bNxtNew) )
1712 {
1713 if( bMovedFwd )
1714 oNotify->SetInvaKeep();
1715 bMovedFwd = false;
1716 }
1717 }
1718 }
1719 continue;
1720 }
1721
1722 // I don't fit into my parents, so it's time to make changes
1723 // as constructively as possible.
1724
1725 //If I'm NOT allowed to leave the parent Frame, I've got a problem.
1726 // Following Arthur Dent, we do the only thing that you can do with
1727 // an unsolvable problem: We ignore it with all our power.
1728 if ( !bMoveable || IsUndersized() )
1729 {
1730 break;
1731 }
1732
1733 // If there's no way I can make myself fit into my Upper, the situation
1734 // could still probably be mitigated by splitting up.
1735 // This situation arises with freshly created Follows that had been moved
1736 // to the next page but is still too big for it - ie. needs to be split
1737 // as well.
1738
1739 // If I'm unable to split (WouldFit()) and can't be fitted, I'm going
1740 // to tell my TextFrame part that, if possible, we still need to split despite
1741 // the "don't split" attribute.
1742 bool bMoveOrFit = false;
1743 bool bDontMoveMe = !GetIndPrev();
1744 if( bDontMoveMe && IsInSct() )
1745 {
1747 bDontMoveMe = !pBoss->IsInSct() ||
1748 ( !pBoss->Lower()->GetNext() && !pBoss->GetPrev() );
1749 }
1750
1751 // Finally, we are able to split table rows. Therefore, bDontMoveMe
1752 // can be set to false:
1753 if( bDontMoveMe && IsInTab() &&
1754 nullptr != GetNextCellLeaf() )
1755 bDontMoveMe = false;
1756
1757 assert(bMoveable);
1758
1759 if ( bDontMoveMe && aRectFnSet.GetHeight(getFrameArea()) >
1760 aRectFnSet.GetHeight(GetUpper()->getFramePrintArea()) )
1761 {
1762 if ( !bFitPromise )
1763 {
1764 SwTwips nTmp = aRectFnSet.GetHeight(GetUpper()->getFramePrintArea()) -
1765 aRectFnSet.GetTop(getFramePrintArea());
1766 bool bSplit = !IsFwdMoveAllowed();
1767 if (nTmp > 0 && WouldFit(nTmp, bSplit, false, false))
1768 {
1769 Prepare( PrepareHint::WidowsOrphans, nullptr, false );
1770 setFrameAreaSizeValid(false);
1771 bFitPromise = true;
1772 continue;
1773 }
1774 /*
1775 * In earlier days, we never tried to fit TextFrames in
1776 * frames and sections using bMoveOrFit by ignoring
1777 * its attributes (Widows, Keep).
1778 * This should have been done at least for column frames;
1779 * as it must be tried anyway with linked frames and sections.
1780 * Exception: If we sit in FormatWidthCols, we must not ignore
1781 * the attributes.
1782 */
1783 else if ( !bFootnote &&
1784 ( !bFly || !FindFlyFrame()->IsColLocked() ) &&
1785 ( !bSct || !FindSctFrame()->IsColLocked() ) )
1786 bMoveOrFit = true;
1787 }
1788#if OSL_DEBUG_LEVEL > 0
1789 else
1790 {
1791 OSL_FAIL( "+TextFrame didn't respect WouldFit promise." );
1792 }
1793#endif
1794 }
1795
1796 // Let's see if I can find some space somewhere...
1797 // footnotes in the neighbourhood are moved into _MoveFootnoteCntFwd
1798 SwFrame *pPre = GetIndPrev();
1799 SwFrame *pOldUp = GetUpper();
1800
1801/* MA 13. Oct. 98: What is this supposed to be!?
1802 * AMA 14. Dec 98: If a column section can't find any space for its first ContentFrame, it should be
1803 * moved not only to the next column, but probably even to the next page, creating
1804 * a section-follow there.
1805 */
1806 if( IsInSct() && bMovedFwd && bMakePage && pOldUp->IsColBodyFrame() &&
1807 pOldUp->GetUpper()->GetUpper()->IsSctFrame() &&
1808 ( pPre || pOldUp->GetUpper()->GetPrev() ) &&
1809 static_cast<SwSectionFrame*>(pOldUp->GetUpper()->GetUpper())->MoveAllowed(this) )
1810 {
1811 bMovedFwd = false;
1812 }
1813
1814 const bool bCheckForGrownBody = pOldUp->IsBodyFrame();
1815 const tools::Long nOldBodyHeight = aRectFnSet.GetHeight(pOldUp->getFrameArea());
1816
1817 if ( !bMovedFwd && !MoveFwd( bMakePage, false ) )
1818 bMakePage = false;
1819 aRectFnSet.Refresh(this);
1820 if (!bMovedFwd && bFootnote && GetIndPrev() != pPre)
1821 { // SwFlowFrame::CutTree() could have formatted and deleted pPre
1822 auto const pPrevFootnoteFrame(static_cast<SwFootnoteFrame const*>(
1823 FindFootnoteFrame())->GetMaster());
1824 bool bReset = true;
1825 if (pPrevFootnoteFrame)
1826 { // use GetIndNext() in case there are sections
1827 for (auto p = pPrevFootnoteFrame->Lower(); p; p = p->GetIndNext())
1828 {
1829 if (p == pPre)
1830 {
1831 bReset = false;
1832 break;
1833 }
1834 }
1835 }
1836 if (bReset)
1837 {
1838 pPre = nullptr;
1839 }
1840 }
1841
1842 // If MoveFwd moves the paragraph to the next page, a following
1843 // paragraph, which contains footnotes can cause the old upper
1844 // frame to grow. In this case we explicitly allow a new check
1845 // for MoveBwd. Robust: We also check the bMovedBwd flag again.
1846 // If pOldUp was a footnote frame, it has been deleted inside MoveFwd.
1847 // Therefore we only check for growing body frames.
1848 bMovedFwd = !bCheckForGrownBody || bMovedBwd || pOldUp == GetUpper() ||
1849 aRectFnSet.GetHeight(pOldUp->getFrameArea()) <= nOldBodyHeight;
1850
1851 bFormatted = false;
1852 if ( bMoveOrFit && GetUpper() == pOldUp )
1853 {
1854 // FME 2007-08-30 #i81146# new loop control
1855 if ( nConsecutiveFormatsWithoutChange <= cnStopFormat )
1856 {
1857 Prepare( PrepareHint::MustFit, nullptr, false );
1858 setFrameAreaSizeValid(false);
1859 bMustFit = true;
1860 continue;
1861 }
1862
1863#if OSL_DEBUG_LEVEL > 0
1864 OSL_FAIL( "LoopControl in SwContentFrame::MakeAll" );
1865#endif
1866 }
1867 if ( bMovedBwd && GetUpper() )
1868 { // Retire invalidations that have become useless.
1870 if( pPre && !pPre->IsSctFrame() )
1871 ::ValidateSz( pPre );
1872 }
1873
1874 } //while ( !isFrameAreaPositionValid() || !isFrameAreaSizeValid() || !isFramePrintAreaValid() )
1875
1876 // NEW: Looping Louie (Light). Should not be applied in balanced sections.
1877 // Should only be applied if there is no better solution!
1878 LOOPING_LOUIE_LIGHT( bMovedFwd && bMovedBwd && !IsInBalancedSection() &&
1879 (
1880
1881 ( bFootnote && !FindFootnoteFrame()->GetRef()->IsInSct() ) ||
1882
1883 // #i33887#
1884 ( IsInSct() && bKeep )
1885
1886 // ... add your conditions here ...
1887
1888 ),
1889 static_cast<SwTextFrame&>(*this) );
1890
1891 pSaveFootnote.reset();
1892
1893 UnlockJoin();
1894 oDeleteGuard.reset();
1895 if ( bMovedFwd || bMovedBwd )
1896 oNotify->SetInvaKeep();
1897 if ( bMovedFwd )
1898 {
1899 oNotify->SetInvalidatePrevPrtArea();
1900 }
1901 oNotify.reset();
1902 SetFlyLock( false );
1903}
1904
1905void MakeNxt( SwFrame *pFrame, SwFrame *pNxt )
1906{
1907 // fix(25455): Validate, otherwise this leads to a recursion.
1908 // The first try, cancelling with pFrame = 0 if !Valid, leads to a problem, as
1909 // the Keep may not be considered properly anymore (27417).
1910 const bool bOldPos = pFrame->isFrameAreaPositionValid();
1911 const bool bOldSz = pFrame->isFrameAreaSizeValid();
1912 const bool bOldPrt = pFrame->isFramePrintAreaValid();
1913 pFrame->setFrameAreaPositionValid(true);
1914 pFrame->setFrameAreaSizeValid(true);
1915 pFrame->setFramePrintAreaValid(true);
1916
1917 // fix(29272): Don't call MakeAll - there, pFrame might be invalidated again, and
1918 // we recursively end up in here again.
1919 if ( pNxt->IsContentFrame() )
1920 {
1921 SwContentNotify aNotify( static_cast<SwContentFrame*>(pNxt) );
1922 SwBorderAttrAccess aAccess( SwFrame::GetCache(), pNxt );
1923 const SwBorderAttrs &rAttrs = *aAccess.Get();
1924 if ( !pNxt->isFrameAreaSizeValid() )
1925 {
1927
1928 if( pNxt->IsVertical() )
1929 {
1930 aFrm.Height( pNxt->GetUpper()->getFramePrintArea().Height() );
1931 }
1932 else
1933 {
1934 aFrm.Width( pNxt->GetUpper()->getFramePrintArea().Width() );
1935 }
1936 }
1937 static_cast<SwContentFrame*>(pNxt)->MakePrtArea( rAttrs );
1938 pNxt->Format( pNxt->getRootFrame()->GetCurrShell()->GetOut(), &rAttrs );
1939 }
1940 else
1941 {
1942 SwLayNotify aNotify( static_cast<SwLayoutFrame*>(pNxt) );
1943 SwBorderAttrAccess aAccess( SwFrame::GetCache(), pNxt );
1944 const SwBorderAttrs &rAttrs = *aAccess.Get();
1945 if ( !pNxt->isFrameAreaSizeValid() )
1946 {
1948
1949 if( pNxt->IsVertical() )
1950 {
1951 aFrm.Height( pNxt->GetUpper()->getFramePrintArea().Height() );
1952 }
1953 else
1954 {
1955 aFrm.Width( pNxt->GetUpper()->getFramePrintArea().Width() );
1956 }
1957 }
1958 pNxt->Format( pNxt->getRootFrame()->GetCurrShell()->GetOut(), &rAttrs );
1959 }
1960
1961 pFrame->setFrameAreaPositionValid(bOldPos);
1962 pFrame->setFrameAreaSizeValid(bOldSz);
1963 pFrame->setFramePrintAreaValid(bOldPrt);
1964}
1965
1968static bool lcl_IsNextFootnoteBoss( const SwFrame *pFrame, const SwFrame* pNxt )
1969{
1970 assert(pFrame && pNxt && "lcl_IsNextFootnoteBoss: No Frames?");
1971 pFrame = pFrame->FindFootnoteBossFrame();
1972 pNxt = pNxt->FindFootnoteBossFrame();
1973 // If pFrame is a last column, we use the page instead.
1974 while( pFrame && pFrame->IsColumnFrame() && !pFrame->GetNext() )
1975 pFrame = pFrame->GetUpper()->FindFootnoteBossFrame();
1976 // If pNxt is a first column, we use the page instead.
1977 while( pNxt && pNxt->IsColumnFrame() && !pNxt->GetPrev() )
1978 pNxt = pNxt->GetUpper()->FindFootnoteBossFrame();
1979 // So... now pFrame and pNxt are either two adjacent pages or columns.
1980 return pFrame && pNxt && pFrame->GetNext() == pNxt;
1981}
1982
1984 SwLayoutFrame *pNewUpper,
1985 bool bTstMove,
1986 const bool bObjsInNewUpper )
1987{
1988 // To have the footnote select its place carefully, it needs
1989 // to be moved in any case if there is at least one page/column
1990 // between the footnote and the new Upper.
1991 SwFootnoteFrame* pFootnoteFrame = nullptr;
1992 if ( IsInFootnote() )
1993 {
1994 if( !lcl_IsNextFootnoteBoss( pNewUpper, this ) )
1995 return true;
1996 pFootnoteFrame = FindFootnoteFrame();
1997 }
1998
1999 bool bRet;
2000 bool bSplit = !pNewUpper->Lower();
2001 SwContentFrame *pFrame = this;
2002 const SwFrame *pTmpPrev = pNewUpper->Lower();
2003 if( pTmpPrev && pTmpPrev->IsFootnoteFrame() )
2004 pTmpPrev = static_cast<const SwFootnoteFrame*>(pTmpPrev)->Lower();
2005 while ( pTmpPrev && pTmpPrev->GetNext() )
2006 pTmpPrev = pTmpPrev->GetNext();
2007 do
2008 {
2009 // #i46181#
2010 SwTwips nSecondCheck = 0;
2011 SwTwips nOldSpace = nSpace;
2012 bool bOldSplit = bSplit;
2013
2014 if ( bTstMove || IsInFly() || ( IsInSct() &&
2015 ( pFrame->GetUpper()->IsColBodyFrame() || ( pFootnoteFrame &&
2016 pFootnoteFrame->GetUpper()->GetUpper()->IsColumnFrame() ) ) ) )
2017 {
2018 // This is going to get a bit insidious now. If you're faint of heart,
2019 // you'd better look away here. If a Fly contains columns, then the Contents
2020 // are movable, except ones in the last column (see SwFrame::IsMoveable()).
2021 // Of course they're allowed to float back. WouldFit() only returns a usable
2022 // value if the Frame is movable. To fool WouldFit() into believing there's
2023 // a movable Frame, I'm just going to hang it somewhere else for the time.
2024 // The same procedure applies for column sections to make SwSectionFrame::Growable()
2025 // return the proper value.
2026 // Within footnotes, we may even need to put the SwFootnoteFrame somewhere else, if
2027 // there's no SwFootnoteFrame there.
2028 SwFrame* pTmpFrame = pFrame->IsInFootnote() && !pNewUpper->FindFootnoteFrame() ?
2029 static_cast<SwFrame*>(pFrame->FindFootnoteFrame()) : pFrame;
2030 SwLayoutFrame *pUp = pTmpFrame->GetUpper();
2031 SwFrame *pOldNext = pTmpFrame->GetNext();
2032 pTmpFrame->RemoveFromLayout();
2033 pTmpFrame->InsertBefore( pNewUpper, nullptr );
2034 // tdf#107126 for a section in a footnote, we have only inserted
2035 // the SwTextFrame but no SwSectionFrame - reset mbInfSct flag
2036 // to avoid crashing (but perhaps we should create a temp
2037 // SwSectionFrame here because WidowsAndOrphans checks for that?)
2038 pTmpFrame->InvalidateInfFlags();
2039 if ( pFrame->IsTextFrame() &&
2040 ( bTstMove ||
2041 static_cast<SwTextFrame*>(pFrame)->HasFollow() ||
2042 ( !static_cast<SwTextFrame*>(pFrame)->HasPara() &&
2043 !static_cast<SwTextFrame*>(pFrame)->IsEmpty()
2044 )
2045 )
2046 )
2047 {
2048 bTstMove = true;
2049 bRet = static_cast<SwTextFrame*>(pFrame)->TestFormat( pTmpPrev, nSpace, bSplit );
2050 }
2051 else
2052 bRet = pFrame->WouldFit(nSpace, bSplit, false, true);
2053
2054 pTmpFrame->RemoveFromLayout();
2055 pTmpFrame->InsertBefore( pUp, pOldNext );
2056 pTmpFrame->InvalidateInfFlags(); // restore flags
2057 }
2058 else
2059 {
2060 bRet = pFrame->WouldFit(nSpace, bSplit, false, true);
2061 nSecondCheck = !bSplit ? 1 : 0;
2062 }
2063
2064 SwBorderAttrAccess aAccess( SwFrame::GetCache(), pFrame );
2065 const SwBorderAttrs &rAttrs = *aAccess.Get();
2066
2067 // Sad but true: We need to consider the spacing in our calculation.
2068 // This already happened in TestFormat.
2069 if ( bRet && !bTstMove )
2070 {
2071 SwTwips nUpper;
2072
2073 if ( pTmpPrev )
2074 {
2075 nUpper = CalcUpperSpace( nullptr, pTmpPrev );
2076
2077 // in balanced columned section frames we do not want the
2078 // common border
2079 bool bCommonBorder = true;
2080 if ( pFrame->IsInSct() && pFrame->GetUpper()->IsColBodyFrame() )
2081 {
2082 const SwSectionFrame* pSct = pFrame->FindSctFrame();
2083 bCommonBorder = pSct->GetFormat()->GetBalancedColumns().GetValue();
2084 }
2085
2086 // #i46181#
2087 nSecondCheck = ( 1 == nSecondCheck &&
2088 pFrame == this &&
2089 IsTextFrame() &&
2090 bCommonBorder &&
2091 !static_cast<const SwTextFrame*>(this)->IsEmpty() ) ?
2092 nUpper :
2093 0;
2094
2095 nUpper += bCommonBorder ?
2096 rAttrs.GetBottomLine( *pFrame ) :
2097 rAttrs.CalcBottomLine();
2098
2099 }
2100 else
2101 {
2102 // #i46181#
2103 nSecondCheck = 0;
2104
2105 if( pFrame->IsVertical() )
2106 nUpper = pFrame->getFrameArea().Width() - pFrame->getFramePrintArea().Width();
2107 else
2108 nUpper = pFrame->getFrameArea().Height() - pFrame->getFramePrintArea().Height();
2109 }
2110
2111 nSpace -= nUpper;
2112
2113 if ( nSpace < 0 )
2114 {
2115 bRet = false;
2116
2117 // #i46181#
2118 if ( nSecondCheck > 0 )
2119 {
2120 // The following code is intended to solve a (rare) problem
2121 // causing some frames not to move backward:
2122 // SwTextFrame::WouldFit() claims that the whole paragraph
2123 // fits into the given space and subtracts the height of
2124 // all lines from nSpace. nSpace - nUpper is not a valid
2125 // indicator if the frame should be allowed to move backward.
2126 // We do a second check with the original remaining space
2127 // reduced by the required upper space:
2128 nOldSpace -= nSecondCheck;
2129 const bool bSecondRet = nOldSpace >= 0 && pFrame->WouldFit(nOldSpace, bOldSplit, false, true);
2130 if ( bSecondRet && bOldSplit && nOldSpace >= 0 )
2131 {
2132 bRet = true;
2133 bSplit = true;
2134 }
2135 }
2136 }
2137 }
2138
2139 // Also consider lower spacing in table cells
2140 IDocumentSettingAccess const& rIDSA(pNewUpper->GetFormat()->getIDocumentSettingAccess());
2141 if ( bRet && IsInTab() &&
2143 {
2144 nSpace -= rAttrs.GetULSpace().GetLower();
2145
2147 {
2148 nSpace -= rAttrs.CalcLineSpacing();
2149 }
2150 if ( nSpace < 0 )
2151 {
2152 bRet = false;
2153 }
2154 }
2155
2156 if (bRet && !bSplit && pFrame->IsKeep(rAttrs.GetAttrSet().GetKeep(), GetBreakItem()))
2157 {
2158 if( bTstMove )
2159 {
2160 while( pFrame->IsTextFrame() && static_cast<SwTextFrame*>(pFrame)->HasFollow() )
2161 {
2162 pFrame = static_cast<SwTextFrame*>(pFrame)->GetFollow();
2163 }
2164 // If last follow frame of <this> text frame isn't valid,
2165 // a formatting of the next content frame doesn't makes sense.
2166 // Thus, return true.
2167 if ( IsAnFollow( pFrame ) && !pFrame->isFrameAreaDefinitionValid() )
2168 {
2169 OSL_FAIL( "Only a warning for task 108824:/n<SwContentFrame::WouldFit_(..) - follow not valid!" );
2170 return true;
2171 }
2172 }
2173 SwFrame *pNxt;
2174 if( nullptr != (pNxt = pFrame->FindNext()) && pNxt->IsContentFrame() &&
2175 ( !pFootnoteFrame || ( pNxt->IsInFootnote() &&
2176 pNxt->FindFootnoteFrame()->GetAttr() == pFootnoteFrame->GetAttr() ) ) )
2177 {
2178 // TestFormat(?) does not like paragraph- or character anchored objects.
2179
2180 // current solution for the test formatting doesn't work, if
2181 // objects are present in the remaining area of the new upper
2182 if ( bTstMove &&
2183 ( pNxt->GetDrawObjs() || bObjsInNewUpper ) )
2184 {
2185 return true;
2186 }
2187
2188 if ( !pNxt->isFrameAreaDefinitionValid() )
2189 {
2190 MakeNxt( pFrame, pNxt );
2191 }
2192
2193 // Little trick: if the next has a predecessor, then the paragraph
2194 // spacing has been calculated already, and we don't need to re-calculate
2195 // it in an expensive way.
2196 if( lcl_NotHiddenPrev( pNxt ) )
2197 pTmpPrev = nullptr;
2198 else
2199 {
2200 if( pFrame->IsTextFrame() && static_cast<SwTextFrame*>(pFrame)->IsHiddenNow() )
2201 pTmpPrev = lcl_NotHiddenPrev( pFrame );
2202 else
2203 pTmpPrev = pFrame;
2204 }
2205 pFrame = static_cast<SwContentFrame*>(pNxt);
2206 }
2207 else
2208 pFrame = nullptr;
2209 }
2210 else
2211 pFrame = nullptr;
2212
2213 } while ( bRet && pFrame );
2214
2215 return bRet;
2216}
2217
2218/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
@ ADD_PARA_LINE_SPACING_TO_TABLE_CELLS
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...
void PrepareLock(SwFlowFrame *pTab)
Definition: calcmove.cxx:208
static SwFrame * lcl_Prev(SwFrame *pFrame, bool bSectPrv=true)
Definition: calcmove.cxx:504
void PrepareUnlock(SwFlowFrame *pTab)
Definition: calcmove.cxx:212
static SwFrame * lcl_NotHiddenPrev(SwFrame *pFrame)
Definition: calcmove.cxx:516
void MakeNxt(SwFrame *pFrame, SwFrame *pNxt)
Definition: calcmove.cxx:1905
static bool lcl_IsNextFootnoteBoss(const SwFrame *pFrame, const SwFrame *pNxt)
This routine checks whether there are no other FootnoteBosses between the pFrame's FootnoteBoss and t...
Definition: calcmove.cxx:1968
void ValidateSz(SwFrame *pFrame)
Definition: calcmove.cxx:1204
#define STOP_FLY_FORMAT
Definition: calcmove.cxx:1200
static void lcl_CheckObjects(SwSortedObjs &rSortedObjs, const SwFrame *pFrame, tools::Long &rBot)
Definition: calcmove.cxx:698
static bool lcl_IsCalcUpperAllowed(const SwFrame &rFrame)
Definition: calcmove.cxx:219
const int cnStopFormat
Definition: calcmove.cxx:1202
Provides access to settings of a document.
virtual bool get(DocumentSettingId id) const =0
Return the specified document setting.
SAL_WARN_UNUSED_RESULT Point PixelToLogic(const Point &rDevicePt) const
bool GetValue() const
constexpr tools::Long Height() const
constexpr tools::Long Width() const
static bool IsLocked()
Definition: frmtool.hxx:478
tools::Long GetWidth() const
sal_uInt16 GetLower() const
wrapper class for the positioning of Writer fly frames and drawing objects
virtual SwFrameFormat & GetFrameFormat()=0
virtual const SwFlyFrame * DynCastFlyFrame() const
virtual SwRect GetObjRect() const =0
const SvxFormatKeepItem & GetKeep(bool=true) const
Definition: frmatr.hxx:56
SwBorderAttrs * Get()
Definition: frmtool.cxx:2682
sal_uInt16 CalcRightLine() const
Definition: frmtool.hxx:528
bool JoinedWithPrev(const SwFrame &_rFrame, const SwFrame *_pPrevFrame=nullptr) const
Definition: frmtool.cxx:2590
const Size & GetSize() const
Definition: frmtool.hxx:412
tools::Long CalcLeft(const SwFrame *pCaller) const
Definition: frmtool.cxx:2372
sal_uInt16 CalcTopLine() const
Definition: frmtool.hxx:510
const SvxULSpaceItem & GetULSpace() const
Definition: frmtool.hxx:396
sal_uInt16 CalcLeftLine() const
Definition: frmtool.hxx:522
sal_uInt16 GetBottomLine(const SwFrame &_rFrame) const
Definition: frmtool.hxx:494
const SwAttrSet & GetAttrSet() const
Definition: frmtool.hxx:395
sal_uInt16 CalcBottomLine() const
Definition: frmtool.hxx:516
tools::Long CalcRight(const SwFrame *pCaller) const
Definition: frmtool.cxx:2310
sal_uInt16 CalcLineSpacing() const
Definition: frmtool.hxx:546
SwContentFrame is the layout for content nodes: a common base class for text (paragraph) and non-text...
Definition: cntfrm.hxx:58
virtual bool ShouldBwdMoved(SwLayoutFrame *pNewUpper, bool &) override
Return value tells whether the Frame should be moved.
Definition: calcmove.cxx:54
virtual void MakeAll(vcl::RenderContext *pRenderContext) override
Definition: calcmove.cxx:1213
friend void MakeNxt(SwFrame *pFrame, SwFrame *pNxt)
Definition: calcmove.cxx:1905
const SwContentFrame * GetFollow() const
Definition: cntfrm.hxx:135
void MakePrtArea(const SwBorderAttrs &)
Definition: calcmove.cxx:1066
bool WouldFit_(SwTwips nSpace, SwLayoutFrame *pNewUpper, bool bTstMove, const bool bObjsInNewUpper)
Definition: calcmove.cxx:1983
virtual bool WouldFit(SwTwips &nMaxHeight, bool &bSplit, bool bTst, bool)
Definition: unusedf.cxx:35
virtual SwTwips ShrinkFrame(SwTwips, bool bTst=false, bool bInfo=false) override
Definition: wsfrm.cxx:2226
virtual SwTwips GrowFrame(SwTwips, bool bTst=false, bool bInfo=false) override
Definition: wsfrm.cxx:2105
SwContentFrame * getLayoutFrame(const SwRootFrame *, const SwPosition *pPos=nullptr, std::pair< Point, bool > const *pViewPosAndCalcFrame=nullptr) const
Definition: node.cxx:1230
Ends a section of nodes in the document model.
Definition: node.hxx:378
general base class for all free-flowing frames
Definition: flyfrm.hxx:79
SwLayoutFrame * FindBodyCont()
Searches the first ContentFrame in BodyText below the page.
Definition: findfrm.cxx:46
const SwTextFootnote * GetAttr() const
Definition: ftnfrm.hxx:122
const SwContentFrame * GetRef() const
Definition: ftnfrm.cxx:2906
RndStdIds GetAnchorId() const
Definition: fmtanchr.hxx:67
bool IsEndNote() const
Definition: fmtftn.hxx:73
sal_uInt8 GetWidthPercent() const
Definition: fmtfsize.hxx:91
const SwFormatFrameSize & GetFrameSize(bool=true) const
Definition: fmtfsize.hxx:104
const SwFormatAnchor & GetAnchor(bool=true) const
Definition: fmtanchr.hxx:88
const IDocumentSettingAccess & getIDocumentSettingAccess() const
Provides access to the document settings interface.
Definition: format.cxx:711
const SwFormatNoBalancedColumns & GetBalancedColumns(bool=true) const
Definition: fmtclbl.hxx:42
const SwRect & getFrameArea() const
Definition: frame.hxx:179
bool isFrameAreaDefinitionValid() const
Definition: frame.hxx:171
bool isFrameAreaPositionValid() const
Definition: frame.hxx:166
const SwRect & getFramePrintArea() const
Definition: frame.hxx:180
void setFramePrintAreaValid(bool bNew)
Definition: wsfrm.cxx:100
void setFrameAreaPositionValid(bool bNew)
Definition: wsfrm.cxx:84
bool isFramePrintAreaValid() const
Definition: frame.hxx:168
bool isFrameAreaSizeValid() const
Definition: frame.hxx:167
void setFrameAreaSizeValid(bool bNew)
Definition: wsfrm.cxx:92
Style of a layout element.
Definition: frmfmt.hxx:62
Base class of the Writer layout elements.
Definition: frame.hxx:315
bool IsRowFrame() const
Definition: frame.hxx:1222
bool IsCollapse() const
Definition: calcmove.cxx:1055
SwTwips Grow(SwTwips, bool bTst=false, bool bInfo=false)
Definition: wsfrm.cxx:1510
bool IsCellFrame() const
Definition: frame.hxx:1226
bool IsInBalancedSection() const
Definition: findfrm.cxx:1872
void InvalidateInfFlags()
Definition: frame.hxx:608
bool IsFootnoteContFrame() const
Definition: frame.hxx:1198
bool IsTextFrame() const
Definition: frame.hxx:1234
virtual bool Prepare(const PrepareHint ePrep=PrepareHint::Clear, const void *pVoid=nullptr, bool bNotify=true)
Definition: wsfrm.cxx:603
SwFrame * GetIndPrev() const
Definition: frame.hxx:724
SwFlyFrame * FindFlyFrame()
Definition: frame.hxx:1111
SwSectionFrame * FindSctFrame()
Definition: frame.hxx:1115
SwTabFrame * FindTabFrame()
Definition: frame.hxx:1099
SwFrame * FindNext()
Definition: frame.hxx:1141
SwFrame * GetNext()
Definition: frame.hxx:676
void ResetCompletePaint() const
Definition: frame.hxx:998
bool IsPageFrame() const
Definition: frame.hxx:1178
bool IsColLocked() const
Definition: frame.hxx:886
bool IsColumnFrame() const
Definition: frame.hxx:1182
void PrepareMake(vcl::RenderContext *pRenderContext)
Prepares the Frame for "formatting" (MakeAll()).
Definition: calcmove.cxx:246
bool IsVertLRBT() const
Definition: frame.hxx:983
friend class SwFlowFrame
Definition: frame.hxx:317
bool IsTabFrame() const
Definition: frame.hxx:1218
SwFrameType GetType() const
Definition: frame.hxx:519
bool IsInFootnote() const
Definition: frame.hxx:949
bool IsHeaderFrame() const
Definition: frame.hxx:1190
virtual void Calc(vcl::RenderContext *pRenderContext) const
Definition: trvlfrm.cxx:1799
const SwSortedObjs * GetDrawObjs() const
Definition: frame.hxx:564
bool IsInTab() const
Definition: frame.hxx:955
virtual void MakePos()
Definition: calcmove.cxx:526
static SwCache & GetCache()
Definition: frame.hxx:521
bool IsRightToLeft() const
Definition: frame.hxx:987
bool IsInFly() const
Definition: frame.hxx:961
void InsertBefore(SwLayoutFrame *pParent, SwFrame *pBehind)
Insert SwFrame into existing structure.
Definition: wsfrm.cxx:836
virtual bool IsDeleteForbidden() const
Definition: frame.hxx:887
bool IsPageBodyFrame() const
Definition: layfrm.hxx:215
const SwAttrSet * GetAttrSet() const
WARNING: this may not return correct RES_PAGEDESC/RES_BREAK items for SwTextFrame,...
Definition: findfrm.cxx:731
friend void ValidateSz(SwFrame *pFrame)
Definition: calcmove.cxx:1204
void PrepareCursor()
Definition: calcmove.cxx:403
void RemoveFromLayout()
Definition: wsfrm.cxx:1013
bool IsFlowFrame() const
Definition: frame.hxx:1242
void InvalidatePrt()
Definition: frame.hxx:1036
bool IsMoveable(const SwLayoutFrame *_pLayoutFrame=nullptr) const
determine, if frame is moveable in given environment
Definition: findfrm.cxx:1416
SwLayoutFrame * GetNextCellLeaf()
Definition: findfrm.cxx:1579
bool IsRootFrame() const
Definition: frame.hxx:1174
bool IsFooterFrame() const
Definition: frame.hxx:1194
bool IsFootnoteFrame() const
Definition: frame.hxx:1202
SwLayoutFrame * GetUpper()
Definition: frame.hxx:678
virtual void Format(vcl::RenderContext *pRenderContext, const SwBorderAttrs *pAttrs=nullptr)
Definition: unusedf.cxx:25
virtual bool IsLeaveUpperAllowed() const
Definition: tabfrm.cxx:6128
bool IsVertical() const
Definition: frame.hxx:973
SwRootFrame * getRootFrame()
Definition: frame.hxx:679
void SetCompletePaint() const
Definition: frame.hxx:994
virtual const SvxFormatBreakItem & GetBreakItem() const
Definition: findfrm.cxx:711
bool IsFlyFrame() const
Definition: frame.hxx:1210
bool IsContentFrame() const
Definition: frame.hxx:1230
SwFrame * GetPrev()
Definition: frame.hxx:677
bool IsSctFrame() const
Definition: frame.hxx:1214
bool IsVertLR() const
Definition: frame.hxx:979
void InvalidateSize()
Definition: frame.hxx:1029
SwPageFrame * FindPageFrame()
Definition: frame.hxx:680
SwFootnoteFrame * FindFootnoteFrame()
Definition: frame.hxx:1107
SwFrame * GetIndNext()
Definition: frame.hxx:727
SwFootnoteBossFrame * FindFootnoteBossFrame(bool bFootnotes=false)
Definition: findfrm.cxx:460
virtual Size ChgSize(const Size &aNewSize)
Definition: wsfrm.cxx:737
sal_uInt16 GetPhyPageNum() const
Definition: trvlfrm.cxx:1706
virtual void MakeAll(vcl::RenderContext *pRenderContext)=0
void OptPrepareMake()
Definition: calcmove.cxx:378
bool IsBodyFrame() const
Definition: frame.hxx:1206
bool IsNeighbourFrame() const
Definition: frame.hxx:912
bool IsColBodyFrame() const
These SwFrame inlines are here, so that frame.hxx does not need to include layfrm....
Definition: layfrm.hxx:210
bool IsInSct() const
Definition: frame.hxx:967
A layout frame is a frame that contains other frames (m_pLower), e.g. SwPageFrame or SwTabFrame.
Definition: layfrm.hxx:36
virtual void Format(vcl::RenderContext *pRenderContext, const SwBorderAttrs *pAttrs=nullptr) override
"Formats" the Frame; Frame and PrtArea.
Definition: wsfrm.cxx:3443
bool IsAnLower(const SwFrame *) const
Definition: findfrm.cxx:231
virtual void MakeAll(vcl::RenderContext *pRenderContext) override
Definition: calcmove.cxx:944
virtual const SwFrameFormat * GetFormat() const
Definition: ssfrm.cxx:399
const SwFrame * ContainsAny(const bool _bInvestigateFootnoteForSections=false) const
Method <ContainsAny()> doesn't investigate content of footnotes by default.
Definition: findfrm.cxx:129
bool IsBefore(const SwLayoutFrame *_pCheckRefLayFrame) const
method to check relative position of layout frame to a given layout frame.
Definition: findfrm.cxx:258
const SwFrame * Lower() const
Definition: layfrm.hxx:101
static bool FrameMovedFwdByObjPos(const SwDoc &_rDoc, const SwTextFrame &_rTextFrame, sal_uInt32 &_ornToPageNum)
Definition: layouter.cxx:342
SwNodeOffset GetIndex() const
Definition: node.hxx:312
SwNodes & GetNodes()
Node is in which nodes-array/doc?
Definition: node.hxx:742
SwDoc & GetDoc()
Definition: node.hxx:233
SwTableNode * FindTableNode()
Search table node, in which it is.
Definition: node.cxx:380
const IDocumentLayoutAccess & getIDocumentLayoutAccess() const
Provides access to the document layout interface.
Definition: node.cxx:2158
A page of the document layout.
Definition: pagefrm.hxx:58
virtual void MakeAll(vcl::RenderContext *pRenderContext) override
Definition: calcmove.cxx:794
bool IsEmptyPage() const
Definition: pagefrm.hxx:157
bool CheckPageHeightValidForHideWhitespace(SwTwips nDiff)
Is bottom-of-page-frame - bottom-of-text-frame difference valid in case whitespace is hidden?...
Definition: pagechg.cxx:2541
std::unique_ptr< SwSortedObjs > m_pSortedObjs
Definition: pagefrm.hxx:61
size_t GetContentHeight(const tools::Long nTop, const tools::Long nBottom) const
Calculate the content height of a page (without columns).
Definition: calcmove.cxx:726
bool IsVert() const
Definition: frame.hxx:1366
tools::Long GetHeight(const SwRect &rRect) const
Definition: frame.hxx:1381
void SetWidth(SwRect &rRect, tools::Long nNew) const
Definition: frame.hxx:1389
void SetPosX(SwRect &rRect, tools::Long nNew) const
Definition: frame.hxx:1399
tools::Long GetWidth(const SwRect &rRect) const
Definition: frame.hxx:1380
void SetHeight(SwRect &rRect, tools::Long nNew) const
Definition: frame.hxx:1390
tools::Long GetTop(const SwRect &rRect) const
Definition: frame.hxx:1376
bool IsVertL2R() const
Definition: frame.hxx:1367
Point GetPos(const SwRect &rRect) const
Definition: frame.hxx:1382
void SetXMargins(SwFrame &rFrame, tools::Long nLeft, tools::Long nRight) const
Definition: frame.hxx:1406
void SetPosY(SwRect &rRect, tools::Long nNew) const
Definition: frame.hxx:1400
bool OverStep(const SwRect &rRect, tools::Long nPos) const
Definition: frame.hxx:1417
tools::Long GetLeft(const SwRect &rRect) const
Definition: frame.hxx:1378
tools::Long GetBottom(const SwRect &rRect) const
Definition: frame.hxx:1377
tools::Long BottomDist(const SwRect &rRect, tools::Long nPos) const
Definition: frame.hxx:1413
void SetTop(SwRect &rRect, tools::Long nNew) const
Definition: frame.hxx:1385
void Refresh(const SwFrame *pFrame)
Definition: frame.hxx:1358
tools::Long GetPrtBottom(const SwFrame &rFrame) const
Definition: frame.hxx:1409
void SetLeft(SwRect &rRect, tools::Long nNew) const
Definition: frame.hxx:1387
Of course Writer needs its own rectangles.
Definition: swrect.hxx:35
void Height(tools::Long nNew)
Definition: swrect.hxx:193
void Top(const tools::Long nTop)
Definition: swrect.hxx:206
void Pos(const Point &rNew)
Definition: swrect.hxx:171
void SSize(const Size &rNew)
Definition: swrect.hxx:180
void Left(const tools::Long nLeft)
Definition: swrect.hxx:197
void Width(tools::Long nNew)
Definition: swrect.hxx:189
The root element of a Writer document layout.
Definition: rootfrm.hxx:82
SwViewShell * GetCurrShell() const
Definition: rootfrm.hxx:206
const SwPageFrame * GetLastPage() const
Definition: rootfrm.hxx:362
SwSection * GetSection()
Definition: sectfrm.hxx:97
bool MoveAllowed(const SwFrame *) const
Definition: sectfrm.cxx:2400
bool Growable() const
checks whether the SectionFrame is still able to grow, as case may be the environment has to be asked
Definition: sectfrm.cxx:2152
bool IsFootnoteLock() const
Definition: sectfrm.hxx:170
class for collecting anchored objects
Definition: sortedobjs.hxx:49
size_t size() const
Definition: sortedobjs.cxx:43
SwTabFrame is one table in the document layout, containing rows (which contain cells).
Definition: tabfrm.hxx:47
const SwFormatFootnote & GetFootnote() const
Definition: txatbase.hxx:208
Represents the visualization of a paragraph.
Definition: txtfrm.hxx:165
SwContentFrame * JoinFrame()
Definition: frmform.cxx:616
SwTwips GetFootnoteLine(const SwTextFootnote *pFootnote) const
If we're a Footnote that grows towards its reference ... public, because it's needed by SwContentFram...
Definition: txtftn.cxx:273
bool IsLocked() const
Definition: txtfrm.hxx:523
bool IsHiddenNow() const
Hidden.
Definition: txtfrm.cxx:1360
const OUString & GetText() const
Returns the text portion we want to edit (for inline see underneath)
Definition: txtfrm.cxx:1293
SwTextNode const * GetTextNodeForParaProps() const
Definition: txtfrm.cxx:1303
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:111
bool IsCollapse() const
Definition: calcmove.cxx:1034
const OUString & GetText() const
Definition: ndtxt.hxx:242
bool getBrowseMode() const
Definition: viewopt.hxx:580
bool IsWhitespaceHidden() const
Definition: viewopt.hxx:596
vcl::RenderContext * GetOut() const
Definition: viewsh.hxx:347
const SwViewOption * GetViewOptions() const
Definition: viewsh.hxx:433
const SwRect & VisArea() const
Definition: viewsh.cxx:630
sal_Int32 GetBrowseWidth() const
Definition: viewsh.cxx:2089
const Size & GetBrowseBorder() const
Definition: viewsh.cxx:2084
@ TestFormat
@ MoveFwd
@ MakeAll
#define PROTOCOL_ENTER(pFrame, nFunc, nAct, pPar)
Definition: dbg_lay.hxx:92
virtual SotClipboardFormatId GetFormat(const TransferableDataHelper &aHelper) override
SwRectFn fnRectVert
Definition: frame.hxx:1347
#define FRM_NOTE_VERT
Definition: frame.hxx:107
SwFrameType
Definition: frame.hxx:75
#define FRM_NEIGHBOUR
Definition: frame.hxx:106
SwRectFn fnRectVertL2RB2T
Definition: frame.hxx:1347
SwRectFn fnRectHori
Definition: newfrm.cxx:286
SwRectFn fnRectVertL2R
Definition: frame.hxx:1347
constexpr tools::Long BROWSE_HEIGHT
Definition: frmtool.hxx:54
#define FAR_AWAY
Definition: frmtool.hxx:53
static bool bFootnote
Definition: insfnote.cxx:33
void * p
void LOOPING_LOUIE_LIGHT(bool bCondition, const SwTextFrame &rTextFrame)
Definition: layouter.cxx:424
const long LONG_MAX
int i
constexpr auto toTwips(N number, Length from)
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
long Long
SwNodeOffset min(const SwNodeOffset &a, const SwNodeOffset &b)
Definition: nodeoffset.hxx:35
SwNodeOffset abs(const SwNodeOffset &a)
Definition: nodeoffset.hxx:34
const char GetValue[]
SDRTEXTVERTADJUST_TOP
SwRectGet fnGetWidth
Definition: frame.hxx:1294
SwRectSet fnAddRight
Definition: frame.hxx:1309
SwRectGet fnGetHeight
Definition: frame.hxx:1295
SwRectSet fnAddBottom
Definition: frame.hxx:1307
SwFrameGet fnGetPrtBottom
Definition: frame.hxx:1323
SwRectMax fnOverStep
Definition: frame.hxx:1331
SwRectSet fnSubLeft
Definition: frame.hxx:1308
#define MINLAY
Definition: swtypes.hxx:62
tools::Long SwTwips
Definition: swtypes.hxx:51
constexpr sal_Int32 COMPLETE_STRING
Definition: swtypes.hxx:57
@ FramePositionChanged
@ AdjustSizeWithoutFormatting
unsigned char sal_uInt8
unsigned char sal_Bool