include/sfx2/charmapcontainer.hxx        |   31 +++--
 include/svx/cuicharmap.hxx               |    4 
 sfx2/source/control/charmapcontainer.cxx |  185 +++++++++----------------------
 svx/source/dialog/cuicharmap.cxx         |   27 ----
 4 files changed, 83 insertions(+), 164 deletions(-)

New commits:
commit 2e06e649c798ca38eb6cd56336c9db86e9ca98cf
Author:     Michael Weghorn <[email protected]>
AuthorDate: Wed Dec 10 15:12:30 2025 +0100
Commit:     Michael Weghorn <[email protected]>
CommitDate: Fri Dec 12 13:24:49 2025 +0100

    SfxCharmapContainer: Use container of struct instead of 2 separate ones
    
    SfxCharmapContainer remembers recently used and
    favorite characters. In this context, a character
    is defined by two strings, one for the character's text
    and one for the font used.
    
    So far, two std::deque<OUString> were used for each
    of the remembered lists (SfxCharmapContainer::m_aRecentCharList
    and SfxCharmapContainer::m_aRecentCharFontList for the
    recent charcters, SfxCharmapContainer::m_aFavCharList
    and SfxCharmapContainer::m_aFavCharFontList for the
    favorite characters).
    
    Accessing or modifying one semantic "character" entry
    would then also require accessing/modifying both
    containers and making sure they remain in sync.
    
    Extra helper functions were used to be able to
    search one semantic entry, etc.
    
    Simplify the whole handling by introducing a new
    struct, CharAndFont that holds both, the character's
    text and its font.
    This allows to use a single std::deque<CharAndFont>
    for each of the recent and favorite character lists
    and using standard algorithms to access them.
    
    The class is used e.g. by the "Insert" -> "Special Character..."
    dialog.
    
    Change-Id: I0a3e63a2e09302e16ca7a59d14ebca91b3582221
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195397
    Reviewed-by: Michael Weghorn <[email protected]>
    Tested-by: Jenkins

diff --git a/include/sfx2/charmapcontainer.hxx 
b/include/sfx2/charmapcontainer.hxx
index ac3a8cd752af..65a3787aa1dd 100644
--- a/include/sfx2/charmapcontainer.hxx
+++ b/include/sfx2/charmapcontainer.hxx
@@ -28,10 +28,22 @@
 
 class SFX2_DLLPUBLIC SfxCharmapContainer
 {
-    std::deque<OUString> m_aRecentCharList;
-    std::deque<OUString> m_aRecentCharFontList;
-    std::deque<OUString> m_aFavCharList;
-    std::deque<OUString> m_aFavCharFontList;
+    struct CharAndFont
+    {
+        OUString sChar;
+        OUString sFont;
+
+        CharAndFont(const OUString& rChar, const OUString& rFont)
+            : sChar(rChar)
+            , sFont(rFont)
+        {
+        }
+
+        bool operator==(const CharAndFont& rOther) const = default;
+    };
+
+    std::deque<CharAndFont> m_aRecentChars;
+    std::deque<CharAndFont> m_aFavChars;
 
     SvxCharView m_aRecentCharView[16];
     SvxCharView m_aFavCharView[16];
@@ -65,21 +77,14 @@ public:
 
     void updateRecentCharacterList(const OUString& sTitle, const OUString& 
rFont);
     void updateFavCharacterList(const OUString& sTitle, const OUString& rFont);
-    void deleteFavCharacterFromList(std::u16string_view sTitle, 
std::u16string_view rFont);
+    void deleteFavCharacterFromList(const OUString& rTitle, const OUString& 
rFont);
 
-    bool isFavChar(std::u16string_view sTitle, std::u16string_view rFont);
+    bool isFavChar(const OUString& rTitle, const OUString& rFont);
     bool hasRecentChars() const;
 
     bool FavCharListIsFull() const;
 
     void GrabFocusToFirstFavorite();
-
-private:
-    std::pair<std::deque<OUString>::const_iterator, 
std::deque<OUString>::const_iterator>
-    getRecentChar(std::u16string_view sTitle, std::u16string_view rFont) const;
-
-    std::pair<std::deque<OUString>::const_iterator, 
std::deque<OUString>::const_iterator>
-    getFavChar(std::u16string_view sTitle, std::u16string_view rFont) const;
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s 
cinkeys+=0=break: */
diff --git a/include/svx/cuicharmap.hxx b/include/svx/cuicharmap.hxx
index 3ef569442bf4..9f8ea01d3f7f 100644
--- a/include/svx/cuicharmap.hxx
+++ b/include/svx/cuicharmap.hxx
@@ -101,7 +101,7 @@ private:
 
     void insertCharToDoc(const OUString& sChar);
 
-    void setFavButtonState(std::u16string_view sTitle, std::u16string_view 
rFont);
+    void setFavButtonState(const OUString& sTitle, const OUString& rFont);
 
     void setCharName(sal_UCS4 nDecimalValue);
 
diff --git a/sfx2/source/control/charmapcontainer.cxx 
b/sfx2/source/control/charmapcontainer.cxx
index ea6a52b2484c..05e134b32522 100644
--- a/sfx2/source/control/charmapcontainer.cxx
+++ b/sfx2/source/control/charmapcontainer.cxx
@@ -133,35 +133,27 @@ void SfxCharmapContainer::init(bool bHasInsert, const 
Link<SvxCharView*,void> &r
 
 void SfxCharmapContainer::getFavCharacterList()
 {
-    m_aFavCharList.clear();
-    m_aFavCharFontList.clear();
+    m_aFavChars.clear();
 
     //retrieve recent character list
     const css::uno::Sequence< OUString > rFavCharList( 
officecfg::Office::Common::FavoriteCharacters::FavoriteCharacterList::get() );
-    m_aFavCharList.insert( m_aFavCharList.end(), rFavCharList.begin(), 
rFavCharList.end() );
 
     //retrieve recent character font list
     const css::uno::Sequence< OUString > rFavCharFontList( 
officecfg::Office::Common::FavoriteCharacters::FavoriteCharacterFontList::get() 
);
-    m_aFavCharFontList.insert( m_aFavCharFontList.end(), 
rFavCharFontList.begin(), rFavCharFontList.end() );
 
-    // tdf#135997: make sure that the two lists are same length
-    const auto nCommonLength = std::min(m_aFavCharList.size(), 
m_aFavCharFontList.size());
-    m_aFavCharList.resize(nCommonLength);
-    m_aFavCharFontList.resize(nCommonLength);
+    const auto nCommonLength = std::min(rFavCharList.size(), 
rFavCharFontList.size());
+    for (sal_uInt32 i = 0; i < nCommonLength; i++)
+        m_aFavChars.emplace_back(rFavCharList[i], rFavCharFontList[i]);
 }
 
 void SfxCharmapContainer::updateFavCharControl()
 {
-    assert(m_aFavCharList.size() == m_aFavCharFontList.size());
-
     int i = 0;
-    for ( std::deque< OUString >::iterator it = m_aFavCharList.begin(), it2 = 
m_aFavCharFontList.begin();
-        it != m_aFavCharList.end() && it2 != m_aFavCharFontList.end();
-        ++it, ++it2, i++)
+    for (auto it = m_aFavChars.begin(); it != m_aFavChars.end(); ++it, i++)
     {
-        m_aFavCharView[i].SetText(*it);
+        m_aFavCharView[i].SetText(it->sChar);
         vcl::Font rFont = m_aFavCharView[i].GetFont();
-        rFont.SetFamilyName( *it2 );
+        rFont.SetFamilyName(it->sFont);
         m_aFavCharView[i].SetFont(rFont);
         m_aFavCharView[i].Show();
     }
@@ -177,21 +169,17 @@ void SfxCharmapContainer::updateFavCharControl()
 
 void SfxCharmapContainer::getRecentCharacterList()
 {
-    m_aRecentCharList.clear();
-    m_aRecentCharFontList.clear();
+    m_aRecentChars.clear();
 
     //retrieve recent character list
     const css::uno::Sequence< OUString > rRecentCharList( 
officecfg::Office::Common::RecentCharacters::RecentCharacterList::get() );
-    m_aRecentCharList.insert( m_aRecentCharList.end(), 
rRecentCharList.begin(), rRecentCharList.end() );
 
     //retrieve recent character font list
     const css::uno::Sequence< OUString > rRecentCharFontList( 
officecfg::Office::Common::RecentCharacters::RecentCharacterFontList::get() );
-    m_aRecentCharFontList.insert( m_aRecentCharFontList.end(), 
rRecentCharFontList.begin(), rRecentCharFontList.end() );
 
-    // tdf#135997: make sure that the two lists are same length
-    const auto nCommonLength = std::min(m_aRecentCharList.size(), 
m_aRecentCharFontList.size());
-    m_aRecentCharList.resize(nCommonLength);
-    m_aRecentCharFontList.resize(nCommonLength);
+    const sal_uInt32 nCommonLength = std::min(rRecentCharList.size(), 
rRecentCharFontList.size());
+    for (sal_uInt32 i = 0; i < nCommonLength; i++)
+        m_aRecentChars.emplace_back(rRecentCharList[i], 
rRecentCharFontList[i]);
 }
 
 void SfxCharmapContainer::GrabFocusToFirstFavorite()
@@ -199,46 +187,14 @@ void SfxCharmapContainer::GrabFocusToFirstFavorite()
     m_aFavCharView[0].GrabFocus();
 }
 
-static std::pair<std::deque<OUString>::const_iterator, 
std::deque<OUString>::const_iterator>
-findInPair(std::u16string_view str1, const std::deque<OUString>& rContainer1,
-           std::u16string_view str2, const std::deque<OUString>& rContainer2)
-{
-    assert(rContainer1.size() == rContainer2.size());
-
-    for (auto it1 = std::find(rContainer1.begin(), rContainer1.end(), str1);
-         it1 != rContainer1.end(); it1 = std::find(std::next(it1), 
rContainer1.end(), str1))
-    {
-        auto it2 = rContainer2.begin() + (it1 - rContainer1.begin());
-        if (*it2 == str2)
-            return { it1, it2 };
-    }
-    return { rContainer1.end(), rContainer2.end() };
-}
-
-std::pair<std::deque<OUString>::const_iterator, 
std::deque<OUString>::const_iterator>
-SfxCharmapContainer::getRecentChar(std::u16string_view sTitle, 
std::u16string_view rFont) const
-{
-    return findInPair(sTitle, m_aRecentCharList, rFont, m_aRecentCharFontList);
-}
-
-std::pair<std::deque<OUString>::const_iterator, 
std::deque<OUString>::const_iterator>
-SfxCharmapContainer::getFavChar(std::u16string_view sTitle, 
std::u16string_view rFont) const
-{
-    return findInPair(sTitle, m_aFavCharList, rFont, m_aFavCharFontList);
-}
-
 void SfxCharmapContainer::updateRecentCharControl()
 {
-    assert(m_aRecentCharList.size() == m_aRecentCharFontList.size());
-
     int i = 0;
-    for ( std::deque< OUString >::iterator it = m_aRecentCharList.begin(), it2 
= m_aRecentCharFontList.begin();
-        it != m_aRecentCharList.end() && it2 != m_aRecentCharFontList.end();
-        ++it, ++it2, i++)
+    for (auto it = m_aRecentChars.begin(); it != m_aRecentChars.end(); ++it, 
i++)
     {
-        m_aRecentCharView[i].SetText(*it);
+        m_aRecentCharView[i].SetText(it->sChar);
         vcl::Font rFont = m_aRecentCharView[i].GetFont();
-        rFont.SetFamilyName( *it2 );
+        rFont.SetFamilyName(it->sFont);
         m_aRecentCharView[i].SetFont(rFont);
         m_aRecentCharView[i].Show();
     }
@@ -255,31 +211,24 @@ void SfxCharmapContainer::updateRecentCharControl()
 void SfxCharmapContainer::updateRecentCharacterList(const OUString& sTitle, 
const OUString& rFont)
 {
     // if recent char to be added is already in list, remove it
-    if( const auto [itChar, itChar2] = getRecentChar(sTitle, rFont);
-        itChar != m_aRecentCharList.end() &&  itChar2 != 
m_aRecentCharFontList.end() )
-    {
-        m_aRecentCharList.erase( itChar );
-        m_aRecentCharFontList.erase( itChar2);
-    }
+    auto itChar = std::ranges::find(m_aRecentChars, CharAndFont(sTitle, 
rFont));
+    if (itChar != m_aRecentChars.end())
+        m_aRecentChars.erase(itChar);
 
-    if (m_aRecentCharList.size() == 16)
-    {
-        m_aRecentCharList.pop_back();
-        m_aRecentCharFontList.pop_back();
-    }
+    if (m_aRecentChars.size() == 16)
+        m_aRecentChars.pop_back();
 
-    m_aRecentCharList.push_front(sTitle);
-    m_aRecentCharFontList.push_front(rFont);
+    m_aRecentChars.emplace_front(sTitle, rFont);
 
-    css::uno::Sequence< OUString > aRecentCharList(m_aRecentCharList.size());
+    css::uno::Sequence<OUString> aRecentCharList(m_aRecentChars.size());
     auto aRecentCharListRange = asNonConstRange(aRecentCharList);
-    css::uno::Sequence< OUString > 
aRecentCharFontList(m_aRecentCharFontList.size());
+    css::uno::Sequence<OUString> aRecentCharFontList(m_aRecentChars.size());
     auto aRecentCharFontListRange = asNonConstRange(aRecentCharFontList);
 
-    for (size_t i = 0; i < m_aRecentCharList.size(); ++i)
+    for (size_t i = 0; i < m_aRecentChars.size(); ++i)
     {
-        aRecentCharListRange[i] = m_aRecentCharList[i];
-        aRecentCharFontListRange[i] = m_aRecentCharFontList[i];
+        aRecentCharListRange[i] = m_aRecentChars[i].sChar;
+        aRecentCharFontListRange[i] = m_aRecentChars[i].sFont;
     }
 
     std::shared_ptr<comphelper::ConfigurationChanges> 
batch(comphelper::ConfigurationChanges::create());
@@ -293,31 +242,24 @@ void SfxCharmapContainer::updateRecentCharacterList(const 
OUString& sTitle, cons
 void SfxCharmapContainer::updateFavCharacterList(const OUString& sTitle, const 
OUString& rFont)
 {
     // if Fav char to be added is already in list, remove it
-    if( const auto [itChar, itChar2] = getFavChar(sTitle, rFont);
-        itChar != m_aFavCharList.end() &&  itChar2 != m_aFavCharFontList.end() 
)
-    {
-        m_aFavCharList.erase( itChar );
-        m_aFavCharFontList.erase( itChar2);
-    }
+    auto itChar = std::ranges::find(m_aFavChars, CharAndFont(sTitle, rFont));
+    if (itChar != m_aFavChars.end())
+        m_aFavChars.erase(itChar);
 
-    if (m_aFavCharList.size() == 16)
-    {
-        m_aFavCharList.pop_back();
-        m_aFavCharFontList.pop_back();
-    }
+    if (m_aFavChars.size() == 16)
+        m_aFavChars.pop_back();
 
-    m_aFavCharList.push_back(sTitle);
-    m_aFavCharFontList.push_back(rFont);
+    m_aFavChars.emplace_back(sTitle, rFont);
 
-    css::uno::Sequence< OUString > aFavCharList(m_aFavCharList.size());
+    css::uno::Sequence<OUString> aFavCharList(m_aFavChars.size());
     auto aFavCharListRange = asNonConstRange(aFavCharList);
-    css::uno::Sequence< OUString > aFavCharFontList(m_aFavCharFontList.size());
+    css::uno::Sequence<OUString> aFavCharFontList(m_aFavChars.size());
     auto aFavCharFontListRange = asNonConstRange(aFavCharFontList);
 
-    for (size_t i = 0; i < m_aFavCharList.size(); ++i)
+    for (size_t i = 0; i < m_aFavChars.size(); ++i)
     {
-        aFavCharListRange[i] = m_aFavCharList[i];
-        aFavCharFontListRange[i] = m_aFavCharFontList[i];
+        aFavCharListRange[i] = m_aFavChars[i].sChar;
+        aFavCharFontListRange[i] = m_aFavChars[i].sFont;
     }
 
     std::shared_ptr<comphelper::ConfigurationChanges> 
batch(comphelper::ConfigurationChanges::create());
@@ -326,25 +268,22 @@ void SfxCharmapContainer::updateFavCharacterList(const 
OUString& sTitle, const O
     batch->commit();
 }
 
-void SfxCharmapContainer::deleteFavCharacterFromList(std::u16string_view 
sTitle, std::u16string_view rFont)
+void SfxCharmapContainer::deleteFavCharacterFromList(const OUString& rTitle, 
const OUString& rFont)
 {
     // if Fav char is found, remove it
-    if( const auto [itChar, itChar2] = getFavChar(sTitle, rFont);
-        itChar != m_aFavCharList.end() &&  itChar2 != m_aFavCharFontList.end() 
)
-    {
-        m_aFavCharList.erase( itChar );
-        m_aFavCharFontList.erase( itChar2);
-    }
+    auto itChar = std::ranges::find(m_aFavChars, CharAndFont(rTitle, rFont));
+    if (itChar != m_aFavChars.end())
+        m_aFavChars.erase(itChar);
 
-    css::uno::Sequence< OUString > aFavCharList(m_aFavCharList.size());
+    css::uno::Sequence<OUString> aFavCharList(m_aFavChars.size());
     auto aFavCharListRange = asNonConstRange(aFavCharList);
-    css::uno::Sequence< OUString > aFavCharFontList(m_aFavCharFontList.size());
+    css::uno::Sequence<OUString> aFavCharFontList(m_aFavChars.size());
     auto aFavCharFontListRange = asNonConstRange(aFavCharFontList);
 
-    for (size_t i = 0; i < m_aFavCharList.size(); ++i)
+    for (size_t i = 0; i < m_aFavChars.size(); ++i)
     {
-        aFavCharListRange[i] = m_aFavCharList[i];
-        aFavCharFontListRange[i] = m_aFavCharFontList[i];
+        aFavCharListRange[i] = m_aFavChars[i].sChar;
+        aFavCharFontListRange[i] = m_aFavChars[i].sFont;
     }
 
     std::shared_ptr<comphelper::ConfigurationChanges> 
batch(comphelper::ConfigurationChanges::create());
@@ -353,10 +292,9 @@ void 
SfxCharmapContainer::deleteFavCharacterFromList(std::u16string_view sTitle,
     batch->commit();
 }
 
-bool SfxCharmapContainer::isFavChar(std::u16string_view sTitle, 
std::u16string_view rFont)
+bool SfxCharmapContainer::isFavChar(const OUString& rTitle, const OUString& 
rFont)
 {
-    const auto [itChar, itFont] = getFavChar(sTitle, rFont);
-    return itChar != m_aFavCharList.end() && itFont != 
m_aFavCharFontList.end();
+    return std::ranges::find(m_aFavChars, CharAndFont(rTitle, rFont)) != 
m_aFavChars.end();
 }
 
 IMPL_LINK(SfxCharmapContainer, RecentClearClickHdl, SvxCharView*, rView, void)
@@ -365,22 +303,19 @@ IMPL_LINK(SfxCharmapContainer, RecentClearClickHdl, 
SvxCharView*, rView, void)
     OUString sFont = rView->GetFont().GetFamilyName();
 
     // if recent char to be added is already in list, remove it
-    if( const auto [itChar, itChar2] = getRecentChar(sTitle, sFont);
-        itChar != m_aRecentCharList.end() &&  itChar2 != 
m_aRecentCharFontList.end() )
-    {
-        m_aRecentCharList.erase( itChar );
-        m_aRecentCharFontList.erase( itChar2);
-    }
+    auto itChar = std::ranges::find(m_aRecentChars, CharAndFont(sTitle, 
sFont));
+    if (itChar != m_aRecentChars.end())
+        m_aRecentChars.erase(itChar);
 
-    css::uno::Sequence< OUString > aRecentCharList(m_aRecentCharList.size());
+    css::uno::Sequence<OUString> aRecentCharList(m_aRecentChars.size());
     auto aRecentCharListRange = asNonConstRange(aRecentCharList);
-    css::uno::Sequence< OUString > 
aRecentCharFontList(m_aRecentCharFontList.size());
+    css::uno::Sequence<OUString> aRecentCharFontList(m_aRecentChars.size());
     auto aRecentCharFontListRange = asNonConstRange(aRecentCharFontList);
 
-    for (size_t i = 0; i < m_aRecentCharList.size(); ++i)
+    for (size_t i = 0; i < m_aRecentChars.size(); ++i)
     {
-        aRecentCharListRange[i] = m_aRecentCharList[i];
-        aRecentCharFontListRange[i] = m_aRecentCharFontList[i];
+        aRecentCharListRange[i] = m_aRecentChars[i].sChar;
+        aRecentCharFontListRange[i] = m_aRecentChars[i].sFont;
     }
 
     std::shared_ptr<comphelper::ConfigurationChanges> 
batch(comphelper::ConfigurationChanges::create());
@@ -393,8 +328,7 @@ IMPL_LINK(SfxCharmapContainer, RecentClearClickHdl, 
SvxCharView*, rView, void)
 
 IMPL_LINK_NOARG(SfxCharmapContainer, RecentClearAllClickHdl, SvxCharView*, 
void)
 {
-    m_aRecentCharList.clear();
-    m_aRecentCharFontList.clear();
+    m_aRecentChars.clear();
 
     std::shared_ptr<comphelper::ConfigurationChanges> 
batch(comphelper::ConfigurationChanges::create());
     officecfg::Office::Common::RecentCharacters::RecentCharacterList::set({ }, 
batch);
@@ -412,8 +346,7 @@ IMPL_LINK(SfxCharmapContainer, FavClearClickHdl, 
SvxCharView*, rView, void)
 
 IMPL_LINK_NOARG(SfxCharmapContainer, FavClearAllClickHdl, SvxCharView*, void)
 {
-    m_aFavCharList.clear();
-    m_aFavCharFontList.clear();
+    m_aFavChars.clear();
 
     std::shared_ptr<comphelper::ConfigurationChanges> 
batch(comphelper::ConfigurationChanges::create());
     
officecfg::Office::Common::FavoriteCharacters::FavoriteCharacterList::set({ }, 
batch);
@@ -425,12 +358,12 @@ IMPL_LINK_NOARG(SfxCharmapContainer, FavClearAllClickHdl, 
SvxCharView*, void)
 
 bool SfxCharmapContainer::FavCharListIsFull() const
 {
-    return m_aFavCharList.size() == 16;
+    return m_aFavChars.size() == 16;
 }
 
 bool SfxCharmapContainer::hasRecentChars() const
 {
-    return !m_aRecentCharList.empty();
+    return !m_aRecentChars.empty();
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s 
cinkeys+=0=break: */
diff --git a/svx/source/dialog/cuicharmap.cxx b/svx/source/dialog/cuicharmap.cxx
index c13494a72bb7..faa7e0fdfb54 100644
--- a/svx/source/dialog/cuicharmap.cxx
+++ b/svx/source/dialog/cuicharmap.cxx
@@ -121,7 +121,7 @@ void SvxCharacterMap::prepForRun()
     if( SvxShowCharSet::getSelectedChar() == ' ')
     {
         m_xOKBtn->set_sensitive(false);
-        setFavButtonState(u"", u"");
+        setFavButtonState(u""_ustr, u""_ustr);
     }
     else
     {
@@ -274,9 +274,9 @@ void SvxCharacterMap::init()
     m_xSearchText->connect_changed(LINK(this, SvxCharacterMap, 
SearchUpdateHdl));
 }
 
-void SvxCharacterMap::setFavButtonState(std::u16string_view sTitle, 
std::u16string_view rFont)
+void SvxCharacterMap::setFavButtonState(const OUString& sTitle, const 
OUString& rFont)
 {
-    if(sTitle.empty() || rFont.empty())
+    if (sTitle.isEmpty() || rFont.isEmpty())
     {
         m_xFavouritesBtn->set_sensitive(false);
         return;
commit c4a4035b19c92b4e0d876076c604bba8b794081d
Author:     Michael Weghorn <[email protected]>
AuthorDate: Wed Dec 10 12:55:31 2025 +0100
Commit:     Michael Weghorn <[email protected]>
CommitDate: Fri Dec 12 13:24:39 2025 +0100

    svx: Drop SvxShowText::mbCenter
    
    It's initialized to false in the ctor, but
    SvxCharacterMap, the only user of SvxShowText,
    calls SvxShowText::SetCentered(true) for its
    SvxShowText right in the ctor, so the value
    of that member is effectively always true.
    
    Therefore, drop it and the unused code paths.
    
    Change-Id: I56a37c95f73d5dcd7ad076fd6b4774965ce500df
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195396
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <[email protected]>

diff --git a/include/svx/cuicharmap.hxx b/include/svx/cuicharmap.hxx
index d7b38996599a..3ef569442bf4 100644
--- a/include/svx/cuicharmap.hxx
+++ b/include/svx/cuicharmap.hxx
@@ -41,7 +41,6 @@ private:
     ScopedVclPtr<VirtualDevice> m_xVirDev;
     OUString m_sText;
     tools::Long mnY;
-    bool mbCenter;
     vcl::Font m_aFont;
 
     virtual void Paint(vcl::RenderContext& rRenderContext, const 
tools::Rectangle&) override;
@@ -55,7 +54,6 @@ public:
     vcl::Font const& GetFont() const { return m_aFont; }
     void SetText(const OUString& rText);
     OUString const& GetText() const { return m_sText; }
-    void SetCentered(bool bCenter) { mbCenter = bCenter; }
 
     Size get_preferred_size() const { return 
GetDrawingArea()->get_preferred_size(); }
 };
diff --git a/svx/source/dialog/cuicharmap.cxx b/svx/source/dialog/cuicharmap.cxx
index a21d0f7f0659..c13494a72bb7 100644
--- a/svx/source/dialog/cuicharmap.cxx
+++ b/svx/source/dialog/cuicharmap.cxx
@@ -77,7 +77,6 @@ SvxCharacterMap::SvxCharacterMap(weld::Widget* pParent, const 
SfxItemSet* pSet,
     , m_xSearchSet(new 
SvxSearchCharSet(m_xBuilder->weld_scrolled_window(u"searchscroll"_ustr, true), 
m_xVirDev))
     , m_xSearchSetArea(new weld::CustomWeld(*m_xBuilder, 
u"searchcharset"_ustr, *m_xSearchSet))
 {
-    m_aShowChar.SetCentered(true);
     m_xFontLB->make_sorted();
     //lock the size request of this widget to the width of all possible entries
     fillAllSubsets(*m_xSubsetLB);
@@ -759,7 +758,6 @@ IMPL_LINK(SvxCharacterMap, CharPreSelectHdl, 
SvxShowCharSet*, pCharSet, void)
 SvxShowText::SvxShowText(const VclPtr<VirtualDevice>& rVirDev)
     : m_xVirDev(rVirDev)
     , mnY(0)
-    , mbCenter(false)
 {
 }
 
@@ -809,8 +807,7 @@ void SvxShowText::Paint(vcl::RenderContext& rRenderContext, 
const tools::Rectang
             bGotBoundary = false;
             break;
         }
-        if (!mbCenter)
-            break;
+
         //only shrink in the single glyph large view mode
         tools::Long nTextWidth = aBoundRect.GetWidth();
         if (nAvailWidth > nTextWidth)
@@ -840,21 +837,7 @@ void SvxShowText::Paint(vcl::RenderContext& 
rRenderContext, const tools::Rectang
         else if( nYHDelta <= 0 )
             aPoint.AdjustY(nYHDelta - 1 );
 
-        if (mbCenter)
-        {
-            // move glyph to middle of cell
-            aPoint.setX( -aBoundRect.Left() + (aSize.Width() - 
aBoundRect.GetWidth()) / 2 );
-        }
-        else
-        {
-            // shift back horizontally if needed
-            int nXLDelta = aBoundRect.Left();
-            int nXHDelta = aSize.Width() - aBoundRect.Right();
-            if( nXLDelta <= 0 )
-                aPoint.AdjustX( -(nXLDelta - 1) );
-            else if( nXHDelta <= 0 )
-                aPoint.AdjustX(nXHDelta - 1 );
-        }
+        aPoint.setX(-aBoundRect.Left() + (aSize.Width() - 
aBoundRect.GetWidth()) / 2);
     }
 
     rRenderContext.SetLineColor(aShadowColor);

Reply via email to