LibreOffice Module sw (master)  1
tocntntanchoredobjectposition.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 <anchoredobject.hxx>
22 #include <frame.hxx>
23 #include <txtfrm.hxx>
24 #include <pagefrm.hxx>
25 #include <sectfrm.hxx>
26 #include <tabfrm.hxx>
27 #include <rootfrm.hxx>
28 #include <viewopt.hxx>
29 #include <viewsh.hxx>
30 #include <frmfmt.hxx>
31 #include <fmtsrnd.hxx>
32 #include <fmtfsize.hxx>
33 #include <fmtanchr.hxx>
34 #include <fmtornt.hxx>
35 #include <editeng/lrspitem.hxx>
36 #include <editeng/ulspitem.hxx>
37 #include <svx/svdobj.hxx>
39 #include <frmatr.hxx>
41 #include <sortedobjs.hxx>
42 #include <textboxhelper.hxx>
43 
44 using namespace objectpositioning;
45 using namespace ::com::sun::star;
46 
48  : SwAnchoredObjectPosition ( _rDrawObj ),
49  mpVertPosOrientFrame( nullptr ),
50  // #i26791#
51  maOffsetToFrameAnchorPos( Point() ),
52  mbAnchorToChar ( false ),
53  mpToCharOrientFrame( nullptr ),
54  mpToCharRect( nullptr ),
55  // #i22341#
56  mnToCharTopOfLine( 0 )
57 {}
58 
60 {}
61 
63 {
64  return mbAnchorToChar;
65 }
66 
68 {
69  return mpToCharOrientFrame;
70 }
71 
73 {
74  return mpToCharRect;
75 }
76 
77 // #i22341#
79 {
80  return mnToCharTopOfLine;
81 }
82 
84 {
85  OSL_ENSURE( dynamic_cast<const SwTextFrame*>( &GetAnchorFrame()) != nullptr ,
86  "SwToContentAnchoredObjectPosition::GetAnchorTextFrame() - wrong anchor frame type" );
87 
88  return static_cast<SwTextFrame&>(GetAnchorFrame());
89 }
90 
91 // #i23512#
92 static bool lcl_DoesVertPosFits( const SwTwips _nRelPosY,
93  const SwTwips _nAvail,
94  const SwLayoutFrame* _pUpperOfOrientFrame,
95  const bool _bBrowse,
96  const bool _bGrowInTable,
97  SwLayoutFrame*& _orpLayoutFrameToGrow )
98 {
99  bool bVertPosFits = false;
100 
101  if ( _nRelPosY <= _nAvail )
102  {
103  bVertPosFits = true;
104  }
105  else if ( _bBrowse )
106  {
107  if ( _pUpperOfOrientFrame->IsInSct() )
108  {
109  SwSectionFrame* pSctFrame =
110  const_cast<SwSectionFrame*>(_pUpperOfOrientFrame->FindSctFrame());
111  bVertPosFits = pSctFrame->GetUpper()->Grow( _nRelPosY - _nAvail, true ) > 0;
112  // Note: do not provide a layout frame for a grow.
113  }
114  else
115  {
116  bVertPosFits = const_cast<SwLayoutFrame*>(_pUpperOfOrientFrame)->
117  Grow( _nRelPosY - _nAvail, true ) > 0;
118  if ( bVertPosFits )
119  _orpLayoutFrameToGrow = const_cast<SwLayoutFrame*>(_pUpperOfOrientFrame);
120  }
121  }
122  else if ( _pUpperOfOrientFrame->IsInTab() && _bGrowInTable )
123  {
124  // #i45085# - check, if upper frame would grow the
125  // expected amount of twips.
126  const SwTwips nTwipsGrown = const_cast<SwLayoutFrame*>(_pUpperOfOrientFrame)->
127  Grow( _nRelPosY - _nAvail, true );
128  bVertPosFits = ( nTwipsGrown == ( _nRelPosY - _nAvail ) );
129  if ( bVertPosFits )
130  _orpLayoutFrameToGrow = const_cast<SwLayoutFrame*>(_pUpperOfOrientFrame);
131  }
132 
133  return bVertPosFits;
134 }
135 
137 {
138  // get format of object
139  const SwFrameFormat& rFrameFormat = GetFrameFormat();
140 
141  // declare and set <pFooter> to footer frame, if object is anchored
142  // at a frame belonging to the footer.
143  const SwFrame* pFooter = GetAnchorFrame().FindFooterOrHeader();
144  if ( pFooter && !pFooter->IsFooterFrame() )
145  pFooter = nullptr;
146 
147  // declare and set <bBrowse> to true, if document is in browser mode and
148  // object is anchored at the body, but not at frame belonging to a table.
149  bool bBrowse = GetAnchorFrame().IsInDocBody() && !GetAnchorFrame().IsInTab();
150  if( bBrowse )
151  {
153  if( !pSh || !pSh->GetViewOptions()->getBrowseMode() )
154  bBrowse = false;
155  }
156 
157  // determine left/right and its upper/lower spacing.
158  const SvxLRSpaceItem &rLR = rFrameFormat.GetLRSpace();
159  const SvxULSpaceItem &rUL = rFrameFormat.GetULSpace();
160 
161  // determine, if object has no surrounding.
162  const SwFormatSurround& rSurround = rFrameFormat.GetSurround();
163  const bool bNoSurround = rSurround.GetSurround() == css::text::WrapTextMode_NONE;
164  const bool bWrapThrough = rSurround.GetSurround() == css::text::WrapTextMode_THROUGH;
165 
166  // new class <SwEnvironmentOfAnchoredObject>
168 
169  // #i18732# - grow only, if object has to follow the text flow
170  const bool bGrow = DoesObjFollowsTextFlow() &&
171  ( !GetAnchorFrame().IsInTab() ||
172  !rFrameFormat.GetFrameSize().GetHeightPercent() );
173 
174  // get text frame the object is anchored at
175  const SwTextFrame& rAnchorTextFrame = GetAnchorTextFrame();
176  SwRectFnSet aRectFnSet(&rAnchorTextFrame);
177 
178  const SwRect aObjBoundRect( GetAnchoredObj().GetObjRect() );
179 
180  // local variable keeping the calculated relative position; initialized with
181  // current relative position.
182  // #i26791# - use new object instance of <SwAnchoredObject>
183  Point aRelPos( GetAnchoredObj().GetCurrRelPos() );
184 
185  SwTwips nRelDiff = 0;
186 
187  bool bMoveable = rAnchorTextFrame.IsMoveable();
188 
189  // determine frame the object position has to be oriented at.
190  const SwTextFrame* pOrientFrame = &rAnchorTextFrame;
191  const SwTextFrame* pAnchorFrameForVertPos = &rAnchorTextFrame;
192  {
193  // if object is at-character anchored, determine character-rectangle
194  // and frame, position has to be oriented at.
195  mbAnchorToChar = (RndStdIds::FLY_AT_CHAR == rFrameFormat.GetAnchor().GetAnchorId());
196  if ( mbAnchorToChar )
197  {
198  const SwFormatAnchor& rAnch = rFrameFormat.GetAnchor();
199  // #i26791# - use new object instance of <SwAnchoredObject>
200  // Due to table break algorithm the character
201  // rectangle can have no height. Thus, check also the width
202  if ( ( !GetAnchoredObj().GetLastCharRect().Height() &&
203  !GetAnchoredObj().GetLastCharRect().Width() ) ||
204  !GetAnchoredObj().GetLastTopOfLine() )
205  {
207  // Due to table break algorithm the character
208  // rectangle can have no height. Thus, check also the width
209  if ( ( !GetAnchoredObj().GetLastCharRect().Height() &&
210  !GetAnchoredObj().GetLastCharRect().Width() ) ||
211  !GetAnchoredObj().GetLastTopOfLine() )
212  {
213  // Get default for <mpVertPosOrientFrame>, if it's not set.
214  if ( !mpVertPosOrientFrame )
215  {
216  mpVertPosOrientFrame = rAnchorTextFrame.GetUpper();
217  }
218  return;
219  }
220  }
222  // #i22341# - get top of line, in which the anchor character is.
224  pOrientFrame = &(const_cast<SwTextFrame&>(rAnchorTextFrame).GetFrameAtOfst(
225  rAnchorTextFrame.MapModelToViewPos(*rAnch.GetContentAnchor())));
226  mpToCharOrientFrame = pOrientFrame;
227  }
228  }
229  aRectFnSet.Refresh(pOrientFrame);
230 
231  // determine vertical position
232  {
233 
234  // determine vertical positioning and alignment attributes
235  SwFormatVertOrient aVert( rFrameFormat.GetVertOrient() );
236 
237  // #i18732# - determine layout frame for vertical
238  // positions aligned to 'page areas'.
239  const SwLayoutFrame& rPageAlignLayFrame =
240  aEnvOfObj.GetVertEnvironmentLayoutFrame( *pOrientFrame );
241 
242  if ( aVert.GetVertOrient() != text::VertOrientation::NONE )
243  {
244  // #i18732# - adjustments for follow text flow or not
245  // AND vertical alignment at 'page areas'.
246  SwTwips nAlignAreaHeight;
247  SwTwips nAlignAreaOffset;
248  GetVertAlignmentValues( *pOrientFrame, rPageAlignLayFrame,
249  aVert.GetRelationOrient(),
250  nAlignAreaHeight, nAlignAreaOffset );
251 
252  // determine relative vertical position
253  SwTwips nRelPosY = nAlignAreaOffset;
254  const SwTwips nObjHeight = aRectFnSet.GetHeight(aObjBoundRect);
255  const SwTwips nUpperSpace = aRectFnSet.IsVert()
256  ? ( aRectFnSet.IsVertL2R()
257  ? rLR.GetLeft()
258  : rLR.GetRight() )
259  : rUL.GetUpper();
260  // --> OD 2009-08-31 #monglianlayout#
261  const SwTwips nLowerSpace = aRectFnSet.IsVert()
262  ? ( aRectFnSet.IsVertL2R()
263  ? rLR.GetLeft()
264  : rLR.GetRight() )
265  : rUL.GetLower();
266  switch ( aVert.GetVertOrient() )
267  {
268  case text::VertOrientation::CHAR_BOTTOM:
269  {
270  if ( mbAnchorToChar )
271  {
272  // bottom (to character anchored)
273  nRelPosY += nAlignAreaHeight + nUpperSpace;
274  if ( aRectFnSet.IsVert() && !aRectFnSet.IsVertL2R() )
275  {
276  nRelPosY += nObjHeight;
277  }
278  break;
279  }
280  [[fallthrough]];
281  }
282  case text::VertOrientation::TOP:
283  {
284  // #i22341# - special case for vertical
285  // alignment at top of line
286  if ( mbAnchorToChar &&
287  aVert.GetRelationOrient() == text::RelOrientation::TEXT_LINE )
288  {
289  nRelPosY -= (nObjHeight + nLowerSpace);
290  }
291  else
292  {
293  nRelPosY += nUpperSpace;
294  }
295  }
296  break;
297  // #i22341#
298  case text::VertOrientation::LINE_TOP:
299  {
300  if ( mbAnchorToChar &&
301  aVert.GetRelationOrient() == text::RelOrientation::TEXT_LINE )
302  {
303  nRelPosY -= (nObjHeight + nLowerSpace);
304  }
305  else
306  {
307  OSL_FAIL( "<SwToContentAnchoredObjectPosition::CalcPosition()> - unknown combination of vertical position and vertical alignment." );
308  }
309  }
310  break;
311  case text::VertOrientation::CENTER:
312  {
313  nRelPosY += (nAlignAreaHeight / 2) - (nObjHeight / 2);
314  }
315  break;
316  // #i22341#
317  case text::VertOrientation::LINE_CENTER:
318  {
319  if ( mbAnchorToChar &&
320  aVert.GetRelationOrient() == text::RelOrientation::TEXT_LINE )
321  {
322  nRelPosY += (nAlignAreaHeight / 2) - (nObjHeight / 2);
323  }
324  else
325  {
326  OSL_FAIL( "<SwToContentAnchoredObjectPosition::CalcPosition()> - unknown combination of vertical position and vertical alignment." );
327  }
328  }
329  break;
330  case text::VertOrientation::BOTTOM:
331  {
332  if ( ( aVert.GetRelationOrient() == text::RelOrientation::FRAME ||
333  aVert.GetRelationOrient() == text::RelOrientation::PRINT_AREA ) &&
334  bNoSurround )
335  {
336  // bottom (aligned to 'paragraph areas')
337  nRelPosY += nAlignAreaHeight + nUpperSpace;
338  }
339  else
340  {
341  // #i22341# - special case for vertical
342  // alignment at top of line
343  if ( mbAnchorToChar &&
344  aVert.GetRelationOrient() == text::RelOrientation::TEXT_LINE )
345  {
346  nRelPosY += nUpperSpace;
347  }
348  else
349  {
350  nRelPosY += nAlignAreaHeight -
351  ( nObjHeight + nLowerSpace );
352  }
353  }
354  }
355  break;
356  // #i22341#
357  case text::VertOrientation::LINE_BOTTOM:
358  {
359  if ( mbAnchorToChar &&
360  aVert.GetRelationOrient() == text::RelOrientation::TEXT_LINE )
361  {
362  nRelPosY += nUpperSpace;
363  }
364  else
365  {
366  OSL_FAIL( "<SwToContentAnchoredObjectPosition::CalcPosition()> - unknown combination of vertical position and vertical alignment." );
367  }
368  }
369  break;
370  default:
371  break;
372  }
373 
374  // adjust relative position by distance between anchor frame and
375  // the frame, the object is oriented at.
376  // #i28701# - correction: adjust relative position,
377  // only if the floating screen object has to follow the text flow.
378  if ( DoesObjFollowsTextFlow() && pOrientFrame != &rAnchorTextFrame )
379  {
380  // #i11860# - use new method <GetTopForObjPos>
381  // to get top of frame for object positioning.
382  const SwTwips nTopOfOrient = GetTopForObjPos( *pOrientFrame, aRectFnSet.FnRect(), aRectFnSet.IsVert() );
383  nRelPosY += aRectFnSet.YDiff( nTopOfOrient,
384  GetTopForObjPos( rAnchorTextFrame, aRectFnSet.FnRect(), aRectFnSet.IsVert() ) );
385  }
386 
387  // #i42124# - capture object inside vertical
388  // layout environment.
389  {
390  const SwTwips nTopOfAnch =
391  GetTopForObjPos( *pOrientFrame, aRectFnSet.FnRect(), aRectFnSet.IsVert() );
392  const SwLayoutFrame& rVertEnvironLayFrame =
394  *(pOrientFrame->GetUpper()) );
395  const bool bCheckBottom = !DoesObjFollowsTextFlow();
396  nRelPosY = AdjustVertRelPos( nTopOfAnch, aRectFnSet.IsVert(), aRectFnSet.IsVertL2R(),
397  rVertEnvironLayFrame, nRelPosY,
399  bCheckBottom );
400  }
401 
402  // keep calculated relative vertical position - needed for filters
403  // (including the xml-filter)
404  {
405  // determine position
406  SwTwips nAttrRelPosY = nRelPosY - nAlignAreaOffset;
407  // set
408  if ( nAttrRelPosY != aVert.GetPos() )
409  {
410  aVert.SetPos( nAttrRelPosY );
411  const_cast<SwFrameFormat&>(rFrameFormat).LockModify();
412  const_cast<SwFrameFormat&>(rFrameFormat).SetFormatAttr( aVert );
413  const_cast<SwFrameFormat&>(rFrameFormat).UnlockModify();
414  }
415  }
416 
417  // determine absolute 'vertical' position, depending on layout-direction
418  // #i26791# - determine offset to 'vertical' frame
419  // anchor position, depending on layout-direction
420  if ( aRectFnSet.IsVert() )
421  {
422  aRelPos.setX( nRelPosY );
423  maOffsetToFrameAnchorPos.setX( nAlignAreaOffset );
424  }
425  else
426  {
427  aRelPos.setY( nRelPosY );
428  maOffsetToFrameAnchorPos.setY( nAlignAreaOffset );
429  }
430  }
431 
432  // Determine upper of frame vertical position is oriented at.
433  // #i28701# - determine 'virtual' anchor frame.
434  // This frame is used in the following instead of the 'real' anchor
435  // frame <rAnchorTextFrame> for the 'vertical' position in all cases.
436  const SwLayoutFrame* pUpperOfOrientFrame = nullptr;
437  {
438  // #i28701# - As long as the anchor frame is on the
439  // same page as <pOrientFrame> and the vertical position isn't aligned
440  // automatic at the anchor character or the top of the line of the
441  // anchor character, the anchor frame determines the vertical position.
442  if ( &rAnchorTextFrame == pOrientFrame ||
443  ( rAnchorTextFrame.FindPageFrame() == pOrientFrame->FindPageFrame() &&
444  aVert.GetVertOrient() == text::VertOrientation::NONE &&
445  aVert.GetRelationOrient() != text::RelOrientation::CHAR &&
446  aVert.GetRelationOrient() != text::RelOrientation::TEXT_LINE ) )
447  {
448  pUpperOfOrientFrame = rAnchorTextFrame.GetUpper();
449  pAnchorFrameForVertPos = &rAnchorTextFrame;
450  }
451  else
452  {
453  pUpperOfOrientFrame = pOrientFrame->GetUpper();
454  pAnchorFrameForVertPos = pOrientFrame;
455  }
456  }
457 
458  // ignore one-column sections.
459  // #i23512# - correction: also ignore one-columned
460  // sections with footnotes/endnotes
461  if ( pUpperOfOrientFrame->IsInSct() )
462  {
463  const SwSectionFrame* pSctFrame = pUpperOfOrientFrame->FindSctFrame();
464  const bool bIgnoreSection = pUpperOfOrientFrame->IsSctFrame() ||
465  ( pSctFrame->Lower()->IsColumnFrame() &&
466  !pSctFrame->Lower()->GetNext() );
467  if ( bIgnoreSection )
468  pUpperOfOrientFrame = pSctFrame->GetUpper();
469  }
470 
471  if ( aVert.GetVertOrient() == text::VertOrientation::NONE )
472  {
473  // local variable <nRelPosY> for calculation of relative vertical
474  // distance to anchor.
475  SwTwips nRelPosY = 0;
476  // #i26791# - local variable <nVertOffsetToFrameAnchorPos>
477  // for determination of the 'vertical' offset to the frame anchor
478  // position
479  SwTwips nVertOffsetToFrameAnchorPos( 0 );
480  // #i22341# - add special case for vertical alignment
481  // at top of line.
482  if ( mbAnchorToChar &&
483  ( aVert.GetRelationOrient() == text::RelOrientation::CHAR ||
484  aVert.GetRelationOrient() == text::RelOrientation::TEXT_LINE ) )
485  {
486  // #i11860# - use new method <GetTopForObjPos>
487  // to get top of frame for object positioning.
488  SwTwips nTopOfOrient = GetTopForObjPos( *pOrientFrame, aRectFnSet.FnRect(), aRectFnSet.IsVert() );
489  if ( aVert.GetRelationOrient() == text::RelOrientation::CHAR )
490  {
491  nVertOffsetToFrameAnchorPos = aRectFnSet.YDiff(
492  aRectFnSet.GetBottom(*ToCharRect()),
493  nTopOfOrient );
494  }
495  else
496  {
497  nVertOffsetToFrameAnchorPos = aRectFnSet.YDiff( ToCharTopOfLine(),
498  nTopOfOrient );
499  }
500  nRelPosY = nVertOffsetToFrameAnchorPos - aVert.GetPos();
501  }
502  else
503  {
504  // #i28701# - correction: use <pAnchorFrameForVertPos>
505  // instead of <pOrientFrame> and do not adjust relative position
506  // to get correct vertical position.
507  nVertOffsetToFrameAnchorPos = 0;
508  // #i11860# - use new method <GetTopForObjPos>
509  // to get top of frame for object positioning.
510  const SwTwips nTopOfOrient =
511  GetTopForObjPos( *pAnchorFrameForVertPos, aRectFnSet.FnRect(), aRectFnSet.IsVert() );
512  // Increase <nRelPosY> by margin height,
513  // if position is vertical aligned to "paragraph text area"
514  if ( aVert.GetRelationOrient() == text::RelOrientation::PRINT_AREA )
515  {
516  // #i11860# - consider upper space amount of previous frame
517  SwTwips nTopMargin = aRectFnSet.GetTopMargin(*pAnchorFrameForVertPos);
518  if ( pAnchorFrameForVertPos->IsTextFrame() )
519  {
520  nTopMargin -= pAnchorFrameForVertPos->
521  GetUpperSpaceAmountConsideredForPrevFrameAndPageGrid();
522  }
523  nVertOffsetToFrameAnchorPos += nTopMargin;
524  }
525  // #i18732# - adjust <nRelPosY> by difference
526  // between 'page area' and 'anchor' frame, if position is
527  // vertical aligned to 'page areas'
528  else if ( aVert.GetRelationOrient() == text::RelOrientation::PAGE_FRAME )
529  {
530  nVertOffsetToFrameAnchorPos += aRectFnSet.YDiff(
531  aRectFnSet.GetTop(rPageAlignLayFrame.getFrameArea()),
532  nTopOfOrient );
533  }
534  else if ( aVert.GetRelationOrient() == text::RelOrientation::PAGE_PRINT_AREA )
535  {
536  SwRect aPgPrtRect( rPageAlignLayFrame.getFrameArea() );
537  if ( rPageAlignLayFrame.IsPageFrame() )
538  {
539  aPgPrtRect =
540  static_cast<const SwPageFrame&>(rPageAlignLayFrame).PrtWithoutHeaderAndFooter();
541  }
542  nVertOffsetToFrameAnchorPos += aRectFnSet.YDiff(
543  aRectFnSet.GetTop(aPgPrtRect),
544  nTopOfOrient );
545  }
546  nRelPosY = nVertOffsetToFrameAnchorPos + aVert.GetPos();
547  }
548 
549  // <pUpperOfOrientFrame>: layout frame, at which the position has to
550  // is oriented at
551  // <nRelPosY>: rest of the relative distance in the current
552  // layout frame
553  // <nAvail>: space, which is available in the current
554  // layout frame
555 
556  // #i26791# - determine offset to 'vertical'
557  // frame anchor position, depending on layout-direction
558  if ( aRectFnSet.IsVert() )
559  maOffsetToFrameAnchorPos.setX( nVertOffsetToFrameAnchorPos );
560  else
561  maOffsetToFrameAnchorPos.setY( nVertOffsetToFrameAnchorPos );
562  // #i11860# - use new method <GetTopForObjPos>
563  // to get top of frame for object positioning.
564  const SwTwips nTopOfAnch = GetTopForObjPos( *pAnchorFrameForVertPos, aRectFnSet.FnRect(), aRectFnSet.IsVert() );
565  if( nRelPosY <= 0 )
566  {
567  // Allow negative position, but keep it
568  // inside environment layout frame.
569  const SwLayoutFrame& rVertEnvironLayFrame =
570  aEnvOfObj.GetVertEnvironmentLayoutFrame( *pUpperOfOrientFrame );
571  // #i31805# - do not check, if bottom of
572  // anchored object would fit into environment layout frame, if
573  // anchored object has to follow the text flow.
574  const bool bCheckBottom = !DoesObjFollowsTextFlow();
575  nRelPosY = AdjustVertRelPos( nTopOfAnch, aRectFnSet.IsVert(), aRectFnSet.IsVertL2R(),
576  rVertEnvironLayFrame, nRelPosY,
578  bCheckBottom );
579  if ( aRectFnSet.IsVert() )
580  aRelPos.setX( nRelPosY );
581  else
582  aRelPos.setY( nRelPosY );
583  }
584  else
585  {
586  aRectFnSet.Refresh(pAnchorFrameForVertPos);
587  SwTwips nAvail =
588  aRectFnSet.YDiff( aRectFnSet.GetPrtBottom(*pUpperOfOrientFrame),
589  nTopOfAnch );
590  const bool bInFootnote = pAnchorFrameForVertPos->IsInFootnote();
591  while ( nRelPosY )
592  {
593  // #i23512# - correction:
594  // consider section frame for grow in online layout.
595  // use new local method <lcl_DoesVertPosFits(..)>
596  SwLayoutFrame* pLayoutFrameToGrow = nullptr;
597  const bool bDoesVertPosFits = lcl_DoesVertPosFits(
598  nRelPosY, nAvail, pUpperOfOrientFrame, bBrowse,
599  bGrow, pLayoutFrameToGrow );
600 
601  if ( bDoesVertPosFits )
602  {
603  SwTwips nTmpRelPosY =
604  aRectFnSet.YDiff( aRectFnSet.GetPrtBottom(*pUpperOfOrientFrame),
605  nTopOfAnch ) -
606  nAvail + nRelPosY;
607  // #i28701# - adjust calculated
608  // relative vertical position to object's environment.
609  const SwFrame& rVertEnvironLayFrame =
610  aEnvOfObj.GetVertEnvironmentLayoutFrame( *pUpperOfOrientFrame );
611  // Do not check, if bottom of
612  // anchored object would fit into environment layout
613  // frame, if anchored object has to follow the text flow.
614  const bool bCheckBottom = !DoesObjFollowsTextFlow();
615  nTmpRelPosY = AdjustVertRelPos( nTopOfAnch, aRectFnSet.IsVert(), aRectFnSet.IsVertL2R(),
616  rVertEnvironLayFrame,
617  nTmpRelPosY,
619  bCheckBottom );
620  if ( aRectFnSet.IsVert() )
621  aRelPos.setX( nTmpRelPosY );
622  else
623  aRelPos.setY( nTmpRelPosY );
624 
625  // #i23512# - use local variable
626  // <pLayoutFrameToGrow> provided by new method
627  // <lcl_DoesVertPosFits(..)>.
628  if ( pLayoutFrameToGrow )
629  {
630  // No need to grow the anchor cell in case the follow-text-flow object
631  // is wrap-though.
632  if (!GetAnchorFrame().IsInTab() || !DoesObjFollowsTextFlow() || !bWrapThrough)
633  {
634  pLayoutFrameToGrow->Grow( nRelPosY - nAvail );
635  }
636  }
637  nRelPosY = 0;
638  }
639  else
640  {
641  // #i26495# - floating screen objects,
642  // which are anchored inside a table, doesn't follow
643  // the text flow.
644  if ( DoesObjFollowsTextFlow() &&
645  !( aVert.GetRelationOrient() == text::RelOrientation::PAGE_FRAME ||
646  aVert.GetRelationOrient() == text::RelOrientation::PAGE_PRINT_AREA ) &&
647  !GetAnchorFrame().IsInTab() )
648  {
649  if ( bMoveable )
650  {
651  // follow the text flow
652  nRelPosY -= nAvail;
653  MakePageType eMakePage = bInFootnote ? MAKEPAGE_NONE
654  : MAKEPAGE_APPEND;
655  const bool bInSct = pUpperOfOrientFrame->IsInSct();
656  if( bInSct )
657  eMakePage = MAKEPAGE_NOSECTION;
658 
659  const SwLayoutFrame* pTmp =
660  pUpperOfOrientFrame->GetLeaf( eMakePage, true, &rAnchorTextFrame );
661  if ( pTmp &&
662  ( !bInSct ||
663  pUpperOfOrientFrame->FindSctFrame()->IsAnFollow( pTmp->FindSctFrame() ) ) )
664  {
665  pUpperOfOrientFrame = pTmp;
666  bMoveable = rAnchorTextFrame.IsMoveable( pUpperOfOrientFrame );
667  aRectFnSet.Refresh(pUpperOfOrientFrame);
668  nAvail = aRectFnSet.GetHeight(pUpperOfOrientFrame->getFramePrintArea());
669  }
670  else
671  {
672  // if there isn't enough space in the (columned)
673  // section, leave it and set available space <nAvail>
674  // to the space below the section.
675  // if the new available space isn't also enough,
676  // new pages can be created.
677  if( bInSct )
678  {
679  const SwFrame* pSct = pUpperOfOrientFrame->FindSctFrame();
680  pUpperOfOrientFrame = pSct->GetUpper();
681  nAvail = aRectFnSet.YDiff(
682  aRectFnSet.GetPrtBottom(*pUpperOfOrientFrame),
683  aRectFnSet.GetPrtBottom(*pSct) );
684  }
685  else
686  {
687 #if OSL_DEBUG_LEVEL > 1
688  OSL_FAIL( "<SwToContentAnchoredObjectPosition::CalcPosition()> - !bInSct" );
689 #endif
690  nRelDiff = nRelPosY;
691  nRelPosY = 0;
692  }
693  }
694  }
695  else
696  {
697  nRelPosY = 0;
698  }
699  }
700  else
701  {
702  // #i18732# - do not follow text flow respectively
703  // align at 'page areas', but stay inside given environment
704  const SwFrame& rVertEnvironLayFrame =
705  aEnvOfObj.GetVertEnvironmentLayoutFrame( *pUpperOfOrientFrame );
706  nRelPosY = AdjustVertRelPos( nTopOfAnch, aRectFnSet.IsVert(), aRectFnSet.IsVertL2R(),
707  rVertEnvironLayFrame,
708  nRelPosY,
710  if( aRectFnSet.IsVert() )
711  aRelPos.setX( nRelPosY );
712  else
713  aRelPos.setY( nRelPosY );
714  nRelPosY = 0;
715  }
716  }
717  } // end of <while ( nRelPosY )>
718  } // end of else <nRelPosY <= 0>
719  } // end of <aVert.GetVertOrient() == text::VertOrientation::NONE>
720 
721  // We need to calculate the part's absolute position, in order for
722  // it to be put onto the right page and to be pulled into the
723  // LayLeaf's PrtArea
724  const SwTwips nTopOfAnch = GetTopForObjPos( *pAnchorFrameForVertPos, aRectFnSet.FnRect(), aRectFnSet.IsVert() );
725  if( aRectFnSet.IsVert() )
726  {
727  // --> OD 2009-08-31 #monglianlayout#
728  if ( !aRectFnSet.IsVertL2R() )
729  {
730  GetAnchoredObj().SetObjLeft( nTopOfAnch -
731  ( aRelPos.X() - nRelDiff ) -
732  aObjBoundRect.Width() );
733  }
734  else
735  {
736  GetAnchoredObj().SetObjLeft( nTopOfAnch +
737  ( aRelPos.X() - nRelDiff ) );
738  }
739  }
740  else
741  {
742  GetAnchoredObj().SetObjTop( nTopOfAnch +
743  ( aRelPos.Y() - nRelDiff ) );
744  }
745 
746  // grow environment under certain conditions
747  // ignore one-column sections.
748  // #i23512# - correction: also ignore one-columned
749  // sections with footnotes/endnotes
750  if ( pUpperOfOrientFrame->IsInSct() )
751  {
752  const SwSectionFrame* pSctFrame = pUpperOfOrientFrame->FindSctFrame();
753  const bool bIgnoreSection = pUpperOfOrientFrame->IsSctFrame() ||
754  ( pSctFrame->Lower()->IsColumnFrame() &&
755  !pSctFrame->Lower()->GetNext() );
756  if ( bIgnoreSection )
757  pUpperOfOrientFrame = pSctFrame->GetUpper();
758  }
759  SwTwips nDist = aRectFnSet.BottomDist( GetAnchoredObj().GetObjRect(),
760  aRectFnSet.GetPrtBottom(*pUpperOfOrientFrame) );
761  if( nDist < 0 )
762  {
763  // #i23512# - correction:
764  // consider section frame for grow in online layout and
765  // consider page alignment for grow in table.
766  SwLayoutFrame* pLayoutFrameToGrow = nullptr;
767  if ( bBrowse && rAnchorTextFrame.IsMoveable() )
768  {
769  if ( pUpperOfOrientFrame->IsInSct() )
770  {
771  pLayoutFrameToGrow = const_cast<SwLayoutFrame*>(
772  pUpperOfOrientFrame->FindSctFrame()->GetUpper());
773  nDist = aRectFnSet.BottomDist( GetAnchoredObj().GetObjRect(),
774  aRectFnSet.GetPrtBottom(*pLayoutFrameToGrow) );
775  if ( nDist >= 0 )
776  {
777  pLayoutFrameToGrow = nullptr;
778  }
779  }
780  else
781  {
782  pLayoutFrameToGrow =
783  const_cast<SwLayoutFrame*>(pUpperOfOrientFrame);
784  }
785  }
786  else if ( rAnchorTextFrame.IsInTab() && bGrow )
787  {
788  pLayoutFrameToGrow = const_cast<SwLayoutFrame*>(pUpperOfOrientFrame);
789  }
790  if ( pLayoutFrameToGrow )
791  {
792  // No need to grow the anchor cell in case the follow-text-flow object
793  // is wrap-though.
794  if (!GetAnchorFrame().IsInTab() || !DoesObjFollowsTextFlow() || !bWrapThrough)
795  {
796  pLayoutFrameToGrow->Grow( -nDist );
797  }
798  }
799  }
800 
801  if ( DoesObjFollowsTextFlow() &&
802  !( aVert.GetRelationOrient() == text::RelOrientation::PAGE_FRAME ||
803  aVert.GetRelationOrient() == text::RelOrientation::PAGE_PRINT_AREA ) )
804  {
805 
806  nDist = aRectFnSet.BottomDist( GetAnchoredObj().GetObjRect(),
807  aRectFnSet.GetPrtBottom(*pUpperOfOrientFrame) );
808  // #i26945# - floating screen objects, which are
809  // anchored inside a table, doesn't follow the text flow. But, they
810  // have to stay inside its layout environment.
811  if ( nDist < 0 && pOrientFrame->IsInTab() )
812  {
813  // If the anchor frame is the first content of the table cell
814  // and has no follow, the table frame is notified,
815  // that the object doesn't fit into the table cell.
816  // Adjustment of position isn't needed in this case.
817  if ( pOrientFrame == &rAnchorTextFrame &&
818  !pOrientFrame->GetFollow() &&
819  !pOrientFrame->GetIndPrev() )
820  {
821  const_cast<SwTabFrame*>(pOrientFrame->FindTabFrame())
822  ->SetDoesObjsFit( false );
823  }
824  else
825  {
826  SwTwips nTmpRelPosY( 0 );
827  if ( aRectFnSet.IsVert() )
828  nTmpRelPosY = aRelPos.X() - nDist;
829  else
830  nTmpRelPosY = aRelPos.Y() + nDist;
831  const SwLayoutFrame& rVertEnvironLayFrame =
832  aEnvOfObj.GetVertEnvironmentLayoutFrame( *pUpperOfOrientFrame );
833  nTmpRelPosY = AdjustVertRelPos( nTopOfAnch, aRectFnSet.IsVert(), aRectFnSet.IsVertL2R(),
834  rVertEnvironLayFrame,
835  nTmpRelPosY,
837  false );
838  if ( aRectFnSet.IsVert() )
839  {
840  aRelPos.setX( nTmpRelPosY );
841  // --> OD 2009-08-31 #mongolianlayout#
842  if ( !aRectFnSet.IsVertL2R() )
843  {
844  GetAnchoredObj().SetObjLeft( nTopOfAnch -
845  aRelPos.X() -
846  aObjBoundRect.Width() );
847  }
848  else
849  {
850  GetAnchoredObj().SetObjLeft( nTopOfAnch + aRelPos.X() );
851  }
852  }
853  else
854  {
855  aRelPos.setY( nTmpRelPosY );
856  GetAnchoredObj().SetObjTop( nTopOfAnch + aRelPos.Y() );
857  }
858  // If the anchor frame is the first content of the table cell
859  // and the object still doesn't fit, the table frame is notified,
860  // that the object doesn't fit into the table cell.
861  nDist = aRectFnSet.BottomDist( GetAnchoredObj().GetObjRect(),
862  aRectFnSet.GetPrtBottom(*pUpperOfOrientFrame) );
863  if ( nDist < 0 &&
864  pOrientFrame == &rAnchorTextFrame && !pOrientFrame->GetIndPrev() )
865  {
866  const_cast<SwTabFrame*>(pOrientFrame->FindTabFrame())
867  ->SetDoesObjsFit( false );
868  }
869  }
870  }
871  else
872  {
873  // follow text flow
874  const bool bInFootnote = rAnchorTextFrame.IsInFootnote();
875  while( bMoveable && nDist < 0 )
876  {
877  bool bInSct = pUpperOfOrientFrame->IsInSct();
878  if ( bInSct )
879  {
880  const SwLayoutFrame* pTmp = pUpperOfOrientFrame->FindSctFrame()->GetUpper();
881  nDist = aRectFnSet.BottomDist( GetAnchoredObj().GetObjRect(),
882  aRectFnSet.GetPrtBottom(*pTmp) );
883  // #i23129# - Try to flow into next
884  // section|section column. Thus, do *not* leave section
885  // area, if anchored object doesn't fit into upper of section.
886  // But the anchored object is allowed to overlap bottom
887  // section|section column.
888  if ( nDist >= 0 )
889  {
890  break;
891  }
892  }
893  if ( !bInSct &&
894  aRectFnSet.GetTop(GetAnchoredObj().GetObjRect()) ==
895  aRectFnSet.GetPrtTop(*pUpperOfOrientFrame) )
896  // It doesn't fit, moving it would not help either anymore
897  break;
898 
899  const SwLayoutFrame* pNextLay = pUpperOfOrientFrame->GetLeaf(
900  ( bInSct
902  : ( bInFootnote ? MAKEPAGE_NONE : MAKEPAGE_APPEND ) ),
903  true, &rAnchorTextFrame );
904  // correction:
905  // If anchor is in footnote and proposed next layout environment
906  // isn't a footnote frame, object can't follow the text flow
907  if ( bInFootnote && pNextLay && !pNextLay->IsFootnoteFrame() )
908  {
909  pNextLay = nullptr;
910  }
911  if ( pNextLay )
912  {
913  SwRectFnSet fnRectX(pNextLay);
914  if ( !bInSct ||
915  ( pUpperOfOrientFrame->FindSctFrame()->IsAnFollow( pNextLay->FindSctFrame() ) &&
916  fnRectX.GetHeight(pNextLay->getFramePrintArea()) ) )
917  {
918  SwTwips nTmpRelPosY =
919  aRectFnSet.YDiff( aRectFnSet.GetPrtTop(*pNextLay),
920  nTopOfAnch );
921  if ( aRectFnSet.IsVert() )
922  aRelPos.setX( nTmpRelPosY );
923  else
924  aRelPos.setY( nTmpRelPosY );
925  pUpperOfOrientFrame = pNextLay;
926  aRectFnSet.Refresh(pUpperOfOrientFrame);
927  bMoveable = rAnchorTextFrame.IsMoveable( pUpperOfOrientFrame );
928  if( fnRectX.IsVert() )
929  {
930  // --> OD 2009-08-31 #mongolianlayout#
931  if ( !aRectFnSet.IsVertL2R() )
932  {
933  GetAnchoredObj().SetObjLeft( nTopOfAnch -
934  aRelPos.X() -
935  aObjBoundRect.Width() );
936  }
937  else
938  {
939  GetAnchoredObj().SetObjLeft( nTopOfAnch +
940  aRelPos.X() );
941  }
942  }
943  else
944  GetAnchoredObj().SetObjTop( nTopOfAnch +
945  aRelPos.Y() );
946  nDist = aRectFnSet.BottomDist( GetAnchoredObj().GetObjRect(),
947  aRectFnSet.GetPrtBottom(*pUpperOfOrientFrame) );
948  }
949  // #i23129# - leave section area
950  else if ( bInSct )
951  {
952  const SwLayoutFrame* pTmp = pUpperOfOrientFrame->FindSctFrame()->GetUpper();
953  nDist = aRectFnSet.BottomDist( GetAnchoredObj().GetObjRect(),
954  aRectFnSet.GetPrtBottom(*pTmp) );
955  if( nDist < 0 )
956  pUpperOfOrientFrame = pTmp;
957  else
958  break;
959  }
960  }
961  else if ( bInSct )
962  {
963  // If we don't have enough room within the Area, we take a look at
964  // the Page
965  const SwLayoutFrame* pTmp = pUpperOfOrientFrame->FindSctFrame()->GetUpper();
966  nDist = aRectFnSet.BottomDist( GetAnchoredObj().GetObjRect(),
967  aRectFnSet.GetPrtBottom(*pTmp) );
968  if( nDist < 0 )
969  pUpperOfOrientFrame = pTmp;
970  else
971  break;
972  }
973  else
974  bMoveable = false;
975  }
976  }
977  }
978 
979  // keep layout frame vertical position is oriented at.
980  mpVertPosOrientFrame = pUpperOfOrientFrame;
981 
982  // If it was requested to not overlap with already formatted objects, take care of that
983  // here.
984  CalcOverlap(pAnchorFrameForVertPos, aRelPos, nTopOfAnch);
985  }
986 
987  // determine 'horizontal' position
988  {
989  // determine horizontal positioning and alignment attributes
990  SwFormatHoriOrient aHori( rFrameFormat.GetHoriOrient() );
991 
992  // set calculated vertical position in order to determine correct
993  // frame, the horizontal position is oriented at.
994  const SwTwips nTopOfAnch = GetTopForObjPos( *pAnchorFrameForVertPos, aRectFnSet.FnRect(), aRectFnSet.IsVert() );
995  if( aRectFnSet.IsVert() )
996  {
997  // --> OD 2009-08-31 #mongolianlayout#
998  if ( !aRectFnSet.IsVertL2R() )
999  {
1000  GetAnchoredObj().SetObjLeft( nTopOfAnch -
1001  aRelPos.X() - aObjBoundRect.Width() );
1002  }
1003  else
1004  {
1005  GetAnchoredObj().SetObjLeft( nTopOfAnch + aRelPos.X() );
1006  }
1007  }
1008  else
1009  GetAnchoredObj().SetObjTop( nTopOfAnch + aRelPos.Y() );
1010 
1011  // determine frame, horizontal position is oriented at.
1012  // #i28701# - If floating screen object doesn't follow
1013  // the text flow, its horizontal position is oriented at <pOrientFrame>.
1014  const SwFrame* pHoriOrientFrame = DoesObjFollowsTextFlow()
1016  : pOrientFrame;
1017 
1018  // #i26791# - get 'horizontal' offset to frame anchor position.
1019  SwTwips nHoriOffsetToFrameAnchorPos( 0 );
1020  SwTwips nRelPosX = CalcRelPosX( *pHoriOrientFrame, aEnvOfObj,
1021  aHori, rLR, rUL, bWrapThrough,
1022  ( aRectFnSet.IsVert() ? aRelPos.X() : aRelPos.Y() ),
1023  nHoriOffsetToFrameAnchorPos );
1024 
1025  // #i26791# - determine offset to 'horizontal' frame
1026  // anchor position, depending on layout-direction
1027  if ( aRectFnSet.IsVert() )
1028  {
1029  aRelPos.setY( nRelPosX );
1030  maOffsetToFrameAnchorPos.setY( nHoriOffsetToFrameAnchorPos );
1031  }
1032  else
1033  {
1034  aRelPos.setX( nRelPosX );
1035  maOffsetToFrameAnchorPos.setX( nHoriOffsetToFrameAnchorPos );
1036  }
1037 
1038  // save calculated horizontal position - needed for filters
1039  // (including the xml-filter)
1040  {
1041  SwTwips nAttrRelPosX = nRelPosX - nHoriOffsetToFrameAnchorPos;
1042  if ( aHori.GetHoriOrient() != text::HoriOrientation::NONE &&
1043  aHori.GetPos() != nAttrRelPosX )
1044  {
1045  aHori.SetPos( nAttrRelPosX );
1046  const_cast<SwFrameFormat&>(rFrameFormat).LockModify();
1047  const_cast<SwFrameFormat&>(rFrameFormat).SetFormatAttr( aHori );
1048  const_cast<SwFrameFormat&>(rFrameFormat).UnlockModify();
1049  }
1050  }
1051  }
1052 
1053  // set absolute position at object
1054  const SwTwips nTopOfAnch = GetTopForObjPos( *pAnchorFrameForVertPos, aRectFnSet.FnRect(), aRectFnSet.IsVert() );
1055  if( aRectFnSet.IsVert() )
1056  {
1057  // --> OD 2009-08-31 #mongolianlayout#
1058  if ( !aRectFnSet.IsVertL2R() )
1059  {
1060  GetAnchoredObj().SetObjLeft( nTopOfAnch -
1061  aRelPos.X() - aObjBoundRect.Width() );
1062  }
1063  else
1064  {
1065  GetAnchoredObj().SetObjLeft( nTopOfAnch + aRelPos.X() );
1066  }
1067  GetAnchoredObj().SetObjTop( rAnchorTextFrame.getFrameArea().Top() +
1068  aRelPos.Y() );
1069  }
1070  else
1071  {
1072  GetAnchoredObj().SetObjLeft( rAnchorTextFrame.getFrameArea().Left() +
1073  aRelPos.X() );
1074  GetAnchoredObj().SetObjTop( nTopOfAnch + aRelPos.Y() );
1075  }
1076 
1077  // set relative position at object
1078  GetAnchoredObj().SetCurrRelPos( aRelPos );
1079 }
1080 
1082  Point& rRelPos, const SwTwips nTopOfAnch)
1083 {
1084  const SwFrameFormat& rFrameFormat = GetFrameFormat();
1085  bool bAllowOverlap = rFrameFormat.GetWrapInfluenceOnObjPos().GetAllowOverlap();
1086  if (bAllowOverlap)
1087  {
1088  return;
1089  }
1090 
1091  if (rFrameFormat.GetSurround().GetSurround() == css::text::WrapTextMode_THROUGH)
1092  {
1093  // This is explicit wrap through: allowed to overlap.
1094  return;
1095  }
1096 
1097  if (SwTextBoxHelper::isTextBox(&rFrameFormat, RES_FLYFRMFMT))
1098  {
1099  // This is the frame part of a textbox, just take the offset from the textbox's shape part.
1100  SwFrameFormat* pShapeOfTextBox
1102  if (pShapeOfTextBox)
1103  {
1104  SwTwips nYDiff = pShapeOfTextBox->GetWrapInfluenceOnObjPos().GetOverlapVertOffset();
1105  if (nYDiff > 0)
1106  {
1107  rRelPos.setY(rRelPos.getY() + nYDiff + 1);
1108  GetAnchoredObj().SetObjTop(nTopOfAnch + rRelPos.Y());
1109  }
1110  }
1111  return;
1112  }
1113 
1114  // Get the list of objects.
1115  const SwSortedObjs& rSortedObjs = *pAnchorFrameForVertPos->GetDrawObjs();
1116  for (const auto& pAnchoredObj : rSortedObjs)
1117  {
1118  if (pAnchoredObj == &GetAnchoredObj())
1119  {
1120  // We found ourselves, stop iterating.
1121  break;
1122  }
1123 
1124  if (SwTextBoxHelper::isTextBox(&pAnchoredObj->GetFrameFormat(), RES_FLYFRMFMT))
1125  {
1126  // Overlapping with the frame of a textbox is fine.
1127  continue;
1128  }
1129 
1130  css::text::WrapTextMode eWrap = pAnchoredObj->GetFrameFormat().GetSurround().GetSurround();
1131  if (eWrap == css::text::WrapTextMode_THROUGH)
1132  {
1133  // The other object is wrap through: allowed to overlap.
1134  continue;
1135  }
1136 
1137  if (!GetAnchoredObj().GetObjRect().IsOver(pAnchoredObj->GetObjRect()))
1138  {
1139  // Found an already positioned object, but it doesn't overlap, ignore.
1140  continue;
1141  }
1142 
1143  // Already formatted, overlaps: resolve the conflict by shifting ourselves down.
1144  SwTwips nYDiff = pAnchoredObj->GetObjRect().Bottom() - GetAnchoredObj().GetObjRect().Top();
1145  rRelPos.setY(rRelPos.getY() + nYDiff + 1);
1146  GetAnchoredObj().SetObjTop(nTopOfAnch + rRelPos.Y());
1147 
1148  // Store our offset that avoids the overlap. If this is a shape of a textbox, then the frame
1149  // of the textbox will use it.
1150  SwFormatWrapInfluenceOnObjPos aInfluence(rFrameFormat.GetWrapInfluenceOnObjPos());
1151  aInfluence.SetOverlapVertOffset(nYDiff);
1152  const_cast<SwFrameFormat&>(rFrameFormat).LockModify();
1153  const_cast<SwFrameFormat&>(rFrameFormat).SetFormatAttr(aInfluence);
1154  const_cast<SwFrameFormat&>(rFrameFormat).UnlockModify();
1155  }
1156 }
1157 
1162  const SwLayoutFrame& _rProposedFrame ) const
1163 {
1164  const SwFrame* pHoriVirtAnchFrame = &_rProposedFrame;
1165 
1166  // Search for first lower content frame, which is the anchor or a follow
1167  // of the anchor (Note: <Anchor.IsAnFollow( Anchor )> is true)
1168  // If none found, <_rProposedFrame> is returned.
1169  const SwFrame* pFrame = _rProposedFrame.Lower();
1170  while ( pFrame )
1171  {
1172  if ( pFrame->IsContentFrame() &&
1173  GetAnchorTextFrame().IsAnFollow( static_cast<const SwContentFrame*>(pFrame) ) )
1174  {
1175  pHoriVirtAnchFrame = pFrame;
1176  break;
1177  }
1178  pFrame = pFrame->GetNext();
1179  }
1180 
1181  return *pHoriVirtAnchFrame;
1182 }
1183 
1184 
1185 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
long GetLeft() const
SwFrame * FindFooterOrHeader()
Definition: findfrm.cxx:547
void CheckCharRectAndTopOfLine(const bool _bCheckForParaPorInf)
check anchor character rectangle and top of line
Base class of the Writer layout elements.
Definition: frame.hxx:295
static bool lcl_DoesVertPosFits(const SwTwips _nRelPosY, const SwTwips _nAvail, const SwLayoutFrame *_pUpperOfOrientFrame, const bool _bBrowse, const bool _bGrowInTable, SwLayoutFrame *&_orpLayoutFrameToGrow)
const SwRect & GetLastCharRect() const
Represents the visualization of a paragraph.
Definition: txtfrm.hxx:149
virtual SwRect GetObjRect() const =0
long BottomDist(const SwRect &rRect, long nPos) const
Definition: frame.hxx:1390
const SwSortedObjs * GetDrawObjs() const
Definition: frame.hxx:543
bool IsInDocBody() const
Definition: frame.hxx:919
SwTwips Grow(SwTwips, bool bTst=false, bool bInfo=false)
Definition: wsfrm.cxx:1462
sal_uInt16 GetLower() const
bool IsInSct() const
Definition: frame.hxx:943
const SwLayoutFrame & GetVertEnvironmentLayoutFrame(const SwFrame &_rVertOrientFrame) const
determine environment layout frame for possible vertical object positions respectively for alignments...
void CalcOverlap(const SwTextFrame *pAnchorFrameForVertPos, Point &rRelPos, const SwTwips nTopOfAnch)
In case overlap is not allowed, re-position the current object.
const SwFormatVertOrient & GetVertOrient(bool=true) const
Definition: fmtornt.hxx:106
void Refresh(const SwFrame *pFrame)
Definition: frame.hxx:1335
bool IsInFootnote() const
Definition: frame.hxx:925
SwRectFn FnRect() const
Definition: frame.hxx:1345
const SwRect & getFramePrintArea() const
Definition: frame.hxx:176
SwTabFrame is one table in the document layout, containing rows (which contain cells).
Definition: tabfrm.hxx:30
long GetBottom(const SwRect &rRect) const
Definition: frame.hxx:1354
long SwTwips
Definition: swtypes.hxx:49
bool IsVert() const
Definition: frame.hxx:1343
Of course Writer needs its own rectangles.
Definition: swrect.hxx:34
long GetPrtTop(const SwFrame &rFrame) const
Definition: frame.hxx:1385
static SwFrameFormat * getOtherTextBoxFormat(const SwFrameFormat *pFormat, sal_uInt16 nType)
If we have an associated TextFrame, then return that.
bool IsFootnoteFrame() const
Definition: frame.hxx:1178
long YDiff(long n1, long n2) const
Definition: frame.hxx:1399
long GetPrtBottom(const SwFrame &rFrame) const
Definition: frame.hxx:1386
void SetCurrRelPos(Point _aRelPos)
void Top(const long nTop)
Definition: swrect.hxx:202
bool IsMoveable(const SwLayoutFrame *_pLayoutFrame=nullptr) const
determine, if frame is moveable in given environment
Definition: findfrm.cxx:1359
const SwRect & getFrameArea() const
Definition: frame.hxx:175
void setX(long nX)
bool getBrowseMode() const
Definition: viewopt.hxx:433
bool IsInTab() const
Definition: frame.hxx:931
static bool isTextBox(const SwFrameFormat *pFormat, sal_uInt16 nType)
Is the frame format a text box?
bool IsTextFrame() const
Definition: frame.hxx:1210
const SwFormatSurround & GetSurround(bool=true) const
Definition: fmtsrnd.hxx:66
void SetOverlapVertOffset(SwTwips nOverlapVertOffset)
bool IsSctFrame() const
Definition: frame.hxx:1190
void setY(long nY)
SwTextFrame * GetFollow()
Definition: txtfrm.hxx:848
void SetObjTop(const SwTwips _nTop)
long getY() const
long const nTopMargin
#define RES_FLYFRMFMT
Definition: hintids.hxx:276
bool IsColumnFrame() const
Definition: frame.hxx:1158
virtual void CalcPosition() override
calculate position of object
SwTwips AdjustVertRelPos(const SwTwips nTopOfAnch, const bool bVert, const bool bVertL2R, const SwFrame &rPageAlignLayFrame, const SwTwips nProposedRelPosY, const bool bFollowTextFlow, const bool bCheckBottom=true) const
adjust calculated vertical in order to keep object inside 'page' alignment layout frame...
Style of a layout element.
Definition: frmfmt.hxx:57
TextFrameIndex MapModelToViewPos(SwPosition const &rPos) const
Definition: txtfrm.cxx:1257
bool IsContentFrame() const
Definition: frame.hxx:1206
SwFrame * GetIndPrev() const
Definition: frame.hxx:702
const SwFormatAnchor & GetAnchor(bool=true) const
Definition: fmtanchr.hxx:81
RndStdIds GetAnchorId() const
Definition: fmtanchr.hxx:65
const SwFormatHoriOrient & GetHoriOrient(bool=true) const
Definition: fmtornt.hxx:108
const SwPosition * GetContentAnchor() const
Definition: fmtanchr.hxx:67
SwPageFrame * FindPageFrame()
Definition: frame.hxx:658
const SwFrame * Lower() const
Definition: layfrm.hxx:101
FlyAnchors.
Definition: fmtanchr.hxx:34
SwTwips CalcRelPosX(const SwFrame &_rHoriOrientFrame, const SwEnvironmentOfAnchoredObject &_rEnvOfObj, const SwFormatHoriOrient &_rHoriOrient, const SvxLRSpaceItem &_rLRSpacing, const SvxULSpaceItem &_rULSpacing, const bool _bObjWrapThrough, const SwTwips _nRelPosY, SwTwips &_roHoriOffsetToFrameAnchorPos) const
calculate relative horizontal position
sal_uInt8 GetHeightPercent() const
Definition: fmtfsize.hxx:88
SwLayoutFrame * GetUpper()
Definition: frame.hxx:656
long GetTopMargin(const SwFrame &rFrame) const
Definition: frame.hxx:1379
css::text::WrapTextMode GetSurround() const
Definition: fmtsrnd.hxx:51
A page of the document layout.
Definition: pagefrm.hxx:40
long X() const
SwSectionFrame * FindSctFrame()
Definition: frame.hxx:1091
void Left(const long nLeft)
Definition: swrect.hxx:193
const SvxULSpaceItem & GetULSpace(bool=true) const
Definition: frmatr.hxx:76
SwLayoutFrame * GetLeaf(MakePageType eMakePage, bool bFwd)
Definition: flowfrm.cxx:784
MakePageType
Definition: frame.hxx:110
const SwViewOption * GetViewOptions() const
Definition: viewsh.hxx:426
void Width(long nNew)
Definition: swrect.hxx:185
SwTwips GetLastTopOfLine() const
bool IsVertL2R() const
Definition: frame.hxx:1344
void GetVertAlignmentValues(const SwFrame &_rVertOrientFrame, const SwFrame &_rPageAlignLayFrame, const sal_Int16 _eRelOrient, SwTwips &_orAlignAreaHeight, SwTwips &_orAlignAreaOffset) const
long GetHeight(const SwRect &rRect) const
Definition: frame.hxx:1358
const SwFormatWrapInfluenceOnObjPos & GetWrapInfluenceOnObjPos(bool=true) const
bool IsAnFollow(const SwFlowFrame *pFlow) const
Definition: flowfrm.cxx:668
const SwFormatFrameSize & GetFrameSize(bool=true) const
Definition: fmtfsize.hxx:104
long GetRight() const
SwTwips GetTopForObjPos(const SwFrame &_rFrame, const SwRectFn &_fnRect, const bool _bVert) const
helper method to determine top of a frame for the vertical object positioning
void SetObjLeft(const SwTwips _nLeft)
long GetTop(const SwRect &rRect) const
Definition: frame.hxx:1353
A layout frame is a frame that contains other frames (m_pLower), e.g. SwPageFrame or SwTabFrame...
Definition: layfrm.hxx:35
const SwFrame & GetHoriVirtualAnchor(const SwLayoutFrame &_pProposedFrame) const
determine frame for horizontal position
SwViewShell * GetCurrShell() const
Definition: rootfrm.hxx:204
class for collecting anchored objects
Definition: sortedobjs.hxx:48
bool IsFooterFrame() const
Definition: frame.hxx:1170
SwRootFrame * getRootFrame()
Definition: frame.hxx:657
long Y() const
sal_uInt16 GetUpper() const
SwTabFrame * FindTabFrame()
Definition: frame.hxx:1075
SwFrame * GetNext()
Definition: frame.hxx:654
const SvxLRSpaceItem & GetLRSpace(bool=true) const
Definition: frmatr.hxx:74