svx/source/tbxctrls/tbcontrl.cxx |   12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

New commits:
commit 117bca21b7b068266bb91f1d114e435e0a7ab525
Author:     Heiko Tietze <tietze.he...@gmail.com>
AuthorDate: Mon Nov 4 14:22:56 2024 +0100
Commit:     Heiko Tietze <heiko.tie...@documentfoundation.org>
CommitDate: Mon Nov 4 15:53:00 2024 +0100

    Resolves tdf#160626 - Preserve sorting in SvxStyleToolBoxControl
    
    Inserts now up to 12 default styles and adds only user styles
    that are not among the default
    
    Change-Id: I60ea3e46092681a932cf3fe470c2ce9fb3553917
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176011
    Tested-by: Jenkins
    Reviewed-by: Heiko Tietze <heiko.tie...@documentfoundation.org>

diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx
index a11ab9a9d041..bcce38e0a52b 100644
--- a/svx/source/tbxctrls/tbcontrl.cxx
+++ b/svx/source/tbxctrls/tbcontrl.cxx
@@ -177,6 +177,11 @@ public:
             m_xWidget->set_entry_text(rText);
     }
 
+    int find_text(const OUString& rText)
+    {
+        return m_xWidget->find_text(rText);
+    }
+
     void set_active(int nActive)
     {
         m_xWidget->set_active(nActive);
@@ -3257,15 +3262,14 @@ void SvxStyleToolBoxControl::FillStyleBox()
         {
             if ( aStyles.size() + pBox->get_count() > 12)
                 break;
-            // insert default style only if not used (and added to rStyle 
before)
-            if (std::find(aStyles.begin(), aStyles.end(), rStyle.second) >= 
aStyles.end())
-                pBox->append_text(rStyle.second);
+            pBox->append_text(rStyle.second);
         }
     }
     std::sort(aStyles.begin(), aStyles.end());
 
     for (const auto& rStyle : aStyles)
-        pBox->append_text(rStyle);
+        if (pBox->find_text(rStyle) == -1)
+            pBox->append_text(rStyle);
 
     if ((pImpl->bSpecModeWriter || pImpl->bSpecModeCalc) && 
!comphelper::LibreOfficeKit::isActive())
         pBox->append_text(pImpl->aMore);

Reply via email to