filter/source/svg/svgexport.cxx | 19 +++++++++---------- filter/source/svg/svgwriter.cxx | 2 +- formula/source/ui/dlg/funcpage.cxx | 9 +++------ l10ntools/source/pocheck.cxx | 12 ++++++------ l10ntools/source/xmlparse.cxx | 2 +- 5 files changed, 20 insertions(+), 24 deletions(-)
New commits: commit ed663ada467837658eaeba9c414fdf354c46e6dd Author: Pierre <[email protected]> AuthorDate: Sun Oct 19 08:37:28 2025 +0200 Commit: Ilmari Lauhakangas <[email protected]> CommitDate: Thu Oct 23 20:24:51 2025 +0200 tdf#158237 Use C++20 contains() instead of find() and end() Change-Id: I6688c62b13e9e1dce5f6cd077fafc1d5a6adbae4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/192660 Tested-by: Jenkins Reviewed-by: Ilmari Lauhakangas <[email protected]> diff --git a/filter/source/svg/svgexport.cxx b/filter/source/svg/svgexport.cxx index a0ab37259547..a326d473d90c 100644 --- a/filter/source/svg/svgexport.cxx +++ b/filter/source/svg/svgexport.cxx @@ -1993,7 +1993,7 @@ bool SVGFilter::implExportPage( std::u16string_view sPageId, SvXMLElementExport aExp(*mpSVGExport, u"g"_ustr, true, true); // In case the page has a background object we append it . - if( mpObjects->find( rxPage ) != mpObjects->end() ) + if( mpObjects->contains( rxPage ) ) { const GDIMetaFile& rMtf = (*mpObjects)[ rxPage ].GetRepresentation(); if( rMtf.GetActionSize() ) @@ -2133,7 +2133,7 @@ bool SVGFilter::implExportShape( const Reference< css::drawing::XShape >& rxShap } } - if( !bRet && mpObjects->find( rxShape ) != mpObjects->end() ) + if( !bRet && mpObjects->contains( rxShape ) ) { css::awt::Rectangle aBoundRect; const GDIMetaFile& rMtf = (*mpObjects)[ rxShape ].GetRepresentation(); @@ -2563,7 +2563,7 @@ void SVGFilter::implCreateObjectsFromBackground( const Reference< css::drawing:: bBitmapFound = true; // the subsequent bitmaps are still the same just translated BitmapChecksum nChecksum = GetBitmapChecksum( pAction ); - if( maBitmapActionMap.find( nChecksum ) == maBitmapActionMap.end() ) + if( !maBitmapActionMap.contains( nChecksum ) ) { Point aPos; // (0, 0) Size aSize; @@ -2686,7 +2686,7 @@ IMPL_LINK( SVGFilter, CalcFieldHdl, EditFieldInfo*, pInfo, void ) OSL_FAIL( "error: !mCreateOjectsCurrentMasterPage.is()" ); return; } - bool bHasCharSetMap = mTextFieldCharSets.find( mCreateOjectsCurrentMasterPage ) != mTextFieldCharSets.end(); + const bool bHasCharSetMap = mTextFieldCharSets.contains( mCreateOjectsCurrentMasterPage ); static constexpr OUString aHeaderId( NSPREFIX "header-field"_ustr ); static constexpr OUString aFooterId( aOOOAttrFooterField ); @@ -2700,21 +2700,21 @@ IMPL_LINK( SVGFilter, CalcFieldHdl, EditFieldInfo*, pInfo, void ) pCharSetMap = &( mTextFieldCharSets[ mCreateOjectsCurrentMasterPage ] ); } const SvxFieldData* pField = pInfo->GetField().GetField(); - if( bHasCharSetMap && ( pField->GetClassId() == text::textfield::Type::PRESENTATION_HEADER ) && ( pCharSetMap->find( aHeaderId ) != pCharSetMap->end() ) ) + if( bHasCharSetMap && ( pField->GetClassId() == text::textfield::Type::PRESENTATION_HEADER ) && pCharSetMap->contains( aHeaderId ) ) { pCharSet = &( (*pCharSetMap)[ aHeaderId ] ); } - else if( bHasCharSetMap && ( pField->GetClassId() == text::textfield::Type::PRESENTATION_FOOTER ) && ( pCharSetMap->find( aFooterId ) != pCharSetMap->end() ) ) + else if( bHasCharSetMap && ( pField->GetClassId() == text::textfield::Type::PRESENTATION_FOOTER ) && pCharSetMap->contains( aFooterId ) ) { pCharSet = &( (*pCharSetMap)[ aFooterId ] ); } else if( pField->GetClassId() == text::textfield::Type::PRESENTATION_DATE_TIME ) { - if( bHasCharSetMap && ( pCharSetMap->find( aDateTimeId ) != pCharSetMap->end() ) ) + if( bHasCharSetMap && pCharSetMap->contains( aDateTimeId ) ) { pCharSet = &( (*pCharSetMap)[ aDateTimeId ] ); } - if( bHasCharSetMap && ( pCharSetMap->find( aVariableDateTimeId ) != pCharSetMap->end() ) && !(*pCharSetMap)[ aVariableDateTimeId ].empty() ) + if( bHasCharSetMap && pCharSetMap->contains( aVariableDateTimeId ) && !(*pCharSetMap)[ aVariableDateTimeId ].empty() ) { SvxDateFormat eDateFormat = SvxDateFormat::B, eCurDateFormat; const UCharSet & aCharSet = (*pCharSetMap)[ aVariableDateTimeId ]; @@ -2902,8 +2902,7 @@ void SVGExport::SetEmbeddedBulletGlyph(sal_Unicode cBullet) bool SVGExport::IsEmbeddedBulletGlyph(sal_Unicode cBullet) const { - auto it = maEmbeddedBulletGlyphs.find(cBullet); - return it != maEmbeddedBulletGlyphs.end(); + return maEmbeddedBulletGlyphs.contains(cBullet); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/filter/source/svg/svgwriter.cxx b/filter/source/svg/svgwriter.cxx index d310abed972a..97578079766c 100644 --- a/filter/source/svg/svgwriter.cxx +++ b/filter/source/svg/svgwriter.cxx @@ -2922,7 +2922,7 @@ void SVGActionWriter::ImplWriteBmp( const Bitmap& rBmp, if( mpEmbeddedBitmapsMap && !mpEmbeddedBitmapsMap->empty()) { BitmapChecksum nChecksum = rBmp.GetChecksum(); - if( mpEmbeddedBitmapsMap->find( nChecksum ) != mpEmbeddedBitmapsMap->end() ) + if( mpEmbeddedBitmapsMap->contains( nChecksum ) ) { // <use transform="translate(?) scale(?)" xlink:ref="?" > OUString sTransform; diff --git a/formula/source/ui/dlg/funcpage.cxx b/formula/source/ui/dlg/funcpage.cxx index 06f0f6ddd3ef..f6ce824c0e49 100644 --- a/formula/source/ui/dlg/funcpage.cxx +++ b/formula/source/ui/dlg/funcpage.cxx @@ -92,7 +92,7 @@ weld::TreeIter* FuncPage::FillCategoriesMap(const OUString& aCategory, bool bFil if (!bFill) return nullptr; - if (mCategories.find(aCategory) == mCategories.end()) + if (!mCategories.contains(aCategory)) { mCategories[aCategory] = m_xLbFunction->make_iterator(); m_xLbFunction->insert(nullptr, -1, &aCategory, nullptr, nullptr, nullptr, false, @@ -101,10 +101,7 @@ weld::TreeIter* FuncPage::FillCategoriesMap(const OUString& aCategory, bool bFil return mCategories[aCategory].get(); } -bool FuncPage::IsFavourite(sal_uInt16 nFIndex) const -{ - return aFavouritesList.find(nFIndex) != aFavouritesList.end(); -} +bool FuncPage::IsFavourite(sal_uInt16 nFIndex) const { return aFavouritesList.contains(nFIndex); } bool FuncPage::UpdateFavouritesList() { @@ -312,7 +309,7 @@ IMPL_LINK_NOARG(FuncPage, SelTreeViewHdl, weld::TreeView&, void) IMPL_LINK_NOARG(FuncPage, DblClkHdl, weld::TreeView&, bool) { const OUString aString = m_xLbFunction->get_selected_text(); - if (mCategories.find(aString) != mCategories.end()) + if (mCategories.contains(aString)) { const auto& categoryRow = *(mCategories[aString]); if (m_xLbFunction->get_row_expanded(categoryRow)) diff --git a/l10ntools/source/pocheck.cxx b/l10ntools/source/pocheck.cxx index eaf7e41a93ee..2326481043ce 100644 --- a/l10ntools/source/pocheck.cxx +++ b/l10ntools/source/pocheck.cxx @@ -51,7 +51,7 @@ static void checkStyleNames(const OString& aLanguage) const OString& aMsgStr = aPoEntry.getMsgStr(); if( aMsgStr.isEmpty() ) continue; - if( aLocalizedStyleNames.find(aMsgStr) == aLocalizedStyleNames.end() ) + if( !aLocalizedStyleNames.contains(aMsgStr) ) aLocalizedStyleNames[aMsgStr] = 1; else { aLocalizedStyleNames[aMsgStr]++; @@ -63,7 +63,7 @@ static void checkStyleNames(const OString& aLanguage) const OString& aMsgStr = aPoEntry.getMsgStr(); if( aMsgStr.isEmpty() ) continue; - if( aLocalizedNumStyleNames.find(aMsgStr) == aLocalizedNumStyleNames.end() ) + if( !aLocalizedNumStyleNames.contains(aMsgStr) ) aLocalizedNumStyleNames[aMsgStr] = 1; else { aLocalizedNumStyleNames[aMsgStr]++; @@ -171,9 +171,9 @@ static void checkFunctionNames(const OString& aLanguage) const OString& aMsgStr = aPoEntry.getMsgStr(); if( aMsgStr.isEmpty() ) continue; - if( aLocalizedCoreFunctionNames.find(aMsgStr) == aLocalizedCoreFunctionNames.end() ) + if( !aLocalizedCoreFunctionNames.contains(aMsgStr) ) aLocalizedCoreFunctionNames[aMsgStr] = 1; - if( aLocalizedFunctionNames.find(aMsgStr) == aLocalizedFunctionNames.end() ) { + if( !aLocalizedFunctionNames.contains(aMsgStr) ) { aLocalizedFunctionNames[aMsgStr] = 1; } else { aLocalizedFunctionNames[aMsgStr]++; @@ -205,9 +205,9 @@ static void checkFunctionNames(const OString& aLanguage) OString aMsgStr = aPoEntry.getMsgStr(); if( aMsgStr.isEmpty() ) continue; - if( aLocalizedCoreFunctionNames.find(aMsgStr) != aLocalizedCoreFunctionNames.end() ) + if( aLocalizedCoreFunctionNames.contains(aMsgStr) ) aMsgStr += "_ADD"; - if( aLocalizedFunctionNames.find(aMsgStr) == aLocalizedFunctionNames.end() ) { + if( !aLocalizedFunctionNames.contains(aMsgStr) ) { aLocalizedFunctionNames[aMsgStr] = 1; } else { aLocalizedFunctionNames[aMsgStr]++; diff --git a/l10ntools/source/xmlparse.cxx b/l10ntools/source/xmlparse.cxx index d5571a6a1f33..875bdd308a27 100644 --- a/l10ntools/source/xmlparse.cxx +++ b/l10ntools/source/xmlparse.cxx @@ -457,7 +457,7 @@ void XMLFile::SearchL10NElements( XMLChildNode *pCur ) } } - if ( bInsert && ( m_aNodes_localize.find( sName ) != m_aNodes_localize.end() ) ) + if ( bInsert && m_aNodes_localize.contains( sName ) ) InsertL10NElement(pElement); else if ( bInsert && pElement->GetChildList() ) {
