[Libreoffice-commits] core.git: Branch 'libreoffice-7-0' - svx/source

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Wed Jan 27 17:08:11 UTC 2021


 svx/source/tbxctrls/tbcontrl.cxx |   10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

New commits:
commit 0211b72c3d8bc7cf51b54dc4e4a0cf346153da46
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Tue Jan 26 20:44:50 2021 +0000
Commit:     Adolfo Jayme Barrientos <fitojb at ubuntu.com>
CommitDate: Wed Jan 27 18:07:36 2021 +0100

    tdf#138590 use the highlighted menu entry, not the combobox active text
    
    Change-Id: I2fb68c1491d129d5fd9b963ae4db1fb83171a154
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109982
    Tested-by: Jenkins
    Reviewed-by: Adolfo Jayme Barrientos <fitojb at ubuntu.com>

diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx
index 8780b03f2d6e..bef09011d9fa 100644
--- a/svx/source/tbxctrls/tbcontrl.cxx
+++ b/svx/source/tbxctrls/tbcontrl.cxx
@@ -213,6 +213,7 @@ protected:
 
     SfxStyleFamily                  eStyleFamily;
     int                             m_nMaxUserDrawFontWidth;
+    int                             m_nLastItemWithMenu;
     bool                            bRelease;
     Reference< XDispatchProvider >  m_xDispatchProvider;
     Reference< XFrame >             m_xFrame;
@@ -865,6 +866,7 @@ SvxStyleBox_Base::SvxStyleBox_Base(std::unique_ptr<weld::ComboBox> xWidget,
     , m_xWidget(std::move(xWidget))
     , eStyleFamily( eFamily )
     , m_nMaxUserDrawFontWidth(0)
+    , m_nLastItemWithMenu(-1)
     , bRelease( true )
     , m_xDispatchProvider( rDispatchProvider )
     , m_xFrame(_xFrame)
@@ -924,7 +926,10 @@ void SvxStyleBox_Base::ReleaseFocus()
 
 IMPL_LINK(SvxStyleBox_Base, MenuSelectHdl, const OString&, rMenuIdent, void)
 {
-    OUString sEntry = m_xWidget->get_active_text();
+    if (m_nLastItemWithMenu < 0 || m_nLastItemWithMenu >= m_xWidget->get_count())
+        return;
+
+    OUString sEntry = m_xWidget->get_text(m_nLastItemWithMenu);
 
     ReleaseFocus(); // It must be after getting entry pos!
     Sequence<PropertyValue> aArgs(2);
@@ -1160,7 +1165,10 @@ void SvxStyleBox_Base::SetupEntry(vcl::RenderContext& rRenderContext, sal_Int32
         if (nItem == 0 || nItem == m_xWidget->get_count() - 1)
             m_xWidget->set_item_menu(OString::number(nItem), nullptr);
         else
+        {
+            m_nLastItemWithMenu = nItem;
             m_xWidget->set_item_menu(OString::number(nItem), m_xMenu.get());
+        }
     }
 
     if (nItem > 0 && nItem < m_xWidget->get_count() - 1)


More information about the Libreoffice-commits mailing list