34 #include <viewimp.hxx>
54 ~SwPosNotify() COVERITY_NOEXCEPT_FALSE;
56 Point const & LastObjPos() const;
62 mpAnchoredDrawObj( _pAnchoredDrawObj )
64 maOldObjRect = mpAnchoredDrawObj->
GetObjRect();
69 SwPosNotify::~SwPosNotify() COVERITY_NOEXCEPT_FALSE
71 if ( maOldObjRect != mpAnchoredDrawObj->
GetObjRect() )
73 if( maOldObjRect.
HasArea() && mpOldPageFrame )
79 if( aNewObjRect.HasArea() )
128 nullptr, mpAnchoredDrawObj->
GetDrawObj(), maOldObjRect);
133 Point const & SwPosNotify::LastObjPos()
const
135 return maOldObjRect.
Pos();
142 class SwObjPosOscillationControl
147 std::vector<Point> maObjPositions;
152 bool OscillationDetected();
157 SwObjPosOscillationControl::SwObjPosOscillationControl(
159 : mpAnchoredDrawObj( &_rAnchoredDrawObj )
163 bool SwObjPosOscillationControl::OscillationDetected()
165 bool bOscillationDetected =
false;
167 if ( maObjPositions.size() == 20 )
170 bOscillationDetected =
true;
175 for (
auto const & pt : maObjPositions )
177 if ( aNewObjPos == pt )
180 bOscillationDetected =
true;
184 if ( !bOscillationDetected )
186 maObjPositions.push_back( aNewObjPos );
190 return bOscillationDetected;
197 mbNotYetAttachedToAnchorFrame( true ),
199 mbNotYetPositioned( true ),
201 mbCaptureAfterLayoutDirChange( false )
228 bool bOutsidePage(
false );
258 OSL_FAIL(
"<SwAnchoredDrawObject::MakeObjPos() - drawing object not yet attached to anchor frame -> no positioning" );
281 if ( dynamic_cast< const SwDrawVirtObj* >(
GetDrawObj()) ==
nullptr &&
282 !static_cast<SwDrawFrameFormat&>(
GetFrameFormat()).IsPosAttrSet() )
299 case RndStdIds::FLY_AS_CHAR:
307 case RndStdIds::FLY_AT_PARA:
308 case RndStdIds::FLY_AT_CHAR:
315 case RndStdIds::FLY_AT_PAGE:
316 case RndStdIds::FLY_AT_FLY:
325 assert(!
"<SwAnchoredDrawObject::MakeObjPos()> - unknown anchor type.");
336 if ( dynamic_cast< const SwDrawVirtObj* >(
GetDrawObj()) ==
nullptr &&
351 if ( aObjRect.
Right() >= aPageRect.
Right() + 10 )
358 if ( aObjRect.
Left() + 10 <= aPageRect.
Left() )
395 bool bFormatAnchorOnce = !bJoinLocked && bAddVerticalFlyOffsets;
397 if (bFormatAnchor || bFormatAnchorOnce)
403 bool bOscillationDetected =
false;
404 SwObjPosOscillationControl aObjPosOscCtrl( *
this );
408 bool bConsiderWrapInfluenceDueToOverlapPrevCol(
false );
416 SwPosNotify aPosNotify(
this );
430 bOscillationDetected = aObjPosOscCtrl.OscillationDetected();
446 bConsiderWrapInfluenceDueToOverlapPrevCol =
true;
448 }
while ( !
mbValidPos && !bOscillationDetected &&
449 !bConsiderWrapInfluenceDueToOverlapPrevCol );
454 if ( bOscillationDetected || bConsiderWrapInfluenceDueToOverlapPrevCol )
472 SwPosNotify aPosNotify(
this );
485 const Point aNewAnchorPos =
494 const Point aAnchPos( aRectFnSet.
GetPos(pAnchorFrame->getFrameArea()) );
503 Point aNewAnchorPos =
506 if ( aNewAnchorPos != aCurrAnchorPos )
509 Size aMove( aCurrAnchorPos.getX() - aNewAnchorPos.getX(),
510 aCurrAnchorPos.getY() - aNewAnchorPos.getY() );
573 if ( dynamic_cast< const SwTextFrame* >(
GetAnchorFrame()) !=
nullptr &&
574 (
GetFrameFormat().GetAnchor().GetAnchorId() == RndStdIds::FLY_AS_CHAR) )
589 if ( pPageFrameRegisteredAt &&
590 pPageFrameRegisteredAt != pPageFrame )
598 if ( pPageFrameOfAnchor &&
599 pPageFrameOfAnchor != pPageFrame &&
600 pPageFrameOfAnchor != pPageFrameRegisteredAt )
637 if (nPageNum % 2 == (isOutside ? 0 : 1))
657 if (
GetDrawObj()->GetRelativeWidthRelation() == text::RelOrientation::FRAME)
663 else if (
GetDrawObj()->GetRelativeWidthRelation() == text::RelOrientation::PAGE_LEFT)
668 nWidth = getInsideOutsideRelativeWidth(
true,
GetPageFrame());
673 else if (
GetDrawObj()->GetRelativeWidthRelation() == text::RelOrientation::PAGE_RIGHT)
677 nWidth = getInsideOutsideRelativeWidth(
false,
GetPageFrame());
696 if (
GetDrawObj()->GetRelativeHeightRelation() == text::RelOrientation::FRAME)
699 else if (
GetDrawObj()->GetRelativeHeightRelation() == text::RelOrientation::PAGE_PRINT_AREA)
708 else if (
GetDrawObj()->GetRelativeHeightRelation() == text::RelOrientation::PAGE_PRINT_AREA_BOTTOM)
714 aFooterRect = pFooterFrame->GetPaintArea();
722 if ( nTargetWidth != aCurrObjRect.
GetWidth( ) || nTargetHeight != aCurrObjRect.
GetHeight( ) )
738 uno::Reference<drawing::XShape> xShape(
pObject->getUnoShape(), uno::UNO_QUERY);
740 uno::makeAny(xShape->getSize()));
771 const SwRect* _pNewObjRect )
778 const bool bVert = _pNewAnchorFrame->
IsVertical();
782 nHoriRelPos = aObjRect.
Top() - aAnchorPos.Y();
783 nVertRelPos = aAnchorPos.X() - aObjRect.
Right();
787 nHoriRelPos = aAnchorPos.X() - aObjRect.
Right();
788 nVertRelPos = aObjRect.
Top() - aAnchorPos.Y();
792 nHoriRelPos = aObjRect.
Left() - aAnchorPos.X();
793 nVertRelPos = aObjRect.
Top() - aAnchorPos.Y();
845 text::PositionLayoutDir::PositionInHoriL2R )
848 switch ( eLayoutDir )
857 nHoriPos = -aObjRect.
Left() - aObjRect.
Width();
862 nHoriPos = aObjRect.
Top();
863 nVertPos = -aObjRect.
Left() - aObjRect.
Width();
868 assert(!
"<SwAnchoredDrawObject::SetPositioningAttr()> - unsupported layout direction");
877 if (nHoriPos != aHori.
GetPos()) {
884 if (nVertPos != aVert.
GetPos()) {
892 text::PositionLayoutDir::PositionInLayoutDirOfAnchor );
Base class of the Writer layout elements.
Represents the visualization of a paragraph.
bool OverlapsPrevColumn() const
method to determine, if the anchored object is overlapping with a previous column ...
void Right(const tools::Long nRight)
Point GetPos(const SwRect &rRect) const
class for the positioning of drawing objects
virtual const tools::Rectangle & GetCurrentBoundRect() const
virtual void NotifyBackground(SwPageFrame *_pPageFrame, const SwRect &_rRect, PrepareHint _eHint) override
method to notify background of drawing object
bool IsAnyShellAccessible() const
void Left(const tools::Long nLeft)
constexpr TypedWhichId< SwFormatFrameSize > RES_FRM_SIZE(89)
virtual bool Prepare(const PrepareHint ePrep=PrepareHint::Clear, const void *pVoid=nullptr, bool bNotify=true)
virtual void UpdateLayoutDir()
method update layout direction the layout direction, the anchored object is assigned to ...
bool mbNotYetAttachedToAnchorFrame
const SwRect & getFramePrintArea() const
void SetConsiderForTextWrap(const bool _bConsiderForTextWrap)
void RemoveDrawObjFromPage(SwAnchoredObject &_rToRemoveObj)
void InvalidatePage_(SwPageFrame *_pPageFrame)
method to invalidate the given page frame
void Pos(const Point &rNew)
Helper class for notify that positioning of an anchored object is in progress.
virtual void Calc(vcl::RenderContext *pRenderContext) const
Of course Writer needs its own rectangles.
EmbeddedObjectRef * pObject
void MakeObjPosAnchoredAtLayout()
method for the intrinsic positioning of an at-page|at-frame anchored drawing object ...
The root element of a Writer document layout.
void InvalidateFlyInCnt() const
bool isFrameAreaDefinitionValid() const
virtual bool SetObjTop_(const SwTwips _nTop) override
virtual const tools::Rectangle & GetSnapRect() const
sal_uInt16 GetPhyPageNum() const
SwRect GetPaintArea() const
|* The paintarea is the area, in which the content of a frame is allowed |* to be displayed...
wrapper class for the positioning of Writer fly frames and drawing objects
virtual void InvalidateObjPos() override
method to invalidate position of the anchored object
void SetCurrRelPos(Point _aRelPos)
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
virtual void SetAnchorPos(const Point &rPnt)
void SetAttr(const SfxPoolItem &, SwFormat &)
Set attribute in given format.1y If Undo is enabled, the old values is added to the Undo history...
SwRect & Intersection(const SwRect &rRect)
static bool isTextBox(const SwFrameFormat *pFormat, sal_uInt16 nType)
Is the frame format a text box?
void SetTmpConsiderWrapInfluence(const bool _bTmpConsiderWrapInfluence)
void Width(tools::Long nNew)
virtual void ObjectAttachedToAnchorFrame()
method to indicate, that anchored object is attached to an anchor frame
virtual bool IsEnableSetModified() const =0
void SetObjTop(const SwTwips _nTop)
virtual void RegisterAtCorrectPage() override
method to assure that anchored object is registered at the correct page frame
virtual bool IsAutoGrowHeight() const override
bool ConsiderForTextWrap() const
virtual void ObjectAttachedToAnchorFrame() override
method to indicate, that anchored object is attached to an anchor frame
virtual void CalcPosition() override
calculate position of object
const SdrObject * GetDrawObj() const
const SwFooterFrame * GetFooterFrame() const
virtual SwRect GetObjRect() const override
SwRect GetBoundRect(OutputDevice const *pOutputDevice) const
SwPageFrame * FindPageFrame()
void AppendDrawObjToPage(SwAnchoredObject &_rNewObj)
void InvalidatePage(const SwPageFrame *pPage=nullptr) const
Invalidates the page in which the Frame is currently placed.
SwLayoutFrame * GetUpper()
const SwRect & GetObjRectWithSpaces() const
method to determine object area inclusive its spacing
bool IsOutsidePage() const
IDocumentState const & getIDocumentState() const
void SetDrawObjAnchor()
method to set internal anchor position of instance of the drawing object ...
virtual void Move(const Size &rSiz)
void SetLastObjRect(const tools::Rectangle &_rNewObjRect)
tools::Long GetBottomMargin() const
void InvalidateFlyLayout() const
Validate, invalidate and query the Page status Layout/Content and Fly/non-Fly respectively are inspec...
A page of the document layout.
const double * GetRelativeWidth() const
SwFrame * GetAnchorFrameContainingAnchPos()
determine anchor frame containing the anchor position
virtual ~SwAnchoredDrawObject() override
void MakeObjPosAnchoredAtPara()
method for the intrinsic positioning of an at-paragraph|at-character anchored drawing object ...
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const SwLayoutFrame * GetVertPosOrientFrame() const
virtual SwFrameFormat & GetFrameFormat() override
const Point & GetCurrRelPos() const
tools::Rectangle SVRect() const
bool ConsiderObjWrapInfluenceOnObjPos() const
method to determine, if wrapping style influence of the anchored object has to be considered on the o...
bool InvalidationOfPosAllowed() const
method to determine, if invalidation of position is allowed
tools::Long GetRightMargin() const
SwPageFrame * FindPageFrameOfAnchor()
method to determine the page frame, on which the 'anchor' of the given anchored object is...
std::optional< tools::Rectangle > maLastObjRect
SwPageFrame * GetPageFrame()
void ClrContourCache(const SdrObject *pObj)
bool NotYetPositioned() const
virtual SwRect GetObjBoundRect() const override
void AdjustPositioningAttr(const SwFrame *_pNewAnchorFrame, const SwRect *_pNewObjRect=nullptr)
adjust positioning and alignment attributes for new anchor frame
bool IsRightToLeft() const
void Top(const tools::Long nTop)
void InvalidateObjRectWithSpaces() const
TextFrameIndex CalcFlyPos(SwFrameFormat const *pSearch)
Calculates the position of FlyInContentFrames.
constexpr TypedWhichId< SwDrawFrameFormat > RES_DRAWFRMFMT(157)
bool ConsiderObjWrapInfluenceOfOtherObjs() const
method to determine, if other anchored objects, also attached at to the anchor frame, have to consider its wrap influence.
virtual bool get(DocumentSettingId id) const =0
Return the specified document setting.
const Point & GetAnchorPos() const
tools::Long GetTopMargin() const
const SwContentFrame * GetTurbo() const
void SetObjLeft(const SwTwips _nLeft)
void DisallowTurbo() const
virtual void MakeObjPos() override
method to determine position for the object and set the position at the object
virtual void SetEnableSetModified(bool bEnableSetModified)=0
static void syncProperty(SwFrameFormat *pShape, sal_uInt16 nWID, sal_uInt8 nMemberID, const css::uno::Any &rValue)
Sync property of TextBox with the one of the shape.
virtual void UpdateLayoutDir() override
method update layout direction the layout direction, the anchored object is assigned to ...
bool mbCaptureAfterLayoutDirChange
void SetPositioningAttr()
method to set positioning attributes (not for as-character anchored)
const SwFrame * GetAnchorFrame() const
tools::Long GetLeftMargin() const
void SetVertPosOrientFrame(const SwLayoutFrame &_rVertPosOrientFrame)
virtual void CalcPosition() override
calculate position for object
const SwHeaderFrame * GetHeaderFrame() const
SwViewShell * GetCurrShell() const
bool IsPositioningInProgress() const
is positioning of anchored object in progress
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...
Point GetFrameAnchorPos(bool bIgnoreFlysAnchoredAtThisFrame) const
returns the position for anchors based on frame direction
virtual bool SetObjLeft_(const SwTwips _nLeft) override
void SetRestartLayoutProcess(const bool _bRestartLayoutProcess)
void Height(tools::Long nNew)
const sal_Int32 COMPLETE_STRING
SwRootFrame * getRootFrame()
const Point & GetRelPos() const
calculated relative position for object
const SwLayoutFrame & GetVertPosOrientFrame() const
frame, at which the vertical position is oriented at
void MoveAccessible(const SwFrame *pFrame, const SdrObject *pObj, const SwRect &rOldFrame)
Move a frame's position in the accessible view.
const double * GetRelativeHeight() const
virtual const SwFrameFormat * GetFormat() const