[Libreoffice-commits] core.git: cui/source

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Tue Sep 3 13:05:20 UTC 2019


 cui/source/inc/numpages.hxx      |    6 ++++--
 cui/source/tabpages/numpages.cxx |   28 +++++++++++++++++++++++-----
 2 files changed, 27 insertions(+), 7 deletions(-)

New commits:
commit 6c8128532e5631702ed426ed664807d6e760e195
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Tue Sep 3 10:14:45 2019 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Tue Sep 3 15:04:29 2019 +0200

    Resolves: tdf#127120 double selection in B&N dialog
    
    because the list wants to ensure that at least one thing is selected and the
    multiselect is implemented with two events of deselect-all followed by select.
    
    post a user event on getting either deselect or select and process it
    once when the dust has settled
    
    Change-Id: I553bf23d7a8c4625a8706fb2df4b169d91b7ad32
    Reviewed-on: https://gerrit.libreoffice.org/78541
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/cui/source/inc/numpages.hxx b/cui/source/inc/numpages.hxx
index 54614209a779..391094109005 100644
--- a/cui/source/inc/numpages.hxx
+++ b/cui/source/inc/numpages.hxx
@@ -330,8 +330,9 @@ class SvxNumPositionTabPage : public SfxTabPage
     std::unique_ptr<SvxNumRule> pActNum;
     std::unique_ptr<SvxNumRule> pSaveNum;
 
-    sal_uInt16              nActNumLvl;
-    sal_uInt16              nNumItemId;
+    ImplSVEvent*        m_pLevelHdlEvent;
+    sal_uInt16          nActNumLvl;
+    sal_uInt16          nNumItemId;
     MapUnit             eCoreUnit;
 
     bool                bModified           : 1;
@@ -370,6 +371,7 @@ class SvxNumPositionTabPage : public SfxTabPage
     void                InitControls();
 
     DECL_LINK(LevelHdl_Impl, weld::TreeView&, void);
+    DECL_LINK(LevelHdl, void *, void);
     DECL_LINK(EditModifyHdl_Impl, weld::ComboBox&, void);
     DECL_LINK(DistanceHdl_Impl, weld::MetricSpinButton&, void);
     DECL_LINK(DistanceFocusHdl_Impl, Control&, void);
diff --git a/cui/source/tabpages/numpages.cxx b/cui/source/tabpages/numpages.cxx
index d1a86909034b..902dd01fbea6 100644
--- a/cui/source/tabpages/numpages.cxx
+++ b/cui/source/tabpages/numpages.cxx
@@ -2485,6 +2485,7 @@ void SvxNumberingPreview::Paint(vcl::RenderContext& rRenderContext, const ::tool
 //merged
 SvxNumPositionTabPage::SvxNumPositionTabPage(TabPageParent pParent, const SfxItemSet& rSet)
     : SfxTabPage(pParent, "cui/ui/numberingpositionpage.ui", "NumberingPositionPage", &rSet)
+    , m_pLevelHdlEvent(nullptr)
     , nActNumLvl(1)
     , nNumItemId(SID_ATTR_NUMBERING_RULE)
     , bModified(false)
@@ -2556,6 +2557,11 @@ SvxNumPositionTabPage::~SvxNumPositionTabPage()
 
 void SvxNumPositionTabPage::dispose()
 {
+    if (m_pLevelHdlEvent)
+    {
+        Application::RemoveUserEvent(m_pLevelHdlEvent);
+        m_pLevelHdlEvent = nullptr;
+    }
     m_xPreviewWIN.reset();
     SfxTabPage::dispose();
 }
@@ -2996,17 +3002,29 @@ IMPL_LINK_NOARG(SvxNumPositionTabPage, EditModifyHdl_Impl, weld::ComboBox&, void
     SetModified();
 }
 
-IMPL_LINK(SvxNumPositionTabPage, LevelHdl_Impl, weld::TreeView&, rBox, void)
+IMPL_LINK_NOARG(SvxNumPositionTabPage, LevelHdl_Impl, weld::TreeView&, void)
+{
+    if (m_pLevelHdlEvent)
+        return;
+    // tdf#127120 multiselection may be implemented by deselect follow by select so
+    // fire off the handler to happen on next event loop and only process the
+    // final state
+    m_pLevelHdlEvent = Application::PostUserEvent(LINK(this, SvxNumPositionTabPage, LevelHdl));
+}
+
+IMPL_LINK_NOARG(SvxNumPositionTabPage, LevelHdl, void*, void)
 {
+    m_pLevelHdlEvent = nullptr;
+
     sal_uInt16 nSaveNumLvl = nActNumLvl;
     nActNumLvl = 0;
-    std::vector<int> aSelectedRows = rBox.get_selected_rows();
+    std::vector<int> aSelectedRows = m_xLevelLB->get_selected_rows();
     if (std::find(aSelectedRows.begin(), aSelectedRows.end(), pActNum->GetLevelCount()) != aSelectedRows.end() &&
             (aSelectedRows.size() == 1 || nSaveNumLvl != 0xffff))
     {
         nActNumLvl = 0xFFFF;
         for( sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++ )
-            rBox.unselect(i);
+            m_xLevelLB->unselect(i);
     }
     else if (!aSelectedRows.empty())
     {
@@ -3017,7 +3035,7 @@ IMPL_LINK(SvxNumPositionTabPage, LevelHdl_Impl, weld::TreeView&, rBox, void)
                 nActNumLvl |= nMask;
             nMask <<= 1;
         }
-        rBox.unselect(pActNum->GetLevelCount());
+        m_xLevelLB->unselect(pActNum->GetLevelCount());
     }
     else
     {
@@ -3027,7 +3045,7 @@ IMPL_LINK(SvxNumPositionTabPage, LevelHdl_Impl, weld::TreeView&, rBox, void)
         {
             if(nActNumLvl & nMask)
             {
-                rBox.select(i);
+                m_xLevelLB->select(i);
                 break;
             }
             nMask <<=1;


More information about the Libreoffice-commits mailing list