dbaccess/source/ui/misc/WTypeSelect.cxx | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-)
New commits: commit 00dfdd0154a25c56723296958b1d08f7fa07763a Author: Hossein <[email protected]> AuthorDate: Thu Jan 8 14:30:36 2026 +0100 Commit: Hossein <[email protected]> CommitDate: Tue Jan 20 14:44:32 2026 +0100 tdf#170269 Use C++20 std::ranges::all_of instead of a loop Used C++20 std::ranges::all_of() instead of a loop to simplify the code. Also, it seemed that sort() was not necesary, so I removed that. Change-Id: I244c862252881683d50cfe9bc140b7b6b5dfa82f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/196851 Tested-by: Jenkins Reviewed-by: Hossein <[email protected]> diff --git a/dbaccess/source/ui/misc/WTypeSelect.cxx b/dbaccess/source/ui/misc/WTypeSelect.cxx index 622c7da18bbc..37bdde5cc578 100644 --- a/dbaccess/source/ui/misc/WTypeSelect.cxx +++ b/dbaccess/source/ui/misc/WTypeSelect.cxx @@ -330,18 +330,15 @@ OWizTypeSelectList::OWizTypeSelectList(std::unique_ptr<weld::TreeView> xControl) bool OWizTypeSelectList::IsPrimaryKeyAllowed() const { - auto aRows = m_xControl->get_selected_rows(); - std::sort(aRows.begin(), aRows.end()); + if (!m_bPKey) + return true; - const sal_Int32 nCount = aRows.size(); + auto aRows = m_xControl->get_selected_rows(); - for( sal_Int32 j = 0; m_bPKey && j < nCount; ++j ) - { - OFieldDescription* pField = weld::fromId<OFieldDescription*>(m_xControl->get_id(aRows[j])); - if(!pField || pField->getTypeInfo()->nSearchType == ColumnSearch::NONE) - return false; - } - return true; + return std::ranges::all_of(aRows, [this](sal_Int32 row) { + auto* pField = weld::fromId<OFieldDescription*>(m_xControl->get_id(row)); + return pField && pField->getTypeInfo()->nSearchType != ColumnSearch::NONE; + }); } void OWizTypeSelectList::setPrimaryKey(OFieldDescription* _pFieldDescr, sal_uInt16 _nPos, bool _bSet)
