LibreOffice Module sw (master)  1
objectformattertxtfrm.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 
21 #include <sortedobjs.hxx>
22 #include <rootfrm.hxx>
23 #include <flyfrms.hxx>
24 #include <txtfrm.hxx>
25 #include <pagefrm.hxx>
26 #include <rowfrm.hxx>
27 #include <layouter.hxx>
28 #include <fmtanchr.hxx>
30 #include <fmtfollowtextflow.hxx>
31 #include <layact.hxx>
32 #include <ftnfrm.hxx>
33 
34 using namespace ::com::sun::star;
35 
36 // little helper class to forbid follow formatting for the given text frame
38 {
39 private:
42 
43 public:
44  explicit SwForbidFollowFormat( SwTextFrame& _rTextFrame )
45  : mrTextFrame( _rTextFrame ),
46  bOldFollowFormatAllowed( _rTextFrame.FollowFormatAllowed() )
47  {
48  mrTextFrame.ForbidFollowFormat();
49  }
50 
52  {
53  if ( bOldFollowFormatAllowed )
54  {
55  mrTextFrame.AllowFollowFormat();
56  }
57  }
58 };
59 
61  const SwPageFrame& _rPageFrame,
62  SwTextFrame* _pMasterAnchorTextFrame,
63  SwLayAction* _pLayAction )
64  : SwObjectFormatter( _rPageFrame, _pLayAction, true ),
65  mrAnchorTextFrame( _rAnchorTextFrame ),
66  mpMasterAnchorTextFrame( _pMasterAnchorTextFrame )
67 {
68 }
69 
71 {
72 }
73 
74 std::unique_ptr<SwObjectFormatterTextFrame> SwObjectFormatterTextFrame::CreateObjFormatter(
75  SwTextFrame& _rAnchorTextFrame,
76  const SwPageFrame& _rPageFrame,
77  SwLayAction* _pLayAction )
78 {
79  std::unique_ptr<SwObjectFormatterTextFrame> pObjFormatter;
80 
81  // determine 'master' of <_rAnchorTextFrame>, if anchor frame is a follow text frame.
82  SwTextFrame* pMasterOfAnchorFrame = nullptr;
83  if ( _rAnchorTextFrame.IsFollow() )
84  {
85  pMasterOfAnchorFrame = _rAnchorTextFrame.FindMaster();
86  while ( pMasterOfAnchorFrame && pMasterOfAnchorFrame->IsFollow() )
87  {
88  pMasterOfAnchorFrame = pMasterOfAnchorFrame->FindMaster();
89  }
90  }
91 
92  // create object formatter, if floating screen objects are registered
93  // at anchor frame (or at 'master' anchor frame)
94  if ( _rAnchorTextFrame.GetDrawObjs() ||
95  ( pMasterOfAnchorFrame && pMasterOfAnchorFrame->GetDrawObjs() ) )
96  {
97  pObjFormatter.reset(
98  new SwObjectFormatterTextFrame( _rAnchorTextFrame, _rPageFrame,
99  pMasterOfAnchorFrame, _pLayAction ));
100  }
101 
102  return pObjFormatter;
103 }
104 
106 {
107  return mrAnchorTextFrame;
108 }
109 
110 // #i40147# - add parameter <_bCheckForMovedFwd>.
112  const bool _bCheckForMovedFwd )
113 {
114  // consider, if the layout action has to be
115  // restarted due to a delete of a page frame.
116  if ( GetLayAction() && GetLayAction()->IsAgain() )
117  {
118  return false;
119  }
120 
121  bool bSuccess( true );
122 
123  if ( _rAnchoredObj.IsFormatPossible() )
124  {
125  _rAnchoredObj.SetRestartLayoutProcess( false );
126 
127  FormatObj_( _rAnchoredObj );
128  // consider, if the layout action has to be
129  // restarted due to a delete of a page frame.
130  if ( GetLayAction() && GetLayAction()->IsAgain() )
131  {
132  return false;
133  }
134 
135  // check, if layout process has to be restarted.
136  // if yes, perform needed invalidations.
137 
138  // no restart of layout process,
139  // if anchored object is anchored inside a Writer fly frame,
140  // its position is already locked, and it follows the text flow.
141  const bool bRestart =
142  _rAnchoredObj.RestartLayoutProcess() &&
143  !( _rAnchoredObj.PositionLocked() &&
144  _rAnchoredObj.GetAnchorFrame()->IsInFly() &&
145  _rAnchoredObj.GetFrameFormat().GetFollowTextFlow().GetValue() );
146  if ( bRestart )
147  {
148  bSuccess = false;
149  InvalidatePrevObjs( _rAnchoredObj );
150  InvalidateFollowObjs( _rAnchoredObj );
151  }
152 
153  // format anchor text frame, if wrapping style influence of the object
154  // has to be considered and it's <NONE_SUCCESSIVE_POSITIONED>
155  // #i3317# - consider also anchored objects, whose
156  // wrapping style influence is temporarily considered.
157  // #i40147# - consider also anchored objects, for
158  // whose the check of a moved forward anchor frame is requested.
159  // revise decision made for i3317:
160  // anchored objects, whose wrapping style influence is temporarily considered,
161  // have to be considered in method <SwObjectFormatterTextFrame::DoFormatObjs()>
162  if ( bSuccess &&
163  _rAnchoredObj.ConsiderObjWrapInfluenceOnObjPos() &&
164  ( _bCheckForMovedFwd ||
165  _rAnchoredObj.GetFrameFormat().GetWrapInfluenceOnObjPos().
166  // #i35017# - handle ITERATIVE as ONCE_SUCCESSIVE
167  GetWrapInfluenceOnObjPos( true ) ==
168  // #i35017# - constant name has changed
169  text::WrapInfluenceOnPosition::ONCE_SUCCESSIVE ) )
170  {
171  // #i26945# - check conditions for move forward of
172  // anchor text frame
173  // determine, if anchor text frame has previous frame
174  const bool bDoesAnchorHadPrev = ( mrAnchorTextFrame.GetIndPrev() != nullptr );
175 
176  // #i40141# - use new method - it also formats the
177  // section the anchor frame is in.
179 
180  // #i35911#
181  if ( _rAnchoredObj.HasClearedEnvironment() )
182  {
183  _rAnchoredObj.SetClearedEnvironment( true );
184  // #i44049# - consider, that anchor frame
185  // could already been marked to move forward.
186  SwPageFrame* pAnchorPageFrame( mrAnchorTextFrame.FindPageFrame() );
187  if ( pAnchorPageFrame != _rAnchoredObj.GetPageFrame() )
188  {
189  bool bInsert( true );
190  sal_uInt32 nToPageNum( 0 );
191  const SwDoc& rDoc = *(GetPageFrame().GetFormat()->GetDoc());
193  rDoc, mrAnchorTextFrame, nToPageNum ) )
194  {
195  if ( nToPageNum < pAnchorPageFrame->GetPhyPageNum() )
197  else
198  bInsert = false;
199  }
200  if ( bInsert )
201  {
203  pAnchorPageFrame->GetPhyPageNum() );
205  bSuccess = false;
206  InvalidatePrevObjs( _rAnchoredObj );
207  InvalidateFollowObjs( _rAnchoredObj );
208  }
209  else
210  {
211  OSL_FAIL( "<SwObjectFormatterTextFrame::DoFormatObj(..)> - anchor frame not marked to move forward" );
212  }
213  }
214  }
215  else if ( !mrAnchorTextFrame.IsFollow() && bDoesAnchorHadPrev )
216  {
217  // index of anchored object in collection of page numbers and
218  // anchor types
219  sal_uInt32 nIdx( CountOfCollected() );
220  OSL_ENSURE( nIdx > 0,
221  "<SwObjectFormatterTextFrame::DoFormatObj(..)> - anchored object not collected!?" );
222  --nIdx;
223 
224  sal_uInt32 nToPageNum( 0 );
225  // #i43913#
226  bool bDummy( false );
227  // #i58182# - consider new method signature
229  GetPgNumOfCollected( nIdx ),
231  nToPageNum, bDummy ) )
232  {
233  // #i49987# - consider, that anchor frame
234  // could already been marked to move forward.
235  bool bInsert( true );
236  sal_uInt32 nMovedFwdToPageNum( 0 );
237  const SwDoc& rDoc = *(GetPageFrame().GetFormat()->GetDoc());
239  rDoc, mrAnchorTextFrame, nMovedFwdToPageNum ) )
240  {
241  if ( nMovedFwdToPageNum < nToPageNum )
243  else
244  bInsert = false;
245  }
246  if ( bInsert )
247  {
248  // Indicate that anchor text frame has to move forward and
249  // invalidate its position to force a re-format.
251  nToPageNum );
253 
254  // Indicate restart of the layout process
255  bSuccess = false;
256 
257  // If needed, invalidate previous objects anchored at same anchor
258  // text frame.
259  InvalidatePrevObjs( _rAnchoredObj );
260 
261  // Invalidate object and following objects for the restart of the
262  // layout process
263  InvalidateFollowObjs( _rAnchoredObj );
264  }
265  else
266  {
267  OSL_FAIL( "<SwObjectFormatterTextFrame::DoFormatObj(..)> - anchor frame not marked to move forward" );
268  }
269  }
270  }
271  // i40155# - mark anchor frame not to wrap around
272  // objects under the condition, that its follow contains all its text.
273  else if ( !mrAnchorTextFrame.IsFollow() &&
276  {
280  }
281  }
282  }
283 
284  return bSuccess;
285 }
286 
288 {
290  {
291  if ( GetLayAction() &&
293  {
294  // notify layout action, thus is can restart the layout process on
295  // a previous page.
296  GetLayAction()->SetAgain();
297  }
298  else
299  {
300  // the anchor text frame has to be valid, thus assert.
301  OSL_FAIL( "<SwObjectFormatterTextFrame::DoFormatObjs()> called for invalidate anchor text frame." );
302  }
303 
304  return false;
305  }
306 
307  bool bSuccess( true );
308 
309  if ( mrAnchorTextFrame.IsFollow() )
310  {
311  // Only floating screen objects anchored as-character are directly
312  // registered at a follow text frame. The other floating screen objects
313  // are registered at the 'master' anchor text frame.
314  // Thus, format the other floating screen objects through the 'master'
315  // anchor text frame
316  OSL_ENSURE( mpMasterAnchorTextFrame,
317  "SwObjectFormatterTextFrame::DoFormatObjs() - missing 'master' anchor text frame" );
319 
320  if ( bSuccess )
321  {
322  // format of as-character anchored floating screen objects - no failure
323  // excepted on the format of these objects.
324  bSuccess = FormatObjsAtFrame_();
325  }
326  }
327  else
328  {
329  bSuccess = FormatObjsAtFrame_();
330  }
331 
332  // consider anchored objects, whose wrapping style influence are temporarily
333  // considered.
334  if ( bSuccess &&
335  ( ConsiderWrapOnObjPos() ||
338  {
339  const bool bDoesAnchorHadPrev = ( mrAnchorTextFrame.GetIndPrev() != nullptr );
340 
341  // Format anchor text frame after its objects are formatted.
342  // Note: The format of the anchor frame also formats the invalid
343  // previous frames of the anchor frame. The format of the previous
344  // frames is needed to get a correct result of format of the
345  // anchor frame for the following check for moved forward anchors
346  // #i40141# - use new method - it also formats the
347  // section the anchor frame is in.
349 
350  sal_uInt32 nToPageNum( 0 );
351  // #i43913#
352  bool bInFollow( false );
353  SwAnchoredObject* pObj = nullptr;
354  if ( !mrAnchorTextFrame.IsFollow() )
355  {
357  // #i35017# - constant name has changed
358  text::WrapInfluenceOnPosition::ONCE_CONCURRENT,
359  nToPageNum, bInFollow );
360  }
361  // #i35911#
362  if ( pObj && pObj->HasClearedEnvironment() )
363  {
364  pObj->SetClearedEnvironment( true );
365  // #i44049# - consider, that anchor frame
366  // could already been marked to move forward.
367  SwPageFrame* pAnchorPageFrame( mrAnchorTextFrame.FindPageFrame() );
368  // #i43913# - consider, that anchor frame
369  // is a follow or is in a follow row, which will move forward.
370  if ( pAnchorPageFrame != pObj->GetPageFrame() ||
371  bInFollow )
372  {
373  bool bInsert( true );
374  sal_uInt32 nTmpToPageNum( 0 );
375  const SwDoc& rDoc = *(GetPageFrame().GetFormat()->GetDoc());
377  rDoc, mrAnchorTextFrame, nTmpToPageNum ) )
378  {
379  if ( nTmpToPageNum < pAnchorPageFrame->GetPhyPageNum() )
381  else
382  bInsert = false;
383  }
384  if ( bInsert )
385  {
387  pAnchorPageFrame->GetPhyPageNum() );
389  bSuccess = false;
390  InvalidatePrevObjs( *pObj );
391  InvalidateFollowObjs( *pObj );
392  }
393  else
394  {
395  OSL_FAIL( "<SwObjectFormatterTextFrame::DoFormatObjs(..)> - anchor frame not marked to move forward" );
396  }
397  }
398  }
399  else if ( pObj && bDoesAnchorHadPrev )
400  {
401  // Object found, whose anchor is moved forward
402 
403  // #i49987# - consider, that anchor frame
404  // could already been marked to move forward.
405  bool bInsert( true );
406  sal_uInt32 nMovedFwdToPageNum( 0 );
407  const SwDoc& rDoc = *(GetPageFrame().GetFormat()->GetDoc());
409  rDoc, mrAnchorTextFrame, nMovedFwdToPageNum ) )
410  {
411  if ( nMovedFwdToPageNum < nToPageNum )
413  else
414  bInsert = false;
415  }
416  if ( bInsert )
417  {
418  // Indicate that anchor text frame has to move forward and
419  // invalidate its position to force a re-format.
422 
423  // Indicate restart of the layout process
424  bSuccess = false;
425 
426  // If needed, invalidate previous objects anchored at same anchor
427  // text frame.
428  InvalidatePrevObjs( *pObj );
429 
430  // Invalidate object and following objects for the restart of the
431  // layout process
432  InvalidateFollowObjs( *pObj );
433  }
434  else
435  {
436  OSL_FAIL( "<SwObjectFormatterTextFrame::DoFormatObjs(..)> - anchor frame not marked to move forward" );
437  }
438  }
439  // #i40155# - mark anchor frame not to wrap around
440  // objects under the condition, that its follow contains all its text.
441  else if ( !mrAnchorTextFrame.IsFollow() &&
444  {
448  }
449  }
450 
451  return bSuccess;
452 }
453 
455 {
456  // invalidate all previous objects, whose wrapping influence on the object
457  // positioning is <NONE_CONCURRENT_POSITIONED>.
458  // Note: list of objects at anchor frame is sorted by this property.
459  if ( _rAnchoredObj.GetFrameFormat().GetWrapInfluenceOnObjPos().
460  // #i35017# - handle ITERATIVE as ONCE_SUCCESSIVE
461  GetWrapInfluenceOnObjPos( true ) ==
462  // #i35017# - constant name has changed
463  text::WrapInfluenceOnPosition::ONCE_CONCURRENT )
464  {
465  const SwSortedObjs* pObjs = GetAnchorFrame().GetDrawObjs();
466  if ( pObjs )
467  {
468  // determine start index
469  size_t i = pObjs->ListPosOf( _rAnchoredObj );
470  while (i > 0)
471  {
472  --i;
473  SwAnchoredObject* pAnchoredObj = (*pObjs)[i];
474  if ( pAnchoredObj->GetFrameFormat().GetWrapInfluenceOnObjPos().
475  // #i35017# - handle ITERATIVE as ONCE_SUCCESSIVE
476  GetWrapInfluenceOnObjPos( true ) ==
477  // #i35017# - constant name has changed
478  text::WrapInfluenceOnPosition::ONCE_CONCURRENT )
479  {
481  }
482  }
483  }
484  }
485 }
486 
488 {
490 
491  const SwSortedObjs* pObjs = GetPageFrame().GetSortedObjs();
492  if ( pObjs )
493  {
494  // determine start index
495  for ( size_t i = pObjs->ListPosOf( _rAnchoredObj ) + 1; i < pObjs->size(); ++i )
496  {
497  SwAnchoredObject* pAnchoredObj = (*pObjs)[i];
499  }
500  }
501 }
502 
504  const sal_Int16 _nWrapInfluenceOnPosition,
505  sal_uInt32& _noToPageNum,
506  bool& _boInFollow )
507 {
508  // #i35017# - constant names have changed
509  OSL_ENSURE( _nWrapInfluenceOnPosition == text::WrapInfluenceOnPosition::ONCE_SUCCESSIVE ||
510  _nWrapInfluenceOnPosition == text::WrapInfluenceOnPosition::ONCE_CONCURRENT,
511  "<SwObjectFormatterTextFrame::GetFirstObjWithMovedFwdAnchor(..)> - invalid value for parameter <_nWrapInfluenceOnPosition>" );
512 
513  SwAnchoredObject* pRetAnchoredObj = nullptr;
514 
515  sal_uInt32 i = 0;
516  for ( ; i < CountOfCollected(); ++i )
517  {
518  SwAnchoredObject* pAnchoredObj = GetCollectedObj(i);
519  if ( pAnchoredObj->ConsiderObjWrapInfluenceOnObjPos() &&
520  pAnchoredObj->GetFrameFormat().GetWrapInfluenceOnObjPos().
521  // #i35017# - handle ITERATIVE as ONCE_SUCCESSIVE
522  GetWrapInfluenceOnObjPos( true ) == _nWrapInfluenceOnPosition )
523  {
524  // #i26945# - use new method <_CheckMovedFwdCondition(..)>
525  // #i43913#
526  // #i58182# - consider new method signature
528  GetPgNumOfCollected( i ),
530  _noToPageNum, _boInFollow ) )
531  {
532  pRetAnchoredObj = pAnchoredObj;
533  break;
534  }
535  }
536  }
537 
538  return pRetAnchoredObj;
539 }
540 
541 // #i58182#
542 // - replace private method by corresponding static public method
544  SwAnchoredObject& _rAnchoredObj,
545  const sal_uInt32 _nFromPageNum,
546  const bool _bAnchoredAtMasterBeforeFormatAnchor,
547  sal_uInt32& _noToPageNum,
548  bool& _boInFollow )
549 {
550  bool bAnchorIsMovedForward( false );
551 
552  SwPageFrame* pPageFrameOfAnchor = _rAnchoredObj.FindPageFrameOfAnchor();
553  if ( pPageFrameOfAnchor )
554  {
555  const sal_uInt32 nPageNum = pPageFrameOfAnchor->GetPhyPageNum();
556  if ( nPageNum > _nFromPageNum )
557  {
558  _noToPageNum = nPageNum;
559  // Handling of special case:
560  // If anchor frame is move forward into a follow flow row,
561  // <_noToPageNum> is set to <_nFromPageNum + 1>, because it is
562  // possible that the anchor page frame isn't valid, because the
563  // page distance between master row and follow flow row is greater
564  // than 1.
565  if ( _noToPageNum > (_nFromPageNum + 1) )
566  {
567  SwFrame* pAnchorFrame = _rAnchoredObj.GetAnchorFrameContainingAnchPos();
568  if ( pAnchorFrame->IsInTab() &&
569  pAnchorFrame->IsInFollowFlowRow() )
570  {
571  _noToPageNum = _nFromPageNum + 1;
572  }
573  }
574  bAnchorIsMovedForward = true;
575  }
576  }
577  // #i26945# - check, if an at-paragraph|at-character
578  // anchored object is now anchored at a follow text frame, which will be
579  // on the next page. Also check, if an at-character anchored object
580  // is now anchored at a text frame, which is in a follow flow row,
581  // which will be on the next page.
582  if ( !bAnchorIsMovedForward &&
583  _bAnchoredAtMasterBeforeFormatAnchor &&
584  ((_rAnchoredObj.GetFrameFormat().GetAnchor().GetAnchorId() == RndStdIds::FLY_AT_CHAR) ||
585  (_rAnchoredObj.GetFrameFormat().GetAnchor().GetAnchorId() == RndStdIds::FLY_AT_PARA)))
586  {
587  SwFrame* pAnchorFrame = _rAnchoredObj.GetAnchorFrameContainingAnchPos();
588  OSL_ENSURE( pAnchorFrame->IsTextFrame(),
589  "<SwObjectFormatterTextFrame::CheckMovedFwdCondition(..) - wrong type of anchor frame>" );
590  SwTextFrame* pAnchorTextFrame = static_cast<SwTextFrame*>(pAnchorFrame);
591  bool bCheck( false );
592  if ( pAnchorTextFrame->IsFollow() )
593  {
594  bCheck = true;
595  }
596  else if( pAnchorTextFrame->IsInTab() )
597  {
598  const SwRowFrame* pMasterRow = pAnchorTextFrame->IsInFollowFlowRow();
599  if ( pMasterRow &&
600  pMasterRow->FindPageFrame() == pPageFrameOfAnchor )
601  {
602  bCheck = true;
603  }
604  }
605  if ( bCheck )
606  {
607  // check, if found text frame will be on the next page
608  // by checking, if it's in a column, which has no next.
609  SwFrame* pColFrame = pAnchorTextFrame->FindColFrame();
610  while ( pColFrame && !pColFrame->GetNext() )
611  {
612  pColFrame = pColFrame->FindColFrame();
613  }
614  if ( !pColFrame || !pColFrame->GetNext() )
615  {
616  _noToPageNum = _nFromPageNum + 1;
617  bAnchorIsMovedForward = true;
618  // #i43913#
619  _boInFollow = true;
620  }
621  }
622  }
623 
624  return bAnchorIsMovedForward;
625 }
626 
627 // #i40140# - helper method to format layout frames used by
628 // method <SwObjectFormatterTextFrame::FormatAnchorFrameForCheckMoveFwd()>
629 // #i44049# - format till a certain lower frame, if provided.
631  SwFrame* pLastLowerFrame = nullptr )
632 {
633  SwFrame* pLowerFrame = pLayFrame->GetLower();
634  while ( pLowerFrame )
635  {
636  // #i44049#
637  if ( pLastLowerFrame && pLowerFrame == pLastLowerFrame )
638  {
639  break;
640  }
641  if ( pLowerFrame->IsLayoutFrame() )
642  {
643  SwFrameDeleteGuard aCrudeHack(pLowerFrame); // ??? any issue setting this for non-footnote frames?
644  lcl_FormatContentOfLayoutFrame( static_cast<SwLayoutFrame*>(pLowerFrame),
645  pLastLowerFrame );
646  }
647  else
648  pLowerFrame->Calc(pLowerFrame->getRootFrame()->GetCurrShell()->GetOut());
649 
650  // Calc on a SwTextFrame in a footnote can move it to the next page -
651  // deletion of the SwFootnoteFrame was disabled with SwFrameDeleteGuard
652  // but now we have to clean up empty footnote frames to prevent crashes.
653  // Note: check it at this level, not lower: both container and footnote
654  // can be deleted at the same time!
655  SwFrame *const pNext = pLowerFrame->GetNext();
656  if (pLowerFrame->IsFootnoteContFrame())
657  {
658  for (SwFrame * pFootnote = pLowerFrame->GetLower(); pFootnote; )
659  {
660  assert(pFootnote->IsFootnoteFrame());
661  SwFrame *const pNextNote = pFootnote->GetNext();
662  if (!pFootnote->IsDeleteForbidden() && !pFootnote->GetLower() && !pFootnote->IsColLocked() &&
663  !static_cast<SwFootnoteFrame*>(pFootnote)->IsBackMoveLocked())
664  {
665  pFootnote->Cut();
666  SwFrame::DestroyFrame(pFootnote);
667  }
668  pFootnote = pNextNote;
669  }
670  }
671  pLowerFrame = pNext;
672  }
673 }
674 
684 {
685  // #i47014# - no format of section and previous columns
686  // for follow text frames.
687  if ( !_rAnchorTextFrame.IsFollow() )
688  {
689  // if anchor frame is directly inside a section, format this section and
690  // its previous frames.
691  // Note: It's a very simple format without formatting objects.
692  if ( _rAnchorTextFrame.IsInSct() )
693  {
694  SwFrame* pSectFrame = _rAnchorTextFrame.GetUpper();
695  while ( pSectFrame )
696  {
697  if ( pSectFrame->IsSctFrame() || pSectFrame->IsCellFrame() )
698  {
699  break;
700  }
701  pSectFrame = pSectFrame->GetUpper();
702  }
703  if ( pSectFrame && pSectFrame->IsSctFrame() )
704  {
705  SwFrameDeleteGuard aDeleteGuard(&_rAnchorTextFrame);
706  // #i44049#
707  _rAnchorTextFrame.LockJoin();
708  SwFrame* pFrame = pSectFrame->GetUpper()->GetLower();
709  // #i49605# - section frame could move forward
710  // by the format of its previous frame.
711  // Thus, check for valid <pFrame>.
712  while ( pFrame && pFrame != pSectFrame )
713  {
714  if ( pFrame->IsLayoutFrame() )
715  lcl_FormatContentOfLayoutFrame( static_cast<SwLayoutFrame*>(pFrame) );
716  else
717  pFrame->Calc(pFrame->getRootFrame()->GetCurrShell()->GetOut());
718 
719  pFrame = pFrame->GetNext();
720  }
721  lcl_FormatContentOfLayoutFrame( static_cast<SwLayoutFrame*>(pSectFrame),
722  &_rAnchorTextFrame );
723  // #i44049#
724  _rAnchorTextFrame.UnlockJoin();
725  }
726  }
727 
728  // #i40140# - if anchor frame is inside a column,
729  // format the content of the previous columns.
730  // Note: It's a very simple format without formatting objects.
731  SwFrame* pColFrameOfAnchor = _rAnchorTextFrame.FindColFrame();
732  if ( pColFrameOfAnchor )
733  {
734  // #i44049#
735  _rAnchorTextFrame.LockJoin();
736  SwFrame* pColFrame = pColFrameOfAnchor->GetUpper()->GetLower();
737  while ( pColFrame != pColFrameOfAnchor )
738  {
739  SwFrame* pFrame = pColFrame->GetLower();
740  while ( pFrame )
741  {
742  if ( pFrame->IsLayoutFrame() )
743  lcl_FormatContentOfLayoutFrame( static_cast<SwLayoutFrame*>(pFrame) );
744  else
745  pFrame->Calc(pFrame->getRootFrame()->GetCurrShell()->GetOut());
746 
747  pFrame = pFrame->GetNext();
748  }
749 
750  pColFrame = pColFrame->GetNext();
751  }
752  // #i44049#
753  _rAnchorTextFrame.UnlockJoin();
754  }
755  }
756 
757  // format anchor frame - format of its follow not needed
758  // #i43255# - forbid follow format, only if anchor text
759  // frame is in table
760  if ( _rAnchorTextFrame.IsInTab() )
761  {
762  SwForbidFollowFormat aForbidFollowFormat( _rAnchorTextFrame );
763  _rAnchorTextFrame.Calc(_rAnchorTextFrame.getRootFrame()->GetCurrShell()->GetOut());
764  }
765  else
766  {
767  _rAnchorTextFrame.Calc(_rAnchorTextFrame.getRootFrame()->GetCurrShell()->GetOut());
768  }
769 }
770 
776 {
778 }
779 
784 {
785  bool bRet( false );
786 
787  const SwSortedObjs* pObjs = GetAnchorFrame().GetDrawObjs();
788  if ( pObjs && pObjs->size() > 1 )
789  {
790  for (SwAnchoredObject* pAnchoredObj : *pObjs)
791  {
792  if ( pAnchoredObj->ConsiderObjWrapInfluenceOnObjPos() )
793  {
794  bRet = true;
795  break;
796  }
797  }
798  }
799 
800  return bRet;
801 }
802 
803 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
vcl::RenderContext * GetOut() const
Definition: viewsh.hxx:341
static bool CheckMovedFwdCondition(SwAnchoredObject &_rAnchoredObj, const sal_uInt32 _nFromPageNum, const bool _bAnchoredAtMasterBeforeFormatAnchor, sal_uInt32 &_noToPageNum, bool &_boInFollow)
method to check the conditions, if 'anchor is moved forward'
bool GetValue() const
virtual bool DoFormatObj(SwAnchoredObject &_rAnchoredObj, const bool _bCheckForMovedFwd=false) override
intrinsic method to format a certain floating screen object
Base class of the Writer layout elements.
Definition: frame.hxx:295
Represents the visualization of a paragraph.
Definition: txtfrm.hxx:149
const SwPageFrame & GetPageFrame() const
void AllowFollowFormat()
Definition: txtfrm.hxx:737
bool IsFollow() const
Definition: flowfrm.hxx:166
const SwSortedObjs * GetDrawObjs() const
Definition: frame.hxx:543
void SetClearedEnvironment(const bool _bClearedEnvironment)
SwAnchoredObject * GetFirstObjWithMovedFwdAnchor(const sal_Int16 _nWrapInfluenceOnPosition, sal_uInt32 &_noToPageNum, bool &_boInFollow)
method to determine first anchored object, whose 'anchor is moved forward'.
bool IsInFly() const
Definition: frame.hxx:937
bool IsInSct() const
Definition: frame.hxx:943
virtual SwFrame & GetAnchorFrame() override
static std::unique_ptr< SwObjectFormatterTextFrame > CreateObjFormatter(SwTextFrame &_rAnchorTextFrame, const SwPageFrame &_rPageFrame, SwLayAction *_pLayAction)
method to create an instance of is necessary.
bool AtLeastOneObjIsTmpConsiderWrapInfluence()
method to determine if at least one anchored object has state
SwLayAction * GetLayAction()
Definition: doc.hxx:185
void InvalidatePos()
Definition: frame.hxx:1019
TextFrameIndex GetOfst() const
Definition: txtfrm.hxx:426
SwForbidFollowFormat(SwTextFrame &_rTextFrame)
bool ConsiderWrapOnObjPos() const
static void DestroyFrame(SwFrame *const pFrame)
this is the only way to delete a SwFrame instance
Definition: ssfrm.cxx:382
virtual void Calc(vcl::RenderContext *pRenderContext) const
Definition: trvlfrm.cxx:1788
bool IsCellFrame() const
Definition: frame.hxx:1202
bool isFrameAreaDefinitionValid() const
Definition: frame.hxx:167
sal_uInt16 GetPhyPageNum() const
Definition: pagefrm.hxx:190
void InvalidateObjPosForConsiderWrapInfluence()
method to perform necessary invalidations for the positioning of objects, for whose the wrapping styl...
wrapper class for the positioning of Writer fly frames and drawing objects
bool IsInTab() const
Definition: frame.hxx:931
bool IsTextFrame() const
Definition: frame.hxx:1210
void InvalidatePrevObjs(SwAnchoredObject &_rAnchoredObj)
method to invalidate objects, anchored previous to given object at the anchor text frame ...
SwTextFrame *const mpMasterAnchorTextFrame
bool IsSctFrame() const
Definition: frame.hxx:1190
SwAnchoredObject * GetCollectedObj(const sal_uInt32 _nIndex)
accessor to collected anchored object
SwTextFrame * GetFollow()
Definition: txtfrm.hxx:844
virtual void Cut()=0
const SwFormatFollowTextFlow & GetFollowTextFlow(bool=true) const
SwFrame * GetIndPrev() const
Definition: frame.hxx:702
const SwSortedObjs * GetSortedObjs() const
Definition: pagefrm.hxx:118
const SwFormatAnchor & GetAnchor(bool=true) const
Definition: fmtanchr.hxx:81
The usage of LayAction is always the same:
Definition: layact.hxx:56
bool FormatObjsAtFrame_(SwTextFrame *_pMasterTextFrame=nullptr)
invokes the intrinsic format method for all floating screen objects, anchored at anchor frame on the ...
RndStdIds GetAnchorId() const
Definition: fmtanchr.hxx:65
sal_uInt32 GetPgNumOfCollected(const sal_uInt32 _nIndex)
accessor to 'anchor' page number of collected anchored object
size_t size() const
Definition: sortedobjs.cxx:42
SwPageFrame * FindPageFrame()
Definition: frame.hxx:658
static void RemoveMovedFwdFrame(const SwDoc &_rDoc, const SwTextFrame &_rTextFrame)
Definition: layouter.cxx:331
int i
void FormatObj_(SwAnchoredObject &_rAnchoredObj)
performs the intrinsic format of a given floating screen object and its content.
SwLayoutFrame * GetUpper()
Definition: frame.hxx:656
void LockJoin()
Definition: flowfrm.hxx:139
const SwRowFrame * IsInFollowFlowRow() const
Definition: findfrm.cxx:1774
const SwDoc * GetDoc() const
The document is set in SwAttrPool now, therefore you always can access it.
Definition: format.hxx:119
void FormatAnchorFrameForCheckMoveFwd()
method to format the anchor frame for checking of the move forward condition
A page of the document layout.
Definition: pagefrm.hxx:40
SwFrame * GetAnchorFrameContainingAnchPos()
determine anchor frame containing the anchor position
bool RestartLayoutProcess() const
SwFrame * FindColFrame()
Definition: findfrm.cxx:529
void InvalidateFollowObjs(SwAnchoredObject &_rAnchoredObj)
method to invalidate objects, anchored after the given object at the page frame
static void lcl_FormatContentOfLayoutFrame(SwLayoutFrame *pLayFrame, SwFrame *pLastLowerFrame=nullptr)
bool IsLayoutFrame() const
Definition: frame.hxx:1146
virtual bool IsFormatPossible() const
method to determine, if a format on the anchored object is possible
bool ConsiderObjWrapInfluenceOnObjPos() const
method to determine, if wrapping style influence of the anchored object has to be considered on the o...
void UnlockJoin()
Definition: flowfrm.hxx:140
virtual SwFrameFormat & GetFrameFormat()=0
SwPageFrame * FindPageFrameOfAnchor()
method to determine the page frame, on which the 'anchor' of the given anchored object is...
void SetAgain()
Definition: layact.hxx:151
SwTextFrame * FindMaster() const
Definition: flowfrm.cxx:679
SwPageFrame * GetPageFrame()
sal_uInt16 GetPhyPageNum() const
Definition: trvlfrm.cxx:1689
bool HasClearedEnvironment() const
method to determine, if due to anchored object size and wrapping style, its layout environment is cle...
void ForbidFollowFormat()
Definition: txtfrm.hxx:742
virtual ~SwObjectFormatterTextFrame() override
SwFrame * GetLower()
Definition: findfrm.cxx:169
size_t ListPosOf(const SwAnchoredObject &_rAnchoredObj) const
Position of object <_rAnchoredObj> in sorted list.
Definition: sortedobjs.cxx:275
const SwFormatWrapInfluenceOnObjPos & GetWrapInfluenceOnObjPos(bool=true) const
bool IsCollectedAnchoredAtMaster(const sal_uInt32 _nIndex)
accessor to 'anchor' type of collected anchored object
A layout frame is a frame that contains other frames (m_pLower), e.g. SwPageFrame or SwTabFrame...
Definition: layfrm.hxx:35
const SwFrame * GetAnchorFrame() const
static bool FrameMovedFwdByObjPos(const SwDoc &_rDoc, const SwTextFrame &_rTextFrame, sal_uInt32 &_ornToPageNum)
Definition: layouter.cxx:341
bool IsFootnoteContFrame() const
Definition: frame.hxx:1174
static void FormatAnchorFrameAndItsPrevs(SwTextFrame &_rAnchorTextFrame)
method to format given anchor text frame and its previous frames
bool PositionLocked() const
SwViewShell * GetCurrShell() const
Definition: rootfrm.hxx:204
o3tl::strong_int< sal_Int32, struct Tag_TextFrameIndex > TextFrameIndex
Denotes a character index in a text frame at a layout level, after extent mapping from a text node at...
class for collecting anchored objects
Definition: sortedobjs.hxx:48
virtual bool DoFormatObjs() override
intrinsic method to format all floating screen objects
void SetRestartLayoutProcess(const bool _bRestartLayoutProcess)
SwObjectFormatterTextFrame(SwTextFrame &_rAnchorTextFrame, const SwPageFrame &_rPageFrame, SwTextFrame *_pMasterAnchorTextFrame, SwLayAction *_pLayAction)
SwRootFrame * getRootFrame()
Definition: frame.hxx:657
static void InsertMovedFwdFrame(const SwDoc &_rDoc, const SwTextFrame &_rMovedFwdFrameByObjPos, const sal_uInt32 _nToPageNum)
Definition: layouter.cxx:311
SwRowFrame is one table row in the document layout.
Definition: rowfrm.hxx:28
virtual const SwFrameFormat * GetFormat() const
Definition: ssfrm.cxx:393
SwFrame * GetNext()
Definition: frame.hxx:654
sal_uInt32 CountOfCollected()
accessor to total number of collected anchored objects