cppuhelper/source/component_context.cxx          |    2 +-
 desktop/source/lib/init.cxx                      |    2 +-
 filter/source/graphicfilter/icgm/actimpr.cxx     |    2 +-
 filter/source/svg/svgexport.cxx                  |    2 +-
 forms/source/xforms/convert.cxx                  |    2 +-
 libreofficekit/source/gtk/lokdocview.cxx         |    2 +-
 linguistic/source/gciterator.cxx                 |    4 ++--
 sd/source/core/CustomAnimationCloner.cxx         |    2 +-
 sdext/source/pdfimport/sax/saxattrlist.cxx       |    2 +-
 sfx2/qa/cppunit/doc.cxx                          |    4 ++--
 stoc/source/servicemanager/servicemanager.cxx    |    2 +-
 svl/source/items/itempool.cxx                    |    2 +-
 svx/source/smarttags/SmartTagMgr.cxx             |    2 +-
 sw/source/uibase/sidebar/CommentsPanel.cxx       |    2 +-
 vcl/source/cnttype/mcnttype.cxx                  |    2 +-
 vcl/source/window/builder.cxx                    |    4 ++--
 vcl/unx/generic/printer/cpdmgr.cxx               |    2 +-
 vcl/unx/generic/printer/cupsmgr.cxx              |    2 +-
 writerperfect/source/common/WPXSvInputStream.cxx |    4 ++--
 19 files changed, 23 insertions(+), 23 deletions(-)

New commits:
commit bf7ac07c04cb06316b745eb9716787b16c1314dd
Author:     Johann <jlor...@linagora.com>
AuthorDate: Tue Dec 17 13:16:39 2024 +0100
Commit:     Ilmari Lauhakangas <ilmari.lauhakan...@libreoffice.org>
CommitDate: Fri Dec 27 16:20:47 2024 +0100

    tdf#158237: Use C++20 contains() instead of find() and end()
    
    Change-Id: I0528229042aa62d3d99e8dbaad68a86d41cf369a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178659
    Reviewed-by: Ilmari Lauhakangas <ilmari.lauhakan...@libreoffice.org>
    Tested-by: Jenkins

diff --git a/cppuhelper/source/component_context.cxx 
b/cppuhelper/source/component_context.cxx
index 227affa9a619..a8c58c4812e9 100644
--- a/cppuhelper/source/component_context.cxx
+++ b/cppuhelper/source/component_context.cxx
@@ -246,7 +246,7 @@ Sequence<OUString> ComponentContext::getElementNames()
 sal_Bool ComponentContext::hasByName( OUString const & name )
 {
     std::unique_lock guard( m_aMutex );
-    return m_map.find( name ) != m_map.end();
+    return m_map.contains( name );
 }
 
 // XElementAccess
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index f858b9fdd22a..9f42a3524707 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -7693,7 +7693,7 @@ static void lo_setDocumentPassword(LibreOfficeKit* pThis,
     assert(pThis);
     assert(pURL);
     LibLibreOffice_Impl *const pLib = static_cast<LibLibreOffice_Impl*>(pThis);
-    assert(pLib->mInteractionMap.find(OString(pURL)) != 
pLib->mInteractionMap.end());
+    assert(pLib->mInteractionMap.contains(OString(pURL)));
     pLib->mInteractionMap.find(OString(pURL))->second->SetPassword(pPassword);
 }
 
diff --git a/filter/source/graphicfilter/icgm/actimpr.cxx 
b/filter/source/graphicfilter/icgm/actimpr.cxx
index 64cd4d8359b3..3d51d8e4470a 100644
--- a/filter/source/graphicfilter/icgm/actimpr.cxx
+++ b/filter/source/graphicfilter/icgm/actimpr.cxx
@@ -321,7 +321,7 @@ void CGMImpressOutAct::ImplSetFillBundle()
     drawing::Hatch aHatch;
 
     aHatch.Color = nFillColor;
-    if ( mpCGM->pElement->maHatchMap.find( nHatchIndex ) !=  
mpCGM->pElement->maHatchMap.end() )
+    if ( mpCGM->pElement->maHatchMap.contains( nHatchIndex ) )
     {
         HatchEntry& rHatchEntry = mpCGM->pElement->maHatchMap[ nHatchIndex ];
         switch ( rHatchEntry.HatchStyle )
diff --git a/filter/source/svg/svgexport.cxx b/filter/source/svg/svgexport.cxx
index 63e829653046..28b9980d5f88 100644
--- a/filter/source/svg/svgexport.cxx
+++ b/filter/source/svg/svgexport.cxx
@@ -2222,7 +2222,7 @@ bool SVGFilter::implExportShape( const Reference< 
css::drawing::XShape >& rxShap
                     }
 
                     const GDIMetaFile* pEmbeddedBitmapsMtf = nullptr;
-                    if( mEmbeddedBitmapActionMap.find( rxShape ) !=  
mEmbeddedBitmapActionMap.end() )
+                    if( mEmbeddedBitmapActionMap.contains( rxShape ) )
                     {
                         pEmbeddedBitmapsMtf = &( mEmbeddedBitmapActionMap[ 
rxShape ].GetRepresentation() );
                     }
diff --git a/forms/source/xforms/convert.cxx b/forms/source/xforms/convert.cxx
index 1192cc729b93..c95d5fae6856 100644
--- a/forms/source/xforms/convert.cxx
+++ b/forms/source/xforms/convert.cxx
@@ -280,7 +280,7 @@ Convert& Convert::get()
 
 bool Convert::hasType( const css::uno::Type& rType )
 {
-    return maMap.find( rType ) != maMap.end();
+    return maMap.contains( rType );
 }
 
 css::uno::Sequence<css::uno::Type> Convert::getTypes() const
diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index 0c2784537032..83abc73095ce 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -1789,7 +1789,7 @@ static const GdkRGBA& getDarkColor(int nViewId, 
LOKDocViewPrivate& priv)
         GdkRGBA aColor = aColors[nColorCounter++ % aColors.size()];
         aColorMap[nViewId] = aColor;
     }
-    assert(aColorMap.find(nViewId) != aColorMap.end());
+    assert(aColorMap.contains(nViewId));
     return aColorMap[nViewId];
 }
 
diff --git a/linguistic/source/gciterator.cxx b/linguistic/source/gciterator.cxx
index 5a253752f4a3..e2acf1e9d0e6 100644
--- a/linguistic/source/gciterator.cxx
+++ b/linguistic/source/gciterator.cxx
@@ -251,7 +251,7 @@ css::uno::Any SAL_CALL LngXStringKeyMap::getValue(const 
OUString& aKey)
 
 sal_Bool SAL_CALL LngXStringKeyMap::hasValue(const OUString& aKey)
 {
-    return maMap.find(aKey) != maMap.end();
+    return maMap.contains(aKey);
 }
 
 ::sal_Int32 SAL_CALL LngXStringKeyMap::getCount() { return maMap.size(); }
@@ -341,7 +341,7 @@ OUString GrammarCheckingIterator::GetOrCreateDocId(
     OUString aRes;
     if (xComponent.is())
     {
-        if (m_aDocIdMap.find( xComponent.get() ) != m_aDocIdMap.end())
+        if (m_aDocIdMap.contains( xComponent.get() ))
         {
             // return already existing entry
             aRes = m_aDocIdMap[ xComponent.get() ];
diff --git a/sd/source/core/CustomAnimationCloner.cxx 
b/sd/source/core/CustomAnimationCloner.cxx
index 8c89a5874f43..31569cc51fc6 100644
--- a/sd/source/core/CustomAnimationCloner.cxx
+++ b/sd/source/core/CustomAnimationCloner.cxx
@@ -275,7 +275,7 @@ namespace sd
     {
         if( xSource.is() )
         {
-            if( maShapeMap.find(xSource) != maShapeMap.end() )
+            if( maShapeMap.contains(xSource) )
             {
                 return maShapeMap[xSource];
             }
diff --git a/sdext/source/pdfimport/sax/saxattrlist.cxx 
b/sdext/source/pdfimport/sax/saxattrlist.cxx
index d9ae07b12317..e529e7eafabf 100644
--- a/sdext/source/pdfimport/sax/saxattrlist.cxx
+++ b/sdext/source/pdfimport/sax/saxattrlist.cxx
@@ -53,7 +53,7 @@ OUString SAL_CALL SaxAttrList::getTypeByIndex( sal_Int16 
i_nIndex)
 
 OUString SAL_CALL SaxAttrList::getTypeByName( const OUString& i_rName )
 {
-    return (m_aIndexMap.find( i_rName ) != m_aIndexMap.end()) ? CDATA : 
OUString();
+    return (m_aIndexMap.contains( i_rName )) ? CDATA : OUString();
 }
 
 OUString SAL_CALL SaxAttrList::getValueByIndex( sal_Int16 i_nIndex )
diff --git a/sfx2/qa/cppunit/doc.cxx b/sfx2/qa/cppunit/doc.cxx
index b16c078ef412..87b9d13a1ed4 100644
--- a/sfx2/qa/cppunit/doc.cxx
+++ b/sfx2/qa/cppunit/doc.cxx
@@ -140,8 +140,8 @@ CPPUNIT_TEST_FIXTURE(Test, testSetDocumentPropertiesUpdate)
     // - Actual  : foo
     // i.e. ZOTERO_PREF_1 was not updated.
     CPPUNIT_ASSERT_EQUAL(u"test"_ustr, it->second.get<OUString>());
-    CPPUNIT_ASSERT(bool(aMap.find(u"ZOTERO_PREF_2"_ustr) == aMap.end()));
-    CPPUNIT_ASSERT(aMap.find(u"OTHER"_ustr) != aMap.end());
+    CPPUNIT_ASSERT(!aMap.contains(u"ZOTERO_PREF_2"_ustr));
+    CPPUNIT_ASSERT(aMap.contains(u"OTHER"_ustr));
 }
 }
 
diff --git a/stoc/source/servicemanager/servicemanager.cxx 
b/stoc/source/servicemanager/servicemanager.cxx
index 82ec03c3635d..b38381ddaddb 100644
--- a/stoc/source/servicemanager/servicemanager.cxx
+++ b/stoc/source/servicemanager/servicemanager.cxx
@@ -1047,7 +1047,7 @@ void OServiceManager::insert( const Any & Element )
 // helper function
 bool OServiceManager::haveFactoryWithThisImplementation(const OUString& 
aImplName)
 {
-    return ( m_ImplementationNameMap.find(aImplName) != 
m_ImplementationNameMap.end());
+    return m_ImplementationNameMap.contains(aImplName);
 }
 
 // XSet
diff --git a/svl/source/items/itempool.cxx b/svl/source/items/itempool.cxx
index ea9166c37618..72663cf1b61d 100644
--- a/svl/source/items/itempool.cxx
+++ b/svl/source/items/itempool.cxx
@@ -208,7 +208,7 @@ const SlotIDToWhichIDMap& 
ItemInfoPackage::getSlotIDToWhichIDMap() const
             if (0 != rCandidate.getSlotID())
             {
 #ifdef DBG_UTIL
-                if (maSlotIDToWhichIDMap.find(rCandidate.getSlotID()) != 
maSlotIDToWhichIDMap.end())
+                if (maSlotIDToWhichIDMap.contains(rCandidate.getSlotID()))
                     assert(false && "ITEM: SlotID used double in 
ItemInfoPackage (!)");
 #endif
                 maSlotIDToWhichIDMap[rCandidate.getSlotID()] = 
rCandidate.getWhich();
diff --git a/svx/source/smarttags/SmartTagMgr.cxx 
b/svx/source/smarttags/SmartTagMgr.cxx
index 49ee7e0b3bac..f302fd1da0d4 100644
--- a/svx/source/smarttags/SmartTagMgr.cxx
+++ b/svx/source/smarttags/SmartTagMgr.cxx
@@ -491,7 +491,7 @@ void SmartTagMgr::AssociateActionsWithRecognizers()
             const OUString aSmartTagName = xRecognizer->getSmartTagName(j);
 
             // check if smart tag type has already been processed:
-            if ( maSmartTagMap.find( aSmartTagName ) != maSmartTagMap.end() )
+            if ( maSmartTagMap.contains( aSmartTagName ) )
                 continue;
 
             bool bFound = false;
diff --git a/sw/source/uibase/sidebar/CommentsPanel.cxx 
b/sw/source/uibase/sidebar/CommentsPanel.cxx
index 66a8cf9eef20..b95596100c0d 100644
--- a/sw/source/uibase/sidebar/CommentsPanel.cxx
+++ b/sw/source/uibase/sidebar/CommentsPanel.cxx
@@ -528,7 +528,7 @@ void CommentsPanel::deleteComment(sal_uInt32 nId)
     // // If the root comment is deleted, the new root comment of the thread 
should be the next comment in the thread
     // // but due to a bug `getRootCommentWin` returns root comment of some 
other/random thread so we completely lose
     // // access to the current thread.
-    // if (mpThreadsMap.find(nId) != mpThreadsMap.end())
+    // if (mpThreadsMap.contains(nId))
     // {
     //     pRootNote = mpThreadsMap[nId];
     // }
diff --git a/vcl/source/cnttype/mcnttype.cxx b/vcl/source/cnttype/mcnttype.cxx
index cc5facf17717..2c1ff0ed9a5f 100644
--- a/vcl/source/cnttype/mcnttype.cxx
+++ b/vcl/source/cnttype/mcnttype.cxx
@@ -53,7 +53,7 @@ css::uno::Sequence< OUString > SAL_CALL 
CMimeContentType::getParameters( )
 
 sal_Bool SAL_CALL CMimeContentType::hasParameter( const OUString& aName )
 {
-    return ( m_ParameterMap.end( ) != m_ParameterMap.find( 
aName.toAsciiLowerCase() ) );
+    return m_ParameterMap.contains( aName.toAsciiLowerCase() );
 }
 
 OUString SAL_CALL CMimeContentType::getParameterValue( const OUString& aName )
diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx
index df2df8235f68..b21d26bb5f1e 100644
--- a/vcl/source/window/builder.cxx
+++ b/vcl/source/window/builder.cxx
@@ -1673,7 +1673,7 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window 
*pParent, const OUString
     }
     else if (name == "GtkIconView")
     {
-        assert(rMap.find(u"model"_ustr) != rMap.end() && "GtkIconView must 
have a model");
+        assert(rMap.contains(u"model"_ustr) && "GtkIconView must have a 
model");
 
         //window we want to apply the packing props for this GtkIconView to
         VclPtr<vcl::Window> xWindowForPackingProps;
@@ -1696,7 +1696,7 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window 
*pParent, const OUString
     {
         if (!isLegacy())
         {
-            assert(rMap.find(u"model"_ustr) != rMap.end() && "GtkTreeView must 
have a model");
+            assert(rMap.contains(u"model"_ustr) && "GtkTreeView must have a 
model");
         }
 
         //window we want to apply the packing props for this GtkTreeView to
diff --git a/vcl/unx/generic/printer/cpdmgr.cxx 
b/vcl/unx/generic/printer/cpdmgr.cxx
index 7dc17cede353..00023060b073 100644
--- a/vcl/unx/generic/printer/cpdmgr.cxx
+++ b/vcl/unx/generic/printer/cpdmgr.cxx
@@ -507,7 +507,7 @@ void CPDManager::initialize()
     std::unordered_map<OUString, Printer>::iterator it = m_aPrinters.begin();
     while (it != m_aPrinters.end())
     {
-        if (m_aCPDDestMap.find(it->first) != m_aCPDDestMap.end())
+        if (m_aCPDDestMap.contains(it->first))
         {
             ++it;
             continue;
diff --git a/vcl/unx/generic/printer/cupsmgr.cxx 
b/vcl/unx/generic/printer/cupsmgr.cxx
index fa61a6052b20..87f2acc8d088 100644
--- a/vcl/unx/generic/printer/cupsmgr.cxx
+++ b/vcl/unx/generic/printer/cupsmgr.cxx
@@ -383,7 +383,7 @@ void CUPSManager::initialize()
     std::unordered_map< OUString, Printer >::iterator it = m_aPrinters.begin();
     while(it != m_aPrinters.end())
     {
-        if( m_aCUPSDestMap.find( it->first ) != m_aCUPSDestMap.end() )
+        if( m_aCUPSDestMap.contains( it->first ) )
         {
             ++it;
             continue;
diff --git a/writerperfect/source/common/WPXSvInputStream.cxx 
b/writerperfect/source/common/WPXSvInputStream.cxx
index 0767e94d263e..c4fa9c56614a 100644
--- a/writerperfect/source/common/WPXSvInputStream.cxx
+++ b/writerperfect/source/common/WPXSvInputStream.cxx
@@ -565,7 +565,7 @@ bool WPXSvInputStream::existsSubStream(const char* const 
name)
     if (isOLE())
     {
         ensureOLEIsInitialized();
-        return mpOLEStorage->maNameMap.end() != 
mpOLEStorage->maNameMap.find(aName);
+        return mpOLEStorage->maNameMap.contains(aName);
     }
 
     mxSeekable->seek(0);
@@ -573,7 +573,7 @@ bool WPXSvInputStream::existsSubStream(const char* const 
name)
     if (isZip())
     {
         ensureZipIsInitialized();
-        return mpZipStorage->maNameMap.end() != 
mpZipStorage->maNameMap.find(aName);
+        return mpZipStorage->maNameMap.contains(aName);
     }
 
     return false;

Reply via email to