xref: /AOO41X/main/toolkit/source/helper/unowrapper.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_toolkit.hxx"
30*cdf0e10cSrcweir #include <com/sun/star/awt/WindowEvent.hpp>
31*cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
32*cdf0e10cSrcweir 
33*cdf0e10cSrcweir #include <toolkit/helper/unowrapper.hxx>
34*cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx>
35*cdf0e10cSrcweir #include <toolkit/helper/convert.hxx>
36*cdf0e10cSrcweir #include <toolkit/awt/vclxwindow.hxx>
37*cdf0e10cSrcweir #include <toolkit/awt/vclxwindows.hxx>
38*cdf0e10cSrcweir #include <toolkit/awt/vclxcontainer.hxx>
39*cdf0e10cSrcweir #include <toolkit/awt/vclxtopwindow.hxx>
40*cdf0e10cSrcweir #include <toolkit/awt/vclxgraphics.hxx>
41*cdf0e10cSrcweir 
42*cdf0e10cSrcweir #include "toolkit/dllapi.h"
43*cdf0e10cSrcweir #include <vcl/svapp.hxx>
44*cdf0e10cSrcweir #include <vcl/syswin.hxx>
45*cdf0e10cSrcweir #include <vcl/menu.hxx>
46*cdf0e10cSrcweir 
47*cdf0e10cSrcweir #include <tools/debug.hxx>
48*cdf0e10cSrcweir 
49*cdf0e10cSrcweir using namespace ::com::sun::star;
50*cdf0e10cSrcweir 
51*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > CreateXWindow( Window* pWindow )
52*cdf0e10cSrcweir {
53*cdf0e10cSrcweir     switch ( pWindow->GetType() )
54*cdf0e10cSrcweir     {
55*cdf0e10cSrcweir 		case WINDOW_IMAGERADIOBUTTON:
56*cdf0e10cSrcweir 		case WINDOW_IMAGEBUTTON:
57*cdf0e10cSrcweir 		case WINDOW_SPINBUTTON:
58*cdf0e10cSrcweir 		case WINDOW_MENUBUTTON:
59*cdf0e10cSrcweir 		case WINDOW_MOREBUTTON:
60*cdf0e10cSrcweir 		case WINDOW_PUSHBUTTON:
61*cdf0e10cSrcweir 		case WINDOW_HELPBUTTON:
62*cdf0e10cSrcweir 		case WINDOW_OKBUTTON:
63*cdf0e10cSrcweir 		case WINDOW_CANCELBUTTON:   return new VCLXButton;
64*cdf0e10cSrcweir 		case WINDOW_CHECKBOX:       return new VCLXCheckBox;
65*cdf0e10cSrcweir         // --> OD 2009-06-29 #i95042#
66*cdf0e10cSrcweir         // A Window of type <MetricBox> is inherited from type <ComboBox>.
67*cdf0e10cSrcweir         // Thus, it does make more sense to return a <VCLXComboBox> instance
68*cdf0e10cSrcweir         // instead of only a <VCLXWindow> instance, especially regarding its
69*cdf0e10cSrcweir         // corresponding accessibility API.
70*cdf0e10cSrcweir         case WINDOW_METRICBOX:
71*cdf0e10cSrcweir         case WINDOW_COMBOBOX:       return new VCLXComboBox;
72*cdf0e10cSrcweir 		case WINDOW_SPINFIELD:
73*cdf0e10cSrcweir 		case WINDOW_NUMERICFIELD:
74*cdf0e10cSrcweir 		case WINDOW_CURRENCYFIELD:  return new VCLXNumericField;
75*cdf0e10cSrcweir 		case WINDOW_DATEFIELD:      return new VCLXDateField;
76*cdf0e10cSrcweir         case WINDOW_MULTILINEEDIT:
77*cdf0e10cSrcweir 		case WINDOW_EDIT:           return new VCLXEdit;
78*cdf0e10cSrcweir 		case WINDOW_METRICFIELD:    return new VCLXSpinField;
79*cdf0e10cSrcweir 		case WINDOW_MESSBOX:
80*cdf0e10cSrcweir 		case WINDOW_INFOBOX:
81*cdf0e10cSrcweir 		case WINDOW_WARNINGBOX:
82*cdf0e10cSrcweir 		case WINDOW_QUERYBOX:
83*cdf0e10cSrcweir 		case WINDOW_ERRORBOX:       return new VCLXMessageBox;
84*cdf0e10cSrcweir 		case WINDOW_FIXEDIMAGE:     return new VCLXImageControl;
85*cdf0e10cSrcweir 		case WINDOW_FIXEDTEXT:      return new VCLXFixedText;
86*cdf0e10cSrcweir 		case WINDOW_MULTILISTBOX:
87*cdf0e10cSrcweir 		case WINDOW_LISTBOX:        return new VCLXListBox;
88*cdf0e10cSrcweir 		case WINDOW_LONGCURRENCYFIELD:  return new VCLXCurrencyField;
89*cdf0e10cSrcweir 		case WINDOW_DIALOG:
90*cdf0e10cSrcweir 		case WINDOW_MODALDIALOG:
91*cdf0e10cSrcweir 		case WINDOW_TABDIALOG:
92*cdf0e10cSrcweir 		case WINDOW_BUTTONDIALOG:
93*cdf0e10cSrcweir 		case WINDOW_MODELESSDIALOG: return new VCLXDialog;
94*cdf0e10cSrcweir 		case WINDOW_PATTERNFIELD:   return new VCLXPatternField;
95*cdf0e10cSrcweir 		case WINDOW_RADIOBUTTON:    return new VCLXRadioButton;
96*cdf0e10cSrcweir 		case WINDOW_SCROLLBAR:      return new VCLXScrollBar;
97*cdf0e10cSrcweir 		case WINDOW_TIMEFIELD:      return new VCLXTimeField;
98*cdf0e10cSrcweir 
99*cdf0e10cSrcweir 		case WINDOW_SYSWINDOW:
100*cdf0e10cSrcweir 		case WINDOW_WORKWINDOW:
101*cdf0e10cSrcweir 		case WINDOW_DOCKINGWINDOW:
102*cdf0e10cSrcweir 		case WINDOW_FLOATINGWINDOW:
103*cdf0e10cSrcweir 		case WINDOW_HELPTEXTWINDOW:	return new VCLXTopWindow;
104*cdf0e10cSrcweir 
105*cdf0e10cSrcweir 		case WINDOW_WINDOW:
106*cdf0e10cSrcweir 		case WINDOW_TABPAGE:        return new VCLXContainer;
107*cdf0e10cSrcweir 
108*cdf0e10cSrcweir 		case WINDOW_TOOLBOX:		return new VCLXToolBox;
109*cdf0e10cSrcweir 
110*cdf0e10cSrcweir         // case WINDOW_FIXEDLINE:
111*cdf0e10cSrcweir 		// case WINDOW_FIXEDBITMAP:
112*cdf0e10cSrcweir 		// case WINDOW_DATEBOX:
113*cdf0e10cSrcweir 		// case WINDOW_GROUPBOX:
114*cdf0e10cSrcweir 		// case WINDOW_LONGCURRENCYBOX:
115*cdf0e10cSrcweir 		// case WINDOW_SPLITTER:
116*cdf0e10cSrcweir 		// case WINDOW_STATUSBAR:
117*cdf0e10cSrcweir 		// case WINDOW_TABCONTROL:
118*cdf0e10cSrcweir 		// case WINDOW_NUMERICBOX:
119*cdf0e10cSrcweir 		// case WINDOW_TRISTATEBOX:
120*cdf0e10cSrcweir 		// case WINDOW_TIMEBOX:
121*cdf0e10cSrcweir 		// case WINDOW_SPLITWINDOW:
122*cdf0e10cSrcweir 		// case WINDOW_SCROLLBARBOX:
123*cdf0e10cSrcweir 		// case WINDOW_PATTERNBOX:
124*cdf0e10cSrcweir 		// case WINDOW_CURRENCYBOX:
125*cdf0e10cSrcweir         default:                    return new VCLXWindow( true );
126*cdf0e10cSrcweir     }
127*cdf0e10cSrcweir }
128*cdf0e10cSrcweir 
129*cdf0e10cSrcweir //	----------------------------------------------------
130*cdf0e10cSrcweir //	class UnoWrapper
131*cdf0e10cSrcweir //	----------------------------------------------------
132*cdf0e10cSrcweir 
133*cdf0e10cSrcweir extern "C" {
134*cdf0e10cSrcweir 
135*cdf0e10cSrcweir TOOLKIT_DLLPUBLIC UnoWrapperBase* CreateUnoWrapper()
136*cdf0e10cSrcweir {
137*cdf0e10cSrcweir 	return new UnoWrapper( NULL );
138*cdf0e10cSrcweir }
139*cdf0e10cSrcweir 
140*cdf0e10cSrcweir }	// extern "C"
141*cdf0e10cSrcweir 
142*cdf0e10cSrcweir 
143*cdf0e10cSrcweir UnoWrapper::UnoWrapper( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XToolkit>& rxToolkit )
144*cdf0e10cSrcweir {
145*cdf0e10cSrcweir     mxToolkit = rxToolkit;
146*cdf0e10cSrcweir }
147*cdf0e10cSrcweir 
148*cdf0e10cSrcweir void UnoWrapper::Destroy()
149*cdf0e10cSrcweir {
150*cdf0e10cSrcweir 	delete this;
151*cdf0e10cSrcweir }
152*cdf0e10cSrcweir 
153*cdf0e10cSrcweir UnoWrapper::~UnoWrapper()
154*cdf0e10cSrcweir {
155*cdf0e10cSrcweir }
156*cdf0e10cSrcweir 
157*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::awt::XToolkit> UnoWrapper::GetVCLToolkit()
158*cdf0e10cSrcweir {
159*cdf0e10cSrcweir 	if ( !mxToolkit.is() )
160*cdf0e10cSrcweir 		mxToolkit = VCLUnoHelper::CreateToolkit();
161*cdf0e10cSrcweir 	return mxToolkit.get();
162*cdf0e10cSrcweir }
163*cdf0e10cSrcweir 
164*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer> UnoWrapper::GetWindowInterface( Window* pWindow, sal_Bool bCreate )
165*cdf0e10cSrcweir {
166*cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer> xPeer = pWindow->GetWindowPeer();
167*cdf0e10cSrcweir 	if ( !xPeer.is() && bCreate )
168*cdf0e10cSrcweir 	{
169*cdf0e10cSrcweir         xPeer = CreateXWindow( pWindow );
170*cdf0e10cSrcweir 		SetWindowInterface( pWindow, xPeer );
171*cdf0e10cSrcweir 	}
172*cdf0e10cSrcweir 	return xPeer;
173*cdf0e10cSrcweir }
174*cdf0e10cSrcweir 
175*cdf0e10cSrcweir void UnoWrapper::SetWindowInterface( Window* pWindow, ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer> xIFace )
176*cdf0e10cSrcweir {
177*cdf0e10cSrcweir 	VCLXWindow* pVCLXWindow = VCLXWindow::GetImplementation( xIFace );
178*cdf0e10cSrcweir 
179*cdf0e10cSrcweir 	DBG_ASSERT( pVCLXWindow, "SetComponentInterface - unsupported type" );
180*cdf0e10cSrcweir 	if ( pVCLXWindow )
181*cdf0e10cSrcweir 	{
182*cdf0e10cSrcweir 		::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer> xPeer = pWindow->GetWindowPeer();
183*cdf0e10cSrcweir 		if( xPeer.is() )
184*cdf0e10cSrcweir 		{
185*cdf0e10cSrcweir 			bool bSameInstance( pVCLXWindow == dynamic_cast< VCLXWindow* >( xPeer.get() ));
186*cdf0e10cSrcweir             DBG_ASSERT( bSameInstance, "UnoWrapper::SetWindowInterface: there already *is* a WindowInterface for this window!" );
187*cdf0e10cSrcweir 			if ( bSameInstance )
188*cdf0e10cSrcweir 				return;
189*cdf0e10cSrcweir 		}
190*cdf0e10cSrcweir 		pVCLXWindow->SetWindow( pWindow );
191*cdf0e10cSrcweir 		pWindow->SetWindowPeer( xIFace, pVCLXWindow );
192*cdf0e10cSrcweir 	}
193*cdf0e10cSrcweir }
194*cdf0e10cSrcweir 
195*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::awt::XGraphics> UnoWrapper::CreateGraphics( OutputDevice* pOutDev )
196*cdf0e10cSrcweir {
197*cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::awt::XGraphics> xGrf;
198*cdf0e10cSrcweir 	VCLXGraphics* pGrf = new VCLXGraphics;
199*cdf0e10cSrcweir 	xGrf = pGrf;
200*cdf0e10cSrcweir 	pGrf->Init( pOutDev );
201*cdf0e10cSrcweir 	return xGrf;
202*cdf0e10cSrcweir }
203*cdf0e10cSrcweir 
204*cdf0e10cSrcweir void UnoWrapper::ReleaseAllGraphics( OutputDevice* pOutDev )
205*cdf0e10cSrcweir {
206*cdf0e10cSrcweir 	List* pLst = pOutDev->GetUnoGraphicsList();
207*cdf0e10cSrcweir 	if ( pLst )
208*cdf0e10cSrcweir 	{
209*cdf0e10cSrcweir 		for ( sal_uInt32 n = 0; n < pLst->Count(); n++ )
210*cdf0e10cSrcweir 		{
211*cdf0e10cSrcweir 			VCLXGraphics* pGrf = (VCLXGraphics*)pLst->GetObject( n );
212*cdf0e10cSrcweir 			pGrf->SetOutputDevice( NULL );
213*cdf0e10cSrcweir 		}
214*cdf0e10cSrcweir 	}
215*cdf0e10cSrcweir 
216*cdf0e10cSrcweir }
217*cdf0e10cSrcweir 
218*cdf0e10cSrcweir // MT: Wurde im Window-CTOR gerufen, damit Container-Listener
219*cdf0e10cSrcweir // vom Parent reagieren, aber hat sowieso nicht richtig funktioniert,
220*cdf0e10cSrcweir // weil im Window-CTOR das Interface noch nicht da ist!
221*cdf0e10cSrcweir // => Nur Listener rufen, wenn ueber das ::com::sun::star::awt::Toolkit erzeugt
222*cdf0e10cSrcweir 
223*cdf0e10cSrcweir /*
224*cdf0e10cSrcweir void ImplSmartWindowCreated( Window* pNewWindow )
225*cdf0e10cSrcweir {
226*cdf0e10cSrcweir 	UNOWindowData* pParentUNOData = pNewWindow->GetParent() ?
227*cdf0e10cSrcweir 							pNewWindow->GetParent()->GetUNOData() : NULL;
228*cdf0e10cSrcweir 
229*cdf0e10cSrcweir 	if ( pParentUNOData && pParentUNOData->GetListeners( EL_CONTAINER ) )
230*cdf0e10cSrcweir 	{
231*cdf0e10cSrcweir 		UNOWindowData* pUNOData = pNewWindow->GetUNOData();
232*cdf0e10cSrcweir 		if ( !pUNOData )
233*cdf0e10cSrcweir 			pUNOData = ImplSmartCreateUNOData( pNewWindow );
234*cdf0e10cSrcweir 
235*cdf0e10cSrcweir 		::com::sun::star::awt::VclContainerEvent aEvent;
236*cdf0e10cSrcweir 		aEvent.Source = (UsrObject*)pParentUNOData->GetWindowPeer();
237*cdf0e10cSrcweir 		aEvent.Id = VCLCOMPONENT_ADDED;
238*cdf0e10cSrcweir 		aEvent.Child = (UsrObject*)pUNOData->GetWindowPeer();
239*cdf0e10cSrcweir 
240*cdf0e10cSrcweir 		EventList* pLst = pParentUNOData->GetListeners( EL_CONTAINER );
241*cdf0e10cSrcweir 		for ( sal_uInt32 n = 0; n < pLst->Count(); n++ )
242*cdf0e10cSrcweir 		{
243*cdf0e10cSrcweir 			::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > * pRef = pLst->GetObject( n );
244*cdf0e10cSrcweir 			((::com::sun::star::awt::XVclContainerListener*)(::com::sun::star::lang::XEventListener*)*pRef)->windowAdded( aEvent );
245*cdf0e10cSrcweir 		}
246*cdf0e10cSrcweir 	}
247*cdf0e10cSrcweir }
248*cdf0e10cSrcweir */
249*cdf0e10cSrcweir 
250*cdf0e10cSrcweir sal_Bool lcl_ImplIsParent( Window* pParentWindow, Window* pPossibleChild )
251*cdf0e10cSrcweir {
252*cdf0e10cSrcweir     Window* pWindow = ( pPossibleChild != pParentWindow ) ? pPossibleChild : NULL;
253*cdf0e10cSrcweir 	while ( pWindow && ( pWindow != pParentWindow ) )
254*cdf0e10cSrcweir 		pWindow = pWindow->GetParent();
255*cdf0e10cSrcweir 
256*cdf0e10cSrcweir 	return pWindow ? sal_True : sal_False;
257*cdf0e10cSrcweir }
258*cdf0e10cSrcweir 
259*cdf0e10cSrcweir void UnoWrapper::WindowDestroyed( Window* pWindow )
260*cdf0e10cSrcweir {
261*cdf0e10cSrcweir 	// ggf. existieren noch von ::com::sun::star::loader::Java erzeugte Childs, die sonst erst
262*cdf0e10cSrcweir 	// im Garbage-Collector zerstoert werden...
263*cdf0e10cSrcweir 	Window* pChild = pWindow->GetWindow( WINDOW_FIRSTCHILD );
264*cdf0e10cSrcweir 	while ( pChild )
265*cdf0e10cSrcweir 	{
266*cdf0e10cSrcweir 		Window* pNextChild = pChild->GetWindow( WINDOW_NEXT );
267*cdf0e10cSrcweir 
268*cdf0e10cSrcweir 		Window* pClient = pChild->GetWindow( WINDOW_CLIENT );
269*cdf0e10cSrcweir         if ( pClient->GetWindowPeer() )
270*cdf0e10cSrcweir         {
271*cdf0e10cSrcweir             ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > xComp( pClient->GetComponentInterface( sal_False ), ::com::sun::star::uno::UNO_QUERY );
272*cdf0e10cSrcweir 			xComp->dispose();
273*cdf0e10cSrcweir         }
274*cdf0e10cSrcweir 
275*cdf0e10cSrcweir 		pChild = pNextChild;
276*cdf0e10cSrcweir 	}
277*cdf0e10cSrcweir 
278*cdf0e10cSrcweir 	// ::com::sun::star::chaos::System-Windows suchen...
279*cdf0e10cSrcweir 	Window* pOverlap = pWindow->GetWindow( WINDOW_OVERLAP );
280*cdf0e10cSrcweir 	pOverlap = pOverlap->GetWindow( WINDOW_FIRSTOVERLAP );
281*cdf0e10cSrcweir 	while ( pOverlap )
282*cdf0e10cSrcweir 	{
283*cdf0e10cSrcweir 		Window* pNextOverlap = pOverlap->GetWindow( WINDOW_NEXT );
284*cdf0e10cSrcweir 		Window* pClient = pOverlap->GetWindow( WINDOW_CLIENT );
285*cdf0e10cSrcweir 
286*cdf0e10cSrcweir 		if ( pClient->GetWindowPeer() && lcl_ImplIsParent( pWindow, pClient ) )
287*cdf0e10cSrcweir         {
288*cdf0e10cSrcweir             ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > xComp( pClient->GetComponentInterface( sal_False ), ::com::sun::star::uno::UNO_QUERY );
289*cdf0e10cSrcweir 			xComp->dispose();
290*cdf0e10cSrcweir         }
291*cdf0e10cSrcweir 
292*cdf0e10cSrcweir 		pOverlap = pNextOverlap;
293*cdf0e10cSrcweir 	}
294*cdf0e10cSrcweir 
295*cdf0e10cSrcweir 	Window* pParent = pWindow->GetParent();
296*cdf0e10cSrcweir 	if ( pParent && pParent->GetWindowPeer() )
297*cdf0e10cSrcweir         pParent->GetWindowPeer()->notifyWindowRemoved( *pWindow );
298*cdf0e10cSrcweir 
299*cdf0e10cSrcweir     VCLXWindow* pWindowPeer = pWindow->GetWindowPeer();
300*cdf0e10cSrcweir     uno::Reference< lang::XComponent > xWindowPeerComp( pWindow->GetComponentInterface( sal_False ), uno::UNO_QUERY );
301*cdf0e10cSrcweir     OSL_ENSURE( ( pWindowPeer != NULL ) == ( xWindowPeerComp.is() == sal_True ),
302*cdf0e10cSrcweir         "UnoWrapper::WindowDestroyed: inconsistency in the window's peers!" );
303*cdf0e10cSrcweir 	if ( pWindowPeer )
304*cdf0e10cSrcweir 	{
305*cdf0e10cSrcweir 		pWindowPeer->SetWindow( NULL );
306*cdf0e10cSrcweir 		pWindow->SetWindowPeer( NULL, NULL );
307*cdf0e10cSrcweir 	}
308*cdf0e10cSrcweir     if ( xWindowPeerComp.is() )
309*cdf0e10cSrcweir         xWindowPeerComp->dispose();
310*cdf0e10cSrcweir 
311*cdf0e10cSrcweir     // #102132# Iterate over frames after setting Window peer to NULL,
312*cdf0e10cSrcweir     // because while destroying other frames, we get get into the method again and try
313*cdf0e10cSrcweir     // to destroy this window again...
314*cdf0e10cSrcweir     // #i42462#/#116855# no, don't loop: Instead, just ensure that all our top-window-children
315*cdf0e10cSrcweir     // are disposed, too (which should also be a valid fix for #102132#, but doesn't have the extreme
316*cdf0e10cSrcweir     // performance penalties)
317*cdf0e10cSrcweir     if ( pWindow )
318*cdf0e10cSrcweir     {
319*cdf0e10cSrcweir         Window* pTopWindowChild = pWindow->GetWindow( WINDOW_FIRSTTOPWINDOWCHILD );
320*cdf0e10cSrcweir         while ( pTopWindowChild )
321*cdf0e10cSrcweir         {
322*cdf0e10cSrcweir             OSL_ENSURE( pTopWindowChild->GetParent() == pWindow,
323*cdf0e10cSrcweir                         "UnoWrapper::WindowDestroyed: inconsistency in the SystemWindow relationship!" );
324*cdf0e10cSrcweir 
325*cdf0e10cSrcweir             Window* pNextTopChild = pTopWindowChild->GetWindow( WINDOW_NEXTTOPWINDOWSIBLING );
326*cdf0e10cSrcweir 
327*cdf0e10cSrcweir             //the window still could be on the stack, so we have to
328*cdf0e10cSrcweir             // use lazy delete ( it will automatically
329*cdf0e10cSrcweir             // disconnect from the currently destroyed parent window )
330*cdf0e10cSrcweir             pTopWindowChild->doLazyDelete();
331*cdf0e10cSrcweir 
332*cdf0e10cSrcweir             pTopWindowChild = pNextTopChild;
333*cdf0e10cSrcweir         }
334*cdf0e10cSrcweir     }
335*cdf0e10cSrcweir }
336*cdf0e10cSrcweir 
337*cdf0e10cSrcweir // ----------------------------------------------------------------------------
338*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > UnoWrapper::CreateAccessible( Menu* pMenu, sal_Bool bIsMenuBar )
339*cdf0e10cSrcweir {
340*cdf0e10cSrcweir     return maAccessibleFactoryAccess.getFactory().createAccessible( pMenu, bIsMenuBar );
341*cdf0e10cSrcweir }
342