sw/source/ui/index/cnttab.cxx |   27 +++++++++++++--------------
 1 file changed, 13 insertions(+), 14 deletions(-)

New commits:
commit 02503363d6fcb15a003e1f8f7781c64e90d6e82e
Author:     Michael Weghorn <[email protected]>
AuthorDate: Mon Feb 23 12:39:49 2026 +0100
Commit:     Michael Weghorn <[email protected]>
CommitDate: Mon Feb 23 16:25:00 2026 +0100

    sw: Reduce variable scope in SwTokenWindow::InsertAtSelection
    
    pControl is newly assigned at the beginning of each
    of these for loops, so these can be separate
    variables with reduced scope.
    
    Change-Id: Id258205e96e8dfa9854c44e2e8a2e2bd6c89350d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200049
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <[email protected]>

diff --git a/sw/source/ui/index/cnttab.cxx b/sw/source/ui/index/cnttab.cxx
index bec1f2cfea08..c17253bf676b 100644
--- a/sw/source/ui/index/cnttab.cxx
+++ b/sw/source/ui/index/cnttab.cxx
@@ -3011,13 +3011,12 @@ void SwTokenWindow::InsertAtSelection(const 
SwFormToken& rToken)
         bool bPreStartLinkFound = false;
         bool bPreEndLinkFound = false;
 
-        SwTOXWidget* pControl = nullptr;
         SwTOXButton* pExchange = nullptr;
 
         auto it = m_aControlList.cbegin();
         for( ; it != m_aControlList.cend() && m_pActiveCtrl != it->get(); ++it 
)
         {
-            pControl = it->get();
+            SwTOXWidget* pControl = it->get();
 
             if( WindowType::EDIT != pControl->GetType())
             {
@@ -3048,7 +3047,7 @@ void SwTokenWindow::InsertAtSelection(const SwFormToken& 
rToken)
         {
             for( ; it != m_aControlList.cend(); ++it )
             {
-                pControl = it->get();
+                SwTOXWidget* pControl = it->get();
 
                 if( pControl != m_pActiveCtrl &&
                     WindowType::EDIT != pControl->GetType())
commit 5806de57a8e8aba6924fc72bb6140fc333c4effd
Author:     Michael Weghorn <[email protected]>
AuthorDate: Mon Feb 23 12:29:21 2026 +0100
Commit:     Michael Weghorn <[email protected]>
CommitDate: Mon Feb 23 16:24:53 2026 +0100

    sw: Reduce casting in SwTokenWindow::InsertAtSelection
    
    Switch local var pExchange from SwTOXWidget* to SwTOXButton*
    and remember the result of the earlier cast (before
    assigning to pExchange) instead of casting over and
    over again.
    
    Change-Id: I987df94a4e72b97cb34476477b03e634f1223be9
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200048
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <[email protected]>

diff --git a/sw/source/ui/index/cnttab.cxx b/sw/source/ui/index/cnttab.cxx
index 4b0bb3a842d3..bec1f2cfea08 100644
--- a/sw/source/ui/index/cnttab.cxx
+++ b/sw/source/ui/index/cnttab.cxx
@@ -3012,7 +3012,7 @@ void SwTokenWindow::InsertAtSelection(const SwFormToken& 
rToken)
         bool bPreEndLinkFound = false;
 
         SwTOXWidget* pControl = nullptr;
-        SwTOXWidget* pExchange = nullptr;
+        SwTOXButton* pExchange = nullptr;
 
         auto it = m_aControlList.cbegin();
         for( ; it != m_aControlList.cend() && m_pActiveCtrl != it->get(); ++it 
)
@@ -3021,8 +3021,8 @@ void SwTokenWindow::InsertAtSelection(const SwFormToken& 
rToken)
 
             if( WindowType::EDIT != pControl->GetType())
             {
-                const SwFormToken& rNewToken =
-                                static_cast<const 
SwTOXButton*>(pControl)->GetFormToken();
+                SwTOXButton* pButton = static_cast<SwTOXButton*>(pControl);
+                const SwFormToken& rNewToken = pButton->GetFormToken();
 
                 if( TOKEN_LINK_START == rNewToken.eTokenType )
                 {
@@ -3036,7 +3036,7 @@ void SwTokenWindow::InsertAtSelection(const SwFormToken& 
rToken)
                     else
                     {
                         bPreEndLinkFound = false;
-                        pExchange = pControl;
+                        pExchange = pButton;
                     }
                 }
             }
@@ -3053,15 +3053,15 @@ void SwTokenWindow::InsertAtSelection(const 
SwFormToken& rToken)
                 if( pControl != m_pActiveCtrl &&
                     WindowType::EDIT != pControl->GetType())
                 {
-                    const SwFormToken& rNewToken =
-                                    static_cast<const 
SwTOXButton*>(pControl)->GetFormToken();
+                    SwTOXButton* pButton = static_cast<SwTOXButton*>(pControl);
+                    const SwFormToken& rNewToken = pButton->GetFormToken();
 
                     if( TOKEN_LINK_START == rNewToken.eTokenType )
                     {
                         if(bPostLinkStartFound)
                             break;
                         bPostLinkStartFound = true;
-                        pExchange = pControl;
+                        pExchange = pButton;
                     }
                     else if(TOKEN_LINK_END == rNewToken.eTokenType )
                     {
@@ -3087,8 +3087,8 @@ void SwTokenWindow::InsertAtSelection(const SwFormToken& 
rToken)
             OSL_ENSURE(pExchange, "no control to exchange?");
             if(pExchange)
             {
-                static_cast<SwTOXButton*>(pExchange)->SetLinkEnd();
-                
static_cast<SwTOXButton*>(pExchange)->SetText(m_aButtonTexts[TOKEN_LINK_END]);
+                pExchange->SetLinkEnd();
+                pExchange->SetText(m_aButtonTexts[TOKEN_LINK_END]);
             }
         }
 
@@ -3098,8 +3098,8 @@ void SwTokenWindow::InsertAtSelection(const SwFormToken& 
rToken)
 
             if(pExchange)
             {
-                static_cast<SwTOXButton*>(pExchange)->SetLinkStart();
-                
static_cast<SwTOXButton*>(pExchange)->SetText(m_aButtonTexts[TOKEN_LINK_START]);
+                pExchange->SetLinkStart();
+                pExchange->SetText(m_aButtonTexts[TOKEN_LINK_START]);
             }
         }
     }

Reply via email to