diff options
author | Tamás Zolnai <tamas.zolnai@collabora.com> | 2016-09-27 07:09:35 +0200 |
---|---|---|
committer | Tamás Zolnai <tamas.zolnai@collabora.com> | 2016-09-27 07:09:35 +0200 |
commit | c55873f3e72a05cf94dabd7109c99e4b66c4f5a6 (patch) | |
tree | c6e414f0df11cff0a80e6cf339d26c5f0487b4c9 /sc/source/ui | |
parent | b905116dc41a4101e4e44d39d946bbba6a3a334d (diff) |
Return early on error
Change-Id: I963c069e27903e3d1a709ce0c17666a17f45f132
Diffstat (limited to 'sc/source/ui')
-rw-r--r-- | sc/source/ui/unoobj/dapiuno.cxx | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/sc/source/ui/unoobj/dapiuno.cxx b/sc/source/ui/unoobj/dapiuno.cxx index 982b085abf9a..677a6ae83b4b 100644 --- a/sc/source/ui/unoobj/dapiuno.cxx +++ b/sc/source/ui/unoobj/dapiuno.cxx @@ -2527,12 +2527,27 @@ Reference< XDataPilotField > SAL_CALL ScDataPilotFieldObj::createNameGroup( cons { SolarMutexGuard aGuard; - Reference< XDataPilotField > xRet; - OUString sNewDim; - if( !rItems.hasElements() ) throw IllegalArgumentException(); + Reference< XMembersAccess > xMembers = GetMembers(); + if (!xMembers.is()) + { + SAL_WARN("sc.ui", "Cannot access members of the field object."); + throw RuntimeException(); + } + + for (const OUString& aEntryName : rItems) + { + if (!xMembers->hasByName(aEntryName)) + { + SAL_WARN("sc.ui", "There is no member with that name: " + aEntryName + "."); + throw IllegalArgumentException(); + } + } + + Reference< XDataPilotField > xRet; + OUString sNewDim; ScDPObject* pDPObj = nullptr; if( ScDPSaveDimension* pDim = GetDPDimension( &pDPObj ) ) { @@ -2613,25 +2628,9 @@ Reference< XDataPilotField > SAL_CALL ScDataPilotFieldObj::createNameGroup( cons OUString aGroupName = pGroupDimension->CreateGroupName( ScGlobal::GetRscString(STR_PIVOT_GROUP) ); ScDPSaveGroupItem aGroup( aGroupName ); - Reference< XMembersAccess > xMembers = GetMembers(); - if (!xMembers.is()) - { - SAL_WARN("sc.ui", "Cannot access members of the field object."); - delete pNewGroupDim; - throw RuntimeException(); - } - for (sal_Int32 nEntry = 0; nEntry < rItems.getLength(); nEntry++) { OUString aEntryName(rItems[nEntry]); - - if (!xMembers->hasByName(aEntryName)) - { - SAL_WARN("sc.ui", "There is no member with that name: " + aEntryName + "."); - delete pNewGroupDim; - throw IllegalArgumentException(); - } - if ( pBaseGroupDim ) { // for each selected (intermediate) group, add all its items |