diff options
author | Jan-Marek Glogowski <glogow@fbihome.de> | 2018-08-30 16:19:30 +0200 |
---|---|---|
committer | Jan-Marek Glogowski <glogow@fbihome.de> | 2018-09-28 09:46:00 +0200 |
commit | 36fca319d8c49147f0362a61956138e9c5292ed3 (patch) | |
tree | f8c89ea3eb03dd7ce187de126765186dbd08236f | |
parent | 30e9f06dcfb578c894d2e5c003403bfbda57ae13 (diff) |
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@fbihome.de>
-rw-r--r-- | vcl/source/window/dlgctrl.cxx | 49 |
1 files changed, 26 insertions, 23 deletions
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 ); } |