summaryrefslogtreecommitdiff
path: root/sw/source/core/layout
diff options
context:
space:
mode:
authorMichael Stahl <Michael.Stahl@cib.de>2018-09-18 16:21:44 +0200
committerMichael Stahl <Michael.Stahl@cib.de>2018-09-19 10:08:55 +0200
commitf62ba688ca1c22fcdcf7efd811d702e982799882 (patch)
treeb0b58daa34da816da3376864d43fe5bd50a441b9 /sw/source/core/layout
parent18dbdd512b11c02b2b5c8d28355a4d2188003d46 (diff)
sw: rework annoying GetFrameOfModify/getLayoutFrame parameters private/mst/sw_redlinehide_2
The bCalcFrame is only evaluated if a pPoint is given; this is surprising and should be more visible in the interface, so people don't go on a goose chase to find places that may do formatting in inappropriate places. So put these parameters into a pair instead, which doesn't have particularly good ergonomics in C++, particularly since compilers warn about taking the address of a temporary object... Change-Id: I101c6eeb5bd6baf83c2bd9a6cb91ccaa04036cc3
Diffstat (limited to 'sw/source/core/layout')
-rw-r--r--sw/source/core/layout/atrfrm.cxx19
-rw-r--r--sw/source/core/layout/flycnt.cxx3
-rw-r--r--sw/source/core/layout/flylay.cxx2
-rw-r--r--sw/source/core/layout/frmtool.cxx18
-rw-r--r--sw/source/core/layout/ftnfrm.cxx2
-rw-r--r--sw/source/core/layout/pagedesc.cxx3
-rw-r--r--sw/source/core/layout/trvlfrm.cxx17
7 files changed, 42 insertions, 22 deletions
diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx
index 15335abbc426..9a7f977a7d97 100644
--- a/sw/source/core/layout/atrfrm.cxx
+++ b/sw/source/core/layout/atrfrm.cxx
@@ -2697,7 +2697,13 @@ SwRect SwFrameFormat::FindLayoutRect( const bool bPrtArea, const Point* pPoint )
else
{
const SwFrameType nFrameType = RES_FLYFRMFMT == Which() ? SwFrameType::Fly : FRM_ALL;
- pFrame = ::GetFrameOfModify( nullptr, *this, nFrameType, pPoint);
+ std::pair<Point, bool> tmp;
+ if (pPoint)
+ {
+ tmp.first = *pPoint;
+ tmp.second = false;
+ }
+ pFrame = ::GetFrameOfModify(nullptr, *this, nFrameType, nullptr, pPoint ? &tmp : nullptr);
}
if( pFrame )
@@ -2715,8 +2721,9 @@ SdrObject* SwFrameFormat::FindRealSdrObject()
if( RES_FLYFRMFMT == Which() )
{
Point aNullPt;
+ std::pair<Point, bool> const tmp(aNullPt, false);
SwFlyFrame* pFly = static_cast<SwFlyFrame*>(::GetFrameOfModify( nullptr, *this, SwFrameType::Fly,
- &aNullPt ));
+ nullptr, &tmp));
return pFly ? pFly->GetVirtDrawObj() : nullptr;
}
return FindSdrObject();
@@ -3058,8 +3065,14 @@ void SwFlyFrameFormat::MakeFrames()
SwFlyFrame* SwFlyFrameFormat::GetFrame( const Point* pPoint ) const
{
+ std::pair<Point, bool> tmp;
+ if (pPoint)
+ {
+ tmp.first = *pPoint;
+ tmp.second = false;
+ }
return static_cast<SwFlyFrame*>(::GetFrameOfModify( nullptr, *this, SwFrameType::Fly,
- pPoint ));
+ nullptr, &tmp));
}
SwAnchoredObject* SwFlyFrameFormat::GetAnchoredObj() const
diff --git a/sw/source/core/layout/flycnt.cxx b/sw/source/core/layout/flycnt.cxx
index f756318af219..5d9f1ba2fce5 100644
--- a/sw/source/core/layout/flycnt.cxx
+++ b/sw/source/core/layout/flycnt.cxx
@@ -169,7 +169,8 @@ void SwFlyAtContentFrame::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pN
if ( !pContent )
{
SwContentNode *pNode = aNewIdx.GetNode().GetContentNode();
- pContent = pNode->getLayoutFrame( getRootFrame(), &pOldAnchor->getFrameArea().Pos(), nullptr, false );
+ std::pair<Point, bool> const tmp(pOldAnchor->getFrameArea().Pos(), false);
+ pContent = pNode->getLayoutFrame(getRootFrame(), nullptr, &tmp);
OSL_ENSURE( pContent, "New anchor not found" );
}
//Flys are never attached to a follow, but always on the master which
diff --git a/sw/source/core/layout/flylay.cxx b/sw/source/core/layout/flylay.cxx
index 36bc46ba762c..d9d2120bfdda 100644
--- a/sw/source/core/layout/flylay.cxx
+++ b/sw/source/core/layout/flylay.cxx
@@ -781,7 +781,7 @@ void SwFlyLayFrame::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew )
{
SwNodeIndex aIdx( pAnch->GetContentAnchor()->nNode );
SwContentFrame *pContent = GetFormat()->GetDoc()->GetNodes().GoNext( &aIdx )->
- GetContentNode()->getLayoutFrame( getRootFrame(), nullptr, nullptr, false );
+ GetContentNode()->getLayoutFrame(getRootFrame(), nullptr, nullptr);
if( pContent )
{
SwFlyFrame *pTmp = pContent->FindFlyFrame();
diff --git a/sw/source/core/layout/frmtool.cxx b/sw/source/core/layout/frmtool.cxx
index d9c3a0f5cc8b..766761b719fe 100644
--- a/sw/source/core/layout/frmtool.cxx
+++ b/sw/source/core/layout/frmtool.cxx
@@ -3422,8 +3422,9 @@ void SwFrameHolder::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
}
}
-SwFrame* GetFrameOfModify( const SwRootFrame* pLayout, SwModify const& rMod, SwFrameType const nFrameType,
- const Point* pPoint, const SwPosition *pPos, const bool bCalcFrame )
+SwFrame* GetFrameOfModify(SwRootFrame const*const pLayout, SwModify const& rMod,
+ SwFrameType const nFrameType, SwPosition const*const pPos,
+ std::pair<Point, bool> const*const pViewPosAndCalcFrame)
{
SwFrame *pMinFrame = nullptr, *pTmpFrame;
SwFrameHolder aHolder;
@@ -3444,7 +3445,7 @@ SwFrame* GetFrameOfModify( const SwRootFrame* pLayout, SwModify const& rMod, SwF
(!pTmpFrame->IsFlowFrame() ||
!SwFlowFrame::CastFlowFrame( pTmpFrame )->IsFollow() ))
{
- if( pPoint )
+ if (pViewPosAndCalcFrame)
{
// watch for Frame being deleted
if ( pMinFrame )
@@ -3452,7 +3453,7 @@ SwFrame* GetFrameOfModify( const SwRootFrame* pLayout, SwModify const& rMod, SwF
else
aHolder.Reset();
- if( bCalcFrame )
+ if (pViewPosAndCalcFrame->second)
{
// tdf#108118 prevent recursion
DisableCallbackAction a(*pTmpFrame->getRootFrame());
@@ -3480,7 +3481,8 @@ SwFrame* GetFrameOfModify( const SwRootFrame* pLayout, SwModify const& rMod, SwF
}
// for Flys go via the parent if the Fly is not yet "formatted"
- if( !bCalcFrame && pTmpFrame->GetType() & SwFrameType::Fly &&
+ if (!pViewPosAndCalcFrame->second &&
+ pTmpFrame->GetType() & SwFrameType::Fly &&
static_cast<SwFlyFrame*>(pTmpFrame)->GetAnchorFrame() &&
FAR_AWAY == pTmpFrame->getFrameArea().Pos().getX() &&
FAR_AWAY == pTmpFrame->getFrameArea().Pos().getY() )
@@ -3488,7 +3490,7 @@ SwFrame* GetFrameOfModify( const SwRootFrame* pLayout, SwModify const& rMod, SwF
else
aCalcRect = pTmpFrame->getFrameArea();
- if ( aCalcRect.IsInside( *pPoint ) )
+ if (aCalcRect.IsInside(pViewPosAndCalcFrame->first))
{
pMinFrame = pTmpFrame;
break;
@@ -3496,7 +3498,7 @@ SwFrame* GetFrameOfModify( const SwRootFrame* pLayout, SwModify const& rMod, SwF
// Point not in rectangle. Compare distances:
const Point aCalcRectCenter = aCalcRect.Center();
- const Point aDiff = aCalcRectCenter - *pPoint;
+ const Point aDiff = aCalcRectCenter - pViewPosAndCalcFrame->first;
const sal_uInt64 nCurrentDist = sal_Int64(aDiff.getX()) * sal_Int64(aDiff.getX()) + sal_Int64(aDiff.getY()) * sal_Int64(aDiff.getY()); // opt: no sqrt
if ( !pMinFrame || nCurrentDist < nMinDist )
{
@@ -3506,7 +3508,7 @@ SwFrame* GetFrameOfModify( const SwRootFrame* pLayout, SwModify const& rMod, SwF
}
else
{
- // if no pPoint is provided, take the first one
+ // if no pViewPosAndCalcFrame is provided, take the first one
pMinFrame = pTmpFrame;
break;
}
diff --git a/sw/source/core/layout/ftnfrm.cxx b/sw/source/core/layout/ftnfrm.cxx
index 1911206a5228..de19e6ffec2e 100644
--- a/sw/source/core/layout/ftnfrm.cxx
+++ b/sw/source/core/layout/ftnfrm.cxx
@@ -2838,7 +2838,7 @@ SwContentFrame* SwFootnoteFrame::GetRefFromAttr()
assert(mpAttribute && "invalid Attribute");
SwTextNode& rTNd = const_cast<SwTextNode&>(mpAttribute->GetTextNode());
SwPosition aPos( rTNd, SwIndex( &rTNd, mpAttribute->GetStart() ));
- SwContentFrame* pCFrame = rTNd.getLayoutFrame( getRootFrame(), nullptr, &aPos, false );
+ SwContentFrame* pCFrame = rTNd.getLayoutFrame(getRootFrame(), &aPos);
return pCFrame;
}
diff --git a/sw/source/core/layout/pagedesc.cxx b/sw/source/core/layout/pagedesc.cxx
index aab5b2c90d78..8dc2ad33a1d9 100644
--- a/sw/source/core/layout/pagedesc.cxx
+++ b/sw/source/core/layout/pagedesc.cxx
@@ -299,7 +299,8 @@ static const SwFrame* lcl_GetFrameOfNode( const SwNode& rNd )
pMod = nullptr;
Point aNullPt;
- return pMod ? ::GetFrameOfModify( nullptr, *pMod, nFrameType, &aNullPt )
+ std::pair<Point, bool> const tmp(aNullPt, false);
+ return pMod ? ::GetFrameOfModify(nullptr, *pMod, nFrameType, nullptr, &tmp)
: nullptr;
}
diff --git a/sw/source/core/layout/trvlfrm.cxx b/sw/source/core/layout/trvlfrm.cxx
index 8f523cf32390..2f076858fbfe 100644
--- a/sw/source/core/layout/trvlfrm.cxx
+++ b/sw/source/core/layout/trvlfrm.cxx
@@ -983,9 +983,8 @@ sal_uInt16 SwRootFrame::GetCurrPage( const SwPaM *pActualCursor ) const
{
OSL_ENSURE( pActualCursor, "got no page cursor" );
SwFrame const*const pActFrame = pActualCursor->GetPoint()->nNode.GetNode().
- GetContentNode()->getLayoutFrame( this, nullptr,
- pActualCursor->GetPoint(),
- false );
+ GetContentNode()->getLayoutFrame(this,
+ pActualCursor->GetPoint());
return pActFrame->FindPageFrame()->GetPhyPageNum();
}
@@ -1893,8 +1892,10 @@ bool SwRootFrame::MakeTableCursors( SwTableCursor& rTableCursor )
const SwContentNode* pTmpStartNode = rTableCursor.GetContentNode();
const SwContentNode* pTmpEndNode = rTableCursor.GetContentNode(false);
- const SwFrame* pTmpStartFrame = pTmpStartNode ? pTmpStartNode->getLayoutFrame( this, &aPtPt, nullptr, false ) : nullptr;
- const SwFrame* pTmpEndFrame = pTmpEndNode ? pTmpEndNode->getLayoutFrame( this, &aMkPt, nullptr, false ) : nullptr;
+ std::pair<Point, bool> tmp(aPtPt, false);
+ const SwFrame *const pTmpStartFrame = pTmpStartNode ? pTmpStartNode->getLayoutFrame(this, nullptr, &tmp) : nullptr;
+ tmp.first = aMkPt;
+ const SwFrame *const pTmpEndFrame = pTmpEndNode ? pTmpEndNode->getLayoutFrame(this, nullptr, &tmp) : nullptr;
const SwLayoutFrame* pStart = pTmpStartFrame ? pTmpStartFrame->GetUpper() : nullptr;
const SwLayoutFrame* pEnd = pTmpEndFrame ? pTmpEndFrame->GetUpper() : nullptr;
@@ -2040,11 +2041,13 @@ void SwRootFrame::CalcFrameRects(SwShellCursor &rCursor)
//First obtain the ContentFrames for the start and the end - those are needed
//anyway.
+ std::pair<Point, bool> tmp(rCursor.GetSttPos(), true);
SwContentFrame* pStartFrame = pStartPos->nNode.GetNode().
- GetContentNode()->getLayoutFrame( this, &rCursor.GetSttPos(), pStartPos );
+ GetContentNode()->getLayoutFrame(this, pStartPos, &tmp);
+ tmp.first = rCursor.GetEndPos();
SwContentFrame* pEndFrame = pEndPos->nNode.GetNode().
- GetContentNode()->getLayoutFrame( this, &rCursor.GetEndPos(), pEndPos );
+ GetContentNode()->getLayoutFrame(this, pEndPos, &tmp);
assert(pStartFrame && pEndFrame && "No ContentFrames found.");
//tdf#119224 start and end are expected to exist for the scope of this function