summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2014-04-22 10:03:48 +0200
committerStephan Bergmann <sbergman@redhat.com>2014-04-22 10:03:48 +0200
commitb2e6ac535eb923336a99f9ebfcd4b50fce1790a0 (patch)
treea49eff019e13e16820eaa0d7f90652ad9083293f
parentd83dfeb5e59c8f3de12d673b001a44001f644e7d (diff)
Do not unconditionally throw NoSuchElementException
...this fixes 1a9463277006e8e5a8c0b82bbf5d5ab2d5ea15ac "coverity#704274 Logically dead code" and JunitTest_sc_unoapi. Change-Id: I20fc5262d6198fca1c7dfc970a7f8664c325aa91
-rw-r--r--sc/source/ui/unoobj/dapiuno.cxx12
1 files changed, 4 insertions, 8 deletions
diff --git a/sc/source/ui/unoobj/dapiuno.cxx b/sc/source/ui/unoobj/dapiuno.cxx
index 4aebc8a0ebac..567439f7549a 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()