sw/source/core/crsr/viscrs.cxx |   22 +++++++---------------
 1 file changed, 7 insertions(+), 15 deletions(-)

New commits:
commit 926372b8de7f283c5fd890c23b6d0755ff6bed87
Author:     Justin Luth <jl...@mail.com>
AuthorDate: Wed Jul 24 10:07:09 2024 -0400
Commit:     Justin Luth <jl...@mail.com>
CommitDate: Wed Jul 24 20:01:18 2024 +0200

    tdf#157952 sw content controls, drop-down: remove when obsolete
    
    One place that was missed was when moving from one content control
    to another (for example, using the tab key).
    
    Change-Id: I62a3af2a5a7036aaac605d592c244a58f5b65a12
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170967
    Reviewed-by: Justin Luth <jl...@mail.com>
    Tested-by: Jenkins

diff --git a/sw/source/core/crsr/viscrs.cxx b/sw/source/core/crsr/viscrs.cxx
index 5a67e7192d0d..64b9d3be49e1 100644
--- a/sw/source/core/crsr/viscrs.cxx
+++ b/sw/source/core/crsr/viscrs.cxx
@@ -696,6 +696,13 @@ void SwSelPaintRects::HighlightContentControl()
         }
     }
 
+    // clear an obsolete dropdown if the cursor has moved away from the 
content control
+    if (m_pContentControlButton
+        && (!pContentControl || m_pContentControlButton->GetContentControl() 
!= pContentControl))
+    {
+        m_pContentControlButton.disposeAndClear();
+    }
+
     auto pWrtShell = dynamic_cast<const SwWrtShell*>(GetShell());
     if (!aContentControlRanges.empty())
     {
@@ -756,11 +763,6 @@ void SwSelPaintRects::HighlightContentControl()
             if (pWrtShell)
             {
                 auto& rEditWin = 
const_cast<SwEditWin&>(pWrtShell->GetView().GetEditWin());
-                if (m_pContentControlButton
-                    && m_pContentControlButton->GetContentControl() != 
pContentControl)
-                {
-                    m_pContentControlButton.disposeAndClear();
-                }
                 if (!m_pContentControlButton)
                 {
                     m_pContentControlButton = 
VclPtr<SwDropDownContentControlButton>::Create(
@@ -783,11 +785,6 @@ void SwSelPaintRects::HighlightContentControl()
             if (pWrtShell)
             {
                 auto& rEditWin = 
const_cast<SwEditWin&>(pWrtShell->GetView().GetEditWin());
-                if (m_pContentControlButton
-                    && m_pContentControlButton->GetContentControl() != 
pContentControl)
-                {
-                    m_pContentControlButton.disposeAndClear();
-                }
                 if (!m_pContentControlButton)
                 {
                     m_pContentControlButton = 
VclPtr<SwDateContentControlButton>::Create(
@@ -824,11 +821,6 @@ void SwSelPaintRects::HighlightContentControl()
         }
         m_pContentControlOverlay.reset();
 
-        if (m_pContentControlButton)
-        {
-            m_pContentControlButton.disposeAndClear();
-        }
-
         if (pWrtShell)
         {
             auto& rEditWin = 
const_cast<SwEditWin&>(pWrtShell->GetView().GetEditWin());

Reply via email to