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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Fri Sep 28 07:46:27 UTC 2018


 vcl/source/window/dlgctrl.cxx |   49 ++++++++++++++++++++++--------------------
 1 file changed, 26 insertions(+), 23 deletions(-)

New commits:
commit 36fca319d8c49147f0362a61956138e9c5292ed3
Author:     Jan-Marek Glogowski <glogow at fbihome.de>
AuthorDate: Thu Aug 30 16:19:30 2018 +0200
Commit:     Jan-Marek Glogowski <glogow at fbihome.de>
CommitDate: Fri Sep 28 09:46:00 2018 +0200

    Move TabPage lookup into extra function
    
    This way it's easier to read the follow up patch.
    
    Change-Id: I42e8f78b69b4ed2cb28bf0f36496eb751e8cb433
    Reviewed-on: https://gerrit.libreoffice.org/61036
    Tested-by: Jenkins
    Reviewed-by: Jan-Marek Glogowski <glogow at fbihome.de>

diff --git a/vcl/source/window/dlgctrl.cxx b/vcl/source/window/dlgctrl.cxx
index 76adefb1d2a1..4479291b6f24 100644
--- a/vcl/source/window/dlgctrl.cxx
+++ b/vcl/source/window/dlgctrl.cxx
@@ -68,6 +68,30 @@ static vcl::Window* ImplGetTopParentOfTabHierarchy( vcl::Window* pParent )
     return pResult;
 }
 
+static vcl::Window* ImplGetCurTabWindow(const vcl::Window* pWindow)
+{
+    assert(pWindow->GetType() == WindowType::TABCONTROL);
+    const TabControl* pTabControl = static_cast<const TabControl*>(pWindow);
+    // Check if the TabPage is a Child of the TabControl and still exists (by
+    // walking all child windows); because it could be that the TabPage has been
+    // destroyed already by a Dialog-Dtor, event that the TabControl still exists.
+    const TabPage* pTempTabPage = pTabControl->GetTabPage(pTabControl->GetCurPageId());
+    if (pTempTabPage)
+    {
+        vcl::Window* pTempWindow = pTabControl->GetWindow(GetWindowType::FirstChild);
+        while (pTempWindow)
+        {
+            if (pTempWindow->ImplGetWindow() == pTempTabPage)
+            {
+                return const_cast<TabPage*>(pTempTabPage);
+            }
+            pTempWindow = nextLogicalChildOfParent(pTabControl, pTempWindow);
+        }
+    }
+
+    return nullptr;
+}
+
 static vcl::Window* ImplGetSubChildWindow( vcl::Window* pParent, sal_uInt16 n, sal_uInt16& nIndex )
 {
     vcl::Window*     pTabPage = nullptr;
@@ -91,31 +115,10 @@ static vcl::Window* ImplGetSubChildWindow( vcl::Window* pParent, sal_uInt16 n, s
             else
             {
                 pFoundWindow = pWindow;
-
                 // for a TabControl, remember the current TabPage for later use
                 if ( pWindow->GetType() == WindowType::TABCONTROL )
-                {
-                    TabControl* pTabControl = static_cast<TabControl*>(pWindow);
-                    // Check if the TabPage is a Child of the TabControl and still exists (by
-                    // walking all child windows); because it could be that the TabPage has been
-                    // destroyed already by a Dialog-Dtor, event that the TabControl still exists.
-                    TabPage* pTempTabPage = pTabControl->GetTabPage( pTabControl->GetCurPageId() );
-                    if ( pTempTabPage )
-                    {
-                        vcl::Window* pTempWindow = pTabControl->GetWindow( GetWindowType::FirstChild );
-                        while ( pTempWindow )
-                        {
-                            if ( pTempWindow->ImplGetWindow() == pTempTabPage )
-                            {
-                                pTabPage = pTempTabPage;
-                                break;
-                            }
-                            pTempWindow = nextLogicalChildOfParent(pTabControl, pTempWindow);
-                        }
-                    }
-                }
-                else if ( ( pWindow->GetStyle() & WB_DIALOGCONTROL )
-                       || ( pWindow->GetStyle() & WB_CHILDDLGCTRL ) )
+                    pTabPage = ImplGetCurTabWindow(pWindow);
+                else if (pWindow->GetStyle() & (WB_DIALOGCONTROL | WB_CHILDDLGCTRL))
                     pFoundWindow = ImplGetSubChildWindow( pWindow, n, nIndex );
             }
 


More information about the Libreoffice-commits mailing list