From 9c34c9c2409a8f09c3373d314ef7872d7c2aee92 Mon Sep 17 00:00:00 2001 From: Eike Rathke Date: Fri, 8 Sep 2017 13:41:52 +0200 Subject: Inspecting children is only necessary if parent is selected Change-Id: I9980bef27442504f59f5a85e655a761c5d35a012 --- sc/source/ui/cctrl/checklistmenu.cxx | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'sc/source') diff --git a/sc/source/ui/cctrl/checklistmenu.cxx b/sc/source/ui/cctrl/checklistmenu.cxx index 74c5f6df301a..d2c16a98ebc5 100644 --- a/sc/source/ui/cctrl/checklistmenu.cxx +++ b/sc/source/ui/cctrl/checklistmenu.cxx @@ -1649,20 +1649,23 @@ void ScCheckListBox::GetRecursiveChecked( SvTreeListEntry* pEntry, std::unordere rLabel = GetEntryText(pEntry); else rLabel = GetEntryText(pEntry) + ";" + rLabel; - } - if (pEntry->HasChildren()) - { - const SvTreeListEntries& rChildren = pEntry->GetChildEntries(); - for (auto& rChild : rChildren) + // Prerequisite: the selection mechanism guarantees that if a child is + // selected then also the parent is selected, so we only have to + // inspect the children in case the parent is selected. + if (pEntry->HasChildren()) { - OUString aLabel = rLabel; - GetRecursiveChecked( rChild.get(), vOut, aLabel); - if (!aLabel.isEmpty() && aLabel != rLabel) - vOut.insert( aLabel); + const SvTreeListEntries& rChildren = pEntry->GetChildEntries(); + for (auto& rChild : rChildren) + { + OUString aLabel = rLabel; + GetRecursiveChecked( rChild.get(), vOut, aLabel); + if (!aLabel.isEmpty() && aLabel != rLabel) + vOut.insert( aLabel); + } + // Let the caller not add the parent alone. + rLabel.clear(); } - // Let the caller not add the parent alone. - rLabel.clear(); } } -- cgit