sw/source/core/draw/dcontact.cxx |   16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

New commits:
commit 2b4de0e1b2119c82b906c9f4025b7a1ce525aca5
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Sun Jan 14 12:31:48 2024 +0600
Commit:     Christian Lohmaier <lohmaier+libreoff...@googlemail.com>
CommitDate: Fri May 31 13:19:21 2024 +0200

    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.kagan...@collabora.com>
    (cherry picked from commit 5703d3af04b8fe78fdd4dbef14b08d8446402779)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167940
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>
    (cherry picked from commit 660443e38c2d059d557298e1131cf42b96436e30)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168065
    Reviewed-by: Christian Lohmaier <lohmaier+libreoff...@googlemail.com>
    Tested-by: Christian Lohmaier <lohmaier+libreoff...@googlemail.com>

diff --git a/sw/source/core/draw/dcontact.cxx b/sw/source/core/draw/dcontact.cxx
index 115887a368dc..a91e92569f7a 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)

Reply via email to