LibreOffice Module sw (master)  1
frmtool.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 <svx/svdpage.hxx>
21 #include <editeng/brushitem.hxx>
22 #include <editeng/shaditem.hxx>
23 #include <editeng/ulspitem.hxx>
24 #include <editeng/boxitem.hxx>
25 #include <editeng/lspcitem.hxx>
26 #include <editeng/fhgtitem.hxx>
27 #include <sal/log.hxx>
28 #include <osl/diagnose.h>
29 
30 #include <drawdoc.hxx>
31 #include <fmtornt.hxx>
32 #include <fmthdft.hxx>
33 #include <fmtfsize.hxx>
34 #include <fmtsrnd.hxx>
35 #include <docary.hxx>
36 #include <lineinfo.hxx>
37 #include <swmodule.hxx>
38 #include <pagefrm.hxx>
39 #include <colfrm.hxx>
40 #include <fesh.hxx>
41 #include <viewimp.hxx>
42 #include <viewopt.hxx>
43 #include <dflyobj.hxx>
44 #include <dcontact.hxx>
45 #include <frmatr.hxx>
46 #include <frmtool.hxx>
47 #include <tabfrm.hxx>
48 #include <rowfrm.hxx>
49 #include <ftnfrm.hxx>
50 #include <txtfrm.hxx>
51 #include <notxtfrm.hxx>
52 #include <flyfrms.hxx>
53 #include <layact.hxx>
54 #include <pagedesc.hxx>
55 #include <section.hxx>
56 #include <sectfrm.hxx>
57 #include <node2lay.hxx>
58 #include <ndole.hxx>
59 #include <hints.hxx>
60 #include "layhelp.hxx"
61 #include <laycache.hxx>
62 #include <rootfrm.hxx>
63 #include <paratr.hxx>
64 #include <redline.hxx>
65 #include <sortedobjs.hxx>
66 #include <objectformatter.hxx>
67 #include <calbck.hxx>
68 #include <ndtxt.hxx>
69 #include <undobj.hxx>
72 #include <IDocumentTimerAccess.hxx>
75 #include <IDocumentState.hxx>
76 #include <frameformats.hxx>
77 #include <boost/circular_buffer.hpp>
79 
80 using namespace ::com::sun::star;
81 
82 namespace {
83  // FIXME: would likely better be a member of SwRootFrame instead of a global flag
84  bool isFlyCreationSuppressed = false;
85 }
86 namespace sw {
87  FlyCreationSuppressor::FlyCreationSuppressor(bool wasAlreadySuppressedAllowed)
88  : m_wasAlreadySuppressed(isFlyCreationSuppressed)
89  {
90  (void)wasAlreadySuppressedAllowed;
91  assert(wasAlreadySuppressedAllowed || !isFlyCreationSuppressed);
92  isFlyCreationSuppressed = true;
93  }
95  {
96  isFlyCreationSuppressed = m_wasAlreadySuppressed;
97  }
98 }
99 
100 bool bObjsDirect = true;
102 
104 bool StackHack::s_bLocked = false;
105 
107  mpFrame( pF ),
108  maFrame( pF->getFrameArea() ),
109  maPrt( pF->getFramePrintArea() ),
110  mbInvaKeep( false ),
111  mbValidSize( pF->isFrameAreaSizeValid() )
112 {
113  if ( pF->IsTextFrame() )
114  {
115  mnFlyAnchorOfst = static_cast<SwTextFrame*>(pF)->GetBaseOffsetForFly( true );
116  mnFlyAnchorOfstNoWrap = static_cast<SwTextFrame*>(pF)->GetBaseOffsetForFly( false );
117  }
118  else
119  {
120  mnFlyAnchorOfst = 0;
122  }
123 
124  mbHadFollow = pF->IsContentFrame() && static_cast<SwContentFrame*>(pF)->GetFollow();
125 }
126 
127 SwFrameNotify::~SwFrameNotify() COVERITY_NOEXCEPT_FALSE
128 {
129  SwRectFnSet aRectFnSet(mpFrame);
130  const bool bAbsP = aRectFnSet.PosDiff(maFrame, mpFrame->getFrameArea());
131  const bool bChgWidth =
132  aRectFnSet.GetWidth(maFrame) != aRectFnSet.GetWidth(mpFrame->getFrameArea());
133  const bool bChgHeight =
134  aRectFnSet.GetHeight(maFrame)!=aRectFnSet.GetHeight(mpFrame->getFrameArea());
135  const bool bChgFlyBasePos = mpFrame->IsTextFrame() &&
136  ( ( mnFlyAnchorOfst != static_cast<SwTextFrame*>(mpFrame)->GetBaseOffsetForFly( true ) ) ||
137  ( mnFlyAnchorOfstNoWrap != static_cast<SwTextFrame*>(mpFrame)->GetBaseOffsetForFly( false ) ) );
138 
139  if ( mpFrame->IsFlowFrame() && !mpFrame->IsInFootnote() )
140  {
142 
143  if ( !pFlow->IsFollow() )
144  {
145  if ( !mpFrame->GetIndPrev() )
146  {
147  if ( mbInvaKeep )
148  {
149  SwFrame *pPre = mpFrame->FindPrev();
150  if ( pPre && pPre->IsFlowFrame() )
151  {
152  // 1. pPre wants to keep with me:
153  bool bInvalidPrePos = SwFlowFrame::CastFlowFrame(pPre)->IsKeep(pPre->GetAttrSet()->GetKeep(), pPre->GetBreakItem())
154  && pPre->GetIndPrev();
155 
156  // 2. pPre is a table and the last row wants to keep with me:
157  if ( !bInvalidPrePos && pPre->IsTabFrame() )
158  {
159  SwTabFrame* pPreTab = static_cast<SwTabFrame*>(pPre);
161  {
162  SwRowFrame* pLastRow = static_cast<SwRowFrame*>(pPreTab->GetLastLower());
163  if ( pLastRow && pLastRow->ShouldRowKeepWithNext() )
164  bInvalidPrePos = true;
165  }
166  }
167 
168  if ( bInvalidPrePos )
169  pPre->InvalidatePos();
170  }
171  }
172  }
173  else if ( !pFlow->HasFollow() )
174  {
175  tools::Long nOldHeight = aRectFnSet.GetHeight(maFrame);
176  tools::Long nNewHeight = aRectFnSet.GetHeight(mpFrame->getFrameArea());
177  if( (nOldHeight > nNewHeight) || (!nOldHeight && nNewHeight) )
178  pFlow->CheckKeep();
179  }
180  }
181  }
182 
183  if ( bAbsP )
184  {
186 
187  SwFrame* pNxt = mpFrame->GetIndNext();
188  // #121888# - skip empty section frames
189  while ( pNxt &&
190  pNxt->IsSctFrame() && !static_cast<SwSectionFrame*>(pNxt)->GetSection() )
191  {
192  pNxt = pNxt->GetIndNext();
193  }
194 
195  if ( pNxt )
196  pNxt->InvalidatePos();
197  else
198  {
199  // #104100# - correct condition for setting retouche
200  // flag for vertical layout.
201  if( mpFrame->IsRetoucheFrame() &&
202  aRectFnSet.TopDist( maFrame, aRectFnSet.GetTop(mpFrame->getFrameArea()) ) > 0 )
203  {
204  mpFrame->SetRetouche();
205  }
206 
207  // A fresh follow frame does not have to be invalidated, because
208  // it is already formatted:
209  if ( mbHadFollow || !mpFrame->IsContentFrame() || !static_cast<SwContentFrame*>(mpFrame)->GetFollow() )
210  {
211  if ( !mpFrame->IsTabFrame() || !static_cast<SwTabFrame*>(mpFrame)->GetFollow() )
213  }
214  }
215  }
216 
217  //For each resize of the background graphics is a repaint necessary.
218  const bool bPrtWidth =
219  aRectFnSet.GetWidth(maPrt) != aRectFnSet.GetWidth(mpFrame->getFramePrintArea());
220  const bool bPrtHeight =
221  aRectFnSet.GetHeight(maPrt)!=aRectFnSet.GetHeight(mpFrame->getFramePrintArea());
222  if ( bPrtWidth || bPrtHeight )
223  {
224  bool bUseNewFillProperties(false);
226  {
228  if(aFillAttributes && aFillAttributes->isUsed())
229  {
230  bUseNewFillProperties = true;
231  // use SetCompletePaint if needed
232  if(aFillAttributes->needCompleteRepaint())
233  {
235  }
236  }
237  }
238  if (!bUseNewFillProperties)
239  {
241  if(GPOS_NONE != ePos && GPOS_TILED != ePos)
243  }
244  }
245  else
246  {
247  // #97597# - consider case that *only* margins between
248  // frame and printing area has changed. Then, frame has to be repainted,
249  // in order to force paint of the margin areas.
250  if ( !bAbsP && (bChgWidth || bChgHeight) )
251  {
253  }
254  }
255 
256  const bool bPrtP = aRectFnSet.PosDiff( maPrt, mpFrame->getFramePrintArea() );
257  if ( bAbsP || bPrtP || bChgWidth || bChgHeight ||
258  bPrtWidth || bPrtHeight || bChgFlyBasePos )
259  {
260  if( mpFrame->IsAccessibleFrame() )
261  {
262  SwRootFrame *pRootFrame = mpFrame->getRootFrame();
263  if( pRootFrame && pRootFrame->IsAnyShellAccessible() &&
264  pRootFrame->GetCurrShell() )
265  {
266  pRootFrame->GetCurrShell()->Imp()->MoveAccessibleFrame( mpFrame, maFrame );
267  }
268  }
269 
270  // Notification of anchored objects
271  if ( mpFrame->GetDrawObjs() )
272  {
273  const SwSortedObjs &rObjs = *mpFrame->GetDrawObjs();
274  SwPageFrame* pPageFrame = nullptr;
275  for (SwAnchoredObject* pObj : rObjs)
276  {
277  // OD 2004-03-31 #i26791# - no general distinction between
278  // Writer fly frames and drawing objects
279  bool bNotify = false;
280  bool bNotifySize = false;
281  SwContact* pContact = ::GetUserCall( pObj->GetDrawObj() );
282  const bool bAnchoredAsChar = pContact->ObjAnchoredAsChar();
283  if ( !bAnchoredAsChar )
284  {
285  // Notify object, which aren't anchored as-character:
286 
287  // always notify objects, if frame position has changed
288  // or if the object is to-page|to-fly anchored.
289  if ( bAbsP ||
290  pContact->ObjAnchoredAtPage() ||
291  pContact->ObjAnchoredAtFly() )
292  {
293  bNotify = true;
294 
295  // assure that to-fly anchored Writer fly frames are
296  // registered at the correct page frame, if frame
297  // position has changed.
298  if ( bAbsP && pContact->ObjAnchoredAtFly() &&
299  dynamic_cast<const SwFlyFrame*>( pObj) != nullptr )
300  {
301  // determine to-fly anchored Writer fly frame
302  SwFlyFrame* pFlyFrame = static_cast<SwFlyFrame*>(pObj);
303  // determine page frame of to-fly anchored
304  // Writer fly frame
305  SwPageFrame* pFlyPageFrame = pFlyFrame->FindPageFrame();
306  // determine page frame, if needed.
307  if ( !pPageFrame )
308  {
309  pPageFrame = mpFrame->FindPageFrame();
310  }
311  if ( pPageFrame != pFlyPageFrame )
312  {
313  OSL_ENSURE( pFlyPageFrame, "~SwFrameNotify: Fly from Nowhere" );
314  if( pFlyPageFrame )
315  pFlyPageFrame->MoveFly( pFlyFrame, pPageFrame );
316  else
317  pPageFrame->AppendFlyToPage( pFlyFrame );
318  }
319  }
320  }
321  // otherwise the objects are notified in dependence to
322  // its positioning and alignment
323  else
324  {
325  const SwFormatVertOrient& rVert =
326  pContact->GetFormat()->GetVertOrient();
327  if ( ( rVert.GetVertOrient() == text::VertOrientation::CENTER ||
328  rVert.GetVertOrient() == text::VertOrientation::BOTTOM ||
329  rVert.GetRelationOrient() == text::RelOrientation::PRINT_AREA ) &&
330  ( bChgHeight || bPrtHeight ) )
331  {
332  bNotify = true;
333  }
334  if ( !bNotify )
335  {
336  const SwFormatHoriOrient& rHori =
337  pContact->GetFormat()->GetHoriOrient();
338  if ( ( rHori.GetHoriOrient() != text::HoriOrientation::NONE ||
339  rHori.GetRelationOrient()== text::RelOrientation::PRINT_AREA ||
340  rHori.GetRelationOrient()== text::RelOrientation::FRAME ) &&
341  ( bChgWidth || bPrtWidth || bChgFlyBasePos ) )
342  {
343  bNotify = true;
344  }
345  }
346  }
347  }
348  else if ( bPrtWidth )
349  {
350  // Notify as-character anchored objects, if printing area
351  // width has changed.
352  bNotify = true;
353  bNotifySize = true;
354  }
355 
356  // perform notification via the corresponding invalidations
357  if ( bNotify )
358  {
359  if ( auto pFlyFrame = dynamic_cast<SwFlyFrame*>( pObj) )
360  {
361  if ( bNotifySize )
362  pFlyFrame->InvalidateSize_();
363  // #115759# - no invalidation of
364  // position for as-character anchored objects.
365  if ( !bAnchoredAsChar )
366  {
367  pFlyFrame->InvalidatePos_();
368  }
369  pFlyFrame->Invalidate_();
370  }
371  else if ( dynamic_cast<const SwAnchoredDrawObject*>( pObj) != nullptr )
372  {
373  // #115759# - no invalidation of
374  // position for as-character anchored objects.
375  if ( !bAnchoredAsChar )
376  {
377  pObj->InvalidateObjPos();
378  }
379  }
380  else
381  {
382  OSL_FAIL( "<SwContentNotify::~SwContentNotify()> - unknown anchored object type." );
383  }
384  }
385  }
386  }
387  }
389  {
390  SwRootFrame *pRootFrame = mpFrame->getRootFrame();
391  if( pRootFrame && pRootFrame->IsAnyShellAccessible() &&
392  pRootFrame->GetCurrShell() )
393  {
395  }
396  }
397 
398  // #i9046# Automatic frame width
399  SwFlyFrame* pFly = nullptr;
400  // #i35879# Do not trust the inf flags. pFrame does not
401  // necessarily have to have an upper!
402  if ( mpFrame->IsFlyFrame() || nullptr == ( pFly = mpFrame->ImplFindFlyFrame() ))
403  return;
404 
405  // #i61999#
406  // no invalidation of columned Writer fly frames, because automatic
407  // width doesn't make sense for such Writer fly frames.
408  if ( !pFly->Lower() || pFly->Lower()->IsColumnFrame() )
409  return;
410 
411  const SwFormatFrameSize &rFrameSz = pFly->GetFormat()->GetFrameSize();
412 
413  // This could be optimized. Basically the fly frame only has to
414  // be invalidated, if the first line of pFrame (if pFrame is a content
415  // frame, for other frame types it's the print area) has changed its
416  // size and pFrame was responsible for the current width of pFly. On
417  // the other hand, this is only rarely used and re-calculation of
418  // the fly frame does not cause too much trouble. So we keep it this
419  // way:
420  if ( SwFrameSize::Fixed != rFrameSz.GetWidthSizeType() )
421  {
422  // #i50668#, #i50998# - invalidation of position
423  // of as-character anchored fly frames not needed and can cause
424  // layout loops
425  if ( dynamic_cast<const SwFlyInContentFrame*>( pFly) == nullptr )
426  {
427  pFly->InvalidatePos();
428  }
429  pFly->InvalidateSize();
430  }
431 }
432 
434  SwFrameNotify( pLayFrame ),
435  m_bLowersComplete( false )
436 {
437 }
438 
439 // OD 2004-05-11 #i28701# - local method to invalidate the position of all
440 // frames inclusive its floating screen objects, which are lowers of the given
441 // layout frame
442 static void lcl_InvalidatePosOfLowers( SwLayoutFrame& _rLayoutFrame )
443 {
444  if( _rLayoutFrame.IsFlyFrame() && _rLayoutFrame.GetDrawObjs() )
445  {
446  _rLayoutFrame.InvalidateObjs( false );
447  }
448 
449  SwFrame* pLowerFrame = _rLayoutFrame.Lower();
450  while ( pLowerFrame )
451  {
452  pLowerFrame->InvalidatePos();
453  if ( pLowerFrame->IsTextFrame() )
454  {
455  static_cast<SwTextFrame*>(pLowerFrame)->Prepare( PrepareHint::FramePositionChanged );
456  }
457  else if ( pLowerFrame->IsTabFrame() )
458  {
459  pLowerFrame->InvalidatePrt();
460  }
461 
462  pLowerFrame->InvalidateObjs( false );
463 
464  pLowerFrame = pLowerFrame->GetNext();
465  }
466 }
467 
469 {
470  SwLayoutFrame *pLay = static_cast<SwLayoutFrame*>(mpFrame);
471  SwRectFnSet aRectFnSet(pLay);
472  bool bNotify = false;
473  if ( pLay->getFramePrintArea().SSize() != maPrt.SSize() )
474  {
475  if ( !IsLowersComplete() )
476  {
477  bool bInvaPercent;
478 
479  if ( pLay->IsRowFrame() )
480  {
481  bInvaPercent = true;
482  tools::Long nNew = aRectFnSet.GetHeight(pLay->getFramePrintArea());
483  if( nNew != aRectFnSet.GetHeight(maPrt) )
484  static_cast<SwRowFrame*>(pLay)->AdjustCells( nNew, true);
485  if( aRectFnSet.GetWidth(pLay->getFramePrintArea())
486  != aRectFnSet.GetWidth(maPrt) )
487  static_cast<SwRowFrame*>(pLay)->AdjustCells( 0, false );
488  }
489  else
490  {
491  //Proportional adoption of the internal.
492  //1. If the formatted is no Fly
493  //2. If he contains no columns
494  //3. If the Fly has a fixed height and the columns
495  // are next to be.
496  // Hoehe danebenliegen.
497  //4. Never at SectionFrames.
498  bool bLow;
499  if( pLay->IsFlyFrame() )
500  {
501  if ( pLay->Lower() )
502  {
503  bLow = !pLay->Lower()->IsColumnFrame() ||
504  aRectFnSet.GetHeight(pLay->Lower()->getFrameArea())
505  != aRectFnSet.GetHeight(pLay->getFramePrintArea());
506  }
507  else
508  bLow = false;
509  }
510  else if( pLay->IsSctFrame() )
511  {
512  if ( pLay->Lower() )
513  {
514  if( pLay->Lower()->IsColumnFrame() && pLay->Lower()->GetNext() )
515  bLow = pLay->Lower()->getFrameArea().Height() != pLay->getFramePrintArea().Height();
516  else
517  bLow = pLay->getFramePrintArea().Width() != maPrt.Width();
518  }
519  else
520  bLow = false;
521  }
522  else if( pLay->IsFooterFrame() && !pLay->HasFixSize() )
523  bLow = pLay->getFramePrintArea().Width() != maPrt.Width();
524  else
525  bLow = true;
526  bInvaPercent = bLow;
527  if ( bLow )
528  {
529  pLay->ChgLowersProp( maPrt.SSize() );
530  }
531  // If the PrtArea has been extended, it might be possible that the chain of parts
532  // can take another frame. As a result, the "possible right one" needs to be
533  // invalidated. This only pays off if this or its Uppers are moveable sections.
534  // A PrtArea has been extended if width or height are larger than before.
535  if ( (pLay->getFramePrintArea().Height() > maPrt.Height() ||
536  pLay->getFramePrintArea().Width() > maPrt.Width()) &&
537  (pLay->IsMoveable() || pLay->IsFlyFrame()) )
538  {
539  SwFrame *pTmpFrame = pLay->Lower();
540  if ( pTmpFrame && pTmpFrame->IsFlowFrame() )
541  {
542  while ( pTmpFrame->GetNext() )
543  pTmpFrame = pTmpFrame->GetNext();
544  pTmpFrame->InvalidateNextPos();
545  }
546  }
547  }
548  bNotify = true;
549  //EXPENSIVE!! But how we do it more elegant?
550  if( bInvaPercent )
551  pLay->InvaPercentLowers( pLay->getFramePrintArea().Height() - maPrt.Height() );
552  }
553  if ( pLay->IsTabFrame() )
554  //So that _only_ the shadow is drawn while resizing.
555  static_cast<SwTabFrame*>(pLay)->SetComplete();
556  else
557  {
558  const SwViewShell *pSh = pLay->getRootFrame()->GetCurrShell();
559  if( !( pSh && pSh->GetViewOptions()->getBrowseMode() ) ||
560  !(pLay->GetType() & (SwFrameType::Body | SwFrameType::Page)) )
561  //Thereby the subordinates are retouched clean.
562  //Example problem: Take the Flys with the handles and downsize.
563  //Not for body and page, otherwise it flickers when loading HTML.
564  pLay->SetCompletePaint();
565  }
566  }
567  //Notify Lower if the position has changed.
568  const bool bPrtPos = aRectFnSet.PosDiff( maPrt, pLay->getFramePrintArea() );
569  const bool bPos = bPrtPos || aRectFnSet.PosDiff( maFrame, pLay->getFrameArea() );
570  const bool bSize = pLay->getFrameArea().SSize() != maFrame.SSize();
571 
572  if ( bPos && pLay->Lower() && !IsLowersComplete() )
573  {
574  pLay->Lower()->InvalidatePos();
575  SwFootnoteFrame* pFtnFrame = pLay->Lower()->IsFootnoteFrame() ?
576  static_cast<SwFootnoteFrame*>(pLay->Lower()) : nullptr;
577  SwFrame* pFtnLower = pFtnFrame ? pFtnFrame->Lower() : nullptr;
578  if (pFtnLower)
579  pFtnLower->InvalidatePos();
580  }
581 
582  if ( bPrtPos )
583  pLay->SetCompletePaint();
584 
585  //Inform the Follower if the SSize has changed.
586  if ( bSize )
587  {
588  if( pLay->GetNext() )
589  {
590  if ( pLay->GetNext()->IsLayoutFrame() )
591  pLay->GetNext()->InvalidatePos_();
592  else
593  pLay->GetNext()->InvalidatePos();
594  }
595  else if( pLay->IsSctFrame() )
596  pLay->InvalidateNextPos();
597  }
598  if ( !IsLowersComplete() &&
600  pLay->Lower() && pLay->Lower()->IsColumnFrame()) &&
601  (bPos || bNotify) &&
603  {
604  // #i44016# - force unlock of position of lower objects.
605  // #i43913# - no unlock of position of objects,
606  // if <pLay> is a cell frame, and its table frame resp. its parent table
607  // frame is locked.
608  // #i47458# - force unlock of position of lower objects,
609  // only if position of layout frame has changed.
610  bool bUnlockPosOfObjs( bPos );
611  if ( bUnlockPosOfObjs && pLay->IsCellFrame() )
612  {
613  SwTabFrame* pTabFrame( pLay->FindTabFrame() );
614  if ( pTabFrame &&
615  ( pTabFrame->IsJoinLocked() ||
616  ( pTabFrame->IsFollow() &&
617  pTabFrame->FindMaster()->IsJoinLocked() ) ) )
618  {
619  bUnlockPosOfObjs = false;
620  }
621  }
622  // #i49383# - check for footnote frame, if unlock
623  // of position of lower objects is allowed.
624  else if ( bUnlockPosOfObjs && pLay->IsFootnoteFrame() )
625  {
626  bUnlockPosOfObjs = static_cast<SwFootnoteFrame*>(pLay)->IsUnlockPosOfLowerObjs();
627  }
628  // #i51303# - no unlock of object positions for sections
629  else if ( bUnlockPosOfObjs && pLay->IsSctFrame() )
630  {
631  bUnlockPosOfObjs = false;
632  }
633  pLay->NotifyLowerObjs( bUnlockPosOfObjs );
634  }
635  if ( bPos && pLay->IsFootnoteFrame() && pLay->Lower() )
636  {
637  // OD 2004-05-11 #i28701#
639  }
640  if( ( bPos || bSize ) && pLay->IsFlyFrame() && static_cast<SwFlyFrame*>(pLay)->GetAnchorFrame()
641  && static_cast<SwFlyFrame*>(pLay)->GetAnchorFrame()->IsFlyFrame() )
642  static_cast<SwFlyFrame*>(pLay)->AnchorFrame()->InvalidateSize();
643 }
644 
646  SwLayNotify( pFlyFrame ),
647  // #115759# - keep correct page frame - the page frame
648  // the Writer fly frame is currently registered at.
649  pOldPage( pFlyFrame->GetPageFrame() ),
650  aFrameAndSpace( pFlyFrame->GetObjRectWithSpaces() )
651 {
652 }
653 
655 {
656  SwFlyFrame *pFly = static_cast<SwFlyFrame*>(mpFrame);
657  if ( pFly->IsNotifyBack() )
658  {
659  SwViewShell *pSh = pFly->getRootFrame()->GetCurrShell();
660  SwViewShellImp *pImp = pSh ? pSh->Imp() : nullptr;
661  if ( !pImp || !pImp->IsAction() || !pImp->GetLayAction().IsAgain() )
662  {
663  //If in the LayAction the IsAgain is set it can be
664  //that the old page is destroyed in the meantime!
666  // #i35640# - additional notify anchor text frame,
667  // if Writer fly frame has changed its page
668  if ( pFly->GetAnchorFrame()->IsTextFrame() &&
669  pFly->GetPageFrame() != pOldPage )
670  {
672  }
673  }
674  pFly->ResetNotifyBack();
675  }
676 
677  //Have the size or the position changed,
678  //so should the view know this.
679  SwRectFnSet aRectFnSet(pFly);
680  const bool bPosChgd = aRectFnSet.PosDiff( maFrame, pFly->getFrameArea() );
681  const bool bFrameChgd = pFly->getFrameArea().SSize() != maFrame.SSize();
682  const bool bPrtChgd = maPrt != pFly->getFramePrintArea();
683  if ( bPosChgd || bFrameChgd || bPrtChgd )
684  {
685  pFly->NotifyDrawObj();
686  }
687  if ( bPosChgd && maFrame.Pos().X() != FAR_AWAY )
688  {
689  // OD 2004-05-10 #i28701# - no direct move of lower Writer fly frames.
690  // reason: New positioning and alignment (e.g. to-paragraph anchored,
691  // but aligned at page) are introduced.
692  // <SwLayNotify::~SwLayNotify()> takes care of invalidation of lower
693  // floating screen objects by calling method <SwLayoutFrame::NotifyLowerObjs()>.
694 
695  if ( pFly->IsFlyAtContentFrame() )
696  {
697  SwFrame *pNxt = pFly->AnchorFrame()->FindNext();
698  while (pNxt)
699  {
700  pNxt->InvalidatePos();
701  if (!pNxt->IsSctFrame())
702  {
703  break;
704  }
705  // invalidating pos of a section frame doesn't have much
706  // effect, so try again with its lower
707  pNxt = static_cast<SwSectionFrame*>(pNxt)->Lower();
708  }
709  }
710 
711  // #i26945# - notify anchor.
712  // Needed for negative positioned Writer fly frames
713  if ( pFly->GetAnchorFrame()->IsTextFrame() )
714  {
716  }
717  }
718 
719  // OD 2004-05-13 #i28701#
720  // #i45180# - no adjustment of layout process flags and
721  // further notifications/invalidations, if format is called by grow/shrink
722  if ( !pFly->ConsiderObjWrapInfluenceOnObjPos() )
723  return;
724  if (pFly->IsFlyFreeFrame())
725  {
726  if (static_cast<SwFlyFreeFrame*>(pFly)->IsNoMoveOnCheckClip())
727  return;
728  }
729 
730  // #i54138# - suppress restart of the layout process
731  // on changed frame height.
732  // Note: It doesn't seem to be necessary and can cause layout loops.
733  if ( bPosChgd )
734  {
735  // indicate a restart of the layout process
736  pFly->SetRestartLayoutProcess( true );
737  }
738  else
739  {
740  // lock position
741  pFly->LockPosition();
742  }
743 
744  if ( pFly->ConsiderForTextWrap() )
745  return;
746 
747  // indicate that object has to be considered for text wrap
748  pFly->SetConsiderForTextWrap( true );
749  // invalidate 'background' in order to allow its 'background'
750  // to wrap around it.
751  pFly->NotifyBackground( pFly->GetPageFrame(),
752  pFly->GetObjRectWithSpaces(),
754  // invalidate position of anchor frame in order to force
755  // a re-format of the anchor frame, which also causes a
756  // re-format of the invalid previous frames of the anchor frame.
757  pFly->AnchorFrame()->InvalidatePos();
758 }
759 
761  SwFrameNotify( pContentFrame ),
762  // OD 08.01.2004 #i11859#
763  mbChkHeightOfLastLine( false ),
764  mnHeightOfLastLine( 0 ),
765  // OD 2004-02-26 #i25029#
766  mbInvalidatePrevPrtArea( false ),
767  mbBordersJoinedWithPrev( false )
768 {
769  // OD 08.01.2004 #i11859#
770  if ( !pContentFrame->IsTextFrame() )
771  return;
772 
773  SwTextFrame* pTextFrame = static_cast<SwTextFrame*>(pContentFrame);
775  {
776  const SvxLineSpacingItem &rSpace = pTextFrame->GetAttrSet()->GetLineSpacing();
777  if ( rSpace.GetInterLineSpaceRule() == SvxInterLineSpaceRule::Prop )
778  {
779  mbChkHeightOfLastLine = true;
780  mnHeightOfLastLine = pTextFrame->GetHeightOfLastLine();
781  }
782  }
783 }
784 
786 {
787  SwContentFrame *pCnt = static_cast<SwContentFrame*>(mpFrame);
789  pCnt->SetCompletePaint();
790 
791  SwRectFnSet aRectFnSet(pCnt);
792  if ( pCnt->IsInTab() && ( aRectFnSet.PosDiff( pCnt->getFrameArea(), maFrame ) ||
793  pCnt->getFrameArea().SSize() != maFrame.SSize()))
794  {
795  SwLayoutFrame* pCell = pCnt->GetUpper();
796  while( !pCell->IsCellFrame() && pCell->GetUpper() )
797  pCell = pCell->GetUpper();
798  OSL_ENSURE( pCell->IsCellFrame(), "Where's my cell?" );
800  pCell->InvalidatePrt(); //for the vertical align.
801  }
802 
803  // OD 2004-02-26 #i25029#
805  pCnt->IsTextFrame() &&
806  !pCnt->IsFollow() && !pCnt->GetIndPrev() )
807  {
808  // determine previous frame
809  SwFrame* pPrevFrame = pCnt->FindPrev();
810  // skip empty section frames and hidden text frames
811  {
812  while ( pPrevFrame &&
813  ( ( pPrevFrame->IsSctFrame() &&
814  !static_cast<SwSectionFrame*>(pPrevFrame)->GetSection() ) ||
815  ( pPrevFrame->IsTextFrame() &&
816  static_cast<SwTextFrame*>(pPrevFrame)->IsHiddenNow() ) ) )
817  {
818  pPrevFrame = pPrevFrame->FindPrev();
819  }
820  }
821 
822  // Invalidate printing area of found previous frame
823  if ( pPrevFrame )
824  {
825  if ( pPrevFrame->IsSctFrame() )
826  {
827  if ( pCnt->IsInSct() )
828  {
829  // Note: found previous frame is a section frame and
830  // <pCnt> is also inside a section.
831  // Thus due to <mbBordersJoinedWithPrev>,
832  // <pCnt> had joined its borders/shadow with the
833  // last content of the found section.
834  // Invalidate printing area of last content in found section.
835  SwFrame* pLstContentOfSctFrame =
836  static_cast<SwSectionFrame*>(pPrevFrame)->FindLastContent();
837  if ( pLstContentOfSctFrame )
838  {
839  pLstContentOfSctFrame->InvalidatePrt();
840  }
841  }
842  }
843  else
844  {
845  pPrevFrame->InvalidatePrt();
846  }
847  }
848  }
849 
850  const bool bFirst = aRectFnSet.GetWidth(maFrame) == 0;
851 
852  if ( pCnt->IsNoTextFrame() )
853  {
854  //Active PlugIn's or OLE-Objects should know something of the change
855  //thereby they move their window appropriate.
856  SwViewShell *pSh = pCnt->getRootFrame()->GetCurrShell();
857  if ( pSh )
858  {
859  SwOLENode *const pNd(static_cast<SwNoTextFrame*>(pCnt)->GetNode()->GetOLENode());
860  if (nullptr != pNd &&
861  (pNd->GetOLEObj().IsOleRef() ||
862  pNd->IsOLESizeInvalid()) )
863  {
864  const bool bNoTextFramePrtAreaChanged =
865  ( maPrt.SSize().Width() != 0 &&
866  maPrt.SSize().Height() != 0 ) &&
867  maPrt.SSize() != pCnt->getFramePrintArea().SSize();
868  OSL_ENSURE( pCnt->IsInFly(), "OLE not in FlyFrame" );
869  SwFlyFrame *pFly = pCnt->FindFlyFrame();
870  svt::EmbeddedObjectRef& xObj = pNd->GetOLEObj().GetObject();
871  SwFEShell *pFESh = nullptr;
872  for(SwViewShell& rCurrentShell : pSh->GetRingContainer())
873  { if ( dynamic_cast<const SwCursorShell*>( &rCurrentShell) != nullptr )
874  {
875  pFESh = static_cast<SwFEShell*>(&rCurrentShell);
876  // #108369#: Here used to be the condition if (!bFirst).
877  // I think this should mean "do not call CalcAndSetScale"
878  // if the frame is formatted for the first time.
879  // Unfortunately this is not valid anymore since the
880  // SwNoTextFrame already gets a width during CalcLowerPreps.
881  // Nevertheless, the indention of !bFirst seemed to be
882  // to assure that the OLE objects have already been notified
883  // if necessary before calling CalcAndSetScale.
884  // So I replaced !bFirst by !IsOLESizeInvalid. There is
885  // one additional problem specific to the word import:
886  // The layout is calculated _before_ calling PrtOLENotify,
887  // and the OLE objects are not invalidated during import.
888  // Therefore I added the condition !IsUpdateExpField,
889  // have a look at the occurrence of CalcLayout in
890  // uiview/view.cxx.
891  if ( !pNd->IsOLESizeInvalid() &&
893  pFESh->CalcAndSetScale( xObj,
894  &pFly->getFramePrintArea(), &pFly->getFrameArea(),
895  bNoTextFramePrtAreaChanged );
896  }
897  }
898 
899  if ( pFESh && pNd->IsOLESizeInvalid() )
900  {
901  pNd->SetOLESizeInvalid( false );
902  pFESh->CalcAndSetScale( xObj ); // create client
903  }
904  }
905  // ditto animated graphics
906  if ( getFrameArea().HasArea() && static_cast<SwNoTextFrame*>(pCnt)->HasAnimation() )
907  {
908  static_cast<SwNoTextFrame*>(pCnt)->StopAnimation();
910  }
911  }
912  }
913 
914  if ( bFirst )
915  {
916  pCnt->SetRetouche(); //fix(13870)
917 
918  SwDoc& rDoc = pCnt->IsTextFrame()
919  ? static_cast<SwTextFrame*>(pCnt)->GetDoc()
920  : static_cast<SwNoTextFrame*>(pCnt)->GetNode()->GetDoc();
921  if ( !rDoc.GetSpzFrameFormats()->empty() &&
923  {
924  // If certain import filters for foreign file format import
925  // AT_PAGE anchored objects, the corresponding page number is
926  // typically not known. In this case the content position is
927  // stored at which the anchored object is found in the
928  // imported document.
929  // When this content is formatted it is the time at which
930  // the page is known. Thus, this data can be corrected now.
931 
932  const SwPageFrame *pPage = nullptr;
933  SwFrameFormats *pTable = rDoc.GetSpzFrameFormats();
934 
935  for ( size_t i = 0; i < pTable->size(); ++i )
936  {
937  SwFrameFormat *pFormat = (*pTable)[i];
938  const SwFormatAnchor &rAnch = pFormat->GetAnchor();
939  if ( RndStdIds::FLY_AT_PAGE != rAnch.GetAnchorId() ||
940  rAnch.GetContentAnchor() == nullptr )
941  {
942  continue;
943  }
944 
945  if (FrameContainsNode(*pCnt, rAnch.GetContentAnchor()->nNode.GetIndex()))
946  {
947  OSL_FAIL( "<SwContentNotify::~SwContentNotify()> - to page anchored object with content position." );
948  if ( !pPage )
949  {
950  pPage = pCnt->FindPageFrame();
951  }
952  SwFormatAnchor aAnch( rAnch );
953  aAnch.SetAnchor( nullptr );
954  aAnch.SetPageNum( pPage->GetPhyPageNum() );
955  pFormat->SetFormatAttr( aAnch );
956  if ( RES_DRAWFRMFMT != pFormat->Which() )
957  {
958  pFormat->MakeFrames();
959  }
960  }
961  }
962  }
963  }
964 
965  // OD 12.01.2004 #i11859# - invalidate printing area of following frame,
966  // if height of last line has changed.
967  if ( pCnt->IsTextFrame() && mbChkHeightOfLastLine )
968  {
969  if ( mnHeightOfLastLine != static_cast<SwTextFrame*>(pCnt)->GetHeightOfLastLine() )
970  {
971  pCnt->InvalidateNextPrtArea();
972  }
973  }
974 
975  // #i44049#
976  if ( pCnt->IsTextFrame() && aRectFnSet.PosDiff( maFrame, pCnt->getFrameArea() ) )
977  {
978  pCnt->InvalidateObjs();
979  }
980 
981  // #i43255# - move code to invalidate at-character
982  // anchored objects due to a change of its anchor character from
983  // method <SwTextFrame::Format(..)>.
984  if ( !pCnt->IsTextFrame() )
985  return;
986 
987  SwTextFrame* pMasterFrame = pCnt->IsFollow()
988  ? static_cast<SwTextFrame*>(pCnt)->FindMaster()
989  : static_cast<SwTextFrame*>(pCnt);
990  if ( pMasterFrame && !pMasterFrame->IsFlyLock() &&
991  pMasterFrame->GetDrawObjs() )
992  {
993  SwSortedObjs* pObjs = pMasterFrame->GetDrawObjs();
994  for (SwAnchoredObject* pAnchoredObj : *pObjs)
995  {
996  if ( pAnchoredObj->GetFrameFormat().GetAnchor().GetAnchorId()
997  == RndStdIds::FLY_AT_CHAR )
998  {
999  pAnchoredObj->CheckCharRectAndTopOfLine( !pMasterFrame->IsEmpty() );
1000  }
1001  }
1002  }
1003 }
1004 
1005 // note this *cannot* be static because it's a friend
1006 void AppendObj(SwFrame *const pFrame, SwPageFrame *const pPage, SwFrameFormat *const pFormat, const SwFormatAnchor & rAnch)
1007 {
1008  const bool bFlyAtFly = rAnch.GetAnchorId() == RndStdIds::FLY_AT_FLY; // LAYER_IMPL
1009  //Is a frame or a SdrObject described?
1010  const bool bSdrObj = RES_DRAWFRMFMT == pFormat->Which();
1011  // OD 23.06.2003 #108784# - append also drawing objects anchored
1012  // as character.
1013  const bool bDrawObjInContent = bSdrObj &&
1014  (rAnch.GetAnchorId() == RndStdIds::FLY_AS_CHAR);
1015 
1016  if( !(bFlyAtFly ||
1017  (rAnch.GetAnchorId() == RndStdIds::FLY_AT_PARA) ||
1018  (rAnch.GetAnchorId() == RndStdIds::FLY_AT_CHAR) ||
1019  bDrawObjInContent) )
1020  return;
1021 
1022  SdrObject* pSdrObj = nullptr;
1023  if ( bSdrObj && nullptr == (pSdrObj = pFormat->FindSdrObject()) )
1024  {
1025  OSL_ENSURE( !bSdrObj, "DrawObject not found." );
1026  pFormat->GetDoc()->DelFrameFormat( pFormat );
1027  return;
1028  }
1029  if ( pSdrObj )
1030  {
1031  if ( !pSdrObj->getSdrPageFromSdrObject() )
1032  {
1034  InsertObject(pSdrObj, pSdrObj->GetOrdNumDirect());
1035  }
1036 
1037  SwDrawContact* pNew =
1038  static_cast<SwDrawContact*>(GetUserCall( pSdrObj ));
1039  if ( !pNew->GetAnchorFrame() )
1040  {
1041  pFrame->AppendDrawObj( *(pNew->GetAnchoredObj( nullptr )) );
1042  }
1043  // OD 19.06.2003 #108784# - add 'virtual' drawing object,
1044  // if necessary. But control objects have to be excluded.
1045  else if ( !::CheckControlLayer( pSdrObj ) &&
1046  pNew->GetAnchorFrame() != pFrame &&
1047  !pNew->GetDrawObjectByAnchorFrame( *pFrame ) )
1048  {
1049  SwDrawVirtObj* pDrawVirtObj = pNew->AddVirtObj(*pFrame);
1050  pFrame->AppendDrawObj( *(pNew->GetAnchoredObj( pDrawVirtObj )) );
1051 
1052  pDrawVirtObj->ActionChanged();
1053  }
1054  }
1055  else
1056  {
1057  SwFlyFrame *pFly;
1058  if( bFlyAtFly )
1059  pFly = new SwFlyLayFrame( static_cast<SwFlyFrameFormat*>(pFormat), pFrame, pFrame );
1060  else
1061  pFly = new SwFlyAtContentFrame( static_cast<SwFlyFrameFormat*>(pFormat), pFrame, pFrame );
1062  pFly->Lock();
1063  pFrame->AppendFly( pFly );
1064  pFly->Unlock();
1065  if ( pPage )
1066  ::RegistFlys( pPage, pFly );
1067  }
1068 }
1069 
1070 static bool IsShown(sal_uLong const nIndex,
1071  const SwFormatAnchor & rAnch,
1072  std::vector<sw::Extent>::const_iterator const*const pIter,
1073  std::vector<sw::Extent>::const_iterator const*const pEnd,
1074  SwTextNode const*const pFirstNode, SwTextNode const*const pLastNode)
1075 {
1076  assert(!pIter || *pIter == *pEnd || (*pIter)->pNode->GetIndex() == nIndex);
1077  SwPosition const& rAnchor(*rAnch.GetContentAnchor());
1078  if (rAnchor.nNode.GetIndex() != nIndex)
1079  {
1080  return false;
1081  }
1082  if (rAnch.GetAnchorId() == RndStdIds::FLY_AT_PARA)
1083  {
1084  return pIter == nullptr // not merged
1085  || pIter != pEnd // at least one char visible in node
1086  || !IsSelectFrameAnchoredAtPara(rAnchor,
1087  SwPosition(const_cast<SwTextNode&>(*pFirstNode), 0),
1088  SwPosition(const_cast<SwTextNode&>(*pLastNode), pLastNode->Len()));
1089  }
1090  if (pIter)
1091  {
1092  // note: frames are not sorted by anchor position.
1093  assert(pEnd);
1094  assert(pFirstNode);
1095  assert(pLastNode);
1096  assert(rAnch.GetAnchorId() != RndStdIds::FLY_AT_FLY);
1097  for (auto iter = *pIter; iter != *pEnd; ++iter)
1098  {
1099  assert(iter->nStart != iter->nEnd); // TODO possible?
1100  assert(iter->pNode->GetIndex() == nIndex);
1101  if (rAnchor.nContent.GetIndex() < iter->nStart)
1102  {
1103  return false;
1104  }
1105  if (rAnch.GetAnchorId() == RndStdIds::FLY_AT_CHAR)
1106  {
1107  // if there is an extent then obviously the node was not
1108  // deleted fully...
1109  // show if start <= pos <= end
1110  // *or* if first-node/0 *and* not StartOfSection
1111  // *or* if last-node/Len *and* not EndOfSection
1112 
1113  // first determine the extent to compare to, then
1114  // construct start/end positions for the deletion *before* the
1115  // extent and compare once.
1116  // the interesting corner cases are on the edge of the extent!
1117  // no need to check for > the last extent because those
1118  // are never visible.
1119  if (rAnchor.nContent.GetIndex() <= iter->nEnd)
1120  {
1121  if (iter->nStart == 0)
1122  {
1123  return true;
1124  }
1125  else
1126  {
1127  SwPosition const start(
1128  const_cast<SwTextNode&>(
1129  iter == *pIter
1130  ? *pFirstNode // simplification
1131  : *iter->pNode),
1132  iter == *pIter // first extent?
1133  ? iter->pNode == pFirstNode
1134  ? 0 // at start of 1st node
1135  : pFirstNode->Len() // previous node; simplification but should get right result
1136  : (iter-1)->nEnd); // previous extent
1137  SwPosition const end(*iter->pNode, iter->nStart);
1138  return !IsDestroyFrameAnchoredAtChar(rAnchor, start, end);
1139  }
1140  }
1141  else if (iter == *pEnd - 1) // special case: after last extent
1142  {
1143  if (iter->nEnd == iter->pNode->Len())
1144  {
1145  return true; // special case: end of node
1146  }
1147  else
1148  {
1149  SwPosition const start(*iter->pNode, iter->nEnd);
1150  SwPosition const end(
1151  const_cast<SwTextNode&>(*pLastNode), // simplification
1152  iter->pNode == pLastNode
1153  ? iter->pNode->Len()
1154  : 0);
1155  return !IsDestroyFrameAnchoredAtChar(rAnchor, start, end);
1156  }
1157  }
1158  }
1159  else
1160  {
1161  assert(rAnch.GetAnchorId() == RndStdIds::FLY_AS_CHAR);
1162  // for AS_CHAR obviously must be <
1163  if (rAnchor.nContent.GetIndex() < iter->nEnd)
1164  {
1165  return true;
1166  }
1167  }
1168  }
1169  return false;
1170  }
1171  else
1172  {
1173  return true;
1174  }
1175 }
1176 
1178  std::vector<sw::Extent>::const_iterator const*const pIter,
1179  std::vector<sw::Extent>::const_iterator const*const pEnd,
1180  SwTextNode const*const pFirstNode, SwTextNode const*const pLastNode)
1181 {
1182  std::vector<SwFrameFormat*> const & rFlys(rNode.GetAnchoredFlys());
1183  for (SwFrameFormat * pFrameFormat : rFlys)
1184  {
1185  SwFormatAnchor const& rAnchor = pFrameFormat->GetAnchor();
1186  if (rAnchor.GetAnchorId() == RndStdIds::FLY_AT_CHAR
1187  || (rAnchor.GetAnchorId() == RndStdIds::FLY_AS_CHAR
1188  && RES_DRAWFRMFMT == pFrameFormat->Which()))
1189  {
1190  assert(rAnchor.GetContentAnchor()->nNode.GetIndex() == rNode.GetIndex());
1191  if (!IsShown(rNode.GetIndex(), rAnchor, pIter, pEnd, pFirstNode, pLastNode))
1192  {
1193  pFrameFormat->DelFrames();
1194  }
1195  }
1196  }
1197 }
1198 
1199 void AppendObjsOfNode(SwFrameFormats const*const pTable, sal_uLong const nIndex,
1200  SwFrame *const pFrame, SwPageFrame *const pPage, SwDoc *const pDoc,
1201  std::vector<sw::Extent>::const_iterator const*const pIter,
1202  std::vector<sw::Extent>::const_iterator const*const pEnd,
1203  SwTextNode const*const pFirstNode, SwTextNode const*const pLastNode)
1204 {
1205 #if OSL_DEBUG_LEVEL > 0
1206  std::vector<SwFrameFormat*> checkFormats;
1207  for ( size_t i = 0; i < pTable->size(); ++i )
1208  {
1209  SwFrameFormat *pFormat = (*pTable)[i];
1210  const SwFormatAnchor &rAnch = pFormat->GetAnchor();
1211  if ( rAnch.GetContentAnchor() &&
1212  IsShown(nIndex, rAnch, pIter, pEnd, pFirstNode, pLastNode))
1213  {
1214  checkFormats.push_back( pFormat );
1215  }
1216  }
1217 #else
1218  (void)pTable;
1219 #endif
1220 
1221  SwNode const& rNode(*pDoc->GetNodes()[nIndex]);
1222  std::vector<SwFrameFormat*> const & rFlys(rNode.GetAnchoredFlys());
1223  for (size_t it = 0; it != rFlys.size(); )
1224  {
1225  SwFrameFormat *const pFormat = rFlys[it];
1226  const SwFormatAnchor &rAnch = pFormat->GetAnchor();
1227  if ( rAnch.GetContentAnchor() &&
1228  IsShown(nIndex, rAnch, pIter, pEnd, pFirstNode, pLastNode))
1229  {
1230 #if OSL_DEBUG_LEVEL > 0
1231  std::vector<SwFrameFormat*>::iterator checkPos = std::find( checkFormats.begin(), checkFormats.end(), pFormat );
1232  assert( checkPos != checkFormats.end());
1233  checkFormats.erase( checkPos );
1234 #endif
1235  AppendObj(pFrame, pPage, pFormat, rAnch);
1236  }
1237  ++it;
1238  }
1239 
1240 #if OSL_DEBUG_LEVEL > 0
1241  assert( checkFormats.empty());
1242 #endif
1243 }
1244 
1245 
1246 void AppendObjs(const SwFrameFormats *const pTable, sal_uLong const nIndex,
1247  SwFrame *const pFrame, SwPageFrame *const pPage, SwDoc *const pDoc)
1248 {
1249  if (pFrame->IsTextFrame())
1250  {
1251  SwTextFrame const*const pTextFrame(static_cast<SwTextFrame const*>(pFrame));
1252  if (sw::MergedPara const*const pMerged = pTextFrame->GetMergedPara())
1253  {
1254  std::vector<sw::Extent>::const_iterator iterFirst(pMerged->extents.begin());
1255  std::vector<sw::Extent>::const_iterator iter(iterFirst);
1256  SwTextNode const* pNode(pMerged->pFirstNode);
1257  for ( ; ; ++iter)
1258  {
1259  if (iter == pMerged->extents.end()
1260  || iter->pNode != pNode)
1261  {
1262  AppendObjsOfNode(pTable, pNode->GetIndex(), pFrame, pPage, pDoc,
1263  &iterFirst, &iter, pMerged->pFirstNode, pMerged->pLastNode);
1264  sal_uLong const until = iter == pMerged->extents.end()
1265  ? pMerged->pLastNode->GetIndex() + 1
1266  : iter->pNode->GetIndex();
1267  for (sal_uLong i = pNode->GetIndex() + 1; i < until; ++i)
1268  {
1269  // let's show at-para flys on nodes that contain start/end of
1270  // redline too, even if there's no text there
1271  SwNode const*const pTmp(pNode->GetNodes()[i]);
1272  if (pTmp->GetRedlineMergeFlag() == SwNode::Merge::NonFirst)
1273  {
1274  AppendObjsOfNode(pTable, pTmp->GetIndex(), pFrame, pPage, pDoc, &iter, &iter, pMerged->pFirstNode, pMerged->pLastNode);
1275  }
1276  }
1277  if (iter == pMerged->extents.end())
1278  {
1279  break;
1280  }
1281  pNode = iter->pNode;
1282  iterFirst = iter;
1283  }
1284  }
1285  }
1286  else
1287  {
1288  return AppendObjsOfNode(pTable, nIndex, pFrame, pPage, pDoc, nullptr, nullptr, nullptr, nullptr);
1289  }
1290  }
1291  else
1292  {
1293  return AppendObjsOfNode(pTable, nIndex, pFrame, pPage, pDoc, nullptr, nullptr, nullptr, nullptr);
1294  }
1295 }
1296 
1297 bool IsAnchoredObjShown(SwTextFrame const& rFrame, SwFormatAnchor const& rAnchor)
1298 {
1299  assert(rAnchor.GetAnchorId() == RndStdIds::FLY_AT_PARA ||
1300  rAnchor.GetAnchorId() == RndStdIds::FLY_AT_CHAR ||
1301  rAnchor.GetAnchorId() == RndStdIds::FLY_AS_CHAR);
1302  bool ret(true);
1303  if (auto const pMergedPara = rFrame.GetMergedPara())
1304  {
1305  ret = false;
1306  auto const pAnchor(rAnchor.GetContentAnchor());
1307  auto iterFirst(pMergedPara->extents.cbegin());
1308  if (iterFirst == pMergedPara->extents.end()
1309  && (rAnchor.GetAnchorId() == RndStdIds::FLY_AT_PARA
1310  || rAnchor.GetAnchorId() == RndStdIds::FLY_AT_CHAR))
1311  {
1312  ret = (&pAnchor->nNode.GetNode() == pMergedPara->pFirstNode
1313  && (rAnchor.GetAnchorId() == RndStdIds::FLY_AT_PARA
1314  || pAnchor->nContent == 0))
1315  || (&pAnchor->nNode.GetNode() == pMergedPara->pLastNode
1316  && (rAnchor.GetAnchorId() == RndStdIds::FLY_AT_PARA
1317  || pAnchor->nContent == pMergedPara->pLastNode->Len()));
1318  }
1319  auto iter(iterFirst);
1320  SwTextNode const* pNode(pMergedPara->pFirstNode);
1321  for ( ; ; ++iter)
1322  {
1323  if (iter == pMergedPara->extents.end()
1324  || iter->pNode != pNode)
1325  {
1326  assert(pNode->GetRedlineMergeFlag() != SwNode::Merge::Hidden);
1327  if (pNode == &pAnchor->nNode.GetNode())
1328  {
1329  ret = IsShown(pNode->GetIndex(), rAnchor, &iterFirst, &iter,
1330  pMergedPara->pFirstNode, pMergedPara->pLastNode);
1331  break;
1332  }
1333  if (iter == pMergedPara->extents.end())
1334  {
1335  break;
1336  }
1337  pNode = iter->pNode;
1338  if (pAnchor->nNode.GetIndex() < pNode->GetIndex())
1339  {
1340  break;
1341  }
1342  iterFirst = iter;
1343  }
1344  }
1345  }
1346  return ret;
1347 }
1348 
1349 void AppendAllObjs(const SwFrameFormats* pTable, const SwFrame* pSib)
1350 {
1351  //Connecting of all Objects, which are described in the SpzTable with the
1352  //layout.
1353 
1354  boost::circular_buffer<SwFrameFormat*> vFormatsToConnect(pTable->size());
1355  for(const auto& pFormat : *pTable)
1356  {
1357  const auto& rAnch = pFormat->GetAnchor();
1358  // Formats can still remain, because we neither use character bound
1359  // frames nor objects which are anchored to character bounds.
1360  if ((rAnch.GetAnchorId() != RndStdIds::FLY_AT_PAGE) && (rAnch.GetAnchorId() != RndStdIds::FLY_AS_CHAR))
1361  {
1362  auto pContentAnchor = rAnch.GetContentAnchor();
1363  // formats in header/footer have no dependencies
1364  if(pContentAnchor && pFormat->GetDoc()->IsInHeaderFooter(pContentAnchor->nNode))
1365  pFormat->MakeFrames();
1366  else
1367  vFormatsToConnect.push_back(pFormat);
1368  }
1369  }
1370  const SwRootFrame* pRoot = pSib ? pSib->getRootFrame() : nullptr;
1371  const SwFrameFormat* pFirstRequeued(nullptr);
1372  while(!vFormatsToConnect.empty())
1373  {
1374  auto& pFormat = vFormatsToConnect.front();
1375  bool isConnected(false);
1376  pFormat->CallSwClientNotify(sw::GetObjectConnectedHint(isConnected, pRoot));
1377  if(!isConnected)
1378  {
1379  pFormat->MakeFrames();
1380  pFormat->CallSwClientNotify(sw::GetObjectConnectedHint(isConnected, pRoot));
1381  }
1382  // do this *before* push_back! the circular_buffer can be "full"!
1383  vFormatsToConnect.pop_front();
1384  if (!isConnected)
1385  {
1386  if(pFirstRequeued == pFormat)
1387  // If nothing happens anymore we can stop.
1388  break;
1389  if(!pFirstRequeued)
1390  pFirstRequeued = pFormat;
1391  assert(!vFormatsToConnect.full());
1392  vFormatsToConnect.push_back(pFormat);
1393  }
1394  else
1395  {
1396  pFirstRequeued = nullptr;
1397  }
1398  }
1399 }
1400 
1401 namespace sw {
1402 
1404 {
1405  std::vector<SwTextFrame*> frames;
1407  for (SwTextFrame* pFrame = aIter.First(); pFrame; pFrame = aIter.Next())
1408  {
1409  if (pFrame->getRootFrame()->HasMergedParas())
1410  {
1411  frames.push_back(pFrame);
1412  }
1413  }
1415  for (SwTextFrame * pFrame : frames)
1416  {
1417  // SplitNode could have moved the original frame to the start node
1418  // & created a new one on end, or could have created new frame on
1419  // start node... grab start node's frame and recreate MergedPara.
1420  SwTextNode & rFirstNode(pFrame->GetMergedPara()
1421  ? *pFrame->GetMergedPara()->pFirstNode
1422  : rNode);
1423  assert(rFirstNode.GetIndex() <= rNode.GetIndex());
1424  // clear old one first to avoid DelFrames confusing updates & asserts...
1425  pFrame->SetMergedPara(nullptr);
1426  pFrame->SetMergedPara(sw::CheckParaRedlineMerge(
1427  *pFrame, rFirstNode, eMode));
1428  eMode = sw::FrameMode::New; // Existing is not idempotent!
1429  // note: this may or may not delete frames on the end node
1430  }
1431 }
1432 
1433 } // namespace sw
1434 
1439 static void lcl_SetPos( SwFrame& _rNewFrame,
1440  const SwLayoutFrame& _rLayFrame )
1441 {
1442  SwRectFnSet aRectFnSet(&_rLayFrame);
1444  aRectFnSet.SetPos( aFrm, aRectFnSet.GetPos(_rLayFrame.getFrameArea()) );
1445 
1446  // move position by one SwTwip in text flow direction in order to get
1447  // notifications for a new calculated position after its formatting.
1448  if ( aRectFnSet.IsVert() )
1449  {
1450  aFrm.Pos().AdjustX( -1 );
1451  }
1452  else
1453  {
1454  aFrm.Pos().AdjustY(1 );
1455  }
1456 }
1457 
1458 void InsertCnt_( SwLayoutFrame *pLay, SwDoc *pDoc,
1459  sal_uLong nIndex, bool bPages, sal_uLong nEndIndex,
1460  SwFrame *pPrv, sw::FrameMode const eMode )
1461 {
1463  SwRootFrame* pLayout = pLay->getRootFrame();
1464  const bool bOldCallbackActionEnabled = pLayout && pLayout->IsCallbackActionEnabled();
1465  if( bOldCallbackActionEnabled )
1466  pLayout->SetCallbackActionEnabled( false );
1467 
1468  //In the generation of the Layout bPages=true will be handed over.
1469  //Then will be new pages generated all x paragraphs already times in advance.
1470  //On breaks and/or pagedescriptorchanges the corresponding will be generated
1471  //immediately.
1472  //The advantage is, that on one hand already a nearly realistic number of
1473  //pages are created, but above all there are no almost endless long chain
1474  //of paragraphs, which must be moved expensively until it reaches a tolerable
1475  //reduced level.
1476  //We'd like to think that 20 Paragraphs fit on one page.
1477  //So that it does not become in extreme situations so violent we calculate depending
1478  //on the node something to it.
1479  //If in the DocStatistic a usable given pagenumber
1480  //(Will be cared for while writing), so it will be presumed that this will be
1481  //number of pages.
1482  const bool bStartPercent = bPages && !nEndIndex;
1483 
1484  SwPageFrame *pPage = pLay->FindPageFrame();
1485  const SwFrameFormats *pTable = pDoc->GetSpzFrameFormats();
1486  SwFrame *pFrame = nullptr;
1487  std::unique_ptr<SwActualSection> pActualSection;
1488  std::unique_ptr<SwLayHelper> pPageMaker;
1489 
1490  //If the layout will be created (bPages == true) we do head on the progress
1491  //Flys and DrawObjects are not connected immediately, this
1492  //happens only at the end of the function.
1493  if ( bPages )
1494  {
1495  // Attention: the SwLayHelper class uses references to the content-,
1496  // page-, layout-frame etc. and may change them!
1497  pPageMaker.reset(new SwLayHelper( pDoc, pFrame, pPrv, pPage, pLay,
1498  pActualSection, nIndex, 0 == nEndIndex ));
1499  if( bStartPercent )
1500  {
1501  const sal_uLong nPageCount = pPageMaker->CalcPageCount();
1502  if( nPageCount )
1503  bObjsDirect = false;
1504  }
1505  }
1506  else
1507  pPageMaker = nullptr;
1508 
1509  if( pLay->IsInSct() &&
1510  ( pLay->IsSctFrame() || pLay->GetUpper() ) ) // Hereby will newbies
1511  // be intercepted, of which flags could not determined yet,
1512  // for e.g. while inserting a table
1513  {
1514  SwSectionFrame* pSct = pLay->FindSctFrame();
1515  // If content will be inserted in a footnote, which in a column area,
1516  // the column area it is not allowed to be broken up.
1517  // Only if in the inner of the footnote lies an area, is this a candidate
1518  // for pActualSection.
1519  // The same applies for areas in tables, if inside the table will be
1520  // something inserted, it's only allowed to break up areas, which
1521  // lies in the inside also.
1522  if( ( !pLay->IsInFootnote() || pSct->IsInFootnote() ) &&
1523  ( !pLay->IsInTab() || pSct->IsInTab() ) )
1524  {
1525  pActualSection.reset(new SwActualSection(nullptr, pSct, pSct->GetSection()->GetFormat()->GetSectionNode()));
1526  // tdf#132236 for SwUndoDelete: find outer sections whose start
1527  // nodes aren't contained in the range but whose end nodes are,
1528  // because section frames may need to be created for them
1529  SwActualSection * pUpperSection(pActualSection.get());
1530  while (pUpperSection->GetSectionNode()->EndOfSectionIndex() < nEndIndex)
1531  {
1532  SwStartNode *const pStart(pUpperSection->GetSectionNode()->StartOfSectionNode());
1533  if (!pStart->IsSectionNode())
1534  {
1535  break;
1536  }
1537  // note: these don't have a section frame, check it in EndNode case!
1538  auto const pTmp(new SwActualSection(nullptr, nullptr, static_cast<SwSectionNode*>(pStart)));
1539  pUpperSection->SetUpper(pTmp);
1540  pUpperSection = pTmp;
1541  }
1542  OSL_ENSURE( !pLay->Lower() || !pLay->Lower()->IsColumnFrame(),
1543  "InsertCnt_: Wrong Call" );
1544  }
1545  }
1546 
1547  //If a section is "open", the pActualSection points to an SwActualSection.
1548  //If the page breaks, for "open" sections a follow will created.
1549  //For nested sections (which have, however, not a nested layout),
1550  //the SwActualSection class has a member, which points to an upper(section).
1551  //When the "inner" section finishes, the upper will used instead.
1552 
1553  // Do not consider the end node. The caller (Section/MakeFrames()) has to
1554  // ensure that the end of this range is positioned before EndIndex!
1555  for ( ; nEndIndex == 0 || nIndex < nEndIndex; ++nIndex)
1556  {
1557  SwNode *pNd = pDoc->GetNodes()[nIndex];
1558  if ( pNd->IsContentNode() )
1559  {
1560  SwContentNode* pNode = static_cast<SwContentNode*>(pNd);
1561  if (pLayout->HasMergedParas() && !pNd->IsCreateFrameWhenHidingRedlines())
1562  {
1563  if (pNd->IsTextNode()
1565  { // must have a frame already
1566  assert(static_cast<SwTextFrame*>(pNode->getLayoutFrame(pLayout))->GetMergedPara());
1567  }
1568  continue; // skip it
1569  }
1570  pFrame = pNode->IsTextNode()
1571  ? sw::MakeTextFrame(*pNode->GetTextNode(), pLay, eMode)
1572  : pNode->MakeFrame(pLay);
1573  if( pPageMaker )
1574  pPageMaker->CheckInsert( nIndex );
1575 
1576  pFrame->InsertBehind( pLay, pPrv );
1577  // #i27138#
1578  // notify accessibility paragraphs objects about changed
1579  // CONTENT_FLOWS_FROM/_TO relation.
1580  // Relation CONTENT_FLOWS_FROM for next paragraph will change
1581  // and relation CONTENT_FLOWS_TO for previous paragraph will change.
1582  if ( pFrame->IsTextFrame() )
1583  {
1584  SwViewShell* pViewShell( pFrame->getRootFrame()->GetCurrShell() );
1585  // no notification, if <SwViewShell> is in construction
1586  if ( pViewShell && !pViewShell->IsInConstructor() &&
1587  pViewShell->GetLayout() &&
1588  pViewShell->GetLayout()->IsAnyShellAccessible() &&
1589  pFrame->FindPageFrame() != nullptr)
1590  {
1592  dynamic_cast<SwTextFrame*>(pFrame->FindNextCnt( true )),
1593  dynamic_cast<SwTextFrame*>(pFrame->FindPrevCnt()) );
1594  // #i68958#
1595  // The information flags of the text frame are validated
1596  // in methods <FindNextCnt(..)> and <FindPrevCnt(..)>.
1597  // The information flags have to be invalidated, because
1598  // it is possible, that the one of its upper frames
1599  // isn't inserted into the layout.
1600  pFrame->InvalidateInfFlags();
1601  }
1602  }
1603  // OD 12.08.2003 #i17969# - consider horizontal/vertical layout
1604  // for setting position at newly inserted frame
1605  lcl_SetPos( *pFrame, *pLay );
1606  pPrv = pFrame;
1607 
1608  if ( !pTable->empty() && bObjsDirect && !isFlyCreationSuppressed )
1609  AppendObjs( pTable, nIndex, pFrame, pPage, pDoc );
1610  }
1611  else if ( pNd->IsTableNode() )
1612  { //Should we have encountered a table?
1613  SwTableNode *pTableNode = static_cast<SwTableNode*>(pNd);
1614  if (pLayout->IsHideRedlines())
1615  {
1616  // in the problematic case, there can be only 1 redline...
1617  SwPosition const tmp(*pNd);
1618  SwRangeRedline const*const pRedline(
1619  pDoc->getIDocumentRedlineAccess().GetRedline(tmp, nullptr));
1620  // pathology: redline that starts on a TableNode; cannot
1621  // be created in UI but by import filters...
1622  if (pRedline
1623  && pRedline->GetType() == RedlineType::Delete
1624  && &pRedline->Start()->nNode.GetNode() == pNd)
1625  {
1626  SAL_WARN("sw.pageframe", "skipping table frame creation on bizarre redline");
1627  while (true)
1628  {
1629  pTableNode->GetNodes()[nIndex]->SetRedlineMergeFlag(SwNode::Merge::Hidden);
1630  if (nIndex == pTableNode->EndOfSectionIndex())
1631  {
1632  break;
1633  }
1634  ++nIndex;
1635  }
1636  continue;
1637  }
1638  }
1639  if (pLayout->HasMergedParas() && !pNd->IsCreateFrameWhenHidingRedlines())
1640  {
1641  assert(pNd->GetRedlineMergeFlag() == SwNode::Merge::Hidden);
1642  nIndex = pTableNode->EndOfSectionIndex();
1643  continue; // skip it
1644  }
1645 
1646  // #108116# loading may produce table structures that GCLines
1647  // needs to clean up. To keep table formulas correct, change
1648  // all table formulas to internal (BOXPTR) representation.
1649  SwTableFormulaUpdate aMsgHint( &pTableNode->GetTable() );
1650  aMsgHint.m_eFlags = TBL_BOXPTR;
1651  pDoc->getIDocumentFieldsAccess().UpdateTableFields( &aMsgHint );
1652  pTableNode->GetTable().GCLines();
1653 
1654  pFrame = pTableNode->MakeFrame( pLay );
1655 
1656  if( pPageMaker )
1657  pPageMaker->CheckInsert( nIndex );
1658 
1659  pFrame->InsertBehind( pLay, pPrv );
1660  if (pPage) // would null in SwCellFrame ctor
1661  { // tdf#134931 call ResetTurbo(); not sure if Paste() would be
1662  pFrame->InvalidatePage(pPage); // better than InsertBehind()?
1663  }
1664  // #i27138#
1665  // notify accessibility paragraphs objects about changed
1666  // CONTENT_FLOWS_FROM/_TO relation.
1667  // Relation CONTENT_FLOWS_FROM for next paragraph will change
1668  // and relation CONTENT_FLOWS_TO for previous paragraph will change.
1669  {
1670  SwViewShell* pViewShell( pFrame->getRootFrame()->GetCurrShell() );
1671  // no notification, if <SwViewShell> is in construction
1672  if ( pViewShell && !pViewShell->IsInConstructor() &&
1673  pViewShell->GetLayout() &&
1674  pViewShell->GetLayout()->IsAnyShellAccessible() &&
1675  pFrame->FindPageFrame() != nullptr)
1676  {
1678  dynamic_cast<SwTextFrame*>(pFrame->FindNextCnt( true )),
1679  dynamic_cast<SwTextFrame*>(pFrame->FindPrevCnt()) );
1680  }
1681  }
1682  if ( bObjsDirect && !pTable->empty() )
1683  static_cast<SwTabFrame*>(pFrame)->RegistFlys();
1684  // OD 12.08.2003 #i17969# - consider horizontal/vertical layout
1685  // for setting position at newly inserted frame
1686  lcl_SetPos( *pFrame, *pLay );
1687 
1688  pPrv = pFrame;
1689  //Set the index to the endnode of the table section.
1690  nIndex = pTableNode->EndOfSectionIndex();
1691 
1692  SwTabFrame* pTmpFrame = static_cast<SwTabFrame*>(pFrame);
1693  while ( pTmpFrame )
1694  {
1695  pTmpFrame->CheckDirChange();
1696  pTmpFrame = pTmpFrame->IsFollow() ? pTmpFrame->FindMaster() : nullptr;
1697  }
1698 
1699  }
1700  else if ( pNd->IsSectionNode() )
1701  {
1702  if (pLayout->HasMergedParas() && !pNd->IsCreateFrameWhenHidingRedlines())
1703  {
1704  assert(pNd->GetRedlineMergeFlag() == SwNode::Merge::Hidden);
1705  continue; // skip it
1706  }
1707  SwSectionNode *pNode = static_cast<SwSectionNode*>(pNd);
1708  if( pNode->GetSection().CalcHiddenFlag() )
1709  // is hidden, skip the area
1710  nIndex = pNode->EndOfSectionIndex();
1711  else
1712  {
1713  pFrame = pNode->MakeFrame( pLay );
1714  pActualSection.reset( new SwActualSection( pActualSection.release(),
1715  static_cast<SwSectionFrame*>(pFrame), pNode ) );
1716  if ( pActualSection->GetUpper() )
1717  {
1718  //Insert behind the Upper, the "Follow" of the Upper will be
1719  //generated at the EndNode.
1720  SwSectionFrame *pTmp = pActualSection->GetUpper()->GetSectionFrame();
1721  pFrame->InsertBehind( pTmp->GetUpper(), pTmp );
1722  // OD 25.03.2003 #108339# - direct initialization of section
1723  // after insertion in the layout
1724  static_cast<SwSectionFrame*>(pFrame)->Init();
1725  }
1726  else
1727  {
1728  pFrame->InsertBehind( pLay, pPrv );
1729  // OD 25.03.2003 #108339# - direct initialization of section
1730  // after insertion in the layout
1731  static_cast<SwSectionFrame*>(pFrame)->Init();
1732 
1733  // #i33963#
1734  // Do not trust the IsInFootnote flag. If we are currently
1735  // building up a table, the upper of pPrv may be a cell
1736  // frame, but the cell frame does not have an upper yet.
1737  if( pPrv && nullptr != pPrv->ImplFindFootnoteFrame() )
1738  {
1739  if( pPrv->IsSctFrame() )
1740  pPrv = static_cast<SwSectionFrame*>(pPrv)->ContainsContent();
1741  if( pPrv && pPrv->IsTextFrame() )
1742  static_cast<SwTextFrame*>(pPrv)->Prepare( PrepareHint::QuoVadis, nullptr, false );
1743  }
1744  }
1745  if (nIndex + 1 == nEndIndex)
1746  { // tdf#131684 tdf#132236 fix upper of frame moved in
1747  // SwUndoDelete; can't be done there unfortunately
1748  // because empty section frames are deleted here
1749  SwFrame *const pNext(
1750  // if there's a parent section, it has been split
1751  // into 2 SwSectionFrame already :(
1752  ( pFrame->GetNext()
1753  && pFrame->GetNext()->IsSctFrame()
1754  && pActualSection->GetUpper()
1755  && pActualSection->GetUpper()->GetSectionNode() ==
1756  static_cast<SwSectionFrame const*>(pFrame->GetNext())->GetSection()->GetFormat()->GetSectionNode())
1757  ? static_cast<SwSectionFrame *>(pFrame->GetNext())->ContainsContent()
1758  : pFrame->GetNext());
1759  if (pNext
1760  && pNext->IsTextFrame()
1761  && static_cast<SwTextFrame*>(pNext)->GetTextNodeFirst() == pDoc->GetNodes()[nEndIndex]
1762  && (pNext->GetUpper() == pFrame->GetUpper()
1763  || pFrame->GetNext()->IsSctFrame())) // checked above
1764  {
1765  pNext->Cut();
1766  pNext->InvalidateInfFlags(); // mbInfSct changed
1767  // could have columns
1768  SwSectionFrame *const pSection(static_cast<SwSectionFrame*>(pFrame));
1769  assert(!pSection->Lower() || pSection->Lower()->IsLayoutFrame());
1770  SwLayoutFrame *const pParent(pSection->Lower() ? pSection->GetNextLayoutLeaf() : pSection);
1771  assert(!pParent->Lower());
1772  // paste invalidates, section could have indent...
1773  pNext->Paste(pParent, nullptr);
1774  }
1775  }
1776  // #i27138#
1777  // notify accessibility paragraphs objects about changed
1778  // CONTENT_FLOWS_FROM/_TO relation.
1779  // Relation CONTENT_FLOWS_FROM for next paragraph will change
1780  // and relation CONTENT_FLOWS_TO for previous paragraph will change.
1781  {
1782  SwViewShell* pViewShell( pFrame->getRootFrame()->GetCurrShell() );
1783  // no notification, if <SwViewShell> is in construction
1784  if ( pViewShell && !pViewShell->IsInConstructor() &&
1785  pViewShell->GetLayout() &&
1786  pViewShell->GetLayout()->IsAnyShellAccessible() &&
1787  pFrame->FindPageFrame() != nullptr)
1788  {
1790  dynamic_cast<SwTextFrame*>(pFrame->FindNextCnt( true )),
1791  dynamic_cast<SwTextFrame*>(pFrame->FindPrevCnt()) );
1792  }
1793  }
1794  pFrame->CheckDirChange();
1795 
1796  // OD 12.08.2003 #i17969# - consider horizontal/vertical layout
1797  // for setting position at newly inserted frame
1798  lcl_SetPos( *pFrame, *pLay );
1799 
1800  // OD 20.11.2002 #105405# - no page, no invalidate.
1801  if ( pPage )
1802  {
1803  // OD 18.09.2002 #100522#
1804  // invalidate page in order to force format and paint of
1805  // inserted section frame
1806  pFrame->InvalidatePage( pPage );
1807 
1808  // FME 10.11.2003 #112243#
1809  // Invalidate fly content flag:
1810  if ( pFrame->IsInFly() )
1811  pPage->InvalidateFlyContent();
1812 
1813  // OD 14.11.2002 #104684# - invalidate page content in order to
1814  // force format and paint of section content.
1815  pPage->InvalidateContent();
1816  }
1817 
1818  pLay = static_cast<SwLayoutFrame*>(pFrame);
1819  if ( pLay->Lower() && pLay->Lower()->IsLayoutFrame() )
1820  pLay = pLay->GetNextLayoutLeaf();
1821  pPrv = nullptr;
1822  }
1823  }
1824  else if ( pNd->IsEndNode() && pNd->StartOfSectionNode()->IsSectionNode() )
1825  {
1826  if (pLayout->HasMergedParas() && !pNd->IsCreateFrameWhenHidingRedlines())
1827  {
1828  assert(pNd->GetRedlineMergeFlag() == SwNode::Merge::Hidden);
1829  continue; // skip it
1830  }
1832  { // tdf#135014 section break in fieldmark (start inside, end outside)
1834  continue; // skip it
1835  }
1836  assert(pActualSection && "Section end without section start?");
1837  assert(pActualSection->GetSectionNode() == pNd->StartOfSectionNode());
1838 
1839  //Close the section, where appropriate activate the surrounding
1840  //section again.
1841  pActualSection.reset(pActualSection->GetUpper());
1842  pLay = pLay->FindSctFrame();
1843  if ( pActualSection )
1844  {
1845  //Could be, that the last SectionFrame remains empty.
1846  //Then now is the time to remove them.
1847  if ( !pLay->ContainsContent() )
1848  {
1849  SwFrame *pTmpFrame = pLay;
1850  pLay = pTmpFrame->GetUpper();
1851  pPrv = pTmpFrame->GetPrev();
1852  pTmpFrame->RemoveFromLayout();
1853  SwFrame::DestroyFrame(pTmpFrame);
1854  }
1855  else
1856  {
1857  pPrv = pLay;
1858  pLay = pLay->GetUpper();
1859  }
1860 
1861  // new section frame
1862  pFrame = pActualSection->GetSectionNode()->MakeFrame( pLay );
1863  pFrame->InsertBehind( pLay, pPrv );
1864  static_cast<SwSectionFrame*>(pFrame)->Init();
1865 
1866  // OD 12.08.2003 #i17969# - consider horizontal/vertical layout
1867  // for setting position at newly inserted frame
1868  lcl_SetPos( *pFrame, *pLay );
1869 
1870  SwSectionFrame* pOuterSectionFrame = pActualSection->GetSectionFrame();
1871 
1872  // a follow has to be appended to the new section frame
1873  SwSectionFrame* pFollow = pOuterSectionFrame ? pOuterSectionFrame->GetFollow() : nullptr;
1874  if ( pFollow )
1875  {
1876  pOuterSectionFrame->SetFollow( nullptr );
1877  pOuterSectionFrame->InvalidateSize();
1878  static_cast<SwSectionFrame*>(pFrame)->SetFollow( pFollow );
1879  }
1880 
1881  // We don't want to leave empty parts back.
1882  if (pOuterSectionFrame &&
1883  ! pOuterSectionFrame->IsColLocked() &&
1884  ! pOuterSectionFrame->ContainsContent() )
1885  {
1886  pOuterSectionFrame->DelEmpty( true );
1887  SwFrame::DestroyFrame(pOuterSectionFrame);
1888  }
1889  pActualSection->SetSectionFrame( static_cast<SwSectionFrame*>(pFrame) );
1890 
1891  pLay = static_cast<SwLayoutFrame*>(pFrame);
1892  if ( pLay->Lower() && pLay->Lower()->IsLayoutFrame() )
1893  pLay = pLay->GetNextLayoutLeaf();
1894  pPrv = nullptr;
1895  }
1896  else
1897  {
1898  //Nothing more with sections, it goes on right behind
1899  //the SectionFrame.
1900  pPrv = pLay;
1901  pLay = pLay->GetUpper();
1902  }
1903  }
1904  else if( pNd->IsStartNode() &&
1905  SwFlyStartNode == static_cast<SwStartNode*>(pNd)->GetStartNodeType() )
1906  {
1907  if (pLayout->HasMergedParas() && !pNd->IsCreateFrameWhenHidingRedlines())
1908  {
1909  assert(pNd->GetRedlineMergeFlag() == SwNode::Merge::Hidden);
1910  assert(false); // actually a fly-section can't be deleted?
1911  continue; // skip it
1912  }
1913  if ( !pTable->empty() && bObjsDirect && !isFlyCreationSuppressed )
1914  {
1915  SwFlyFrame* pFly = pLay->FindFlyFrame();
1916  if( pFly )
1917  AppendObjs( pTable, nIndex, pFly, pPage, pDoc );
1918  }
1919  }
1920  else
1921  {
1922  assert(!pLayout->HasMergedParas()
1924  // Neither Content nor table nor section, so we are done.
1925  break;
1926  }
1927  }
1928 
1929  if ( pActualSection )
1930  {
1931  // Might happen that an empty (Follow-)Section is left over.
1932  if ( !(pLay = pActualSection->GetSectionFrame())->ContainsContent() )
1933  {
1934  pLay->RemoveFromLayout();
1935  SwFrame::DestroyFrame(pLay);
1936  }
1937  pActualSection.reset();
1938  }
1939 
1940  if ( bPages ) // let the Flys connect to each other
1941  {
1942  if ( !isFlyCreationSuppressed )
1943  AppendAllObjs( pTable, pLayout );
1944  bObjsDirect = true;
1945  }
1946 
1947  if( pPageMaker )
1948  {
1949  pPageMaker->CheckFlyCache( pPage );
1950  pPageMaker.reset();
1951  if( pDoc->GetLayoutCache() )
1952  {
1953 #ifdef DBG_UTIL
1954  pDoc->GetLayoutCache()->CompareLayout( *pDoc );
1955 #endif
1956  pDoc->GetLayoutCache()->ClearImpl();
1957  }
1958  }
1959 
1961  if( bOldCallbackActionEnabled )
1962  pLayout->SetCallbackActionEnabled( bOldCallbackActionEnabled );
1963 }
1964 
1965 void MakeFrames( SwDoc *pDoc, const SwNodeIndex &rSttIdx,
1966  const SwNodeIndex &rEndIdx )
1967 {
1968  bObjsDirect = false;
1969 
1970  SwNodeIndex aTmp( rSttIdx );
1971  sal_uLong nEndIdx = rEndIdx.GetIndex();
1972  SwNode* pNd = pDoc->GetNodes().FindPrvNxtFrameNode( aTmp,
1973  pDoc->GetNodes()[ nEndIdx-1 ]);
1974  if ( pNd )
1975  {
1976  bool bApres = aTmp < rSttIdx;
1977  SwNode2Layout aNode2Layout( *pNd, rSttIdx.GetIndex() );
1978  SwFrame* pFrame;
1980  while( nullptr != (pFrame = aNode2Layout.NextFrame()) )
1981  {
1982  SwLayoutFrame *pUpper = pFrame->GetUpper();
1983  SwFootnoteFrame* pFootnoteFrame = pUpper->FindFootnoteFrame();
1984  bool bOldLock, bOldFootnote;
1985  if( pFootnoteFrame )
1986  {
1987  bOldFootnote = pFootnoteFrame->IsColLocked();
1988  pFootnoteFrame->ColLock();
1989  }
1990  else
1991  bOldFootnote = true;
1992  SwSectionFrame* pSct = pUpper->FindSctFrame();
1993  // Inside of footnotes only those areas are interesting that are inside of them. But
1994  // not the ones (e.g. column areas) in which are the footnote containers positioned.
1995  // #109767# Table frame is in section, insert section in cell frame.
1996  if( pSct && ((pFootnoteFrame && !pSct->IsInFootnote()) || pUpper->IsCellFrame()) )
1997  pSct = nullptr;
1998  if( pSct )
1999  { // to prevent pTmp->MoveFwd from destroying the SectionFrame
2000  bOldLock = pSct->IsColLocked();
2001  pSct->ColLock();
2002  }
2003  else
2004  bOldLock = true;
2005 
2006  // If pFrame cannot be moved, it is not possible to move it to the next page. This applies
2007  // also for frames (in the first column of a frame pFrame is moveable) and column
2008  // sections of tables (also here pFrame is moveable).
2009  bool bMoveNext = nEndIdx - rSttIdx.GetIndex() > 120;
2010  bool bAllowMove = !pFrame->IsInFly() && pFrame->IsMoveable() &&
2011  (!pFrame->IsInTab() || pFrame->IsTabFrame() );
2012  if ( bMoveNext && bAllowMove )
2013  {
2014  SwFrame *pMove = pFrame;
2015  SwFrame *pPrev = pFrame->GetPrev();
2016  SwFlowFrame *pTmp = SwFlowFrame::CastFlowFrame( pMove );
2017  assert(pTmp);
2018 
2019  if ( bApres )
2020  {
2021  // The rest of this page should be empty. Thus, the following one has to move to
2022  // the next page (it might also be located in the following column).
2023  assert(!pTmp->HasFollow() && "prev. node's frame is not last");
2024  pPrev = pFrame;
2025  // If the surrounding SectionFrame has a "next" one,
2026  // so this one needs to be moved as well.
2027  pMove = pFrame->GetIndNext();
2028  SwColumnFrame* pCol = static_cast<SwColumnFrame*>(pFrame->FindColFrame());
2029  if( pCol )
2030  pCol = static_cast<SwColumnFrame*>(pCol->GetNext());
2031  do
2032  {
2033  if( pCol && !pMove )
2034  { // No successor so far, look into the next column
2035  pMove = pCol->ContainsAny();
2036  if( pCol->GetNext() )
2037  pCol = static_cast<SwColumnFrame*>(pCol->GetNext());
2038  else if( pCol->IsInSct() )
2039  { // If there is no following column but we are in a column frame,
2040  // there might be (page) columns outside of it.
2041  pCol = static_cast<SwColumnFrame*>(pCol->FindSctFrame()->FindColFrame());
2042  if( pCol )
2043  pCol = static_cast<SwColumnFrame*>(pCol->GetNext());
2044  }
2045  else
2046  pCol = nullptr;
2047  }
2048  // skip invalid SectionFrames
2049  while( pMove && pMove->IsSctFrame() &&
2050  !static_cast<SwSectionFrame*>(pMove)->GetSection() )
2051  pMove = pMove->GetNext();
2052  } while( !pMove && pCol );
2053 
2054  if( pMove )
2055  {
2056  if ( pMove->IsContentFrame() )
2057  pTmp = static_cast<SwContentFrame*>(pMove);
2058  else if ( pMove->IsTabFrame() )
2059  pTmp = static_cast<SwTabFrame*>(pMove);
2060  else if ( pMove->IsSctFrame() )
2061  {
2062  pMove = static_cast<SwSectionFrame*>(pMove)->ContainsAny();
2063  if( pMove )
2064  pTmp = SwFlowFrame::CastFlowFrame( pMove );
2065  else
2066  pTmp = nullptr;
2067  }
2068  }
2069  else
2070  pTmp = nullptr;
2071  }
2072  else
2073  {
2074  assert(!pTmp->IsFollow() && "next node's frame is not master");
2075  // move the _content_ of a section frame
2076  if( pMove->IsSctFrame() )
2077  {
2078  while( pMove && pMove->IsSctFrame() &&
2079  !static_cast<SwSectionFrame*>(pMove)->GetSection() )
2080  pMove = pMove->GetNext();
2081  if( pMove && pMove->IsSctFrame() )
2082  pMove = static_cast<SwSectionFrame*>(pMove)->ContainsAny();
2083  if( pMove )
2084  pTmp = SwFlowFrame::CastFlowFrame( pMove );
2085  else
2086  pTmp = nullptr;
2087  }
2088  }
2089 
2090  if( pTmp )
2091  {
2092  SwFrame* pOldUp = pTmp->GetFrame().GetUpper();
2093  // MoveFwd==true means that we are still on the same page.
2094  // But since we want to move if possible!
2095  bool bTmpOldLock = pTmp->IsJoinLocked();
2096  pTmp->LockJoin();
2097  while( pTmp->MoveFwd( true, false, true ) )
2098  {
2099  if( pOldUp == pTmp->GetFrame().GetUpper() )
2100  break;
2101  pOldUp = pTmp->GetFrame().GetUpper();
2102  }
2103  if( !bTmpOldLock )
2104  pTmp->UnlockJoin();
2105  }
2106  ::InsertCnt_( pUpper, pDoc, rSttIdx.GetIndex(),
2107  pFrame->IsInDocBody(), nEndIdx, pPrev, eMode );
2108  }
2109  else
2110  {
2111  bool bSplit;
2112  SwFrame* pPrv = bApres ? pFrame : pFrame->GetPrev();
2113  // If the section frame is inserted into another one, it must be split.
2114  if( pSct && rSttIdx.GetNode().IsSectionNode() )
2115  {
2116  bSplit = pSct->SplitSect( pFrame, bApres );
2117  if( !bSplit && !bApres )
2118  {
2119  pUpper = pSct->GetUpper();
2120  pPrv = pSct->GetPrev();
2121  }
2122  }
2123  else
2124  bSplit = false;
2125 
2126  ::InsertCnt_( pUpper, pDoc, rSttIdx.GetIndex(), false,
2127  nEndIdx, pPrv, eMode );
2128  // OD 23.06.2003 #108784# - correction: append objects doesn't
2129  // depend on value of <bAllowMove>
2130  if( !isFlyCreationSuppressed )
2131  {
2132  const SwFrameFormats *pTable = pDoc->GetSpzFrameFormats();
2133  if( !pTable->empty() )
2134  AppendAllObjs( pTable, pUpper );
2135  }
2136 
2137  // If nothing was added (e.g. a hidden section), the split must be reversed.
2138  if( bSplit && pSct && pSct->GetNext()
2139  && pSct->GetNext()->IsSctFrame() )
2140  pSct->MergeNext( static_cast<SwSectionFrame*>(pSct->GetNext()) );
2141  if( pFrame->IsInFly() )
2142  pFrame->FindFlyFrame()->Invalidate_();
2143  if( pFrame->IsInTab() )
2144  pFrame->InvalidateSize();
2145  }
2146 
2147  SwPageFrame *pPage = pUpper->FindPageFrame();
2148  SwFrame::CheckPageDescs( pPage, false );
2149  if( !bOldFootnote )
2150  pFootnoteFrame->ColUnlock();
2151  if( !bOldLock )
2152  {
2153  pSct->ColUnlock();
2154  // pSct might be empty (e.g. when inserting linked section containing further
2155  // sections) and can be destroyed in such cases.
2156  if( !pSct->ContainsContent() )
2157  {
2158  pSct->DelEmpty( true );
2159  pUpper->getRootFrame()->RemoveFromList( pSct );
2160  SwFrame::DestroyFrame(pSct);
2161  }
2162  }
2163  eMode = sw::FrameMode::New; // use Existing only once!
2164  }
2165  }
2166 
2167  bObjsDirect = true;
2168 }
2169 
2170 SwBorderAttrs::SwBorderAttrs(const sw::BorderCacheOwner* pOwner, const SwFrame* pConstructor)
2171  : SwCacheObj(pOwner)
2172  , m_rAttrSet(pConstructor->IsContentFrame()
2173  ? pConstructor->IsTextFrame()
2174  ? static_cast<const SwTextFrame*>(pConstructor)->GetTextNodeForParaProps()->GetSwAttrSet()
2175  : static_cast<const SwNoTextFrame*>(pConstructor)->GetNode()->GetSwAttrSet()
2176  : static_cast<const SwLayoutFrame*>(pConstructor)->GetFormat()->GetAttrSet())
2177  , m_rUL(m_rAttrSet.GetULSpace())
2178  // #i96772#
2179  // LRSpaceItem is copied due to the possibility that it is adjusted - see below
2180  , m_rLR(m_rAttrSet.GetLRSpace().Clone())
2181  , m_rBox(m_rAttrSet.GetBox())
2182  , m_rShadow(m_rAttrSet.GetShadow())
2183  , m_aFrameSize(m_rAttrSet.GetFrameSize().GetSize())
2184  , m_bIsLine(false)
2185  , m_bJoinedWithPrev(false)
2186  , m_bJoinedWithNext(false)
2187  , m_nTopLine(0)
2188  , m_nBottomLine(0)
2189  , m_nLeftLine(0)
2190  , m_nRightLine(0)
2191  , m_nTop(0)
2192  , m_nBottom(0)
2193  , m_nGetTopLine(0)
2194  , m_nGetBottomLine(0)
2195  , m_nLineSpacing(0)
2196 {
2197  // #i96772#
2198  const SwTextFrame* pTextFrame = dynamic_cast<const SwTextFrame*>(pConstructor);
2199  if ( pTextFrame )
2200  {
2202  }
2203  else if ( pConstructor->IsNoTextFrame() )
2204  {
2205  m_rLR = std::make_shared<SvxLRSpaceItem>(RES_LR_SPACE);
2206  }
2207 
2208  // Caution: The USHORTs for the cached values are not initialized by intention!
2209 
2210  // everything needs to be calculated at least once:
2212  m_bTop = m_bBottom = m_bLine = true;
2213 
2214  // except this one: calculate line spacing before cell border only for text frames
2215  m_bLineSpacing = bool(pTextFrame);
2216 
2218  // OD 21.05.2003 #108789# - init cache status for values <m_bJoinedWithPrev>
2219  // and <m_bJoinedWithNext>, which aren't initialized by default.
2220  m_bCachedJoinedWithPrev = false;
2221  m_bCachedJoinedWithNext = false;
2222 }
2223 
2225 {
2226  const_cast<sw::BorderCacheOwner*>(static_cast<sw::BorderCacheOwner const *>(m_pOwner))->m_bInCache = false;
2227 }
2228 
2229 /* All calc methods calculate a safety distance in addition to the values given by the attributes.
2230  * This safety distance is only added when working with borders and/or shadows to prevent that
2231  * e.g. borders are painted over.
2232  */
2233 
2235 {
2236  m_nTop = CalcTopLine() + m_rUL.GetUpper();
2237 
2238  if (m_rLR)
2239  {
2240  bool bGutterAtTop = m_rAttrSet.GetDoc()->getIDocumentSettingAccess().get(
2242  if (bGutterAtTop)
2243  {
2244  // Decrease the print area: the top space is the sum of top and gutter margins.
2245  m_nTop += m_rLR->GetGutterMargin();
2246  }
2247  }
2248 
2249  m_bTop = false;
2250 }
2251 
2253 {
2255  m_bBottom = false;
2256 }
2257 
2259 {
2260  tools::Long nRight=0;
2261 
2262  if (!pCaller->IsTextFrame() || !static_cast<const SwTextFrame*>(pCaller)->GetDoc().GetDocumentSettingManager().get(DocumentSettingId::INVERT_BORDER_SPACING)) {
2263  // OD 23.01.2003 #106895# - for cell frame in R2L text direction the left
2264  // and right border are painted on the right respectively left.
2265  if ( pCaller->IsCellFrame() && pCaller->IsRightToLeft() )
2266  nRight = CalcLeftLine();
2267  else
2268  nRight = CalcRightLine();
2269 
2270  }
2271  // for paragraphs, "left" is "before text" and "right" is "after text"
2272  if ( pCaller->IsTextFrame() && pCaller->IsRightToLeft() )
2273  nRight += m_rLR->GetLeft();
2274  else
2275  nRight += m_rLR->GetRight();
2276 
2277  // correction: retrieve left margin for numbering in R2L-layout
2278  if ( pCaller->IsTextFrame() && pCaller->IsRightToLeft() )
2279  {
2280  nRight += static_cast<const SwTextFrame*>(pCaller)->GetTextNodeForParaProps()->GetLeftMarginWithNum();
2281  }
2282 
2283  if (pCaller->IsPageFrame() && m_rLR)
2284  {
2285  const auto pPageFrame = static_cast<const SwPageFrame*>(pCaller);
2286  bool bGutterAtTop = pPageFrame->GetFormat()->getIDocumentSettingAccess().get(
2288  if (!bGutterAtTop)
2289  {
2290  bool bRtlGutter = pPageFrame->GetAttrSet()->GetItem<SfxBoolItem>(RES_RTL_GUTTER)->GetValue();
2291  tools::Long nGutterMargin = bRtlGutter ? m_rLR->GetGutterMargin() : m_rLR->GetRightGutterMargin();
2292  // Decrease the print area: the right space is the sum of right and right gutter
2293  // margins.
2294  nRight += nGutterMargin;
2295  }
2296  }
2297 
2298  return nRight;
2299 }
2300 
2302 static bool lcl_hasTabFrame(const SwTextFrame* pTextFrame)
2303 {
2304  if (pTextFrame->GetDrawObjs())
2305  {
2306  const SwSortedObjs* pSortedObjs = pTextFrame->GetDrawObjs();
2307  if (pSortedObjs->size() > 0)
2308  {
2309  SwAnchoredObject* pObject = (*pSortedObjs)[0];
2310  if (auto pFly = dynamic_cast<SwFlyFrame*>(pObject))
2311  {
2312  if (pFly->Lower() && pFly->Lower()->IsTabFrame())
2313  return true;
2314  }
2315  }
2316  }
2317  return false;
2318 }
2319 
2321 {
2322  tools::Long nLeft=0;
2323 
2324  if (!pCaller->IsTextFrame() || !static_cast<const SwTextFrame*>(pCaller)->GetDoc().GetDocumentSettingManager().get(DocumentSettingId::INVERT_BORDER_SPACING))
2325  {
2326  // OD 23.01.2003 #106895# - for cell frame in R2L text direction the left
2327  // and right border are painted on the right respectively left.
2328  if ( pCaller->IsCellFrame() && pCaller->IsRightToLeft() )
2329  nLeft = CalcRightLine();
2330  else
2331  nLeft = CalcLeftLine();
2332  }
2333 
2334  // for paragraphs, "left" is "before text" and "right" is "after text"
2335  if ( pCaller->IsTextFrame() && pCaller->IsRightToLeft() )
2336  nLeft += m_rLR->GetRight();
2337  else
2338  {
2339  bool bIgnoreMargin = false;
2340  if (pCaller->IsTextFrame())
2341  {
2342  const SwTextFrame* pTextFrame = static_cast<const SwTextFrame*>(pCaller);
2344  {
2345  // If this is explicitly requested, ignore the margins next to the floating table.
2346  if (lcl_hasTabFrame(pTextFrame))
2347  bIgnoreMargin = true;
2348  // TODO here we only handle the first two paragraphs, would be nice to generalize this.
2349  else if (pTextFrame->FindPrev() && pTextFrame->FindPrev()->IsTextFrame() && lcl_hasTabFrame(static_cast<const SwTextFrame*>(pTextFrame->FindPrev())))
2350  bIgnoreMargin = true;
2351  }
2352  }
2353  if (!bIgnoreMargin)
2354  nLeft += m_rLR->GetLeft();
2355  }
2356 
2357  // correction: do not retrieve left margin for numbering in R2L-layout
2358  if ( pCaller->IsTextFrame() && !pCaller->IsRightToLeft() )
2359  {
2360  nLeft += static_cast<const SwTextFrame*>(pCaller)->GetTextNodeForParaProps()->GetLeftMarginWithNum();
2361  }
2362 
2363  if (pCaller->IsPageFrame() && m_rLR)
2364  {
2365  const auto pPageFrame = static_cast<const SwPageFrame*>(pCaller);
2366  bool bGutterAtTop = pPageFrame->GetFormat()->getIDocumentSettingAccess().get(
2368  if (!bGutterAtTop)
2369  {
2370  bool bRtlGutter = pPageFrame->GetAttrSet()->GetItem<SfxBoolItem>(RES_RTL_GUTTER)->GetValue();
2371  tools::Long nGutterMargin = bRtlGutter ? m_rLR->GetRightGutterMargin() : m_rLR->GetGutterMargin();
2372  // Decrease the print area: the left space is the sum of left and gutter margins.
2373  nLeft += nGutterMargin;
2374  }
2375  }
2376 
2377  return nLeft;
2378 }
2379 
2380 /* Calculated values for borders and shadows.
2381  * It might be that a distance is wanted even without lines. This will be
2382  * considered here and not by the attribute (e.g. bBorderDist for cells).
2383  */
2384 
2386 {
2387  m_nTopLine = m_rBox.CalcLineSpace( SvxBoxItemLine::TOP, /*bEvenIfNoLine*/true );
2388  m_nTopLine = m_nTopLine + m_rShadow.CalcShadowSpace(SvxShadowItemSide::TOP);
2389  m_bTopLine = false;
2390 }
2391 
2393 {
2394  m_nBottomLine = m_rBox.CalcLineSpace( SvxBoxItemLine::BOTTOM, true );
2395  m_nBottomLine = m_nBottomLine + m_rShadow.CalcShadowSpace(SvxShadowItemSide::BOTTOM);
2396  m_bBottomLine = false;
2397 }
2398 
2400 {
2401  m_nLeftLine = m_rBox.CalcLineSpace( SvxBoxItemLine::LEFT, true);
2402  m_nLeftLine = m_nLeftLine + m_rShadow.CalcShadowSpace(SvxShadowItemSide::LEFT);
2403  m_bLeftLine = false;
2404 }
2405 
2407 {
2408  m_nRightLine = m_rBox.CalcLineSpace( SvxBoxItemLine::RIGHT, true );
2409  m_nRightLine = m_nRightLine + m_rShadow.CalcShadowSpace(SvxShadowItemSide::RIGHT);
2410  m_bRightLine = false;
2411 }
2412 
2414 {
2415  m_bIsLine = m_rBox.GetTop() || m_rBox.GetBottom() ||
2416  m_rBox.GetLeft()|| m_rBox.GetRight();
2417  m_bLine = false;
2418 }
2419 
2420 /* The borders of neighboring paragraphs are condensed by following algorithm:
2421  *
2422  * 1. No top border if the predecessor has the same top border and (3) applies.
2423  * In addition, the paragraph needs to have a border at least one side (left/right/bottom).
2424  * 2. No bottom border if the successor has the same bottom border and (3) applies.
2425  * In addition, the paragraph needs to have a border at least one side (left/right/top).
2426  * 3. The borders on the left and right side are identical between the current and the
2427  * pre-/succeeding paragraph.
2428  */
2429 
2430 static bool CmpLines( const editeng::SvxBorderLine *pL1, const editeng::SvxBorderLine *pL2 )
2431 {
2432  return ( ((pL1 && pL2) && (*pL1 == *pL2)) || (!pL1 && !pL2) );
2433 }
2434 
2435 // OD 21.05.2003 #108789# - change name of 1st parameter - "rAttrs" -> "rCmpAttrs"
2436 // OD 21.05.2003 #108789# - compare <CalcRight()> and <rCmpAttrs.CalcRight()>
2437 // instead of only the right LR-spacing, because R2L-layout has to be
2438 // considered.
2440  const SwFrame *pCaller,
2441  const SwFrame *pCmp ) const
2442 {
2443  return ( CmpLines( rCmpAttrs.GetBox().GetLeft(), GetBox().GetLeft() ) &&
2444  CmpLines( rCmpAttrs.GetBox().GetRight(),GetBox().GetRight() ) &&
2445  CalcLeft( pCaller ) == rCmpAttrs.CalcLeft( pCmp ) &&
2446  // OD 21.05.2003 #108789# - compare <CalcRight> with <rCmpAttrs.CalcRight>.
2447  CalcRight( pCaller ) == rCmpAttrs.CalcRight( pCmp ) );
2448 }
2449 
2450 bool SwBorderAttrs::JoinWithCmp( const SwFrame& _rCallerFrame,
2451  const SwFrame& _rCmpFrame ) const
2452 {
2453  bool bReturnVal = false;
2454 
2455  SwBorderAttrAccess aCmpAccess( SwFrame::GetCache(), &_rCmpFrame );
2456  const SwBorderAttrs &rCmpAttrs = *aCmpAccess.Get();
2457  if ( m_rShadow == rCmpAttrs.GetShadow() &&
2458  CmpLines( m_rBox.GetTop(), rCmpAttrs.GetBox().GetTop() ) &&
2459  CmpLines( m_rBox.GetBottom(), rCmpAttrs.GetBox().GetBottom() ) &&
2460  CmpLeftRight( rCmpAttrs, &_rCallerFrame, &_rCmpFrame )
2461  )
2462  {
2463  bReturnVal = true;
2464  }
2465 
2466  return bReturnVal;
2467 }
2468 
2469 // OD 21.05.2003 #108789# - method to determine, if borders are joined with
2470 // previous frame. Calculated value saved in cached value <m_bJoinedWithPrev>
2471 // OD 2004-02-26 #i25029# - add 2nd parameter <_pPrevFrame>
2473  const SwFrame* _pPrevFrame )
2474 {
2475  // set default
2476  m_bJoinedWithPrev = false;
2477 
2478  if ( _rFrame.IsTextFrame() )
2479  {
2480  // text frame can potentially join with previous text frame, if
2481  // corresponding attribute set is set at previous text frame.
2482  // OD 2004-02-26 #i25029# - If parameter <_pPrevFrame> is set, take this
2483  // one as previous frame.
2484  const SwFrame* pPrevFrame = _pPrevFrame ? _pPrevFrame : _rFrame.GetPrev();
2485  // OD 2004-02-13 #i25029# - skip hidden text frames.
2486  while ( pPrevFrame && pPrevFrame->IsTextFrame() &&
2487  static_cast<const SwTextFrame*>(pPrevFrame)->IsHiddenNow() )
2488  {
2489  pPrevFrame = pPrevFrame->GetPrev();
2490  }
2491  if ( pPrevFrame && pPrevFrame->IsTextFrame() &&
2492  pPrevFrame->GetAttrSet()->GetParaConnectBorder().GetValue()
2493  )
2494  {
2495  m_bJoinedWithPrev = JoinWithCmp( _rFrame, *pPrevFrame );
2496  }
2497  }
2498 
2499  // valid cache status, if demanded
2500  // OD 2004-02-26 #i25029# - Do not validate cache, if parameter <_pPrevFrame>
2501  // is set.
2502  m_bCachedJoinedWithPrev = m_bCacheGetLine && !_pPrevFrame;
2503 }
2504 
2505 // OD 21.05.2003 #108789# - method to determine, if borders are joined with
2506 // next frame. Calculated value saved in cached value <m_bJoinedWithNext>
2508 {
2509  // set default
2510  m_bJoinedWithNext = false;
2511 
2512  if ( _rFrame.IsTextFrame() )
2513  {
2514  // text frame can potentially join with next text frame, if
2515  // corresponding attribute set is set at current text frame.
2516  // OD 2004-02-13 #i25029# - get next frame, but skip hidden text frames.
2517  const SwFrame* pNextFrame = _rFrame.GetNext();
2518  while ( pNextFrame && pNextFrame->IsTextFrame() &&
2519  static_cast<const SwTextFrame*>(pNextFrame)->IsHiddenNow() )
2520  {
2521  pNextFrame = pNextFrame->GetNext();
2522  }
2523  if ( pNextFrame && pNextFrame->IsTextFrame() &&
2525  )
2526  {
2527  m_bJoinedWithNext = JoinWithCmp( _rFrame, *pNextFrame );
2528  }
2529  }
2530 
2531  // valid cache status, if demanded
2533 }
2534 
2535 // OD 21.05.2003 #108789# - accessor for cached values <m_bJoinedWithPrev>
2536 // OD 2004-02-26 #i25029# - add 2nd parameter <_pPrevFrame>, which is passed to
2537 // method <_CalcJoindWithPrev(..)>.
2539  const SwFrame* _pPrevFrame ) const
2540 {
2541  if ( !m_bCachedJoinedWithPrev || _pPrevFrame )
2542  {
2543  // OD 2004-02-26 #i25029# - pass <_pPrevFrame> as 2nd parameter
2544  const_cast<SwBorderAttrs*>(this)->CalcJoinedWithPrev( _rFrame, _pPrevFrame );
2545  }
2546 
2547  return m_bJoinedWithPrev;
2548 }
2549 
2550 bool SwBorderAttrs::JoinedWithNext( const SwFrame& _rFrame ) const
2551 {
2552  if ( !m_bCachedJoinedWithNext )
2553  {
2554  const_cast<SwBorderAttrs*>(this)->CalcJoinedWithNext( _rFrame );
2555  }
2556 
2557  return m_bJoinedWithNext;
2558 }
2559 
2560 // OD 2004-02-26 #i25029# - added 2nd parameter <_pPrevFrame>, which is passed to
2561 // method <JoinedWithPrev>
2563  const SwFrame* _pPrevFrame )
2564 {
2565  sal_uInt16 nRet = CalcTopLine();
2566 
2567  // OD 21.05.2003 #108789# - use new method <JoinWithPrev()>
2568  // OD 2004-02-26 #i25029# - add 2nd parameter
2569  if ( JoinedWithPrev( _rFrame, _pPrevFrame ) )
2570  {
2571  nRet = 0;
2572  }
2573 
2575 
2576  m_nGetTopLine = nRet;
2577 }
2578 
2580 {
2581  sal_uInt16 nRet = CalcBottomLine();
2582 
2583  // OD 21.05.2003 #108789# - use new method <JoinWithPrev()>
2584  if ( JoinedWithNext( _rFrame ) )
2585  {
2586  nRet = 0;
2587  }
2588 
2590 
2591  m_nGetBottomLine = nRet;
2592 }
2593 
2595 {
2596  // tdf#125300 compatibility option AddParaLineSpacingToTableCells needs also line spacing
2597  const SvxLineSpacingItem &rSpace = m_rAttrSet.GetLineSpacing();
2598  if ( rSpace.GetInterLineSpaceRule() == SvxInterLineSpaceRule::Prop && rSpace.GetPropLineSpace() > 100 )
2599  {
2600  sal_Int32 nFontSize = m_rAttrSet.Get(RES_CHRATR_FONTSIZE).GetHeight();
2601  m_nLineSpacing = nFontSize * (rSpace.GetPropLineSpace() - 100) * 1.15 / 100;
2602  }
2603  m_bLineSpacing = false;
2604 }
2605 
2607 {
2608  return rFrame.IsContentFrame()
2609  ? static_cast<sw::BorderCacheOwner const*>(rFrame.IsTextFrame()
2610  // sw_redlinehide: presumably this caches the border attrs at the model level and can be shared across different layouts so we want the ParaProps node here
2611  ? static_cast<const SwTextFrame&>(rFrame).GetTextNodeForParaProps()
2612  : static_cast<const SwNoTextFrame&>(rFrame).GetNode())
2613  : static_cast<sw::BorderCacheOwner const*>(static_cast<const SwLayoutFrame&>(rFrame).GetFormat());
2614 }
2615 
2617  SwCacheAccess( rCach,
2618  static_cast<void const *>(GetBorderCacheOwner(*pFrame)),
2619  GetBorderCacheOwner(*pFrame)->IsInCache()),
2620  m_pConstructor( pFrame )
2621 {
2622 }
2623 
2625 {
2626  const_cast<sw::BorderCacheOwner *>(static_cast<sw::BorderCacheOwner const *>(m_pOwner))->m_bInCache = true;
2627  return new SwBorderAttrs( static_cast<sw::BorderCacheOwner const *>(m_pOwner), m_pConstructor );
2628 }
2629 
2631 {
2632  return static_cast<SwBorderAttrs*>(SwCacheAccess::Get());
2633 }
2634 
2636  m_pPage( pPg ),
2637  m_pCurrent( nullptr )
2638 {
2639 }
2640 
2642 {
2643  m_pCurrent = nullptr;
2644  if ( !m_pPage->GetSortedObjs() )
2645  return;
2646 
2647  const SwSortedObjs *pObjs = m_pPage->GetSortedObjs();
2648  if ( !pObjs->size() )
2649  return;
2650 
2651  sal_uInt32 nTopOrd = 0;
2652  (*pObjs)[0]->GetDrawObj()->GetOrdNum(); // force updating
2653  for (SwAnchoredObject* i : *pObjs)
2654  {
2655  const SdrObject* pObj = i->GetDrawObj();
2656  if ( dynamic_cast<const SwVirtFlyDrawObj*>( pObj) == nullptr )
2657  continue;
2658  sal_uInt32 nTmp = pObj->GetOrdNumDirect();
2659  if ( nTmp >= nTopOrd )
2660  {
2661  nTopOrd = nTmp;
2662  m_pCurrent = pObj;
2663  }
2664  }
2665 }
2666 
2668 {
2669  m_pCurrent = nullptr;
2670  if ( m_pPage->GetSortedObjs() )
2671  {
2672  sal_uInt32 nBotOrd = USHRT_MAX;
2673  const SwSortedObjs *pObjs = m_pPage->GetSortedObjs();
2674  if ( pObjs->size() )
2675  {
2676  (*pObjs)[0]->GetDrawObj()->GetOrdNum(); // force updating
2677  for (SwAnchoredObject* i : *pObjs)
2678  {
2679  const SdrObject* pObj = i->GetDrawObj();
2680  if ( dynamic_cast<const SwVirtFlyDrawObj*>( pObj) == nullptr )
2681  continue;
2682  sal_uInt32 nTmp = pObj->GetOrdNumDirect();
2683  if ( nTmp < nBotOrd )
2684  {
2685  nBotOrd = nTmp;
2686  m_pCurrent = pObj;
2687  }
2688  }
2689  }
2690  }
2691  return m_pCurrent;
2692 }
2693 
2695 {
2696  const sal_uInt32 nCurOrd = m_pCurrent ? m_pCurrent->GetOrdNumDirect() : 0;
2697  m_pCurrent = nullptr;
2698  if ( m_pPage->GetSortedObjs() )
2699  {
2700  sal_uInt32 nOrd = USHRT_MAX;
2701  const SwSortedObjs *pObjs = m_pPage->GetSortedObjs();
2702  if ( pObjs->size() )
2703  {
2704  (*pObjs)[0]->GetDrawObj()->GetOrdNum(); // force updating
2705  for (SwAnchoredObject* i : *pObjs)
2706  {
2707  const SdrObject* pObj = i->GetDrawObj();
2708  if ( dynamic_cast<const SwVirtFlyDrawObj*>( pObj) == nullptr )
2709  continue;
2710  sal_uInt32 nTmp = pObj->GetOrdNumDirect();
2711  if ( nTmp > nCurOrd && nTmp < nOrd )
2712  {
2713  nOrd = nTmp;
2714  m_pCurrent = pObj;
2715  }
2716  }
2717  }
2718  }
2719  return m_pCurrent;
2720 }
2721 
2723 {
2724  const sal_uInt32 nCurOrd = m_pCurrent ? m_pCurrent->GetOrdNumDirect() : 0;
2725  m_pCurrent = nullptr;
2726  if ( !m_pPage->GetSortedObjs() )
2727  return;
2728 
2729  const SwSortedObjs *pObjs = m_pPage->GetSortedObjs();
2730  if ( !pObjs->size() )
2731  return;
2732 
2733  sal_uInt32 nOrd = 0;
2734  (*pObjs)[0]->GetDrawObj()->GetOrdNum(); // force updating
2735  for (SwAnchoredObject* i : *pObjs)
2736  {
2737  const SdrObject* pObj = i->GetDrawObj();
2738  if ( dynamic_cast<const SwVirtFlyDrawObj*>( pObj) == nullptr )
2739  continue;
2740  sal_uInt32 nTmp = pObj->GetOrdNumDirect();
2741  if ( nTmp < nCurOrd && nTmp >= nOrd )
2742  {
2743  nOrd = nTmp;
2744  m_pCurrent = pObj;
2745  }
2746  }
2747 }
2748 
2750 // New algorithm:
2751 // Do not look at each neighbor one by one to set all pointers correctly.
2752 // It is sufficient to detach a part of a chain and check if another chain needs to be added
2753 // when attaching it again. Only the pointers necessary for the chain connection need to be
2754 // adjusted. The correction happens in RestoreContent(). In between all access is restricted.
2755 // During this action, the Flys are detached from the page.
2756 
2757 // #115759# - 'remove' also drawing object from page and
2758 // at-fly anchored objects from page
2759 static void lcl_RemoveObjsFromPage( SwFrame* _pFrame )
2760 {
2761  OSL_ENSURE( _pFrame->GetDrawObjs(), "no DrawObjs in lcl_RemoveObjsFromPage." );
2762  SwSortedObjs &rObjs = *_pFrame->GetDrawObjs();
2763  for (SwAnchoredObject* pObj : rObjs)
2764  {
2765  // #115759# - reset member, at which the anchored
2766  // object orients its vertical position
2767  pObj->ClearVertPosOrientFrame();
2768  // #i43913#
2769  pObj->ResetLayoutProcessBools();
2770  // #115759# - remove also lower objects of as-character
2771  // anchored Writer fly frames from page
2772  if ( auto pFlyFrame = dynamic_cast<SwFlyFrame*>( pObj) )
2773  {
2774  // #115759# - remove also direct lowers of Writer
2775  // fly frame from page
2776  if ( pFlyFrame->GetDrawObjs() )
2777  {
2778  ::lcl_RemoveObjsFromPage( pFlyFrame );
2779  }
2780 
2781  SwContentFrame* pCnt = pFlyFrame->ContainsContent();
2782  while ( pCnt )
2783  {
2784  if ( pCnt->GetDrawObjs() )
2785  ::lcl_RemoveObjsFromPage( pCnt );
2786  pCnt = pCnt->GetNextContentFrame();
2787  }
2788  if ( pFlyFrame->IsFlyFreeFrame() )
2789  {
2790  // #i28701# - use new method <GetPageFrame()>
2791  if (SwPageFrame *pPg = pFlyFrame->GetPageFrame())
2792  pPg->RemoveFlyFromPage(pFlyFrame);
2793  }
2794  }
2795  // #115759# - remove also drawing objects from page
2796  else if ( auto pDrawObj = dynamic_cast<SwAnchoredDrawObject*>( pObj) )
2797  {
2798  if (pObj->GetFrameFormat().GetAnchor().GetAnchorId() != RndStdIds::FLY_AS_CHAR)
2799  {
2800  if (SwPageFrame *pPg = pObj->GetPageFrame())
2801  pPg->RemoveDrawObjFromPage( *pDrawObj );
2802  }
2803  }
2804  }
2805 }
2806 
2808 {
2809  if( pLay->IsSctFrame() && pLay->Lower() && pLay->Lower()->IsColumnFrame() )
2810  sw_RemoveFootnotes( static_cast<SwColumnFrame*>(pLay->Lower()), true, true );
2811 
2812  SwFrame *pSav = pLay->ContainsAny();
2813  if ( nullptr == pSav )
2814  return nullptr;
2815 
2816  if( pSav->IsInFootnote() && !pLay->IsInFootnote() )
2817  {
2818  do
2819  pSav = pSav->FindNext();
2820  while( pSav && pSav->IsInFootnote() );
2821  if( !pSav || !pLay->IsAnLower( pSav ) )
2822  return nullptr;
2823  }
2824 
2825  // Tables should be saved as a whole, exception:
2826  // The contents of a section or a cell inside a table should be saved
2827  if ( pSav->IsInTab() && !( ( pLay->IsSctFrame() || pLay->IsCellFrame() ) && pLay->IsInTab() ) )
2828  while ( !pSav->IsTabFrame() )
2829  pSav = pSav->GetUpper();
2830 
2831  if( pSav->IsInSct() )
2832  { // search the upmost section inside of pLay
2833  SwFrame* pSect = pLay->FindSctFrame();
2834  SwFrame *pTmp = pSav;
2835  do
2836  {
2837  pSav = pTmp;
2838  pTmp = (pSav && pSav->GetUpper()) ? pSav->GetUpper()->FindSctFrame() : nullptr;
2839  } while ( pTmp != pSect );
2840  }
2841 
2842  SwFrame *pFloat = pSav;
2843  if( !pStart )
2844  pStart = pSav;
2845  bool bGo = pStart == pSav;
2846  do
2847  {
2848  if( bGo )
2849  pFloat->GetUpper()->m_pLower = nullptr; // detach the chain part
2850 
2851  // search the end of the chain part, remove Flys on the way
2852  do
2853  {
2854  if( bGo )
2855  {
2856  if ( pFloat->IsContentFrame() )
2857  {
2858  if ( pFloat->GetDrawObjs() )
2859  ::lcl_RemoveObjsFromPage( static_cast<SwContentFrame*>(pFloat) );
2860  }
2861  else if ( pFloat->IsTabFrame() || pFloat->IsSctFrame() )
2862  {
2863  SwContentFrame *pCnt = static_cast<SwLayoutFrame*>(pFloat)->ContainsContent();
2864  if( pCnt )
2865  {
2866  do
2867  { if ( pCnt->GetDrawObjs() )
2868  ::lcl_RemoveObjsFromPage( pCnt );
2869  pCnt = pCnt->GetNextContentFrame();
2870  } while ( pCnt && static_cast<SwLayoutFrame*>(pFloat)->IsAnLower( pCnt ) );
2871  }
2872  }
2873  else {
2874  OSL_ENSURE( !pFloat, "new FloatFrame?" );
2875  }
2876  }
2877  if ( pFloat->GetNext() )
2878  {
2879  if( bGo )
2880  pFloat->mpUpper = nullptr;
2881  pFloat = pFloat->GetNext();
2882  if( !bGo && pFloat == pStart )
2883  {
2884  bGo = true;
2885  pFloat->mpPrev->mpNext = nullptr;
2886  pFloat->mpPrev = nullptr;
2887  }
2888  }
2889  else
2890  break;
2891 
2892  } while ( pFloat );
2893 
2894  // search next chain part and connect both chains
2895  SwFrame *pTmp = pFloat->FindNext();
2896  if( bGo )
2897  pFloat->mpUpper = nullptr;
2898 
2899  if( !pLay->IsInFootnote() )
2900  while( pTmp && pTmp->IsInFootnote() )
2901  pTmp = pTmp->FindNext();
2902 
2903  if ( !pLay->IsAnLower( pTmp ) )
2904  pTmp = nullptr;
2905 
2906  if ( pTmp && bGo )
2907  {
2908  pFloat->mpNext = pTmp; // connect both chains
2909  pFloat->mpNext->mpPrev = pFloat;
2910  }
2911  pFloat = pTmp;
2912  bGo = bGo || ( pStart == pFloat );
2913  } while ( pFloat );
2914 
2915  return bGo ? pStart : nullptr;
2916 }
2917 
2918 // #115759# - add also drawing objects to page and at-fly
2919 // anchored objects to page
2920 static void lcl_AddObjsToPage( SwFrame* _pFrame, SwPageFrame* _pPage )
2921 {
2922  OSL_ENSURE( _pFrame->GetDrawObjs(), "no DrawObjs in lcl_AddObjsToPage." );
2923  SwSortedObjs &rObjs = *_pFrame->GetDrawObjs();
2924  for (SwAnchoredObject* pObj : rObjs)
2925  {
2926  // #115759# - unlock position of anchored object
2927  // in order to get the object's position calculated.
2928  pObj->UnlockPosition();
2929  // #115759# - add also lower objects of as-character
2930  // anchored Writer fly frames from page
2931  if ( auto pFlyFrame = dynamic_cast<SwFlyFrame*>( pObj) )
2932  {
2933  if (pFlyFrame->IsFlyFreeFrame())
2934  {
2935  _pPage->AppendFlyToPage( pFlyFrame );
2936  }
2937  pFlyFrame->InvalidatePos_();
2938  pFlyFrame->InvalidateSize_();
2939  pFlyFrame->InvalidatePage( _pPage );
2940 
2941  // #115759# - add also at-fly anchored objects
2942  // to page
2943  if ( pFlyFrame->GetDrawObjs() )
2944  {
2945  ::lcl_AddObjsToPage( pFlyFrame, _pPage );
2946  }
2947 
2948  SwContentFrame *pCnt = pFlyFrame->ContainsContent();
2949  while ( pCnt )
2950  {
2951  if ( pCnt->GetDrawObjs() )
2952  ::lcl_AddObjsToPage( pCnt, _pPage );
2953  pCnt = pCnt->GetNextContentFrame();
2954  }
2955  }
2956  // #115759# - remove also drawing objects from page
2957  else if ( dynamic_cast<const SwAnchoredDrawObject*>( pObj) != nullptr )
2958  {
2959  if (pObj->GetFrameFormat().GetAnchor().GetAnchorId() != RndStdIds::FLY_AS_CHAR)
2960  {
2961  pObj->InvalidateObjPos();
2962  _pPage->AppendDrawObjToPage(
2963  *static_cast<SwAnchoredDrawObject*>(pObj) );
2964  }
2965  }
2966  }
2967 }
2968 
2969 void RestoreContent( SwFrame *pSav, SwLayoutFrame *pParent, SwFrame *pSibling )
2970 {
2971  OSL_ENSURE( pSav && pParent, "no Save or Parent provided for RestoreContent." );
2972  SwRectFnSet aRectFnSet(pParent);
2973 
2974  // If there are already FlowFrames below the new parent, so add the chain (starting with pSav)
2975  // after the last one. The parts are inserted and invalidated if needed.
2976  // On the way, the Flys of the ContentFrames are registered at the page.
2977 
2978  SwPageFrame *pPage = pParent->FindPageFrame();
2979 
2980  if ( pPage )
2981  pPage->InvalidatePage( pPage );
2982 
2983  // determine predecessor and establish connection or initialize
2984  pSav->mpPrev = pSibling;
2985  SwFrame* pNxt;
2986  if ( pSibling )
2987  {
2988  pNxt = pSibling->mpNext;
2989  pSibling->mpNext = pSav;
2990  pSibling->InvalidatePrt_();
2991  pSibling->InvalidatePage( pPage );
2992  SwFlowFrame *pFlowFrame = dynamic_cast<SwFlowFrame*>(pSibling);
2993  if (pFlowFrame && pFlowFrame->GetFollow())
2994  pSibling->Prepare( PrepareHint::Clear, nullptr, false );
2995  }
2996  else
2997  { pNxt = pParent->m_pLower;
2998  pParent->m_pLower = pSav;
2999  pSav->mpUpper = pParent; // set here already, so that it is explicit when invalidating
3000 
3001  if ( pSav->IsContentFrame() )
3002  static_cast<SwContentFrame*>(pSav)->InvalidatePage( pPage );
3003  else
3004  { // pSav might be an empty SectFrame
3005  SwContentFrame* pCnt = pParent->ContainsContent();
3006  if( pCnt )
3007  pCnt->InvalidatePage( pPage );
3008  }
3009  }
3010 
3011  // the parent needs to grow appropriately
3012  SwTwips nGrowVal = 0;
3013  SwFrame* pLast;
3014  do
3015  { pSav->mpUpper = pParent;
3016  nGrowVal += aRectFnSet.GetHeight(pSav->getFrameArea());
3017  pSav->InvalidateAll_();
3018 
3019  // register Flys, if TextFrames than also invalidate appropriately
3020  if ( pSav->IsContentFrame() )
3021  {
3022  if ( pSav->IsTextFrame() &&
3023  static_cast<SwTextFrame*>(pSav)->GetCacheIdx() != USHRT_MAX )
3024  static_cast<SwTextFrame*>(pSav)->Init(); // I am its friend
3025 
3026  if ( pPage && pSav->GetDrawObjs() )
3027  ::lcl_AddObjsToPage( static_cast<SwContentFrame*>(pSav), pPage );
3028  }
3029  else
3030  { SwContentFrame *pBlub = static_cast<SwLayoutFrame*>(pSav)->ContainsContent();
3031  if( pBlub )
3032  {
3033  do
3034  { if ( pPage && pBlub->GetDrawObjs() )
3035  ::lcl_AddObjsToPage( pBlub, pPage );
3036  if( pBlub->IsTextFrame() && static_cast<SwTextFrame*>(pBlub)->HasFootnote() &&
3037  static_cast<SwTextFrame*>(pBlub)->GetCacheIdx() != USHRT_MAX )
3038  static_cast<SwTextFrame*>(pBlub)->Init(); // I am its friend
3039  pBlub = pBlub->GetNextContentFrame();
3040  } while ( pBlub && static_cast<SwLayoutFrame*>(pSav)->IsAnLower( pBlub ));
3041  }
3042  }
3043  pLast = pSav;
3044  pSav = pSav->GetNext();
3045 
3046  } while ( pSav );
3047 
3048  if( pNxt )
3049  {
3050  pLast->mpNext = pNxt;
3051  pNxt->mpPrev = pLast;
3052  }
3053 
3054  pParent->Grow( nGrowVal );
3055 }
3056 
3057 namespace sw {
3058 
3059 bool IsRightPageByNumber(SwRootFrame const& rLayout, sal_uInt16 const nPageNum)
3060 {
3061  assert(rLayout.GetLower());
3062  // unfortunately can only get SwPageDesc, not SwFormatPageDesc here...
3063  auto const nFirstVirtPageNum(rLayout.GetLower()->GetVirtPageNum());
3064  bool const isFirstPageOfLayoutOdd(nFirstVirtPageNum % 2 == 1);
3065  return ((nPageNum % 2) == 1) == isFirstPageOfLayoutOdd;
3066 }
3067 
3068 } // namespace sw
3069 
3071  bool const isRightPage, bool const bFirst, bool bInsertEmpty,
3072  bool const bFootnote,
3073  SwFrame *pSibling,
3074  bool const bVeryFirstPage )
3075 {
3076  assert(pUpper);
3077  assert(pUpper->IsRootFrame());
3078  assert(!pSibling || static_cast<SwLayoutFrame const*>(pUpper)->Lower() != pSibling); // currently no insert before 1st page
3079  SwPageFrame *pRet;
3080  SwDoc *pDoc = static_cast<SwLayoutFrame*>(pUpper)->GetFormat()->GetDoc();
3081  if (bFirst)
3082  {
3083  if (rDesc.IsFirstShared())
3084  {
3085  // We need to fallback to left or right page format, decide it now.
3086  // FIXME: is this still needed?
3087  if (isRightPage)
3088  {
3089  rDesc.GetFirstMaster().SetFormatAttr( rDesc.GetMaster().GetHeader() );
3090  rDesc.GetFirstMaster().SetFormatAttr( rDesc.GetMaster().GetFooter() );
3091  // fdo#60250 copy margins for mirrored pages
3092  rDesc.GetFirstMaster().SetFormatAttr( rDesc.GetMaster().GetLRSpace() );
3093  }
3094  else
3095  {
3096  rDesc.GetFirstLeft().SetFormatAttr( rDesc.GetLeft().GetHeader() );
3097  rDesc.GetFirstLeft().SetFormatAttr( rDesc.GetLeft().GetFooter() );
3098  rDesc.GetFirstLeft().SetFormatAttr( rDesc.GetLeft().GetLRSpace() );
3099  }
3100  }
3101  }
3102  SwFrameFormat *pFormat(isRightPage ? rDesc.GetRightFormat(bFirst) : rDesc.GetLeftFormat(bFirst));
3103  // If there is no FrameFormat for this page, add an empty page
3104  if ( !pFormat )
3105  {
3106  pFormat = isRightPage ? rDesc.GetLeftFormat(bVeryFirstPage) : rDesc.GetRightFormat(bVeryFirstPage);
3107  OSL_ENSURE( pFormat, "Descriptor without any format?!" );
3108  bInsertEmpty = !bInsertEmpty;
3109  }
3110  if( bInsertEmpty )
3111  {
3112  SwPageDesc *pTmpDesc = pSibling && pSibling->GetPrev() ?
3113  static_cast<SwPageFrame*>(pSibling->GetPrev())->GetPageDesc() : &rDesc;
3114  pRet = new SwPageFrame( pDoc->GetEmptyPageFormat(), pUpper, pTmpDesc );
3115  SAL_INFO( "sw.pageframe", "InsertNewPage - insert empty p: " << pRet << " d: " << pTmpDesc );
3116  pRet->Paste( pUpper, pSibling );
3117  pRet->PreparePage( bFootnote );
3118  }
3119  pRet = new SwPageFrame( pFormat, pUpper, &rDesc );
3120  SAL_INFO( "sw.pageframe", "InsertNewPage p: " << pRet << " d: " << &rDesc << " f: " << pFormat );
3121  pRet->Paste( pUpper, pSibling );
3122  pRet->PreparePage( bFootnote );
3123  if ( pRet->GetNext() )
3125  return pRet;
3126 }
3127 
3128 /* The following two methods search the layout structure recursively and
3129  * register all Flys at the page that have a Frame in this structure as an anchor.
3130  */
3131 
3132 static void lcl_Regist( SwPageFrame *pPage, const SwFrame *pAnch )
3133 {
3134  SwSortedObjs *pObjs = const_cast<SwSortedObjs*>(pAnch->GetDrawObjs());
3135  for (SwAnchoredObject* pObj : *pObjs)
3136  {
3137  if (SwFlyFrame* pFly = dynamic_cast<SwFlyFrame*>(pObj))
3138  {
3139  // register (not if already known)
3140  // #i28701# - use new method <GetPageFrame()>
3141  SwPageFrame *pPg = pFly->IsFlyFreeFrame()
3142  ? pFly->GetPageFrame() : pFly->FindPageFrame();
3143  if ( pPg != pPage )
3144  {
3145  if ( pPg )
3146  pPg->RemoveFlyFromPage( pFly );
3147  pPage->AppendFlyToPage( pFly );
3148  }
3149  ::RegistFlys( pPage, pFly );
3150  }
3151  else
3152  {
3153  // #i87493#
3154  if ( pPage != pObj->GetPageFrame() )
3155  {
3156  // #i28701#
3157  if (SwPageFrame *pPg = pObj->GetPageFrame())
3158  pPg->RemoveDrawObjFromPage( *pObj );
3159  pPage->AppendDrawObjToPage( *pObj );
3160  }
3161  }
3162 
3163  const SwFlyFrame* pFly = pAnch->FindFlyFrame();
3164  if ( pFly &&
3165  pObj->GetDrawObj()->GetOrdNum() < pFly->GetVirtDrawObj()->GetOrdNum() &&
3166  pObj->GetDrawObj()->getSdrPageFromSdrObject() )
3167  {
3168  //#i119945# set pFly's OrdNum to pObj's. So when pFly is removed by Undo, the original OrdNum will not be changed.
3170  pObj->GetDrawObj()->GetOrdNumDirect() );
3171  }
3172  }
3173 }
3174 
3175 void RegistFlys( SwPageFrame *pPage, const SwLayoutFrame *pLay )
3176 {
3177  if ( pLay->GetDrawObjs() )
3178  ::lcl_Regist( pPage, pLay );
3179  const SwFrame *pFrame = pLay->Lower();
3180  while ( pFrame )
3181  {
3182  if ( pFrame->IsLayoutFrame() )
3183  ::RegistFlys( pPage, static_cast<const SwLayoutFrame*>(pFrame) );
3184  else if ( pFrame->GetDrawObjs() )
3185  ::lcl_Regist( pPage, pFrame );
3186  pFrame = pFrame->GetNext();
3187  }
3188 }
3189 
3191 void Notify( SwFlyFrame *pFly, SwPageFrame *pOld, const SwRect &rOld,
3192  const SwRect* pOldPrt )
3193 {
3194  const SwRect aFrame( pFly->GetObjRectWithSpaces() );
3195  if ( rOld.Pos() != aFrame.Pos() )
3196  { // changed position, invalidate old and new area
3197  if ( rOld.HasArea() &&
3198  rOld.Left()+pFly->GetFormat()->GetLRSpace().GetLeft() < FAR_AWAY )
3199  {
3200  pFly->NotifyBackground( pOld, rOld, PrepareHint::FlyFrameLeave );
3201  }
3203  }
3204  else if ( rOld.SSize() != aFrame.SSize() )
3205  { // changed size, invalidate the area that was left or is now overlapped
3206  // For simplicity, we purposely invalidate a Twip even if not needed.
3207 
3208  SwViewShell *pSh = pFly->getRootFrame()->GetCurrShell();
3209  if( pSh && rOld.HasArea() )
3210  pSh->InvalidateWindows( rOld );
3211 
3212  // #i51941# - consider case that fly frame isn't
3213  // registered at the old page <pOld>
3214  SwPageFrame* pPageFrame = pFly->FindPageFrame();
3215  if ( pOld != pPageFrame )
3216  {
3217  pFly->NotifyBackground( pPageFrame, aFrame, PrepareHint::FlyFrameArrive );
3218  }
3219 
3220  if ( rOld.Left() != aFrame.Left() )
3221  {
3222  SwRect aTmp( rOld );
3223  aTmp.Union( aFrame );
3224  aTmp.Left( std::min(aFrame.Left(), rOld.Left()) );
3225  aTmp.Right( std::max(aFrame.Left(), rOld.Left()) );
3227  }
3228  SwTwips nOld = rOld.Right();
3229  SwTwips nNew = aFrame.Right();
3230  if ( nOld != nNew )
3231  {
3232  SwRect aTmp( rOld );
3233  aTmp.Union( aFrame );
3234  aTmp.Left( std::min(nNew, nOld) );
3235  aTmp.Right( std::max(nNew, nOld) );
3237  }
3238  if ( rOld.Top() != aFrame.Top() )
3239  {
3240  SwRect aTmp( rOld );
3241  aTmp.Union( aFrame );
3242  aTmp.Top( std::min(aFrame.Top(), rOld.Top()) );
3243  aTmp.Bottom( std::max(aFrame.Top(), rOld.Top()) );
3245  }
3246  nOld = rOld.Bottom();
3247  nNew = aFrame.Bottom();
3248  if ( nOld != nNew )
3249  {
3250  SwRect aTmp( rOld );
3251  aTmp.Union( aFrame );
3252  aTmp.Top( std::min(nNew, nOld) );
3253  aTmp.Bottom( std::max(nNew, nOld) );
3255  }
3256  }
3257  else if(pOldPrt && *pOldPrt != pFly->getFramePrintArea())
3258  {
3259  bool bNotifyBackground(pFly->GetFormat()->GetSurround().IsContour());
3260 
3261  if(!bNotifyBackground &&
3262  pFly->IsFlyFreeFrame() &&
3263  static_cast< const SwFlyFreeFrame* >(pFly)->supportsAutoContour())
3264  {
3265  // RotateFlyFrame3: Also notify for FlyFrames which allow AutoContour
3266  bNotifyBackground = true;
3267  }
3268 
3269  if(bNotifyBackground)
3270  {
3271  // #i24097#
3273  }
3274  }
3275 }
3276 
3277 static void lcl_CheckFlowBack( SwFrame* pFrame, const SwRect &rRect )
3278 {
3279  SwTwips nBottom = rRect.Bottom();
3280  while( pFrame )
3281  {
3282  if( pFrame->IsLayoutFrame() )
3283  {
3284  if( rRect.IsOver( pFrame->getFrameArea() ) )
3285  lcl_CheckFlowBack( static_cast<SwLayoutFrame*>(pFrame)->Lower(), rRect );
3286  }
3287  else if( !pFrame->GetNext() && nBottom > pFrame->getFrameArea().Bottom() )
3288  {
3289  if( pFrame->IsContentFrame() && static_cast<SwContentFrame*>(pFrame)->HasFollow() )
3290  pFrame->InvalidateSize();
3291  else
3292  pFrame->InvalidateNextPos();
3293  }
3294  pFrame = pFrame->GetNext();
3295  }
3296 }
3297 
3298 static void lcl_NotifyContent( const SdrObject *pThis, SwContentFrame *pCnt,
3299  const SwRect &rRect, const PrepareHint eHint )
3300 {
3301  if ( !pCnt->IsTextFrame() )
3302  return;
3303 
3304  SwRect aCntPrt( pCnt->getFramePrintArea() );
3305  aCntPrt.Pos() += pCnt->getFrameArea().Pos();
3307  {
3308  // #i35640# - use given rectangle <rRect> instead
3309  // of current bound rectangle
3310  if ( aCntPrt.IsOver( rRect ) )
3312  }
3313  // #i23129# - only invalidate, if the text frame
3314  // printing area overlaps with the given rectangle.
3315  else if ( aCntPrt.IsOver( rRect ) )
3316  pCnt->Prepare( eHint, static_cast<void*>(&aCntPrt.Intersection_( rRect )) );
3317  if ( !pCnt->GetDrawObjs() )
3318  return;
3319 
3320  const SwSortedObjs &rObjs = *pCnt->GetDrawObjs();
3321  for (SwAnchoredObject* pObj : rObjs)
3322  {
3323  if ( auto pFly = dynamic_cast<SwFlyFrame*>( pObj) )
3324  {
3325  if ( pFly->IsFlyInContentFrame() )
3326  {
3327  SwContentFrame *pContent = pFly->ContainsContent();
3328  while ( pContent )
3329  {
3330  ::lcl_NotifyContent( pThis, pContent, rRect, eHint );
3331  pContent = pContent->GetNextContentFrame();
3332  }
3333  }
3334  }
3335  }
3336 }
3337 
3338 void Notify_Background( const SdrObject* pObj,
3339  SwPageFrame* pPage,
3340  const SwRect& rRect,
3341  const PrepareHint eHint,
3342  const bool bInva )
3343 {
3344  // If the frame was positioned correctly for the first time, do not inform the old area
3345  if ( eHint == PrepareHint::FlyFrameLeave && rRect.Top() == FAR_AWAY )
3346  return;
3347 
3348  SwLayoutFrame* pArea;
3349  SwFlyFrame *pFlyFrame = nullptr;
3350  SwFrame* pAnchor;
3351  if( auto pVirtFlyDrawObj = dynamic_cast<const SwVirtFlyDrawObj*>( pObj) )
3352  {
3353  pFlyFrame = const_cast<SwVirtFlyDrawObj*>(pVirtFlyDrawObj)->GetFlyFrame();
3354  pAnchor = pFlyFrame->AnchorFrame();
3355  }
3356  else
3357  {
3358  pFlyFrame = nullptr;
3359  pAnchor = const_cast<SwFrame*>(
3360  GetUserCall(pObj)->GetAnchoredObj( pObj )->GetAnchorFrame() );
3361  }
3362  if( PrepareHint::FlyFrameLeave != eHint && pAnchor->IsInFly() )
3363  pArea = pAnchor->FindFlyFrame();
3364  else
3365  pArea = pPage;
3366  SwContentFrame *pCnt = nullptr;
3367  if ( pArea )
3368  {
3369  if( PrepareHint::FlyFrameArrive != eHint )
3370  lcl_CheckFlowBack( pArea, rRect );
3371 
3372  // Only the Flys following this anchor are reacting. Thus, those do not
3373  // need to be processed.
3374  // An exception is LEAVE, since the Fly might come "from above".
3375  // If the anchor is positioned on the previous page, the whole page
3376  // needs to be processed (47722).
3377  // OD 2004-05-13 #i28701# - If the wrapping style has to be considered
3378  // on the object positioning, the complete area has to be processed,
3379  // because content frames before the anchor frame also have to consider
3380  // the object for the text wrapping.
3381  // #i3317# - The complete area has always been
3382  // processed.
3383  {
3384  pCnt = pArea->ContainsContent();
3385  }
3386  }
3387  SwFrame *pLastTab = nullptr;
3388 
3389  bool isValidTableBeforeAnchor(false);
3390  while ( pCnt && pArea && pArea->IsAnLower( pCnt ) )
3391  {
3392  ::lcl_NotifyContent( pObj, pCnt, rRect, eHint );
3393  if ( pCnt->IsInTab() )
3394  {
3395  SwTabFrame *pTab = pCnt->FindTabFrame();
3396  if ( pTab != pLastTab )
3397  {
3398  pLastTab = pTab;
3399  isValidTableBeforeAnchor = false;
3400  if (PrepareHint::FlyFrameArrive == eHint
3401  && pFlyFrame // TODO: do it for draw objects too?
3402  && pTab->IsFollow() // table starts on previous page?
3403  // "through" means they will actually overlap anyway
3404  && css::text::WrapTextMode_THROUGH != pFlyFrame->GetFormat()->GetSurround().GetSurround()
3405  // if it's anchored in footer it can't move to other page
3406  && !pAnchor->FindFooterOrHeader())
3407  {
3408  SwFrame * pTmp(pAnchor->GetPrev());
3409  while (pTmp)
3410  {
3411  if (pTmp == pTab)
3412  {
3413  // tdf#99460 the table shouldn't be moved by the fly
3414  isValidTableBeforeAnchor = true;
3415  break;
3416  }
3417  pTmp = pTmp->GetPrev();
3418  }
3419  }
3420  // #i40606# - use <GetLastBoundRect()>
3421  // instead of <GetCurrentBoundRect()>, because a recalculation
3422  // of the bounding rectangle isn't intended here.
3423  if (!isValidTableBeforeAnchor
3424  && (pTab->getFrameArea().IsOver(SwRect(pObj->GetLastBoundRect())) ||
3425  pTab->getFrameArea().IsOver(rRect)))
3426  {
3427  if ( !pFlyFrame || !pFlyFrame->IsLowerOf( pTab ) )
3428  pTab->InvalidatePrt();
3429  }
3430  }
3431  SwLayoutFrame* pCell = pCnt->GetUpper();
3432  // #i40606# - use <GetLastBoundRect()>
3433  // instead of <GetCurrentBoundRect()>, because a recalculation
3434  // of the bounding rectangle isn't intended here.
3435  if (!isValidTableBeforeAnchor && pCell->IsCellFrame() &&
3436  ( pCell->getFrameArea().IsOver( SwRect(pObj->GetLastBoundRect()) ) ||
3437  pCell->getFrameArea().IsOver( rRect ) ) )
3438  {
3439  const SwFormatVertOrient &rOri = pCell->GetFormat()->GetVertOrient();
3441  pCell->InvalidatePrt();
3442  }
3443  }
3444  pCnt = pCnt->GetNextContentFrame();
3445  }
3446  // #128702# - make code robust
3447  if ( pPage && pPage->GetSortedObjs() )
3448  {
3449  pObj->GetOrdNum();
3450  const SwSortedObjs &rObjs = *pPage->GetSortedObjs();
3451  for (SwAnchoredObject* pAnchoredObj : rObjs)
3452  {
3453  if ( dynamic_cast<const SwFlyFrame*>( pAnchoredObj) != nullptr )
3454  {
3455  if( pAnchoredObj->GetDrawObj() == pObj )
3456  continue;
3457  SwFlyFrame *pFly = static_cast<SwFlyFrame*>(pAnchoredObj);
3458  if ( pFly->getFrameArea().Top() == FAR_AWAY )
3459  continue;
3460 
3461  if ( !pFlyFrame ||
3462  (!pFly->IsLowerOf( pFlyFrame ) &&
3463  pFly->GetVirtDrawObj()->GetOrdNumDirect() < pObj->GetOrdNumDirect()))
3464  {
3465  pCnt = pFly->ContainsContent();
3466  while ( pCnt )
3467  {
3468  ::lcl_NotifyContent( pObj, pCnt, rRect, eHint );
3469  pCnt = pCnt->GetNextContentFrame();
3470  }
3471  }
3472  if( pFly->IsFlyLayFrame() )
3473  {
3474  if( pFly->Lower() && pFly->Lower()->IsColumnFrame() &&
3475  pFly->getFrameArea().Bottom() >= rRect.Top() &&
3476  pFly->getFrameArea().Top() <= rRect.Bottom() &&
3477  pFly->getFrameArea().Right() >= rRect.Left() &&
3478  pFly->getFrameArea().Left() <= rRect.Right() )
3479  {
3480  pFly->InvalidateSize();
3481  }
3482  }
3483  // Flys above myself might sidestep if they have an automatic
3484  // alignment. This happens independently of my attributes since
3485  // this might have been changed as well.
3486  else if ( pFly->IsFlyAtContentFrame() &&
3487  pObj->GetOrdNumDirect() <
3488  pFly->GetVirtDrawObj()->GetOrdNumDirect() &&
3489  pFlyFrame && !pFly->IsLowerOf( pFlyFrame ) )
3490  {
3491  const SwFormatHoriOrient &rH = pFly->GetFormat()->GetHoriOrient();
3493  text::HoriOrientation::CENTER != rH.GetHoriOrient() &&
3494  ( !pFly->IsAutoPos() || text::RelOrientation::CHAR != rH.GetRelationOrient() ) &&
3495  (pFly->getFrameArea().Bottom() >= rRect.Top() &&
3496  pFly->getFrameArea().Top() <= rRect.Bottom()) )
3497  pFly->InvalidatePos();
3498  }
3499  }
3500  }
3501  }
3502  if ( pFlyFrame && pAnchor->GetUpper() && pAnchor->IsInTab() )//MA_FLY_HEIGHT
3503  pAnchor->GetUpper()->InvalidateSize();
3504 
3505  // #i82258# - make code robust
3506  SwViewShell* pSh = nullptr;
3507  if ( bInva && pPage &&
3508  nullptr != (pSh = pPage->getRootFrame()->GetCurrShell()) )
3509  {
3510  pSh->InvalidateWindows( rRect );
3511  }
3512 }
3513 
3516 const SwFrame* GetVirtualUpper( const SwFrame* pFrame, const Point& rPos )
3517 {
3518  if( pFrame->IsTextFrame() )
3519  {
3520  pFrame = pFrame->GetUpper();
3521  if( !pFrame->getFrameArea().IsInside( rPos ) )
3522  {
3523  if( pFrame->IsFootnoteFrame() )
3524  {
3525  const SwFootnoteFrame* pTmp = static_cast<const SwFootnoteFrame*>(pFrame)->GetFollow();
3526  while( pTmp )
3527  {
3528  if( pTmp->getFrameArea().IsInside( rPos ) )
3529  return pTmp;
3530  pTmp = pTmp->GetFollow();
3531  }
3532  }
3533  else
3534  {
3535  SwFlyFrame* pTmp = const_cast<SwFlyFrame*>(pFrame->FindFlyFrame());
3536  while( pTmp )
3537  {
3538  if( pTmp->getFrameArea().IsInside( rPos ) )
3539  return pTmp;
3540  pTmp = pTmp->GetNextLink();
3541  }
3542  }
3543  }
3544  }
3545  return pFrame;
3546 }
3547 
3548 bool Is_Lower_Of(const SwFrame *pCurrFrame, const SdrObject* pObj)
3549 {
3550  Point aPos;
3551  const SwFrame* pFrame;
3552  if (const SwVirtFlyDrawObj *pFlyDrawObj = dynamic_cast<const SwVirtFlyDrawObj*>(pObj))
3553  {
3554  const SwFlyFrame* pFly = pFlyDrawObj->GetFlyFrame();
3555  pFrame = pFly->GetAnchorFrame();
3556  aPos = pFly->getFrameArea().Pos();
3557  }
3558  else
3559  {
3560  pFrame = static_cast<SwDrawContact*>(GetUserCall(pObj))->GetAnchorFrame(pObj);
3561  aPos = pObj->GetCurrentBoundRect().TopLeft();
3562  }
3563  OSL_ENSURE( pFrame, "8-( Fly is lost in Space." );
3564  pFrame = GetVirtualUpper( pFrame, aPos );
3565  do
3566  { if ( pFrame == pCurrFrame )
3567  return true;
3568  if( pFrame->IsFlyFrame() )
3569  {
3570  aPos = pFrame->getFrameArea().Pos();
3571  pFrame = GetVirtualUpper( static_cast<const SwFlyFrame*>(pFrame)->GetAnchorFrame(), aPos );
3572  }
3573  else
3574  pFrame = pFrame->GetUpper();
3575  } while ( pFrame );
3576  return false;
3577 }
3578 
3580 const SwFrame *FindContext( const SwFrame *pFrame, SwFrameType nAdditionalContextType )
3581 {
3585  nAdditionalContextType;
3586  do
3587  { if ( pFrame->GetType() & nTyp )
3588  break;
3589  pFrame = pFrame->GetUpper();
3590  } while( pFrame );
3591  return pFrame;
3592 }
3593 
3594 bool IsFrameInSameContext( const SwFrame *pInnerFrame, const SwFrame *pFrame )
3595 {
3596  const SwFrame *pContext = FindContext( pInnerFrame, SwFrameType::None );
3597 
3601  do
3602  { if ( pFrame->GetType() & nTyp )
3603  {
3604  if( pFrame == pContext )
3605  return true;
3606  if( pFrame->IsCellFrame() )
3607  return false;
3608  }
3609  if( pFrame->IsFlyFrame() )
3610  {
3611  Point aPos( pFrame->getFrameArea().Pos() );
3612  pFrame = GetVirtualUpper( static_cast<const SwFlyFrame*>(pFrame)->GetAnchorFrame(), aPos );
3613  }
3614  else
3615  pFrame = pFrame->GetUpper();
3616  } while( pFrame );
3617 
3618  return false;
3619 }
3620 
3622 {
3623  SwFrame *pLow = pCell->Lower();
3624  if ( pLow && (pLow->IsContentFrame() || pLow->IsSctFrame()) )
3625  {
3626  tools::Long nHeight = 0, nFlyAdd = 0;
3627  do
3628  {
3629  tools::Long nLow = pLow->getFrameArea().Height();
3630  if( pLow->IsTextFrame() && static_cast<SwTextFrame*>(pLow)->IsUndersized() )
3631  nLow += static_cast<SwTextFrame*>(pLow)->GetParHeight()-pLow->getFramePrintArea().Height();
3632  else if( pLow->IsSctFrame() && static_cast<SwSectionFrame*>(pLow)->IsUndersized() )
3633  nLow += static_cast<SwSectionFrame*>(pLow)->Undersize();
3634  nFlyAdd = std::max( tools::Long(0), nFlyAdd - nLow );
3635  nFlyAdd = std::max( nFlyAdd, ::CalcHeightWithFlys( pLow ) );
3636  nHeight += nLow;
3637  pLow = pLow->GetNext();
3638  } while ( pLow );
3639  if ( nFlyAdd )
3640  nHeight += nFlyAdd;
3641 
3642  // The border cannot be calculated based on PrtArea and Frame, since both can be invalid.
3643  SwBorderAttrAccess aAccess( SwFrame::GetCache(), pCell );
3644  const SwBorderAttrs &rAttrs = *aAccess.Get();
3645  nHeight += rAttrs.CalcTop() + rAttrs.CalcBottom();
3646 
3647  return pCell->getFrameArea().Height() - nHeight;
3648  }
3649  else
3650  {
3651  tools::Long nRstHeight = 0;
3652  while (pLow && pLow->IsLayoutFrame())
3653  {
3654  nRstHeight += ::CalcRowRstHeight(static_cast<SwLayoutFrame*>(pLow));
3655  pLow = pLow->GetNext();
3656  }
3657  return nRstHeight;
3658  }
3659 }
3660 
3662 {
3663  SwFrame *pLow = pRow->Lower();
3664  if (!(pLow && pLow->IsLayoutFrame()))
3665  {
3666  return 0;
3667  }
3668  SwTwips nRstHeight = LONG_MAX;
3669  while (pLow && pLow->IsLayoutFrame())
3670  {
3671  nRstHeight = std::min(nRstHeight, ::lcl_CalcCellRstHeight(static_cast<SwLayoutFrame*>(pLow)));
3672  pLow = pLow->GetNext();
3673  }
3674  return nRstHeight;
3675 }
3676 
3677 const SwFrame* FindPage( const SwRect &rRect, const SwFrame *pPage )
3678 {
3679  if ( !rRect.IsOver( pPage->getFrameArea() ) )
3680  {
3681  const SwRootFrame* pRootFrame = static_cast<const SwRootFrame*>(pPage->GetUpper());
3682  const SwFrame* pTmpPage = pRootFrame ? pRootFrame->GetPageAtPos( rRect.TopLeft(), &rRect.SSize(), true ) : nullptr;
3683  if ( pTmpPage )
3684  pPage = pTmpPage;
3685  }
3686 
3687  return pPage;
3688 }
3689 
3690 namespace {
3691 
3692 class SwFrameHolder : private SfxListener
3693 {
3694  SwFrame* m_pFrame;
3695  bool m_bSet;
3696  virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
3697 public:
3698  SwFrameHolder()
3699  : m_pFrame(nullptr)
3700  , m_bSet(false)
3701  {
3702  }
3703  void SetFrame( SwFrame* pHold );
3704  SwFrame* GetFrame() { return m_pFrame; }
3705  void Reset();
3706  bool IsSet() const { return m_bSet; }
3707 };
3708 
3709 }
3710 
3711 void SwFrameHolder::SetFrame( SwFrame* pHold )
3712 {
3713  m_bSet = true;
3714  if (m_pFrame != pHold)
3715  {
3716  if (m_pFrame)
3717  EndListening(*m_pFrame);
3718  StartListening(*pHold);
3719  m_pFrame = pHold;
3720  }
3721 }
3722 
3723 void SwFrameHolder::Reset()
3724 {
3725  if (m_pFrame)
3726  EndListening(*m_pFrame);
3727  m_bSet = false;
3728  m_pFrame = nullptr;
3729 }
3730 
3731 void SwFrameHolder::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
3732 {
3733  if (rHint.GetId() == SfxHintId::Dying && &rBC == m_pFrame)
3734  {
3735  m_pFrame = nullptr;
3736  }
3737 }
3738 
3740  SwFrameType const nFrameType, SwPosition const*const pPos,
3741  std::pair<Point, bool> const*const pViewPosAndCalcFrame)
3742 {
3743  SwFrame *pMinFrame = nullptr, *pTmpFrame;
3744  SwFrameHolder aHolder;
3745  SwRect aCalcRect;
3746  bool bClientIterChanged = false;
3747 
3749  do {
3750  pMinFrame = nullptr;
3751  aHolder.Reset();
3752  sal_uInt64 nMinDist = 0;
3753  bClientIterChanged = false;
3754 
3755  for( pTmpFrame = aIter.First(); pTmpFrame; pTmpFrame = aIter.Next() )
3756  {
3757  if( pTmpFrame->GetType() & nFrameType &&
3758  ( !pLayout || pLayout == pTmpFrame->getRootFrame() ) &&
3759  (!pTmpFrame->IsFlowFrame() ||
3760  !SwFlowFrame::CastFlowFrame( pTmpFrame )->IsFollow() ))
3761  {
3762  if (pViewPosAndCalcFrame)
3763  {
3764  // watch for Frame being deleted
3765  if ( pMinFrame )
3766  aHolder.SetFrame( pMinFrame );
3767  else
3768  aHolder.Reset();
3769 
3770  if (pViewPosAndCalcFrame->second)
3771  {
3772  // tdf#108118 prevent recursion
3773  DisableCallbackAction a(*pTmpFrame->getRootFrame());
3774  // - format parent Writer
3775  // fly frame, if it isn't been formatted yet.
3776  // Note: The Writer fly frame could be the frame itself.
3777  SwFlyFrame* pFlyFrame( pTmpFrame->FindFlyFrame() );
3778  if ( pFlyFrame &&
3779  pFlyFrame->getFrameArea().Pos().X() == FAR_AWAY &&
3780  pFlyFrame->getFrameArea().Pos().Y() == FAR_AWAY )
3781  {
3782  SwObjectFormatter::FormatObj( *pFlyFrame );
3783  }
3784  pTmpFrame->Calc(pLayout ? pLayout->GetCurrShell()->GetOut() : nullptr);
3785  }
3786 
3787  // aIter.IsChanged checks if the current pTmpFrame has been deleted while
3788  // it is the current iterator
3789  // FrameHolder watches for deletion of the current pMinFrame
3790  if( aIter.IsChanged() || ( aHolder.IsSet() && !aHolder.GetFrame() ) )
3791  {
3792  // restart iteration
3793  bClientIterChanged = true;
3794  break;
3795  }
3796 
3797  // for Flys go via the parent if the Fly is not yet "formatted"
3798  if (!pViewPosAndCalcFrame->second &&
3799  pTmpFrame->GetType() & SwFrameType::Fly &&
3800  static_cast<SwFlyFrame*>(pTmpFrame)->GetAnchorFrame() &&
3801  FAR_AWAY == pTmpFrame->getFrameArea().Pos().getX() &&
3802  FAR_AWAY == pTmpFrame->getFrameArea().Pos().getY() )
3803  aCalcRect = static_cast<SwFlyFrame*>(pTmpFrame)->GetAnchorFrame()->getFrameArea();
3804  else
3805  aCalcRect = pTmpFrame->getFrameArea();
3806 
3807  if (aCalcRect.IsInside(pViewPosAndCalcFrame->first))
3808  {
3809  pMinFrame = pTmpFrame;
3810  break;
3811  }
3812 
3813  // Point not in rectangle. Compare distances:
3814  const Point aCalcRectCenter = aCalcRect.Center();
3815  const Point aDiff = aCalcRectCenter - pViewPosAndCalcFrame->first;
3816  const sal_uInt64 nCurrentDist = sal_Int64(aDiff.getX()) * sal_Int64(aDiff.getX()) + sal_Int64(aDiff.getY()) * sal_Int64(aDiff.getY()); // opt: no sqrt
3817  if ( !pMinFrame || nCurrentDist < nMinDist )
3818  {
3819  pMinFrame = pTmpFrame;
3820  nMinDist = nCurrentDist;
3821  }
3822  }
3823  else
3824  {
3825  // if no pViewPosAndCalcFrame is provided, take the first one
3826  pMinFrame = pTmpFrame;
3827  break;
3828  }
3829  }
3830  }
3831  } while( bClientIterChanged );
3832 
3833  if( pPos && pMinFrame && pMinFrame->IsTextFrame() )
3834  return static_cast<SwTextFrame*>(pMinFrame)->GetFrameAtPos( *pPos );
3835 
3836  return pMinFrame;
3837 }
3838 
3839 bool IsExtraData( const SwDoc *pDoc )
3840 {
3841  const SwLineNumberInfo &rInf = pDoc->GetLineNumberInfo();
3842  return rInf.IsPaintLineNumbers() ||
3843  rInf.IsCountInFlys() ||
3844  (static_cast<sal_Int16>(SW_MOD()->GetRedlineMarkPos()) != text::HoriOrientation::NONE &&
3846  (pDoc->GetEditShell() && pDoc->GetEditShell()->GetViewOptions() &&
3848 }
3849 
3850 // OD 22.09.2003 #110978#
3852 {
3853  SwRect aPrtWithoutHeaderFooter( getFramePrintArea() );
3854  aPrtWithoutHeaderFooter.Pos() += getFrameArea().Pos();
3855 
3856  const SwFrame* pLowerFrame = Lower();
3857  while ( pLowerFrame )
3858  {
3859  // Note: independent on text direction page header and page footer are
3860  // always at top respectively at bottom of the page frame.
3861  if ( pLowerFrame->IsHeaderFrame() )
3862  {
3863  aPrtWithoutHeaderFooter.AddTop( pLowerFrame->getFrameArea().Height() );
3864  }
3865  if ( pLowerFrame->IsFooterFrame() )
3866  {
3867  aPrtWithoutHeaderFooter.AddBottom( - pLowerFrame->getFrameArea().Height() );
3868  }
3869 
3870  pLowerFrame = pLowerFrame->GetNext();
3871  }
3872 
3873  return aPrtWithoutHeaderFooter;
3874 }
3875 
3882 void GetSpacingValuesOfFrame( const SwFrame& rFrame,
3883  SwTwips& onLowerSpacing,
3884  SwTwips& onLineSpacing,
3885  bool& obIsLineSpacingProportional,
3886  bool bIdenticalStyles )
3887 {
3888  if ( !rFrame.IsFlowFrame() )
3889  {
3890  onLowerSpacing = 0;
3891  onLineSpacing = 0;
3892  }
3893  else
3894  {
3895  const SvxULSpaceItem& rULSpace = rFrame.GetAttrSet()->GetULSpace();
3896  // check contextual spacing if the style of actual and next paragraphs are identical
3897  if (bIdenticalStyles)
3898  onLowerSpacing = (rULSpace.GetContext() ? 0 : rULSpace.GetLower());
3899  else
3900  onLowerSpacing = rULSpace.GetLower();
3901 
3902  onLineSpacing = 0;
3903  obIsLineSpacingProportional = false;
3904  if ( rFrame.IsTextFrame() )
3905  {
3906  onLineSpacing = static_cast<const SwTextFrame&>(rFrame).GetLineSpace();
3907  obIsLineSpacingProportional =
3908  onLineSpacing != 0 &&
3909  static_cast<const SwTextFrame&>(rFrame).GetLineSpace( true ) == 0;
3910  }
3911 
3912  OSL_ENSURE( onLowerSpacing >= 0 && onLineSpacing >= 0,
3913  "<GetSpacingValuesOfFrame(..)> - spacing values aren't positive!" );
3914  }
3915 }
3916 
3919 {
3920  const SwContentFrame* pContent = rCell.ContainsContent();
3921  const SwTabFrame* pTab = rCell.FindTabFrame();
3922 
3923  while ( pContent && rCell.IsAnLower( pContent ) )
3924  {
3925  const SwTabFrame* pTmpTab = pContent->FindTabFrame();
3926  if ( pTmpTab != pTab )
3927  {
3928  SwFrame const*const pTmp = pTmpTab->FindLastContentOrTable();
3929  if (pTmp)
3930  {
3931  pContent = pTmp->FindNextCnt();
3932  }
3933  else
3934  {
3935  pContent = nullptr;
3936  }
3937  }
3938  else
3939  break;
3940  }
3941  return pContent;
3942 }
3943 
3945  : mpFrame( pFrame )
3946  , mpRegIn( pFrame
3947  ? pFrame->IsTextFrame()
3948  // sw_redlinehide: GetDep() may be a member of SwTextFrame!
3949  ? static_cast<SwTextFrame const*>(pFrame)->GetTextNodeFirst()
3950  : const_cast<SwFrame*>(pFrame)->GetDep()
3951  : nullptr )
3952 {
3953 }
3954 
3957 {
3958  if ( !mpFrame || !mpRegIn )
3959  return false;
3960 
3962  SwFrame* pLast = aIter.First();
3963  while ( pLast )
3964  {
3965  if ( pLast == mpFrame )
3966  return false;
3967  pLast = aIter.Next();
3968  }
3969 
3970  return true;
3971 }
3972 
3973 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool m_bJoinedWithPrev
Definition: frmtool.hxx:331
SwTwips mnFlyAnchorOfstNoWrap
Definition: frmtool.hxx:232
bool IsAnLower(const SwFrame *) const
Definition: findfrm.cxx:207
vcl::RenderContext * GetOut() const
Definition: viewsh.hxx:338
bool GetValue() const
SwFrame * FindFooterOrHeader()
Definition: findfrm.cxx:548
Starts a section of nodes in the document model.
Definition: node.hxx:312
sal_uInt16 CalcBottomLine() const
Definition: frmtool.hxx:507
bool IsContour() const
Definition: fmtsrnd.hxx:53
static bool s_bLocked
Definition: frmtool.hxx:455
const SwVirtFlyDrawObj * GetVirtDrawObj() const
Definition: fly.cxx:2783
Base class for the following contact objects (frame + draw objects).
Definition: dcontact.hxx:66
Base class of the Writer layout elements.
Definition: frame.hxx:313
Base class that provides the general functionalities for frames that are allowed at page breaks (flow...
Definition: flowfrm.hxx:58
sal_uInt16 m_nLineSpacing
Definition: frmtool.hxx:335
SwFlyNotify(SwFlyFrame *pFlyFrame)
Definition: frmtool.cxx:645
Represents the visualization of a paragraph.
Definition: txtfrm.hxx:158
SdrObject * GetDrawObjectByAnchorFrame(const SwFrame &_rAnchorFrame)
get drawing object ('master' or 'virtual') by frame.
Definition: dcontact.cxx:856
FlyCreationSuppressor(bool isAlreadySuppressedAllowed=true)
Definition: frmtool.cxx:87
bool m_bBottom
Definition: frmtool.hxx:316
void InvalidateInfFlags()
Definition: frame.hxx:607
void InvalidateAccessibleFrameContent(const SwFrame *pFrame)
Invalidate accessible frame's content.
Definition: viewimp.cxx:333
void NotifyDrawObj()
Definition: fly.cxx:2478
const SdrObject * Next()
Definition: frmtool.cxx:2694
sal_uLong GetIndex() const
Definition: node.hxx:291
static void lcl_SetPos(SwFrame &_rNewFrame, const SwLayoutFrame &_rLayFrame)
local method to set 'working' position for newly inserted frames
Definition: frmtool.cxx:1439
void Right(const tools::Long nRight)
Definition: swrect.hxx:200
const SvxBoxItem & m_rBox
Definition: frmtool.hxx:305
bool IsFlyLayFrame() const
Definition: flyfrm.hxx:217
sal_uInt16 m_nLeftLine
Definition: frmtool.hxx:335
void ColLock()
Definition: ftnfrm.hxx:136
bool IsFollow() const
Definition: flowfrm.hxx:166
Point GetPos(const SwRect &rRect) const
Definition: frame.hxx:1380
virtual const SwFlyFrameFormat * GetFormat() const override
Definition: fly.cxx:2877
void RemoveFromList(SwSectionFrame *pSct)
Definition: rootfrm.hxx:382
const SwSortedObjs * GetDrawObjs() const
Definition: frame.hxx:563
void SetCallbackActionEnabled(bool b)
Definition: rootfrm.hxx:387
sal_uInt16 GetPropLineSpace() const
bool m_bTopLine
Definition: frmtool.hxx:311
Marks a position in the document model.
Definition: pam.hxx:35
virtual const tools::Rectangle & GetCurrentBoundRect() const
SwFrame * mpNext
Definition: frame.hxx:337
SwFrame * mpPrev
Definition: frame.hxx:338
bool IsSectionNode() const
Definition: node.hxx:645
SwContentFrame * GetNextContentFrame() const
Definition: cntfrm.hxx:115
SwFrame * mpFrame
Definition: frmtool.hxx:228
SwContentNode * GetNode(SwPaM &rPam, bool &rbFirst, SwMoveFnCollection const &fnMove, bool const bInReadOnly, SwRootFrame const *const i_pLayout)
This function returns the next node in direction of search.
Definition: pam.cxx:823
void Init()
const SwPageFrame * GetPageAtPos(const Point &rPt, const Size *pSize=nullptr, bool bExtend=false) const
Point rPt: The point that should be used to find the page Size pSize: If given, we return the (first)...
Definition: findfrm.cxx:573
bool IsInFly() const
Definition: frame.hxx:958
SwRect & Union(const SwRect &rRect)
Definition: swrect.cxx:41
const SwFrame * m_pConstructor
Definition: frmtool.hxx:423
bool IsRootFrame() const
Definition: frame.hxx:1171
SwTwips Grow(SwTwips, bool bTst=false, bool bInfo=false)
Definition: wsfrm.cxx:1506
SwFrameFormat & GetLeft()
Definition: pagedesc.hxx:239
sal_uInt16 GetLower() const
bool IsInSct() const
Definition: frame.hxx:964
bool CheckControlLayer(const SdrObject *pObj)
Definition: dcontact.cxx:679
bool MoveFwd(bool bMakePage, bool bPageBreak, bool bMoveAlways=false)
Return value guarantees that a new page was not created, although false does not NECESSARILY indicate...
Definition: flowfrm.cxx:1927
const SwPageFrame * m_pPage
Definition: frmtool.hxx:438
drawinglayer::attribute::SdrAllFillAttributesHelperPtr getSdrAllFillAttributesHelper() const
Definition: findfrm.cxx:694
void ClearImpl()
Definition: laycache.cxx:440
bool m_bRightLine
Definition: frmtool.hxx:314
bool IsAnyShellAccessible() const
Definition: rootfrm.hxx:390
const SwLineNumberInfo & GetLineNumberInfo() const
Definition: lineinfo.cxx:49
const SwOLEObj & GetOLEObj() const
Definition: ndole.hxx:112
SwViewShellImp * Imp()
Definition: viewsh.hxx:182
void DelEmpty(bool bRemove)
Definition: sectfrm.cxx:186
bool IsLowerOf(const SwLayoutFrame *pUpper) const
Definition: fly.cxx:2161
SwFootnoteFrame * ImplFindFootnoteFrame()
Definition: findfrm.cxx:505
static void CheckPageDescs(SwPageFrame *pStart, bool bNotifyFields=true, SwPageFrame **ppPrev=nullptr)
Check all pages (starting from the given one) if they use the appropriate frame format.
Definition: pagechg.cxx:1056
const SvxBrushItem & GetBackground(bool=true) const
Definition: frmatr.hxx:58
void RestoreContent(SwFrame *pSav, SwLayoutFrame *pParent, SwFrame *pSibling)
Definition: frmtool.cxx:2969
const SwFormatHeader & GetHeader(bool=true) const
Definition: fmthdft.hxx:97
virtual bool get(DocumentSettingId id) const override
Return the specified document setting.
const SwRect & getFrameArea() const
Definition: frmtool.hxx:241
~SwFrameNotify() COVERITY_NOEXCEPT_FALSE
Definition: frmtool.cxx:127
bool bObjsDirect
Definition: frmtool.cxx:100
void ColLock()
Definition: sectfrm.hxx:95
std::string GetValue
bool IsColLocked() const
Definition: frame.hxx:883
bool SplitSect(SwFrame *pFrame, bool bApres)
Splits the SectionFrame surrounding the pFrame up in two parts: pFrame and the start of the 2nd part...
Definition: sectfrm.cxx:509
SwTwips mnHeightOfLastLine
Definition: frmtool.hxx:272
bool IsKeep(SvxFormatKeepItem const &rKeep, SvxFormatBreakItem const &rBreak, bool bBreakCheck=false) const
method to determine if a Keep needs to be considered (Breaks!)
Definition: flowfrm.cxx:235
const SwFormatVertOrient & GetVertOrient(bool=true) const
Definition: fmtornt.hxx:106
void Left(const tools::Long nLeft)
Definition: swrect.hxx:195
SwNodeIndex nNode
Definition: pam.hxx:37
GPOS_NONE
void SetCompletePaint() const
Definition: frame.hxx:991
bool IsInFootnote() const
Definition: frame.hxx:946
virtual bool Prepare(const PrepareHint ePrep=PrepareHint::Clear, const void *pVoid=nullptr, bool bNotify=true)
Definition: wsfrm.cxx:600
SwFrameType GetType() const
Definition: frame.hxx:518
virtual sal_Int32 Len() const override
Definition: ndtxt.cxx:276
sal_uIntPtr sal_uLong
long Long
std::shared_ptr< SvxLRSpaceItem > m_rLR
Definition: frmtool.hxx:304
const SwRect & getFramePrintArea() const
Definition: frame.hxx:179
constexpr TypedWhichId< SvxFontHeightItem > RES_CHRATR_FONTSIZE(8)
void SetConsiderForTextWrap(const bool _bConsiderForTextWrap)
const SwParaConnectBorderItem & GetParaConnectBorder(bool=true) const
Definition: paratr.hxx:222
static SwCache & GetCache()
Definition: frame.hxx:520
SwTabFrame is one table in the document layout, containing rows (which contain cells).
Definition: tabfrm.hxx:46
SwFrameFormat & GetFirstMaster()
Definition: pagedesc.hxx:240
tools::Long CalcRight(const SwFrame *pCaller) const
Definition: frmtool.cxx:2258
sw::MergedPara * GetMergedPara()
Definition: txtfrm.hxx:450
bool mbValidSize
Definition: frmtool.hxx:235
bool JoinedWithPrev(const SwFrame &_rFrame, const SwFrame *_pPrevFrame=nullptr) const
Definition: frmtool.cxx:2538
SwContentFrame * getLayoutFrame(const SwRootFrame *, const SwPosition *pPos=nullptr, std::pair< Point, bool > const *pViewPosAndCalcFrame=nullptr) const
Definition: node.cxx:1213
virtual SwContentFrame * MakeFrame(SwFrame *pSib)=0
MakeFrame will be called for a certain layout pSib is another SwFrame of the same layout (e...
Definition: doc.hxx:188
SwFrame * FindPrev()
Definition: frame.hxx:1152
void Unlock()
Definition: flyfrm.hxx:146
TElementType * Next()
Definition: calbck.hxx:333
SwLayNotify(SwLayoutFrame *pLayFrame)
Definition: frmtool.cxx:433
bool HasFollow() const
Definition: flowfrm.hxx:165
helper class to disable creation of an action by a callback event in particular, change event from a ...
Definition: rootfrm.hxx:451
bool m_bJoinedWithNext
Definition: frmtool.hxx:332
void Prev()
Definition: frmtool.cxx:2722
const SvxShadowItem & GetShadow() const
Definition: frmtool.hxx:389
void InvalidatePos()
Definition: frame.hxx:1040
SwFrameNotify(SwFrame *pFrame)
Definition: frmtool.cxx:106
virtual void CalcAndSetScale(svt::EmbeddedObjectRef &xObj, const SwRect *pFlyPrtRect=nullptr, const SwRect *pFlyFrameRect=nullptr, const bool bNoTextFramePrtAreaChanged=false)=0
Client for OleObject has to be up-to-date regarding scaling.
bool JoinWithCmp(const SwFrame &_rCallerFrame, const SwFrame &_rCmpFrame) const
Definition: frmtool.cxx:2450
static void lcl_CheckFlowBack(SwFrame *pFrame, const SwRect &rRect)
Definition: frmtool.cxx:3277
Helps during the InsertCnt_ function to create new pages.
Definition: layhelp.hxx:103
bool IsSelectFrameAnchoredAtPara(SwPosition const &rAnchorPos, SwPosition const &rStart, SwPosition const &rEnd, DelContentType const nDelContentType)
is a fly anchored at paragraph at rAnchorPos selected?
Definition: undobj.cxx:1639
sal_uInt16 CalcTopLine() const
Definition: frmtool.hxx:501
bool IsVert() const
Definition: frame.hxx:1364
SwSectionFormat * GetFormat()
Definition: section.hxx:336
static void DestroyFrame(SwFrame *const pFrame)
this is the only way to delete a SwFrame instance
Definition: ssfrm.cxx:384
void Pos(const Point &rNew)
Definition: swrect.hxx:169
Dialog to specify the properties of date form field.
sal_uInt16 m_nRightLine
Definition: frmtool.hxx:335
SwFrame * FindNext()
Definition: frame.hxx:1138
bool IsCellFrame() const
Definition: frame.hxx:1223
bool supportsFullDrawingLayerFillAttributeSet() const
Definition: findfrm.cxx:710
void Top()
Definition: frmtool.cxx:2641
Of course Writer needs its own rectangles.
Definition: swrect.hxx:35
virtual const SvxFormatBreakItem & GetBreakItem() const
Definition: findfrm.cxx:657
tools::Long GetWidth(const SwRect &rRect) const
Definition: frame.hxx:1378
const void * m_pOwner
Definition: swcache.hxx:203
bool IsDestroyFrameAnchoredAtChar(SwPosition const &rAnchorPos, SwPosition const &rStart, SwPosition const &rEnd, DelContentType const nDelContentType)
will DelContentIndex destroy a frame anchored at character at rAnchorPos?
Definition: undobj.cxx:1598
const editeng::SvxBorderLine * GetRight() const
bool IsFlyLock() const
Definition: flowfrm.hxx:230
static SwFlowFrame * CastFlowFrame(SwFrame *pFrame)
Definition: flowfrm.cxx:2703
sal_Int16 GetRelationOrient() const
Definition: fmtornt.hxx:55
void SetPageNum(sal_uInt16 nNew)
Definition: fmtanchr.hxx:72
EmbeddedObjectRef * pObject
bool IsCountInFlys() const
Definition: lineinfo.hxx:86
The root element of a Writer document layout.
Definition: rootfrm.hxx:82
SwContact * GetUserCall(const SdrObject *pObj)
Returns the UserCall if applicable from the group object.
Definition: dcontact.cxx:171
css::chart::ChartAxisLabelPosition ePos
static void lcl_RemoveObjsFromPage(SwFrame *_pFrame)
Keep and restore the substructure of a layout frame for an action.
Definition: frmtool.cxx:2759
bool IsFootnoteFrame() const
Definition: frame.hxx:1199
const SwFrameFormats * GetSpzFrameFormats() const
Definition: doc.hxx:744
SfxHintId GetId() const
static bool bFootnote
Definition: insfnote.cxx:33
tools::Long TopDist(const SwRect &rRect, tools::Long nPos) const
Definition: frame.hxx:1410
SwCacheObj * Get(bool isDuplicateOwnerAllowed)
Definition: swcache.hxx:257
void CheckDirChange()
checks the layout direction and invalidates the lower frames recursively, if necessary.
Definition: ssfrm.cxx:192
void AddTop(const tools::Long nAdd)
Definition: swrect.cxx:165
sal_uInt16 GetPhyPageNum() const
Definition: pagefrm.hxx:204
const SwSection & GetSection() const
Definition: node.hxx:542
bool IsFlyAtContentFrame() const
Definition: flyfrm.hxx:218
tools::Long GetTop(const SwRect &rRect) const
Definition: frame.hxx:1374
virtual SwCacheObj * NewObj() override
Can be use in NewObj.
Definition: frmtool.cxx:2624
virtual void UnblockIdling()=0
Decrement block count.
Point TopLeft() const
Definition: swrect.cxx:174
void RemoveFlyFromPage(SwFlyFrame *pToRemove)
Definition: flylay.cxx:889
IDocumentFieldsAccess const & getIDocumentFieldsAccess() const
Definition: doc.cxx:357
void CalcBottomLine_()
Definition: frmtool.cxx:2392
void SetRetouche() const
Definition: frame.hxx:1000
bool IsFrameInSameContext(const SwFrame *pInnerFrame, const SwFrame *pFrame)
Definition: frmtool.cxx:3594
tools::Long CalcHeightWithFlys(const SwFrame *pFrame)
Definition: tabfrm.cxx:4000
GPOS_TILED
void InvalidateObjs(const bool _bNoInvaOfAsCharAnchoredObjs=true)
Definition: fly.cxx:2345
bool IsFlyFrame() const
Definition: frame.hxx:1207
sal_uInt16 CalcLeftLine() const
Definition: frmtool.hxx:513
void InvalidateNextPrtArea()
method to invalidate printing area of next frame #i11859#
Definition: findfrm.cxx:1282
void ChgLowersProp(const Size &rOldSize)
Change size of lowers proportionally.
Definition: wsfrm.cxx:3015
wrapper class for the positioning of Writer fly frames and drawing objects
virtual bool IsUpdateExpField() const =0
const void * m_pOwner
Definition: swcache.hxx:161
bool m_bLineSpacing
Definition: frmtool.hxx:318
bool DoesContainAtPageObjWithContentAnchor()
Definition: doc.hxx:573
SvxGraphicPosition GetGraphicPos() const
void AppendFly(SwFlyFrame *pNew)
Definition: fly.cxx:2180
constexpr TypedWhichId< SwDrawFrameFormat > RES_DRAWFRMFMT(159)
bool IsMoveable(const SwLayoutFrame *_pLayoutFrame=nullptr) const
determine, if frame is moveable in given environment
Definition: findfrm.cxx:1362
const SwFrame * GetVirtualUpper(const SwFrame *pFrame, const Point &rPos)
Provides the Upper of an anchor in paragraph-bound objects.
Definition: frmtool.cxx:3516
void Notify_Background(const SdrObject *pObj, SwPageFrame *pPage, const SwRect &rRect, const PrepareHint eHint, const bool bInva)
Definition: frmtool.cxx:3338
SdrPage * getSdrPageFromSdrObject() const
bool IsLowersComplete() const
Definition: frmtool.hxx:254
const SwFrame * GetAnchorFrame(const SdrObject *_pDrawObj=nullptr) const
Definition: dcontact.cxx:804
bool empty() const
Definition: docary.hxx:260
const SwRect & getFrameArea() const
Definition: frame.hxx:178
bool getBrowseMode() const
Definition: viewopt.hxx:472
SwSectionNode * GetSectionNode()
Definition: section.cxx:957
bool IsInTab() const
Definition: frame.hxx:952
std::unique_ptr< sw::MergedPara > CheckParaRedlineMerge(SwTextFrame &rFrame, SwTextNode &rTextNode, FrameMode eMode)
Definition: redlnitr.cxx:205
bool m_bCachedGetBottomLine
Definition: frmtool.hxx:324
svt::EmbeddedObjectRef & GetObject()
Definition: ndole.cxx:967
const SvxShadowItem & m_rShadow
Definition: frmtool.hxx:306
sal_uLong GetIndex() const
Definition: ndindex.hxx:152
constexpr TypedWhichId< SfxBoolItem > RES_RTL_GUTTER(132)
virtual void UpdateTableFields(SfxPoolItem *pHt)=0
SwFrame * MakeFrame(SwFrame *)
Definition: ndsect.cxx:1040
bool IsTextFrame() const
Definition: frame.hxx:1231
void InsertCnt_(SwLayoutFrame *pLay, SwDoc *pDoc, sal_uLong nIndex, bool bPages, sal_uLong nEndIndex, SwFrame *pPrv, sw::FrameMode const eMode)
Definition: frmtool.cxx:1458
std::shared_ptr< SdrAllFillAttributesHelper > SdrAllFillAttributesHelperPtr
Definition: format.hxx:41
void InvalidateFlyContent() const
Definition: pagefrm.hxx:368
void CalcJoinedWithNext(const SwFrame &_rFrame)
Definition: frmtool.cxx:2507
void CalcTopLine_()
Definition: frmtool.cxx:2385
bool IsStartNode() const
Definition: node.hxx:625
void CalcJoinedWithPrev(const SwFrame &_rFrame, const SwFrame *_pPrevFrame)
Definition: frmtool.cxx:2472
bool mbHadFollow
Definition: frmtool.hxx:233
void Width(tools::Long nNew)
Definition: swrect.hxx:187
void Lock()
Definition: flyfrm.hxx:145
void GetTopLine_(const SwFrame &_rFrame, const SwFrame *_pPrevFrame)
Definition: frmtool.cxx:2562
Mode eMode
const SwTable & GetTable() const
Definition: node.hxx:499
bool m_bLeftLine
Definition: frmtool.hxx:313
const SwFormatSurround & GetSurround(bool=true) const
Definition: fmtsrnd.hxx:66
std::vector< SwFrameFormat * > const & GetAnchoredFlys() const
Definition: node.hxx:297
SwDoc * GetDoc() const
Definition: viewsh.hxx:281
bool empty() const
Describes parts of multiple text nodes, which will form a text frame, even when redlines are hidden a...
Definition: txtfrm.hxx:956
bool IsSctFrame() const
Definition: frame.hxx:1211
const SwAttrSet & m_rAttrSet
Definition: frmtool.hxx:301
SwFlyFrame * FindFlyFrame()
Definition: frame.hxx:1108
bool mbInvaKeep
Definition: frmtool.hxx:234
const SwRect aFrameAndSpace
Definition: frmtool.hxx:260
void AppendObjs(const SwFrameFormats *const pTable, sal_uLong const nIndex, SwFrame *const pFrame, SwPageFrame *const pPage, SwDoc *const pDoc)
Definition: frmtool.cxx:1246
SdrObject * DrawObj()
const SwRect maPrt
Definition: frmtool.hxx:230
const SwRect maFrame
Definition: frmtool.hxx:229
bool IsFlowFrame() const
Definition: frame.hxx:1239
const SvxFormatKeepItem & GetKeep(bool=true) const
Definition: frmatr.hxx:56
SwFrame * AnchorFrame()
static sw::BorderCacheOwner const * GetBorderCacheOwner(SwFrame const &rFrame)
Definition: frmtool.cxx:2606
SwDrawVirtObj * AddVirtObj(SwFrame const &rAnchorFrame)
add a 'virtual' drawing object to drawing page.
Definition: dcontact.cxx:830
void CalcLineSpacing_()
Definition: frmtool.cxx:2594
sal_uInt32 GetOrdNumDirect() const
Specific frame formats (frames, DrawObjects).
SwLayoutCache * GetLayoutCache() const
Definition: doc.hxx:1546
const SwAttrSet * GetAttrSet() const
WARNING: this may not return correct RES_PAGEDESC/RES_BREAK items for SwTextFrame, use GetBreakItem()/GetPageDescItem() instead.
Definition: findfrm.cxx:677
void InvalidateContent() const
Definition: pagefrm.hxx:380
const SwFrame & GetFrame() const
Definition: flowfrm.hxx:151
virtual void Paste(SwFrame *pParent, SwFrame *pSibling=nullptr)=0
FrameMode
Definition: txtfrm.hxx:103
const bool m_wasAlreadySuppressed
Definition: frmtool.hxx:164
bool IsShowOutlineContentVisibilityButton() const
Definition: viewopt.cxx:99
virtual void Cut()=0
SwFrame * GetFrameOfModify(SwRootFrame const *const pLayout, sw::BroadcastingModify const &rMod, SwFrameType const nFrameType, SwPosition const *const pPos, std::pair< Point, bool > const *const pViewPosAndCalcFrame)
Definition: frmtool.cxx:3739
sal_uInt16 GetVirtPageNum() const
Definition: trvlfrm.cxx:1806
bool IsColumnFrame() const
Definition: frame.hxx:1179
const SwContentFrame * GetCellContent(const SwLayoutFrame &rCell)
get the content of the table cell, skipping content from nested tables
Definition: frmtool.cxx:3918
void AppendObj(SwFrame *const pFrame, SwPageFrame *const pPage, SwFrameFormat *const pFormat, const SwFormatAnchor &rAnch)
Definition: frmtool.cxx:1006
bool ConsiderForTextWrap() const
bool IsEmpty() const
Definition: txtfrm.hxx:521
SwFootnoteFrame * FindFootnoteFrame()
Definition: frame.hxx:1104
bool IsContentNode() const
Definition: node.hxx:629
bool FrameContainsNode(SwContentFrame const &rFrame, sal_uLong nNodeIndex)
Definition: txtfrm.cxx:288
SwTextNode const * GetTextNodeForParaProps() const
Definition: txtfrm.cxx:1305
const editeng::SvxBorderLine * GetTop() const
SwFrame * FindLastContentOrTable()
Definition: tabfrm.cxx:3483
Style of a layout element.
Definition: frmfmt.hxx:58
PrepareHint
Definition: swtypes.hxx:194
SwTabFrame * FindMaster(bool bFirstMaster=false) const
Definition: flowfrm.cxx:774
bool IsContentFrame() const
Definition: frame.hxx:1227
#define SW_MOD()
Definition: swmodule.hxx:256
SwFrame * GetIndPrev() const
Definition: frame.hxx:723
const editeng::SvxBorderLine * GetLeft() const
const SdrObject * GetDrawObj() const
void InvalidatePrt()
Definition: frame.hxx:1033
const SwSortedObjs * GetSortedObjs() const
Definition: pagefrm.hxx:132
const SwFormatAnchor & GetAnchor(bool=true) const
Definition: fmtanchr.hxx:81
int i
Reference< XAnimationNode > Clone(const Reference< XAnimationNode > &xSourceNode, const SdPage *pSource, const SdPage *pTarget)
void MoveAccessibleFrame(const SwFrame *pFrame, const SwRect &rOldFrame)
Definition: viewimp.hxx:288
SwBorderAttrs(const sw::BorderCacheOwner *pOwner, const SwFrame *pConstructor)
Definition: frmtool.cxx:2170
const SwFrame * GetLastLower() const
Definition: findfrm.cxx:1831
uno_Any a
const SwStartNode * StartOfSectionNode() const
Definition: node.hxx:132
SwDoc & GetDoc()
Definition: node.hxx:212
SwPageFrame * InsertNewPage(SwPageDesc &rDesc, SwFrame *pUpper, bool const isRightPage, bool const bFirst, bool bInsertEmpty, bool const bFootnote, SwFrame *pSibling, bool const bVeryFirstPage)
Definition: frmtool.cxx:3070
SwFrameType
Definition: frame.hxx:73
void ClearLRSpaceItemDueToListLevelIndents(std::shared_ptr< SvxLRSpaceItem > &o_rLRSpaceItem) const
Definition: ndtxt.cxx:3267
SwFrame * GetIndNext()
Definition: frame.hxx:726
const SwSectionFrame * GetFollow() const
Definition: sectfrm.hxx:169
SwFrameFormat * GetFormat()
Definition: dcontact.hxx:112
RndStdIds GetAnchorId() const
Definition: fmtanchr.hxx:65
SwEditShell const * GetEditShell() const
Definition: doccorr.cxx:328
void RemoveHiddenObjsOfNode(SwTextNode const &rNode, std::vector< sw::Extent >::const_iterator const *const pIter, std::vector< sw::Extent >::const_iterator const *const pEnd, SwTextNode const *const pFirstNode, SwTextNode const *const pLastNode)
Definition: frmtool.cxx:1177
const SwFormatHoriOrient & GetHoriOrient(bool=true) const
Definition: fmtornt.hxx:108
size_t size() const
Definition: sortedobjs.cxx:43
const SwPosition * GetContentAnchor() const
Definition: fmtanchr.hxx:67
void AddBottom(const tools::Long nAdd)
Definition: swrect.cxx:167
tools::Long CalcLeft(const SwFrame *pCaller) const
Definition: frmtool.cxx:2320
sal_uInt16 m_nTopLine
Definition: frmtool.hxx:335
SwPageFrame * FindPageFrame()
Definition: frame.hxx:679
SwFrame * m_pLower
Definition: layfrm.hxx:53
bool CmpLeftRight(const SwBorderAttrs &rCmpAttrs, const SwFrame *pCaller, const SwFrame *pCmp) const
Definition: frmtool.cxx:2439
sal_uInt16 CalcShadowSpace(SvxShadowItemSide nShadow) const
SwFrameFormat * GetLeftFormat(bool const bFirst=false)
Definition: pagedesc.cxx:383
void AppendDrawObjToPage(SwAnchoredObject &_rNewObj)
Definition: flylay.cxx:1032
SwOrderIter(const SwPageFrame *pPage)
Definition: frmtool.cxx:2635
SwTabFrame * MakeFrame(SwFrame *)
Definition: ndtbl.cxx:2360
const SwFrame * Lower() const
Definition: layfrm.hxx:101
SwContentFrame * FindNextCnt(const bool _bInSameFootnote=false)
Definition: findfrm.cxx:191
TElementType * First()
Definition: calbck.hxx:325
void InvalidatePage(const SwPageFrame *pPage=nullptr) const
Invalidates the page in which the Frame is currently placed.
Definition: wsfrm.cxx:610
tools::Long GetHeight(const SwRect &rRect) const
Definition: frame.hxx:1379
SwSection * GetSection()
Definition: sectfrm.hxx:93
FlyAnchors.
Definition: fmtanchr.hxx:34
bool IsJoinLocked() const
Definition: flowfrm.hxx:175
static void lcl_AddObjsToPage(SwFrame *_pFrame, SwPageFrame *_pPage)
Definition: frmtool.cxx:2920
void SetFollow(SwFlowFrame *const pFollow)
Definition: flowfrm.cxx:92
const SwFrameFormat * GetEmptyPageFormat() const
Definition: doc.hxx:749
tools::Long GetLeft() const
bool IsAction() const
SS for the Lay-/IdleAction and relatives.
Definition: viewimp.hxx:186
const SdrPage * GetPage(sal_uInt16 nPgNum) const
void ActionChanged() const
SwLayoutFrame * GetUpper()
Definition: frame.hxx:677
virtual const SwDrawModel * GetDrawModel() const =0
Draw Model and id accessors.
bool HasArea() const
Definition: swrect.hxx:288
const SvxBoxItem & GetBox() const
Definition: frmtool.hxx:388
bool PosDiff(const SwRect &rRect1, const SwRect &rRect2) const
Definition: frame.hxx:1368
static void lcl_InvalidatePosOfLowers(SwLayoutFrame &_rLayoutFrame)
Definition: frmtool.cxx:442
const SwFrame * mpFrame
Definition: frmtool.hxx:599
SwBorderAttrAccess(SwCache &rCache, const SwFrame *pOwner)
Definition: frmtool.cxx:2616
SvxGraphicPosition
const SwRect & GetObjRectWithSpaces() const
method to determine object area inclusive its spacing
::rtl::Reference< Content > pContent
const SwFormatFooter & GetFooter(bool=true) const
Definition: fmthdft.hxx:99
SwFrameSize GetWidthSizeType() const
Definition: fmtfsize.hxx:83
sal_Int16 GetHoriOrient() const
Definition: fmtornt.hxx:87
void LockJoin()
Definition: flowfrm.hxx:139
bool IsRowFrame() const
Definition: frame.hxx:1219
sal_uInt32 GetOrdNum() const
IDocumentState const & getIDocumentState() const
Definition: doc.cxx:394
SwFlyFrame * ImplFindFlyFrame()
Definition: findfrm.cxx:517
bool ObjAnchoredAtPage() const
Definition: dcontact.hxx:146
css::text::WrapTextMode GetSurround() const
Definition: fmtsrnd.hxx:51
SvxInterLineSpaceRule GetInterLineSpaceRule() const
bool IsRetoucheFrame() const
Definition: frame.hxx:1243
SwFrame * GetPrev()
Definition: frame.hxx:676
SwLayoutFrame * mpUpper
Definition: frame.hxx:336
sal_uInt16 m_nBottom
Definition: frmtool.hxx:335
const SdrObject * m_pCurrent
Definition: frmtool.hxx:439
Marks a node in the document model.
Definition: ndindex.hxx:31
SwRect PrtWithoutHeaderAndFooter() const
Definition: frmtool.cxx:3851
bool IsChanged() const
Definition: calbck.hxx:310
bool IsEndNode() const
Definition: node.hxx:633
SwNodes & GetNodes()
Node is in which nodes-array/doc?
Definition: node.hxx:694
const SvxLineSpacingItem & GetLineSpacing(bool=true) const
Definition: paratr.hxx:192
void AppendObjsOfNode(SwFrameFormats const *const pTable, sal_uLong const nIndex, SwFrame *const pFrame, SwPageFrame *const pPage, SwDoc *const pDoc, std::vector< sw::Extent >::const_iterator const *const pIter, std::vector< sw::Extent >::const_iterator const *const pEnd, SwTextNode const *const pFirstNode, SwTextNode const *const pLastNode)
Definition: frmtool.cxx:1199
Bookkeeping helper for SwCache caching writer borders.
ring_container GetRingContainer()
Definition: ring.hxx:240
bool m_bCachedJoinedWithNext
Definition: frmtool.hxx:329
void MoveFly(SwFlyFrame *pToMove, SwPageFrame *pDest)
Definition: flylay.cxx:937
const SwDoc * GetDoc() const
The document is set in SwAttrPool now, therefore you always can access it.
Definition: format.hxx:123
const IDocumentSettingAccess & getIDocumentSettingAccess() const
Provides access to the document settings interface.
Definition: format.cxx:717
void SSize(const Size &rNew)
Definition: swrect.hxx:178
bool HasFixSize() const
Definition: frame.hxx:669
bool isFrameAreaSizeValid() const
Definition: frame.hxx:166
virtual const SwAnchoredObject * GetAnchoredObj(const SdrObject *_pSdrObj) const =0
bool IsNotifyBack() const
Definition: flyfrm.hxx:224
SwContentNotify(SwContentFrame *pContentFrame)
Definition: frmtool.cxx:760
bool mbBordersJoinedWithPrev
Definition: frmtool.hxx:276
void InvalidatePos_()
Definition: frame.hxx:786
SwTwips CalcRowRstHeight(SwLayoutFrame *pRow)
Definition: frmtool.cxx:3661
A page of the document layout.
Definition: pagefrm.hxx:57
static void lcl_Regist(SwPageFrame *pPage, const SwFrame *pAnch)
Definition: frmtool.cxx:3132
bool mbChkHeightOfLastLine
Definition: frmtool.hxx:271
SwDeletionChecker(const SwFrame *pFrame)
Definition: frmtool.cxx:3944
const SwFrame * FindPage(const SwRect &rRect, const SwFrame *pPage)
Definition: frmtool.cxx:3677
SwTextFrame * MakeTextFrame(SwTextNode &rNode, SwFrame *, sw::FrameMode eMode)
Definition: txtfrm.cxx:800
Frame cannot be moved in Var-direction.
tools::Long SwTwips
Definition: swtypes.hxx:49
void InvalidateWindows(const SwRect &rRect)
Definition: viewsh.cxx:544
void CalcRightLine_()
Definition: frmtool.cxx:2406
enumrange< T >::Iterator end(enumrange< T >)
const long LONG_MAX
sal_uInt16 CalcTop() const
Definition: frmtool.hxx:525
Point Center() const
Definition: swrect.cxx:35
bool IsExtraData(const SwDoc *pDoc)
Definition: frmtool.cxx:3839
< purpose of derivation from SwClient: character style for displaying the numbers.
Definition: lineinfo.hxx:37
SwBorderAttrs * Get()
Definition: frmtool.cxx:2630
bool m_bCacheGetLine
Definition: frmtool.hxx:322
constexpr Point TopLeft() const
void InvalidateSize()
Definition: frame.hxx:1026
SwTwips mnFlyAnchorOfst
Definition: frmtool.hxx:231
bool ShouldRowKeepWithNext(const bool bCheckParents=true) const
Definition: tabfrm.cxx:4875
SwSectionFrame * FindSctFrame()
Definition: frame.hxx:1112
void CalcTop_()
Definition: frmtool.cxx:2234
SwFrame * FindColFrame()
Definition: findfrm.cxx:530
virtual const SwRangeRedline * GetRedline(const SwPosition &rPos, SwRedlineTable::size_type *pFndPos) const =0
bool CalcHiddenFlag() const
Definition: section.cxx:337
void InvalidateAccessibleParaFlowRelation(const SwTextFrame *_pFromTextFrame, const SwTextFrame *_pToTextFrame)
invalidate CONTENT_FLOWS_FROM/_TO relation for paragraphs
Definition: viewsh.cxx:2485
void sw_RemoveFootnotes(SwFootnoteBossFrame *pBoss, bool bPageOnly, bool bEndNotes)
remove all footnotes (not the references) and all footnote pages
Definition: ftnfrm.cxx:908
virtual bool SetFormatAttr(const SfxPoolItem &rAttr)
Definition: format.cxx:450
bool IsOleRef() const
To avoid unnecessary loading of object.
Definition: ndole.cxx:910
static bool lcl_hasTabFrame(const SwTextFrame *pTextFrame)
Tries to detect if this paragraph has a floating table attached.
Definition: frmtool.cxx:2302
sal_uInt16 Which() const
for Querying of Writer-functions.
Definition: format.hxx:82
virtual const tools::Rectangle & GetLastBoundRect() const
bool IsLayoutFrame() const
Definition: frame.hxx:1167
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint)
SwFrameFormat & GetMaster()
Definition: pagedesc.hxx:238
sal_uLong EndOfSectionIndex() const
Definition: node.hxx:678
void Bottom(const tools::Long nBottom)
Definition: swrect.hxx:209
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:79
SwPageFrame * pOldPage
Definition: frmtool.hxx:259
const sw::BroadcastingModify * mpRegIn
Definition: frmtool.hxx:600
IDocumentRedlineAccess const & getIDocumentRedlineAccess() const
Definition: doc.cxx:335
void GetSpacingValuesOfFrame(const SwFrame &rFrame, SwTwips &onLowerSpacing, SwTwips &onLineSpacing, bool &obIsLineSpacingProportional, bool bIdenticalStyles)
method to determine the spacing values of a frame
Definition: frmtool.cxx:3882
const SvxULSpaceItem & GetULSpace(bool=true) const
Definition: frmatr.hxx:46
bool ConsiderObjWrapInfluenceOnObjPos() const
method to determine, if wrapping style influence of the anchored object has to be considered on the o...
SwLayAction & GetLayAction()
Definition: viewimp.hxx:188
bool IsTabFrame() const
Definition: frame.hxx:1215
void GCLines()
Definition: gctable.cxx:454
general base class for all free-flowing frames
Definition: flyfrm.hxx:78
void IsLine_()
Definition: frmtool.cxx:2413
bool IsRightPageByNumber(SwRootFrame const &rLayout, sal_uInt16 nPageNum)
Definition: frmtool.cxx:3059
void CheckKeep()
Definition: flowfrm.cxx:147
sal_Int16 GetRelationOrient() const
Definition: fmtornt.hxx:88
void UnlockJoin()
Definition: flowfrm.hxx:140
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
void RecreateStartTextFrames(SwTextNode &rNode)
Definition: frmtool.cxx:1403
bool IsPaintLineNumbers() const
Definition: lineinfo.hxx:80
static SwTwips lcl_CalcCellRstHeight(SwLayoutFrame *pCell)
Definition: frmtool.cxx:3621
const SvxULSpaceItem & m_rUL
Definition: frmtool.hxx:302
void ColUnlock()
Definition: sectfrm.hxx:96
unsigned char sal_uInt8
SwPageFrame * GetPageFrame()
void InvaPercentLowers(SwTwips nDiff=0)
Invalidates the inner Frames, whose width and/or height are calculated using percentages.
Definition: wsfrm.cxx:3564
const SwViewOption * GetViewOptions() const
Definition: viewsh.hxx:423
static bool FormatObj(SwAnchoredObject &_rAnchoredObj, SwFrame *_pAnchorFrame=nullptr, const SwPageFrame *_pPageFrame=nullptr)
method to format a given floating screen object
const SwFrame * ContainsAny(const bool _bInvestigateFootnoteForSections=false) const
Method doesn't investigate content of footnotes by default.
Definition: findfrm.cxx:126
The Cache object base class Users of the Cache must derive a class from the SwCacheObj and store thei...
Definition: swcache.hxx:134
void NotifyLowerObjs(const bool _bUnlockPosOfObjs=false)
force an unlockposition call for the lower objects.
Definition: fly.cxx:2412
void InvalidateAll_()
Definition: frame.hxx:802
SwFrameFormat & GetFirstLeft()
Definition: pagedesc.hxx:241
void InsertBehind(SwLayoutFrame *pParent, SwFrame *pBefore)
Insert SwFrame into existing structure.
Definition: wsfrm.cxx:869
virtual const SwAnchoredObject * GetAnchoredObj(const SdrObject *_pSdrObj) const override
Definition: dcontact.cxx:762
bool bSetCompletePaintOnInvalidate
Definition: frmtool.cxx:101
sal_uInt16 CalcBottom() const
Definition: frmtool.hxx:531
#define SAL_INFO(area, stream)
sal_uInt16 m_nBottomLine
Definition: frmtool.hxx:335
void GetBottomLine_(const SwFrame &_rFrame)
Definition: frmtool.cxx:2579
bool IsInside(const Point &rPOINT) const
Definition: swrect.cxx:105
SwFrameFormat * GetRightFormat(bool const bFirst=false)
Layout uses the following methods to obtain a format in order to be able to create a page...
Definition: pagedesc.cxx:390
void CalcLeftLine_()
Definition: frmtool.cxx:2399
bool IsNoTextFrame() const
Definition: frame.hxx:1235
void RemoveFromLayout()
Definition: wsfrm.cxx:1010
SwTwips GetHeightOfLastLine() const
Definition: txtfrm.hxx:767
virtual void MakeFrames()
Creates the views.
Definition: atrfrm.cxx:2744
bool IsFlyFreeFrame() const
Definition: flyfrm.hxx:216
IDocumentSettingAccess const & getIDocumentSettingAccess() const
Definition: doc.cxx:176
const SwFootnoteFrame * GetFollow() const
Definition: ftnfrm.hxx:116
SwNodes & GetNodes()
Definition: doc.hxx:409
const SwDoc * GetDoc() const
Definition: swatrset.hxx:197
bool IsAnchoredObjShown(SwTextFrame const &rFrame, SwFormatAnchor const &rAnchor)
Definition: frmtool.cxx:1297
new class for re-direct methods calls at a 'virtual' drawing object to its referenced object...
Definition: dcontact.hxx:212
bool JoinedWithNext(const SwFrame &_rFrame) const
Definition: frmtool.cxx:2550
void InvalidateNextPos(bool bNoFootnote=false)
Definition: frame.hxx:1069
bool IsRightToLeft() const
Definition: frame.hxx:984
::sw::DocumentSettingManager & GetDocumentSettingManager()
Definition: doc.cxx:186
bool mbInvalidatePrevPrtArea
Definition: frmtool.hxx:275
void Top(const tools::Long nTop)
Definition: swrect.hxx:204
static void lcl_NotifyContent(const SdrObject *pThis, SwContentFrame *pCnt, const SwRect &rRect, const PrepareHint eHint)
Definition: frmtool.cxx:3298
bool IsAgain() const
Definition: layact.hxx:167
bool HasBeenDeleted() const
return true if mpFrame != 0 and mpFrame is not client of pRegIn false otherwise
Definition: frmtool.cxx:3956
SwFlyFrame * GetNextLink() const
Definition: flyfrm.hxx:195
SwFrame * GetLower()
Definition: findfrm.cxx:170
bool Is_Lower_Of(const SwFrame *pCurrFrame, const SdrObject *pObj)
Definition: frmtool.cxx:3548
bool ObjAnchoredAtFly() const
Definition: dcontact.hxx:147
bool IsPageFrame() const
Definition: frame.hxx:1175
bool ObjAnchoredAsChar() const
Definition: dcontact.hxx:150
void Notify(SwFlyFrame *pFly, SwPageFrame *pOld, const SwRect &rOld, const SwRect *pOldPrt)
Notify the background based on the difference between old and new rectangle.
Definition: frmtool.cxx:3191
static bool CmpLines(const editeng::SvxBorderLine *pL1, const editeng::SvxBorderLine *pL2)
Definition: frmtool.cxx:2430
const SwFrame * FindContext(const SwFrame *pFrame, SwFrameType nAdditionalContextType)
provides the area of a frame in that no Fly from another area can overlap
Definition: frmtool.cxx:3580
constexpr TypedWhichId< SvxLRSpaceItem > RES_LR_SPACE(91)
void AppendAllObjs(const SwFrameFormats *pTable, const SwFrame *pSib)
Definition: frmtool.cxx:1349
sal_Int16 GetVertOrient() const
Definition: fmtornt.hxx:54
void SetPos(SwRect &rRect, const Point &rNew) const
Definition: frame.hxx:1417
void AppendFlyToPage(SwFlyFrame *pNew)
Definition: flylay.cxx:792
bool IsHideRedlines() const
Replacement for sw::DocumentRedlineManager::GetRedlineFlags() (this is layout-level redline hiding)...
Definition: rootfrm.hxx:422
bool m_bBottomLine
Definition: frmtool.hxx:312
void PreparePage(bool bFootnote)
Always call after Paste Creates the page-bound frames and formats the generic content.
Definition: pagechg.cxx:467
virtual bool get(DocumentSettingId id) const =0
Return the specified document setting.
virtual bool IsNewDoc() const =0
#define FAR_AWAY
Definition: frmtool.hxx:53
const SwFormatFrameSize & GetFrameSize(bool=true) const
Definition: fmtfsize.hxx:104
sal_uInt16 CalcLineSpace(SvxBoxItemLine nLine, bool bEvenIfNoLine=false) const
void AppendDrawObj(SwAnchoredObject &_rNewObj)
Definition: fly.cxx:2238
void SetOLESizeInvalid(bool b)
Definition: ndole.hxx:134
static void AssertPageFlys(SwPageFrame *)
Makes sure that, starting from the passed Page, all page-bound Frames are on the right Page (pagenumb...
Definition: pagechg.cxx:1680
bool IsOLESizeInvalid() const
Definition: ndole.hxx:133
bool CompareLayout(const SwDoc &rDoc) const
Definition: laycache.cxx:325
void DelFrameFormat(SwFrameFormat *pFormat, bool bBroadcast=false)
Definition: docfmt.cxx:686
bool IsAccessibleFrame() const
Definition: frame.hxx:1247
void InvalidatePrt_()
Definition: frame.hxx:778
virtual void NotifyBackground(SwPageFrame *_pPageFrame, const SwRect &_rRect, PrepareHint _eHint)=0
method to trigger notification of 'background'
bool m_bIsLine
Definition: frmtool.hxx:320
#define SAL_WARN(area, stream)
SwDoc & GetDoc()
Definition: txtfrm.hxx:460
bool IsTableNode() const
Definition: node.hxx:641
virtual SdrObject * SetObjectOrdNum(size_t nOldObjNum, size_t nNewObjNum)
Access class for the Cache.
Definition: swcache.hxx:195
size_t size() const
SwContentFrame * FindPrevCnt()
Definition: findfrm.cxx:175
bool HasMergedParas() const
Definition: rootfrm.hxx:426
virtual void Paste(SwFrame *pParent, SwFrame *pSibling=nullptr) override
Definition: pagechg.cxx:899
A layout frame is a frame that contains other frames (m_pLower), e.g. SwPageFrame or SwTabFrame...
Definition: layfrm.hxx:35
SwFrame * SaveContent(SwLayoutFrame *pLay, SwFrame *pStart)
Definition: frmtool.cxx:2807
bool IsFirstShared() const
Definition: pagedesc.cxx:397
void MakeFrames(SwDoc *pDoc, const SwNodeIndex &rSttIdx, const SwNodeIndex &rEndIdx)
Definition: frmtool.cxx:1965
void MergeNext(SwSectionFrame *pNxt)
|* Merges two SectionFrames, in case it's about the same section.
Definition: sectfrm.cxx:466
const SwFrame * GetAnchorFrame() const
const SwLayoutFrame * GetNextLayoutLeaf() const
Definition: frame.hxx:1017
void ColUnlock()
Definition: ftnfrm.hxx:137
static bool IsShown(sal_uLong const nIndex, const SwFormatAnchor &rAnch, std::vector< sw::Extent >::const_iterator const *const pIter, std::vector< sw::Extent >::const_iterator const *const pEnd, SwTextNode const *const pFirstNode, SwTextNode const *const pLastNode)
Definition: frmtool.cxx:1070
TableFormulaUpdateFlags m_eFlags
Definition: hints.hxx:268
void RegistFlys(SwPageFrame *pPage, const SwLayoutFrame *pLay)
Definition: frmtool.cxx:3175
virtual const SwRedlineTable & GetRedlineTable() const =0
bool m_bCachedGetTopLine
Definition: frmtool.hxx:323
bool IsOver(const SwRect &rRect) const
Definition: swrect.cxx:123
const SwContentFrame * ContainsContent() const
Checks if the frame contains one or more ContentFrame's anywhere in his subsidiary structure; if so t...
Definition: findfrm.cxx:67
const SwFlowFrame * GetFollow() const
Definition: flowfrm.hxx:168
SwViewShell * GetCurrShell() const
Definition: rootfrm.hxx:207
class for collecting anchored objects
Definition: sortedobjs.hxx:48
bool IsTextNode() const
Definition: node.hxx:637
sal_uInt16 m_nGetBottomLine
Definition: frmtool.hxx:335
void SetRestartLayoutProcess(const bool _bRestartLayoutProcess)
void Height(tools::Long nNew)
Definition: swrect.hxx:191
Merge GetRedlineMergeFlag() const
Definition: node.hxx:98
const editeng::SvxBorderLine * GetBottom() const
virtual ~SwBorderAttrs() override
Definition: frmtool.cxx:2224
SwNode * FindPrvNxtFrameNode(SwNodeIndex &rFrameIdx, const SwNode *pEnd) const
Search previous / next content node or table node with frames.
Definition: nodes.cxx:2035
SdrObject * FindSdrObject()
Definition: frmfmt.hxx:138
sal_uInt16 m_nTop
Definition: frmtool.hxx:335
void ResetNotifyBack()
Definition: flyfrm.hxx:226
bool IsFooterFrame() const
Definition: frame.hxx:1191
sal_uInt16 m_nGetTopLine
Definition: frmtool.hxx:335
SwRootFrame * getRootFrame()
Definition: frame.hxx:678
bool GetContext() const
bool IsCallbackActionEnabled() const
Definition: rootfrm.hxx:388
bool IsAutoPos() const
Definition: flyfrm.hxx:214
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
Definition: ndtxt.hxx:850
const SdrObject * Bottom()
Definition: frmtool.cxx:2667
IDocumentTimerAccess const & getIDocumentTimerAccess() const
Definition: doc.cxx:249
SwRowFrame is one table row in the document layout.
Definition: rowfrm.hxx:28
sal_uInt16 GetUpper() const
bool IsHeaderFrame() const
Definition: frame.hxx:1187
const IDocumentDrawModelAccess & getIDocumentDrawModelAccess() const
Provides access to the document draw model interface.
Definition: format.cxx:718
bool IsCreateFrameWhenHidingRedlines() const
Definition: node.hxx:94
void SetAnchor(const SwPosition *pPos)
Definition: atrfrm.cxx:1583
virtual const SwFrameFormat * GetFormat() const
Definition: ssfrm.cxx:395
bool m_bCachedJoinedWithPrev
Definition: frmtool.hxx:328
SwTabFrame * FindTabFrame()
Definition: frame.hxx:1096
sal_uInt16 CalcRightLine() const
Definition: frmtool.hxx:519
static sal_uInt8 s_nCnt
Definition: frmtool.hxx:454
void CalcBottom_()
Definition: frmtool.cxx:2252
SwFrame * GetNext()
Definition: frame.hxx:675
const SvxLRSpaceItem & GetLRSpace(bool=true) const
Definition: frmatr.hxx:74
virtual void BlockIdling()=0
Increment block count.
Base class of the Writer document model elements.
Definition: node.hxx:80
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo