sc/source/ui/unoobj/dapiuno.cxx |   12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

New commits:
commit b2e6ac535eb923336a99f9ebfcd4b50fce1790a0
Author: Stephan Bergmann <sberg...@redhat.com>
Date:   Tue Apr 22 10:03:48 2014 +0200

    Do not unconditionally throw NoSuchElementException
    
    ...this fixes 1a9463277006e8e5a8c0b82bbf5d5ab2d5ea15ac "coverity#704274
    Logically dead code" and JunitTest_sc_unoapi.
    
    Change-Id: I20fc5262d6198fca1c7dfc970a7f8664c325aa91

diff --git a/sc/source/ui/unoobj/dapiuno.cxx b/sc/source/ui/unoobj/dapiuno.cxx
index 4aebc8a..567439f 100644
--- a/sc/source/ui/unoobj/dapiuno.cxx
+++ b/sc/source/ui/unoobj/dapiuno.cxx
@@ -3230,27 +3230,23 @@ Any SAL_CALL ScDataPilotItemsObj::getByName( const 
OUString& aName )
 {
     SolarMutexGuard aGuard;
     Reference<XNameAccess> xMembers = GetMembers();
-    Any aRet;
     if (xMembers.is())
     {
         Reference<XIndexAccess> xMembersIndex(new ScNameToIndexAccess( 
xMembers ));
         sal_Int32 nCount = xMembersIndex->getCount();
-        sal_Bool bFound(false);
         sal_Int32 nItem = 0;
-        while (nItem < nCount && !bFound )
+        while (nItem < nCount)
         {
             Reference<XNamed> xMember(xMembersIndex->getByIndex(nItem), 
UNO_QUERY);
             if (xMember.is() && (aName == xMember->getName()))
             {
-                aRet = Any( Reference< XPropertySet >( GetObjectByIndex_Impl( 
nItem ) ) );
-                break;
+                return Any( Reference< XPropertySet >( GetObjectByIndex_Impl( 
nItem ) ) );
             }
             ++nItem;
         }
-        if (!bFound)
-            throw NoSuchElementException();
+        throw NoSuchElementException();
     }
-    return aRet;
+    return Any();
 }
 
 Sequence<OUString> SAL_CALL ScDataPilotItemsObj::getElementNames()
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to