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