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