diff options
author | Philipp Lohmann <Philipp.Lohmann@Sun.COM> | 2009-10-09 15:11:54 +0200 |
---|---|---|
committer | Philipp Lohmann <Philipp.Lohmann@Sun.COM> | 2009-10-09 15:11:54 +0200 |
commit | 834e45248a6fa97d8b0246c2ce8666ffd9c3cf6b (patch) | |
tree | c1222c6e5899327891b31adc93938b9b49a130ac /vcl/source/window/dlgctrl.cxx | |
parent | 2589f7adbf0066980b8da68355c2d48369465764 (diff) | |
parent | 9b9d44ee50a38180c2451ca527bf7b9f6f46f0fe (diff) |
merge with m61
Diffstat (limited to 'vcl/source/window/dlgctrl.cxx')
-rw-r--r-- | vcl/source/window/dlgctrl.cxx | 65 |
1 files changed, 61 insertions, 4 deletions
diff --git a/vcl/source/window/dlgctrl.cxx b/vcl/source/window/dlgctrl.cxx index 392c2ceaa478..c6f64d74c5fc 100644 --- a/vcl/source/window/dlgctrl.cxx +++ b/vcl/source/window/dlgctrl.cxx @@ -46,10 +46,41 @@ using namespace ::com::sun::star; // ======================================================================= +static BOOL ImplHasIndirectTabParent( Window* pWindow ) +{ + // The window has inderect tab parent if it is included in tab hierarchy + // of the indirect parent window + + return ( pWindow && pWindow->GetParent() + && ( pWindow->GetParent()->ImplGetWindow()->GetStyle() & WB_CHILDDLGCTRL ) ); +} + +// ----------------------------------------------------------------------- + +static Window* ImplGetTopParentOfTabHierarchy( Window* pParent ) +{ + // The method allows to find the most close parent containing all the + // window from the current tab-hierarchy + // The direct parent should be provided as a parameter here + + Window* pResult = pParent; + + if ( pResult ) + { + while ( pResult->GetParent() && ( pResult->ImplGetWindow()->GetStyle() & WB_CHILDDLGCTRL ) ) + pResult = pResult->GetParent(); + } + + return pResult; +} + +// ----------------------------------------------------------------------- + static Window* ImplGetSubChildWindow( Window* pParent, USHORT n, USHORT& nIndex ) { Window* pTabPage = NULL; Window* pFoundWindow = NULL; + Window* pWindow = pParent->GetWindow( WINDOW_FIRSTCHILD ); Window* pNextWindow = pWindow; while ( pWindow ) @@ -96,7 +127,8 @@ static Window* ImplGetSubChildWindow( Window* pParent, USHORT n, USHORT& nIndex } } } - else if ( pWindow->GetStyle() & WB_DIALOGCONTROL ) + else if ( ( pWindow->GetStyle() & WB_DIALOGCONTROL ) + || ( pWindow->GetStyle() & WB_CHILDDLGCTRL ) ) pFoundWindow = ImplGetSubChildWindow( pWindow, n, nIndex ); } @@ -122,6 +154,8 @@ static Window* ImplGetSubChildWindow( Window* pParent, USHORT n, USHORT& nIndex static Window* ImplGetChildWindow( Window* pParent, USHORT n, USHORT& nIndex, BOOL bTestEnable ) { + pParent = ImplGetTopParentOfTabHierarchy( pParent ); + nIndex = 0; Window* pWindow = ImplGetSubChildWindow( pParent, n, nIndex ); if ( bTestEnable ) @@ -284,14 +318,16 @@ static Window* ImplFindDlgCtrlWindow( Window* pParent, Window* pWindow, USHORT& USHORT nFormEnd; // Focus-Fenster in der Child-Liste suchen - pSWindow = ImplGetChildWindow( pParent, 0, i, FALSE ); + Window* pFirstChildWindow = pSWindow = ImplGetChildWindow( pParent, 0, i, FALSE ); if( pWindow == NULL ) pWindow = pSWindow; while ( pSWindow ) { - if ( pSWindow->ImplGetWindow()->IsDialogControlStart() ) + // the DialogControlStart mark is only accepted for the direct children + if ( !ImplHasIndirectTabParent( pSWindow ) + && pSWindow->ImplGetWindow()->IsDialogControlStart() ) nFormStart = i; // SecondWindow wegen zusammengesetzten Controls wie @@ -331,12 +367,33 @@ static Window* ImplFindDlgCtrlWindow( Window* pParent, Window* pWindow, USHORT& // Formularende suchen nFormEnd = nFormStart; pTempWindow = pSWindow; + sal_Int32 nIteration = 0; do { nFormEnd = i; pTempWindow = ImplGetNextWindow( pParent, i, i, FALSE ); - if ( !i || (pTempWindow && pTempWindow->ImplGetWindow()->IsDialogControlStart()) ) + + // the DialogControlStart mark is only accepted for the direct children + if ( !i + || ( pTempWindow && !ImplHasIndirectTabParent( pTempWindow ) + && pTempWindow->ImplGetWindow()->IsDialogControlStart() ) ) break; + + if ( pTempWindow && pTempWindow == pFirstChildWindow ) + { + // It is possible to go through the begin of hierarchy once + // while looking for DialogControlStart mark. + // If it happens second time, it looks like an endless loop, + // that should be impossible, but just for the case... + nIteration++; + if ( nIteration >= 2 ) + { + // this is an unexpected scenario + DBG_ASSERT( FALSE, "It seems to be an endless loop!" ); + rFormStart = 0; + break; + } + } } while ( pTempWindow ); rFormEnd = nFormEnd; |