Simplify a bit
And avoid a second call of pObj->GetUserCall.
Change-Id: I4487ad33df594a8a96b517c5b4671512dea7116d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162042
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
diff --git a/sw/source/core/draw/dcontact.cxx b/sw/source/core/draw/dcontact.cxx
index 1afe6e5..f0f8a7fd 100644
--- a/sw/source/core/draw/dcontact.cxx
+++ b/sw/source/core/draw/dcontact.cxx
@@ -170,12 +170,16 @@ SwRect GetBoundRectOfAnchoredObj( const SdrObject* pObj )
/// Returns the UserCall if applicable from the group object
SwContact* GetUserCall( const SdrObject* pObj )
{
SdrObject *pTmp;
while ( !pObj->GetUserCall() && nullptr != (pTmp = pObj->getParentSdrObjectFromSdrObject()) )
pObj = pTmp;
assert((!pObj->GetUserCall() || nullptr != dynamic_cast<const SwContact*>(pObj->GetUserCall())) &&
"<::GetUserCall(..)> - wrong type of found object user call." );
return static_cast<SwContact*>(pObj->GetUserCall());
for (; pObj; pObj = pObj->getParentSdrObjectFromSdrObject())
{
if (auto pUserCall = pObj->GetUserCall())
{
assert(dynamic_cast<SwContact*>(pUserCall)
&& "<::GetUserCall(..)> - wrong type of found object user call.");
return static_cast<SwContact*>(pUserCall);
}
}
return nullptr;
}
/// Returns true if the SrdObject is a Marquee-Object (scrolling text)