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