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>
49#include <ndtxt.hxx>
50#include <textboxhelper.hxx>
51#include <fmtfollowtextflow.hxx>
52#include <unoprnms.hxx>
53
54using namespace ::com::sun::star;
55
56namespace
57{
58
59SwTwips 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 )
65 aResult += pCnt->GetUpperSpaceAmountConsideredForPrevFrameAndPageGrid();
66 else
67 aResult += pCnt->getFrameArea().Width() - pCnt->GetUpperSpaceAmountConsideredForPrevFrameAndPageGrid();
68 return aResult;
69 }
70 else
71 return pCnt->getFrameArea().Top() + pCnt->GetUpperSpaceAmountConsideredForPrevFrameAndPageGrid();
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
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->GetAnchorNode());
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)
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
194namespace {
195
196// #i3317# - re-factoring of the position stack
197class 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
208public:
209 explicit SwOszControl( const SwFlyFrame *pFrame );
210 ~SwOszControl();
211 bool ChkOsz();
212 static bool IsInProgress( const SwFlyFrame *pFly );
213};
214
215}
216
217const SwFlyFrame* SwOszControl::s_pStack1 = nullptr;
218const SwFlyFrame* SwOszControl::s_pStack2 = nullptr;
219const SwFlyFrame* SwOszControl::s_pStack3 = nullptr;
220const SwFlyFrame* SwOszControl::s_pStack4 = nullptr;
221const SwFlyFrame* SwOszControl::s_pStack5 = nullptr;
222
223SwOszControl::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
238SwOszControl::~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
254bool 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
269bool 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()>
327 {
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();
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.
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,
538 SwTextBoxHelper::getProperty(pShapeFormat,
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 auto pFormat = GetFormat();
552 const bool bLocked = pFormat->IsModifyLocked();
553 if (!bLocked)
554 pFormat->LockModify();
555 pFormat->SetFormatAttr(aHOri);
556 pFormat->SetFormatAttr(aVOri);
557 if (!bLocked)
558 pFormat->UnlockModify();
559 }
560 if ( bOsz || bConsiderWrapInfluenceDueToOverlapPrevCol ||
561 // #i40444#
562 bConsiderWrapInfluenceDueToMovedFwdAnchor )
563 {
567 }
569}
570
576{
578 !SwOszControl::IsInProgress( this );
579}
580
581namespace {
582
583class SwDistance
584{
585public:
586 SwTwips m_nMain, m_nSub;
587 SwDistance()
588 : m_nMain(0)
589 , m_nSub(0)
590 {
591 }
592 bool operator<( const SwDistance& rTwo ) const
593 {
594 return m_nMain < rTwo.m_nMain
595 || (m_nMain == rTwo.m_nMain && m_nSub && rTwo.m_nSub && m_nSub < rTwo.m_nSub);
596 }
597 bool operator<=( const SwDistance& rTwo ) const
598 {
599 return m_nMain < rTwo.m_nMain
600 || (m_nMain == rTwo.m_nMain
601 && (!m_nSub || !rTwo.m_nSub || m_nSub <= rTwo.m_nSub));
602 }
603};
604
605}
606
607static const SwFrame * lcl_CalcDownDist( SwDistance &rRet,
608 const Point &rPt,
609 const SwContentFrame *pCnt )
610{
611 rRet.m_nSub = 0;
612 //If the point stays inside the Cnt everything is clear already; the Content
613 //automatically has a distance of 0.
614 if ( pCnt->getFrameArea().Contains( rPt ) )
615 {
616 rRet.m_nMain = 0;
617 return pCnt;
618 }
619 else
620 {
621 const SwLayoutFrame *pUp = pCnt->IsInTab() ? pCnt->FindTabFrame()->GetUpper() : pCnt->GetUpper();
622 // single column sections need to interconnect to their upper
623 while( pUp->IsSctFrame() )
624 pUp = pUp->GetUpper();
625 const bool bVert = pUp->IsVertical();
626
627 const bool bVertL2R = pUp->IsVertLR();
628
629 //Follow the text flow.
630 // #i70582#
631 // --> OD 2009-03-05 - adopted for Support for Classical Mongolian Script
632 const SwTwips nTopForObjPos = lcl_GetTopForObjPos(pCnt, bVert, bVertL2R);
633 if ( pUp->getFrameArea().Contains( rPt ) )
634 {
635 // <rPt> point is inside environment of given content frame
636 // #i70582#
637 if( bVert )
638 {
639 if ( bVertL2R )
640 rRet.m_nMain = rPt.X() - nTopForObjPos;
641 else
642 rRet.m_nMain = nTopForObjPos - rPt.X();
643 }
644 else
645 rRet.m_nMain = rPt.Y() - nTopForObjPos;
646 return pCnt;
647 }
648 else if ( rPt.Y() <= pUp->getFrameArea().Top() )
649 {
650 // <rPt> point is above environment of given content frame
651 // correct for vertical layout?
652 rRet.m_nMain = LONG_MAX;
653 }
654 else if( rPt.X() < pUp->getFrameArea().Left() &&
655 rPt.Y() <= ( bVert ? pUp->getFrameArea().Top() : pUp->getFrameArea().Bottom() ) )
656 {
657 // <rPt> point is left of environment of given content frame
658 // seems not to be correct for vertical layout!?
659 const SwFrame *pLay = pUp->GetLeaf( MAKEPAGE_NONE, false, pCnt );
660 if( !pLay ||
661 (bVert && (pLay->getFrameArea().Top() + pLay->getFramePrintArea().Bottom()) <rPt.Y())||
662 (!bVert && (pLay->getFrameArea().Left() + pLay->getFramePrintArea().Right())<rPt.X()) )
663 {
664 // <rPt> point is in left border of environment
665 // #i70582#
666 if( bVert )
667 {
668 if ( bVertL2R )
669 rRet.m_nMain = rPt.X() - nTopForObjPos;
670 else
671 rRet.m_nMain = nTopForObjPos - rPt.X();
672 }
673 else
674 rRet.m_nMain = rPt.Y() - nTopForObjPos;
675 return pCnt;
676 }
677 else
678 rRet.m_nMain = LONG_MAX;
679 }
680 else
681 {
682 rRet.m_nMain
683 = bVert ? (bVertL2R
684 ? ((pUp->getFrameArea().Left() + pUp->getFramePrintArea().Right())
685 - nTopForObjPos)
686 : (nTopForObjPos
687 - (pUp->getFrameArea().Left() + pUp->getFramePrintArea().Left())))
688 : ((pUp->getFrameArea().Top() + pUp->getFramePrintArea().Bottom())
689 - nTopForObjPos);
690
691 const SwFrame *pPre = pCnt;
692 const SwFrame *pLay = pUp->GetLeaf( MAKEPAGE_NONE, true, pCnt );
693 SwTwips nFrameTop = 0;
694 SwTwips nPrtHeight = 0;
695 bool bSct = false;
696 const SwSectionFrame *pSect = pUp->FindSctFrame();
697 if( pSect )
698 {
699 rRet.m_nSub = rRet.m_nMain;
700 rRet.m_nMain = 0;
701 }
702 if( pSect && !pSect->IsAnLower( pLay ) )
703 {
704 bSct = false;
705 const SwSectionFrame* pNxtSect = pLay ? pLay->FindSctFrame() : nullptr;
706 if (pSect->IsAnFollow(pNxtSect) && pLay)
707 {
708 if( pLay->IsVertical() )
709 {
710 if ( pLay->IsVertLR() )
711 nFrameTop = pLay->getFrameArea().Left();
712 else
713 nFrameTop = pLay->getFrameArea().Left() + pLay->getFrameArea().Width();
714 nPrtHeight = pLay->getFramePrintArea().Width();
715 }
716 else
717 {
718 nFrameTop = pLay->getFrameArea().Top();
719 nPrtHeight = pLay->getFramePrintArea().Height();
720 }
721 pSect = pNxtSect;
722 }
723 else
724 {
725 pLay = pSect->GetUpper();
726 if( pLay->IsVertical() )
727 {
728 if ( pLay->IsVertLR() )
729 {
730 nFrameTop = pSect->getFrameArea().Right();
731 nPrtHeight = pLay->getFrameArea().Left() + pLay->getFramePrintArea().Left()
732 + pLay->getFramePrintArea().Width() - pSect->getFrameArea().Left()
733 - pSect->getFrameArea().Width();
734 }
735 else
736 {
737 nFrameTop = pSect->getFrameArea().Left();
738 nPrtHeight = pSect->getFrameArea().Left() - pLay->getFrameArea().Left()
739 - pLay->getFramePrintArea().Left();
740 }
741 }
742 else
743 {
744 nFrameTop = pSect->getFrameArea().Bottom();
745 nPrtHeight = pLay->getFrameArea().Top() + pLay->getFramePrintArea().Top()
746 + pLay->getFramePrintArea().Height() - pSect->getFrameArea().Top()
747 - pSect->getFrameArea().Height();
748 }
749 pSect = nullptr;
750 }
751 }
752 else if( pLay )
753 {
754 if( pLay->IsVertical() )
755 {
756 if ( pLay->IsVertLR() )
757 {
758 nFrameTop = pLay->getFrameArea().Left();
759 nPrtHeight = pLay->getFramePrintArea().Width();
760 }
761 else
762 {
763 nFrameTop = pLay->getFrameArea().Left() + pLay->getFrameArea().Width();
764 nPrtHeight = pLay->getFramePrintArea().Width();
765 }
766 }
767 else
768 {
769 nFrameTop = pLay->getFrameArea().Top();
770 nPrtHeight = pLay->getFramePrintArea().Height();
771 }
772 bSct = nullptr != pSect;
773 }
774 while ( pLay && !pLay->getFrameArea().Contains( rPt ) &&
775 ( pLay->getFrameArea().Top() <= rPt.Y() || pLay->IsInFly() ||
776 ( pLay->IsInSct() &&
777 pLay->FindSctFrame()->GetUpper()->getFrameArea().Top() <= rPt.Y())) )
778 {
779 if ( pLay->IsFootnoteContFrame() )
780 {
781 if ( !static_cast<const SwLayoutFrame*>(pLay)->Lower() )
782 {
783 SwFrame *pDel = const_cast<SwFrame*>(pLay);
784 pDel->Cut();
786 return pPre;
787 }
788 return nullptr;
789 }
790 else
791 {
792 if( bSct || pSect )
793 rRet.m_nSub += nPrtHeight;
794 else
795 rRet.m_nMain += nPrtHeight;
796 pPre = pLay;
797 pLay = pLay->GetLeaf( MAKEPAGE_NONE, true, pCnt );
798 if( pSect && !pSect->IsAnLower( pLay ) )
799 { // If we're leaving a SwSectionFrame, the next Leaf-Frame
800 // is the part of the upper below the SectionFrame.
801 const SwSectionFrame* pNxtSect = pLay ?
802 pLay->FindSctFrame() : nullptr;
803 bSct = false;
804 if (pLay && pSect->IsAnFollow(pNxtSect))
805 {
806 pSect = pNxtSect;
807 if( pLay->IsVertical() )
808 {
809 if ( pLay->IsVertLR() )
810 {
811 nFrameTop = pLay->getFrameArea().Left();
812 nPrtHeight = pLay->getFramePrintArea().Width();
813 }
814 else
815 {
816 nFrameTop = pLay->getFrameArea().Left() + pLay->getFrameArea().Width();
817 nPrtHeight = pLay->getFramePrintArea().Width();
818 }
819 }
820 else
821 {
822 nFrameTop = pLay->getFrameArea().Top();
823 nPrtHeight = pLay->getFramePrintArea().Height();
824 }
825 }
826 else
827 {
828 pLay = pSect->GetUpper();
829 if( pLay->IsVertical() )
830 {
831 if ( pLay->IsVertLR() )
832 {
833 nFrameTop = pSect->getFrameArea().Right();
834 nPrtHeight = pLay->getFrameArea().Left()+pLay->getFramePrintArea().Left()
835 + pLay->getFramePrintArea().Width() - pSect->getFrameArea().Left()
836 - pSect->getFrameArea().Width();
837 }
838 else
839 {
840 nFrameTop = pSect->getFrameArea().Left();
841 nPrtHeight = pSect->getFrameArea().Left() -
842 pLay->getFrameArea().Left() - pLay->getFramePrintArea().Left();
843 }
844 }
845 else
846 {
847 nFrameTop = pSect->getFrameArea().Bottom();
848 nPrtHeight = pLay->getFrameArea().Top()+pLay->getFramePrintArea().Top()
849 + pLay->getFramePrintArea().Height() - pSect->getFrameArea().Top()
850 - pSect->getFrameArea().Height();
851 }
852 pSect = nullptr;
853 }
854 }
855 else if( pLay )
856 {
857 if( pLay->IsVertical() )
858 {
859 if ( pLay->IsVertLR() )
860 {
861 nFrameTop = pLay->getFrameArea().Left();
862 nPrtHeight = pLay->getFramePrintArea().Width();
863 }
864 else
865 {
866 nFrameTop = pLay->getFrameArea().Left() + pLay->getFrameArea().Width();
867 nPrtHeight = pLay->getFramePrintArea().Width();
868 }
869 }
870 else
871 {
872 nFrameTop = pLay->getFrameArea().Top();
873 nPrtHeight = pLay->getFramePrintArea().Height();
874 }
875 bSct = nullptr != pSect;
876 }
877 }
878 }
879 if ( pLay )
880 {
881 if ( pLay->getFrameArea().Contains( rPt ) )
882 {
883 SwTwips nDiff = pLay->IsVertical() ? ( pLay->IsVertLR() ? ( rPt.X() - nFrameTop ) : ( nFrameTop - rPt.X() ) )
884 : ( rPt.Y() - nFrameTop );
885 if( bSct || pSect )
886 rRet.m_nSub += nDiff;
887 else
888 rRet.m_nMain += nDiff;
889 }
890 if ( pLay->IsFootnoteContFrame() && !static_cast<const SwLayoutFrame*>(pLay)->Lower() )
891 {
892 SwFrame *pDel = const_cast<SwFrame*>(pLay);
893 pDel->Cut();
895 return nullptr;
896 }
897 return pLay;
898 }
899 else
900 rRet.m_nMain = LONG_MAX;
901 }
902 }
903 return nullptr;
904}
905
906static sal_uInt64 lcl_FindCntDiff( const Point &rPt, const SwLayoutFrame *pLay,
907 const SwContentFrame *& rpCnt,
908 const bool bBody, const bool bFootnote )
909{
910 // Searches below pLay the nearest Cnt to the point. The reference point of
911 //the Contents is always the left upper corner.
912 //The Cnt should preferably be above the point.
913
914 rpCnt = nullptr;
915 sal_uInt64 nDistance = SAL_MAX_UINT64;
916 sal_uInt64 nNearest = SAL_MAX_UINT64;
917 const SwContentFrame *pCnt = pLay ? pLay->ContainsContent() : nullptr;
918
919 while ( pCnt && (bBody != pCnt->IsInDocBody() || bFootnote != pCnt->IsInFootnote()))
920 {
921 pCnt = pCnt->GetNextContentFrame();
922 if ( !pLay->IsAnLower( pCnt ) )
923 pCnt = nullptr;
924 }
925 const SwContentFrame *pNearest = pCnt;
926 if ( pCnt )
927 {
928 do
929 {
930 //Calculate the distance between those two points.
931 //'delta' X^2 + 'delta' Y^2 = 'distance'^2
932 sal_uInt64 dX = std::max( pCnt->getFrameArea().Left(), rPt.X() ) -
933 std::min( pCnt->getFrameArea().Left(), rPt.X() ),
934 dY = std::max( pCnt->getFrameArea().Top(), rPt.Y() ) -
935 std::min( pCnt->getFrameArea().Top(), rPt.Y() );
936 // square of the difference will do fine here
937 const sal_uInt64 nDiff = (dX * dX) + (dY * dY);
938 if ( pCnt->getFrameArea().Top() <= rPt.Y() )
939 {
940 if ( nDiff < nDistance )
941 {
942 //This one is the nearer one
943 nDistance = nNearest = nDiff;
944 rpCnt = pNearest = pCnt;
945 }
946 }
947 else if ( nDiff < nNearest )
948 {
949 nNearest = nDiff;
950 pNearest = pCnt;
951 }
952 pCnt = pCnt->GetNextContentFrame();
953 while ( pCnt &&
954 (bBody != pCnt->IsInDocBody() || bFootnote != pCnt->IsInFootnote()))
955 pCnt = pCnt->GetNextContentFrame();
956
957 } while ( pCnt && pLay->IsAnLower( pCnt ) );
958 }
959 if (nDistance == SAL_MAX_UINT64)
960 { rpCnt = pNearest;
961 return nNearest;
962 }
963 return nDistance;
964}
965
966static const SwContentFrame * lcl_FindCnt( const Point &rPt, const SwContentFrame *pCnt,
967 const bool bBody, const bool bFootnote )
968{
969 //Starting from pCnt searches the ContentFrame whose left upper corner is the
970 //nearest to the point.
971 //Always returns a ContentFrame.
972
973 //First the nearest Content inside the page which contains the Content is
974 //searched. Starting from this page the pages in both directions need to
975 //be considered. If possible a Content is returned whose Y-position is
976 //above the point.
977 const SwContentFrame *pRet, *pNew;
978 const SwLayoutFrame *pLay = pCnt->FindPageFrame();
979 sal_uInt64 nDist; // not sure if a sal_Int32 would be enough?
980
981 nDist = ::lcl_FindCntDiff( rPt, pLay, pNew, bBody, bFootnote );
982 if ( pNew )
983 pRet = pNew;
984 else
985 { pRet = pCnt;
986 nDist = SAL_MAX_UINT64;
987 }
988 const SwContentFrame *pNearest = pRet;
989 sal_uInt64 nNearest = nDist;
990
991 if ( pLay )
992 {
993 const SwLayoutFrame *pPge = pLay;
994 sal_uInt64 nOldNew = SAL_MAX_UINT64;
995 for ( int i = 0; pPge->GetPrev() && (i < 3); ++i )
996 {
997 pPge = static_cast<const SwLayoutFrame*>(pPge->GetPrev());
998 const sal_uInt64 nNew = ::lcl_FindCntDiff( rPt, pPge, pNew, bBody, bFootnote );
999 if ( nNew < nDist )
1000 {
1001 if ( pNew->getFrameArea().Top() <= rPt.Y() )
1002 {
1003 pRet = pNearest = pNew;
1004 nDist = nNearest = nNew;
1005 }
1006 else if ( nNew < nNearest )
1007 {
1008 pNearest = pNew;
1009 nNearest = nNew;
1010 }
1011 }
1012 else if (nOldNew != SAL_MAX_UINT64 && nNew > nOldNew)
1013 break;
1014 else
1015 nOldNew = nNew;
1016
1017 }
1018 pPge = pLay;
1019 nOldNew = SAL_MAX_UINT64;
1020 for ( int j = 0; pPge->GetNext() && (j < 3); ++j )
1021 {
1022 pPge = static_cast<const SwLayoutFrame*>(pPge->GetNext());
1023 const sal_uInt64 nNew = ::lcl_FindCntDiff( rPt, pPge, pNew, bBody, bFootnote );
1024 if ( nNew < nDist )
1025 {
1026 if ( pNew->getFrameArea().Top() <= rPt.Y() )
1027 {
1028 pRet = pNearest = pNew;
1029 nDist = nNearest = nNew;
1030 }
1031 else if ( nNew < nNearest )
1032 {
1033 pNearest = pNew;
1034 nNearest = nNew;
1035 }
1036 }
1037 else if (nOldNew != SAL_MAX_UINT64 && nNew > nOldNew)
1038 break;
1039 else
1040 nOldNew = nNew;
1041 }
1042 }
1043 if ( pRet->getFrameArea().Top() > rPt.Y() )
1044 return pNearest;
1045 else
1046 return pRet;
1047}
1048
1049static void lcl_PointToPrt( Point &rPoint, const SwFrame *pFrame )
1050{
1051 SwRect aTmp( pFrame->getFramePrintArea() );
1052 aTmp += pFrame->getFrameArea().Pos();
1053 if ( rPoint.getX() < aTmp.Left() )
1054 rPoint.setX(aTmp.Left());
1055 else if ( rPoint.getX() > aTmp.Right() )
1056 rPoint.setX(aTmp.Right());
1057 if ( rPoint.getY() < aTmp.Top() )
1058 rPoint.setY(aTmp.Top());
1059 else if ( rPoint.getY() > aTmp.Bottom() )
1060 rPoint.setY(aTmp.Bottom());
1061
1062}
1063
1069const SwContentFrame *FindAnchor( const SwFrame *pOldAnch, const Point &rNew,
1070 const bool bBodyOnly )
1071{
1072 //Search the nearest Cnt around the given document position in the text
1073 //flow. The given anchor is the starting Frame.
1074 const SwContentFrame* pCnt;
1075 if ( pOldAnch->IsContentFrame() )
1076 {
1077 pCnt = static_cast<const SwContentFrame*>(pOldAnch);
1078 }
1079 else
1080 {
1081 Point aTmp( rNew );
1082 const SwLayoutFrame *pTmpLay = static_cast<const SwLayoutFrame*>(pOldAnch);
1083 if( pTmpLay->IsRootFrame() )
1084 {
1085 SwRect aTmpRect( aTmp, Size(0,0) );
1086 pTmpLay = static_cast<const SwLayoutFrame*>(::FindPage( aTmpRect, pTmpLay->Lower() ));
1087 }
1088 pCnt = pTmpLay->GetContentPos( aTmp, false, bBodyOnly );
1089 }
1090
1091 //Take care to use meaningful ranges during search. This means to not enter
1092 //or leave header/footer in this case.
1093 const bool bBody = pCnt->IsInDocBody() || bBodyOnly;
1094 const bool bFootnote = !bBodyOnly && pCnt->IsInFootnote();
1095
1096 Point aNew( rNew );
1097 if ( bBody )
1098 {
1099 //#38848 drag from page margin into the body.
1100 const SwFrame *pPage = pCnt->FindPageFrame();
1101 ::lcl_PointToPrt( aNew, pPage->GetUpper() );
1102 SwRect aTmp( aNew, Size( 0, 0 ) );
1103 pPage = ::FindPage( aTmp, pPage );
1104 ::lcl_PointToPrt( aNew, pPage );
1105 }
1106
1107 if ( pCnt->IsInDocBody() == bBody && pCnt->getFrameArea().Contains( aNew ) )
1108 return pCnt;
1109 else if ( pOldAnch->IsInDocBody() || pOldAnch->IsPageFrame() )
1110 {
1111 // Maybe the selected anchor is on the same page as the current anchor.
1112 // With this we won't run into problems with the columns.
1113 Point aTmp( aNew );
1114 const SwContentFrame *pTmp = pCnt->FindPageFrame()->
1115 GetContentPos( aTmp, false, true );
1116 if ( pTmp && pTmp->getFrameArea().Contains( aNew ) )
1117 return pTmp;
1118 }
1119
1120 //Starting from the anchor we now search in both directions until we found
1121 //the nearest one respectively.
1122 //Not the direct distance is relevant but the distance which needs to be
1123 //traveled through the text flow.
1124 const SwContentFrame *pUpLst;
1125 const SwContentFrame *pUpFrame = pCnt;
1126 SwDistance nUp, nUpLst;
1127 ::lcl_CalcDownDist( nUp, aNew, pUpFrame );
1128 SwDistance nDown = nUp;
1129 bool bNegAllowed = true;// Make it possible to leave the negative section once.
1130 do
1131 {
1132 pUpLst = pUpFrame; nUpLst = nUp;
1133 pUpFrame = pUpLst->GetPrevContentFrame();
1134 while ( pUpFrame &&
1135 (bBody != pUpFrame->IsInDocBody() || bFootnote != pUpFrame->IsInFootnote()))
1136 pUpFrame = pUpFrame->GetPrevContentFrame();
1137 if ( pUpFrame )
1138 {
1139 ::lcl_CalcDownDist( nUp, aNew, pUpFrame );
1140 //It makes sense to search further, if the distance grows inside
1141 //a table.
1142 if ( pUpLst->IsInTab() && pUpFrame->IsInTab() )
1143 {
1144 while ( pUpFrame && ((nUpLst < nUp && pUpFrame->IsInTab()) ||
1145 bBody != pUpFrame->IsInDocBody()) )
1146 {
1147 pUpFrame = pUpFrame->GetPrevContentFrame();
1148 if ( pUpFrame )
1149 ::lcl_CalcDownDist( nUp, aNew, pUpFrame );
1150 }
1151 }
1152 }
1153 if ( !pUpFrame )
1154 nUp.m_nMain = LONG_MAX;
1155 if (nUp.m_nMain >= 0 && LONG_MAX != nUp.m_nMain)
1156 {
1157 bNegAllowed = false;
1158 if (nUpLst.m_nMain < 0) //don't take the wrong one, if the value
1159 //just changed from negative to positive.
1160 { pUpLst = pUpFrame;
1161 nUpLst = nUp;
1162 }
1163 }
1164 } while (pUpFrame && ((bNegAllowed && nUp.m_nMain < 0) || (nUp <= nUpLst)));
1165
1166 const SwContentFrame *pDownLst;
1167 const SwContentFrame *pDownFrame = pCnt;
1168 SwDistance nDownLst;
1169 if (nDown.m_nMain < 0)
1170 nDown.m_nMain = LONG_MAX;
1171 do
1172 {
1173 pDownLst = pDownFrame; nDownLst = nDown;
1174 pDownFrame = pDownLst->GetNextContentFrame();
1175 while ( pDownFrame &&
1176 (bBody != pDownFrame->IsInDocBody() || bFootnote != pDownFrame->IsInFootnote()))
1177 pDownFrame = pDownFrame->GetNextContentFrame();
1178 if ( pDownFrame )
1179 {
1180 ::lcl_CalcDownDist( nDown, aNew, pDownFrame );
1181 if (nDown.m_nMain < 0)
1182 nDown.m_nMain = LONG_MAX;
1183 //It makes sense to search further, if the distance grows inside
1184 //a table.
1185 if ( pDownLst->IsInTab() && pDownFrame->IsInTab() )
1186 {
1187 while (pDownFrame
1188 && ((nDown.m_nMain != LONG_MAX && pDownFrame->IsInTab())
1189 || bBody != pDownFrame->IsInDocBody()))
1190 {
1191 pDownFrame = pDownFrame->GetNextContentFrame();
1192 if ( pDownFrame )
1193 ::lcl_CalcDownDist( nDown, aNew, pDownFrame );
1194 if (nDown.m_nMain < 0)
1195 nDown.m_nMain = LONG_MAX;
1196 }
1197 }
1198 }
1199 if ( !pDownFrame )
1200 nDown.m_nMain = LONG_MAX;
1201
1202 } while (pDownFrame && nDown <= nDownLst && nDown.m_nMain != LONG_MAX
1203 && nDownLst.m_nMain != LONG_MAX);
1204
1205 //If we couldn't find one in both directions, we'll search the Content whose
1206 //left upper corner is the nearest to the point. Such a situation may
1207 //happen, if the point doesn't lay in the text flow but in any margin.
1208 if (nDownLst.m_nMain == LONG_MAX && nUpLst.m_nMain == LONG_MAX)
1209 {
1210 // If an OLE objects, which is contained in a fly frame
1211 // is resized in inplace mode and the new Position is outside the
1212 // fly frame, we do not want to leave our fly frame.
1213 if ( pCnt->IsInFly() )
1214 return pCnt;
1215
1216 return ::lcl_FindCnt( aNew, pCnt, bBody, bFootnote );
1217 }
1218 else
1219 return nDownLst < nUpLst ? pDownLst : pUpLst;
1220}
1221
1222void SwFlyAtContentFrame::SetAbsPos( const Point &rNew )
1223{
1224 SwPageFrame *pOldPage = FindPageFrame();
1225 const SwRect aOld( GetObjRectWithSpaces() );
1226 Point aNew( rNew );
1227
1229 aNew.setX(aNew.getX() + getFrameArea().Width());
1230 SwContentFrame *pCnt = const_cast<SwContentFrame*>(::FindAnchor( GetAnchorFrame(), aNew ));
1231 if( pCnt->IsProtected() )
1232 pCnt = const_cast<SwContentFrame*>(static_cast<const SwContentFrame*>(GetAnchorFrame()));
1233
1234 SwPageFrame *pTmpPage = nullptr;
1235 const bool bVert = pCnt->IsVertical();
1236
1237 const bool bVertL2R = pCnt->IsVertLR();
1238 const bool bRTL = pCnt->IsRightToLeft();
1239
1240 if( ( !bVert != !GetAnchorFrame()->IsVertical() ) ||
1241 ( !bRTL != !GetAnchorFrame()->IsRightToLeft() ) )
1242 {
1243 if( bVert || bRTL )
1244 aNew.setX(aNew.getX() + getFrameArea().Width());
1245 else
1246 aNew.setX(aNew.getX() - getFrameArea().Width());
1247 }
1248
1249 if ( pCnt->IsInDocBody() )
1250 {
1251 //#38848 drag from page margin into the body.
1252 pTmpPage = pCnt->FindPageFrame();
1253 ::lcl_PointToPrt( aNew, pTmpPage->GetUpper() );
1254 SwRect aTmp( aNew, Size( 0, 0 ) );
1255 pTmpPage = const_cast<SwPageFrame*>(static_cast<const SwPageFrame*>(::FindPage( aTmp, pTmpPage )));
1256 ::lcl_PointToPrt( aNew, pTmpPage );
1257 }
1258
1259 //Setup RelPos, only invalidate if requested.
1260 //rNew is an absolute position. We need to calculate the distance from rNew
1261 //to the anchor inside the text flow to correctly set RelPos.
1263 const SwFrame *pFrame = nullptr;
1264 SwTwips nY;
1265 if ( pCnt->getFrameArea().Contains( aNew ) )
1266 {
1267 // #i70582#
1268 if ( bVert )
1269 {
1270 nY = pCnt->getFrameArea().Left() - rNew.X();
1271 if ( bVertL2R )
1272 nY = -nY;
1273 else
1274 nY += pCnt->getFrameArea().Width() - getFrameArea().Width();
1275 nY -= pCnt->GetUpperSpaceAmountConsideredForPrevFrameAndPageGrid();
1276 }
1277 else
1278 nY = rNew.Y() - pCnt->getFrameArea().Top() - pCnt->GetUpperSpaceAmountConsideredForPrevFrameAndPageGrid();
1279 }
1280 else
1281 {
1282 SwDistance aDist;
1283 pFrame = ::lcl_CalcDownDist( aDist, aNew, pCnt );
1284 nY = aDist.m_nMain + aDist.m_nSub;
1285 }
1286
1287 SwTwips nX = 0;
1288
1289 if ( pCnt->IsFollow() )
1290 {
1291 // Flys are never attached to the follow but always to the master,
1292 // which we're going to search now.
1293 const SwContentFrame *pOriginal = pCnt;
1294 const SwContentFrame *pFollow = pCnt;
1295 while ( pCnt->IsFollow() )
1296 {
1297 do
1298 {
1299 SwContentFrame* pPrev = pCnt->GetPrevContentFrame();
1300 if (!pPrev)
1301 {
1302 SAL_WARN("sw.core", "very unexpected missing PrevContentFrame");
1303 break;
1304 }
1305 pCnt = pPrev;
1306 }
1307 while ( pCnt->GetFollow() != pFollow );
1308 pFollow = pCnt;
1309 }
1310 SwTwips nDiff = 0;
1311 do
1312 { const SwFrame *pUp = pFollow->GetUpper();
1313 if( pUp->IsVertical() )
1314 {
1315 if ( pUp->IsVertLR() )
1316 nDiff += pUp->getFramePrintArea().Width() - pFollow->GetRelPos().getX();
1317 else
1318 nDiff += pFollow->getFrameArea().Left() + pFollow->getFrameArea().Width()
1319 - pUp->getFrameArea().Left() - pUp->getFramePrintArea().Left();
1320 }
1321 else
1322 nDiff += pUp->getFramePrintArea().Height() - pFollow->GetRelPos().Y();
1323 pFollow = pFollow->GetFollow();
1324 } while ( pFollow != pOriginal );
1325 nY += nDiff;
1326 if( bVert )
1327 nX = pCnt->getFrameArea().Top() - pOriginal->getFrameArea().Top();
1328 else
1329 nX = pCnt->getFrameArea().Left() - pOriginal->getFrameArea().Left();
1330 }
1331
1332 if ( nY == LONG_MAX )
1333 {
1334 // #i70582#
1335 const SwTwips nTopForObjPos = lcl_GetTopForObjPos(pCnt, bVert, bVertL2R);
1336 if( bVert )
1337 {
1338 if ( bVertL2R )
1339 nY = rNew.X() - nTopForObjPos;
1340 else
1341 nY = nTopForObjPos - rNew.X();
1342 }
1343 else
1344 {
1345 nY = rNew.Y() - nTopForObjPos;
1346 }
1347 }
1348
1349 SwFlyFrameFormat *pFormat = GetFormat();
1350
1351 if( bVert )
1352 {
1353 if( !pFrame )
1354 nX += rNew.Y() - pCnt->getFrameArea().Top();
1355 else
1356 nX = rNew.Y() - pFrame->getFrameArea().Top();
1357 }
1358 else
1359 {
1360 if( !pFrame )
1361 {
1362 if ( pCnt->IsRightToLeft() )
1363 nX += pCnt->getFrameArea().Right() - rNew.X() - getFrameArea().Width();
1364 else
1365 nX += rNew.X() - pCnt->getFrameArea().Left();
1366 }
1367 else
1368 {
1369 if ( pFrame->IsRightToLeft() )
1370 nX += pFrame->getFrameArea().Right() - rNew.X() - getFrameArea().Width();
1371 else
1372 nX = rNew.X() - pFrame->getFrameArea().Left();
1373 }
1374 }
1375 GetFormat()->GetDoc()->GetIDocumentUndoRedo().StartUndo( SwUndoId::START, nullptr );
1376
1377 if( pCnt != GetAnchorFrame() || ( IsAutoPos() && pCnt->IsTextFrame() &&
1378 GetFormat()->getIDocumentSettingAccess().get(DocumentSettingId::HTML_MODE)) )
1379 {
1380 //Set the anchor attribute according to the new Cnt.
1381 SwFormatAnchor aAnch( pFormat->GetAnchor() );
1382 SwPosition pos = *aAnch.GetContentAnchor();
1383 if( IsAutoPos() && pCnt->IsTextFrame() )
1384 {
1385 SwTextFrame const*const pTextFrame(static_cast<SwTextFrame const*>(pCnt));
1387 Point aPt( rNew );
1388 if( pCnt->GetModelPositionForViewPoint( &pos, aPt, &eTmpState )
1389 && FrameContainsNode(*pTextFrame, pos.GetNodeIndex()))
1390 {
1391 const SwTextAttr *const pTextInputField =
1392 pos.GetNode().GetTextNode()->GetTextAttrAt(
1394 if (pTextInputField != nullptr)
1395 {
1396 pos.SetContent( pTextInputField->GetStart() );
1397 }
1399 if( text::RelOrientation::CHAR == pFormat->GetVertOrient().GetRelationOrient() )
1400 nY = LONG_MAX;
1401 if( text::RelOrientation::CHAR == pFormat->GetHoriOrient().GetRelationOrient() )
1402 nX = LONG_MAX;
1403 }
1404 else
1405 {
1406 pos = pTextFrame->MapViewToModelPos(TextFrameIndex(0));
1407 }
1408 }
1409 else if (pCnt->IsTextFrame())
1410 {
1411 pos = static_cast<SwTextFrame const*>(pCnt)->MapViewToModelPos(TextFrameIndex(0));
1412 }
1413 else // is that even possible? maybe if there was a change of anchor type from AT_FLY or something?
1414 {
1415 assert(pCnt->IsNoTextFrame());
1416 pos.Assign(*static_cast<SwNoTextFrame*>(pCnt)->GetNode());
1417 }
1418 aAnch.SetAnchor( &pos );
1419
1420 // handle change of anchor node:
1421 // if count of the anchor frame also change, the fly frames have to be
1422 // re-created. Thus, delete all fly frames except the <this> before the
1423 // anchor attribute is change and re-create them afterwards.
1424 {
1425 SwHandleAnchorNodeChg aHandleAnchorNodeChg( *pFormat, aAnch, this );
1426 pFormat->GetDoc()->SetAttr( aAnch, *pFormat );
1427 }
1428 }
1429 else if ( pTmpPage && pTmpPage != GetPageFrame() )
1430 GetPageFrame()->MoveFly( this, pTmpPage );
1431
1432 const Point aRelPos = bVert ? Point( -nY, nX ) : Point( nX, nY );
1433 ChgRelPos( aRelPos );
1434 GetFormat()->GetDoc()->GetIDocumentUndoRedo().EndUndo( SwUndoId::END, nullptr );
1435
1436 if ( pOldPage != FindPageFrame() )
1438}
1439
1447{
1448 SwPageFrame* pPageFrame( nullptr );
1449 if ( GetVertPosOrientFrame() )
1450 {
1451 pPageFrame = const_cast<SwPageFrame*>(GetVertPosOrientFrame()->FindPageFrame());
1452 }
1453 if ( pPageFrame && GetPageFrame() != pPageFrame )
1454 {
1455 RegisterAtPage(*pPageFrame);
1456 }
1457}
1458
1460{
1461 assert(GetPageFrame() != &rPageFrame);
1462 if (GetPageFrame())
1463 {
1464 GetPageFrame()->MoveFly( this, &rPageFrame );
1465 }
1466 else
1467 {
1468 rPageFrame.AppendFlyToPage( this );
1469 }
1470}
1471
1472// #i26791#
1474{
1475 // if fly frame position is valid, nothing is to do. Thus, return
1477 {
1478 return;
1479 }
1480
1481 // #i26791# - validate position flag here.
1483
1484 // #i35911# - no calculation of new position, if
1485 // anchored object is marked that it clears its environment and its
1486 // environment is already cleared.
1487 // before checking for cleared environment
1488 // check, if member <mpVertPosOrientFrame> is set.
1489 if ( GetVertPosOrientFrame() &&
1491 {
1492 return;
1493 }
1494
1495 // use new class to position object
1497 aObjPositioning( *GetVirtDrawObj() );
1498 aObjPositioning.CalcPosition();
1499
1500 SetVertPosOrientFrame ( aObjPositioning.GetVertPosOrientFrame() );
1501}
1502
1503// #i28701#
1505{
1506 bool bAllowed( SwFlyFreeFrame::InvalidationAllowed( _nInvalid ) );
1507
1508 // forbiddance of base instance can't be over ruled.
1509 if ( bAllowed )
1510 {
1511 if ( _nInvalid == INVALID_POS ||
1512 _nInvalid == INVALID_ALL )
1513 {
1514 bAllowed = InvalidationOfPosAllowed();
1515 }
1516 }
1517
1518 return bAllowed;
1519}
1520
1521/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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...
bool operator<=(const BigInt &rVal1, const BigInt &rVal2)
bool GetValue() const
SfxHintId GetId() const
wrapper class for the positioning of Writer fly frames and drawing objects
void SetTmpConsiderWrapInfluenceOfOtherObjs()
method to apply temporary consideration of wrapping style influence to the anchored objects,...
const SwFrame * GetAnchorFrame() const
bool InvalidationOfPosAllowed() const
method to determine, if invalidation of position is allowed
void ResetLastCharRectHeight()
SwFrame * AnchorFrame()
void SetVertPosOrientFrame(const SwLayoutFrame &_rVertPosOrientFrame)
SwFrame * GetAnchorFrameContainingAnchPos()
determine anchor frame containing the anchor position
void ClearCharRectAndTopOfLine()
reset members <maLastCharRect> and <mnLastTopOfLine>
const SwLayoutFrame * GetVertPosOrientFrame() const
void SetTmpConsiderWrapInfluence(const bool _bTmpConsiderWrapInfluence)
bool OverlapsPrevColumn() const
method to determine, if the anchored object is overlapping with a previous column
bool ConsiderObjWrapInfluenceOnObjPos() const
method to determine, if wrapping style influence of the anchored object has to be considered on the o...
SwPageFrame * GetPageFrame()
bool HasClearedEnvironment() const
method to determine, if due to anchored object size and wrapping style, its layout environment is cle...
const SwRect & GetObjRectWithSpaces() const
method to determine object area inclusive its spacing
bool ConsiderObjWrapInfluenceOfOtherObjs() const
method to determine, if other anchored objects, also attached at to the anchor frame,...
void SetRestartLayoutProcess(const bool _bRestartLayoutProcess)
bool ClearedEnvironment() const
SwContentFrame is the layout for content nodes: a common base class for text (paragraph) and non-text...
Definition: cntfrm.hxx:58
SwContentFrame * GetPrevContentFrame() const
Definition: cntfrm.hxx:127
const SwContentFrame * GetFollow() const
Definition: cntfrm.hxx:135
SwContentFrame * GetNextContentFrame() const
Definition: cntfrm.hxx:119
SwTextFrame * FindMaster() const
Definition: flowfrm.cxx:737
SwContentFrame * getLayoutFrame(const SwRootFrame *, const SwPosition *pPos=nullptr, std::pair< Point, bool > const *pViewPosAndCalcFrame=nullptr) const
Definition: node.cxx:1230
Definition: doc.hxx:194
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
IDocumentUndoRedo & GetIDocumentUndoRedo()
Definition: doc.cxx:150
virtual bool InvalidationAllowed(const InvalidationType _nInvalid) const override
method to determine, if an invalidation is allowed.
Definition: flycnt.cxx:1504
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
virtual void MakeObjPos() override
method to determine position for the object and set the position at the object
Definition: flycnt.cxx:1473
void SetAbsPos(const Point &rNew)
Definition: flycnt.cxx:1222
virtual void RegisterAtCorrectPage() override
method to assure that anchored object is registered at the correct page frame
Definition: flycnt.cxx:1446
virtual void SwClientNotify(const SwModify &, const SfxHint &) override
Definition: flycnt.cxx:85
SwFlyAtContentFrame(SwFlyFrameFormat *, SwFrame *, SwFrame *pAnchor)
Definition: flycnt.cxx:76
virtual bool IsFormatPossible() const override
method to determine, if a format on the Writer fly frame is possible
Definition: flycnt.cxx:575
virtual void RegisterAtPage(SwPageFrame &) override
Definition: flycnt.cxx:1459
general base class for all free-flowing frames
Definition: flyfrm.hxx:79
const SwVirtFlyDrawObj * GetVirtDrawObj() const
Definition: fly.cxx:2811
virtual const SwFlyFrameFormat * GetFormat() const override
Definition: fly.cxx:2905
static const SwFormatAnchor * GetAnchorFromPoolItem(const SfxPoolItem &rItem)
Definition: fly.cxx:2976
void SetNotifyBack()
Definition: flyfrm.hxx:225
bool IsLowerOf(const SwLayoutFrame *pUpper) const
Definition: fly.cxx:2183
virtual const SwFlyFrame * DynCastFlyFrame() const override
Definition: fly.cxx:2989
virtual SwFrameFormat & GetFrameFormat() override
Definition: fly.cxx:2830
virtual void SwClientNotify(const SwModify &rMod, const SfxHint &rHint) override
Definition: fly.cxx:668
bool IsLocked() const
Definition: flyfrm.hxx:213
bool m_bAtCnt
RndStdIds::FLY_AT_PARA, anchored at paragraph or RndStdIds::FLY_AT_CHAR.
Definition: flyfrm.hxx:129
bool m_bAutoPosition
RndStdIds::FLY_AT_CHAR, anchored at character.
Definition: flyfrm.hxx:132
virtual const IDocumentDrawModelAccess & getIDocumentDrawModelAccess() override
Definition: fly.cxx:308
bool IsClipped() const
Definition: flyfrm.hxx:228
bool IsAutoPos() const
Definition: flyfrm.hxx:214
void ChgRelPos(const Point &rAbsPos)
Change the relative position.
Definition: fly.cxx:1133
virtual void MakeAll(vcl::RenderContext *pRenderContext) override
Definition: flylay.cxx:113
virtual void NotifyBackground(SwPageFrame *pPage, const SwRect &rRect, PrepareHint eHint) override
Notifies the background (all ContentFrames that currently are overlapping).
Definition: flylay.cxx:107
virtual bool IsFormatPossible() const override
method to determine, if a format on the Writer fly frame is possible
Definition: flylay.cxx:710
FlyAnchors.
Definition: fmtanchr.hxx:37
void SetAnchor(const SwPosition *pPos)
Definition: atrfrm.cxx:1586
RndStdIds GetAnchorId() const
Definition: fmtanchr.hxx:67
const SwPosition * GetContentAnchor() const
Definition: fmtanchr.hxx:74
SwNode * GetAnchorNode() const
Definition: atrfrm.cxx:1606
sal_uInt8 GetWidthPercent() const
Definition: fmtfsize.hxx:91
sal_uInt8 GetHeightPercent() const
Definition: fmtfsize.hxx:88
Defines the horizontal position of a fly frame.
Definition: fmtornt.hxx:73
void SetPos(SwTwips nNew)
Definition: fmtornt.hxx:100
SwTwips GetPos() const
Definition: fmtornt.hxx:99
sal_Int16 GetRelationOrient() const
Definition: fmtornt.hxx:95
void SetSurround(css::text::WrapTextMode eNew)
Definition: fmtsrnd.hxx:55
css::text::WrapTextMode GetSurround() const
Definition: fmtsrnd.hxx:51
Defines the vertical position of a fly frame.
Definition: fmtornt.hxx:37
sal_Int16 GetRelationOrient() const
Definition: fmtornt.hxx:58
SwTwips GetPos() const
Definition: fmtornt.hxx:62
void SetPos(SwTwips nNew)
Definition: fmtornt.hxx:63
const SwDoc * GetDoc() const
The document is set in SwAttrPool now, therefore you always can access it.
Definition: format.hxx:139
const SwFormatFrameSize & GetFrameSize(bool=true) const
Definition: fmtfsize.hxx:104
const SwFormatVertOrient & GetVertOrient(bool=true) const
Definition: fmtornt.hxx:113
const SwFormatFollowTextFlow & GetFollowTextFlow(bool=true) const
const SwFormatAnchor & GetAnchor(bool=true) const
Definition: fmtanchr.hxx:88
const SwFormatSurround & GetSurround(bool=true) const
Definition: fmtsrnd.hxx:66
const SwFormatHoriOrient & GetHoriOrient(bool=true) const
Definition: fmtornt.hxx:115
virtual bool SetFormatAttr(const SfxPoolItem &rAttr)
Definition: format.cxx:447
const SwRect & getFrameArea() const
Definition: frame.hxx:179
bool isFrameAreaDefinitionValid() const
Definition: frame.hxx:171
bool isFrameAreaPositionValid() const
Definition: frame.hxx:166
const SwRect & getFramePrintArea() const
Definition: frame.hxx:180
void setFrameAreaPositionValid(bool bNew)
Definition: wsfrm.cxx:84
Style of a layout element.
Definition: frmfmt.hxx:62
SdrObject * FindRealSdrObject()
Definition: atrfrm.cxx:2795
Base class of the Writer layout elements.
Definition: frame.hxx:315
virtual void Cut()=0
bool IsCellFrame() const
Definition: frame.hxx:1226
bool IsFootnoteContFrame() const
Definition: frame.hxx:1198
void RemoveFly(SwFlyFrame *pToRemove)
Definition: fly.cxx:2220
bool IsTextFrame() const
Definition: frame.hxx:1234
SwTextFrame * DynCastTextFrame()
Definition: findfrm.cxx:1895
bool IsInDocBody() const
Definition: frame.hxx:943
SwFlyFrame * FindFlyFrame()
Definition: frame.hxx:1111
SwSectionFrame * FindSctFrame()
Definition: frame.hxx:1115
SwTabFrame * FindTabFrame()
Definition: frame.hxx:1099
SwFrame * GetNext()
Definition: frame.hxx:676
bool HasFixSize() const
Definition: frame.hxx:670
bool IsPageFrame() const
Definition: frame.hxx:1178
bool IsColLocked() const
Definition: frame.hxx:886
bool IsColumnFrame() const
Definition: frame.hxx:1182
InvalidationType
enumeration for the different invalidations #i28701#
Definition: frame.hxx:489
@ INVALID_POS
Definition: frame.hxx:490
@ INVALID_ALL
Definition: frame.hxx:490
virtual bool InvalidationAllowed(const InvalidationType _nInvalid) const
method to determine, if an invalidation is allowed.
Definition: wsfrm.cxx:1951
void InvalidatePos_()
Definition: frame.hxx:787
bool IsInFootnote() const
Definition: frame.hxx:949
const SwSortedObjs * GetDrawObjs() const
Definition: frame.hxx:564
bool IsInTab() const
Definition: frame.hxx:955
bool IsProtected() const
Is the Frame or rather the Section in which it lies protected?
Definition: trvlfrm.cxx:1639
bool IsRightToLeft() const
Definition: frame.hxx:987
bool IsInFly() const
Definition: frame.hxx:961
void AppendFly(SwFlyFrame *pNew)
Definition: fly.cxx:2202
const SwRowFrame * IsInFollowFlowRow() const
Definition: findfrm.cxx:1842
virtual bool GetModelPositionForViewPoint(SwPosition *, Point &, SwCursorMoveState *=nullptr, bool bTestBackground=false) const
Definition: unusedf.cxx:47
bool IsRootFrame() const
Definition: frame.hxx:1174
bool IsFooterFrame() const
Definition: frame.hxx:1194
SwLayoutFrame * GetUpper()
Definition: frame.hxx:678
bool IsVertical() const
Definition: frame.hxx:973
SwLayoutFrame * GetLeaf(MakePageType eMakePage, bool bFwd)
Definition: flowfrm.cxx:842
void InvalidatePage(const SwPageFrame *pPage=nullptr) const
Invalidates the page in which the Frame is currently placed.
Definition: wsfrm.cxx:613
SwRootFrame * getRootFrame()
Definition: frame.hxx:679
bool IsNoTextFrame() const
Definition: frame.hxx:1238
Point GetRelPos() const
Definition: trvlfrm.cxx:1807
bool IsContentFrame() const
Definition: frame.hxx:1230
SwFrame * GetPrev()
Definition: frame.hxx:677
void InvalidateSize_()
Definition: frame.hxx:771
bool IsSctFrame() const
Definition: frame.hxx:1214
bool IsVertLR() const
Definition: frame.hxx:979
SwPageFrame * FindPageFrame()
Definition: frame.hxx:680
SwFrame * FindFooterOrHeader()
Definition: findfrm.cxx:602
static void DestroyFrame(SwFrame *const pFrame)
this is the only way to delete a SwFrame instance
Definition: ssfrm.cxx:388
bool IsInSct() const
Definition: frame.hxx:967
A layout frame is a frame that contains other frames (m_pLower), e.g. SwPageFrame or SwTabFrame.
Definition: layfrm.hxx:36
bool IsAnLower(const SwFrame *) const
Definition: findfrm.cxx:231
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
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:1183
const SwFrame * Lower() const
Definition: layfrm.hxx:101
static void InsertMovedFwdFrame(const SwDoc &_rDoc, const SwTextFrame &_rMovedFwdFrameByObjPos, const sal_uInt32 _nToPageNum)
Definition: layouter.cxx:312
static bool FrameMovedFwdByObjPos(const SwDoc &_rDoc, const SwTextFrame &_rTextFrame, sal_uInt32 &_ornToPageNum)
Definition: layouter.cxx:342
static void RemoveMovedFwdFrame(const SwDoc &_rDoc, const SwTextFrame &_rTextFrame)
Definition: layouter.cxx:332
const SwContentNode * GetNode() const
Definition: notxtfrm.hxx:77
Marks a node in the document model.
Definition: ndindex.hxx:31
SwNode & GetNode() const
Definition: ndindex.hxx:136
SwNodeOffset GetIndex() const
Definition: ndindex.hxx:171
SwContentNode * GetContentNode()
Definition: node.hxx:664
static void FormatAnchorFrameAndItsPrevs(SwTextFrame &_rAnchorTextFrame)
method to format given anchor text frame and its previous frames
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'
A page of the document layout.
Definition: pagefrm.hxx:58
void AppendFlyToPage(SwFlyFrame *pNew)
Definition: flylay.cxx:788
void MoveFly(SwFlyFrame *pToMove, SwPageFrame *pDest)
Definition: flylay.cxx:950
tools::Long GetHeight(const SwRect &rRect) const
Definition: frame.hxx:1381
tools::Long GetTop(const SwRect &rRect) const
Definition: frame.hxx:1376
Point GetPos(const SwRect &rRect) const
Definition: frame.hxx:1382
Of course Writer needs its own rectangles.
Definition: swrect.hxx:35
void Height(tools::Long nNew)
Definition: swrect.hxx:193
void Top(const tools::Long nTop)
Definition: swrect.hxx:206
void Right(const tools::Long nRight)
Definition: swrect.hxx:202
void Bottom(const tools::Long nBottom)
Definition: swrect.hxx:211
void Pos(const Point &rNew)
Definition: swrect.hxx:171
bool Contains(const Point &rPOINT) const
Definition: swrect.hxx:356
void Left(const tools::Long nLeft)
Definition: swrect.hxx:197
void Width(tools::Long nNew)
Definition: swrect.hxx:189
class for collecting anchored objects
Definition: sortedobjs.hxx:49
A wrapper around SfxPoolItem to store the start position of (usually) a text portion,...
Definition: txatbase.hxx:44
sal_Int32 GetStart() const
Definition: txatbase.hxx:88
static tools::Rectangle getRelativeTextRectangle(SdrObject *pShape)
Return the textbox rectangle of a draw shape (in relative twips).
static SwFrameFormat * getOtherTextBoxFormat(const SwFrameFormat *pFormat, sal_uInt16 nType, const SdrObject *pObject=nullptr)
If we have an associated TextFrame, then return that.
static void getProperty(SwFrameFormat const *pShape, sal_uInt16 nWID, sal_uInt8 nMemberID, css::uno::Any &rValue)
Get a property of the underlying TextFrame.
Represents the visualization of a paragraph.
Definition: txtfrm.hxx:165
SwPosition MapViewToModelPos(TextFrameIndex nIndex) const
Definition: txtfrm.cxx:1246
SwTextNode * GetTextNodeFirst()
Definition: txtfrm.hxx:463
virtual void CalcPosition() override
calculate position of object
const SwLayoutFrame & GetVertPosOrientFrame() const
frame, at which the vertical position is oriented at
constexpr tools::Long Top() const
constexpr tools::Long Left() const
@ SetOnlyText
stay with the cursor inside text
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:1069
static void lcl_PointToPrt(Point &rPoint, const SwFrame *pFrame)
Definition: flycnt.cxx:1049
static const SwFrame * lcl_CalcDownDist(SwDistance &rRet, const Point &rPt, const SwContentFrame *pCnt)
Definition: flycnt.cxx:607
static sal_uInt64 lcl_FindCntDiff(const Point &rPt, const SwLayoutFrame *pLay, const SwContentFrame *&rpCnt, const bool bBody, const bool bFootnote)
Definition: flycnt.cxx:906
static const SwContentFrame * lcl_FindCnt(const Point &rPt, const SwContentFrame *pCnt, const bool bBody, const bool bFootnote)
Definition: flycnt.cxx:966
@ MAKEPAGE_NONE
Definition: frame.hxx:114
void Notify_Background(const SdrObject *pObj, SwPageFrame *pPage, const SwRect &rRect, const PrepareHint eHint, const bool bInva)
Definition: frmtool.cxx:3390
bool bSetCompletePaintOnInvalidate
Definition: frmtool.cxx:105
const SwFrame * FindPage(const SwRect &rRect, const SwFrame *pPage)
Definition: frmtool.cxx:3729
constexpr TypedWhichId< SwFlyFrameFormat > RES_FLYFRMFMT(156)
constexpr TypedWhichId< SwFormatField > RES_TXTATR_INPUTFIELD(55)
static bool bFootnote
Definition: insfnote.cxx:33
const long LONG_MAX
#define SAL_WARN(area, stream)
int i
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
bool FrameContainsNode(SwContentFrame const &rFrame, SwNodeOffset nNodeIndex)
Definition: txtfrm.cxx:290
@ Parent
EXPAND : (Start < nIndex <= End)
SwNodeOffset min(const SwNodeOffset &a, const SwNodeOffset &b)
Definition: nodeoffset.hxx:35
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:1019
Marks a position in the document model.
Definition: pam.hxx:37
tools::Long SwTwips
Definition: swtypes.hxx:51
#define SAL_MAX_UINT64
#define UNO_NAME_FRAME_ISAUTOMATIC_HEIGHT
Definition: unoprnms.hxx:596
size_t pos
bool operator<(const wwFont &r1, const wwFont &r2)
Definition: wrtw8sty.cxx:841