diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2016-09-18 16:07:22 +0200 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2016-09-18 16:48:22 +0000 |
commit | 046f3aa2d9285da7661c4d9f59c0baf406227553 (patch) | |
tree | 91f5f31ff2792a9fda655c7f10209739c605ed0a /sc | |
parent | 0a2d66c66642c6f1a65039861087592311457b37 (diff) |
extract the code to get the max key id to own method
Change-Id: I56bd53e03a7ea97b15895528ec02a09a73d877b6
Reviewed-on: https://gerrit.libreoffice.org/28994
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/conditio.hxx | 2 | ||||
-rw-r--r-- | sc/source/core/data/conditio.cxx | 12 | ||||
-rw-r--r-- | sc/source/core/data/table1.cxx | 9 |
3 files changed, 15 insertions, 8 deletions
diff --git a/sc/inc/conditio.hxx b/sc/inc/conditio.hxx index f5693916465c..e3a19d05cf03 100644 --- a/sc/inc/conditio.hxx +++ b/sc/inc/conditio.hxx @@ -523,6 +523,8 @@ public: void startRendering(); void endRendering(); + + sal_uInt32 getMaxKey() const; }; #endif diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx index e9440a09fa4d..2a6b48aeb07a 100644 --- a/sc/source/core/data/conditio.cxx +++ b/sc/source/core/data/conditio.cxx @@ -2282,4 +2282,16 @@ void ScConditionalFormatList::clear() m_ConditionalFormats.clear(); } +sal_uInt32 ScConditionalFormatList::getMaxKey() const +{ + sal_uInt32 nMax = 0; + for (const auto& aEntry : m_ConditionalFormats) + { + if (aEntry->GetKey() > nMax) + nMax = aEntry->GetKey(); + } + + return nMax; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx index f770c7e02d61..2da7c761afcd 100644 --- a/sc/source/core/data/table1.cxx +++ b/sc/source/core/data/table1.cxx @@ -2115,14 +2115,7 @@ sal_uLong ScTable::AddCondFormat( ScConditionalFormat* pNew ) if(!mpCondFormatList) mpCondFormatList.reset(new ScConditionalFormatList()); - sal_uLong nMax = 0; - for(ScConditionalFormatList::const_iterator itr = mpCondFormatList->begin(); - itr != mpCondFormatList->end(); ++itr) - { - sal_uLong nKey = (*itr)->GetKey(); - if(nKey > nMax) - nMax = nKey; - } + sal_uInt32 nMax = mpCondFormatList->getMaxKey(); pNew->SetKey(nMax+1); mpCondFormatList->InsertNew(pNew); |