sc/source/ui/unoobj/dapiuno.cxx | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-)
New commits: commit c55873f3e72a05cf94dabd7109c99e4b66c4f5a6 Author: Tamás Zolnai <[email protected]> Date: Tue Sep 27 07:09:35 2016 +0200 Return early on error Change-Id: I963c069e27903e3d1a709ce0c17666a17f45f132 diff --git a/sc/source/ui/unoobj/dapiuno.cxx b/sc/source/ui/unoobj/dapiuno.cxx index 982b085..677a6ae 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
_______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
