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