diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2023-10-10 12:47:11 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2023-10-11 08:50:10 +0200 |
commit | f47e4b152f5d436fbbe31588601dcf4285716a31 (patch) | |
tree | e2e88c053fba85f5444811cbfc2a450e2e807eb4 | |
parent | cef5f921839496f40d133d43c2ee8c76af9e6222 (diff) |
Simplify a bit
Change-Id: If87cf8d71ce49af191cf991e2dc5479b275cd918
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157745
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
-rw-r--r-- | sot/source/base/formats.cxx | 24 |
1 files changed, 7 insertions, 17 deletions
diff --git a/sot/source/base/formats.cxx b/sot/source/base/formats.cxx index 0b3d80120022..0186c120ed3c 100644 --- a/sot/source/base/formats.cxx +++ b/sot/source/base/formats.cxx @@ -1200,7 +1200,7 @@ SotAction_Impl const aEXCHG_DEST_SDDOC_FREE_AREA_Link[] = }; /* --- exchange destinations --- */ -SotDestinationEntry_Impl const aDestinationArray[] = +SotDestinationEntry_Impl constexpr aDestinationArray[] = { { SotExchangeDest::DOC_OLEOBJ, aEXCHG_DEST_DOC_OLEOBJ_Def, @@ -1304,9 +1304,6 @@ SotDestinationEntry_Impl const aDestinationArray[] = aEXCHG_DEST_SWDOC_FREE_AREA_WEB_Copy, aEXCHG_DEST_SWDOC_FREE_AREA_WEB_Link }, - { - static_cast<SotExchangeDest>(0xffff), nullptr, nullptr, nullptr, nullptr - } }; } // namespace @@ -1477,19 +1474,14 @@ sal_uInt8 SotExchange::GetExchangeAction( const DataFlavorExVector& rDataFlavorE const Reference< XTransferable >* pxTransferable, SotExchangeActionFlags* pActionFlags ) { - rFormat = SotClipboardFormatId::STRING; - //Todo: incorporate a binary search - const SotDestinationEntry_Impl* pEntry = aDestinationArray; - while( static_cast<SotExchangeDest>(0xffff) != pEntry->nDestination ) - { - if( pEntry->nDestination == nDestination ) - break; - ++pEntry; - } + auto pEntry = std::find_if(std::begin(aDestinationArray), std::end(aDestinationArray), + [nDestination](const auto& entry) + { return entry.nDestination == nDestination; }); - if( static_cast<SotExchangeDest>(0xffff) == pEntry->nDestination ) + if (pEntry == std::end(aDestinationArray)) { + rFormat = SotClipboardFormatId::STRING; return EXCHG_INOUT_ACTION_NONE; } @@ -1542,10 +1534,8 @@ sal_uInt8 SotExchange::GetExchangeAction( const DataFlavorExVector& rDataFlavorE rDefaultAction = 0; return 0; } - rDefaultAction = nUserAction; } - else - rDefaultAction = nUserAction; + rDefaultAction = nUserAction; switch( nUserAction ) { |