[Libreoffice-commits] core.git: writerfilter/source
Adrien Ollier (via logerrit)
logerrit at kemper.freedesktop.org
Sun Sep 1 06:10:44 UTC 2019
writerfilter/source/rtftok/rtfsprm.cxx | 54 ++++++++++++++++++---------------
1 file changed, 30 insertions(+), 24 deletions(-)
New commits:
commit a56f2d01687512d4ecdf5b3df949d909aa8834b6
Author: Adrien Ollier <adr.ollier at hotmail.fr>
AuthorDate: Fri Aug 16 01:52:36 2019 +0200
Commit: Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Sun Sep 1 08:10:10 2019 +0200
makes RTFSprms::set clearer
Change-Id: Ic1aab40c8a4abdd73c616b2faaf95ef183fa2e38
Signed-off-by: Adrien Ollier <adr.ollier at hotmail.fr>
Reviewed-on: https://gerrit.libreoffice.org/77556
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
diff --git a/writerfilter/source/rtftok/rtfsprm.cxx b/writerfilter/source/rtftok/rtfsprm.cxx
index 5404dd9176ea..76838e3aa620 100644
--- a/writerfilter/source/rtftok/rtfsprm.cxx
+++ b/writerfilter/source/rtftok/rtfsprm.cxx
@@ -103,32 +103,38 @@ void RTFSprms::set(Id nKeyword, const RTFValue::Pointer_t& pValue, RTFOverwrite
{
ensureCopyBeforeWrite();
- if (eOverwrite == RTFOverwrite::YES_PREPEND)
+ switch (eOverwrite)
{
- auto it = std::remove_if(m_pSprms->begin(), m_pSprms->end(), RTFSprms_compare{ nKeyword });
- m_pSprms->erase(it, m_pSprms->end());
- m_pSprms->insert(m_pSprms->begin(), std::make_pair(nKeyword, pValue));
- return;
- }
-
- bool bFound = false;
- if (eOverwrite == RTFOverwrite::YES || eOverwrite == RTFOverwrite::NO_IGNORE)
- {
- for (auto& rSprm : *m_pSprms)
- if (rSprm.first == nKeyword)
- {
- if (eOverwrite == RTFOverwrite::YES)
- {
- rSprm.second = pValue;
- return;
- }
-
- bFound = true;
- break;
- }
+ case RTFOverwrite::YES_PREPEND:
+ {
+ m_pSprms->erase(
+ std::remove_if(m_pSprms->begin(), m_pSprms->end(), RTFSprms_compare{ nKeyword }),
+ m_pSprms->end());
+ m_pSprms->emplace(m_pSprms->cbegin(), nKeyword, pValue);
+ break;
+ }
+ case RTFOverwrite::YES:
+ {
+ auto it
+ = std::find_if(m_pSprms->begin(), m_pSprms->end(), RTFSprms_compare{ nKeyword });
+ if (it != m_pSprms->end())
+ it->second = pValue;
+ else
+ m_pSprms->emplace_back(nKeyword, pValue);
+ break;
+ }
+ case RTFOverwrite::NO_IGNORE:
+ {
+ if (std::none_of(m_pSprms->cbegin(), m_pSprms->cend(), RTFSprms_compare{ nKeyword }))
+ m_pSprms->emplace_back(nKeyword, pValue);
+ break;
+ }
+ case RTFOverwrite::NO_APPEND:
+ {
+ m_pSprms->emplace_back(nKeyword, pValue);
+ break;
+ }
}
- if (eOverwrite == RTFOverwrite::NO_APPEND || !bFound)
- m_pSprms->push_back(std::make_pair(nKeyword, pValue));
}
bool RTFSprms::erase(Id nKeyword)
More information about the Libreoffice-commits
mailing list