49 mpVertPosOrientFrame( nullptr ),
51 maOffsetToFrameAnchorPos(
Point() ),
52 mbAnchorToChar ( false ),
53 mpToCharOrientFrame( nullptr ),
54 mpToCharRect( nullptr ),
56 mnToCharTopOfLine( 0 )
85 OSL_ENSURE( dynamic_cast<const SwTextFrame*>( &
GetAnchorFrame()) !=
nullptr ,
86 "SwToContentAnchoredObjectPosition::GetAnchorTextFrame() - wrong anchor frame type" );
96 const bool _bGrowInTable,
99 bool bVertPosFits =
false;
101 if ( _nRelPosY <= _nAvail )
107 if ( _pUpperOfOrientFrame->
IsInSct() )
111 bVertPosFits = pSctFrame->
GetUpper()->
Grow( _nRelPosY - _nAvail,
true ) > 0;
116 bVertPosFits =
const_cast<SwLayoutFrame*
>(_pUpperOfOrientFrame)->
117 Grow( _nRelPosY - _nAvail,
true ) > 0;
119 _orpLayoutFrameToGrow =
const_cast<SwLayoutFrame*
>(_pUpperOfOrientFrame);
122 else if ( _pUpperOfOrientFrame->
IsInTab() && _bGrowInTable )
127 Grow( _nRelPosY - _nAvail,
true );
128 bVertPosFits = ( nTwipsGrown == ( _nRelPosY - _nAvail ) );
130 _orpLayoutFrameToGrow =
const_cast<SwLayoutFrame*
>(_pUpperOfOrientFrame);
163 const bool bNoSurround = rSurround.
GetSurround() == css::text::WrapTextMode_NONE;
164 const bool bWrapThrough = rSurround.
GetSurround() == css::text::WrapTextMode_THROUGH;
187 bool bMoveable = rAnchorTextFrame.
IsMoveable();
190 const SwTextFrame* pOrientFrame = &rAnchorTextFrame;
224 pOrientFrame = &(
const_cast<SwTextFrame&
>(rAnchorTextFrame).GetFrameAtOfst(
229 aRectFnSet.
Refresh(pOrientFrame);
249 aVert.GetRelationOrient(),
250 nAlignAreaHeight, nAlignAreaOffset );
258 const SwTwips nHeightBetweenOffsetAndMargin = nAlignAreaOffset + nTopMarginHeight;
261 SwTwips nRelPosY = nAlignAreaOffset;
274 switch ( aVert.GetVertOrient() )
276 case text::VertOrientation::CHAR_BOTTOM:
281 nRelPosY += nAlignAreaHeight + nUpperSpace;
284 nRelPosY += nObjHeight;
290 case text::VertOrientation::TOP:
295 aVert.GetRelationOrient() == text::RelOrientation::TEXT_LINE )
297 nRelPosY -= (nObjHeight + nLowerSpace);
301 nRelPosY += nUpperSpace;
306 case text::VertOrientation::LINE_TOP:
309 aVert.GetRelationOrient() == text::RelOrientation::TEXT_LINE )
311 nRelPosY -= (nObjHeight + nLowerSpace);
315 OSL_FAIL(
"<SwToContentAnchoredObjectPosition::CalcPosition()> - unknown combination of vertical position and vertical alignment." );
319 case text::VertOrientation::CENTER:
321 if (aVert.GetRelationOrient() == text::RelOrientation::PAGE_PRINT_AREA_TOP)
322 nRelPosY = (nAlignAreaOffset / 2) - (nObjHeight / 2) + (nHeightBetweenOffsetAndMargin / 2);
324 nRelPosY += (nAlignAreaHeight / 2) - (nObjHeight / 2);
328 case text::VertOrientation::LINE_CENTER:
331 aVert.GetRelationOrient() == text::RelOrientation::TEXT_LINE )
333 nRelPosY += (nAlignAreaHeight / 2) - (nObjHeight / 2);
337 OSL_FAIL(
"<SwToContentAnchoredObjectPosition::CalcPosition()> - unknown combination of vertical position and vertical alignment." );
341 case text::VertOrientation::BOTTOM:
343 if ( ( aVert.GetRelationOrient() == text::RelOrientation::FRAME ||
344 aVert.GetRelationOrient() == text::RelOrientation::PRINT_AREA ) &&
348 nRelPosY += nAlignAreaHeight + nUpperSpace;
355 aVert.GetRelationOrient() == text::RelOrientation::TEXT_LINE )
357 nRelPosY += nUpperSpace;
361 if (aVert.GetRelationOrient() == text::RelOrientation::PAGE_PRINT_AREA_TOP)
362 nRelPosY = 0 - (nObjHeight + nLowerSpace) + nHeightBetweenOffsetAndMargin;
364 nRelPosY += nAlignAreaHeight - (nObjHeight + nLowerSpace);
370 case text::VertOrientation::LINE_BOTTOM:
373 aVert.GetRelationOrient() == text::RelOrientation::TEXT_LINE )
375 nRelPosY += nUpperSpace;
379 OSL_FAIL(
"<SwToContentAnchoredObjectPosition::CalcPosition()> - unknown combination of vertical position and vertical alignment." );
396 nRelPosY += aRectFnSet.
YDiff( nTopOfOrient,
410 rVertEnvironLayFrame, nRelPosY,
419 SwTwips nAttrRelPosY = nRelPosY - nAlignAreaOffset;
421 if ( nAttrRelPosY != aVert.GetPos() )
423 aVert.SetPos( nAttrRelPosY );
425 const_cast<SwFrameFormat&
>(rFrameFormat).SetFormatAttr( aVert );
433 if ( aRectFnSet.
IsVert() )
435 aRelPos.setX( nRelPosY );
440 aRelPos.setY( nRelPosY );
455 if ( &rAnchorTextFrame == pOrientFrame ||
458 aVert.GetRelationOrient() != text::RelOrientation::CHAR &&
459 aVert.GetRelationOrient() != text::RelOrientation::TEXT_LINE ) )
461 pUpperOfOrientFrame = rAnchorTextFrame.
GetUpper();
462 pAnchorFrameForVertPos = &rAnchorTextFrame;
466 pUpperOfOrientFrame = pOrientFrame->
GetUpper();
467 pAnchorFrameForVertPos = pOrientFrame;
474 if ( pUpperOfOrientFrame->
IsInSct() )
477 const bool bIgnoreSection = pUpperOfOrientFrame->
IsSctFrame() ||
480 if ( bIgnoreSection )
481 pUpperOfOrientFrame = pSctFrame->
GetUpper();
492 SwTwips nVertOffsetToFrameAnchorPos( 0 );
496 ( aVert.GetRelationOrient() == text::RelOrientation::CHAR ||
497 aVert.GetRelationOrient() == text::RelOrientation::TEXT_LINE ) )
502 if ( aVert.GetRelationOrient() == text::RelOrientation::CHAR )
504 nVertOffsetToFrameAnchorPos = aRectFnSet.
YDiff(
513 nRelPosY = nVertOffsetToFrameAnchorPos - aVert.GetPos();
520 nVertOffsetToFrameAnchorPos = 0;
527 if ( aVert.GetRelationOrient() == text::RelOrientation::PRINT_AREA )
533 nTopMargin -= pAnchorFrameForVertPos->
534 GetUpperSpaceAmountConsideredForPrevFrameAndPageGrid();
536 nVertOffsetToFrameAnchorPos += nTopMargin;
541 else if (aVert.GetRelationOrient() == text::RelOrientation::PAGE_FRAME
542 || aVert.GetRelationOrient() == text::RelOrientation::PAGE_PRINT_AREA_TOP)
544 nVertOffsetToFrameAnchorPos += aRectFnSet.
YDiff(
545 aRectFnSet.
GetTop(rPageAlignLayFrame.getFrameArea()),
548 else if ( aVert.GetRelationOrient() == text::RelOrientation::PAGE_PRINT_AREA )
550 SwRect aPgPrtRect( rPageAlignLayFrame.getFrameArea() );
551 if ( rPageAlignLayFrame.IsPageFrame() )
554 static_cast<const SwPageFrame&
>(rPageAlignLayFrame).PrtWithoutHeaderAndFooter();
556 nVertOffsetToFrameAnchorPos += aRectFnSet.
YDiff(
557 aRectFnSet.
GetTop(aPgPrtRect),
560 else if (aVert.GetRelationOrient() == text::RelOrientation::PAGE_PRINT_AREA_BOTTOM)
563 SwRect aPgPrtRect(rPageAlignLayFrame.getFrameArea());
564 if (rPageAlignLayFrame.IsPageFrame())
566 auto& rPageFrame =
static_cast<const SwPageFrame&
>(rPageAlignLayFrame);
570 nVertOffsetToFrameAnchorPos += aRectFnSet.
YDiff(nPageBottom, nTopOfOrient);
572 nRelPosY = nVertOffsetToFrameAnchorPos + aVert.GetPos();
584 if ( aRectFnSet.
IsVert() )
602 rVertEnvironLayFrame, nRelPosY,
605 if ( aRectFnSet.
IsVert() )
606 aRelPos.setX( nRelPosY );
608 aRelPos.setY( nRelPosY );
612 aRectFnSet.
Refresh(pAnchorFrameForVertPos);
616 const bool bInFootnote = pAnchorFrameForVertPos->
IsInFootnote();
624 nRelPosY, nAvail, pUpperOfOrientFrame, bBrowse,
625 bGrow, pLayoutFrameToGrow );
627 if ( bDoesVertPosFits )
635 const SwFrame& rVertEnvironLayFrame =
642 rVertEnvironLayFrame,
646 if ( aRectFnSet.
IsVert() )
647 aRelPos.setX( nTmpRelPosY );
649 aRelPos.setY( nTmpRelPosY );
654 if ( pLayoutFrameToGrow )
660 pLayoutFrameToGrow->
Grow( nRelPosY - nAvail );
671 ( aVert.GetRelationOrient() != text::RelOrientation::PAGE_FRAME &&
672 aVert.GetRelationOrient() != text::RelOrientation::PAGE_PRINT_AREA ) &&
681 const bool bInSct = pUpperOfOrientFrame->
IsInSct();
686 pUpperOfOrientFrame->
GetLeaf( eMakePage,
true, &rAnchorTextFrame );
691 pUpperOfOrientFrame = pTmp;
692 bMoveable = rAnchorTextFrame.
IsMoveable( pUpperOfOrientFrame );
693 aRectFnSet.
Refresh(pUpperOfOrientFrame);
706 pUpperOfOrientFrame = pSct->
GetUpper();
707 nAvail = aRectFnSet.
YDiff(
713 #if OSL_DEBUG_LEVEL > 1
714 OSL_FAIL(
"<SwToContentAnchoredObjectPosition::CalcPosition()> - !bInSct" );
730 const SwFrame& rVertEnvironLayFrame =
733 rVertEnvironLayFrame,
737 aRelPos.setX( nRelPosY );
739 aRelPos.setY( nRelPosY );
757 ( aRelPos.X() - nRelDiff ) -
758 aObjBoundRect.
Width() );
763 ( aRelPos.X() - nRelDiff ) );
769 ( aRelPos.Y() - nRelDiff ) );
776 if ( pUpperOfOrientFrame->
IsInSct() )
779 const bool bIgnoreSection = pUpperOfOrientFrame->
IsSctFrame() ||
782 if ( bIgnoreSection )
783 pUpperOfOrientFrame = pSctFrame->
GetUpper();
793 if ( bBrowse && rAnchorTextFrame.
IsMoveable() )
795 if ( pUpperOfOrientFrame->
IsInSct() )
803 pLayoutFrameToGrow =
nullptr;
812 else if ( rAnchorTextFrame.
IsInTab() && bGrow )
814 pLayoutFrameToGrow =
const_cast<SwLayoutFrame*
>(pUpperOfOrientFrame);
816 if ( pLayoutFrameToGrow )
822 pLayoutFrameToGrow->
Grow( -nDist );
828 ( aVert.GetRelationOrient() != text::RelOrientation::PAGE_FRAME &&
829 aVert.GetRelationOrient() != text::RelOrientation::PAGE_PRINT_AREA ) )
837 if ( nDist < 0 && pOrientFrame->IsInTab() )
843 if ( pOrientFrame == &rAnchorTextFrame &&
848 ->SetDoesObjsFit(
false );
853 if ( aRectFnSet.
IsVert() )
854 nTmpRelPosY = aRelPos.X() - nDist;
856 nTmpRelPosY = aRelPos.Y() + nDist;
860 rVertEnvironLayFrame,
864 if ( aRectFnSet.
IsVert() )
866 aRelPos.setX( nTmpRelPosY );
872 aObjBoundRect.
Width() );
881 aRelPos.setY( nTmpRelPosY );
890 pOrientFrame == &rAnchorTextFrame && !pOrientFrame->
GetIndPrev() )
893 ->SetDoesObjsFit(
false );
900 const bool bInFootnote = rAnchorTextFrame.
IsInFootnote();
901 while( bMoveable && nDist < 0 )
903 bool bInSct = pUpperOfOrientFrame->
IsInSct();
921 aRectFnSet.
GetPrtTop(*pUpperOfOrientFrame) )
929 true, &rAnchorTextFrame );
947 if ( aRectFnSet.
IsVert() )
948 aRelPos.setX( nTmpRelPosY );
950 aRelPos.setY( nTmpRelPosY );
951 pUpperOfOrientFrame = pNextLay;
952 aRectFnSet.
Refresh(pUpperOfOrientFrame);
953 bMoveable = rAnchorTextFrame.
IsMoveable( pUpperOfOrientFrame );
961 aObjBoundRect.
Width() );
982 pUpperOfOrientFrame = pTmp;
995 pUpperOfOrientFrame = pTmp;
1010 CalcOverlap(pAnchorFrameForVertPos, aRelPos, nTopOfAnch);
1021 if( aRectFnSet.
IsVert() )
1027 aRelPos.X() - aObjBoundRect.
Width() );
1045 SwTwips nHoriOffsetToFrameAnchorPos( 0 );
1047 aHori, rLR, rUL, bWrapThrough,
1048 ( aRectFnSet.
IsVert() ? aRelPos.X() : aRelPos.Y() ),
1049 nHoriOffsetToFrameAnchorPos );
1053 if ( aRectFnSet.
IsVert() )
1055 aRelPos.setY( nRelPosX );
1060 aRelPos.setX( nRelPosX );
1067 SwTwips nAttrRelPosX = nRelPosX - nHoriOffsetToFrameAnchorPos;
1069 aHori.GetPos() != nAttrRelPosX )
1071 aHori.SetPos( nAttrRelPosX );
1073 const_cast<SwFrameFormat&
>(rFrameFormat).SetFormatAttr( aHori );
1081 if( aRectFnSet.
IsVert() )
1087 aRelPos.X() - aObjBoundRect.
Width() );
1108 Point& rRelPos,
const SwTwips nTopOfAnch)
1128 if (pShapeOfTextBox)
1133 rRelPos.setY(rRelPos.getY() + nYDiff + 1);
1141 auto pSortedObjs = pAnchorFrameForVertPos->
GetDrawObjs();
1147 for (
const auto& pAnchoredObj : *pSortedObjs)
1161 css::text::WrapTextMode eWrap = pAnchoredObj->GetFrameFormat().GetSurround().GetSurround();
1162 if (eWrap == css::text::WrapTextMode_THROUGH)
1168 if (!
GetAnchoredObj().GetObjRect().IsOver(pAnchoredObj->GetObjRect()))
1176 rRelPos.setY(rRelPos.getY() + nYDiff + 1);
1184 const_cast<SwFrameFormat&
>(rFrameFormat).SetFormatAttr(aInfluence);
1195 const SwFrame* pHoriVirtAnchFrame = &_rProposedFrame;
1206 pHoriVirtAnchFrame = pFrame;
1212 return *pHoriVirtAnchFrame;
SwFrame * FindFooterOrHeader()
void CheckCharRectAndTopOfLine(const bool _bCheckForParaPorInf)
check anchor character rectangle and top of line
Base class of the Writer layout elements.
static bool lcl_DoesVertPosFits(const SwTwips _nRelPosY, const SwTwips _nAvail, const SwLayoutFrame *_pUpperOfOrientFrame, const bool _bBrowse, const bool _bGrowInTable, SwLayoutFrame *&_orpLayoutFrameToGrow)
const SwRect & GetLastCharRect() const
Represents the visualization of a paragraph.
virtual SwRect GetObjRect() const =0
const SwSortedObjs * GetDrawObjs() const
const SwFrameFormat & GetFrameFormat() const
SwTwips Grow(SwTwips, bool bTst=false, bool bInfo=false)
sal_uInt16 GetLower() const
const SwLayoutFrame & GetVertEnvironmentLayoutFrame(const SwFrame &_rVertOrientFrame) const
determine environment layout frame for possible vertical object positions respectively for alignments...
tools::Long BottomDist(const SwRect &rRect, tools::Long nPos) const
void CalcOverlap(const SwTextFrame *pAnchorFrameForVertPos, Point &rRelPos, const SwTwips nTopOfAnch)
In case overlap is not allowed, re-position the current object.
void Left(const tools::Long nLeft)
void Refresh(const SwFrame *pFrame)
bool IsInFootnote() const
tools::Long GetRight() const
const SwRect & getFramePrintArea() const
virtual ~SwToContentAnchoredObjectPosition() override
SwTabFrame is one table in the document layout, containing rows (which contain cells).
Of course Writer needs its own rectangles.
static SwFrameFormat * getOtherTextBoxFormat(const SwFrameFormat *pFormat, sal_uInt16 nType)
If we have an associated TextFrame, then return that.
bool IsFootnoteFrame() const
const SwRect * mpToCharRect
tools::Long GetTop(const SwRect &rRect) const
SwRect GetPaintArea() const
|* The paintarea is the area, in which the content of a frame is allowed |* to be displayed...
void SetCurrRelPos(Point _aRelPos)
bool IsMoveable(const SwLayoutFrame *_pLayoutFrame=nullptr) const
determine, if frame is moveable in given environment
const SwRect & getFrameArea() const
bool getBrowseMode() const
static bool isTextBox(const SwFrameFormat *pFormat, sal_uInt16 nType)
Is the frame format a text box?
void Width(tools::Long nNew)
SwAnchoredObject & GetAnchoredObj() const
SwTextFrame * GetFollow()
void SetObjTop(const SwTwips _nTop)
SwFrame & GetAnchorFrame() const
SwToContentAnchoredObjectPosition(SdrObject &_rDrawObj)
bool IsColumnFrame() const
virtual void CalcPosition() override
calculate position of object
SwTwips AdjustVertRelPos(const SwTwips nTopOfAnch, const bool bVert, const bool bVertL2R, const SwFrame &rPageAlignLayFrame, const SwTwips nProposedRelPosY, const bool bFollowTextFlow, const bool bCheckBottom=true) const
adjust calculated vertical in order to keep object inside 'page' alignment layout frame...
TextFrameIndex MapModelToViewPos(SwPosition const &rPos) const
bool IsContentFrame() const
SwFrame * GetIndPrev() const
tools::Long GetPrtBottom(const SwFrame &rFrame) const
SwPageFrame * FindPageFrame()
const SwFrame * Lower() const
tools::Long GetHeight(const SwRect &rRect) const
SwTwips CalcRelPosX(const SwFrame &_rHoriOrientFrame, const SwEnvironmentOfAnchoredObject &_rEnvOfObj, const SwFormatHoriOrient &_rHoriOrient, const SvxLRSpaceItem &_rLRSpacing, const SvxULSpaceItem &_rULSpacing, const bool _bObjWrapThrough, const SwTwips _nRelPosY, SwTwips &_roHoriOffsetToFrameAnchorPos) const
calculate relative horizontal position
tools::Long GetLeft() const
SwLayoutFrame * GetUpper()
tools::Long GetPrtTop(const SwFrame &rFrame) const
tools::Long GetTopMargin(const SwFrame &rFrame) const
SwRect PrtWithoutHeaderAndFooter() const
tools::Long YDiff(tools::Long n1, tools::Long n2) const
const SwFrame * mpToCharOrientFrame
A page of the document layout.
SwSectionFrame * FindSctFrame()
tools::Long const nTopMargin
SwLayoutFrame * GetLeaf(MakePageType eMakePage, bool bFwd)
const SwLayoutFrame * mpVertPosOrientFrame
const SwViewOption * GetViewOptions() const
SwTwips GetLastTopOfLine() const
void Top(const tools::Long nTop)
void GetVertAlignmentValues(const SwFrame &_rVertOrientFrame, const SwFrame &_rPageAlignLayFrame, const sal_Int16 _eRelOrient, SwTwips &_orAlignAreaHeight, SwTwips &_orAlignAreaOffset) const
bool IsAnFollow(const SwFlowFrame *pFlow) const
tools::Long GetTopMargin() const
constexpr TypedWhichId< SwFlyFrameFormat > RES_FLYFRMFMT(154)
SwTwips GetTopForObjPos(const SwFrame &_rFrame, const SwRectFn &_fnRect, const bool _bVert) const
helper method to determine top of a frame for the vertical object positioning
void SetObjLeft(const SwTwips _nLeft)
SwTextFrame & GetAnchorTextFrame() const
virtual const SwFrame * ToCharOrientFrame() const override
tools::Long GetBottom(const SwRect &rRect) const
bool DoesObjFollowsTextFlow() const
SwTwips mnToCharTopOfLine
A layout frame is a frame that contains other frames (m_pLower), e.g. SwPageFrame or SwTabFrame...
virtual const SwRect * ToCharRect() const override
virtual bool IsAnchoredToChar() const override
const SwFrame & GetHoriVirtualAnchor(const SwLayoutFrame &_pProposedFrame) const
determine frame for horizontal position
const SwHeaderFrame * GetHeaderFrame() const
SwViewShell * GetCurrShell() const
bool IsFooterFrame() const
SwRootFrame * getRootFrame()
virtual SwTwips ToCharTopOfLine() const override
sal_uInt16 GetUpper() const
SwTabFrame * FindTabFrame()
Point maOffsetToFrameAnchorPos