summaryrefslogtreecommitdiff
path: root/vcl/source/window/dlgctrl.cxx
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2018-09-26 14:09:59 +0200
committerJan-Marek Glogowski <glogow@fbihome.de>2018-09-29 02:33:23 +0200
commit9ff4232c365c19c9402fce80e26ccbf739d0b82e (patch)
tree16167b2b3091b28d4b678685039e80d27dd07bbd /vcl/source/window/dlgctrl.cxx
parent278b1de21f8395ab2a6c49377cf4aec4c16f05c6 (diff)
Handle initial TabControl and border window
ImplGetSubChildWindow has special code to handle a TabControl and its pages. If the function finds a TabControl as a child it'll return its window and then recurse into the current page. This currently breaks in the case where the initial parent is a TabControl. where the function will walk all of the tab pages. The function also ignores border windows, but not if the initial parent is a border window. This patch correctly handles both cases and as a bonus drops all the special page handling during child iteration. Change-Id: Ie8699dae8d08628b66b33e0704237b9e219874bc Reviewed-on: https://gerrit.libreoffice.org/61037 Tested-by: Jenkins Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
Diffstat (limited to 'vcl/source/window/dlgctrl.cxx')
-rw-r--r--vcl/source/window/dlgctrl.cxx56
1 files changed, 29 insertions, 27 deletions
diff --git a/vcl/source/window/dlgctrl.cxx b/vcl/source/window/dlgctrl.cxx
index 4479291b6f24..36dcf861c566 100644
--- a/vcl/source/window/dlgctrl.cxx
+++ b/vcl/source/window/dlgctrl.cxx
@@ -94,49 +94,51 @@ static vcl::Window* ImplGetCurTabWindow(const vcl::Window* pWindow)
static vcl::Window* ImplGetSubChildWindow( vcl::Window* pParent, sal_uInt16 n, sal_uInt16& nIndex )
{
- vcl::Window* pTabPage = nullptr;
- vcl::Window* pFoundWindow = nullptr;
+ // ignore border window
+ pParent = pParent->ImplGetWindow();
+ assert(pParent == pParent->ImplGetWindow());
- vcl::Window* pWindow = firstLogicalChildOfParent(pParent);
- vcl::Window* pNextWindow = pWindow;
- while ( pWindow )
+ vcl::Window* pFoundWindow = nullptr;
+ vcl::Window* pWindow = firstLogicalChildOfParent(pParent);
+ vcl::Window* pNextWindow = pWindow;
+
+ // process just the current page of a tab control
+ if (pWindow && pParent->GetType() == WindowType::TABCONTROL)
+ {
+ pWindow = ImplGetCurTabWindow(pParent);
+ pNextWindow = lastLogicalChildOfParent(pParent);
+ }
+
+ while (pWindow)
{
pWindow = pWindow->ImplGetWindow();
// skip invisible and disabled windows
- if ( pTabPage || isVisibleInLayout(pWindow) )
+ if (isVisibleInLayout(pWindow))
{
- // if the last control was a TabControl, take its TabPage
- if ( pTabPage )
+ // return the TabControl itself, before handling its page
+ if (pWindow->GetType() == WindowType::TABCONTROL)
{
- pFoundWindow = ImplGetSubChildWindow( pTabPage, n, nIndex );
- pTabPage = nullptr;
+ if (n == nIndex)
+ return pWindow;
+ ++nIndex;
}
+ if (pWindow->GetStyle() & (WB_DIALOGCONTROL | WB_CHILDDLGCTRL))
+ pFoundWindow = ImplGetSubChildWindow(pWindow, n, nIndex);
else
- {
pFoundWindow = pWindow;
- // for a TabControl, remember the current TabPage for later use
- if ( pWindow->GetType() == WindowType::TABCONTROL )
- pTabPage = ImplGetCurTabWindow(pWindow);
- else if (pWindow->GetStyle() & (WB_DIALOGCONTROL | WB_CHILDDLGCTRL))
- pFoundWindow = ImplGetSubChildWindow( pWindow, n, nIndex );
- }
- if ( n == nIndex )
+ if (n == nIndex)
return pFoundWindow;
- nIndex++;
+ ++nIndex;
}
- if ( pTabPage )
- pWindow = pTabPage;
- else
- {
- pWindow = nextLogicalChildOfParent(pParent, pNextWindow);
- pNextWindow = pWindow;
- }
+ pWindow = nextLogicalChildOfParent(pParent, pNextWindow);
+ pNextWindow = pWindow;
}
- nIndex--;
+ --nIndex;
+ assert(!pFoundWindow || (pFoundWindow == pFoundWindow->ImplGetWindow()));
return pFoundWindow;
}