LibreOffice Module sw (master)  1
flycnt.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 <sal/log.hxx>
21 #include <osl/diagnose.h>
22 #include <svx/swframetypes.hxx>
23 #include <pagefrm.hxx>
24 #include <txtfrm.hxx>
25 #include <notxtfrm.hxx>
26 #include <doc.hxx>
27 #include <pam.hxx>
28 #include <IDocumentUndoRedo.hxx>
31 #include <frmtool.hxx>
32 #include <dflyobj.hxx>
33 #include <hints.hxx>
34 #include <fmtanchr.hxx>
35 #include <fmtornt.hxx>
36 #include <fmtfsize.hxx>
37 #include <fmtsrnd.hxx>
38 #include <txatbase.hxx>
39 
40 #include <tabfrm.hxx>
41 #include <flyfrms.hxx>
42 #include <crstate.hxx>
43 #include <sectfrm.hxx>
44 
46 #include <sortedobjs.hxx>
47 #include <layouter.hxx>
49 #include <HandleAnchorNodeChg.hxx>
50 #include <ndtxt.hxx>
51 #include <textboxhelper.hxx>
52 #include <fmtfollowtextflow.hxx>
53 #include <unoprnms.hxx>
54 
55 using namespace ::com::sun::star;
56 
57 namespace
58 {
59 
60 SwTwips lcl_GetTopForObjPos(const SwContentFrame* pCnt, const bool bVert, const bool bVertL2R)
61 {
62  if ( bVert )
63  {
64  SwTwips aResult = pCnt->getFrameArea().Left();
65  if ( bVertL2R )
67  else
69  return aResult;
70  }
71  else
73 }
74 
75 }
76 
78  SwFlyFreeFrame( pFormat, pSib, pAnch )
79 {
80  m_bAtCnt = true;
81  m_bAutoPosition = (RndStdIds::FLY_AT_CHAR == pFormat->GetAnchor().GetAnchorId());
82 }
83 
84 // #i28701#
85 
86 void SwFlyAtContentFrame::SwClientNotify(const SwModify& rMod, const SfxHint& rHint)
87 {
88  auto pLegacy = dynamic_cast<const sw::LegacyModifyHint*>(&rHint);
89  if(!pLegacy)
90  return;
91  const SwFormatAnchor* pAnch = pLegacy->m_pNew ? GetAnchorFromPoolItem(*pLegacy->m_pNew) : nullptr;
92  if(!pAnch)
93  {
94  SwFlyFrame::SwClientNotify(rMod, rHint);
95  return;
96  }
97  OSL_ENSURE(pAnch->GetAnchorId() == GetFormat()->GetAnchor().GetAnchorId(),
98  "Illegal change of anchor type.");
99 
100  //Unregister, get hold of a new anchor and attach it
102  SwPageFrame* pOldPage = FindPageFrame();
103  const SwFrame* pOldAnchor = GetAnchorFrame();
104  SwContentFrame* pContent = const_cast<SwContentFrame*>(static_cast<const SwContentFrame*>(GetAnchorFrame()));
105  AnchorFrame()->RemoveFly(this);
106 
107  const bool bBodyFootnote = (pContent->IsInDocBody() || pContent->IsInFootnote());
108 
109  // Search the new anchor using the NodeIdx; the relation between old
110  // and new NodeIdx determines the search direction
111  const SwNodeIndex aNewIdx(pAnch->GetContentAnchor()->nNode);
112  SwNodeIndex aOldIdx(pContent->IsTextFrame()
113  // sw_redlinehide: can pick any node here, the compare with
114  // FrameContainsNode should catch it
115  ? *static_cast<SwTextFrame *>(pContent)->GetTextNodeFirst()
116  : *static_cast<SwNoTextFrame *>(pContent)->GetNode());
117 
118  //fix: depending on which index was smaller, searching in the do-while
119  //loop previously was done forward or backwards respectively. This however
120  //could lead to an infinite loop. To at least avoid the loop, searching
121  //is now done in only one direction. Getting hold of a frame from the node
122  //is still possible if the new anchor could not be found. Chances are
123  //good that this will be the correct one.
124  // consider the case that at found anchor frame candidate already a
125  // fly frame of the given fly format is registered.
126  // consider, that <pContent> is the already
127  // the new anchor frame.
128  bool bFound(FrameContainsNode(*pContent, aNewIdx.GetIndex()));
129  const bool bNext = !bFound && aOldIdx < aNewIdx;
130  while(pContent && !bFound)
131  {
132  do
133  {
134  if(bNext)
135  pContent = pContent->GetNextContentFrame();
136  else
137  pContent = pContent->GetPrevContentFrame();
138  } while(pContent &&
139  (bBodyFootnote != (pContent->IsInDocBody() || pContent->IsInFootnote())));
140  if(pContent)
141  bFound = FrameContainsNode(*pContent, aNewIdx.GetIndex());
142 
143  // check, if at found anchor frame candidate already a fly frame
144  // of the given fly frame format is registered.
145  if(bFound && pContent && pContent->GetDrawObjs())
146  {
147  SwFrameFormat* pMyFlyFrameFormat(&GetFrameFormat());
148  SwSortedObjs &rObjs = *pContent->GetDrawObjs();
149  for(SwAnchoredObject* rObj : rObjs)
150  {
151  SwFlyFrame* pFlyFrame = dynamic_cast<SwFlyFrame*>(rObj);
152  if (pFlyFrame &&
153  &(pFlyFrame->GetFrameFormat()) == pMyFlyFrameFormat)
154  {
155  bFound = false;
156  break;
157  }
158  }
159  }
160  }
161  if(!pContent)
162  {
163  SwContentNode *pNode = aNewIdx.GetNode().GetContentNode();
164  std::pair<Point, bool> const tmp(pOldAnchor->getFrameArea().Pos(), false);
165  pContent = pNode->getLayoutFrame(getRootFrame(), nullptr, &tmp);
166  OSL_ENSURE(pContent, "New anchor not found");
167  }
168  //Flys are never attached to a follow, but always on the master which
169  //we are going to search now.
170  SwContentFrame* pFlow = pContent;
171  while(pFlow->IsFollow())
172  pFlow = pFlow->FindMaster();
173  pContent = pFlow;
174 
175  //and *puff* it's attached...
176  pContent->AppendFly( this );
177  if(pOldPage && pOldPage != FindPageFrame())
179 
180  //Fix(3495)
181  InvalidatePos_();
182  InvalidatePage();
183  SetNotifyBack();
184  // #i28701# - reset member <maLastCharRect> and
185  // <mnLastTopOfLine> for to-character anchored objects.
187 }
188 
189 //We need some helper classes to monitor the oscillation and a few functions
190 //to not get lost.
191 
192 namespace {
193 
194 // #i3317# - re-factoring of the position stack
195 class SwOszControl
196 {
197  static const SwFlyFrame* s_pStack1;
198  static const SwFlyFrame* s_pStack2;
199  static const SwFlyFrame* s_pStack3;
200  static const SwFlyFrame* s_pStack4;
201  static const SwFlyFrame* s_pStack5;
202 
203  const SwFlyFrame* m_pFly;
204  std::vector<Point> maObjPositions;
205 
206 public:
207  explicit SwOszControl( const SwFlyFrame *pFrame );
208  ~SwOszControl();
209  bool ChkOsz();
210  static bool IsInProgress( const SwFlyFrame *pFly );
211 };
212 
213 }
214 
215 const SwFlyFrame* SwOszControl::s_pStack1 = nullptr;
216 const SwFlyFrame* SwOszControl::s_pStack2 = nullptr;
217 const SwFlyFrame* SwOszControl::s_pStack3 = nullptr;
218 const SwFlyFrame* SwOszControl::s_pStack4 = nullptr;
219 const SwFlyFrame* SwOszControl::s_pStack5 = nullptr;
220 
221 SwOszControl::SwOszControl(const SwFlyFrame* pFrame)
222  : m_pFly(pFrame)
223 {
224  if (!SwOszControl::s_pStack1)
225  SwOszControl::s_pStack1 = m_pFly;
226  else if (!SwOszControl::s_pStack2)
227  SwOszControl::s_pStack2 = m_pFly;
228  else if (!SwOszControl::s_pStack3)
229  SwOszControl::s_pStack3 = m_pFly;
230  else if (!SwOszControl::s_pStack4)
231  SwOszControl::s_pStack4 = m_pFly;
232  else if (!SwOszControl::s_pStack5)
233  SwOszControl::s_pStack5 = m_pFly;
234 }
235 
236 SwOszControl::~SwOszControl()
237 {
238  if (SwOszControl::s_pStack1 == m_pFly)
239  SwOszControl::s_pStack1 = nullptr;
240  else if (SwOszControl::s_pStack2 == m_pFly)
241  SwOszControl::s_pStack2 = nullptr;
242  else if (SwOszControl::s_pStack3 == m_pFly)
243  SwOszControl::s_pStack3 = nullptr;
244  else if (SwOszControl::s_pStack4 == m_pFly)
245  SwOszControl::s_pStack4 = nullptr;
246  else if (SwOszControl::s_pStack5 == m_pFly)
247  SwOszControl::s_pStack5 = nullptr;
248  // #i3317#
249  maObjPositions.clear();
250 }
251 
252 bool SwOszControl::IsInProgress( const SwFlyFrame *pFly )
253 {
254  if (SwOszControl::s_pStack1 && !pFly->IsLowerOf(SwOszControl::s_pStack1))
255  return true;
256  if (SwOszControl::s_pStack2 && !pFly->IsLowerOf(SwOszControl::s_pStack2))
257  return true;
258  if (SwOszControl::s_pStack3 && !pFly->IsLowerOf(SwOszControl::s_pStack3))
259  return true;
260  if (SwOszControl::s_pStack4 && !pFly->IsLowerOf(SwOszControl::s_pStack4))
261  return true;
262  if (SwOszControl::s_pStack5 && !pFly->IsLowerOf(SwOszControl::s_pStack5))
263  return true;
264  return false;
265 }
266 
267 bool SwOszControl::ChkOsz()
268 {
269  bool bOscillationDetected = false;
270 
271  if ( maObjPositions.size() == 20 )
272  {
273  // #i3317# position stack is full -> oscillation
274  bOscillationDetected = true;
275  }
276  else
277  {
278  Point aNewObjPos = m_pFly->GetObjRect().Pos();
279  for ( auto const & pt : maObjPositions )
280  {
281  if ( aNewObjPos == pt )
282  {
283  // position already occurred -> oscillation
284  bOscillationDetected = true;
285  break;
286  }
287  }
288  if ( !bOscillationDetected )
289  {
290  maObjPositions.push_back( aNewObjPos );
291  }
292  }
293 
294  return bOscillationDetected;
295 }
296 
314 {
315  if ( !GetFormat()->GetDoc()->getIDocumentDrawModelAccess().IsVisibleLayerId( GetVirtDrawObj()->GetLayer() ) )
316  {
317  return;
318  }
319 
320  if ( SwOszControl::IsInProgress( this ) || IsLocked() || IsColLocked() )
321  return;
322 
323  // #i28701# - use new method <GetPageFrame()>
324  if( !GetPageFrame() && GetAnchorFrame() && GetAnchorFrame()->IsInFly() )
325  {
326  SwFlyFrame* pFly = AnchorFrame()->FindFlyFrame();
327  SwPageFrame *pTmpPage = pFly ? pFly->FindPageFrame() : nullptr;
328  if( pTmpPage )
329  pTmpPage->AppendFlyToPage( this );
330  }
331  // #i28701# - use new method <GetPageFrame()>
332  if( !GetPageFrame() )
333  return;
334 
336  {
337  SwFlyFrameFormat *pFormat = GetFormat();
338  const SwFormatFrameSize &rFrameSz = GetFormat()->GetFrameSize();
339  if( rFrameSz.GetHeightPercent() != SwFormatFrameSize::SYNCED &&
340  rFrameSz.GetHeightPercent() >= 100 )
341  {
342  pFormat->LockModify();
343  SwFormatSurround aMain( pFormat->GetSurround() );
344  if ( aMain.GetSurround() == css::text::WrapTextMode_NONE )
345  {
346  aMain.SetSurround( css::text::WrapTextMode_THROUGH );
347  pFormat->SetFormatAttr( aMain );
348  }
349  pFormat->UnlockModify();
350  }
351  }
352 
353  SwOszControl aOszCntrl( this );
354 
355  // #i43255#
356  // #i50356# - format the anchor frame, which
357  // contains the anchor position. E.g., for at-character anchored
358  // object this can be the follow frame of the anchor frame.
359  const bool bFormatAnchor =
360  !static_cast<const SwTextFrame*>( GetAnchorFrameContainingAnchPos() )->IsAnyJoinLocked() &&
363 
364  const SwFrame* pFooter = GetAnchorFrame()->FindFooterOrHeader();
365  if( pFooter && !pFooter->IsFooterFrame() )
366  pFooter = nullptr;
367  bool bOsz = false;
368  bool bExtra = Lower() && Lower()->IsColumnFrame();
369  // #i3317# - boolean, to apply temporarily the
370  // 'straightforward positioning process' for the frame due to its
371  // overlapping with a previous column.
372  bool bConsiderWrapInfluenceDueToOverlapPrevCol( false );
373  // #i35911# - boolean, to apply temporarily the
374  // 'straightforward positioning process' for the frame due to fact
375  // that it causes the complete content of its layout environment
376  // to move forward.
377  // #i40444# - extend usage of this boolean:
378  // apply temporarily the 'straightforward positioning process' for
379  // the frame due to the fact that the frame clears the area for
380  // the anchor frame, thus it has to move forward.
381  bool bConsiderWrapInfluenceDueToMovedFwdAnchor( false );
382  do {
383  SwRectFnSet aRectFnSet(this);
384  Point aOldPos( aRectFnSet.GetPos(getFrameArea()) );
385  SwFlyFreeFrame::MakeAll(pRenderContext);
386 
387  const bool bPosChgDueToOwnFormat =
388  aOldPos != aRectFnSet.GetPos(getFrameArea());
389  // #i3317#
392  {
393  bConsiderWrapInfluenceDueToOverlapPrevCol = true;
394  }
395  // #i28701# - no format of anchor frame, if
396  // wrapping style influence is considered on object positioning
397  if ( bFormatAnchor )
398  {
399  SwTextFrame& rAnchPosAnchorFrame =
400  dynamic_cast<SwTextFrame&>(*GetAnchorFrameContainingAnchPos());
401  // #i58182# - For the usage of new method
402  // <SwObjectFormatterTextFrame::CheckMovedFwdCondition(..)>
403  // to check move forward of anchor frame due to the object
404  // positioning it's needed to know, if the object is anchored
405  // at the master frame before the anchor frame is formatted.
406  const bool bAnchoredAtMaster(!rAnchPosAnchorFrame.IsFollow());
407 
408  // #i56300#
409  // perform complete format of anchor text frame and its
410  // previous frames, which have become invalid due to the
411  // fly frame format.
413  // #i35911#
414  // #i40444#
415  // #i58182# - usage of new method
416  // <SwObjectFormatterTextFrame::CheckMovedFwdCondition(..)>
417  sal_uInt32 nToPageNum( 0 );
418  bool bDummy( false );
420  *this, GetPageFrame()->GetPhyPageNum(),
421  bAnchoredAtMaster, nToPageNum, bDummy ) )
422  {
423  bConsiderWrapInfluenceDueToMovedFwdAnchor = true;
424  // mark anchor text frame
425  // directly, that it is moved forward by object positioning.
426  SwTextFrame* pAnchorTextFrame( static_cast<SwTextFrame*>(AnchorFrame()) );
427  bool bInsert( true );
428  sal_uInt32 nAnchorFrameToPageNum( 0 );
429  const SwDoc& rDoc = *(GetFrameFormat().GetDoc());
431  rDoc, *pAnchorTextFrame, nAnchorFrameToPageNum ) )
432  {
433  if ( nAnchorFrameToPageNum < nToPageNum )
434  SwLayouter::RemoveMovedFwdFrame( rDoc, *pAnchorTextFrame );
435  else
436  bInsert = false;
437  }
438  if ( bInsert )
439  {
440  SwLayouter::InsertMovedFwdFrame( rDoc, *pAnchorTextFrame,
441  nToPageNum );
442  }
443  }
444  }
445 
446  if ( aOldPos != aRectFnSet.GetPos(getFrameArea()) ||
448  ( pFooter || bPosChgDueToOwnFormat ) ) )
449  {
450  bOsz = aOszCntrl.ChkOsz();
451 
452  // special loop prevention for dedicated document:
453  if ( bOsz &&
454  HasFixSize() && IsClipped() &&
456  {
457  SwFrameFormat* pFormat = GetFormat();
458  const SwFormatFrameSize& rFrameSz = pFormat->GetFrameSize();
459  if ( rFrameSz.GetWidthPercent() &&
461  {
462  SwFormatSurround aSurround( pFormat->GetSurround() );
463  if ( aSurround.GetSurround() == css::text::WrapTextMode_NONE )
464  {
465  pFormat->LockModify();
466  aSurround.SetSurround( css::text::WrapTextMode_THROUGH );
467  pFormat->SetFormatAttr( aSurround );
468  pFormat->UnlockModify();
469  bOsz = false;
470  OSL_FAIL( "<SwFlyAtContentFrame::MakeAll()> - special loop prevention for dedicated document of b6403541 applied" );
471  }
472  }
473  }
474  }
475 
476  if ( bExtra && Lower() && !Lower()->isFrameAreaPositionValid() )
477  {
478  // If a multi column frame leaves invalid columns because of
479  // a position change, we loop once more and format
480  // our content using FormatWidthCols again.
481  InvalidateSize_();
482  bExtra = false; // Ensure only one additional loop run
483  }
484  } while ( !isFrameAreaDefinitionValid() && !bOsz &&
485  // #i3317#
486  !bConsiderWrapInfluenceDueToOverlapPrevCol &&
487  // #i40444#
488  !bConsiderWrapInfluenceDueToMovedFwdAnchor &&
489  GetFormat()->GetDoc()->getIDocumentDrawModelAccess().IsVisibleLayerId( GetVirtDrawObj()->GetLayer() ) );
490 
491  // #i3317# - instead of attribute change apply
492  // temporarily the 'straightforward positioning process'.
493  // #i80924#
494  // handle special case during splitting of table rows
495  if ( bConsiderWrapInfluenceDueToMovedFwdAnchor &&
496  GetAnchorFrame()->IsInTab() &&
498  {
499  const SwFrame* pCellFrame = GetAnchorFrame();
500  while ( pCellFrame && !pCellFrame->IsCellFrame() )
501  {
502  pCellFrame = pCellFrame->GetUpper();
503  }
504  if ( pCellFrame )
505  {
506  SwRectFnSet aRectFnSet(pCellFrame);
507  if ( aRectFnSet.GetTop(pCellFrame->getFrameArea()) == 0 &&
508  aRectFnSet.GetHeight(pCellFrame->getFrameArea()) == 0 )
509  {
510  bConsiderWrapInfluenceDueToMovedFwdAnchor = false;
511  }
512  }
513  }
514  // tdf#137803: Fix the position of the shape during autoSize
515  SwFrameFormat* pShapeFormat
517  // FIXME: According to tdf37153, ignore FollowTextFlow objs, because
518  // wrong position will applied in that case. FollowTextFlow needs fix.
519  if (pShapeFormat && !pShapeFormat->GetFollowTextFlow().GetValue() &&
520  SwTextBoxHelper::getProperty(pShapeFormat,
521  UNO_NAME_FRAME_ISAUTOMATIC_HEIGHT).get<bool>() )
522  {
523  // get the text area of the shape
524  const tools::Rectangle aTextRectangle
525  = SwTextBoxHelper::getTextRectangle(pShapeFormat, false);
526  // get the original textframe position
527  SwFormatHoriOrient aHOri = pShapeFormat->GetHoriOrient();
528  SwFormatVertOrient aVOri = pShapeFormat->GetVertOrient();
529  // calc the right position of the shape depending on text area
530  aHOri.SetPos(aHOri.GetPos() + aTextRectangle.getX());
531  aVOri.SetPos(aVOri.GetPos() + aTextRectangle.getY());
532  // save the new position for the shape
533  GetFormat()->SetFormatAttr(aHOri);
534  GetFormat()->SetFormatAttr(aVOri);
535  }
536  if ( bOsz || bConsiderWrapInfluenceDueToOverlapPrevCol ||
537  // #i40444#
538  bConsiderWrapInfluenceDueToMovedFwdAnchor )
539  {
541  SetRestartLayoutProcess( true );
543  }
545 }
546 
552 {
554  !SwOszControl::IsInProgress( this );
555 }
556 
557 namespace {
558 
559 class SwDistance
560 {
561 public:
562  SwTwips m_nMain, m_nSub;
563  SwDistance()
564  : m_nMain(0)
565  , m_nSub(0)
566  {
567  }
568  bool operator<( const SwDistance& rTwo ) const
569  {
570  return m_nMain < rTwo.m_nMain
571  || (m_nMain == rTwo.m_nMain && m_nSub && rTwo.m_nSub && m_nSub < rTwo.m_nSub);
572  }
573  bool operator<=( const SwDistance& rTwo ) const
574  {
575  return m_nMain < rTwo.m_nMain
576  || (m_nMain == rTwo.m_nMain
577  && (!m_nSub || !rTwo.m_nSub || m_nSub <= rTwo.m_nSub));
578  }
579 };
580 
581 }
582 
583 static const SwFrame * lcl_CalcDownDist( SwDistance &rRet,
584  const Point &rPt,
585  const SwContentFrame *pCnt )
586 {
587  rRet.m_nSub = 0;
588  //If the point stays inside the Cnt everything is clear already; the Content
589  //automatically has a distance of 0.
590  if ( pCnt->getFrameArea().IsInside( rPt ) )
591  {
592  rRet.m_nMain = 0;
593  return pCnt;
594  }
595  else
596  {
597  const SwLayoutFrame *pUp = pCnt->IsInTab() ? pCnt->FindTabFrame()->GetUpper() : pCnt->GetUpper();
598  // single column sections need to interconnect to their upper
599  while( pUp->IsSctFrame() )
600  pUp = pUp->GetUpper();
601  const bool bVert = pUp->IsVertical();
602 
603  const bool bVertL2R = pUp->IsVertLR();
604 
605  //Follow the text flow.
606  // #i70582#
607  // --> OD 2009-03-05 - adopted for Support for Classical Mongolian Script
608  const SwTwips nTopForObjPos = lcl_GetTopForObjPos(pCnt, bVert, bVertL2R);
609  if ( pUp->getFrameArea().IsInside( rPt ) )
610  {
611  // <rPt> point is inside environment of given content frame
612  // #i70582#
613  if( bVert )
614  {
615  if ( bVertL2R )
616  rRet.m_nMain = rPt.X() - nTopForObjPos;
617  else
618  rRet.m_nMain = nTopForObjPos - rPt.X();
619  }
620  else
621  rRet.m_nMain = rPt.Y() - nTopForObjPos;
622  return pCnt;
623  }
624  else if ( rPt.Y() <= pUp->getFrameArea().Top() )
625  {
626  // <rPt> point is above environment of given content frame
627  // correct for vertical layout?
628  rRet.m_nMain = LONG_MAX;
629  }
630  else if( rPt.X() < pUp->getFrameArea().Left() &&
631  rPt.Y() <= ( bVert ? pUp->getFrameArea().Top() : pUp->getFrameArea().Bottom() ) )
632  {
633  // <rPt> point is left of environment of given content frame
634  // seems not to be correct for vertical layout!?
635  const SwFrame *pLay = pUp->GetLeaf( MAKEPAGE_NONE, false, pCnt );
636  if( !pLay ||
637  (bVert && (pLay->getFrameArea().Top() + pLay->getFramePrintArea().Bottom()) <rPt.Y())||
638  (!bVert && (pLay->getFrameArea().Left() + pLay->getFramePrintArea().Right())<rPt.X()) )
639  {
640  // <rPt> point is in left border of environment
641  // #i70582#
642  if( bVert )
643  {
644  if ( bVertL2R )
645  rRet.m_nMain = rPt.X() - nTopForObjPos;
646  else
647  rRet.m_nMain = nTopForObjPos - rPt.X();
648  }
649  else
650  rRet.m_nMain = rPt.Y() - nTopForObjPos;
651  return pCnt;
652  }
653  else
654  rRet.m_nMain = LONG_MAX;
655  }
656  else
657  {
658  rRet.m_nMain
659  = bVert ? (bVertL2R
660  ? ((pUp->getFrameArea().Left() + pUp->getFramePrintArea().Right())
661  - nTopForObjPos)
662  : (nTopForObjPos
663  - (pUp->getFrameArea().Left() + pUp->getFramePrintArea().Left())))
664  : ((pUp->getFrameArea().Top() + pUp->getFramePrintArea().Bottom())
665  - nTopForObjPos);
666 
667  const SwFrame *pPre = pCnt;
668  const SwFrame *pLay = pUp->GetLeaf( MAKEPAGE_NONE, true, pCnt );
669  SwTwips nFrameTop = 0;
670  SwTwips nPrtHeight = 0;
671  bool bSct = false;
672  const SwSectionFrame *pSect = pUp->FindSctFrame();
673  if( pSect )
674  {
675  rRet.m_nSub = rRet.m_nMain;
676  rRet.m_nMain = 0;
677  }
678  if( pSect && !pSect->IsAnLower( pLay ) )
679  {
680  bSct = false;
681  const SwSectionFrame* pNxtSect = pLay ? pLay->FindSctFrame() : nullptr;
682  if (pSect->IsAnFollow(pNxtSect) && pLay)
683  {
684  if( pLay->IsVertical() )
685  {
686  if ( pLay->IsVertLR() )
687  nFrameTop = pLay->getFrameArea().Left();
688  else
689  nFrameTop = pLay->getFrameArea().Left() + pLay->getFrameArea().Width();
690  nPrtHeight = pLay->getFramePrintArea().Width();
691  }
692  else
693  {
694  nFrameTop = pLay->getFrameArea().Top();
695  nPrtHeight = pLay->getFramePrintArea().Height();
696  }
697  pSect = pNxtSect;
698  }
699  else
700  {
701  pLay = pSect->GetUpper();
702  if( pLay->IsVertical() )
703  {
704  if ( pLay->IsVertLR() )
705  {
706  nFrameTop = pSect->getFrameArea().Right();
707  nPrtHeight = pLay->getFrameArea().Left() + pLay->getFramePrintArea().Left()
708  + pLay->getFramePrintArea().Width() - pSect->getFrameArea().Left()
709  - pSect->getFrameArea().Width();
710  }
711  else
712  {
713  nFrameTop = pSect->getFrameArea().Left();
714  nPrtHeight = pSect->getFrameArea().Left() - pLay->getFrameArea().Left()
715  - pLay->getFramePrintArea().Left();
716  }
717  }
718  else
719  {
720  nFrameTop = pSect->getFrameArea().Bottom();
721  nPrtHeight = pLay->getFrameArea().Top() + pLay->getFramePrintArea().Top()
722  + pLay->getFramePrintArea().Height() - pSect->getFrameArea().Top()
723  - pSect->getFrameArea().Height();
724  }
725  pSect = nullptr;
726  }
727  }
728  else if( pLay )
729  {
730  if( pLay->IsVertical() )
731  {
732  if ( pLay->IsVertLR() )
733  {
734  nFrameTop = pLay->getFrameArea().Left();
735  nPrtHeight = pLay->getFramePrintArea().Width();
736  }
737  else
738  {
739  nFrameTop = pLay->getFrameArea().Left() + pLay->getFrameArea().Width();
740  nPrtHeight = pLay->getFramePrintArea().Width();
741  }
742  }
743  else
744  {
745  nFrameTop = pLay->getFrameArea().Top();
746  nPrtHeight = pLay->getFramePrintArea().Height();
747  }
748  bSct = nullptr != pSect;
749  }
750  while ( pLay && !pLay->getFrameArea().IsInside( rPt ) &&
751  ( pLay->getFrameArea().Top() <= rPt.Y() || pLay->IsInFly() ||
752  ( pLay->IsInSct() &&
753  pLay->FindSctFrame()->GetUpper()->getFrameArea().Top() <= rPt.Y())) )
754  {
755  if ( pLay->IsFootnoteContFrame() )
756  {
757  if ( !static_cast<const SwLayoutFrame*>(pLay)->Lower() )
758  {
759  SwFrame *pDel = const_cast<SwFrame*>(pLay);
760  pDel->Cut();
761  SwFrame::DestroyFrame(pDel);
762  return pPre;
763  }
764  return nullptr;
765  }
766  else
767  {
768  if( bSct || pSect )
769  rRet.m_nSub += nPrtHeight;
770  else
771  rRet.m_nMain += nPrtHeight;
772  pPre = pLay;
773  pLay = pLay->GetLeaf( MAKEPAGE_NONE, true, pCnt );
774  if( pSect && !pSect->IsAnLower( pLay ) )
775  { // If we're leaving a SwSectionFrame, the next Leaf-Frame
776  // is the part of the upper below the SectionFrame.
777  const SwSectionFrame* pNxtSect = pLay ?
778  pLay->FindSctFrame() : nullptr;
779  bSct = false;
780  if (pLay && pSect->IsAnFollow(pNxtSect))
781  {
782  pSect = pNxtSect;
783  if( pLay->IsVertical() )
784  {
785  if ( pLay->IsVertLR() )
786  {
787  nFrameTop = pLay->getFrameArea().Left();
788  nPrtHeight = pLay->getFramePrintArea().Width();
789  }
790  else
791  {
792  nFrameTop = pLay->getFrameArea().Left() + pLay->getFrameArea().Width();
793  nPrtHeight = pLay->getFramePrintArea().Width();
794  }
795  }
796  else
797  {
798  nFrameTop = pLay->getFrameArea().Top();
799  nPrtHeight = pLay->getFramePrintArea().Height();
800  }
801  }
802  else
803  {
804  pLay = pSect->GetUpper();
805  if( pLay->IsVertical() )
806  {
807  if ( pLay->IsVertLR() )
808  {
809  nFrameTop = pSect->getFrameArea().Right();
810  nPrtHeight = pLay->getFrameArea().Left()+pLay->getFramePrintArea().Left()
811  + pLay->getFramePrintArea().Width() - pSect->getFrameArea().Left()
812  - pSect->getFrameArea().Width();
813  }
814  else
815  {
816  nFrameTop = pSect->getFrameArea().Left();
817  nPrtHeight = pSect->getFrameArea().Left() -
818  pLay->getFrameArea().Left() - pLay->getFramePrintArea().Left();
819  }
820  }
821  else
822  {
823  nFrameTop = pSect->getFrameArea().Bottom();
824  nPrtHeight = pLay->getFrameArea().Top()+pLay->getFramePrintArea().Top()
825  + pLay->getFramePrintArea().Height() - pSect->getFrameArea().Top()
826  - pSect->getFrameArea().Height();
827  }
828  pSect = nullptr;
829  }
830  }
831  else if( pLay )
832  {
833  if( pLay->IsVertical() )
834  {
835  if ( pLay->IsVertLR() )
836  {
837  nFrameTop = pLay->getFrameArea().Left();
838  nPrtHeight = pLay->getFramePrintArea().Width();
839  }
840  else
841  {
842  nFrameTop = pLay->getFrameArea().Left() + pLay->getFrameArea().Width();
843  nPrtHeight = pLay->getFramePrintArea().Width();
844  }
845  }
846  else
847  {
848  nFrameTop = pLay->getFrameArea().Top();
849  nPrtHeight = pLay->getFramePrintArea().Height();
850  }
851  bSct = nullptr != pSect;
852  }
853  }
854  }
855  if ( pLay )
856  {
857  if ( pLay->getFrameArea().IsInside( rPt ) )
858  {
859  SwTwips nDiff = pLay->IsVertical() ? ( pLay->IsVertLR() ? ( rPt.X() - nFrameTop ) : ( nFrameTop - rPt.X() ) )
860  : ( rPt.Y() - nFrameTop );
861  if( bSct || pSect )
862  rRet.m_nSub += nDiff;
863  else
864  rRet.m_nMain += nDiff;
865  }
866  if ( pLay->IsFootnoteContFrame() && !static_cast<const SwLayoutFrame*>(pLay)->Lower() )
867  {
868  SwFrame *pDel = const_cast<SwFrame*>(pLay);
869  pDel->Cut();
870  SwFrame::DestroyFrame(pDel);
871  return nullptr;
872  }
873  return pLay;
874  }
875  else
876  rRet.m_nMain = LONG_MAX;
877  }
878  }
879  return nullptr;
880 }
881 
882 static sal_uInt64 lcl_FindCntDiff( const Point &rPt, const SwLayoutFrame *pLay,
883  const SwContentFrame *& rpCnt,
884  const bool bBody, const bool bFootnote )
885 {
886  // Searches below pLay the nearest Cnt to the point. The reference point of
887  //the Contents is always the left upper corner.
888  //The Cnt should preferably be above the point.
889 
890  rpCnt = nullptr;
891  sal_uInt64 nDistance = SAL_MAX_UINT64;
892  sal_uInt64 nNearest = SAL_MAX_UINT64;
893  const SwContentFrame *pCnt = pLay ? pLay->ContainsContent() : nullptr;
894 
895  while ( pCnt && (bBody != pCnt->IsInDocBody() || bFootnote != pCnt->IsInFootnote()))
896  {
897  pCnt = pCnt->GetNextContentFrame();
898  if ( !pLay->IsAnLower( pCnt ) )
899  pCnt = nullptr;
900  }
901  const SwContentFrame *pNearest = pCnt;
902  if ( pCnt )
903  {
904  do
905  {
906  //Calculate the distance between those two points.
907  //'delta' X^2 + 'delta' Y^2 = 'distance'^2
908  sal_uInt64 dX = std::max( pCnt->getFrameArea().Left(), rPt.X() ) -
909  std::min( pCnt->getFrameArea().Left(), rPt.X() ),
910  dY = std::max( pCnt->getFrameArea().Top(), rPt.Y() ) -
911  std::min( pCnt->getFrameArea().Top(), rPt.Y() );
912  // square of the difference will do fine here
913  const sal_uInt64 nDiff = (dX * dX) + (dY * dY);
914  if ( pCnt->getFrameArea().Top() <= rPt.Y() )
915  {
916  if ( nDiff < nDistance )
917  {
918  //This one is the nearer one
919  nDistance = nNearest = nDiff;
920  rpCnt = pNearest = pCnt;
921  }
922  }
923  else if ( nDiff < nNearest )
924  {
925  nNearest = nDiff;
926  pNearest = pCnt;
927  }
928  pCnt = pCnt->GetNextContentFrame();
929  while ( pCnt &&
930  (bBody != pCnt->IsInDocBody() || bFootnote != pCnt->IsInFootnote()))
931  pCnt = pCnt->GetNextContentFrame();
932 
933  } while ( pCnt && pLay->IsAnLower( pCnt ) );
934  }
935  if (nDistance == SAL_MAX_UINT64)
936  { rpCnt = pNearest;
937  return nNearest;
938  }
939  return nDistance;
940 }
941 
942 static const SwContentFrame * lcl_FindCnt( const Point &rPt, const SwContentFrame *pCnt,
943  const bool bBody, const bool bFootnote )
944 {
945  //Starting from pCnt searches the ContentFrame whose left upper corner is the
946  //nearest to the point.
947  //Always returns a ContentFrame.
948 
949  //First the nearest Content inside the page which contains the Content is
950  //searched. Starting from this page the pages in both directions need to
951  //be considered. If possible a Content is returned whose Y-position is
952  //above the point.
953  const SwContentFrame *pRet, *pNew;
954  const SwLayoutFrame *pLay = pCnt->FindPageFrame();
955  sal_uInt64 nDist; // not sure if a sal_Int32 would be enough?
956 
957  nDist = ::lcl_FindCntDiff( rPt, pLay, pNew, bBody, bFootnote );
958  if ( pNew )
959  pRet = pNew;
960  else
961  { pRet = pCnt;
962  nDist = SAL_MAX_UINT64;
963  }
964  const SwContentFrame *pNearest = pRet;
965  sal_uInt64 nNearest = nDist;
966 
967  if ( pLay )
968  {
969  const SwLayoutFrame *pPge = pLay;
970  sal_uInt64 nOldNew = SAL_MAX_UINT64;
971  for ( int i = 0; pPge->GetPrev() && (i < 3); ++i )
972  {
973  pPge = static_cast<const SwLayoutFrame*>(pPge->GetPrev());
974  const sal_uInt64 nNew = ::lcl_FindCntDiff( rPt, pPge, pNew, bBody, bFootnote );
975  if ( nNew < nDist )
976  {
977  if ( pNew->getFrameArea().Top() <= rPt.Y() )
978  {
979  pRet = pNearest = pNew;
980  nDist = nNearest = nNew;
981  }
982  else if ( nNew < nNearest )
983  {
984  pNearest = pNew;
985  nNearest = nNew;
986  }
987  }
988  else if (nOldNew != SAL_MAX_UINT64 && nNew > nOldNew)
989  break;
990  else
991  nOldNew = nNew;
992 
993  }
994  pPge = pLay;
995  nOldNew = SAL_MAX_UINT64;
996  for ( int j = 0; pPge->GetNext() && (j < 3); ++j )
997  {
998  pPge = static_cast<const SwLayoutFrame*>(pPge->GetNext());
999  const sal_uInt64 nNew = ::lcl_FindCntDiff( rPt, pPge, pNew, bBody, bFootnote );
1000  if ( nNew < nDist )
1001  {
1002  if ( pNew->getFrameArea().Top() <= rPt.Y() )
1003  {
1004  pRet = pNearest = pNew;
1005  nDist = nNearest = nNew;
1006  }
1007  else if ( nNew < nNearest )
1008  {
1009  pNearest = pNew;
1010  nNearest = nNew;
1011  }
1012  }
1013  else if (nOldNew != SAL_MAX_UINT64 && nNew > nOldNew)
1014  break;
1015  else
1016  nOldNew = nNew;
1017  }
1018  }
1019  if ( pRet->getFrameArea().Top() > rPt.Y() )
1020  return pNearest;
1021  else
1022  return pRet;
1023 }
1024 
1025 static void lcl_PointToPrt( Point &rPoint, const SwFrame *pFrame )
1026 {
1027  SwRect aTmp( pFrame->getFramePrintArea() );
1028  aTmp += pFrame->getFrameArea().Pos();
1029  if ( rPoint.getX() < aTmp.Left() )
1030  rPoint.setX(aTmp.Left());
1031  else if ( rPoint.getX() > aTmp.Right() )
1032  rPoint.setX(aTmp.Right());
1033  if ( rPoint.getY() < aTmp.Top() )
1034  rPoint.setY(aTmp.Top());
1035  else if ( rPoint.getY() > aTmp.Bottom() )
1036  rPoint.setY(aTmp.Bottom());
1037 
1038 }
1039 
1045 const SwContentFrame *FindAnchor( const SwFrame *pOldAnch, const Point &rNew,
1046  const bool bBodyOnly )
1047 {
1048  //Search the nearest Cnt around the given document position in the text
1049  //flow. The given anchor is the starting Frame.
1050  const SwContentFrame* pCnt;
1051  if ( pOldAnch->IsContentFrame() )
1052  {
1053  pCnt = static_cast<const SwContentFrame*>(pOldAnch);
1054  }
1055  else
1056  {
1057  Point aTmp( rNew );
1058  const SwLayoutFrame *pTmpLay = static_cast<const SwLayoutFrame*>(pOldAnch);
1059  if( pTmpLay->IsRootFrame() )
1060  {
1061  SwRect aTmpRect( aTmp, Size(0,0) );
1062  pTmpLay = static_cast<const SwLayoutFrame*>(::FindPage( aTmpRect, pTmpLay->Lower() ));
1063  }
1064  pCnt = pTmpLay->GetContentPos( aTmp, false, bBodyOnly );
1065  }
1066 
1067  //Take care to use meaningful ranges during search. This means to not enter
1068  //or leave header/footer in this case.
1069  const bool bBody = pCnt->IsInDocBody() || bBodyOnly;
1070  const bool bFootnote = !bBodyOnly && pCnt->IsInFootnote();
1071 
1072  Point aNew( rNew );
1073  if ( bBody )
1074  {
1075  //#38848 drag from page margin into the body.
1076  const SwFrame *pPage = pCnt->FindPageFrame();
1077  ::lcl_PointToPrt( aNew, pPage->GetUpper() );
1078  SwRect aTmp( aNew, Size( 0, 0 ) );
1079  pPage = ::FindPage( aTmp, pPage );
1080  ::lcl_PointToPrt( aNew, pPage );
1081  }
1082 
1083  if ( pCnt->IsInDocBody() == bBody && pCnt->getFrameArea().IsInside( aNew ) )
1084  return pCnt;
1085  else if ( pOldAnch->IsInDocBody() || pOldAnch->IsPageFrame() )
1086  {
1087  // Maybe the selected anchor is on the same page as the current anchor.
1088  // With this we won't run into problems with the columns.
1089  Point aTmp( aNew );
1090  const SwContentFrame *pTmp = pCnt->FindPageFrame()->
1091  GetContentPos( aTmp, false, true );
1092  if ( pTmp && pTmp->getFrameArea().IsInside( aNew ) )
1093  return pTmp;
1094  }
1095 
1096  //Starting from the anchor we now search in both directions until we found
1097  //the nearest one respectively.
1098  //Not the direct distance is relevant but the distance which needs to be
1099  //traveled through the text flow.
1100  const SwContentFrame *pUpLst;
1101  const SwContentFrame *pUpFrame = pCnt;
1102  SwDistance nUp, nUpLst;
1103  ::lcl_CalcDownDist( nUp, aNew, pUpFrame );
1104  SwDistance nDown = nUp;
1105  bool bNegAllowed = true;// Make it possible to leave the negative section once.
1106  do
1107  {
1108  pUpLst = pUpFrame; nUpLst = nUp;
1109  pUpFrame = pUpLst->GetPrevContentFrame();
1110  while ( pUpFrame &&
1111  (bBody != pUpFrame->IsInDocBody() || bFootnote != pUpFrame->IsInFootnote()))
1112  pUpFrame = pUpFrame->GetPrevContentFrame();
1113  if ( pUpFrame )
1114  {
1115  ::lcl_CalcDownDist( nUp, aNew, pUpFrame );
1116  //It makes sense to search further, if the distance grows inside
1117  //a table.
1118  if ( pUpLst->IsInTab() && pUpFrame->IsInTab() )
1119  {
1120  while ( pUpFrame && ((nUpLst < nUp && pUpFrame->IsInTab()) ||
1121  bBody != pUpFrame->IsInDocBody()) )
1122  {
1123  pUpFrame = pUpFrame->GetPrevContentFrame();
1124  if ( pUpFrame )
1125  ::lcl_CalcDownDist( nUp, aNew, pUpFrame );
1126  }
1127  }
1128  }
1129  if ( !pUpFrame )
1130  nUp.m_nMain = LONG_MAX;
1131  if (nUp.m_nMain >= 0 && LONG_MAX != nUp.m_nMain)
1132  {
1133  bNegAllowed = false;
1134  if (nUpLst.m_nMain < 0) //don't take the wrong one, if the value
1135  //just changed from negative to positive.
1136  { pUpLst = pUpFrame;
1137  nUpLst = nUp;
1138  }
1139  }
1140  } while (pUpFrame && ((bNegAllowed && nUp.m_nMain < 0) || (nUp <= nUpLst)));
1141 
1142  const SwContentFrame *pDownLst;
1143  const SwContentFrame *pDownFrame = pCnt;
1144  SwDistance nDownLst;
1145  if (nDown.m_nMain < 0)
1146  nDown.m_nMain = LONG_MAX;
1147  do
1148  {
1149  pDownLst = pDownFrame; nDownLst = nDown;
1150  pDownFrame = pDownLst->GetNextContentFrame();
1151  while ( pDownFrame &&
1152  (bBody != pDownFrame->IsInDocBody() || bFootnote != pDownFrame->IsInFootnote()))
1153  pDownFrame = pDownFrame->GetNextContentFrame();
1154  if ( pDownFrame )
1155  {
1156  ::lcl_CalcDownDist( nDown, aNew, pDownFrame );
1157  if (nDown.m_nMain < 0)
1158  nDown.m_nMain = LONG_MAX;
1159  //It makes sense to search further, if the distance grows inside
1160  //a table.
1161  if ( pDownLst->IsInTab() && pDownFrame->IsInTab() )
1162  {
1163  while (pDownFrame
1164  && ((nDown.m_nMain != LONG_MAX && pDownFrame->IsInTab())
1165  || bBody != pDownFrame->IsInDocBody()))
1166  {
1167  pDownFrame = pDownFrame->GetNextContentFrame();
1168  if ( pDownFrame )
1169  ::lcl_CalcDownDist( nDown, aNew, pDownFrame );
1170  if (nDown.m_nMain < 0)
1171  nDown.m_nMain = LONG_MAX;
1172  }
1173  }
1174  }
1175  if ( !pDownFrame )
1176  nDown.m_nMain = LONG_MAX;
1177 
1178  } while (pDownFrame && nDown <= nDownLst && nDown.m_nMain != LONG_MAX
1179  && nDownLst.m_nMain != LONG_MAX);
1180 
1181  //If we couldn't find one in both directions, we'll search the Content whose
1182  //left upper corner is the nearest to the point. Such a situation may
1183  //happen, if the point doesn't lay in the text flow but in any margin.
1184  if (nDownLst.m_nMain == LONG_MAX && nUpLst.m_nMain == LONG_MAX)
1185  {
1186  // If an OLE objects, which is contained in a fly frame
1187  // is resized in inplace mode and the new Position is outside the
1188  // fly frame, we do not want to leave our fly frame.
1189  if ( pCnt->IsInFly() )
1190  return pCnt;
1191 
1192  return ::lcl_FindCnt( aNew, pCnt, bBody, bFootnote );
1193  }
1194  else
1195  return nDownLst < nUpLst ? pDownLst : pUpLst;
1196 }
1197 
1198 void SwFlyAtContentFrame::SetAbsPos( const Point &rNew )
1199 {
1200  SwPageFrame *pOldPage = FindPageFrame();
1201  const SwRect aOld( GetObjRectWithSpaces() );
1202  Point aNew( rNew );
1203 
1205  aNew.setX(aNew.getX() + getFrameArea().Width());
1206  SwContentFrame *pCnt = const_cast<SwContentFrame*>(::FindAnchor( GetAnchorFrame(), aNew ));
1207  if( pCnt->IsProtected() )
1208  pCnt = const_cast<SwContentFrame*>(static_cast<const SwContentFrame*>(GetAnchorFrame()));
1209 
1210  SwPageFrame *pTmpPage = nullptr;
1211  const bool bVert = pCnt->IsVertical();
1212 
1213  const bool bVertL2R = pCnt->IsVertLR();
1214  const bool bRTL = pCnt->IsRightToLeft();
1215 
1216  if( ( !bVert != !GetAnchorFrame()->IsVertical() ) ||
1217  ( !bRTL != !GetAnchorFrame()->IsRightToLeft() ) )
1218  {
1219  if( bVert || bRTL )
1220  aNew.setX(aNew.getX() + getFrameArea().Width());
1221  else
1222  aNew.setX(aNew.getX() - getFrameArea().Width());
1223  }
1224 
1225  if ( pCnt->IsInDocBody() )
1226  {
1227  //#38848 drag from page margin into the body.
1228  pTmpPage = pCnt->FindPageFrame();
1229  ::lcl_PointToPrt( aNew, pTmpPage->GetUpper() );
1230  SwRect aTmp( aNew, Size( 0, 0 ) );
1231  pTmpPage = const_cast<SwPageFrame*>(static_cast<const SwPageFrame*>(::FindPage( aTmp, pTmpPage )));
1232  ::lcl_PointToPrt( aNew, pTmpPage );
1233  }
1234 
1235  //Setup RelPos, only invalidate if requested.
1236  //rNew is an absolute position. We need to calculate the distance from rNew
1237  //to the anchor inside the text flow to correctly set RelPos.
1239  const SwFrame *pFrame = nullptr;
1240  SwTwips nY;
1241  if ( pCnt->getFrameArea().IsInside( aNew ) )
1242  {
1243  // #i70582#
1244  if ( bVert )
1245  {
1246  nY = pCnt->getFrameArea().Left() - rNew.X();
1247  if ( bVertL2R )
1248  nY = -nY;
1249  else
1250  nY += pCnt->getFrameArea().Width() - getFrameArea().Width();
1252  }
1253  else
1254  nY = rNew.Y() - pCnt->getFrameArea().Top() - pCnt->GetUpperSpaceAmountConsideredForPrevFrameAndPageGrid();
1255  }
1256  else
1257  {
1258  SwDistance aDist;
1259  pFrame = ::lcl_CalcDownDist( aDist, aNew, pCnt );
1260  nY = aDist.m_nMain + aDist.m_nSub;
1261  }
1262 
1263  SwTwips nX = 0;
1264 
1265  if ( pCnt->IsFollow() )
1266  {
1267  // Flys are never attached to the follow but always to the master,
1268  // which we're going to search now.
1269  const SwContentFrame *pOriginal = pCnt;
1270  const SwContentFrame *pFollow = pCnt;
1271  while ( pCnt->IsFollow() )
1272  {
1273  do
1274  {
1275  SwContentFrame* pPrev = pCnt->GetPrevContentFrame();
1276  if (!pPrev)
1277  {
1278  SAL_WARN("sw.core", "very unexpected missing PrevContentFrame");
1279  break;
1280  }
1281  pCnt = pPrev;
1282  }
1283  while ( pCnt->GetFollow() != pFollow );
1284  pFollow = pCnt;
1285  }
1286  SwTwips nDiff = 0;
1287  do
1288  { const SwFrame *pUp = pFollow->GetUpper();
1289  if( pUp->IsVertical() )
1290  {
1291  if ( pUp->IsVertLR() )
1292  nDiff += pUp->getFramePrintArea().Width() - pFollow->GetRelPos().getX();
1293  else
1294  nDiff += pFollow->getFrameArea().Left() + pFollow->getFrameArea().Width()
1295  - pUp->getFrameArea().Left() - pUp->getFramePrintArea().Left();
1296  }
1297  else
1298  nDiff += pUp->getFramePrintArea().Height() - pFollow->GetRelPos().Y();
1299  pFollow = pFollow->GetFollow();
1300  } while ( pFollow != pOriginal );
1301  nY += nDiff;
1302  if( bVert )
1303  nX = pCnt->getFrameArea().Top() - pOriginal->getFrameArea().Top();
1304  else
1305  nX = pCnt->getFrameArea().Left() - pOriginal->getFrameArea().Left();
1306  }
1307 
1308  if ( nY == LONG_MAX )
1309  {
1310  // #i70582#
1311  const SwTwips nTopForObjPos = lcl_GetTopForObjPos(pCnt, bVert, bVertL2R);
1312  if( bVert )
1313  {
1314  if ( bVertL2R )
1315  nY = rNew.X() - nTopForObjPos;
1316  else
1317  nY = nTopForObjPos - rNew.X();
1318  }
1319  else
1320  {
1321  nY = rNew.Y() - nTopForObjPos;
1322  }
1323  }
1324 
1325  SwFlyFrameFormat *pFormat = GetFormat();
1326 
1327  if( bVert )
1328  {
1329  if( !pFrame )
1330  nX += rNew.Y() - pCnt->getFrameArea().Top();
1331  else
1332  nX = rNew.Y() - pFrame->getFrameArea().Top();
1333  }
1334  else
1335  {
1336  if( !pFrame )
1337  {
1338  if ( pCnt->IsRightToLeft() )
1339  nX += pCnt->getFrameArea().Right() - rNew.X() - getFrameArea().Width();
1340  else
1341  nX += rNew.X() - pCnt->getFrameArea().Left();
1342  }
1343  else
1344  {
1345  if ( pFrame->IsRightToLeft() )
1346  nX += pFrame->getFrameArea().Right() - rNew.X() - getFrameArea().Width();
1347  else
1348  nX = rNew.X() - pFrame->getFrameArea().Left();
1349  }
1350  }
1352 
1353  if( pCnt != GetAnchorFrame() || ( IsAutoPos() && pCnt->IsTextFrame() &&
1355  {
1356  //Set the anchor attribute according to the new Cnt.
1357  SwFormatAnchor aAnch( pFormat->GetAnchor() );
1358  SwPosition pos = *aAnch.GetContentAnchor();
1359  if( IsAutoPos() && pCnt->IsTextFrame() )
1360  {
1361  SwTextFrame const*const pTextFrame(static_cast<SwTextFrame const*>(pCnt));
1363  Point aPt( rNew );
1364  if( pCnt->GetModelPositionForViewPoint( &pos, aPt, &eTmpState )
1365  && FrameContainsNode(*pTextFrame, pos.nNode.GetIndex()))
1366  {
1367  const SwTextAttr *const pTextInputField =
1368  pos.nNode.GetNode().GetTextNode()->GetTextAttrAt(
1369  pos.nContent.GetIndex(), RES_TXTATR_INPUTFIELD, SwTextNode::PARENT );
1370  if (pTextInputField != nullptr)
1371  {
1372  pos.nContent = pTextInputField->GetStart();
1373  }
1375  if( text::RelOrientation::CHAR == pFormat->GetVertOrient().GetRelationOrient() )
1376  nY = LONG_MAX;
1377  if( text::RelOrientation::CHAR == pFormat->GetHoriOrient().GetRelationOrient() )
1378  nX = LONG_MAX;
1379  }
1380  else
1381  {
1382  pos = pTextFrame->MapViewToModelPos(TextFrameIndex(0));
1383  }
1384  }
1385  else if (pCnt->IsTextFrame())
1386  {
1387  pos = static_cast<SwTextFrame const*>(pCnt)->MapViewToModelPos(TextFrameIndex(0));
1388  }
1389  else // is that even possible? maybe if there was a change of anchor type from AT_FLY or something?
1390  {
1391  assert(pCnt->IsNoTextFrame());
1392  pos.nNode = *static_cast<SwNoTextFrame*>(pCnt)->GetNode();
1393  pos.nContent.Assign(static_cast<SwNoTextFrame*>(pCnt)->GetNode(), 0);
1394  }
1395  aAnch.SetAnchor( &pos );
1396 
1397  // handle change of anchor node:
1398  // if count of the anchor frame also change, the fly frames have to be
1399  // re-created. Thus, delete all fly frames except the <this> before the
1400  // anchor attribute is change and re-create them afterwards.
1401  {
1402  SwHandleAnchorNodeChg aHandleAnchorNodeChg( *pFormat, aAnch, this );
1403  pFormat->GetDoc()->SetAttr( aAnch, *pFormat );
1404  }
1405  }
1406  else if ( pTmpPage && pTmpPage != GetPageFrame() )
1407  GetPageFrame()->MoveFly( this, pTmpPage );
1408 
1409  const Point aRelPos = bVert ? Point( -nY, nX ) : Point( nX, nY );
1410  ChgRelPos( aRelPos );
1412 
1413  if ( pOldPage != FindPageFrame() )
1414  ::Notify_Background( GetVirtDrawObj(), pOldPage, aOld, PrepareHint::FlyFrameLeave, false );
1415 }
1416 
1424 {
1425  SwPageFrame* pPageFrame( nullptr );
1426  if ( GetVertPosOrientFrame() )
1427  {
1428  pPageFrame = const_cast<SwPageFrame*>(GetVertPosOrientFrame()->FindPageFrame());
1429  }
1430  if ( pPageFrame && GetPageFrame() != pPageFrame )
1431  {
1432  if ( GetPageFrame() )
1433  GetPageFrame()->MoveFly( this, pPageFrame );
1434  else
1435  pPageFrame->AppendFlyToPage( this );
1436  }
1437 }
1438 
1439 // #i26791#
1441 {
1442  // if fly frame position is valid, nothing is to do. Thus, return
1443  if ( isFrameAreaPositionValid() )
1444  {
1445  return;
1446  }
1447 
1448  // #i26791# - validate position flag here.
1450 
1451  // #i35911# - no calculation of new position, if
1452  // anchored object is marked that it clears its environment and its
1453  // environment is already cleared.
1454  // before checking for cleared environment
1455  // check, if member <mpVertPosOrientFrame> is set.
1456  if ( GetVertPosOrientFrame() &&
1458  {
1459  return;
1460  }
1461 
1462  // use new class to position object
1464  aObjPositioning( *GetVirtDrawObj() );
1465  aObjPositioning.CalcPosition();
1466 
1467  SetVertPosOrientFrame ( aObjPositioning.GetVertPosOrientFrame() );
1468 }
1469 
1470 // #i28701#
1472 {
1473  bool bAllowed( SwFlyFreeFrame::InvalidationAllowed( _nInvalid ) );
1474 
1475  // forbiddance of base instance can't be over ruled.
1476  if ( bAllowed )
1477  {
1478  if ( _nInvalid == INVALID_POS ||
1479  _nInvalid == INVALID_ALL )
1480  {
1481  bAllowed = InvalidationOfPosAllowed();
1482  }
1483  }
1484 
1485  return bAllowed;
1486 }
1487 
1488 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool IsAnLower(const SwFrame *) const
Definition: findfrm.cxx:207
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
SwFrame * FindFooterOrHeader()
Definition: findfrm.cxx:548
const SwVirtFlyDrawObj * GetVirtDrawObj() const
Definition: fly.cxx:2771
Base class of the Writer layout elements.
Definition: frame.hxx:298
Represents the visualization of a paragraph.
Definition: txtfrm.hxx:157
bool OverlapsPrevColumn() const
method to determine, if the anchored object is overlapping with a previous column ...
bool operator<(const SwTextGlyphsKey &l, const SwTextGlyphsKey &r)
Definition: fntcache.cxx:120
void Right(const tools::Long nRight)
Definition: swrect.hxx:200
virtual void SwClientNotify(const SwModify &rMod, const SfxHint &rHint) override
Definition: fly.cxx:659
bool IsFollow() const
Definition: flowfrm.hxx:166
Point GetPos(const SwRect &rRect) const
Definition: frame.hxx:1364
virtual const SwFlyFrameFormat * GetFormat() const override
Definition: fly.cxx:2860
void SetNotifyBack()
Definition: flyfrm.hxx:200
const SwSortedObjs * GetDrawObjs() const
Definition: frame.hxx:548
Marks a position in the document model.
Definition: pam.hxx:35
SwContentFrame * GetNextContentFrame() const
Definition: cntfrm.hxx:98
SwContentNode * GetNode(SwPaM &rPam, bool &rbFirst, SwMoveFnCollection const &fnMove, bool const bInReadOnly, SwRootFrame const *const i_pLayout)
This function returns the next node in direction of search.
Definition: pam.cxx:823
bool IsInDocBody() const
Definition: frame.hxx:924
bool IsInFly() const
Definition: frame.hxx:942
bool IsRootFrame() const
Definition: frame.hxx:1155
bool IsInSct() const
Definition: frame.hxx:948
bool IsLowerOf(const SwLayoutFrame *pUpper) const
Definition: fly.cxx:2148
const SwContentFrame * FindAnchor(const SwFrame *pOldAnch, const Point &rNew, const bool bBodyOnly)
Searches an anchor for paragraph bound objects starting from pOldAnch.
Definition: flycnt.cxx:1045
static sal_uInt64 lcl_FindCntDiff(const Point &rPt, const SwLayoutFrame *pLay, const SwContentFrame *&rpCnt, const bool bBody, const bool bFootnote)
Definition: flycnt.cxx:882
bool IsColLocked() const
Definition: frame.hxx:867
virtual bool IsFormatPossible() const override
method to determine, if a format on the Writer fly frame is possible
Definition: flylay.cxx:714
virtual void NotifyBackground(SwPageFrame *pPage, const SwRect &rRect, PrepareHint eHint) override
Notifies the background (all ContentFrames that currently are overlapping).
Definition: flylay.cxx:109
const SwFormatVertOrient & GetVertOrient(bool=true) const
Definition: fmtornt.hxx:106
void Left(const tools::Long nLeft)
Definition: swrect.hxx:195
SwNodeIndex nNode
Definition: pam.hxx:37
bool IsInFootnote() const
Definition: frame.hxx:930
bool ClearedEnvironment() const
const SwFrame * FindPage(const SwRect &rRect, const SwFrame *pPage)
Definition: frmtool.cxx:3662
SwTwips GetPos() const
Definition: fmtornt.hxx:92
const SwRect & getFramePrintArea() const
Definition: frame.hxx:179
void SetAbsPos(const Point &rNew)
Definition: flycnt.cxx:1198
SwContentFrame * getLayoutFrame(const SwRootFrame *, const SwPosition *pPos=nullptr, std::pair< Point, bool > const *pViewPosAndCalcFrame=nullptr) const
Definition: node.cxx:1212
virtual SwUndoId EndUndo(SwUndoId const eUndoId, SwRewriter const *const pRewriter)=0
Closes undo block.
void InvalidateSize_()
Definition: frame.hxx:754
Definition: doc.hxx:187
tools::Long getY() const
virtual bool InvalidationAllowed(const InvalidationType _nInvalid) const
method to determine, if an invalidation is allowed.
Definition: wsfrm.cxx:1934
void SetSurround(css::text::WrapTextMode eNew)
Definition: fmtsrnd.hxx:55
bool operator<=(const BigInt &rVal1, const BigInt &rVal2)
static void DestroyFrame(SwFrame *const pFrame)
this is the only way to delete a SwFrame instance
Definition: ssfrm.cxx:384
void Pos(const Point &rNew)
Definition: swrect.hxx:169
void SetTmpConsiderWrapInfluenceOfOtherObjs()
method to apply temporary consideration of wrapping style influence to the anchored objects...
IDocumentUndoRedo & GetIDocumentUndoRedo()
Definition: doc.cxx:144
bool IsCellFrame() const
Definition: frame.hxx:1207
Of course Writer needs its own rectangles.
Definition: swrect.hxx:35
void ClearCharRectAndTopOfLine()
reset members and
sal_Int16 GetRelationOrient() const
Definition: fmtornt.hxx:55
void Notify_Background(const SdrObject *pObj, SwPageFrame *pPage, const SwRect &rRect, const PrepareHint eHint, const bool bInva)
Definition: frmtool.cxx:3323
static SwFrameFormat * getOtherTextBoxFormat(const SwFrameFormat *pFormat, sal_uInt16 nType)
If we have an associated TextFrame, then return that.
bool isFrameAreaDefinitionValid() const
Definition: frame.hxx:170
static bool bFootnote
Definition: insfnote.cxx:33
constexpr TypedWhichId< SwFlyFrameFormat > RES_FLYFRMFMT(156)
virtual SwFrameFormat & GetFrameFormat() override
Definition: fly.cxx:2790
bool bSetCompletePaintOnInvalidate
Definition: frmtool.cxx:84
virtual bool GetModelPositionForViewPoint(SwPosition *, Point &, SwCursorMoveState *=nullptr, bool bTestBackground=false) const
Definition: unusedf.cxx:47
tools::Long GetTop(const SwRect &rRect) const
Definition: frame.hxx:1358
virtual void MakeObjPos() override
method to determine position for the object and set the position at the object
Definition: flycnt.cxx:1440
wrapper class for the positioning of Writer fly frames and drawing objects
void AppendFly(SwFlyFrame *pNew)
Definition: fly.cxx:2167
const SwRect & getFrameArea() const
Definition: frame.hxx:178
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
size_t pos
A wrapper around SfxPoolItem to store the start position of (usually) a text portion, with an optional end.
Definition: txatbase.hxx:41
bool IsInTab() const
Definition: frame.hxx:936
void SetAttr(const SfxPoolItem &, SwFormat &)
Set attribute in given format.1y If Undo is enabled, the old values is added to the Undo history...
Definition: docfmt.cxx:451
virtual void RegisterAtCorrectPage() override
method to assure that anchored object is registered at the correct page frame
Definition: flycnt.cxx:1423
void SetTmpConsiderWrapInfluence(const bool _bTmpConsiderWrapInfluence)
bool IsTextFrame() const
Definition: frame.hxx:1215
sal_Int32 GetStart() const
Definition: txatbase.hxx:86
void Width(tools::Long nNew)
Definition: swrect.hxx:187
const SwFormatSurround & GetSurround(bool=true) const
Definition: fmtsrnd.hxx:66
bool m_bAtCnt
RndStdIds::FLY_AT_PARA, anchored at paragraph or RndStdIds::FLY_AT_CHAR.
Definition: flyfrm.hxx:111
SwContentFrame * GetPrevContentFrame() const
Definition: cntfrm.hxx:106
bool IsSctFrame() const
Definition: frame.hxx:1195
SwFlyFrame * FindFlyFrame()
Definition: frame.hxx:1092
tools::Long getX() const
SwFrame * AnchorFrame()
virtual void MakeAll(vcl::RenderContext *pRenderContext) override
|* With a paragraph-anchored fly it's absolutely possible that |* the anchor reacts to changes of the...
Definition: flycnt.cxx:313
virtual void Cut()=0
bool IsColumnFrame() const
Definition: frame.hxx:1163
bool FrameContainsNode(SwContentFrame const &rFrame, sal_uLong nNodeIndex)
Definition: txtfrm.cxx:284
Point GetRelPos() const
Definition: trvlfrm.cxx:1796
virtual void CalcPosition() override
calculate position of object
const SwFormatFollowTextFlow & GetFollowTextFlow(bool=true) const
Style of a layout element.
Definition: frmfmt.hxx:58
virtual SwUndoId StartUndo(SwUndoId const eUndoId, SwRewriter const *const pRewriter)=0
Opens undo block.
bool IsContentFrame() const
Definition: frame.hxx:1211
const SwContentFrame * GetFollow() const
Definition: cntfrm.hxx:114
void RemoveFly(SwFlyFrame *pToRemove)
Definition: fly.cxx:2185
#define SAL_MAX_UINT64
const SwFormatAnchor & GetAnchor(bool=true) const
Definition: fmtanchr.hxx:81
int i
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:663
static void RemoveMovedFwdFrame(const SwDoc &_rDoc, const SwTextFrame &_rTextFrame)
Definition: layouter.cxx:332
const SwFrame * Lower() const
Definition: layfrm.hxx:101
void SetPos(SwTwips nNew)
Definition: fmtornt.hxx:60
SwContentNode * GetContentNode()
Definition: node.hxx:619
void InvalidatePage(const SwPageFrame *pPage=nullptr) const
Invalidates the page in which the Frame is currently placed.
Definition: wsfrm.cxx:604
tools::Long GetHeight(const SwRect &rRect) const
Definition: frame.hxx:1363
FlyAnchors.
Definition: fmtanchr.hxx:34
sal_uInt8 GetHeightPercent() const
Definition: fmtfsize.hxx:88
SwLayoutFrame * GetUpper()
Definition: frame.hxx:661
const SwRect & GetObjRectWithSpaces() const
method to determine object area inclusive its spacing
::rtl::Reference< Content > pContent
void UnlockModify()
Definition: calbck.hxx:204
static void getProperty(SwFrameFormat const *pShape, sal_uInt16 nWID, sal_uInt8 nMemberID, css::uno::Any &rValue)
Get a property of the underlying TextFrame.
SwTwips GetUpperSpaceAmountConsideredForPrevFrameAndPageGrid() const
method to determine the upper space amount, which is considered for the previous frame and the page g...
Definition: flowfrm.cxx:1725
void LockModify()
Definition: calbck.hxx:203
SwFrame * GetPrev()
Definition: frame.hxx:660
const SwRowFrame * IsInFollowFlowRow() const
Definition: findfrm.cxx:1786
virtual const IDocumentDrawModelAccess & getIDocumentDrawModelAccess() override
Definition: fly.cxx:302
Marks a node in the document model.
Definition: ndindex.hxx:31
bool isFrameAreaPositionValid() const
Definition: frame.hxx:165
void MoveFly(SwFlyFrame *pToMove, SwPageFrame *pDest)
Definition: flylay.cxx:935
const SwDoc * GetDoc() const
The document is set in SwAttrPool now, therefore you always can access it.
Definition: format.hxx:123
sal_uInt8 GetWidthPercent() const
Definition: fmtfsize.hxx:91
const IDocumentSettingAccess & getIDocumentSettingAccess() const
Provides access to the document settings interface.
Definition: format.cxx:717
bool HasFixSize() const
Definition: frame.hxx:653
void InvalidatePos_()
Definition: frame.hxx:770
virtual bool IsFormatPossible() const override
method to determine, if a format on the Writer fly frame is possible
Definition: flycnt.cxx:551
A page of the document layout.
Definition: pagefrm.hxx:41
virtual void MakeAll(vcl::RenderContext *pRenderContext) override
Definition: flylay.cxx:115
stay with the cursor inside text
SwFrame * GetAnchorFrameContainingAnchPos()
determine anchor frame containing the anchor position
static const SwContentFrame * lcl_FindCnt(const Point &rPt, const SwContentFrame *pCnt, const bool bBody, const bool bFootnote)
Definition: flycnt.cxx:942
tools::Long SwTwips
Definition: swtypes.hxx:49
const long LONG_MAX
EXPAND : (Start < nIndex <= End)
Definition: ndtxt.hxx:363
SwSectionFrame * FindSctFrame()
Definition: frame.hxx:1096
virtual bool SetFormatAttr(const SfxPoolItem &rAttr)
Definition: format.cxx:450
void setFrameAreaPositionValid(bool bNew)
Definition: wsfrm.cxx:83
void Bottom(const tools::Long nBottom)
Definition: swrect.hxx:209
const SwLayoutFrame * GetVertPosOrientFrame() const
bool m_bAutoPosition
RndStdIds::FLY_AT_CHAR, anchored at character.
Definition: flyfrm.hxx:114
bool IsVertLR() const
Definition: frame.hxx:960
SwLayoutFrame * GetLeaf(MakePageType eMakePage, bool bFwd)
Definition: flowfrm.cxx:843
bool ConsiderObjWrapInfluenceOnObjPos() const
method to determine, if wrapping style influence of the anchored object has to be considered on the o...
general base class for all free-flowing frames
Definition: flyfrm.hxx:60
bool InvalidationOfPosAllowed() const
method to determine, if invalidation of position is allowed
sal_Int16 GetRelationOrient() const
Definition: fmtornt.hxx:88
bool IsLocked() const
Definition: flyfrm.hxx:192
SwTextFrame * FindMaster() const
Definition: flowfrm.cxx:738
SwPageFrame * GetPageFrame()
sal_uInt16 GetPhyPageNum() const
Definition: trvlfrm.cxx:1695
SwTwips GetPos() const
Definition: fmtornt.hxx:59
bool HasClearedEnvironment() const
method to determine, if due to anchored object size and wrapping style, its layout environment is cle...
bool IsInside(const Point &rPOINT) const
Definition: swrect.cxx:105
bool IsNoTextFrame() const
Definition: frame.hxx:1219
bool IsRightToLeft() const
Definition: frame.hxx:968
bool IsClipped() const
Definition: flyfrm.hxx:203
void Top(const tools::Long nTop)
Definition: swrect.hxx:204
bool IsPageFrame() const
Definition: frame.hxx:1159
virtual void SwClientNotify(const SwModify &, const SfxHint &) override
Definition: flycnt.cxx:86
static const SwFormatAnchor * GetAnchorFromPoolItem(const SfxPoolItem &rItem)
Definition: fly.cxx:2931
static tools::Rectangle getTextRectangle(SwFrameFormat *pShape, bool bAbsolute=true)
Return the textbox rectangle of a draw shape (in twips).
bool ConsiderObjWrapInfluenceOfOtherObjs() const
method to determine, if other anchored objects, also attached at to the anchor frame, have to consider its wrap influence.
void AppendFlyToPage(SwFlyFrame *pNew)
Definition: flylay.cxx:790
virtual bool get(DocumentSettingId id) const =0
Return the specified document setting.
bool IsAnFollow(const SwFlowFrame *pFlow) const
Definition: flowfrm.cxx:727
constexpr TypedWhichId< SwFormatField > RES_TXTATR_INPUTFIELD(55)
const SwFormatFrameSize & GetFrameSize(bool=true) const
Definition: fmtfsize.hxx:104
void SetPos(SwTwips nNew)
Definition: fmtornt.hxx:93
#define UNO_NAME_FRAME_ISAUTOMATIC_HEIGHT
Definition: unoprnms.hxx:591
bool IsVertical() const
Definition: frame.hxx:954
#define SAL_WARN(area, stream)
static void lcl_PointToPrt(Point &rPoint, const SwFrame *pFrame)
Definition: flycnt.cxx:1025
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
void SetVertPosOrientFrame(const SwLayoutFrame &_rVertPosOrientFrame)
static bool FrameMovedFwdByObjPos(const SwDoc &_rDoc, const SwTextFrame &_rTextFrame, sal_uInt32 &_ornToPageNum)
Definition: layouter.cxx:342
bool IsFootnoteContFrame() const
Definition: frame.hxx:1179
SwFlyAtContentFrame(SwFlyFrameFormat *, SwFrame *, SwFrame *pAnchor)
Definition: flycnt.cxx:77
static void FormatAnchorFrameAndItsPrevs(SwTextFrame &_rAnchorTextFrame)
method to format given anchor text frame and its previous frames
virtual bool InvalidationAllowed(const InvalidationType _nInvalid) const override
method to determine, if an invalidation is allowed.
Definition: flycnt.cxx:1471
const SwContentFrame * ContainsContent() const
Checks if the frame contains one or more ContentFrame's anywhere in his subsidiary structure; if so t...
Definition: findfrm.cxx:67
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
const SwContentFrame * GetContentPos(Point &rPoint, const bool bDontLeave, const bool bBodyOnly=false, SwCursorMoveState *pCMS=nullptr, const bool bDefaultExpand=true) const
Finds the closest Content for the SPoint Is used for Pages, Flys and Cells if GetModelPositionForView...
Definition: trvlfrm.cxx:1186
void ResetLastCharRectHeight()
void ChgRelPos(const Point &rAbsPos)
Change the relative position.
Definition: fly.cxx:1111
void SetRestartLayoutProcess(const bool _bRestartLayoutProcess)
void Height(tools::Long nNew)
Definition: swrect.hxx:191
static const SwFrame * lcl_CalcDownDist(SwDistance &rRet, const Point &rPt, const SwContentFrame *pCnt)
Definition: flycnt.cxx:583
SwPosition MapViewToModelPos(TextFrameIndex nIndex) const
Definition: txtfrm.cxx:1238
InvalidationType
enumeration for the different invalidations #i28701#
Definition: frame.hxx:472
bool IsFooterFrame() const
Definition: frame.hxx:1175
SwRootFrame * getRootFrame()
Definition: frame.hxx:662
const SwLayoutFrame & GetVertPosOrientFrame() const
frame, at which the vertical position is oriented at
bool IsAutoPos() const
Definition: flyfrm.hxx:193
static void InsertMovedFwdFrame(const SwDoc &_rDoc, const SwTextFrame &_rMovedFwdFrameByObjPos, const sal_uInt32 _nToPageNum)
Definition: layouter.cxx:312
bool IsProtected() const
Is the Frame or rather the Section in which it lies protected?
Definition: trvlfrm.cxx:1628
SwTabFrame * FindTabFrame()
Definition: frame.hxx:1080
SwFrame * GetNext()
Definition: frame.hxx:659