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