diff options
author | Caolán McNamara <caolanm@redhat.com> | 2019-10-09 09:13:57 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2019-10-09 11:25:24 +0200 |
commit | 37e65a2d577d69cfd10df999bc189180f2dea157 (patch) | |
tree | 5628e92aa29a3b9395388d8019e74cbf91cd5b84 /sc | |
parent | 1ba990fc26fde5e34b05981a2202b9f96f4475df (diff) |
cid#1452393 silence Using invalid iterator
Change-Id: Idf3ec9c751f8c7d93ce82e25613757627b867cc4
Reviewed-on: https://gerrit.libreoffice.org/80521
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/core/data/dpoutput.cxx | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/sc/source/core/data/dpoutput.cxx b/sc/source/core/data/dpoutput.cxx index 54c4a204dedb..558d4bde8d4b 100644 --- a/sc/source/core/data/dpoutput.cxx +++ b/sc/source/core/data/dpoutput.cxx @@ -1152,6 +1152,18 @@ long ScDPOutput::GetHeaderRows() const return pPageFields.size() + ( bDoFilter ? 1 : 0 ); } +namespace +{ + void insertNames(ScDPUniqueStringSet& rNames, const uno::Sequence<sheet::MemberResult>& rMemberResults) + { + for (const sheet::MemberResult& rMemberResult : rMemberResults) + { + if (rMemberResult.Flags & sheet::MemberResultFlags::HASMEMBER) + rNames.insert(rMemberResult.Name); + } + } +} + void ScDPOutput::GetMemberResultNames(ScDPUniqueStringSet& rNames, long nDimension) { // Return the list of all member names in a dimension's MemberResults. @@ -1161,26 +1173,20 @@ void ScDPOutput::GetMemberResultNames(ScDPUniqueStringSet& rNames, long nDimensi auto lFindDimension = [nDimension](const ScDPOutLevelData& rField) { return rField.mnDim == nDimension; }; // look in column fields - auto it = std::find_if(pColFields.begin(), pColFields.end(), lFindDimension); - bool bFound = it != pColFields.end(); - - if (!bFound) + auto colit = std::find_if(pColFields.begin(), pColFields.end(), lFindDimension); + if (colit != pColFields.end()) { - // look in row fields - it = std::find_if(pRowFields.begin(), pRowFields.end(), lFindDimension); - bFound = it != pRowFields.end(); + // collect the member names + insertNames(rNames, colit->maResult); + return; } - // collect the member names - - if ( bFound ) + // look in row fields + auto rowit = std::find_if(pRowFields.begin(), pRowFields.end(), lFindDimension); + if (rowit != pRowFields.end()) { - const uno::Sequence<sheet::MemberResult> aMemberResults = it->maResult; - for (const sheet::MemberResult& rMemberResult : aMemberResults) - { - if ( rMemberResult.Flags & sheet::MemberResultFlags::HASMEMBER ) - rNames.insert(rMemberResult.Name); - } + // collect the member names + insertNames(rNames, rowit->maResult); } } |