1*9d1279ecSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*9d1279ecSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*9d1279ecSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*9d1279ecSAndrew Rist  * distributed with this work for additional information
6*9d1279ecSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*9d1279ecSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*9d1279ecSAndrew Rist  * "License"); you may not use this file except in compliance
9*9d1279ecSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*9d1279ecSAndrew Rist  *
11*9d1279ecSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*9d1279ecSAndrew Rist  *
13*9d1279ecSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*9d1279ecSAndrew Rist  * software distributed under the License is distributed on an
15*9d1279ecSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*9d1279ecSAndrew Rist  * KIND, either express or implied.  See the License for the
17*9d1279ecSAndrew Rist  * specific language governing permissions and limitations
18*9d1279ecSAndrew Rist  * under the License.
19*9d1279ecSAndrew Rist  *
20*9d1279ecSAndrew Rist  *************************************************************/
21*9d1279ecSAndrew Rist 
22*9d1279ecSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_automation.hxx"
26cdf0e10cSrcweir #include <tools/time.hxx>
27cdf0e10cSrcweir #include <vcl/splitwin.hxx>
28cdf0e10cSrcweir #include <vcl/wrkwin.hxx>
29cdf0e10cSrcweir #ifndef _BASIC_TTRESHLP_HXX
30cdf0e10cSrcweir #include <basic/ttstrhlp.hxx>
31cdf0e10cSrcweir #endif
32cdf0e10cSrcweir #include "statemnt.hxx"
33cdf0e10cSrcweir 
34cdf0e10cSrcweir #ifndef _RETSRTM_HXX
35cdf0e10cSrcweir #include "retstrm.hxx"
36cdf0e10cSrcweir #endif
37cdf0e10cSrcweir #include "rcontrol.hxx"
38cdf0e10cSrcweir 
39cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
40cdf0e10cSrcweir #include "editwin.hxx"
41cdf0e10cSrcweir #endif
42cdf0e10cSrcweir 
43cdf0e10cSrcweir #include "profiler.hxx"
44cdf0e10cSrcweir #include <vcl/floatwin.hxx>
45cdf0e10cSrcweir #include <vcl/toolbox.hxx>
46cdf0e10cSrcweir 
47cdf0e10cSrcweir // only needed for dynamic_cast in wintree
48cdf0e10cSrcweir #include <svtools/editbrowsebox.hxx>
49cdf0e10cSrcweir #include <svtools/valueset.hxx>
50cdf0e10cSrcweir #include <svtools/roadmap.hxx>
51cdf0e10cSrcweir #include <svtools/extensionlistbox.hxx>
52cdf0e10cSrcweir #include <svtools/table/tablecontrol.hxx>
53cdf0e10cSrcweir 
54cdf0e10cSrcweir #define WINDOW_ANYTYPE WINDOW_BASE
55cdf0e10cSrcweir 
56cdf0e10cSrcweir 
57cdf0e10cSrcweir TTProfiler *StatementList::pProfiler = NULL;
58cdf0e10cSrcweir StatementList *StatementList::pFirst = NULL;
59cdf0e10cSrcweir sal_Bool StatementList::bReadingCommands = sal_False;
60cdf0e10cSrcweir sal_Bool StatementList::bIsInReschedule = sal_False;
61cdf0e10cSrcweir sal_uInt16 StatementList::nModalCount = 0;
62cdf0e10cSrcweir Window *StatementList::pLastFocusWindow = NULL;
63cdf0e10cSrcweir sal_Bool StatementList::bWasDragManager = sal_False;
64cdf0e10cSrcweir sal_Bool StatementList::bWasPopupMenu = sal_False;
65cdf0e10cSrcweir sal_Bool StatementList::bBasicWasRunning = sal_False;
66cdf0e10cSrcweir RetStream *StatementList::pRet = NULL;
67cdf0e10cSrcweir sal_Bool StatementList::IsError = sal_False;
68cdf0e10cSrcweir sal_Bool StatementList::bDying = sal_False;
69cdf0e10cSrcweir sal_Bool StatementList::bExecuting = sal_False;
70cdf0e10cSrcweir StatementList *StatementList::pCurrentProfileStatement = NULL;
71cdf0e10cSrcweir sal_Bool StatementList::bUsePostEvents = sal_True;
72cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
73cdf0e10cSrcweir EditWindow *StatementList::m_pDbgWin;
74cdf0e10cSrcweir #endif
75cdf0e10cSrcweir 
76cdf0e10cSrcweir 
77cdf0e10cSrcweir rtl::OString StatementList::aWindowWaitUId = rtl::OString();
78cdf0e10cSrcweir Window *StatementList::pWindowWaitPointer = NULL;
79cdf0e10cSrcweir rtl::OString StatementList::aWindowWaitOldHelpId = rtl::OString();
80cdf0e10cSrcweir rtl::OString StatementList::aWindowWaitOldUniqueId = rtl::OString();
81cdf0e10cSrcweir sal_uInt16 StatementList::nUseBindings = 0;
82cdf0e10cSrcweir 
83cdf0e10cSrcweir sal_uInt16 StatementList::aSubMenuId1 = 0;	// Untermen�s bei PopupMenus
84cdf0e10cSrcweir sal_uInt16 StatementList::aSubMenuId2 = 0;	// erstmal 2-Stufig
85cdf0e10cSrcweir sal_uInt16 StatementList::aSubMenuId3 = 0;	// and now even 3 levels #i31512#
86cdf0e10cSrcweir SystemWindow *StatementList::pMenuWindow = NULL;
87cdf0e10cSrcweir TTProperties *StatementList::pTTProperties = NULL;
88cdf0e10cSrcweir 
89cdf0e10cSrcweir sal_uInt16 StatementList::nMinTypeKeysDelay = 0;	// Verz�gerung der einzelnen Anschl�ge f�r TypeKeys
90cdf0e10cSrcweir sal_uInt16 StatementList::nMaxTypeKeysDelay = 0;
91cdf0e10cSrcweir sal_Bool StatementList::bDoTypeKeysDelay = sal_False;
92cdf0e10cSrcweir 
93cdf0e10cSrcweir Window* StatementList::pFirstDocFrame = NULL;
94cdf0e10cSrcweir 
95cdf0e10cSrcweir sal_Bool StatementList::bIsSlotInExecute = sal_False;
96cdf0e10cSrcweir 
97cdf0e10cSrcweir sal_Bool StatementList::bCatchGPF = sal_True;
98cdf0e10cSrcweir 
99cdf0e10cSrcweir 
100cdf0e10cSrcweir IMPL_GEN_RES_STR;
101cdf0e10cSrcweir 
102cdf0e10cSrcweir 
103cdf0e10cSrcweir static TTSettings* pTTSettings = NULL;
104cdf0e10cSrcweir 
GetTTSettings()105cdf0e10cSrcweir TTSettings* GetTTSettings()
106cdf0e10cSrcweir {
107cdf0e10cSrcweir     if ( !pTTSettings )
108cdf0e10cSrcweir     {
109cdf0e10cSrcweir         pTTSettings = new TTSettings;
110cdf0e10cSrcweir 
111cdf0e10cSrcweir         // DisplayHID
112cdf0e10cSrcweir         pTTSettings->pDisplayInstance = NULL;
113cdf0e10cSrcweir         pTTSettings->pDisplayHidWin = NULL;
114cdf0e10cSrcweir         pTTSettings->Old = NULL;
115cdf0e10cSrcweir         pTTSettings->Act = NULL;
116cdf0e10cSrcweir         pTTSettings->aOriginalCaption.Erase();
117cdf0e10cSrcweir 
118cdf0e10cSrcweir         // Translate
119cdf0e10cSrcweir 	    pTTSettings->pTranslateWin = NULL;
120cdf0e10cSrcweir 	    pTTSettings->bToTop = sal_True;
121cdf0e10cSrcweir     }
122cdf0e10cSrcweir 
123cdf0e10cSrcweir     return pTTSettings;
124cdf0e10cSrcweir }
125cdf0e10cSrcweir 
126cdf0e10cSrcweir 
127cdf0e10cSrcweir 
128cdf0e10cSrcweir 
129cdf0e10cSrcweir // FIXME: HELPID
130cdf0e10cSrcweir #define IS_WINP_CLOSING(pWin) (pWin->GetHelpId().equals( "TT_Win_is_closing_HID" ) && pWin->GetUniqueId().equals( "TT_Win_is_closing_UID" ))
131cdf0e10cSrcweir 
132cdf0e10cSrcweir /*
133cdf0e10cSrcweir UniString GEN_RES_STR0( sal_uLong nResId ) { return ResString( nResId ); }
134cdf0e10cSrcweir UniString GEN_RES_STR1( sal_uLong nResId, const UniString &Text1 ) { return GEN_RES_STR0( nResId ).Append( ArgString( 1, Text1 ) ); }
135cdf0e10cSrcweir UniString GEN_RES_STR2( sal_uLong nResId, const UniString &Text1, const UniString &Text2 ) { return GEN_RES_STR1( nResId, Text1 ).Append( ArgString( 2, Text2 ) ); }
136cdf0e10cSrcweir UniString GEN_RES_STR3( sal_uLong nResId, const UniString &Text1, const UniString &Text2, const UniString &Text3 ) { return GEN_RES_STR2( nResId, Text1, Text2 ).Append( ArgString( 3, Text3 ) );}
137cdf0e10cSrcweir */
StatementList()138cdf0e10cSrcweir StatementList::StatementList()
139cdf0e10cSrcweir : nRetryCount(MAX_RETRIES)
140cdf0e10cSrcweir , bStatementInQue(sal_False)
141cdf0e10cSrcweir {
142cdf0e10cSrcweir 	if (!pRet)
143cdf0e10cSrcweir 		pRet = new RetStream;		// so Sp�t wie m�glich, aber dennoch Zentral und auf jeden Fall rechtzeitig, da pRet private ist.
144cdf0e10cSrcweir }
145cdf0e10cSrcweir 
InitProfile()146cdf0e10cSrcweir void StatementList::InitProfile()
147cdf0e10cSrcweir {
148cdf0e10cSrcweir 	if ( pProfiler )
149cdf0e10cSrcweir 	{
150cdf0e10cSrcweir 		if ( pProfiler->IsProfilingPerCommand() || pProfiler->IsPartitioning() )
151cdf0e10cSrcweir 			pProfiler->StartProfileInterval( pCurrentProfileStatement != this );
152cdf0e10cSrcweir 
153cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
154cdf0e10cSrcweir 		if ( pCurrentProfileStatement != NULL && pCurrentProfileStatement != this )
155cdf0e10cSrcweir 			pRet->GenReturn( RET_ProfileInfo, 0, CUniString("InitProfile von anderem Statement gerufen ohne SendProfile\n") );
156cdf0e10cSrcweir #endif
157cdf0e10cSrcweir 		pCurrentProfileStatement = this;
158cdf0e10cSrcweir 	}
159cdf0e10cSrcweir }
160cdf0e10cSrcweir 
SendProfile(String aText)161cdf0e10cSrcweir void StatementList::SendProfile( String aText )
162cdf0e10cSrcweir {
163cdf0e10cSrcweir 	if ( pProfiler )
164cdf0e10cSrcweir 	{
165cdf0e10cSrcweir 		if ( pCurrentProfileStatement == this )
166cdf0e10cSrcweir 		{
167cdf0e10cSrcweir 			if ( pProfiler->IsProfilingPerCommand() || pProfiler->IsPartitioning() )
168cdf0e10cSrcweir 				pProfiler->EndProfileInterval();
169cdf0e10cSrcweir 
170cdf0e10cSrcweir 			if ( pProfiler->IsProfilingPerCommand() )
171cdf0e10cSrcweir 				pRet->GenReturn( RET_ProfileInfo, 0, pProfiler->GetProfileLine( aText ) );
172cdf0e10cSrcweir 
173cdf0e10cSrcweir 			if ( pProfiler->IsPartitioning() )
174cdf0e10cSrcweir                                 // FIXME: HELPID
175cdf0e10cSrcweir 				pRet->GenReturn( RET_ProfileInfo, S_ProfileTime, static_cast<comm_ULONG>(pProfiler->GetPartitioningTime()) ); // GetPartitioningTime() sal_uLong != comm_ULONG on 64bit
176cdf0e10cSrcweir 		}
177cdf0e10cSrcweir 
178cdf0e10cSrcweir 		if ( pProfiler->IsAutoProfiling() )
179cdf0e10cSrcweir 			pRet->GenReturn( RET_ProfileInfo, 0, pProfiler->GetAutoProfiling() );
180cdf0e10cSrcweir 
181cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
182cdf0e10cSrcweir 		if ( pCurrentProfileStatement == NULL )
183cdf0e10cSrcweir 			pRet->GenReturn( RET_ProfileInfo, 0, CUniString("SendProfile ohne InitProfile\n") );
184cdf0e10cSrcweir #endif
185cdf0e10cSrcweir 		pCurrentProfileStatement = NULL;
186cdf0e10cSrcweir 	}
187cdf0e10cSrcweir }
188cdf0e10cSrcweir 
QueStatement(StatementList * pAfterThis)189cdf0e10cSrcweir void StatementList::QueStatement(StatementList *pAfterThis)
190cdf0e10cSrcweir {
191cdf0e10cSrcweir 	DBG_ASSERT(!bStatementInQue,"QueStatement f�r bereits eingetragenes Statement -> Abgebrochen");
192cdf0e10cSrcweir 	if ( bStatementInQue )
193cdf0e10cSrcweir 		return;
194cdf0e10cSrcweir 
195cdf0e10cSrcweir 	bStatementInQue = sal_True;
196cdf0e10cSrcweir 	if ( pAfterThis )
197cdf0e10cSrcweir 	{
198cdf0e10cSrcweir         if ( pAfterThis->bStatementInQue )
199cdf0e10cSrcweir         {
200cdf0e10cSrcweir 		    pNext = pAfterThis->pNext;
201cdf0e10cSrcweir 		    pAfterThis->pNext = this;
202cdf0e10cSrcweir         }
203cdf0e10cSrcweir         else
204cdf0e10cSrcweir         {   // pAfterThis not in que -> already dequed -> add to front of list
205cdf0e10cSrcweir             pNext = pFirst;
206cdf0e10cSrcweir             pFirst = this;
207cdf0e10cSrcweir         }
208cdf0e10cSrcweir 	}
209cdf0e10cSrcweir 	else	// am Ende einf�gen
210cdf0e10cSrcweir 	{
211cdf0e10cSrcweir 		pNext = NULL;
212cdf0e10cSrcweir 		if( !pFirst )
213cdf0e10cSrcweir 			pFirst = this;
214cdf0e10cSrcweir 		else
215cdf0e10cSrcweir         {
216cdf0e10cSrcweir             StatementList *pList;
217cdf0e10cSrcweir             pList = pFirst;
218cdf0e10cSrcweir             while( pList->pNext )
219cdf0e10cSrcweir 			    pList = pList->pNext;
220cdf0e10cSrcweir 		    pList->pNext = this;
221cdf0e10cSrcweir 		}
222cdf0e10cSrcweir 	}
223cdf0e10cSrcweir }
224cdf0e10cSrcweir 
Advance()225cdf0e10cSrcweir void StatementList::Advance()
226cdf0e10cSrcweir {	// pFirst ist static!
227cdf0e10cSrcweir 	pFirst = pNext;
228cdf0e10cSrcweir 	bStatementInQue = sal_False;
229cdf0e10cSrcweir 	pNext = NULL;
230cdf0e10cSrcweir }
231cdf0e10cSrcweir 
232cdf0e10cSrcweir 
~StatementList()233cdf0e10cSrcweir StatementList::~StatementList()
234cdf0e10cSrcweir {
235cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
236cdf0e10cSrcweir 	m_pDbgWin->AddText( "Deleting \n" );
237cdf0e10cSrcweir #endif
238cdf0e10cSrcweir 	DBG_ASSERT(!bReadingCommands,"Deleting commands while reading them!");
239cdf0e10cSrcweir }
240cdf0e10cSrcweir 
GetDocWin(sal_uInt16 nNr)241cdf0e10cSrcweir Window* StatementList::GetDocWin( sal_uInt16 nNr )
242cdf0e10cSrcweir {
243cdf0e10cSrcweir 	Window* pBase = Application::GetFirstTopLevelWindow();
244cdf0e10cSrcweir 
245cdf0e10cSrcweir     while ( pBase )
246cdf0e10cSrcweir     {
247cdf0e10cSrcweir         if ( IsDocWin( pBase ) )
248cdf0e10cSrcweir         {
249cdf0e10cSrcweir             if ( !nNr )
250cdf0e10cSrcweir                 return pBase;
251cdf0e10cSrcweir             nNr--;
252cdf0e10cSrcweir         }
253cdf0e10cSrcweir         pBase = Application::GetNextTopLevelWindow( pBase );
254cdf0e10cSrcweir     }
255cdf0e10cSrcweir     return NULL;
256cdf0e10cSrcweir }
257cdf0e10cSrcweir 
GetDocFrameCount()258cdf0e10cSrcweir sal_uInt16 StatementList::GetDocFrameCount()
259cdf0e10cSrcweir {
260cdf0e10cSrcweir 	Window* pBase = Application::GetFirstTopLevelWindow();
261cdf0e10cSrcweir     sal_uInt16 nCount = 0;
262cdf0e10cSrcweir 
263cdf0e10cSrcweir     while ( pBase )
264cdf0e10cSrcweir     {
265cdf0e10cSrcweir         if ( IsDocFrame( pBase ) )
266cdf0e10cSrcweir             nCount++;
267cdf0e10cSrcweir         pBase = Application::GetNextTopLevelWindow( pBase );
268cdf0e10cSrcweir     }
269cdf0e10cSrcweir     return nCount;
270cdf0e10cSrcweir }
271cdf0e10cSrcweir 
GetDocWinCount()272cdf0e10cSrcweir sal_uInt16 StatementList::GetDocWinCount()
273cdf0e10cSrcweir {
274cdf0e10cSrcweir 	Window* pBase = Application::GetFirstTopLevelWindow();
275cdf0e10cSrcweir     sal_uInt16 nCount = 0;
276cdf0e10cSrcweir 
277cdf0e10cSrcweir     while ( pBase )
278cdf0e10cSrcweir     {
279cdf0e10cSrcweir         if ( IsDocWin( pBase ) )
280cdf0e10cSrcweir             nCount++;
281cdf0e10cSrcweir         pBase = Application::GetNextTopLevelWindow( pBase );
282cdf0e10cSrcweir     }
283cdf0e10cSrcweir     return nCount;
284cdf0e10cSrcweir }
285cdf0e10cSrcweir 
SearchAllWin(Window * pBase,Search & aSearch,sal_Bool MaybeBase)286cdf0e10cSrcweir Window* StatementList::SearchAllWin( Window *pBase, Search &aSearch, sal_Bool MaybeBase )
287cdf0e10cSrcweir {
288cdf0e10cSrcweir 
289cdf0e10cSrcweir 	if ( !pBase && !aSearch.HasSearchFlag( SEARCH_NO_TOPLEVEL_WIN ) )
290cdf0e10cSrcweir 	{
291cdf0e10cSrcweir         sal_Bool bSearchFocusFirst = aSearch.HasSearchFlag( SEARCH_FOCUS_FIRST );
292cdf0e10cSrcweir 
293cdf0e10cSrcweir 		Window *pControl = NULL;
294cdf0e10cSrcweir         if ( bSearchFocusFirst )
295cdf0e10cSrcweir         {
296cdf0e10cSrcweir             // first test Parent of Focus Window
297cdf0e10cSrcweir             pBase = Application::GetFocusWindow();
298cdf0e10cSrcweir             if ( pBase )
299cdf0e10cSrcweir             {
300cdf0e10cSrcweir                 DBG_ASSERT( WinPtrValid( pBase ), "GetFocusWindow is no valid WindowPointer" );
301cdf0e10cSrcweir                 Window *pPParent = pBase;
302cdf0e10cSrcweir                 while ( pPParent->GET_REAL_PARENT() )
303cdf0e10cSrcweir                     pPParent = pPParent->GET_REAL_PARENT();
304cdf0e10cSrcweir 
305cdf0e10cSrcweir //              if ( !IsFirstDocFrame( pPParent ) )
306cdf0e10cSrcweir //              {
307cdf0e10cSrcweir                     // get overlap window. Will be dialog else document itself
308cdf0e10cSrcweir                     pBase = pBase->GetWindow( WINDOW_OVERLAP );
309cdf0e10cSrcweir 
310cdf0e10cSrcweir                     // set flag to find disabled elements.
311cdf0e10cSrcweir                     // This is better than an enabled one on another Window
312cdf0e10cSrcweir                     aSearch.AddSearchFlags( SEARCH_FIND_DISABLED );
313cdf0e10cSrcweir 
314cdf0e10cSrcweir                     // search on current Dialog first
315cdf0e10cSrcweir                     pControl = SearchAllWin( pBase, aSearch );
316cdf0e10cSrcweir 
317cdf0e10cSrcweir                     // search on current Document
318cdf0e10cSrcweir                     if ( !pControl && pBase != pPParent )
319cdf0e10cSrcweir                         pControl = SearchAllWin( pPParent, aSearch );
320cdf0e10cSrcweir 
321cdf0e10cSrcweir                     aSearch.RemoveSearchFlags( SEARCH_FIND_DISABLED );
322cdf0e10cSrcweir 
323cdf0e10cSrcweir                     if ( pControl )
324cdf0e10cSrcweir 			            return pControl;
325cdf0e10cSrcweir //              }
326cdf0e10cSrcweir             }
327cdf0e10cSrcweir         }
328cdf0e10cSrcweir 
329cdf0e10cSrcweir 		pBase = Application::GetFirstTopLevelWindow();
330cdf0e10cSrcweir 
331cdf0e10cSrcweir         // Skip FirstDocFrame
332cdf0e10cSrcweir //      if ( bSearchFocusFirst && IsFirstDocFrame( pBase ) )
333cdf0e10cSrcweir //          pBase = Application::GetNextTopLevelWindow( pBase );
334cdf0e10cSrcweir 
335cdf0e10cSrcweir 		while ( pBase )
336cdf0e10cSrcweir 		{
337cdf0e10cSrcweir 			pControl = SearchAllWin( pBase, aSearch );
338cdf0e10cSrcweir 			if ( pControl )
339cdf0e10cSrcweir 				return pControl;
340cdf0e10cSrcweir 
341cdf0e10cSrcweir 			pBase = Application::GetNextTopLevelWindow( pBase );
342cdf0e10cSrcweir             // Skip FirstDocFrame
343cdf0e10cSrcweir //          if ( bSearchFocusFirst && IsFirstDocFrame( pBase ) )
344cdf0e10cSrcweir //              pBase = Application::GetNextTopLevelWindow( pBase );
345cdf0e10cSrcweir 		}
346cdf0e10cSrcweir 		return NULL;
347cdf0e10cSrcweir 	}
348cdf0e10cSrcweir 
349cdf0e10cSrcweir 
350cdf0e10cSrcweir 	Window *pResult = NULL;
351cdf0e10cSrcweir 	pResult = SearchClientWin( pBase, aSearch, MaybeBase );
352cdf0e10cSrcweir 	if ( pResult )
353cdf0e10cSrcweir 		return pResult;
354cdf0e10cSrcweir 
355cdf0e10cSrcweir //    if ( pBase->GetType() != WINDOW_BORDERWINDOW )
356cdf0e10cSrcweir //		return NULL;
357cdf0e10cSrcweir 
358cdf0e10cSrcweir 	if ( !aSearch.HasSearchFlag( SEARCH_NOOVERLAP ) )
359cdf0e10cSrcweir 	{
360cdf0e10cSrcweir 		if ( pBase->GetWindow( WINDOW_FIRSTOVERLAP ) )
361cdf0e10cSrcweir 			pResult = SearchAllWin( pBase->GetWindow( WINDOW_FIRSTOVERLAP ), aSearch );
362cdf0e10cSrcweir 
363cdf0e10cSrcweir 		if ( !pResult && pBase->GetWindow( WINDOW_NEXT ) )
364cdf0e10cSrcweir 			pResult = SearchAllWin( pBase->GetWindow( WINDOW_NEXT ), aSearch );
365cdf0e10cSrcweir 	}
366cdf0e10cSrcweir 
367cdf0e10cSrcweir 	return pResult;
368cdf0e10cSrcweir }
369cdf0e10cSrcweir 
370cdf0e10cSrcweir 
SearchClientWin(Window * pBase,Search & aSearch,sal_Bool MaybeBase)371cdf0e10cSrcweir Window* StatementList::SearchClientWin( Window *pBase, Search &aSearch, sal_Bool MaybeBase )
372cdf0e10cSrcweir {
373cdf0e10cSrcweir 	if ( !pBase )
374cdf0e10cSrcweir 		return NULL;
375cdf0e10cSrcweir 
376cdf0e10cSrcweir 	if ( MaybeBase && aSearch.IsWinOK( pBase ) )
377cdf0e10cSrcweir 		return pBase;
378cdf0e10cSrcweir 
379cdf0e10cSrcweir 	Window *pResult = NULL;
380cdf0e10cSrcweir 
381cdf0e10cSrcweir 	sal_uInt16 i;
382cdf0e10cSrcweir 	for( i = 0 ; i < pBase->GetChildCount() && !pResult; i++ )
383cdf0e10cSrcweir 		pResult = SearchClientWin( pBase->GetChild(i), aSearch );
384cdf0e10cSrcweir 
385cdf0e10cSrcweir 	return pResult;
386cdf0e10cSrcweir }
387cdf0e10cSrcweir 
388cdf0e10cSrcweir 
IsWinOK(Window * pWin)389cdf0e10cSrcweir sal_Bool SearchUID::IsWinOK( Window *pWin )
390cdf0e10cSrcweir {
391cdf0e10cSrcweir 	if ( aUId.equals( pWin->GetUniqueOrHelpId() ) )
392cdf0e10cSrcweir 	{
393cdf0e10cSrcweir 		if ( ( pWin->IsEnabled() || HasSearchFlag( SEARCH_FIND_DISABLED ) ) && pWin->IsVisible() )
394cdf0e10cSrcweir 			return sal_True;
395cdf0e10cSrcweir 		else
396cdf0e10cSrcweir 		{
397cdf0e10cSrcweir 			if ( !pMaybeResult )
398cdf0e10cSrcweir 				pMaybeResult = pWin;
399cdf0e10cSrcweir 			return sal_False;
400cdf0e10cSrcweir 		}
401cdf0e10cSrcweir 	}
402cdf0e10cSrcweir 	else if ( pWin->GetType() == WINDOW_TOOLBOX )	// Buttons and Controls on ToolBox.
403cdf0e10cSrcweir 	{
404cdf0e10cSrcweir 		ToolBox *pTB = ((ToolBox*)pWin);
405cdf0e10cSrcweir 		sal_uInt16 i;
406cdf0e10cSrcweir 		for ( i = 0; i < pTB->GetItemCount() ; i++ )
407cdf0e10cSrcweir 		{
408cdf0e10cSrcweir 			if ( aUId.equals( Str2Id( pTB->GetItemCommand(pTB->GetItemId( i )) ) ) || aUId.equals( pTB->GetHelpId(pTB->GetItemId( i )) ) )
409cdf0e10cSrcweir 			{		// ID matches.
410cdf0e10cSrcweir 				Window *pItemWin;
411cdf0e10cSrcweir 				pItemWin = pTB->GetItemWindow( pTB->GetItemId( i ) );
412cdf0e10cSrcweir 
413cdf0e10cSrcweir 				if ( bSearchButtonOnToolbox && pTB->GetItemType( i ) == TOOLBOXITEM_BUTTON && !pItemWin )
414cdf0e10cSrcweir 				{		// We got a Control, see if its valid also.
415cdf0e10cSrcweir 						// Same as above.
416cdf0e10cSrcweir 					if ( ( pTB->IsEnabled() || HasSearchFlag( SEARCH_FIND_DISABLED ) ) && pTB->IsVisible() )
417cdf0e10cSrcweir 					{	// We got a Button, see if its valid also.
418cdf0e10cSrcweir 						if ( ( pTB->IsItemEnabled(pTB->GetItemId(i)) || HasSearchFlag( SEARCH_FIND_DISABLED ) )
419cdf0e10cSrcweir 						 && pTB->IsItemVisible(pTB->GetItemId(i)) )
420cdf0e10cSrcweir 							return sal_True;	// We got a Button.
421cdf0e10cSrcweir 						else
422cdf0e10cSrcweir 						{	// better a disabled Button on a valid ToolBox than an invalid ToolBox as below
423cdf0e10cSrcweir 							pMaybeResult = pTB;
424cdf0e10cSrcweir 							return sal_False;
425cdf0e10cSrcweir 						}
426cdf0e10cSrcweir 					}
427cdf0e10cSrcweir 					else if ( !pMaybeResult )
428cdf0e10cSrcweir 					{	// invalid ToolBox
429cdf0e10cSrcweir 						pMaybeResult = pTB;
430cdf0e10cSrcweir 						return sal_False;
431cdf0e10cSrcweir 					}
432cdf0e10cSrcweir 				}
433cdf0e10cSrcweir 				if ( pItemWin )
434cdf0e10cSrcweir 				{		// We got a Control, see if its valid also.
435cdf0e10cSrcweir 						// Same as above.
436cdf0e10cSrcweir 					if ( ( pItemWin->IsEnabled() || HasSearchFlag( SEARCH_FIND_DISABLED ) ) && pItemWin->IsVisible() )
437cdf0e10cSrcweir 					{
438cdf0e10cSrcweir                         if ( !pAlternateResult )    // only take the first found ItemWindow #i35365
439cdf0e10cSrcweir 						    pAlternateResult = pItemWin;	// since we cannot return a Window here
440cdf0e10cSrcweir 						return sal_False;   // continue searching to prefer a window with the right ID #i32292
441cdf0e10cSrcweir 					}
442cdf0e10cSrcweir 					else if ( !pMaybeResult )
443cdf0e10cSrcweir 					{
444cdf0e10cSrcweir 						pMaybeResult = pItemWin;
445cdf0e10cSrcweir 						return sal_False;
446cdf0e10cSrcweir 					}
447cdf0e10cSrcweir 				}
448cdf0e10cSrcweir 			}
449cdf0e10cSrcweir 		}
450cdf0e10cSrcweir 		return sal_False;
451cdf0e10cSrcweir 	}
452cdf0e10cSrcweir 	else
453cdf0e10cSrcweir 		return sal_False;
454cdf0e10cSrcweir }
455cdf0e10cSrcweir 
SearchTree(rtl::OString aUId,sal_Bool bSearchButtonOnToolbox)456cdf0e10cSrcweir Window* StatementList::SearchTree( rtl::OString aUId ,sal_Bool bSearchButtonOnToolbox )
457cdf0e10cSrcweir {
458cdf0e10cSrcweir 	SearchUID aSearch(aUId,bSearchButtonOnToolbox);
459cdf0e10cSrcweir 
460cdf0e10cSrcweir 	Window *pResult = SearchAllWin( NULL, aSearch );
461cdf0e10cSrcweir     if ( pResult )
462cdf0e10cSrcweir 		return pResult;
463cdf0e10cSrcweir 	else if ( aSearch.GetAlternateResultWin() )
464cdf0e10cSrcweir         return aSearch.GetAlternateResultWin();
465cdf0e10cSrcweir     else
466cdf0e10cSrcweir 		return aSearch.GetMaybeWin();
467cdf0e10cSrcweir }
468cdf0e10cSrcweir 
469cdf0e10cSrcweir 
IsWinOK(Window * pWin)470cdf0e10cSrcweir sal_Bool SearchWinPtr::IsWinOK( Window *pWin )
471cdf0e10cSrcweir {
472cdf0e10cSrcweir 	return pWin == pTest;
473cdf0e10cSrcweir }
474cdf0e10cSrcweir 
WinPtrValid(Window * pTest)475cdf0e10cSrcweir sal_Bool StatementList::WinPtrValid(Window *pTest)
476cdf0e10cSrcweir {
477cdf0e10cSrcweir 	SearchWinPtr aSearch( pTest );
478cdf0e10cSrcweir 	return SearchAllWin( NULL, aSearch ) != NULL;
479cdf0e10cSrcweir }
480cdf0e10cSrcweir 
481cdf0e10cSrcweir 
IsWinOK(Window * pWin)482cdf0e10cSrcweir sal_Bool SearchRT::IsWinOK( Window *pWin )
483cdf0e10cSrcweir {
484cdf0e10cSrcweir 	if ( pWin->IsVisible() && pWin->GetType() == mnRT )
485cdf0e10cSrcweir     {
486cdf0e10cSrcweir         mnCount++;
487cdf0e10cSrcweir         if ( mnSkip )
488cdf0e10cSrcweir         {
489cdf0e10cSrcweir             mnSkip--;
490cdf0e10cSrcweir             return sal_False;
491cdf0e10cSrcweir         }
492cdf0e10cSrcweir         else
493cdf0e10cSrcweir             return sal_True;
494cdf0e10cSrcweir     }
495cdf0e10cSrcweir 	return sal_False;
496cdf0e10cSrcweir }
497cdf0e10cSrcweir 
GetWinByRT(Window * pBase,WindowType nRT,sal_Bool MaybeBase,sal_uInt16 nSkip,sal_Bool bSearchAll)498cdf0e10cSrcweir Window* StatementList::GetWinByRT( Window *pBase, WindowType nRT, sal_Bool MaybeBase, sal_uInt16 nSkip, sal_Bool bSearchAll )
499cdf0e10cSrcweir {
500cdf0e10cSrcweir 	SearchRT aSearch( nRT, 0, nSkip );
501cdf0e10cSrcweir     if ( bSearchAll )
502cdf0e10cSrcweir         aSearch.AddSearchFlags( SEARCH_FOCUS_FIRST | SEARCH_FIND_DISABLED );
503cdf0e10cSrcweir     else
504cdf0e10cSrcweir         aSearch.AddSearchFlags( SEARCH_NOOVERLAP | SEARCH_NO_TOPLEVEL_WIN );
505cdf0e10cSrcweir 
506cdf0e10cSrcweir 	return SearchAllWin( pBase, aSearch, MaybeBase );
507cdf0e10cSrcweir }
508cdf0e10cSrcweir 
CountWinByRT(Window * pBase,WindowType nRT,sal_Bool MaybeBase)509cdf0e10cSrcweir sal_uInt16 StatementList::CountWinByRT( Window *pBase, WindowType nRT, sal_Bool MaybeBase )
510cdf0e10cSrcweir {
511cdf0e10cSrcweir 	SearchRT aSearch( nRT, SEARCH_NOOVERLAP | SEARCH_NO_TOPLEVEL_WIN, 0xFFFF );
512cdf0e10cSrcweir 
513cdf0e10cSrcweir 	SearchAllWin( pBase, aSearch, MaybeBase );
514cdf0e10cSrcweir     return aSearch.GetCount();
515cdf0e10cSrcweir }
516cdf0e10cSrcweir 
IsWinOK(Window * pWin)517cdf0e10cSrcweir sal_Bool SearchScroll::IsWinOK( Window *pWin )
518cdf0e10cSrcweir {
519cdf0e10cSrcweir     if ( SearchRT::IsWinOK( pWin ) )
520cdf0e10cSrcweir     {
521cdf0e10cSrcweir         DBG_ASSERT( pWin->GetStyle() & ( WB_HORZ | WB_VERT ), "Nither WB_HORZ nor WB_VERT set on ScrollBar");
522cdf0e10cSrcweir         return (( pWin->GetStyle() & WB_HORZ ) && ( nDirection == CONST_ALIGN_BOTTOM ))
523cdf0e10cSrcweir             || (( pWin->GetStyle() & WB_VERT ) && ( nDirection == CONST_ALIGN_RIGHT ));
524cdf0e10cSrcweir     }
525cdf0e10cSrcweir 	return sal_False;
526cdf0e10cSrcweir }
527cdf0e10cSrcweir 
GetScrollBar(Window * pBase,sal_uInt16 nDirection,sal_Bool MaybeBase)528cdf0e10cSrcweir ScrollBar* StatementList::GetScrollBar( Window *pBase, sal_uInt16 nDirection, sal_Bool MaybeBase )
529cdf0e10cSrcweir {
530cdf0e10cSrcweir 	SearchScroll aSearch( nDirection, SEARCH_NOOVERLAP | SEARCH_NO_TOPLEVEL_WIN );
531cdf0e10cSrcweir 
532cdf0e10cSrcweir 	return (ScrollBar*)SearchAllWin( pBase, aSearch, MaybeBase );
533cdf0e10cSrcweir }
534cdf0e10cSrcweir 
535cdf0e10cSrcweir 
IsWinOK(Window * pWin)536cdf0e10cSrcweir sal_Bool SearchPopupFloatingWin::IsWinOK( Window *pWin )
537cdf0e10cSrcweir {
538cdf0e10cSrcweir 	return pWin->IsVisible() && pWin->GetType() == WINDOW_FLOATINGWINDOW && ((FloatingWindow*)pWin)->IsInPopupMode();
539cdf0e10cSrcweir }
540cdf0e10cSrcweir 
GetPopupFloatingWin(sal_Bool MaybeBase)541cdf0e10cSrcweir Window* StatementList::GetPopupFloatingWin( sal_Bool MaybeBase )
542cdf0e10cSrcweir {
543cdf0e10cSrcweir 	SearchPopupFloatingWin aSearch;
544cdf0e10cSrcweir 
545cdf0e10cSrcweir 	return SearchAllWin( NULL, aSearch, MaybeBase );
546cdf0e10cSrcweir }
547cdf0e10cSrcweir 
548cdf0e10cSrcweir 
GetMatchingMenu(Window * pWin,Menu * pBaseMenu)549cdf0e10cSrcweir Menu* StatementList::GetMatchingMenu( Window* pWin, Menu* pBaseMenu )
550cdf0e10cSrcweir {
551cdf0e10cSrcweir     if ( pBaseMenu )
552cdf0e10cSrcweir     {
553cdf0e10cSrcweir         if ( pBaseMenu->GetWindow() == pWin )
554cdf0e10cSrcweir             return pBaseMenu;
555cdf0e10cSrcweir 
556cdf0e10cSrcweir         sal_uInt16 i;
557cdf0e10cSrcweir //        while ( pBaseMenu )
558cdf0e10cSrcweir //        {
559cdf0e10cSrcweir             i = 0;
560cdf0e10cSrcweir             while ( i < pBaseMenu->GetItemCount() )
561cdf0e10cSrcweir             {
562cdf0e10cSrcweir                 PopupMenu* pPopup = pBaseMenu->GetPopupMenu( pBaseMenu->GetItemId( i ) );
563cdf0e10cSrcweir                 if ( pPopup && pPopup->GetWindow() )
564cdf0e10cSrcweir                 {
565cdf0e10cSrcweir                     if ( pPopup->GetWindow() == pWin )
566cdf0e10cSrcweir                         return pPopup;
567cdf0e10cSrcweir                     else
568cdf0e10cSrcweir                     {
569cdf0e10cSrcweir                         pBaseMenu = pPopup;
570cdf0e10cSrcweir                         i = 0;
571cdf0e10cSrcweir                     }
572cdf0e10cSrcweir                 }
573cdf0e10cSrcweir                 else
574cdf0e10cSrcweir                     i++;
575cdf0e10cSrcweir             }
576cdf0e10cSrcweir //        }
577cdf0e10cSrcweir     }
578cdf0e10cSrcweir     else
579cdf0e10cSrcweir     {
580cdf0e10cSrcweir         if ( PopupMenu::GetActivePopupMenu() )
581cdf0e10cSrcweir         {
582cdf0e10cSrcweir             Menu* pMenu = GetMatchingMenu( pWin, PopupMenu::GetActivePopupMenu() );
583cdf0e10cSrcweir             if ( pMenu )
584cdf0e10cSrcweir                 return pMenu;
585cdf0e10cSrcweir         }
586cdf0e10cSrcweir 
587cdf0e10cSrcweir         sal_uInt16 nSkip = 0;
588cdf0e10cSrcweir         Window* pMenuBarWin = NULL;
589cdf0e10cSrcweir         while ( (pMenuBarWin = GetWinByRT( NULL, WINDOW_MENUBARWINDOW, sal_True, nSkip++, sal_True )) != NULL )
590cdf0e10cSrcweir         {
591cdf0e10cSrcweir             Window* pParent = pMenuBarWin->GET_REAL_PARENT();
592cdf0e10cSrcweir 	        if ( pParent && pParent->GetType() == WINDOW_BORDERWINDOW && pParent->IsVisible() )
593cdf0e10cSrcweir 	        {
594cdf0e10cSrcweir                 Menu* pMenu = NULL;
595cdf0e10cSrcweir                 // find Menu of MenuBarWindow
596cdf0e10cSrcweir 		        sal_uInt16 nCount;
597cdf0e10cSrcweir 		        for ( nCount = 0 ; nCount < pParent->GetChildCount() ; nCount++ )
598cdf0e10cSrcweir                 {
599cdf0e10cSrcweir 			        if ( pParent->GetChild( nCount )->GetType() == WINDOW_WORKWINDOW )
600cdf0e10cSrcweir 				        pMenu = ((WorkWindow*)(pParent->GetChild( nCount )))->GetMenuBar();
601cdf0e10cSrcweir                 }
602cdf0e10cSrcweir                 if ( pMenu )
603cdf0e10cSrcweir                 {
604cdf0e10cSrcweir                     // check for menu bar in Task Window
605cdf0e10cSrcweir                     if ( pMenuBarWin == pWin )
606cdf0e10cSrcweir                         return pMenu;
607cdf0e10cSrcweir 
608cdf0e10cSrcweir                     // search submenues
609cdf0e10cSrcweir                     pMenu = GetMatchingMenu( pWin, pMenu );
610cdf0e10cSrcweir                     if ( pMenu )
611cdf0e10cSrcweir                         return pMenu;
612cdf0e10cSrcweir                 }
613cdf0e10cSrcweir             }
614cdf0e10cSrcweir         }
615cdf0e10cSrcweir     }
616cdf0e10cSrcweir     return NULL;
617cdf0e10cSrcweir }
618cdf0e10cSrcweir 
619cdf0e10cSrcweir 
IsWinOK(Window * pWin)620cdf0e10cSrcweir sal_Bool SearchActive::IsWinOK( Window *pWin )
621cdf0e10cSrcweir {
622cdf0e10cSrcweir //	return pWin->IsVisible() && ( (nRT == WINDOW_ANYTYPE && IsDialog(pWin) ) || pWin->GetType() == nRT )  && (nRT == WINDOW_FILEDIALOG || nRT == WINDOW_PATHDIALOG || nRT == WINDOW_PRINTDIALOG || nRT == WINDOW_PRINTERSETUPDIALOG || nRT == WINDOW_COLORDIALOG || ((SystemWindow*)pWin)->IsActive());
623cdf0e10cSrcweir     // only matches ResID due to problems with UNIX Window Managers
624cdf0e10cSrcweir 	return pWin->IsVisible() && ( (nRT == WINDOW_ANYTYPE && IsDialog(pWin) ) || pWin->GetType() == nRT );
625cdf0e10cSrcweir }
626cdf0e10cSrcweir 
GetActive(WindowType nRT,sal_Bool MaybeBase)627cdf0e10cSrcweir Window* StatementList::GetActive( WindowType nRT, sal_Bool MaybeBase )
628cdf0e10cSrcweir {
629cdf0e10cSrcweir 	SearchActive aSearch( nRT );
630cdf0e10cSrcweir 
631cdf0e10cSrcweir 	return SearchAllWin( NULL, aSearch, MaybeBase );
632cdf0e10cSrcweir }
633cdf0e10cSrcweir 
IsWinOK(Window * pWin)634cdf0e10cSrcweir sal_Bool SearchFadeSplitWin::IsWinOK( Window *pWin )
635cdf0e10cSrcweir {
636cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
637cdf0e10cSrcweir     if ( pWin->GetType() == WINDOW_SPLITWINDOW )
638cdf0e10cSrcweir     {
639cdf0e10cSrcweir         sal_Bool bResult;
640cdf0e10cSrcweir         WindowAlign aAlign;
641cdf0e10cSrcweir         bResult = pWin->IsVisible();
642cdf0e10cSrcweir         bResult = ((SplitWindow*)pWin)->IsFadeInButtonVisible();
643cdf0e10cSrcweir         bResult = ((SplitWindow*)pWin)->IsFadeOutButtonVisible();
644cdf0e10cSrcweir         bResult = ((SplitWindow*)pWin)->IsAutoHideButtonVisible();
645cdf0e10cSrcweir         aAlign = ((SplitWindow*)pWin)->GetAlign();
646cdf0e10cSrcweir     }
647cdf0e10cSrcweir #endif
648cdf0e10cSrcweir 	return pWin->IsVisible() && ( pWin->GetType() == WINDOW_SPLITWINDOW )
649cdf0e10cSrcweir 		&& (((SplitWindow*)pWin)->IsFadeInButtonVisible() || ((SplitWindow*)pWin)->IsFadeOutButtonVisible() )
650cdf0e10cSrcweir 		/*&& ((SplitWindow*)pWin)->IsAutoHideButtonVisible()*/ && ((SplitWindow*)pWin)->GetAlign() == nAlign;
651cdf0e10cSrcweir }
652cdf0e10cSrcweir 
GetFadeSplitWin(Window * pBase,WindowAlign nAlign,sal_Bool MaybeBase)653cdf0e10cSrcweir Window* StatementList::GetFadeSplitWin( Window *pBase, WindowAlign nAlign, sal_Bool MaybeBase )
654cdf0e10cSrcweir {
655cdf0e10cSrcweir 	SearchFadeSplitWin aSearch( nAlign );
656cdf0e10cSrcweir 
657cdf0e10cSrcweir 	if ( GetpApp()->GetAppWindow() == pBase && pBase->GetType() != WINDOW_BORDERWINDOW )
658cdf0e10cSrcweir 		pBase = pBase->GetWindow( WINDOW_OVERLAP );
659cdf0e10cSrcweir 
660cdf0e10cSrcweir 	return SearchAllWin( pBase, aSearch, MaybeBase );
661cdf0e10cSrcweir }
662cdf0e10cSrcweir 
GetMouseWin()663cdf0e10cSrcweir Window* StatementList::GetMouseWin()
664cdf0e10cSrcweir {
665cdf0e10cSrcweir 	Window *pBase = Application::GetFirstTopLevelWindow();
666cdf0e10cSrcweir 	Window *pControl = NULL;
667cdf0e10cSrcweir 	while ( pBase )
668cdf0e10cSrcweir 	{
669cdf0e10cSrcweir 		Window *pBaseFrame = pBase->GetWindow( WINDOW_OVERLAP );
670cdf0e10cSrcweir 
671cdf0e10cSrcweir 		Point aP = pBaseFrame->GetPointerPosPixel();
672cdf0e10cSrcweir 		pControl = pBaseFrame->FindWindow( aP );
673cdf0e10cSrcweir 		if ( pControl )
674cdf0e10cSrcweir 			return pControl;
675cdf0e10cSrcweir 
676cdf0e10cSrcweir 		pBase = Application::GetNextTopLevelWindow( pBase );
677cdf0e10cSrcweir 	}
678cdf0e10cSrcweir 	return NULL;
679cdf0e10cSrcweir }
680cdf0e10cSrcweir 
GetFocus(WindowType nRT,sal_Bool MaybeBase)681cdf0e10cSrcweir Window* StatementList::GetFocus( WindowType nRT, sal_Bool MaybeBase )
682cdf0e10cSrcweir {
683cdf0e10cSrcweir 
684cdf0e10cSrcweir 	if ( nRT == WINDOW_TABCONTROL )
685cdf0e10cSrcweir 	{
686cdf0e10cSrcweir 		Window *pResult = GetActive( WINDOW_TABDIALOG, MaybeBase);
687cdf0e10cSrcweir 		for( sal_uInt16 i = 0 ; pResult && i < pResult->GetChildCount(); i++ )
688cdf0e10cSrcweir 			if ( pResult->GetChild(i)->GetType() == nRT )
689cdf0e10cSrcweir 				return pResult->GetChild(i);
690cdf0e10cSrcweir 	}
691cdf0e10cSrcweir 
692cdf0e10cSrcweir 	return NULL;
693cdf0e10cSrcweir }
694cdf0e10cSrcweir 
GetAnyActive(sal_Bool MaybeBase)695cdf0e10cSrcweir Window* StatementList::GetAnyActive( sal_Bool MaybeBase )
696cdf0e10cSrcweir {
697cdf0e10cSrcweir 	Window *pControl;
698cdf0e10cSrcweir 
699cdf0e10cSrcweir 	pControl = GetActive( WINDOW_MESSBOX, MaybeBase);
700cdf0e10cSrcweir 	if ( !pControl )
701cdf0e10cSrcweir 	{
702cdf0e10cSrcweir 		pControl = GetActive( WINDOW_INFOBOX, MaybeBase);
703cdf0e10cSrcweir 	}
704cdf0e10cSrcweir 	if ( !pControl )
705cdf0e10cSrcweir 	{
706cdf0e10cSrcweir 		pControl = GetActive( WINDOW_WARNINGBOX, MaybeBase);
707cdf0e10cSrcweir 	}
708cdf0e10cSrcweir 	if ( !pControl )
709cdf0e10cSrcweir 	{
710cdf0e10cSrcweir 		pControl = GetActive( WINDOW_ERRORBOX, MaybeBase);
711cdf0e10cSrcweir 	}
712cdf0e10cSrcweir 	if ( !pControl )
713cdf0e10cSrcweir 	{
714cdf0e10cSrcweir 		pControl = GetActive( WINDOW_QUERYBOX, MaybeBase);
715cdf0e10cSrcweir 	}
716cdf0e10cSrcweir 	if ( !pControl )
717cdf0e10cSrcweir 	{
718cdf0e10cSrcweir 		pControl = GetActive( WINDOW_BUTTONDIALOG, MaybeBase);
719cdf0e10cSrcweir 	}
720cdf0e10cSrcweir 	if ( !pControl )
721cdf0e10cSrcweir 	{
722cdf0e10cSrcweir 		pControl = GetActive( WINDOW_FILEDIALOG, MaybeBase);
723cdf0e10cSrcweir 	}
724cdf0e10cSrcweir 	if ( !pControl )
725cdf0e10cSrcweir 	{
726cdf0e10cSrcweir 		pControl = GetActive( WINDOW_PATHDIALOG, MaybeBase);
727cdf0e10cSrcweir 	}
728cdf0e10cSrcweir 	if ( !pControl )
729cdf0e10cSrcweir 	{
730cdf0e10cSrcweir 		pControl = GetActive( WINDOW_PRINTDIALOG, MaybeBase);
731cdf0e10cSrcweir 	}
732cdf0e10cSrcweir 	if ( !pControl )
733cdf0e10cSrcweir 	{
734cdf0e10cSrcweir 		pControl = GetActive( WINDOW_PRINTERSETUPDIALOG, MaybeBase);
735cdf0e10cSrcweir 	}
736cdf0e10cSrcweir 	if ( !pControl )
737cdf0e10cSrcweir 	{
738cdf0e10cSrcweir 		pControl = GetActive( WINDOW_COLORDIALOG, MaybeBase);
739cdf0e10cSrcweir 	}
740cdf0e10cSrcweir 	if ( !pControl )
741cdf0e10cSrcweir 	{
742cdf0e10cSrcweir 		pControl = GetFocus( WINDOW_TABCONTROL, MaybeBase);
743cdf0e10cSrcweir 	}
744cdf0e10cSrcweir 
745cdf0e10cSrcweir 	return pControl;
746cdf0e10cSrcweir }
747cdf0e10cSrcweir 
SetFirstDocFrame(Window * pWin)748cdf0e10cSrcweir void StatementList::SetFirstDocFrame( Window* pWin )
749cdf0e10cSrcweir {
750cdf0e10cSrcweir 	DBG_ASSERT( IsDocFrame( pWin ), "Non Document Frame set as first Document Frame" );
751cdf0e10cSrcweir 	pFirstDocFrame = pWin;
752cdf0e10cSrcweir }
753cdf0e10cSrcweir 
GetFirstDocFrame()754cdf0e10cSrcweir Window* StatementList::GetFirstDocFrame()
755cdf0e10cSrcweir {
756cdf0e10cSrcweir 
757cdf0e10cSrcweir 	if ( pFirstDocFrame && !WinPtrValid( pFirstDocFrame ) )
758cdf0e10cSrcweir 		pFirstDocFrame = NULL;
759cdf0e10cSrcweir     if ( pFirstDocFrame && !pFirstDocFrame->IsVisible() )
760cdf0e10cSrcweir         pFirstDocFrame = NULL;
761cdf0e10cSrcweir 	if ( pFirstDocFrame && !IsDocFrame( pFirstDocFrame ) )
762cdf0e10cSrcweir         pFirstDocFrame = NULL;
763cdf0e10cSrcweir 	if ( !pFirstDocFrame )
764cdf0e10cSrcweir 	{
765cdf0e10cSrcweir 		Window* pBase = Application::GetFirstTopLevelWindow();
766cdf0e10cSrcweir 		while ( pBase && !IsDocFrame( pBase ) )
767cdf0e10cSrcweir 			pBase = Application::GetNextTopLevelWindow( pBase );
768cdf0e10cSrcweir 
769cdf0e10cSrcweir         if ( pBase )
770cdf0e10cSrcweir 			SetFirstDocFrame( pBase );
771cdf0e10cSrcweir 
772cdf0e10cSrcweir         if ( !pBase )   // find just something
773cdf0e10cSrcweir         {
774cdf0e10cSrcweir 		    pBase = Application::GetFirstTopLevelWindow();
775cdf0e10cSrcweir 		    while ( pBase && !pBase->IsVisible() )
776cdf0e10cSrcweir 			    pBase = Application::GetNextTopLevelWindow( pBase );
777cdf0e10cSrcweir 
778cdf0e10cSrcweir             return pBase;   // just for now, later we will hopefully have a Window
779cdf0e10cSrcweir         }
780cdf0e10cSrcweir 	}
781cdf0e10cSrcweir 	return pFirstDocFrame;
782cdf0e10cSrcweir }
783cdf0e10cSrcweir 
IsFirstDocFrame(Window * pWin)784cdf0e10cSrcweir sal_Bool StatementList::IsFirstDocFrame( Window* pWin )
785cdf0e10cSrcweir {
786cdf0e10cSrcweir 	return pWin && ( pWin == GetFirstDocFrame() || ( GetFirstDocFrame() && pWin == GetFirstDocFrame()->GetWindow( WINDOW_CLIENT ) ) ) && ( GetFirstDocFrame() && IsDocFrame( GetFirstDocFrame() ) );
787cdf0e10cSrcweir }
788cdf0e10cSrcweir 
GetDocFrameMenuBar(Window * pWin)789cdf0e10cSrcweir MenuBar* StatementList::GetDocFrameMenuBar( Window* pWin )
790cdf0e10cSrcweir {
791cdf0e10cSrcweir 	if ( pWin && pWin->IsVisible() && pWin->GetType() == WINDOW_BORDERWINDOW )
792cdf0e10cSrcweir 	{
793cdf0e10cSrcweir 		sal_uInt16 nCount;
794cdf0e10cSrcweir 		for ( nCount = 0 ; nCount < pWin->GetChildCount() ; nCount++ )
795cdf0e10cSrcweir         {
796cdf0e10cSrcweir 			if ( pWin->GetChild( nCount )->GetType() == WINDOW_WORKWINDOW )
797cdf0e10cSrcweir 				return ((WorkWindow*)(pWin->GetChild( nCount )))->GetMenuBar();
798cdf0e10cSrcweir         }
799cdf0e10cSrcweir 	}
800cdf0e10cSrcweir 	return NULL;
801cdf0e10cSrcweir }
802cdf0e10cSrcweir 
803cdf0e10cSrcweir // a Doc Frame is a Document or the Backing Window
IsDocFrame(Window * pWin)804cdf0e10cSrcweir sal_Bool StatementList::IsDocFrame( Window* pWin )
805cdf0e10cSrcweir {
806cdf0e10cSrcweir 	if ( pWin && pWin->IsVisible() && pWin->GetType() == WINDOW_BORDERWINDOW )
807cdf0e10cSrcweir 	{
808cdf0e10cSrcweir 		sal_uInt16 nCount;
809cdf0e10cSrcweir         sal_Bool bHasWorkWindow = sal_False;
810cdf0e10cSrcweir         sal_Bool bHasMenuBar = sal_False;
811cdf0e10cSrcweir         // #91724# it is now necessary to sort out the IME WIndow in Solaris as well.
812cdf0e10cSrcweir         // so now we check for existence of WINDOW_WORKWINDOW and newly for
813cdf0e10cSrcweir         // WINDOW_MENUBARWINDOW which contains the Menu and the close/min/max buttons
814cdf0e10cSrcweir 		for ( nCount = 0 ; nCount < pWin->GetChildCount() ; nCount++ )
815cdf0e10cSrcweir         {
816cdf0e10cSrcweir 			if ( pWin->GetChild( nCount )->GetType() == WINDOW_WORKWINDOW )
817cdf0e10cSrcweir 				bHasWorkWindow = sal_True;
818cdf0e10cSrcweir 			if ( pWin->GetChild( nCount )->GetType() == WINDOW_MENUBARWINDOW )
819cdf0e10cSrcweir 				bHasMenuBar = sal_True;
820cdf0e10cSrcweir         }
821cdf0e10cSrcweir         return bHasWorkWindow && bHasMenuBar;
822cdf0e10cSrcweir 	}
823cdf0e10cSrcweir 	return sal_False;
824cdf0e10cSrcweir }
825cdf0e10cSrcweir 
826cdf0e10cSrcweir // a Doc Win is a real document (not the Backing Window)
IsDocWin(Window * pWin)827cdf0e10cSrcweir sal_Bool StatementList::IsDocWin( Window* pWin )
828cdf0e10cSrcweir {
829cdf0e10cSrcweir 	if ( pWin && IsDocFrame( pWin ) )
830cdf0e10cSrcweir 	{
831cdf0e10cSrcweir         if ( GetDocFrameCount() != 1 )
832cdf0e10cSrcweir             return sal_True;
833cdf0e10cSrcweir         else
834cdf0e10cSrcweir         {
835cdf0e10cSrcweir             // check for the close button to see if we are the last one or only the backing Window
836cdf0e10cSrcweir             if ( GetDocFrameMenuBar( pWin ) )
837cdf0e10cSrcweir                 return GetDocFrameMenuBar( pWin )->HasCloser();
838cdf0e10cSrcweir         }
839cdf0e10cSrcweir 	}
840cdf0e10cSrcweir 	return sal_False;
841cdf0e10cSrcweir }
842cdf0e10cSrcweir 
IsIMEWin(Window * pWin)843cdf0e10cSrcweir sal_Bool StatementList::IsIMEWin( Window* pWin )    // Input Window for CJK under Solaris
844cdf0e10cSrcweir {
845cdf0e10cSrcweir 	if ( pWin && pWin->IsVisible() && pWin->GetType() == WINDOW_BORDERWINDOW )
846cdf0e10cSrcweir 	{
847cdf0e10cSrcweir 		sal_uInt16 nCount;
848cdf0e10cSrcweir         sal_Bool bHasWorkWindow = sal_False;
849cdf0e10cSrcweir         sal_Bool bHasWindow = sal_False;
850cdf0e10cSrcweir         // #91724# it is now necessary to sort out the IME WIndow in Solaris as well.
851cdf0e10cSrcweir         // so now we check for existence of WINDOW_WORKWINDOW and newly for
852cdf0e10cSrcweir         // WINDOW_WINDOW which contains the Menu and the close/min/max buttons
853cdf0e10cSrcweir 		for ( nCount = 0 ; nCount < pWin->GetChildCount() ; nCount++ )
854cdf0e10cSrcweir 			if ( pWin->GetChild( nCount )->GetType() == WINDOW_WORKWINDOW )
855cdf0e10cSrcweir 				bHasWorkWindow = sal_True;
856cdf0e10cSrcweir 		for ( nCount = 0 ; nCount < pWin->GetChildCount() ; nCount++ )
857cdf0e10cSrcweir 			if ( pWin->GetChild( nCount )->GetType() == WINDOW_WINDOW )
858cdf0e10cSrcweir 				bHasWindow = sal_True;
859cdf0e10cSrcweir         return bHasWorkWindow && !bHasWindow;
860cdf0e10cSrcweir 	}
861cdf0e10cSrcweir 	return sal_False;
862cdf0e10cSrcweir }
863cdf0e10cSrcweir 
Tree(Window * pBase,int Indent)864cdf0e10cSrcweir UniString StatementList::Tree(Window *pBase, int Indent)
865cdf0e10cSrcweir {
866cdf0e10cSrcweir 
867cdf0e10cSrcweir 	String aReturn, aSep;
868cdf0e10cSrcweir 	if ( !pBase )
869cdf0e10cSrcweir 	{
870cdf0e10cSrcweir 		aSep.AssignAscii("============================\n");
871cdf0e10cSrcweir 		aSep.ConvertLineEnd();
872cdf0e10cSrcweir 		pBase = Application::GetFirstTopLevelWindow();
873cdf0e10cSrcweir 		while ( pBase )
874cdf0e10cSrcweir 		{
875cdf0e10cSrcweir 			Window *pBaseFrame = pBase->GetWindow( WINDOW_OVERLAP );
876cdf0e10cSrcweir 
877cdf0e10cSrcweir 			aReturn += aSep;
878cdf0e10cSrcweir 			aReturn += Tree( pBaseFrame, Indent+1 );
879cdf0e10cSrcweir 
880cdf0e10cSrcweir 			pBase = Application::GetNextTopLevelWindow( pBase );
881cdf0e10cSrcweir 		}
882cdf0e10cSrcweir 		return aReturn;
883cdf0e10cSrcweir 	}
884cdf0e10cSrcweir 
885cdf0e10cSrcweir 
886cdf0e10cSrcweir 	aSep.AssignAscii("----------------------------\n");
887cdf0e10cSrcweir 	aSep.ConvertLineEnd();
888cdf0e10cSrcweir 
889cdf0e10cSrcweir 	aReturn += ClientTree( pBase, Indent );
890cdf0e10cSrcweir 
891cdf0e10cSrcweir 	if ( pBase->GetWindow( WINDOW_FIRSTOVERLAP ) )
892cdf0e10cSrcweir 	{
893cdf0e10cSrcweir 		aReturn += aSep;
894cdf0e10cSrcweir 		aReturn += Tree( pBase->GetWindow( WINDOW_FIRSTOVERLAP ), Indent+1 );
895cdf0e10cSrcweir 	}
896cdf0e10cSrcweir 
897cdf0e10cSrcweir 	if ( pBase->GetWindow( WINDOW_NEXT ) )
898cdf0e10cSrcweir 	{
899cdf0e10cSrcweir 		aReturn += aSep;
900cdf0e10cSrcweir 		aReturn += Tree( pBase->GetWindow( WINDOW_NEXT ), Indent );
901cdf0e10cSrcweir 	}
902cdf0e10cSrcweir 
903cdf0e10cSrcweir 	return aReturn;
904cdf0e10cSrcweir }
905cdf0e10cSrcweir 
ClientTree(Window * pBase,int Indent)906cdf0e10cSrcweir String StatementList::ClientTree(Window *pBase, int Indent)
907cdf0e10cSrcweir {
908cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
909cdf0e10cSrcweir #define WRITE(Text) { m_pDbgWin->AddText(Text); aReturn += Text; }
910cdf0e10cSrcweir #define WRITEc(Text) { m_pDbgWin->AddText(Text); aReturn.AppendAscii(Text); }
911cdf0e10cSrcweir #else
912cdf0e10cSrcweir #define WRITE(Text) { aReturn += Text; }
913cdf0e10cSrcweir #define WRITEc(Text) { aReturn.AppendAscii(Text); }
914cdf0e10cSrcweir #endif
915cdf0e10cSrcweir 
916cdf0e10cSrcweir 	String sIndent,aText,aReturn;
917cdf0e10cSrcweir 	sIndent.Expand(sal::static_int_cast< xub_StrLen >(2*Indent));
918cdf0e10cSrcweir 
919cdf0e10cSrcweir 	aText = pBase->GetText();
920cdf0e10cSrcweir 
921cdf0e10cSrcweir 
922cdf0e10cSrcweir 	UniString t1,t2;t1 = CUniString("\n"); t2 = CUniString("\\n");
923cdf0e10cSrcweir 	aText.SearchAndReplaceAll(t1,t2 );
924cdf0e10cSrcweir 
925cdf0e10cSrcweir 	WRITE(sIndent);
926cdf0e10cSrcweir 
927cdf0e10cSrcweir 	if (pBase->IsDialog())
928cdf0e10cSrcweir 	{
929cdf0e10cSrcweir 		WRITEc("*(Dialog(TH))");
930cdf0e10cSrcweir 	}
931cdf0e10cSrcweir 	if (IsDialog( pBase ))
932cdf0e10cSrcweir 	{
933cdf0e10cSrcweir 		WRITEc("*(Dialog(GH))");
934cdf0e10cSrcweir 	}
935cdf0e10cSrcweir 	if (pBase->HasFocus())
936cdf0e10cSrcweir 	{
937cdf0e10cSrcweir 		WRITEc("*(Focus)");
938cdf0e10cSrcweir 	}
939cdf0e10cSrcweir 	if (!pBase->IsEnabled())
940cdf0e10cSrcweir 	{
941cdf0e10cSrcweir 		WRITEc("*(Disab)");
942cdf0e10cSrcweir 	}
943cdf0e10cSrcweir 	if (pBase->IsVisible())
944cdf0e10cSrcweir 	{
945cdf0e10cSrcweir 		WRITEc("*(Visible)");
946cdf0e10cSrcweir 	}
947cdf0e10cSrcweir 	if ( IsDialog(pBase) && ((SystemWindow*)pBase)->IsActive() )
948cdf0e10cSrcweir 	{
949cdf0e10cSrcweir 		WRITEc("*(Active)");
950cdf0e10cSrcweir 	}
951cdf0e10cSrcweir 	if ( pBase->GetStyle() & WB_CLOSEABLE )
952cdf0e10cSrcweir 	{
953cdf0e10cSrcweir 		WRITEc("*(Closable)");
954cdf0e10cSrcweir 	}
955cdf0e10cSrcweir 	if ( pBase->GetType() == WINDOW_DOCKINGWINDOW &&
956cdf0e10cSrcweir 			((((DockingWindow*)pBase)->GetFloatStyle()) & WB_CLOSEABLE) )
957cdf0e10cSrcweir 	{
958cdf0e10cSrcweir 		WRITEc("*(Closable Docking in Floatingstyle)");
959cdf0e10cSrcweir 	}
960cdf0e10cSrcweir 	if ( pBase->GetStyle() & WB_DOCKABLE )
961cdf0e10cSrcweir 	{
962cdf0e10cSrcweir 		WRITEc("*(Dockable)");
963cdf0e10cSrcweir 	}
964cdf0e10cSrcweir 	if ( pBase->GetType() == WINDOW_SPLITWINDOW &&
965cdf0e10cSrcweir 			(((SplitWindow*)pBase)->IsFadeInButtonVisible() || ((SplitWindow*)pBase)->IsFadeOutButtonVisible()) )
966cdf0e10cSrcweir 	{
967cdf0e10cSrcweir 		WRITEc("*(FadeIn/Out)");
968cdf0e10cSrcweir 	}
969cdf0e10cSrcweir 	WRITEc("Text: ");
970cdf0e10cSrcweir 	WRITE(aText);
971cdf0e10cSrcweir 	WRITEc("\n");
972cdf0e10cSrcweir 
973cdf0e10cSrcweir 	WRITE(sIndent);
974cdf0e10cSrcweir 	WRITEc("UId : ");
975cdf0e10cSrcweir 	WRITE(Id2Str(pBase->GetUniqueOrHelpId()));
976cdf0e10cSrcweir 	WRITEc(":0x");
977cdf0e10cSrcweir     WRITE(
978cdf0e10cSrcweir         String::CreateFromInt64(
979cdf0e10cSrcweir             sal::static_int_cast< sal_Int64 >(
980cdf0e10cSrcweir                 reinterpret_cast< sal_IntPtr >(pBase)),
981cdf0e10cSrcweir             16 ));
982cdf0e10cSrcweir 	WRITEc(":");
983cdf0e10cSrcweir 	WRITE(pBase->GetQuickHelpText());
984cdf0e10cSrcweir 	WRITEc(":");
985cdf0e10cSrcweir 	WRITE(pBase->GetHelpText());
986cdf0e10cSrcweir 	WRITEc("\n");
987cdf0e10cSrcweir 
988cdf0e10cSrcweir 	WRITE(sIndent);
989cdf0e10cSrcweir 	WRITEc("RTyp: ");
990cdf0e10cSrcweir 	WRITE(MakeStringNumber(TypeKenn,pBase->GetType()));
991cdf0e10cSrcweir     if ( pBase->GetType() == WINDOW_CONTROL )
992cdf0e10cSrcweir     {
993cdf0e10cSrcweir         if ( dynamic_cast< svt::EditBrowseBox* >(pBase) )
994cdf0e10cSrcweir             WRITEc("/BrowseBox")
995cdf0e10cSrcweir         else if ( dynamic_cast< ValueSet* >(pBase) )
996cdf0e10cSrcweir             WRITEc("/ValueSet")
997cdf0e10cSrcweir         else if ( dynamic_cast< svt::ORoadmap* >(pBase) )
998cdf0e10cSrcweir             WRITEc("/RoadMap")
999cdf0e10cSrcweir         else if ( dynamic_cast< svt::IExtensionListBox* >(pBase) )
1000cdf0e10cSrcweir             WRITEc("/ExtensionListBox")
1001cdf0e10cSrcweir         else if ( dynamic_cast< svt::table::TableControl* >(pBase) )
1002cdf0e10cSrcweir             WRITEc("/TableControl")
1003cdf0e10cSrcweir         else
1004cdf0e10cSrcweir             WRITEc("/Unknown")
1005cdf0e10cSrcweir     }
1006cdf0e10cSrcweir 	WRITEc("\n");
1007cdf0e10cSrcweir 
1008cdf0e10cSrcweir 	aReturn.ConvertLineEnd();
1009cdf0e10cSrcweir 	sal_uInt16 i;
1010cdf0e10cSrcweir 	for (i = 0 ; i < pBase->GetChildCount() ; i++)
1011cdf0e10cSrcweir 	{
1012cdf0e10cSrcweir 		aReturn += ClientTree(pBase->GetChild(i),Indent+1);
1013cdf0e10cSrcweir 	}
1014cdf0e10cSrcweir 	return aReturn;
1015cdf0e10cSrcweir }
1016cdf0e10cSrcweir 
1017cdf0e10cSrcweir 
CheckWindowWait()1018cdf0e10cSrcweir sal_Bool StatementList::CheckWindowWait()
1019cdf0e10cSrcweir {
1020cdf0e10cSrcweir 	static Time StartTime = Time(0L);	// Abbruch wenn Fenster absolut nicht schliesst.
1021cdf0e10cSrcweir 	if ( StartTime == Time(0L) )
1022cdf0e10cSrcweir 		StartTime = Time();
1023cdf0e10cSrcweir 
1024cdf0e10cSrcweir 	if ( pWindowWaitPointer )
1025cdf0e10cSrcweir 	{
1026cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
1027cdf0e10cSrcweir 		m_pDbgWin->AddText( "Waiting for Window to close ... " );
1028cdf0e10cSrcweir #endif
1029cdf0e10cSrcweir 		if ( WinPtrValid(pWindowWaitPointer) && IS_WINP_CLOSING(pWindowWaitPointer) )
1030cdf0e10cSrcweir 		{
1031cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
1032cdf0e10cSrcweir 			m_pDbgWin->AddText( Id2Str(aWindowWaitUId).AppendAscii(" Still Open. RType=") );
1033cdf0e10cSrcweir 			m_pDbgWin->AddText( String::CreateFromInt32( pWindowWaitPointer->GetType() ).AppendAscii("\n") );
1034cdf0e10cSrcweir #endif
1035cdf0e10cSrcweir 
1036cdf0e10cSrcweir 			// Ist die Zeit schonn abgelaufen?
1037cdf0e10cSrcweir 			if ( StartTime + Time(0,0,10) < Time() )	// 10 Sekunden reichen wohl
1038cdf0e10cSrcweir 			{
1039cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
1040cdf0e10cSrcweir 				m_pDbgWin->AddText( "Close timed out. Going on!! " );
1041cdf0e10cSrcweir #endif
1042cdf0e10cSrcweir 				pWindowWaitPointer->SetHelpId(aWindowWaitOldHelpId);
1043cdf0e10cSrcweir 				pWindowWaitPointer->SetUniqueId(aWindowWaitOldUniqueId);
1044cdf0e10cSrcweir 
1045cdf0e10cSrcweir 				aWindowWaitUId = rtl::OString();
1046cdf0e10cSrcweir 				pWindowWaitPointer = NULL;
1047cdf0e10cSrcweir 				StartTime = Time(0L);
1048cdf0e10cSrcweir 				return sal_True;
1049cdf0e10cSrcweir 			}
1050cdf0e10cSrcweir 
1051cdf0e10cSrcweir 			return sal_False;
1052cdf0e10cSrcweir 		}
1053cdf0e10cSrcweir 		pWindowWaitPointer = NULL;
1054cdf0e10cSrcweir 		aWindowWaitUId = rtl::OString();
1055cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
1056cdf0e10cSrcweir 		m_pDbgWin->AddText( "Closed, Going on.\n" );
1057cdf0e10cSrcweir #endif
1058cdf0e10cSrcweir 	}
1059cdf0e10cSrcweir 	StartTime = Time(0L);
1060cdf0e10cSrcweir 	return sal_True;
1061cdf0e10cSrcweir }
1062cdf0e10cSrcweir 
ReportError(String aMessage)1063cdf0e10cSrcweir void StatementList::ReportError(String aMessage)
1064cdf0e10cSrcweir {
1065cdf0e10cSrcweir 	ReportError ( rtl::OString(), aMessage );
1066cdf0e10cSrcweir }
1067cdf0e10cSrcweir 
ReportError(rtl::OString aUId,String aMessage)1068cdf0e10cSrcweir void StatementList::ReportError(rtl::OString aUId, String aMessage)
1069cdf0e10cSrcweir {
1070cdf0e10cSrcweir 	pRet->GenError ( aUId, aMessage );
1071cdf0e10cSrcweir 	IsError = sal_True;
1072cdf0e10cSrcweir }
1073cdf0e10cSrcweir 
ReportError(String aMessage,sal_uLong nWhatever)1074cdf0e10cSrcweir void StatementList::ReportError(String aMessage, sal_uLong nWhatever)
1075cdf0e10cSrcweir {
1076cdf0e10cSrcweir 	ReportError ( aMessage.AppendAscii(" ").Append(UniString::CreateFromInt32(nWhatever)));
1077cdf0e10cSrcweir }
1078cdf0e10cSrcweir 
DirectLog(sal_uLong nType,String aMessage)1079cdf0e10cSrcweir void StatementList::DirectLog( sal_uLong nType, String aMessage )
1080cdf0e10cSrcweir {
1081cdf0e10cSrcweir 	if ( pRet )
1082cdf0e10cSrcweir 		pRet->GenReturn( RET_DirectLoging, (sal_uInt16) nType, aMessage );
1083cdf0e10cSrcweir }
1084cdf0e10cSrcweir 
1085cdf0e10cSrcweir 
1086cdf0e10cSrcweir #define CALL_EVENT_WITH_NOTIFY( EventType, Event, WinP, Method )	\
1087cdf0e10cSrcweir {																	\
1088cdf0e10cSrcweir     if ( StatementList::WinPtrValid( WinP ) )						\
1089cdf0e10cSrcweir     {                                                               \
1090cdf0e10cSrcweir 	    NotifyEvent aNEvt( EventType, WinP, &Event );				\
1091cdf0e10cSrcweir 	    if ( !WinP->PreNotify( aNEvt ) )							\
1092cdf0e10cSrcweir 		    WinP->Method( Event );									\
1093cdf0e10cSrcweir     }                                                               \
1094cdf0e10cSrcweir }
1095cdf0e10cSrcweir 
ImplKeyInput(Window * pWin,KeyEvent & aKEvnt,sal_Bool bForceDirect)1096cdf0e10cSrcweir void ImplKeyInput( Window* pWin, KeyEvent &aKEvnt, sal_Bool bForceDirect )
1097cdf0e10cSrcweir {
1098cdf0e10cSrcweir 
1099cdf0e10cSrcweir     if ( StatementList::bUsePostEvents && !bForceDirect )
1100cdf0e10cSrcweir     {
1101cdf0e10cSrcweir         if ( StatementList::WinPtrValid( pWin ) )
1102cdf0e10cSrcweir         {
1103cdf0e10cSrcweir             sal_uLong nID1;
1104cdf0e10cSrcweir             sal_uLong nID2;
1105cdf0e10cSrcweir             nID1 = Application::PostKeyEvent( VCLEVENT_WINDOW_KEYINPUT, pWin, &aKEvnt );
1106cdf0e10cSrcweir             nID2 = Application::PostKeyEvent( VCLEVENT_WINDOW_KEYUP, pWin, &aKEvnt );
1107cdf0e10cSrcweir             // wait after posting both events so deleting pWin will remove the second event also
1108cdf0e10cSrcweir             ImplEventWait( nID1 );
1109cdf0e10cSrcweir             ImplEventWait( nID2 );
1110cdf0e10cSrcweir         }
1111cdf0e10cSrcweir     }
1112cdf0e10cSrcweir     else
1113cdf0e10cSrcweir     {
1114cdf0e10cSrcweir         if ( !Application::CallAccel( aKEvnt.GetKeyCode() ) )
1115cdf0e10cSrcweir 	    {
1116cdf0e10cSrcweir 	        CALL_EVENT_WITH_NOTIFY( EVENT_KEYINPUT, aKEvnt, pWin, KeyInput )
1117cdf0e10cSrcweir 
1118cdf0e10cSrcweir             KeyCode aCode = aKEvnt.GetKeyCode();
1119cdf0e10cSrcweir 		    if ( (aCode.GetCode() == KEY_CONTEXTMENU) || ((aCode.GetCode() == KEY_F10) && aCode.IsShift()) )
1120cdf0e10cSrcweir 		    {
1121cdf0e10cSrcweir         	    if ( StatementList::WinPtrValid( pWin ) )
1122cdf0e10cSrcweir                 {
1123cdf0e10cSrcweir 			        Point aPos;
1124cdf0e10cSrcweir 			        // simulate mouseposition at center of window
1125cdf0e10cSrcweir 			        Size aSize = pWin->GetOutputSize();
1126cdf0e10cSrcweir 			        aPos = Point( aSize.getWidth()/2, aSize.getHeight()/2 );
1127cdf0e10cSrcweir 
1128cdf0e10cSrcweir 			        CommandEvent aEvent( aPos, COMMAND_CONTEXTMENU, sal_False );
1129cdf0e10cSrcweir 			        ImplCommand( pWin, aEvent );
1130cdf0e10cSrcweir                 }
1131cdf0e10cSrcweir 		    }
1132cdf0e10cSrcweir 	    }
1133cdf0e10cSrcweir 
1134cdf0e10cSrcweir         CALL_EVENT_WITH_NOTIFY( EVENT_KEYUP, aKEvnt, pWin, KeyUp )
1135cdf0e10cSrcweir     }
1136cdf0e10cSrcweir };
1137cdf0e10cSrcweir 
ImplMouseMove(Window * pWin,MouseEvent & aMEvnt,sal_Bool bForceDirect)1138cdf0e10cSrcweir void ImplMouseMove( Window* pWin, MouseEvent &aMEvnt, sal_Bool bForceDirect )
1139cdf0e10cSrcweir {
1140cdf0e10cSrcweir     if ( StatementList::bUsePostEvents && !bForceDirect )
1141cdf0e10cSrcweir     {
1142cdf0e10cSrcweir         if ( StatementList::WinPtrValid( pWin ) )
1143cdf0e10cSrcweir         {
1144cdf0e10cSrcweir             sal_uLong nID;
1145cdf0e10cSrcweir             nID = Application::PostMouseEvent( VCLEVENT_WINDOW_MOUSEMOVE, pWin, &aMEvnt );
1146cdf0e10cSrcweir             ImplEventWait( nID );
1147cdf0e10cSrcweir         }
1148cdf0e10cSrcweir     }
1149cdf0e10cSrcweir     else
1150cdf0e10cSrcweir     {
1151cdf0e10cSrcweir     //	DragManager* pDragManager = DragManager::GetDragManager();
1152cdf0e10cSrcweir     //	if ( pDragManager )
1153cdf0e10cSrcweir     //		pDragManager->MouseMove( aMEvnt, pWin );
1154cdf0e10cSrcweir     //	else
1155cdf0e10cSrcweir             if ( pWin->IsTracking() )
1156cdf0e10cSrcweir 	    {
1157cdf0e10cSrcweir 		    TrackingEvent	aTEvt( aMEvnt );
1158cdf0e10cSrcweir 		    pWin->Tracking( aTEvt );
1159cdf0e10cSrcweir 	    }
1160cdf0e10cSrcweir 	    else
1161cdf0e10cSrcweir 		    CALL_EVENT_WITH_NOTIFY( EVENT_MOUSEMOVE, aMEvnt, pWin, MouseMove )
1162cdf0e10cSrcweir     }
1163cdf0e10cSrcweir };
1164cdf0e10cSrcweir 
ImplMouseButtonDown(Window * pWin,MouseEvent & aMEvnt,sal_Bool bForceDirect)1165cdf0e10cSrcweir void ImplMouseButtonDown( Window* pWin, MouseEvent &aMEvnt, sal_Bool bForceDirect )
1166cdf0e10cSrcweir {
1167cdf0e10cSrcweir     if ( StatementList::bUsePostEvents && !bForceDirect )
1168cdf0e10cSrcweir     {
1169cdf0e10cSrcweir         if ( StatementList::WinPtrValid( pWin ) )
1170cdf0e10cSrcweir         {
1171cdf0e10cSrcweir             sal_uLong nID;
1172cdf0e10cSrcweir             nID = Application::PostMouseEvent( VCLEVENT_WINDOW_MOUSEBUTTONDOWN, pWin, &aMEvnt );
1173cdf0e10cSrcweir             ImplEventWait( nID );
1174cdf0e10cSrcweir         }
1175cdf0e10cSrcweir     }
1176cdf0e10cSrcweir     else
1177cdf0e10cSrcweir     {
1178cdf0e10cSrcweir         CALL_EVENT_WITH_NOTIFY( EVENT_MOUSEBUTTONDOWN, aMEvnt, pWin, MouseButtonDown )
1179cdf0e10cSrcweir     }
1180cdf0e10cSrcweir };
1181cdf0e10cSrcweir 
ImplMouseButtonUp(Window * pWin,MouseEvent & aMEvnt,sal_Bool bForceDirect)1182cdf0e10cSrcweir void ImplMouseButtonUp( Window* pWin, MouseEvent &aMEvnt, sal_Bool bForceDirect )
1183cdf0e10cSrcweir {
1184cdf0e10cSrcweir     if ( StatementList::bUsePostEvents && !bForceDirect )
1185cdf0e10cSrcweir     {
1186cdf0e10cSrcweir         if ( StatementList::WinPtrValid( pWin ) )
1187cdf0e10cSrcweir         {
1188cdf0e10cSrcweir             sal_uLong nID;
1189cdf0e10cSrcweir             nID = Application::PostMouseEvent( VCLEVENT_WINDOW_MOUSEBUTTONUP, pWin, &aMEvnt );
1190cdf0e10cSrcweir             ImplEventWait( nID );
1191cdf0e10cSrcweir         }
1192cdf0e10cSrcweir     }
1193cdf0e10cSrcweir     else
1194cdf0e10cSrcweir     {
1195cdf0e10cSrcweir     //    	DragManager* pDragManager = DragManager::GetDragManager();
1196cdf0e10cSrcweir     //	if ( pDragManager )
1197cdf0e10cSrcweir     //		pDragManager->ButtonUp( aMEvnt, pWin );
1198cdf0e10cSrcweir     //	else
1199cdf0e10cSrcweir             if ( pWin->IsTracking() )
1200cdf0e10cSrcweir 	    {
1201cdf0e10cSrcweir 		    // siehe #64693 die Position ist f�r Toolboxen relevant
1202cdf0e10cSrcweir 		    // #60020 Jetzt hoffentlich kein GPF mehr
1203cdf0e10cSrcweir 		    // Zuerst Tracking beenden ohne Event
1204cdf0e10cSrcweir 		    pWin->EndTracking( ENDTRACK_DONTCALLHDL );
1205cdf0e10cSrcweir 		    // dann eigenen Event mit richtigem Maus-Event senden
1206cdf0e10cSrcweir 		    TrackingEvent	aTEvt( aMEvnt, ENDTRACK_END );
1207cdf0e10cSrcweir 		    pWin->Tracking( aTEvt );
1208cdf0e10cSrcweir 	    }
1209cdf0e10cSrcweir 	    else
1210cdf0e10cSrcweir 		    CALL_EVENT_WITH_NOTIFY( EVENT_MOUSEBUTTONUP, aMEvnt, pWin, MouseButtonUp )
1211cdf0e10cSrcweir     }
1212cdf0e10cSrcweir };
1213cdf0e10cSrcweir 
ImplEventWait(sal_uLong nID)1214cdf0e10cSrcweir void ImplEventWait( sal_uLong nID )
1215cdf0e10cSrcweir {
1216cdf0e10cSrcweir     while ( !Application::IsProcessedMouseOrKeyEvent( nID ) )
1217cdf0e10cSrcweir         Application::Yield();
1218cdf0e10cSrcweir }
1219cdf0e10cSrcweir 
ImplCommand(Window * pWin,CommandEvent & aCmdEvnt)1220cdf0e10cSrcweir void ImplCommand( Window* pWin, CommandEvent &aCmdEvnt )
1221cdf0e10cSrcweir {
1222cdf0e10cSrcweir 	CALL_EVENT_WITH_NOTIFY( EVENT_COMMAND, aCmdEvnt, pWin, Command )
1223cdf0e10cSrcweir };
1224cdf0e10cSrcweir 
1225