diff options
author | Heiko Tietze <tietze.heiko@gmail.com> | 2023-01-10 15:10:41 +0100 |
---|---|---|
committer | Heiko Tietze <heiko.tietze@documentfoundation.org> | 2023-01-11 08:21:47 +0000 |
commit | 95756934cf56e4a9ff58464bc0ed6881c15fe411 (patch) | |
tree | 411ba1f388566e034b600bb2f1664165bd86114f /svx/source/tbxctrls | |
parent | 30f6793baa5529b0594407cd0caaf3a3cde3289c (diff) |
Resolves tdf#152666 - Hide default styles for large lists
Show the default styles only if the number of items
are low and hide successively otherwise
Change-Id: Iefafa0cfee7629fb034b9583d7aed7501475a54a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145268
Tested-by: Jenkins
Reviewed-by: Heiko Tietze <heiko.tietze@documentfoundation.org>
Diffstat (limited to 'svx/source/tbxctrls')
-rw-r--r-- | svx/source/tbxctrls/tbcontrl.cxx | 47 |
1 files changed, 13 insertions, 34 deletions
diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx index 4563010ac053..03b4f4706ce3 100644 --- a/svx/source/tbxctrls/tbcontrl.cxx +++ b/svx/source/tbxctrls/tbcontrl.cxx @@ -3180,38 +3180,12 @@ void SvxStyleToolBoxControl::FillStyleBox() std::vector<OUString> aStyles; + // add used styles + pStyle = xIter->Next(); + while ( pStyle ) { + aStyles.push_back(pStyle->GetName()); pStyle = xIter->Next(); - - if( pImpl->bSpecModeWriter || pImpl->bSpecModeCalc ) - { - while ( pStyle ) - { - // sort out default styles - bool bInsert = true; - OUString aName( pStyle->GetName() ); - for( auto const & _i: pImpl->aDefaultStyles ) - { - if( _i.first == aName || _i.second == aName ) - { - bInsert = false; - break; - } - } - - if( bInsert ) - aStyles.push_back(aName); - pStyle = xIter->Next(); - } - } - else - { - while ( pStyle ) - { - aStyles.push_back(pStyle->GetName()); - pStyle = xIter->Next(); - } - } } if (pImpl->bSpecModeWriter || pImpl->bSpecModeCalc) @@ -3219,11 +3193,16 @@ void SvxStyleToolBoxControl::FillStyleBox() pBox->append_text(pImpl->aClearForm); pBox->insert_separator(1, "separator"); - // insert default styles - for (const auto &rStyle : pImpl->aDefaultStyles) - pBox->append_text(rStyle.second); + // add default styles if less than 12 items + for( const auto &rStyle : pImpl->aDefaultStyles ) + { + 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); + } } - std::sort(aStyles.begin(), aStyles.end()); for (const auto& rStyle : aStyles) |