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