diff options
author | Pranav Kant <pranavk@collabora.co.uk> | 2017-11-30 01:16:40 +0530 |
---|---|---|
committer | pranavk <pranavk@collabora.co.uk> | 2017-11-30 13:14:13 +0100 |
commit | a36f2d7a66e54e6cc296a565391f8b25396543e3 (patch) | |
tree | 1b17fc224d8150adc3a4601d87646c254a1d489c /desktop | |
parent | 1d961ae75321cd04f40fcee8fae94c059fc466f1 (diff) |
lok: Replace this custom loop with STL
Change-Id: I3b93654ba3d41733209ff819ca1d0250fb47ce74
Reviewed-on: https://gerrit.libreoffice.org/45526
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: pranavk <pranavk@collabora.co.uk>
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/source/lib/init.cxx | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 0bfa4c7d9317..f58714623fbe 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -13,6 +13,7 @@ #include <string.h> #include <stdlib.h> +#include <algorithm> #include <memory> #include <iostream> #include <boost/property_tree/json_parser.hpp> @@ -2340,24 +2341,19 @@ static void doc_postUnoCommand(LibreOfficeKitDocument* pThis, const char* pComma beans::PropertyValue aValue; aValue.Name = "InteractionHandler"; aValue.Value <<= xInteraction; - aPropertyValuesVector.push_back(aValue); - // Check if DontSaveIfUnmodified is specified bool bDontSaveIfUnmodified = false; - auto it = aPropertyValuesVector.begin(); - while (it != aPropertyValuesVector.end()) - { - if (it->Name == "DontSaveIfUnmodified") - { - bDontSaveIfUnmodified = it->Value.get<bool>(); - - // Also remove this param before handling to core - it = aPropertyValuesVector.erase(it); - } - else - it++; - } + aPropertyValuesVector.erase(std::remove_if(aPropertyValuesVector.begin(), + aPropertyValuesVector.end(), + [&bDontSaveIfUnmodified](const beans::PropertyValue& aItem){ + if (aItem.Name == "DontSaveIfUnmodified") + { + bDontSaveIfUnmodified = aItem.Value.get<bool>(); + return true; + } + return false; + }), aPropertyValuesVector.end()); // skip saving and tell the result via UNO_COMMAND_RESULT if (bDontSaveIfUnmodified && !pDocSh->IsModified()) |