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