cui/source/dialogs/cuigaldlg.cxx |   38 +++++++++++++-------------------------
 cui/source/inc/cuigaldlg.hxx     |    8 +-------
 2 files changed, 14 insertions(+), 32 deletions(-)

New commits:
commit 2a700af795fc57876379802744a3f0707f8f592d
Author:     Julien Nabet <serval2...@yahoo.fr>
AuthorDate: Sun Oct 20 15:05:32 2024 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Sun Oct 20 22:25:12 2024 +0200

    FilterEntry is just an OUString, simplify this (cui)
    
    Change-Id: I189922791e5ef3db111aa95fb9dc5af4c757a9ac
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175257
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>
    Tested-by: Jenkins
    (cherry picked from commit b83094d1198ae59ef7736fb3bbce5448459370e9)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175262
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/cui/source/dialogs/cuigaldlg.cxx b/cui/source/dialogs/cuigaldlg.cxx
index fb2007532fc2..15f4e08ba2d3 100644
--- a/cui/source/dialogs/cuigaldlg.cxx
+++ b/cui/source/dialogs/cuigaldlg.cxx
@@ -97,7 +97,7 @@ void SearchThread::execute()
             nBeginFormat = nEndFormat = nFileNumber;
 
         for (sal_Int32 i = nBeginFormat; i <= nEndFormat; ++i)
-            aFormats.push_back( mpBrowser->aFilterEntryList[ i 
]->aFilterName.toAsciiLowerCase() );
+            aFormats.push_back( mpBrowser->aFilterEntryList[ i 
].toAsciiLowerCase() );
 
         ImplSearch( maStartURL, aFormats, mpBrowser->bSearchRecursive );
     }
@@ -665,8 +665,6 @@ void TPGalleryThemeProperties::FillFilterList()
     {
         aExt = rFilter.GetImportFormatShortName( i );
         aName = rFilter.GetImportFormatName( i );
-        size_t entryIndex = 0;
-        FilterEntry* pTestEntry = aFilterEntryList.empty() ? nullptr : 
aFilterEntryList[ entryIndex ].get();
         bool bInList = false;
 
         OUString aExtensions;
@@ -686,22 +684,14 @@ void TPGalleryThemeProperties::FillFilterList()
         }
         aName = addExtension( aName, aExtensions );
 
-        while( pTestEntry )
-        {
-            if ( pTestEntry->aFilterName == aExt )
-            {
-                bInList = true;
-                break;
-            }
-            pTestEntry = ( ++entryIndex < aFilterEntryList.size() )
-                       ? aFilterEntryList[ entryIndex ].get() : nullptr;
-        }
+        auto it = std::find(aFilterEntryList.begin(), aFilterEntryList.end(), 
aExt);
+        if (it != aFilterEntryList.end())
+            bInList = true;
+
         if ( !bInList )
         {
-            std::unique_ptr<FilterEntry> pFilterEntry(new FilterEntry);
-            pFilterEntry->aFilterName = aExt;
             m_xCbbFileType->append_text(aName);
-            aFilterEntryList.push_back(std::move(pFilterEntry));
+            aFilterEntryList.push_back(aExt);
         }
     }
 
@@ -716,11 +706,10 @@ void TPGalleryThemeProperties::FillFilterList()
         {
             OUString aFilterWildcard( aWildcard );
 
-            std::unique_ptr<FilterEntry> pFilterEntry(new FilterEntry);
-            pFilterEntry->aFilterName = aFilter.second.getToken( 0, ';', 
nIndex );
-            aFilterWildcard += pFilterEntry->aFilterName;
+            OUString aFilterName = aFilter.second.getToken( 0, ';', nIndex );
+            aFilterWildcard += aFilterName;
             m_xCbbFileType->append_text(addExtension(aFilter.first, 
aFilterWildcard));
-            aFilterEntryList.push_back( std::move(pFilterEntry) );
+            aFilterEntryList.push_back( aFilterName );
         }
     }
 #endif
@@ -766,12 +755,11 @@ void TPGalleryThemeProperties::FillFilterList()
         aExtensions = "*.*";
 #endif
 
-    std::unique_ptr<FilterEntry> pFilterEntry(new FilterEntry);
-    pFilterEntry->aFilterName = CuiResId(RID_CUISTR_GALLERY_ALLFILES);
-    pFilterEntry->aFilterName = addExtension(pFilterEntry->aFilterName, 
aExtensions);
-    m_xCbbFileType->insert_text(0, pFilterEntry->aFilterName);
+    OUString aFilterName = CuiResId(RID_CUISTR_GALLERY_ALLFILES);
+    aFilterName = addExtension(aFilterName, aExtensions);
+    m_xCbbFileType->insert_text(0, aFilterName);
     m_xCbbFileType->set_active(0);
-    aFilterEntryList.insert(aFilterEntryList.begin(), std::move(pFilterEntry));
+    aFilterEntryList.insert(aFilterEntryList.begin(), aFilterName);
 }
 
 IMPL_LINK_NOARG(TPGalleryThemeProperties, SelectFileTypeHdl, weld::ComboBox&, 
void)
diff --git a/cui/source/inc/cuigaldlg.hxx b/cui/source/inc/cuigaldlg.hxx
index cac63d8a6b1e..1dcf6504459e 100644
--- a/cui/source/inc/cuigaldlg.hxx
+++ b/cui/source/inc/cuigaldlg.hxx
@@ -41,11 +41,6 @@ class TPGalleryThemeProperties;
 
 typedef std::vector< sal_Int32 > TokenList_impl;
 
-struct FilterEntry
-{
-    OUString  aFilterName;
-};
-
 class SearchThread: public salhelper::Thread
 {
 private:
@@ -217,8 +212,7 @@ class TPGalleryThemeProperties : public SfxTabPage
 
     ExchangeData*           pData;
     std::vector<OUString>   aFoundList;
-    std::vector< std::unique_ptr<FilterEntry> >
-                            aFilterEntryList;
+    std::vector<OUString>   aFilterEntryList;
     Timer                   aPreviewTimer;
     OUString                aLastFilterName;
     OUString                aPreviewString;

Reply via email to