1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_automation.hxx"
30 #include <com/sun/star/frame/XFramesSupplier.hpp>
31 #include <com/sun/star/frame/XDispatch.hpp>
32 #include <com/sun/star/frame/XDispatchProvider.hpp>
33 #include <com/sun/star/util/XURLTransformer.hpp>
34 #include <comphelper/processfactory.hxx>
35 #include <comphelper/uieventslogger.hxx>
36 
37 #include <tools/wintypes.hxx>
38 #ifndef _DIALOG_HXX //autogen
39 #include <vcl/dialog.hxx>
40 #endif
41 #ifndef _BUTTON_HXX //autogen
42 #include <vcl/button.hxx>
43 #endif
44 #include <vcl/menubtn.hxx>
45 #include <svtools/svtreebx.hxx>
46 #include <svtools/brwbox.hxx>
47 #ifndef _MSGBOX_HXX //autogen
48 #include <vcl/msgbox.hxx>
49 #endif
50 #ifndef _DOCKWIN_HXX //autogen
51 #include <vcl/dockwin.hxx>
52 #endif
53 #ifndef _FLOATWIN_HXX //autogen
54 #include <vcl/floatwin.hxx>
55 #endif
56 #ifndef _LSTBOX_HXX //autogen
57 #include <vcl/lstbox.hxx>
58 #endif
59 #ifndef _COMBOBOX_HXX //autogen
60 #include <vcl/combobox.hxx>
61 #endif
62 #ifndef _MOREBTN_HXX //autogen
63 #include <vcl/morebtn.hxx>
64 #endif
65 #ifndef _FIELD_HXX //autogen
66 #include <vcl/field.hxx>
67 #endif
68 #ifndef _TOOLBOX_HXX //autogen
69 #include <vcl/toolbox.hxx>
70 #endif
71 #include <vcl/tabctrl.hxx>
72 #include <vcl/tabpage.hxx>
73 #include <vcl/menu.hxx>
74 #include <vcl/status.hxx>
75 #include <svtools/prgsbar.hxx>
76 #include <svtools/editbrowsebox.hxx>
77 #include <vcl/splitwin.hxx>
78 #include <vcl/group.hxx>
79 #include <vcl/fixed.hxx>
80 #include <vcl/wrkwin.hxx>
81 #include <osl/diagnose.h>
82 #include <svtools/valueset.hxx>
83 #include <svtools/roadmap.hxx>
84 #include <svtools/table/tablecontrol.hxx>
85 #include <svtools/table/tablecontrolinterface.hxx>
86 #include <svl/poolitem.hxx>
87 #include <svtools/extensionlistbox.hxx>
88 // Hat keinen Includeschutz
89 #include <svtools/svtdata.hxx>
90 #include <tools/time.hxx>
91 #include <svtools/stringtransfer.hxx>
92 #include <tools/stream.hxx>
93 #include <tools/fsys.hxx>
94 #include <svl/stritem.hxx>
95 #include <svtools/ttprops.hxx>
96 #ifndef _BASIC_TTRESHLP_HXX
97 #include <basic/ttstrhlp.hxx>
98 #endif
99 #include <basic/dispdefs.hxx>
100 #include <basic/sbuno.hxx>
101 #include <vos/socket.hxx>
102 #include <svl/pickerhistory.hxx>
103 #include <com/sun/star/util/XCancellable.hpp>
104 
105 #include <sot/storage.hxx>
106 #include <sot/storinfo.hxx>
107 #include "statemnt.hxx"
108 #include "scmdstrm.hxx"
109 
110 #ifndef _RETSRTM_HXX
111 #include "retstrm.hxx"
112 #endif
113 
114 #if OSL_DEBUG_LEVEL > 1
115 #include "editwin.hxx"
116 #endif
117 #include "rcontrol.hxx"
118 #include <automation/communi.hxx>
119 #include "testtool.hxx"
120 
121 #include "profiler.hxx"
122 
123 #include "recorder.hxx"
124 
125 #include "testtool.hrc"
126 #include <basic/svtmsg.hrc>
127 
128 #include <algorithm>
129 
130 
131 using namespace com::sun::star::frame;
132 using namespace com::sun::star::uno;
133 //using namespace com::sun::star::util; geht wegen Color nicht
134 using namespace com::sun::star::beans;
135 using namespace svt;
136 //using namespace svt::table;
137 
138 
139 #ifndef SBX_VALUE_DECL_DEFINED
140 #define SBX_VALUE_DECL_DEFINED
141 SV_DECL_REF(SbxValue)
142 #endif
143 SV_IMPL_REF(SbxValue)
144 
145 CommunicationLink *StatementFlow::pCommLink = NULL;
146 sal_Bool StatementFlow::bUseIPC = sal_True;
147 sal_Bool StatementFlow::bSending = sal_False;
148 ImplRemoteControl *StatementFlow::pRemoteControl = NULL;
149 
150 sal_uInt16 StatementCommand::nDirPos = 0;
151 Dir *StatementCommand::pDir = NULL;
152 pfunc_osl_printDebugMessage StatementCommand::pOriginal_osl_DebugMessageFunc = NULL;
153 
154 
155 #define RESET_APPLICATION_TO_BACKING_WINDOW
156 
157 
158 #define SET_WINP_CLOSING(pWin) \
159 	pWindowWaitPointer = pWin; \
160 	aWindowWaitUId = pControl->GetUniqueOrHelpId(); \
161 	aWindowWaitOldHelpId = pWin->GetHelpId(); \
162 	aWindowWaitOldUniqueId = pWin->GetUniqueId(); \
163 	pWin->SetHelpId( rtl::OString("TT_Win_is_closing_HID") ); \
164 	pWin->SetUniqueId( rtl::OString("TT_Win_is_closing_UID") );
165 
166 // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
167 
168 StatementFlow::StatementFlow( StatementList *pAfterThis, sal_uInt16 nArtP )
169 : nArt(nArtP)
170 , nParams(0)
171 , nSNr1(0)
172 , nLNr1(0)
173 , aString1()
174 , bBool1(sal_False)
175 {
176 	QueStatement( pAfterThis );
177 }
178 
179 StatementFlow::StatementFlow( sal_uLong nServiceId, SCmdStream *pCmdIn, ImplRemoteControl *pRC )
180 : nArt(0)
181 , nParams(0)
182 , nSNr1(0)
183 , nLNr1(0)
184 , aString1()
185 , bBool1(sal_False)
186 {
187 	QueStatement( NULL );
188 	bUseIPC = (nServiceId == SI_IPCCommandBlock);
189 	pRemoteControl = pRC;
190 	pCmdIn->Read( nArt );
191 	pCmdIn->Read( nParams );
192 
193 	if( nParams & PARAM_USHORT_1 )  pCmdIn->Read( nSNr1 );
194 	if( nParams & PARAM_ULONG_1 )   pCmdIn->Read( nLNr1 );
195 	if( nParams & PARAM_STR_1 )     pCmdIn->Read( aString1 );
196 	if( nParams & PARAM_BOOL_1 )    pCmdIn->Read( bBool1 );	// sollte nie auftreten!!
197 
198 #if OSL_DEBUG_LEVEL > 1
199 	m_pDbgWin->AddText( "Reading FlowControl: " );
200 	m_pDbgWin->AddText( String::CreateFromInt32( nArt ) );
201 	m_pDbgWin->AddText( " Params:" );
202 	if( nParams & PARAM_USHORT_1 )  {m_pDbgWin->AddText( " n1:" );m_pDbgWin->AddText( String::CreateFromInt32( nSNr1 ) );}
203 	if( nParams & PARAM_ULONG_1 )   {m_pDbgWin->AddText( " l1:" );m_pDbgWin->AddText( String::CreateFromInt64( nLNr1 ) );}
204 	if( nParams & PARAM_STR_1 )     {m_pDbgWin->AddText( " s1:" );m_pDbgWin->AddText( aString1 );}
205 	if( nParams & PARAM_BOOL_1 )    {m_pDbgWin->AddText( " b2:" );m_pDbgWin->AddText( bBool1 ? "TRUE" : "FALSE" );}
206 	m_pDbgWin->AddText( "\n" );
207 #endif
208 }
209 
210 void StatementFlow::SendViaSocket()
211 {
212 	if ( bSending )
213 	{
214 #if OSL_DEBUG_LEVEL > 1
215 		m_pDbgWin->AddText( "SendViaSocket called recursively. Aborted!!!\n" );
216 #endif
217 		DBG_ERROR("SendViaSocket called recursively. Aborted!!!");
218 		return;
219 	}
220 	bSending = sal_True;
221 	if ( pCommLink )
222 	{
223 		if ( !pCommLink->TransferDataStream( pRet->GetStream() ) )	// tritt ein Fehler auf, so wird sofort gel�scht ...
224 			pCommLink = NULL;
225 	}
226 	else
227 	{
228 		// Macht nix. Wenn das Basic nicht mehr da ist, ist sowiso alles egal
229 		DBG_ERROR("Cannot send results to TestTool");
230 	}
231 
232 	pRet->Reset();
233 	bSending = sal_False;
234 	IsError = sal_False;
235 }
236 
237 sal_Bool StatementFlow::Execute()
238 {
239 #if OSL_DEBUG_LEVEL > 1
240 	m_pDbgWin->AddText( "Executing Flow: " );
241 	m_pDbgWin->AddText( String::CreateFromInt32( nArt ) );
242 	m_pDbgWin->AddText( "\n" );
243 #endif
244 	switch ( nArt )
245 	{
246 	case F_EndCommandBlock:
247 		{
248 
249 			if ( !bUseIPC )
250 			{
251 				// bBool1 wurde im CTOR auf sal_False initialisiert
252 				if ( !bBool1 )	// also erster Durchlauf
253 				{
254 					pRemoteControl->pRetStream = pRet->GetStream();
255 					bBool1 = sal_True;	// wurde im CTOR auf sal_False initialisiert
256 					nRetryCount = nRetryCount * 4;
257 				}
258 				if ( pRemoteControl->pRetStream && (nRetryCount--) )	// also solange nicht abgeholt
259 				{
260 					return sal_False;	// Bitte einmal vom Callstack runter
261 				}
262 			}
263 
264 		}
265 		break;
266 	}
267 
268 	Advance();
269 	switch ( nArt )
270 	{
271 	case F_EndCommandBlock:
272 		if ( !bUseIPC )
273 		{	// wird oben abgehandelt
274 			pRet->Reset();
275 			IsError = sal_False;
276 		}
277 		else
278 			SendViaSocket();
279 
280 		break;
281 
282 	case F_Sequence:
283 
284 		pRet->GenReturn(RET_Sequence,nLNr1);
285         #if OSL_DEBUG_LEVEL > 1
286 		m_pDbgWin->AddText( "Sending Sequence Nr: " );
287 		m_pDbgWin->AddText( String::CreateFromInt64( nLNr1 ) );
288 		m_pDbgWin->AddText( "\n" );
289 		#endif
290 
291 		break;
292 //	case RET_:
293 	default:
294 		DBG_ERROR( "Unknown Flowcontrol" );
295 		break;
296 	}
297 
298 	delete this;
299 	return sal_True;
300 }
301 
302 // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
303 
304 // neue Hilfsfunktion, die stetig erweitert werden muss
305 static short ImpGetRType( Window *pWin )
306 {
307 	short nRT = C_NoType;
308 	WindowType eRT = pWin->GetType();
309 	switch( eRT ) {
310 		case WINDOW_WINDOW:				nRT = C_Window		      ; break;
311 
312 		case WINDOW_TABCONTROL:			nRT = C_TabControl        ; break;
313 		case WINDOW_RADIOBUTTON:		nRT = C_RadioButton       ; break;
314 		case WINDOW_CHECKBOX:			nRT = C_CheckBox          ; break;
315 		case WINDOW_TRISTATEBOX:		nRT = C_TriStateBox       ; break;
316 		case WINDOW_EDIT:				nRT = C_Edit              ; break;
317 		case WINDOW_MULTILINEEDIT:		nRT = C_MultiLineEdit     ; break;
318 		case WINDOW_MULTILISTBOX:		nRT = C_MultiListBox      ; break;
319 		case WINDOW_LISTBOX:			nRT = C_ListBox           ; break;
320 		case WINDOW_COMBOBOX:			nRT = C_ComboBox          ; break;
321 		case WINDOW_PUSHBUTTON:			nRT = C_PushButton        ; break;
322 		case WINDOW_SPINFIELD:			nRT = C_SpinField         ; break;
323 		case WINDOW_PATTERNFIELD:		nRT = C_PatternField      ; break;
324 		case WINDOW_NUMERICFIELD:		nRT = C_NumericField      ; break;
325 		case WINDOW_METRICFIELD:		nRT = C_MetricField       ; break;
326 		case WINDOW_CURRENCYFIELD:		nRT = C_CurrencyField     ; break;
327 		case WINDOW_DATEFIELD:			nRT = C_DateField         ; break;
328 		case WINDOW_TIMEFIELD:			nRT = C_TimeField         ; break;
329 		case WINDOW_IMAGERADIOBUTTON:	nRT = C_ImageRadioButton  ; break;
330 		case WINDOW_NUMERICBOX:			nRT = C_NumericBox        ; break;
331 		case WINDOW_METRICBOX:			nRT = C_MetricBox         ; break;
332 		case WINDOW_CURRENCYBOX:		nRT = C_CurrencyBox       ; break;
333 		case WINDOW_DATEBOX:			nRT = C_DateBox           ; break;
334 		case WINDOW_TIMEBOX:			nRT = C_TimeBox           ; break;
335 		case WINDOW_IMAGEBUTTON:		nRT = C_ImageButton       ; break;
336 		case WINDOW_MENUBUTTON:			nRT = C_MenuButton        ; break;
337 		case WINDOW_MOREBUTTON:			nRT = C_MoreButton        ; break;
338 
339 
340 		case WINDOW_TABPAGE:			nRT = C_TabPage;		break;
341 		case WINDOW_MODALDIALOG:		nRT = C_ModalDlg;		break;
342 		case WINDOW_FLOATINGWINDOW:		nRT = C_FloatWin;		break;
343 		case WINDOW_MODELESSDIALOG:		nRT = C_ModelessDlg;	break;
344 		case WINDOW_WORKWINDOW:			nRT = C_WorkWin;		break;
345 		case WINDOW_DOCKINGWINDOW:		nRT = C_DockingWin;		break;
346 
347 		case WINDOW_MESSBOX:			nRT = C_MessBox;		break;
348 		case WINDOW_INFOBOX:			nRT = C_InfoBox;		break;
349 		case WINDOW_WARNINGBOX:			nRT = C_WarningBox;		break;
350 		case WINDOW_ERRORBOX:			nRT = C_ErrorBox;		break;
351 		case WINDOW_QUERYBOX:			nRT = C_QueryBox;		break;
352 #if 0 //ifndef VCL
353 		case WINDOW_FILEDIALOG:			nRT = C_FileDlg;		break;
354 		case WINDOW_PATHDIALOG:			nRT = C_PathDlg;		break;
355 		case WINDOW_PRINTDIALOG:		nRT = C_PrintDlg;		break;
356 		case WINDOW_PRINTERSETUPDIALOG:	nRT = C_PrinterSetupDlg;break;
357 		case WINDOW_COLORDIALOG:		nRT = C_ColorDlg;		break;
358 #endif
359 		case WINDOW_TABDIALOG:			nRT = C_TabDlg;			break;
360 //		case WINDOW_TABDIALOG:			nRT = C_SingleTabDlg;	break;
361 
362 		case WINDOW_PATTERNBOX:			nRT = C_PatternBox;		break;
363 		case WINDOW_TOOLBOX:			nRT = C_ToolBox;		break;
364 // Gibts nicht       case WINDOW_VALUESET:			nRT = C_ValueSet;		break;
365 		case WINDOW_CONTROL:			nRT = C_Control;		break;
366 		case WINDOW_OKBUTTON:			nRT = C_OkButton;		break;
367 		case WINDOW_CANCELBUTTON:		nRT = C_CancelButton;	break;
368 		case WINDOW_BUTTONDIALOG:		nRT = C_ButtonDialog;	break;
369 		case WINDOW_TREELISTBOX:		nRT = C_TreeListBox;	break;
370 
371         case WINDOW_DIALOG:				nRT = C_Dialog;			break;
372 	}
373 	return nRT;
374 }
375 
376 // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
377 
378 StatementSlot::StatementSlot( SCmdStream *pCmdIn )
379 : pItemArr(NULL)
380 {
381 	QueStatement( NULL );
382 	pCmdIn->Read( nFunctionId );
383 #if OSL_DEBUG_LEVEL > 1
384 	m_pDbgWin->AddText( "Reading Slot: " );
385 	m_pDbgWin->AddText( String::CreateFromInt32( nFunctionId ) );
386 	m_pDbgWin->AddText( "\n" );
387 #endif
388 	pCmdIn->Read( nAnzahl );
389 	if ( nAnzahl )
390 	{
391         switch ( pCmdIn->GetNextType() )
392         {
393             case BinUSHORT: // use old calling method
394                 {
395 		            nAnzahl++;
396 		            pItemArr = new SfxPoolItem*[nAnzahl];
397 		            for (sal_uInt16 i = 0 ; i+1 < nAnzahl ; i++)
398 			            pCmdIn->Read( pItemArr[i] );
399     		        pItemArr[nAnzahl-1] = NULL;
400                 }
401                 break;
402             case BinString: // new Method
403                 {
404                     aArgs.realloc(nAnzahl);
405                     PropertyValue* pArg = aArgs.getArray();
406 		            for (sal_uInt16 i = 0 ; i < nAnzahl ; i++)
407 			            pCmdIn->Read( pArg[i] );
408                 }
409                 break;
410         }
411 	}
412 }
413 
414 // Constructor for UnoSlot
415 StatementSlot::StatementSlot()
416 : nAnzahl( 0 )
417 , pItemArr(NULL)
418 , nFunctionId( 0 )
419 , bMenuClosed(sal_False)
420 {}
421 
422 StatementSlot::StatementSlot( sal_uLong nSlot, SfxPoolItem* pItem )
423 : pItemArr(NULL)
424 , bMenuClosed(sal_False)
425 {
426 	QueStatement( NULL );
427 	nFunctionId = sal_uInt16(nSlot);
428 #if OSL_DEBUG_LEVEL > 1
429 	m_pDbgWin->AddText( "Reading Slot: " );
430 	m_pDbgWin->AddText( String::CreateFromInt32( nFunctionId ) );
431 	m_pDbgWin->AddText( "\n" );
432 #endif
433 	if ( pItem )
434 	{
435 		nAnzahl = 2;
436 		pItemArr = new SfxPoolItem*[2];
437 		pItemArr[0] = pItem;
438 		pItemArr[1] = NULL;
439 	}
440 	else
441 		nAnzahl = 0;
442 }
443 
444 StatementSlot::~StatementSlot()
445 {
446 	if (nAnzahl)
447 	{
448         if ( pItemArr )
449         {
450 		    for (sal_uInt16 i = 0 ; i+1 < nAnzahl ; i++)
451 			    delete pItemArr[i];
452 		    delete[] pItemArr;
453         }
454 
455         aArgs.realloc( 0 );
456 	}
457 }
458 
459 void StatementSlot::AddReferer()
460 {
461     HACK( "only to test!" );
462 // because slot 6102 /*SID_VERB_START*/ crashes when called with Property Referer
463 // We return to the previous behavior (which was a bug realy) of not adding this Property to calls which have no properties at all
464 // according to MBA most likely this Property can be removed at all and is maybe only needed for Slots with URLs
465     if ( !nAnzahl )
466         return;
467 
468     PropertyValue* pArg;
469 
470     nAnzahl++;
471     aArgs.realloc(nAnzahl);
472     pArg = aArgs.getArray();
473     pArg[nAnzahl-1].Name = rtl::OUString::createFromAscii("Referer");
474     pArg[nAnzahl-1].Value <<= ::rtl::OUString::createFromAscii("private:user");
475 
476     nAnzahl++;
477     aArgs.realloc(nAnzahl);
478     pArg = aArgs.getArray();
479     pArg[nAnzahl-1].Name = rtl::OUString::createFromAscii("SynchronMode");
480     pArg[nAnzahl-1].Value <<= sal_Bool( sal_True );
481 }
482 
483 class SlotStatusListener : public cppu::WeakImplHelper1< XStatusListener >
484 {
485 public:
486     SlotStatusListener();
487 
488     // XStatusListener
489     virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw (::com::sun::star::uno::RuntimeException);
490     // XEventListener
491     virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
492 
493     // local Members
494     sal_Bool bDisposed;
495     sal_Bool bEnabled;
496 };
497 /*
498 struct FeatureStateEvent : public ::com::sun::star::lang::EventObject
499     ::com::sun::star::util::URL FeatureURL;
500     ::rtl::OUString FeatureDescriptor;
501     sal_Bool IsEnabled;
502     sal_Bool Requery;
503     ::com::sun::star::uno::Any State;
504 
505     ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > Source;
506 */
507 
508 SlotStatusListener::SlotStatusListener()
509 : bDisposed( sal_False )
510 , bEnabled( sal_True )
511 {}
512 
513 // XStatusListener
514 void SAL_CALL SlotStatusListener::statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw (::com::sun::star::uno::RuntimeException)
515 {
516 //    DBG_ERROR1("FeatureURL: %s", ByteString( String( Event.FeatureURL.Complete ), RTL_TEXTENCODING_UTF8 ).GetBuffer() );
517 //    DBG_ERROR1("FeatureDescriptor: %s", ByteString( String( Event.FeatureDescriptor ), RTL_TEXTENCODING_UTF8 ).GetBuffer() );
518     bEnabled = Event.IsEnabled;
519 //    DBG_ASSERT( Event.IsEnabled, "Not enabled" );
520 //    DBG_ASSERT( !Event.Requery, "Requery" );
521 }
522 
523 // XEventListener
524 void SAL_CALL SlotStatusListener::disposing( const ::com::sun::star::lang::EventObject& ) throw (::com::sun::star::uno::RuntimeException)
525 {
526     bDisposed = sal_True;
527 }
528 
529 sal_Bool StatementSlot::Execute()
530 {
531 	if ( IsError )
532 	{
533         #if OSL_DEBUG_LEVEL > 1
534 		m_pDbgWin->AddText( "Skipping Slot: " );
535 		m_pDbgWin->AddText( String::CreateFromInt32( nFunctionId ) );
536 		m_pDbgWin->AddText( "\n" );
537 		#endif
538 
539 		Advance();
540 		delete this;
541 		return sal_True;
542 	}
543 
544 	InitProfile();
545 #if OSL_DEBUG_LEVEL > 1
546 	m_pDbgWin->AddText( "Executing Slot: " );
547 	m_pDbgWin->AddText( String::CreateFromInt32( nFunctionId ) );
548 	m_pDbgWin->AddText( "\n" );
549 #endif
550 
551     PopupMenu *pPopup = NULL;
552     MenuBar *pMenuBar = NULL;
553 	Menu *pMenu;
554 
555     GetCurrentMenues( pPopup, pMenuBar, pMenu );
556     if ( pPopup )
557     {
558         if ( !bMenuClosed )
559         {
560             pPopup->EndExecute(0);
561 			aSubMenuId1 = 0;
562 			aSubMenuId2 = 0;
563 			aSubMenuId3 = 0;
564 			pMenuWindow = NULL;
565             bMenuClosed = sal_True;
566 #if OSL_DEBUG_LEVEL > 1
567 	        m_pDbgWin->AddText( "Closed contextmenu\n" );
568 #endif
569 	        return sal_False;
570         }
571 		else if ( nRetryCount-- )
572 		{
573 #if OSL_DEBUG_LEVEL > 1
574 			m_pDbgWin->AddText( "Waiting for contextmenu to close\n" );
575 #endif
576 			return sal_False;
577 		}
578 		else
579 			ReportError( GEN_RES_STR0( S_MENU_NOT_CLOSING ) );
580     }
581 
582 	Advance();
583 
584 	if ( !IsError )
585 	{
586         if ( ( nAnzahl == 0 && !getenv("OLDSLOTHANDLING") ) || aArgs.hasElements() )
587         {   // trying to call slots via uno
588             AddReferer();
589             if ( !aUnoUrl.Len() )
590                 aUnoUrl = CUniString("slot:").Append( String::CreateFromInt32( nFunctionId ) );
591             ::com::sun::star::util::URL aTargetURL;
592             aTargetURL.Complete = aUnoUrl;
593             Reference < XFramesSupplier > xDesktop = Reference < XFramesSupplier >( ::comphelper::getProcessServiceFactory()->createInstance( CUniString("com.sun.star.frame.Desktop") ), UNO_QUERY );
594             Reference < XFrame > xFrame;
595 
596             if ( xDesktop.is() )
597             {
598                 xFrame = xDesktop->getActiveFrame();
599                 if ( !xFrame.is() )
600                 {
601                     Reference < XFrames > xFrames;
602                     xFrames = xDesktop->getFrames();
603                     if ( xFrames.is() && xFrames->getCount() > 0 )
604                     {
605                         Any aFrame = xFrames->getByIndex( xFrames->getCount() -1 );
606                         aFrame >>= xFrame;
607                     }
608                 }
609                 if ( !xFrame.is() )
610                 {
611                     if ( GetFirstDocFrame() )
612                         GetFirstDocFrame()->ToTop();
613                     xFrame = xDesktop->getActiveFrame();
614                 }
615             }
616 
617             if ( xFrame.is() )
618                 xDesktop = Reference < XFramesSupplier >( xFrame, UNO_QUERY );
619             else
620                 xDesktop.clear();
621 
622             while ( xDesktop.is() && xDesktop->getActiveFrame().is() )
623             {
624                 xFrame = xDesktop->getActiveFrame();
625 #if OSL_DEBUG_LEVEL > 1
626                 ::rtl::OUString aName;
627                 if ( xFrame.is() )
628                     aName = xFrame->getName();
629 #endif
630                 xDesktop = Reference < XFramesSupplier >( xFrame, UNO_QUERY );
631             }
632 
633             if ( !xFrame.is() )
634 			    ReportError( GEN_RES_STR1( S_UNO_URL_EXECUTE_FAILED_NO_FRAME, aTargetURL.Complete ) );
635             else
636             {
637                 Reference < ::com::sun::star::util::XURLTransformer > xTrans( ::comphelper::getProcessServiceFactory()->createInstance( CUniString("com.sun.star.util.URLTransformer" )), UNO_QUERY );
638                 xTrans->parseStrict( aTargetURL );
639 
640                 Reference < XDispatchProvider > xProv( xFrame, UNO_QUERY );
641                 Reference < XDispatch > xDisp;
642                 while ( xProv.is() && !xDisp.is() )
643                 {
644                     xDisp = xProv->queryDispatch( aTargetURL, ::rtl::OUString(), 0 );
645                     if ( !xDisp.is() )
646                     {
647                         xFrame = Reference < XFrame > ( xFrame->getCreator(), UNO_QUERY );
648                         xProv = Reference < XDispatchProvider > ( xFrame, UNO_QUERY );
649                     }
650                 }
651 
652                 if ( xDisp.is() )
653                 {
654                     Reference < XStatusListener > xListener = ( XStatusListener* )new SlotStatusListener;
655                     xDisp->addStatusListener( xListener, aTargetURL );
656                     if ( static_cast< SlotStatusListener* >(xListener.get())->bEnabled )
657                     {
658                         if ( bIsSlotInExecute )
659                             ReportError( GEN_RES_STR0( S_SLOT_IN_EXECUTE ) );
660                         else
661                         {
662                             bIsSlotInExecute = sal_True;
663                             xDisp->dispatch( aTargetURL, aArgs );
664                             bIsSlotInExecute = sal_False;
665                         }
666                     }
667                     else
668     			        ReportError( GEN_RES_STR1( S_UNO_URL_EXECUTE_FAILED_DISABLED, aTargetURL.Complete ) );
669                     xDisp->removeStatusListener( xListener, aTargetURL );
670                 }
671                 else
672 			        ReportError( GEN_RES_STR1( S_UNO_URL_EXECUTE_FAILED_NO_DISPATCHER, aTargetURL.Complete ) );
673             }
674         }
675         else
676         {
677             DirectLog( S_QAError, GEN_RES_STR0( S_DEPRECATED ) );
678             if ( !pTTProperties )
679 			    pTTProperties = new TTProperties();
680 
681 		    switch ( pTTProperties->ExecuteFunction( nFunctionId, pItemArr, EXECUTEMODE_DIALOGASYNCHRON | nUseBindings ) )
682 		    {
683 		    case TT_PR_ERR_NODISPATCHER:
684 			    {
685 				    ReportError( rtl::OString::valueOf((sal_Int32)nFunctionId), GEN_RES_STR0( S_SID_EXECUTE_FAILED_NO_DISPATCHER ) );
686 			    }
687 			    break;
688 		    case TT_PR_ERR_NOEXECUTE:
689 			    {
690 				    ReportError( rtl::OString::valueOf((sal_Int32)nFunctionId), GEN_RES_STR0( S_SID_EXECUTE_FAILED ) );
691 			    }
692 			    break;
693 		    }
694 	    }
695     }
696 
697 
698 /*	Neues Verfahren ab 334!
699 	Neue Methode zum einstellen, da� Modale Dialoge immer Asynchron aufgerufen werden
700 	und echter Returnwert, ob Slot geklappt hat
701 	und Testen ob Slot �berhaupt durch UI aufgerufen werden kann        */
702 
703 
704 	SendProfile( SlotString( nFunctionId ) );
705 	delete this;
706 	return sal_True;
707 }
708 
709 // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
710 
711 StatementUnoSlot::StatementUnoSlot(SCmdStream *pIn)
712 {
713 	QueStatement( NULL );
714 
715 	pIn->Read( aUnoUrl );
716 
717 #if OSL_DEBUG_LEVEL > 1
718 	StatementList::m_pDbgWin->AddText( "UnoUrl:" );
719 	StatementList::m_pDbgWin->AddText( aUnoUrl );
720 	StatementList::m_pDbgWin->AddText( "\n" );
721 #endif
722 
723 }
724 
725 // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
726 
727 StatementCommand::StatementCommand( StatementList *pAfterThis, sal_uInt16 MethodId, sal_uInt16 Params, sal_uInt16 Nr1 )
728 : nMethodId( MethodId )
729 , nParams(Params)
730 , nNr1(Nr1)
731 , nNr2(0)
732 , nNr3(0)
733 , nNr4(0)
734 , nLNr1(0)
735 , aString1()
736 , aString2()
737 , bBool1(sal_False)
738 , bBool2(sal_False)
739 {
740 	QueStatement( pAfterThis );
741 
742 #if OSL_DEBUG_LEVEL > 1
743 	m_pDbgWin->AddText( "Directly adding Conmmand:" );
744 	m_pDbgWin->AddText( " Methode: " );
745     m_pDbgWin->AddText( String::CreateFromInt32( nMethodId ) );
746 	m_pDbgWin->AddText( " Params:" );
747 	if( nParams & PARAM_USHORT_1 )	{m_pDbgWin->AddText( " n1:" );m_pDbgWin->AddText( String::CreateFromInt32( nNr1 ) );}
748 	if( nParams & PARAM_USHORT_2 )	{m_pDbgWin->AddText( " n2:" );m_pDbgWin->AddText( String::CreateFromInt32( nNr2 ) );}
749 	if( nParams & PARAM_USHORT_3 )	{m_pDbgWin->AddText( " n3:" );m_pDbgWin->AddText( String::CreateFromInt32( nNr3 ) );}
750 	if( nParams & PARAM_USHORT_4 )	{m_pDbgWin->AddText( " n4:" );m_pDbgWin->AddText( String::CreateFromInt32( nNr4 ) );}
751 	if( nParams & PARAM_ULONG_1 )	{m_pDbgWin->AddText( " nl1:" );m_pDbgWin->AddText( String::CreateFromInt64( nLNr1 ) );}
752 	if( nParams & PARAM_STR_1 )		{m_pDbgWin->AddText( " s1:" );m_pDbgWin->AddText( aString1 );}
753 	if( nParams & PARAM_STR_2 )		{m_pDbgWin->AddText( " s2:" );m_pDbgWin->AddText( aString2 );}
754 	if( nParams & PARAM_BOOL_1 )    {m_pDbgWin->AddText( " b1:" );m_pDbgWin->AddText( bBool1 ? "TRUE" : "FALSE" );}
755 	if( nParams & PARAM_BOOL_2 )    {m_pDbgWin->AddText( " b2:" );m_pDbgWin->AddText( bBool2 ? "TRUE" : "FALSE" );}
756 	m_pDbgWin->AddText( "\n" );
757 #endif
758 }
759 
760 
761 StatementCommand::StatementCommand( SCmdStream *pCmdIn )
762 : nMethodId(0)
763 , nParams(0)
764 , nNr1(0)
765 , nNr2(0)
766 , nNr3(0)
767 , nNr4(0)
768 , nLNr1(0)
769 , aString1()
770 , aString2()
771 , bBool1(sal_False)
772 , bBool2(sal_False)
773 {
774 	QueStatement( NULL );
775 	pCmdIn->Read( nMethodId );
776 	pCmdIn->Read( nParams );
777 
778 	if( nParams & PARAM_USHORT_1 )	pCmdIn->Read( nNr1 );
779 	if( nParams & PARAM_USHORT_2 )	pCmdIn->Read( nNr2 );
780 	if( nParams & PARAM_USHORT_3 )	pCmdIn->Read( nNr3 );
781 	if( nParams & PARAM_USHORT_4 )	pCmdIn->Read( nNr4 );
782 	if( nParams & PARAM_ULONG_1 )	pCmdIn->Read( nLNr1 );
783 	if( nParams & PARAM_STR_1 )		pCmdIn->Read( aString1 );
784 	if( nParams & PARAM_STR_2 )		pCmdIn->Read( aString2 );
785 	if( nParams & PARAM_BOOL_1 )	pCmdIn->Read( bBool1 );
786 	if( nParams & PARAM_BOOL_2 )	pCmdIn->Read( bBool2 );
787 
788 #if OSL_DEBUG_LEVEL > 1
789 	m_pDbgWin->AddText( "Reading Conmmand:" );
790 	m_pDbgWin->AddText( " Methode: " );
791 	m_pDbgWin->AddText( String::CreateFromInt32( nMethodId ) );
792 	m_pDbgWin->AddText( " Params:" );
793 	if( nParams & PARAM_USHORT_1 )	{m_pDbgWin->AddText( " n1:" );m_pDbgWin->AddText( String::CreateFromInt32( nNr1 ) );}
794 	if( nParams & PARAM_USHORT_2 )	{m_pDbgWin->AddText( " n2:" );m_pDbgWin->AddText( String::CreateFromInt32( nNr2 ) );}
795 	if( nParams & PARAM_USHORT_3 )	{m_pDbgWin->AddText( " n3:" );m_pDbgWin->AddText( String::CreateFromInt32( nNr3 ) );}
796 	if( nParams & PARAM_USHORT_4 )	{m_pDbgWin->AddText( " n4:" );m_pDbgWin->AddText( String::CreateFromInt32( nNr4 ) );}
797 	if( nParams & PARAM_ULONG_1 )	{m_pDbgWin->AddText( " nl1:" );m_pDbgWin->AddText( String::CreateFromInt64( nLNr1 ) );}
798 	if( nParams & PARAM_STR_1 )		{m_pDbgWin->AddText( " s1:" );m_pDbgWin->AddText( aString1 );}
799 	if( nParams & PARAM_STR_2 )		{m_pDbgWin->AddText( " s2:" );m_pDbgWin->AddText( aString2 );}
800 	if( nParams & PARAM_BOOL_1 )    {m_pDbgWin->AddText( " b1:" );m_pDbgWin->AddText( bBool1 ? "TRUE" : "FALSE" );}
801 	if( nParams & PARAM_BOOL_2 )    {m_pDbgWin->AddText( " b2:" );m_pDbgWin->AddText( bBool2 ? "TRUE" : "FALSE" );}
802 	m_pDbgWin->AddText( "\n" );
803 #endif
804 
805 	if ( nMethodId == RC_AppAbort )
806 	{
807         #if OSL_DEBUG_LEVEL > 1
808 		m_pDbgWin->AddText( "*Deleting all Commands:\n" );
809 		#endif
810 		bReadingCommands = sal_False;
811 		while ( StatementList::pFirst != this ) // Alles L�schen au�er mich selbst
812 		{
813 			StatementList *pDeQue = StatementList::pFirst;
814 			pDeQue->Advance();
815 			delete pDeQue;
816 		}
817 		bReadingCommands = sal_True;
818         #if OSL_DEBUG_LEVEL > 1
819 		m_pDbgWin->AddText( "*Done deleting all Commands:\n" );
820 		#endif
821 	}
822 
823 }
824 
825 void StatementCommand::WriteControlData( Window *pBase, sal_uLong nConf, sal_Bool bFirst )
826 {
827 
828 	if ( IsDialog(pBase) && !bFirst )
829 		return;
830 
831 	if ( bFirst )
832 		pRet->GenReturn ( RET_WinInfo, rtl::OString(), (comm_ULONG)nConf | DH_MODE_DATA_VALID, UniString(), sal_True );
833 
834 	if ( bFirst )
835     {
836         if ( pBase->GetType() == WINDOW_WINDOW && pBase->GetParent() && pBase->GetParent()->GetType() == WINDOW_CONTROL &&
837              dynamic_cast< svt::table::TableControl* > ( pBase->GetParent() ) )
838             pBase = pBase->GetParent();
839     }
840 
841 	{	// Klammerung, so da� der String nicht w�hrend der Rekursion bestehen bleibt
842 		String aName;
843 		sal_Bool bSkip = sal_False;
844 
845 		switch ( pBase->GetType() )
846 		{
847 			case WINDOW_RADIOBUTTON:
848 			case WINDOW_CHECKBOX:
849 			case WINDOW_TRISTATEBOX:
850 			case WINDOW_PUSHBUTTON:
851 			case WINDOW_OKBUTTON:
852 			case WINDOW_CANCELBUTTON:
853 			case WINDOW_IMAGERADIOBUTTON:
854 			case WINDOW_IMAGEBUTTON:
855 			case WINDOW_MENUBUTTON:
856 			case WINDOW_MOREBUTTON:
857 			case WINDOW_TABPAGE:
858 			case WINDOW_MODALDIALOG:
859 			case WINDOW_FLOATINGWINDOW:
860 			case WINDOW_MODELESSDIALOG:
861 			case WINDOW_WORKWINDOW:
862 			case WINDOW_DOCKINGWINDOW:
863 			case WINDOW_CONTROL:
864 
865 			case WINDOW_FILEDIALOG:
866 			case WINDOW_PATHDIALOG:
867 			case WINDOW_PRINTDIALOG:
868 			case WINDOW_PRINTERSETUPDIALOG:
869 			case WINDOW_COLORDIALOG:
870 			case WINDOW_TABDIALOG:
871 
872 			case WINDOW_BUTTONDIALOG:
873 
874 			case WINDOW_MENUBARWINDOW:
875 				aName = pBase->GetText().EraseAllChars('~');
876 				break;
877 
878 			case WINDOW_EDIT:
879 			case WINDOW_MULTILINEEDIT:
880 			case WINDOW_MULTILISTBOX:
881 			case WINDOW_LISTBOX:
882 			case WINDOW_COMBOBOX:
883 			case WINDOW_SPINFIELD:
884 			case WINDOW_PATTERNFIELD:
885 			case WINDOW_NUMERICFIELD:
886 			case WINDOW_METRICFIELD:
887 			case WINDOW_CURRENCYFIELD:
888 			case WINDOW_DATEFIELD:
889 			case WINDOW_TIMEFIELD:
890 			case WINDOW_NUMERICBOX:
891 			case WINDOW_METRICBOX:
892 			case WINDOW_CURRENCYBOX:
893 			case WINDOW_DATEBOX:
894 			case WINDOW_TIMEBOX:
895 			case WINDOW_PATTERNBOX:
896 			case WINDOW_TOOLBOX:
897 				aName = pBase->GetQuickHelpText();
898 				break;
899 
900 			case WINDOW_MESSBOX:
901 			case WINDOW_INFOBOX:
902 			case WINDOW_WARNINGBOX:
903 			case WINDOW_ERRORBOX:
904 			case WINDOW_QUERYBOX:
905 				aName = ((MessBox*)pBase)->GetMessText();
906 				break;
907 
908 			default:
909 				if ( ( pBase->GetUniqueOrHelpId().getLength() == 0 ) && !( nConf & DH_MODE_ALLWIN ) )
910 					bSkip = sal_True;
911 				break;
912 		}
913 
914 		if ( !bSkip )
915 		{
916 			if ( aName.Len() == 0 )
917 				aName = pBase->GetQuickHelpText();
918 			if ( aName.Len() == 0 )
919 				aName = pBase->GetHelpText();
920 			if ( aName.Len() == 0 )
921 				aName = pBase->GetText();
922 
923 
924     		String aTypeSuffix;
925             if ( pBase->GetType() == WINDOW_CONTROL )
926             {
927                 if ( dynamic_cast< EditBrowseBox* >(pBase) )
928                     aTypeSuffix.AppendAscii( "/BrowseBox", 10 );
929                 else if ( dynamic_cast< ValueSet* >(pBase) )
930                     aTypeSuffix.AppendAscii( "/ValueSet", 9 );
931                 else if ( dynamic_cast< ORoadmap* >(pBase) )
932                     aTypeSuffix.AppendAscii( "/RoadMap", 8 );
933                 else if ( dynamic_cast< IExtensionListBox* >(pBase) )
934                     aTypeSuffix.AppendAscii( "/ExtensionListBox" );
935                 else if ( dynamic_cast< svt::table::TableControl* >(pBase) )
936                     aTypeSuffix.AppendAscii( "/TableControl" );
937                 else
938                     aTypeSuffix.AppendAscii( "/Unknown", 8 );
939             }
940 
941             rtl::OString aId = pBase->GetUniqueOrHelpId();
942             pRet->GenReturn ( RET_WinInfo, aId, (comm_ULONG)pBase->GetType(),
943 			    TypeString(pBase->GetType()).Append(aTypeSuffix).AppendAscii(": ").Append(aName), sal_False );
944 
945 
946 			if ( pBase->GetType() == WINDOW_TOOLBOX )	// Buttons und Controls auf Toolboxen.
947 			{
948 				ToolBox *pTB = ((ToolBox*)pBase);
949 				sal_uInt16 i;
950 				for ( i = 0; i < pTB->GetItemCount() ; i++ )
951 				{
952 					aName = String();
953 //					if ( aName.Len() == 0 )
954 //						aName = pTB->GetQuickHelpText();
955 					if ( aName.Len() == 0 )
956 						aName = pTB->GetHelpText( pTB->GetItemId( i ) );
957 					if ( aName.Len() == 0 )
958 						aName = pTB->GetItemText( pTB->GetItemId( i ) );
959 
960 					Window *pItemWin;
961 					pItemWin = pTB->GetItemWindow( pTB->GetItemId( i ) );
962 					if ( pTB->GetItemType( i ) == TOOLBOXITEM_BUTTON && ( !pItemWin || !pItemWin->IsVisible() ) )
963 					{
964 						if ( pTB->GetItemCommand(pTB->GetItemId( i )).Len() || ( nConf & DH_MODE_ALLWIN ) )
965                             pRet->GenReturn ( RET_WinInfo, Str2Id(pTB->GetItemCommand(pTB->GetItemId( i ))), (comm_ULONG)WINDOW_BUTTON,
966 							    TypeString(WINDOW_BUTTON).AppendAscii(": ").Append(aName), sal_False );
967 						if ( !pTB->GetItemCommand(pTB->GetItemId( i )).Len() || ( nConf & DH_MODE_ALLWIN ) )
968     						pRet->GenReturn ( RET_WinInfo, pTB->GetHelpId(pTB->GetItemId( i )), (comm_ULONG)WINDOW_BUTTON,
969 	    						TypeString(WINDOW_BUTTON).AppendAscii(": ").Append(aName), sal_False );
970 					}
971 					else
972 					{
973 						if ( pItemWin )
974 						{
975                             if ( pTB->GetItemCommand(pTB->GetItemId( i )).Len() || ( nConf & DH_MODE_ALLWIN ) )
976 							    pRet->GenReturn ( RET_WinInfo, Str2Id(pTB->GetItemCommand(pTB->GetItemId( i ))), (comm_ULONG)pItemWin->GetType(),
977 								    TypeString(pItemWin->GetType()).AppendAscii(": ").Append(aName), sal_False );
978                             if ( !pTB->GetItemCommand(pTB->GetItemId( i )).Len() || ( nConf & DH_MODE_ALLWIN ) )
979 							    pRet->GenReturn ( RET_WinInfo, pTB->GetHelpId(pTB->GetItemId( i )), (comm_ULONG)pItemWin->GetType(),
980 								    TypeString(pItemWin->GetType()).AppendAscii(": ").Append(aName), sal_False );
981                             sal_uInt16 ii;
982 							for( ii = 0 ; ii < pItemWin->GetChildCount(); ii++ )
983 								WriteControlData( pItemWin->GetChild(ii), nConf, sal_False );
984 						}
985 						else
986 						{
987 							if ( nConf & DH_MODE_ALLWIN )
988 							{
989 								String aToolBoxItemType;
990 								switch ( pTB->GetItemType( i ) )
991 								{
992 								case TOOLBOXITEM_DONTKNOW:
993 									aToolBoxItemType.AssignAscii("TOOLBOXITEM_DONTKNOW");
994 									break;
995 								case TOOLBOXITEM_BUTTON:
996 									aToolBoxItemType.AssignAscii("TOOLBOXITEM_BUTTON");
997 									break;
998 								case TOOLBOXITEM_SPACE:
999 									aToolBoxItemType.AssignAscii("TOOLBOXITEM_SPACE");
1000 									break;
1001 								case TOOLBOXITEM_SEPARATOR:
1002 									aToolBoxItemType.AssignAscii("TOOLBOXITEM_SEPARATOR");
1003 									break;
1004 								case TOOLBOXITEM_BREAK:
1005 									aToolBoxItemType.AssignAscii("TOOLBOXITEM_BREAK");
1006 									break;
1007 								default:
1008 									DBG_ERROR1( "Unknown TOOLBOXITEM %i", pTB->GetItemType( i ) );
1009 								}
1010                                 if ( pTB->GetItemCommand(pTB->GetItemId( i )).Len() || ( nConf & DH_MODE_ALLWIN ) )
1011 								    pRet->GenReturn ( RET_WinInfo, Str2Id( pTB->GetItemCommand(pTB->GetItemId( i )) ), (comm_ULONG)WINDOW_BASE,
1012 									    aToolBoxItemType.AppendAscii(": ").Append(aName), sal_False );
1013                                 if ( !pTB->GetItemCommand(pTB->GetItemId( i )).Len() || ( nConf & DH_MODE_ALLWIN ) )
1014 								    pRet->GenReturn ( RET_WinInfo, pTB->GetHelpId(pTB->GetItemId( i )), (comm_ULONG)WINDOW_BASE,
1015 									    aToolBoxItemType.AppendAscii(": ").Append(aName), sal_False );
1016 							}
1017 						}
1018 					}
1019 				}
1020 
1021 				return;	// ToolBox ist hier schon komplett abgehandelt.
1022 			}
1023 
1024 
1025 			if ( pBase->GetType() == WINDOW_BUTTONDIALOG	// Buttons auf Buttondialogen mit ID
1026 				|| pBase->GetType() == WINDOW_MESSBOX
1027 				|| pBase->GetType() == WINDOW_INFOBOX
1028 				|| pBase->GetType() == WINDOW_WARNINGBOX
1029 				|| pBase->GetType() == WINDOW_ERRORBOX
1030 				|| pBase->GetType() == WINDOW_QUERYBOX )
1031 			{
1032 				ButtonDialog *pBD = ((ButtonDialog*)pBase);
1033 				sal_uInt16 i;
1034 				for ( i = 0; i < pBD->GetButtonCount() ; i++ )
1035 				{
1036 					aName = String();
1037 					if ( aName.Len() == 0 )
1038 						aName = pBD->GetPushButton( pBD->GetButtonId(i) )->GetText();
1039 					ByteString aID;
1040 					switch ( pBD->GetButtonId(i) )
1041 					{
1042 						case BUTTONID_OK:
1043 							aID.Assign("Ok");
1044 							break;
1045 						case BUTTONID_CANCEL:
1046 							aID.Assign("Cancel");
1047 							break;
1048 						case BUTTONID_YES:
1049 							aID.Assign("Yes");
1050 							break;
1051 						case BUTTONID_NO:
1052 							aID.Assign("No");
1053 							break;
1054 						case BUTTONID_RETRY:
1055 							aID.Assign("Retry");
1056 							break;
1057 						case BUTTONID_HELP:
1058 							aID.Assign("Help");
1059 							break;
1060 						default:
1061 							aID = ByteString::CreateFromInt32( pBD->GetButtonId(i) );
1062 							break;
1063 					}
1064 
1065 					pRet->GenReturn ( RET_WinInfo, aID, (comm_ULONG)pBD->GetPushButton( pBD->GetButtonId(i) )->GetType(),	// So da� der Text angezeigt wird!
1066 						TypeString(pBD->GetPushButton( pBD->GetButtonId(i) )->GetType()).AppendAscii(": ").Append(aName)
1067 						.AppendAscii(" ButtonId = ").AppendAscii( aID.GetBuffer() ), sal_False );
1068 				}
1069 
1070 				return;	// ButtonDialog ist hier schon komplett abgehandelt.
1071 			}
1072 
1073 
1074             Menu* pMenu = GetMatchingMenu( pBase );
1075 
1076 			if ( pMenu )	// Menus
1077 			{
1078 				sal_uInt16 i;
1079 				for ( i = 0; i < pMenu->GetItemCount() ; i++ )
1080 				{
1081                     sal_uInt16 nID = pMenu->GetItemId( i );
1082 
1083                     aName = String();
1084 					if ( aName.Len() == 0 )
1085 						aName = pMenu->GetHelpText( nID );
1086 					if ( aName.Len() == 0 )
1087 						aName = pMenu->GetItemText( nID );
1088 
1089 
1090 					if ( pMenu->GetItemType( i ) == MENUITEM_STRING || pMenu->GetItemType( i ) ==  MENUITEM_IMAGE || pMenu->GetItemType( i ) == MENUITEM_STRINGIMAGE || (nConf & DH_MODE_ALLWIN) )
1091 					{
1092 						String aMenuItemType;
1093 						switch ( pMenu->GetItemType( i ) )
1094 						{
1095 						case MENUITEM_STRING:
1096 							aMenuItemType.AssignAscii("MENUITEM_STRING");
1097 							break;
1098 						case MENUITEM_STRINGIMAGE:
1099 							aMenuItemType.AssignAscii("MENUITEM_STRINGIMAGE");
1100 							break;
1101 						case MENUITEM_IMAGE:
1102 							aMenuItemType.AssignAscii("MENUITEM_IMAGE");
1103 							break;
1104 						case MENUITEM_SEPARATOR:
1105 							aMenuItemType.AssignAscii("MENUITEM_SEPARATOR");
1106 							break;
1107 						case MENUITEM_DONTKNOW:
1108 							aMenuItemType.AssignAscii("MENUITEM_DONTKNOW");
1109 							break;
1110 						default:
1111 							DBG_ERROR1( "Unknown MENUITEM %i", pMenu->GetItemType( i ) );
1112 						}
1113 						if ( pMenu->GetItemCommand(nID).Len() || ( nConf & DH_MODE_ALLWIN ) )
1114                             pRet->GenReturn ( RET_WinInfo, Str2Id( pMenu->GetItemCommand(nID) ), (comm_ULONG)0,
1115                                 aMenuItemType.AppendAscii(": ").Append(aName), sal_False );
1116 						if ( !pMenu->GetItemCommand(nID).Len() || ( nConf & DH_MODE_ALLWIN ) )
1117                             pRet->GenReturn ( RET_WinInfo, rtl::OString::valueOf( (sal_Int32)nID ), (comm_ULONG)0,
1118 	    						aMenuItemType.AppendAscii(": ").Append(aName), sal_False );
1119 					}
1120 				}
1121 
1122 				return;	// Menu ist hier schon komplett abgehandelt.
1123 			}
1124 		}
1125 	}
1126 
1127 	for( sal_uInt16 i = 0 ; i < pBase->GetChildCount(); i++ )
1128 		WriteControlData( pBase->GetChild(i), nConf, sal_False );
1129 }
1130 
1131 class SysWinContainer : public WorkWindow
1132 {
1133 private:
1134 	ToolBox *pClientWin;
1135 	DockingWindow *pDock;
1136 public:
1137 	SysWinContainer( ToolBox *pClient );
1138 	~SysWinContainer();
1139 	virtual void	Resize();
1140 	virtual void	Resizing( Size& rSize );
1141 };
1142 
1143 SysWinContainer::SysWinContainer( ToolBox *pClient )
1144 : WorkWindow( NULL, WB_BORDER | WB_SIZEMOVE | WB_CLOSEABLE )
1145 , pClientWin( pClient )
1146 {
1147 	pDock = new DockingWindow( this );
1148 	pClientWin->SetParent( pDock );
1149 	pClientWin->SetFloatingMode( sal_False );
1150 	SetText( pClient->GetText() );
1151 	SetPosPixel( Point( 1,40 ) );
1152 	Resize();
1153 	pDock->Show();
1154 	EnableAlwaysOnTop();
1155 	Show();
1156 }
1157 
1158 SysWinContainer::~SysWinContainer()
1159 {
1160 	delete pDock;
1161 }
1162 
1163 void SysWinContainer::Resize()
1164 {
1165 	Size aSize( GetOutputSizePixel() );
1166 	Resizing( aSize );
1167 //	aSize = pClientWin->GetSizePixel();
1168 //	aSize = pClientWin->CalcWindowSizePixel();
1169 	if ( aSize != GetSizePixel() )
1170 	{
1171 		SetOutputSizePixel( aSize );
1172 		pDock->SetSizePixel( aSize );
1173 		pClientWin->SetSizePixel( aSize );
1174 	}
1175 }
1176 
1177 void SysWinContainer::Resizing( Size& rSize )
1178 {
1179 	Size aSize;
1180 	Size aBestSize;
1181 	sal_uInt16 i;
1182 	sal_Bool bHasValue = sal_False;
1183 	sal_uLong nBestValue = 0;
1184 	sal_uLong nThisValue;
1185 	for ( i=1 ; i<=1 ; i++ )
1186 	{
1187 		aSize = pClientWin->CalcWindowSizePixel( i );
1188 		nThisValue = Abs( aSize.Width() - rSize.Width() ) + Abs( aSize.Height() - rSize.Height() );
1189 		if ( !bHasValue || ( nThisValue < nBestValue ) )
1190 		{
1191 			nBestValue = nThisValue;
1192 			aBestSize = aSize;
1193 			bHasValue = sal_True;
1194 		}
1195 	}
1196 	rSize = aBestSize;
1197 }
1198 
1199 
1200 class DisplayHidWin : public ToolBox
1201 {
1202 	Edit	*pEdit;
1203 	Size	aMinEditSize;
1204 	sal_uInt16	nLastItemID;
1205 	sal_Bool bIsDraging;
1206 	sal_Bool bIsPermanentDraging;
1207 	void SetDraging( sal_Bool bNewDraging );
1208 	Image *pShow, *pShow2;
1209 	sal_Bool bConfigChanged;
1210 	void EnableButtons( sal_uLong nConf );
1211 
1212 	sal_uLong nEventHookID;
1213 	static long stub_VCLEventHookProc( NotifyEvent& rEvt, void* pData )
1214 	{
1215 		return ((DisplayHidWin*)pData)->VCLEventHook( rEvt );
1216 	}
1217 
1218 	long VCLEventHook( NotifyEvent& rEvt );
1219 	Window *pLastMouseMoveWin;
1220 
1221 	SysWinContainer *pContainer;
1222 
1223     // aborting by pressing shist twice
1224     sal_Bool bOldShift;
1225     Time aLatest;
1226     sal_uInt16 nShiftCount;
1227 
1228 public:
1229 	DisplayHidWin();
1230 	~DisplayHidWin();
1231 
1232 	virtual void	Tracking( const TrackingEvent& rTEvt );
1233 	virtual void	Click();
1234 	virtual void	Select();
1235 	virtual void	SetText( const XubString& rStr );
1236 
1237 	void SetDisplayText( const String &aNewText ){ pEdit->SetText(aNewText); }
1238 	String GetDisplayText() const { return pEdit->GetText(); }
1239 	sal_Bool IsDisplayTextModified() const { return pEdit->IsModified(); }
1240 	void ClearDisplayTextModified() const { pEdit->ClearModifyFlag(); }
1241 
1242 	void SetConfig( sal_uLong nConf );
1243 	sal_uLong GetConfig();
1244 
1245 	sal_Bool IsConfigChanged() { return bConfigChanged; }
1246 	void ConfigSent() { bConfigChanged = sal_False; }
1247 
1248 	sal_Bool IsSendData() { return GetItemState( TT_SEND_DATA ) == STATE_CHECK; }
1249 //	sal_Bool IsAllWin() { return GetItemState( TT_ALLWIN ) == STATE_CHECK; }
1250 
1251 	sal_Bool IsDraging() { return bIsDraging; }
1252 
1253 	Window* LastMouseMoveWin() { return pLastMouseMoveWin; }
1254 };
1255 
1256 DisplayHidWin::DisplayHidWin()
1257 : ToolBox( StatementList::GetFirstDocFrame(), TTProperties::GetSvtResId(DisplayHidToolBox) )
1258 , bIsDraging( sal_False )
1259 , bIsPermanentDraging( sal_False )
1260 , pShow( NULL )
1261 , pShow2( NULL )
1262 , pLastMouseMoveWin( NULL )
1263 , bOldShift( 0 )
1264 , nShiftCount( 0 )
1265 {
1266 	SetOutStyle( TOOLBOX_STYLE_HANDPOINTER | TOOLBOX_STYLE_FLAT );
1267 	pEdit = new Edit( this, WB_CENTER | WB_BORDER );
1268 	aMinEditSize = GetItemRect( TT_OUTPUT ).GetSize();
1269 /**/	aMinEditSize=Size(20,20);
1270 	aMinEditSize.Width() *= 12;
1271 	pEdit->SetSizePixel( aMinEditSize );
1272 	pEdit->Show();
1273 	SetItemWindow( TT_OUTPUT, pEdit );
1274 	Resize();
1275 	pContainer = new SysWinContainer( this );
1276 	nEventHookID = Application::AddEventHook( stub_VCLEventHookProc, this );
1277 }
1278 
1279 DisplayHidWin::~DisplayHidWin()
1280 {
1281 	Application::RemoveEventHook( nEventHookID );
1282     Hide(); // so GetFirstDocFrame won't return ourselves (needed for SOPlayer)
1283 	SetParent( StatementList::GetFirstDocFrame() );
1284 	delete pContainer;
1285 	delete pEdit;
1286 }
1287 
1288 void DisplayHidWin::SetDraging( sal_Bool bNewDraging )
1289 {
1290 	if ( !pShow )
1291 		pShow = new Image( GetItemImage( TT_SHOW ) );
1292 	if ( !pShow2 )
1293 		pShow2 = new Image( Bitmap( TTProperties::GetSvtResId( TT_SHOW2 ) ) );
1294 
1295 	if ( bNewDraging )
1296 		SetItemImage( TT_SHOW, *pShow2 );
1297 	else
1298 		SetItemImage( TT_SHOW, *pShow );
1299 
1300 	bIsDraging = bNewDraging;
1301 }
1302 
1303 void DisplayHidWin::EnableButtons( sal_uLong nConf )
1304 {
1305 	sal_Bool bSend = sal_Bool(nConf & DH_MODE_SEND_DATA);
1306 	EnableItem( TT_ALLWIN, bSend );
1307 	EnableItem( TT_KURZNAME, bSend );
1308 	EnableItem( TT_LANGNAME, bSend );
1309 }
1310 
1311 void DisplayHidWin::Tracking( const TrackingEvent& rTEvt )
1312 {
1313 //	if ( nLastItemID == TT_SHOW && GetItemState( TT_SHOW ) == STATE_NOCHECK && ( rTEvt.IsTrackingEnded() || rTEvt.IsTrackingCanceled() ) )
1314 //		SetDraging( sal_False );
1315 	if ( nLastItemID == TT_SHOW && GetItemState( TT_SHOW ) == STATE_NOCHECK )
1316 		EndTracking( ENDTRACK_CANCEL );
1317 	ToolBox::Tracking( rTEvt);
1318 }
1319 
1320 void DisplayHidWin::Click()
1321 {
1322 	nLastItemID = GetCurItemId();
1323 	if ( nLastItemID == TT_SHOW )
1324 	{
1325 		SetDraging( sal_True );
1326 	}
1327 	ToolBox::Click();
1328 }
1329 
1330 void DisplayHidWin::Select()
1331 {
1332 	if ( GetItemState( GetCurItemId() ) == STATE_NOCHECK )
1333 	{
1334 		SetItemState( GetCurItemId(), STATE_CHECK );
1335 		if ( GetCurItemId() == TT_SHOW )
1336 		{
1337 			bIsPermanentDraging = sal_True;
1338 			SetDraging( sal_True );
1339 		}
1340 	}
1341 	else
1342 	{
1343 		SetItemState( GetCurItemId(), STATE_NOCHECK );
1344 		if ( GetCurItemId() == TT_SHOW )
1345 		{
1346 			bIsPermanentDraging = sal_False;
1347 			SetDraging( sal_False );
1348 		}
1349 	}
1350 	if ( GetCurItemId() == TT_SEND_DATA )
1351 	{
1352 		EnableButtons( GetConfig() );
1353 	}
1354 }
1355 
1356 void DisplayHidWin::SetConfig( sal_uLong nConf )
1357 {
1358 	SetItemState( TT_KURZNAME,  ( nConf & DH_MODE_KURZNAME )  ? STATE_CHECK : STATE_NOCHECK );
1359 	SetItemState( TT_LANGNAME,  ( nConf & DH_MODE_LANGNAME )  ? STATE_CHECK : STATE_NOCHECK );
1360 	SetItemState( TT_ALLWIN,    ( nConf & DH_MODE_ALLWIN )    ? STATE_CHECK : STATE_NOCHECK );
1361 	SetItemState( TT_SEND_DATA, ( nConf & DH_MODE_SEND_DATA ) ? STATE_CHECK : STATE_NOCHECK );
1362 	EnableButtons( nConf );
1363 }
1364 
1365 sal_uLong DisplayHidWin::GetConfig()
1366 {
1367 	sal_uLong nConf = 0;
1368 	if ( GetItemState( TT_KURZNAME ) == STATE_CHECK )
1369 		nConf |= DH_MODE_KURZNAME;
1370 	if ( GetItemState( TT_LANGNAME ) == STATE_CHECK )
1371 		nConf |= DH_MODE_LANGNAME;
1372 	if ( GetItemState( TT_ALLWIN ) == STATE_CHECK )
1373 		nConf |= DH_MODE_ALLWIN;
1374 	if ( IsSendData() )
1375 		nConf |= DH_MODE_SEND_DATA;
1376 
1377 	return nConf;
1378 }
1379 
1380 void DisplayHidWin::SetText( const XubString& rStr )
1381 {
1382 	pContainer->SetText( rStr );
1383 }
1384 
1385 long DisplayHidWin::VCLEventHook( NotifyEvent& rEvt )
1386 {
1387 	if ( EVENT_MOUSEMOVE == rEvt.GetType() )
1388     {
1389 		pLastMouseMoveWin = rEvt.GetWindow();
1390 
1391         // check if abort with pressing shift twice
1392         MouseEvent* pMEvt = (MouseEvent*)rEvt.GetMouseEvent();
1393 
1394         if ( (  pMEvt->IsShift() && !bOldShift ) )    // Shift pressed
1395         {
1396             if ( aLatest < Time() )
1397             {
1398                 nShiftCount = 0;
1399                 aLatest = Time()+Time( 0, 0, 0, 50 );
1400             }
1401             nShiftCount++;
1402         }
1403         if ( ( !pMEvt->IsShift() &&  bOldShift ) )    // Shift released
1404         {
1405             nShiftCount++;
1406             if ( nShiftCount == 4 && aLatest > Time() )
1407             {
1408 			    bIsPermanentDraging = sal_False;
1409 			    SetDraging( sal_False );
1410 		        SetItemState( TT_SHOW, STATE_NOCHECK );
1411             }
1412         }
1413         bOldShift = pMEvt->IsShift();
1414     }
1415 	if ( ( ( EVENT_MOUSEBUTTONUP == rEvt.GetType() && rEvt.GetMouseEvent()->GetButtons() == MOUSE_LEFT) || ( EVENT_MOUSEMOVE == rEvt.GetType() && !rEvt.GetMouseEvent()->GetButtons() ) )
1416 			&& IsDraging() && !bIsPermanentDraging )
1417 		SetDraging( sal_False );
1418 	return 0;
1419 }
1420 
1421 
1422 sal_Bool StatementCommand::DisplayHID()
1423 {
1424 	// Return sal_True -> reexecute command
1425 
1426 	if ( !bBool2 )	// Wird auf sal_False initialisiert
1427 	{
1428 		bBool2 = sal_True;				// Wir sind initialisiert.
1429 		GetTTSettings()->pDisplayInstance = this;	// Und haben die Macht (Alle anderen beenden sich)
1430 
1431 		if ( !(nParams & PARAM_ULONG_1) )
1432 		{
1433 			if( GetTTSettings()->pDisplayHidWin )	// Nichts ver�ndern
1434 				nLNr1 = GetTTSettings()->pDisplayHidWin->GetConfig();
1435 			else	// Beim ersten Aufruf wollen wir alles richtig einstellen
1436 				nLNr1 = DH_MODE_KURZNAME | DH_MODE_LANGNAME;
1437 
1438 			if( ((nParams & PARAM_BOOL_1) && bBool1) )
1439 				nLNr1 |= DH_MODE_SEND_DATA;
1440 			else
1441 				nLNr1 &= ( ~DH_MODE_SEND_DATA );
1442 		}
1443 
1444 		if ( GetTTSettings()->pDisplayHidWin )
1445 			GetTTSettings()->pDisplayHidWin->SetConfig( nLNr1 );
1446 	}
1447 
1448 	if ( GetTTSettings()->pDisplayInstance && GetTTSettings()->pDisplayInstance != this )
1449 	{
1450 		DBG_WARNING("Mehrere DisplayHID am laufen");
1451 		return sal_False;		// Noch eine andere Instanz macht das gleiche!
1452 	}
1453 
1454 	if ( !GetTTSettings()->pDisplayHidWin )
1455 	{
1456 		GetTTSettings()->pDisplayHidWin = new DisplayHidWin();
1457 		GetTTSettings()->aOriginalCaption = GetTTSettings()->pDisplayHidWin->GetText();
1458 		GetTTSettings()->pDisplayHidWin->Show();
1459 		if ( bBool1 )
1460 			nLNr1 |= DH_MODE_SEND_DATA;
1461 		GetTTSettings()->pDisplayHidWin->SetConfig( nLNr1 );
1462 
1463 		GetTTSettings()->Old = NULL;
1464 		GetTTSettings()->Act = NULL;
1465 		GetTTSettings()->pDisplayInstance = this;
1466 	}
1467 	else
1468 	{
1469 		GetTTSettings()->pDisplayHidWin->GetWindow( WINDOW_OVERLAP )->Enable( sal_True, sal_True );
1470 		GetTTSettings()->pDisplayHidWin->GetWindow( WINDOW_OVERLAP )->EnableInput( sal_True, sal_True );
1471 	}
1472 
1473 
1474 	if ( GetTTSettings()->pDisplayHidWin->IsVisible() && !bDying )
1475 	{
1476 
1477 		if ( GetTTSettings()->pDisplayHidWin->IsDraging() )
1478 		{
1479 
1480 
1481 #define HIGHLIGHT_WIN( WinPtr )										\
1482 		{															\
1483 			Color aLineColMem = WinPtr->GetLineColor();				\
1484 			WinPtr->SetLineColor( Color( COL_WHITE ) );				\
1485 			Color aFillColMem = WinPtr->GetFillColor();				\
1486 			WinPtr->SetFillColor( Color( COL_LIGHTRED ) );			\
1487 			RasterOp aROp = WinPtr->GetRasterOp();					\
1488 			WinPtr->SetRasterOp( ROP_XOR );							\
1489 			Size aSz = WinPtr->PixelToLogic( WinPtr->GetSizePixel() );\
1490 			sal_uLong nMaxCornerRadius = WinPtr->PixelToLogic( Point( 80, 0 ) ).X();\
1491 			sal_uLong iCorner = std::max ((sal_uLong) 8, (sal_uLong) std::min( nMaxCornerRadius, (sal_uLong) std::min((sal_uLong) (aSz.Width() / 6), (sal_uLong)(aSz.Height() / 6))));\
1492 			WinPtr->DrawRect(Rectangle(Point(),aSz), iCorner, iCorner);\
1493 			WinPtr->SetLineColor( aLineColMem );					\
1494 			WinPtr->SetFillColor( aFillColMem );					\
1495 			WinPtr->SetRasterOp( aROp );							\
1496 		}
1497 
1498 
1499 #define SET_WIN( WinPtr )											\
1500 			if ( StatementList::WinPtrValid(WinPtr) )	\
1501 			{														\
1502 				HIGHLIGHT_WIN ( WinPtr );							\
1503 			}
1504 
1505 #define RESET_WIN( WinPtr )											\
1506 			if ( StatementList::WinPtrValid(WinPtr) )	\
1507 			{														\
1508 				WinPtr->Invalidate( INVALIDATE_NOTRANSPARENT );		\
1509 				WinPtr->Update();		\
1510 			}
1511 
1512 
1513 			GetTTSettings()->Old = GetTTSettings()->Act;
1514 //			GetTTSettings()->Act = GetMouseWin();
1515 			GetTTSettings()->Act = GetTTSettings()->pDisplayHidWin->LastMouseMoveWin();
1516 
1517             if ( !StatementList::WinPtrValid ( GetTTSettings()->Old ) )
1518                 GetTTSettings()->Old = NULL;
1519             if ( !StatementList::WinPtrValid ( GetTTSettings()->Act ) )
1520                 GetTTSettings()->Act = NULL;
1521 
1522 			if ( GetTTSettings()->Act && GetTTSettings()->Act->GetType() == WINDOW_BORDERWINDOW )
1523 				GetTTSettings()->Act = GetTTSettings()->Act->GetWindow( WINDOW_CLIENT );
1524 
1525 			if ( GetTTSettings()->Act != GetTTSettings()->Old )
1526 			{
1527 				if ( GetTTSettings()->Old )
1528 				{
1529 					RESET_WIN(GetTTSettings()->Old);
1530 				}
1531 				if ( GetTTSettings()->Act )
1532 				{
1533 					SET_WIN(GetTTSettings()->Act);
1534                     GetTTSettings()->pDisplayHidWin->SetDisplayText( Id2Str(GetTTSettings()->Act->GetUniqueOrHelpId()).AppendAscii(" WinType: ")
1535 						.Append(UniString::CreateFromInt64(GetTTSettings()->Act->GetType())).AppendAscii("  ").Append(GetTTSettings()->Act->GetText()));
1536 					if ( GetTTSettings()->Act && !GetTTSettings()->Act->GetUniqueId().equals( GetTTSettings()->Act->GetHelpId() ) )
1537 						GetTTSettings()->pDisplayHidWin->SetText(UniString( TTProperties::GetSvtResId( TT_ALTERNATE_CAPTION ) ).AppendAscii(GetTTSettings()->Act->GetHelpId().getStr()));
1538 					else
1539 						GetTTSettings()->pDisplayHidWin->SetText( GetTTSettings()->aOriginalCaption );
1540 				}
1541 				else
1542 					GetTTSettings()->pDisplayHidWin->SetDisplayText(CUniString("Kein Window/Control gefunden"));
1543 			}
1544 			else if ( GetTTSettings()->Act )
1545 			{
1546 //				SET_WIN(GetTTSettings()->Act);
1547                 // allow setting a HelpID manually (just enter the ID in the displayHID Window and terminate it by |
1548 				if ( GetTTSettings()->pDisplayHidWin->IsDisplayTextModified() && GetTTSettings()->pDisplayHidWin->GetDisplayText().GetTokenCount( '|' ) > 1 )
1549 				{
1550 					GetTTSettings()->Act->SetUniqueId( Str2Id( GetTTSettings()->pDisplayHidWin->GetDisplayText().GetToken( '|' ) ) );
1551 					GetTTSettings()->pDisplayHidWin->ClearDisplayTextModified();
1552 				}
1553 			}
1554 /*			if ( Application::GetLastInputInterval() > 5000 )	// 5 Sekunden lang nix geschehen
1555 			{
1556 				GetTTSettings()->pDisplayHidWin->ToTop( TOTOP_NOGRABFOCUS );
1557 			}
1558 */
1559 			if ( GetTTSettings()->pDisplayHidWin->IsSendData() /*&& bBool2*/ && GetTTSettings()->Act )
1560 			{
1561 				if ( !StatementFlow::bSending )
1562 				{	// Normalerweise syncronisierung �ber Protokoll. Hier ist das aber asyncron!!!
1563 					WriteControlData( GetTTSettings()->Act, GetTTSettings()->pDisplayHidWin->GetConfig() );
1564 					new StatementFlow( this, F_EndCommandBlock );	// Kommando zum Senden erzeugen und in que eintragen
1565 				}
1566 			}
1567 		}	//if ( GetTTSettings()->pDisplayHidWin->IsDraging() )
1568 		else
1569 		{
1570 			if ( GetTTSettings()->Act )
1571 			{
1572 				RESET_WIN(GetTTSettings()->Act);
1573 				GetTTSettings()->Act = NULL;
1574 			}
1575 		}
1576 
1577 		if ( pFirst == this )	// Sollte immer so sein, aber besser isses
1578 			if ( pNext )		// Befehle warten auf Ausf�hrung
1579 			{					// An Ende neu einsortieren
1580 				Advance();
1581 				QueStatement( NULL );
1582 			}
1583 //			{					// Ersten und 2. austauschen.
1584 //				pFirst = pNext;
1585 //				pNext = pNext->pNext;
1586 //				pFirst->pNext = this;
1587 //			}
1588 
1589 	}
1590 	else
1591 	{
1592 		delete GetTTSettings()->pDisplayHidWin;
1593 		GetTTSettings()->pDisplayHidWin = NULL;
1594 		GetTTSettings()->pDisplayInstance = NULL;
1595 	}
1596 
1597 	return GetTTSettings()->pDisplayHidWin != NULL;
1598 }
1599 
1600 class TranslateWin : public WorkWindow
1601 {
1602 private:
1603 	DECL_LINK( DoAccept, PushButton* );
1604 	DECL_LINK( DoNext, PushButton* );
1605 	DECL_LINK( DoSelect, PushButton* );
1606 	DECL_LINK( DoRestore, PushButton* );
1607 	DECL_LINK( TranslationChanged, Edit* );
1608 	DECL_LINK( ShowInplace, Timer* );
1609 
1610 	Timer InplaceTimer;
1611 
1612 //	virtual void MouseButtonUp( const MouseEvent& rMEvt );
1613 //	virtual void MouseMove( const MouseEvent& rMEvt );
1614 
1615 	PushButton PushButtonTT_PB_NEXT;
1616 	GroupBox GroupBoxTT_GB_TRANSLATION;
1617 	Edit EditTT_E_NEW;
1618 	GroupBox GroupBoxTT_GB_COMMENT;
1619 	Edit EditTT_E_COMMENT;
1620 	PushButton PushButtonTT_PB_ACCEPT;
1621 	FixedText FixedTextTT_FT_OLD;
1622 	PushButton PushButtonTT_PB_SELECT;
1623 	PushButton PushButtonTT_PB_RESTORE;
1624 
1625 	Window *Old;
1626 	Window *Act;
1627 	Window *pTranslateWin;
1628 	sal_Bool bSelecting;
1629 
1630 	sal_Bool bAvailable;
1631 	sal_Bool bNext;
1632 
1633 	sal_Bool TestChangedDataSaved();
1634 
1635 
1636 	sal_uLong nEventHookID;
1637 	static long stub_VCLEventHookProc( NotifyEvent& rEvt, void* pData )
1638 	{
1639 		return ((TranslateWin*)pData)->VCLEventHook( rEvt );
1640 	}
1641 
1642 	long VCLEventHook( NotifyEvent& rEvt );
1643 
1644 public:
1645 	TranslateWin();
1646 	~TranslateWin();
1647 
1648 	static String MarkShortcutErrors( Window* pBase, sal_Bool bMark );
1649 
1650 	sal_Bool IsTranslationAvailable(){ return bAvailable; }
1651 	sal_Bool IsNextDialog(){ return bNext; }
1652 	void ResetNextDialog(){ bNext = sal_False; }
1653 
1654 	Window* GetTranslationWindow(){ return pTranslateWin; }
1655 	String GetOriginalText(){ return FixedTextTT_FT_OLD.GetText(); }
1656 	String GetTranslationText(){ return EditTT_E_NEW.GetText(); }
1657 	String GetComment(){ return EditTT_E_COMMENT.GetText(); }
1658 
1659 	void EnableTranslation();
1660 };
1661 
1662 TranslateWin::TranslateWin()
1663 : WorkWindow( NULL, TTProperties::GetSvtResId( TT_INLINE_TRANSLATION ) )
1664 , PushButtonTT_PB_NEXT( this, TTProperties::GetSvtResId( TT_PB_NEXT ) )
1665 , GroupBoxTT_GB_TRANSLATION( this, TTProperties::GetSvtResId( TT_GB_TRANSLATION ) )
1666 , EditTT_E_NEW( this, TTProperties::GetSvtResId( TT_E_NEW ) )
1667 , GroupBoxTT_GB_COMMENT( this, TTProperties::GetSvtResId( TT_GB_COMMENT ) )
1668 , EditTT_E_COMMENT( this, TTProperties::GetSvtResId( TT_E_COMMENT ) )
1669 , PushButtonTT_PB_ACCEPT( this, TTProperties::GetSvtResId( TT_PB_ACCEPT ) )
1670 , FixedTextTT_FT_OLD( this, TTProperties::GetSvtResId( TT_FT_OLD ) )
1671 , PushButtonTT_PB_SELECT( this, TTProperties::GetSvtResId( TT_PB_SELECT ) )
1672 , PushButtonTT_PB_RESTORE( this, TTProperties::GetSvtResId( TT_PB_RESTORE ) )
1673 , Old( NULL )
1674 , Act( NULL )
1675 , pTranslateWin( NULL )
1676 , bSelecting( sal_False )
1677 , bAvailable( sal_False )
1678 , bNext( sal_False )
1679 {
1680     FreeResource();
1681 	PushButtonTT_PB_NEXT.SetClickHdl( LINK( this, TranslateWin, DoNext ) );
1682 	PushButtonTT_PB_ACCEPT.SetClickHdl( LINK( this, TranslateWin, DoAccept ) );
1683 	PushButtonTT_PB_SELECT.SetClickHdl( LINK( this, TranslateWin, DoSelect ) );
1684 	PushButtonTT_PB_RESTORE.SetClickHdl( LINK( this, TranslateWin, DoRestore ) );
1685 	EditTT_E_NEW.SetModifyHdl( LINK( this, TranslateWin, TranslationChanged ) );
1686 	InplaceTimer.SetTimeout( 250 );
1687 	InplaceTimer.SetTimeoutHdl( LINK( this, TranslateWin, ShowInplace ) );
1688 	EnableAlwaysOnTop();
1689 	nEventHookID = Application::AddEventHook( stub_VCLEventHookProc, this );
1690 }
1691 
1692 TranslateWin::~TranslateWin()
1693 {
1694 	Application::RemoveEventHook( nEventHookID );
1695 }
1696 
1697 sal_Bool TranslateWin::TestChangedDataSaved()
1698 {
1699 	if ( ( EditTT_E_NEW.GetText().CompareTo( FixedTextTT_FT_OLD.GetText() ) != COMPARE_EQUAL
1700 			|| EditTT_E_COMMENT.GetText().Len() )
1701 		&& PushButtonTT_PB_ACCEPT.IsEnabled() )
1702 	{
1703 		return MessBox( this, TTProperties::GetSvtResId( TT_DISCARD_CHANGED_DATA ) ).Execute() == RET_YES;
1704 	}
1705 	else
1706 		return sal_True;
1707 }
1708 
1709 IMPL_LINK( TranslateWin, DoAccept, PushButton*, EMPTYARG )
1710 {
1711 	PushButtonTT_PB_SELECT.Disable();
1712 	PushButtonTT_PB_NEXT.Disable();
1713 		PushButtonTT_PB_RESTORE.Disable();
1714 	EditTT_E_NEW.Disable();
1715 	EditTT_E_COMMENT.Disable();
1716 	PushButtonTT_PB_ACCEPT.Disable();
1717 	bAvailable = sal_True;
1718 	return 0;
1719 }
1720 
1721 IMPL_LINK( TranslateWin, DoNext, PushButton*, EMPTYARG )
1722 {
1723 	if ( TestChangedDataSaved() )
1724 	{
1725 		PushButtonTT_PB_SELECT.Disable();
1726 		PushButtonTT_PB_NEXT.Disable();
1727 		PushButtonTT_PB_RESTORE.Disable();
1728 		EditTT_E_NEW.Disable();
1729 		EditTT_E_COMMENT.Disable();
1730 		PushButtonTT_PB_ACCEPT.Disable();
1731 		bNext = sal_True;
1732 	}
1733 	return 0;
1734 }
1735 
1736 IMPL_LINK( TranslateWin, DoSelect, PushButton*, EMPTYARG )
1737 {
1738 	if ( bSelecting )
1739 	{
1740 //		ReleaseMouse();
1741 		bSelecting = sal_False;
1742 	}
1743 	else
1744 	{
1745 		if ( TestChangedDataSaved() )
1746 		{
1747 			PushButtonTT_PB_RESTORE.Disable();
1748 //			CaptureMouse();
1749 			bSelecting = sal_True;
1750 		}
1751 	}
1752 	return 0;
1753 }
1754 
1755 IMPL_LINK( TranslateWin, DoRestore, PushButton*, EMPTYARG )
1756 {
1757 	String sTT_E_OLD( FixedTextTT_FT_OLD.GetText());
1758 	sTT_E_OLD.SearchAndReplaceAll( CUniString("\\n"), CUniString("\n") );
1759 	sTT_E_OLD.SearchAndReplaceAll( CUniString("\\t"), CUniString("\t") );
1760 
1761 	String sTT_E_NEW( EditTT_E_NEW.GetText());
1762 	sTT_E_NEW.SearchAndReplaceAll( CUniString("\\n"), CUniString("\n") );
1763 	sTT_E_NEW.SearchAndReplaceAll( CUniString("\\t"), CUniString("\t") );
1764 
1765 	if ( StatementList::WinPtrValid( pTranslateWin ) && pTranslateWin->GetText().CompareTo( sTT_E_NEW ) == COMPARE_EQUAL )
1766 	{	// Im ersten schritt nur in der UI zur�ck
1767 		pTranslateWin->SetText( sTT_E_OLD );
1768 	}
1769 	else
1770 	{	// Im zweite Schritt auch den eingegebenen Text
1771 		EditTT_E_NEW.SetText( FixedTextTT_FT_OLD.GetText() );
1772 		PushButtonTT_PB_RESTORE.Disable();
1773 	}
1774 	if ( StatementList::WinPtrValid( pTranslateWin ) )
1775 		MarkShortcutErrors( pTranslateWin->GetWindow( WINDOW_OVERLAP ), sal_True );
1776 	return 0;
1777 }
1778 
1779 IMPL_LINK( TranslateWin, TranslationChanged, Edit*, pEdit )
1780 {
1781     (void) pEdit; /* avoid warning about unused parameter */
1782 	PushButtonTT_PB_RESTORE.Enable();
1783 	InplaceTimer.Start();
1784 	return 0;
1785 }
1786 
1787 IMPL_LINK( TranslateWin, ShowInplace, Timer*, EMPTYARG )
1788 {
1789 	PushButtonTT_PB_RESTORE.Enable();
1790 	if ( StatementList::WinPtrValid( pTranslateWin ) )
1791 	{
1792 		String sTT_E_NEW( EditTT_E_NEW.GetText());
1793 		// alle CRs UnQuoten
1794 		sTT_E_NEW.SearchAndReplaceAll( CUniString("\\n"), CUniString("\n") );
1795 		// alle TABSs UnQuoten
1796 		sTT_E_NEW.SearchAndReplaceAll( CUniString("\\t"), CUniString("\t") );
1797 		pTranslateWin->SetText( sTT_E_NEW );
1798 
1799 		MarkShortcutErrors( pTranslateWin->GetWindow( WINDOW_OVERLAP ), sal_True );
1800 	}
1801 	return 0;
1802 }
1803 
1804 long TranslateWin::VCLEventHook( NotifyEvent& rEvt )
1805 {
1806 	if ( EVENT_MOUSEMOVE == rEvt.GetType() )
1807 	{
1808 		if ( bSelecting )
1809 		{
1810 			const MouseEvent *pMEvt = rEvt.GetMouseEvent();
1811 			Old = Act;
1812 			Act = rEvt.GetWindow();
1813 
1814 			if ( Act )
1815 			{
1816 				Window *pWin = Act;
1817 				sal_uInt16 i;
1818 				for ( i = 0 ; i < Act->GetChildCount() ; i++ )
1819 				{
1820 					pWin = Act->GetChild(i);
1821 					Rectangle aWinPosSize( pWin->GetPosPixel(), pWin->GetSizePixel() );
1822 
1823 					if ( ( pWin->IsMouseTransparent() || !pWin->IsEnabled() ) && aWinPosSize.IsInside( pMEvt->GetPosPixel() ) )
1824 					{
1825 						Act = pWin;
1826 						break;
1827 					}
1828 				}
1829 			}
1830 
1831             if ( !StatementList::WinPtrValid ( Old ) )
1832                 Old = NULL;
1833 
1834 			if ( Act != Old )
1835 			{
1836 				if ( Old )
1837 				{
1838 					Window *pWin;
1839 					if ( Old->IsMouseTransparent() && Old->GET_REAL_PARENT() )
1840 						pWin = Old->GET_REAL_PARENT();
1841 					else
1842 						pWin = Old;
1843 					RESET_WIN(pWin);
1844 				}
1845 				if ( Act )
1846 				{
1847 					SET_WIN(Act);
1848 					FixedTextTT_FT_OLD.SetText( Act->GetText() );
1849 				}
1850 				else
1851 					FixedTextTT_FT_OLD.SetText( String() );
1852 			}
1853 			else if ( Act )
1854 			{
1855 	//			SET_WIN(Act);
1856 			}
1857 	/*		if ( Application::GetLastInputInterval() > 5000 )	// 5 Sekunden lang nix geschehen
1858 			{
1859 				ToTop();
1860 			}
1861 	*/
1862 		}	//if ( bSelecting )
1863 		else
1864 		{
1865 			if ( Act )
1866 			{
1867 				if ( Act->IsMouseTransparent() && Act->GET_REAL_PARENT() )
1868 					Act = Act->GET_REAL_PARENT();
1869 				RESET_WIN(Act);
1870 				Act = NULL;
1871 			}
1872 		}
1873 	}
1874 	else if ( EVENT_MOUSEBUTTONUP == rEvt.GetType() )
1875 	{
1876 		if ( bSelecting )
1877 		{
1878 			pTranslateWin = Act;
1879 			if ( pTranslateWin )
1880 			{
1881 				MarkShortcutErrors( pTranslateWin->GetWindow( WINDOW_OVERLAP ), sal_True );
1882 				// alle CRs quoten (NF)
1883 				String sTT_E_NEW( pTranslateWin->GetText());
1884 				sTT_E_NEW.SearchAndReplaceAll( CUniString("\n"), CUniString("\\n") );
1885 				// alle TABSs quoten ()
1886 				sTT_E_NEW.SearchAndReplaceAll( CUniString("\t"), CUniString("\\t") );
1887 
1888 				FixedTextTT_FT_OLD.SetText( sTT_E_NEW );
1889 				EditTT_E_NEW.SetText( sTT_E_NEW );
1890 				EditTT_E_NEW.Enable();
1891 				EditTT_E_NEW.GrabFocus();
1892 				EditTT_E_COMMENT.SetText( String() );
1893 				EditTT_E_COMMENT.Enable();
1894 				PushButtonTT_PB_ACCEPT.Enable();
1895 			}
1896 	//		ReleaseMouse();
1897 			bSelecting = sal_False;
1898 		}
1899 	}
1900 
1901 	return 0;
1902 }
1903 
1904 #define FDS_ACTION_COLLECT	1
1905 #define FDS_ACTION_MARK		2
1906 #define FDS_ACTION_UNMARK	3
1907 
1908 class FindShortcutErrors: public Search
1909 {
1910 	String aShortcuts,aDoubleShortcuts;
1911 	sal_uInt16 nAction;
1912 public:
1913 	FindShortcutErrors();
1914 	virtual sal_Bool IsWinOK( Window *pWin );
1915 	void SetAction( sal_uInt16 nA );
1916 	String GetDoubleShortcuts() { return aDoubleShortcuts; }
1917 };
1918 
1919 FindShortcutErrors::FindShortcutErrors()
1920 : Search( SEARCH_NOOVERLAP | SEARCH_NO_TOPLEVEL_WIN )
1921 {
1922 	SetAction( FDS_ACTION_COLLECT );	// Wir fange immer mit sammeln an, ODER??
1923 }
1924 
1925 void FindShortcutErrors::SetAction( sal_uInt16 nA )
1926 {
1927 	nAction = nA;
1928 	if ( FDS_ACTION_COLLECT == nAction )
1929 	{
1930 		aShortcuts = UniString();
1931 		aDoubleShortcuts = UniString();
1932 	}
1933 }
1934 
1935 sal_Bool FindShortcutErrors::IsWinOK( Window *pWin )
1936 {
1937 	if ( pWin->IsReallyVisible() )
1938 	{
1939 		String aText = pWin->GetText();
1940 		xub_StrLen nPos = aText.Search('~');
1941 		String aShortcut;
1942 		sal_Bool bHasAccel = sal_False;
1943 		if ( nPos != STRING_NOTFOUND )
1944 		{
1945 			aShortcut = aText.Copy( nPos+1, 1 );
1946 			aShortcut.ToLowerAscii();
1947 			bHasAccel = aShortcut.Len() == 1;
1948 		}
1949 
1950 		switch ( nAction )
1951 		{
1952 			case FDS_ACTION_COLLECT:
1953 				{
1954 					if ( aShortcuts.Search( aShortcut ) != STRING_NOTFOUND )
1955 						aDoubleShortcuts += aShortcut;
1956 					else
1957 						aShortcuts += aShortcut;
1958 				}
1959 				break;
1960 			case FDS_ACTION_MARK:
1961 				{
1962 					sal_Bool bMissing = sal_False;
1963 					if ( !bHasAccel && aText.Len() )	// should there be an accelarator defined
1964 					{
1965 
1966 						Window* 	pChild;
1967 						pChild = pWin->GetWindow( WINDOW_CLIENT );
1968 
1969 						if ( (pChild->GetType() == WINDOW_RADIOBUTTON) ||
1970 							 (pChild->GetType() == WINDOW_IMAGERADIOBUTTON) ||
1971 							 (pChild->GetType() == WINDOW_CHECKBOX) ||
1972 							 (pChild->GetType() == WINDOW_TRISTATEBOX) ||
1973 							 (pChild->GetType() == WINDOW_PUSHBUTTON) )
1974 						{
1975 							if ( !pChild->GetText().EqualsAscii( "..." ) )
1976 								bMissing = sal_True;
1977 						}
1978 
1979 						if ( pChild->GetType() == WINDOW_FIXEDTEXT )
1980 						{
1981 							Window* pTempChild = pWin->GetWindow( WINDOW_NEXT );
1982 							if ( pTempChild )
1983 								pTempChild = pTempChild->GetWindow( WINDOW_CLIENT );
1984 
1985 							if ( pTempChild && pChild->GetText().Len() )
1986 							{
1987 								if ( (pTempChild->GetType() == WINDOW_EDIT) ||
1988 									 (pTempChild->GetType() == WINDOW_MULTILINEEDIT) ||
1989 									 (pTempChild->GetType() == WINDOW_SPINFIELD) ||
1990 									 (pTempChild->GetType() == WINDOW_PATTERNFIELD) ||
1991 									 (pTempChild->GetType() == WINDOW_NUMERICFIELD) ||
1992 									 (pTempChild->GetType() == WINDOW_METRICFIELD) ||
1993 									 (pTempChild->GetType() == WINDOW_CURRENCYFIELD) ||
1994 									 (pTempChild->GetType() == WINDOW_DATEFIELD) ||
1995 									 (pTempChild->GetType() == WINDOW_TIMEFIELD) ||
1996 									 (pTempChild->GetType() == WINDOW_LISTBOX) ||
1997 									 (pTempChild->GetType() == WINDOW_MULTILISTBOX) ||
1998 									 (pTempChild->GetType() == WINDOW_COMBOBOX) ||
1999 									 (pTempChild->GetType() == WINDOW_PATTERNBOX) ||
2000 									 (pTempChild->GetType() == WINDOW_NUMERICBOX) ||
2001 									 (pTempChild->GetType() == WINDOW_METRICBOX) ||
2002 									 (pTempChild->GetType() == WINDOW_CURRENCYBOX) ||
2003 									 (pTempChild->GetType() == WINDOW_DATEBOX) ||
2004 									 (pTempChild->GetType() == WINDOW_TIMEBOX) )
2005 								{
2006 									bMissing = sal_True;
2007 								}
2008 							}
2009 						}
2010 					}
2011 
2012 					if ( bHasAccel && aDoubleShortcuts.Search( aShortcut ) != STRING_NOTFOUND )
2013 					{
2014 						if ( pWin->GetType() == WINDOW_GROUPBOX )
2015 							pWin->SetControlForeground( Color( COL_LIGHTRED ) );
2016 						else
2017 						{
2018 							pWin->SetControlBackground();
2019 							Color aCol(COL_GRAY);
2020 							aCol.SetRed( 0xff );
2021 							pWin->SetControlBackground( aCol );
2022 						}
2023 					}
2024 					else if ( bMissing )
2025 					{
2026 						pWin->SetControlBackground();
2027 						Color aCol(COL_GRAY);
2028 						aCol.SetRed( 0xff );
2029 						aCol.SetGreen( 0xff );
2030 						pWin->SetControlBackground( aCol );
2031 					}
2032 					else
2033 					{
2034 						pWin->SetControlForeground();
2035 						pWin->SetControlBackground();
2036 					}
2037 				}
2038 				break;
2039 			case FDS_ACTION_UNMARK:
2040 				{
2041 					pWin->SetControlForeground();
2042 					pWin->SetControlBackground();
2043 				}
2044 				break;
2045 		}
2046 	}
2047 	else
2048 		if ( FDS_ACTION_MARK == nAction || FDS_ACTION_UNMARK == nAction )
2049 		{
2050 			pWin->SetControlForeground();
2051 			pWin->SetControlBackground();
2052 		}
2053 
2054 	return sal_False;
2055 }
2056 
2057 String TranslateWin::MarkShortcutErrors( Window* pBase, sal_Bool bMark )
2058 {
2059 	if ( pBase )
2060 	{
2061 		FindShortcutErrors aFinder;
2062 		if ( bMark )
2063 		{
2064 			StatementList::SearchAllWin( pBase, aFinder, sal_True );	// collect Shortcuts first
2065 			aFinder.SetAction( FDS_ACTION_MARK );
2066 		}
2067 		else
2068 			aFinder.SetAction( FDS_ACTION_UNMARK );
2069 		StatementList::SearchAllWin( pBase, aFinder, sal_True );
2070 		return aFinder.GetDoubleShortcuts();
2071 	}
2072 	return UniString();
2073 }
2074 
2075 void TranslateWin::EnableTranslation()
2076 {
2077 	PushButtonTT_PB_SELECT.Enable();
2078 	PushButtonTT_PB_NEXT.Enable();
2079 	bAvailable = sal_False;
2080 	bNext = sal_False;
2081 }
2082 
2083 void StatementCommand::Translate()
2084 {
2085 	// Es wurde eine initale UniqueId mitgegeben. Dann nur die dopelten Shortcuts liefern
2086 	if( (nParams & PARAM_STR_1) && nLNr1 )
2087 	{
2088 		String aDouble;
2089 		Window *pWin = SearchTree( Str2Id( aString1 ) ,sal_False );
2090 		if ( pWin )
2091 		{
2092 			pWin = pWin->GetWindow( WINDOW_OVERLAP );
2093 			aDouble = TranslateWin::MarkShortcutErrors( pWin, sal_True );
2094 		}
2095 		pRet->GenReturn ( RET_Value, nMethodId, aDouble );
2096 		return;
2097 	}
2098 
2099 	if ( !GetTTSettings()->pTranslateWin )
2100 	{
2101 		GetTTSettings()->pTranslateWin = new TranslateWin;
2102 		GetTTSettings()->bToTop = sal_True;
2103 	}
2104 
2105 	GetTTSettings()->pTranslateWin->Show();
2106 	if ( GetTTSettings()->bToTop )
2107 	{
2108 		GetTTSettings()->pTranslateWin->ToTop();
2109 		GetTTSettings()->bToTop = sal_False;
2110 	}
2111 
2112 //	GetTTSettings()->pTranslateWin->GetWindow( WINDOW_OVERLAP )->Enable( sal_True, sal_True );
2113 	GetTTSettings()->pTranslateWin->GetWindow( WINDOW_OVERLAP )->EnableInput( sal_True, sal_True );
2114 
2115 	if ( GetTTSettings()->pTranslateWin->IsTranslationAvailable() )
2116 	{
2117 		String aTranslation;
2118 		Window* pTranslationWindow = GetTTSettings()->pTranslateWin->GetTranslationWindow();
2119 
2120 		DBG_ASSERT( pTranslationWindow, "Kein Translation Window" );
2121 
2122 		if ( WinPtrValid( pTranslationWindow ) )
2123 		{
2124 			if ( pTranslationWindow->GetType() == WINDOW_BORDERWINDOW && pTranslationWindow->GetWindow( WINDOW_CLIENT ) )
2125 			{
2126 				Window* pNew = pTranslationWindow->GetWindow( WINDOW_CLIENT );
2127 				// Bei Dockingwindoes das kanze Geraffel von Docking Floating �berspringen
2128 				while ( IsDialog( pNew ) && !pNew->GetUniqueOrHelpId().getLength() && pNew->GetChildCount() == 1 )
2129 					pNew = pNew->GetChild( 0 );
2130 				pTranslationWindow = pNew;
2131 			}
2132 
2133 			aTranslation = CUniString("0;");
2134 
2135 			aTranslation += Id2Str( pTranslationWindow->GetUniqueOrHelpId() );
2136 			aTranslation += ';';
2137 
2138 			aTranslation += TypeString( pTranslationWindow->GetType() );
2139 			aTranslation += ';';
2140 
2141 			Window* pParentDialog = pTranslationWindow;
2142 			while ( pParentDialog && !IsDialog( pParentDialog ) )
2143 			{
2144 				pParentDialog = pParentDialog->GET_REAL_PARENT();
2145 			}
2146 
2147 			if ( pParentDialog )
2148 			{
2149 				aTranslation += Id2Str(pParentDialog->GetUniqueOrHelpId());
2150 				aTranslation += ';';
2151 				aTranslation += TypeString( pParentDialog->GetType() );
2152 			}
2153 			else
2154 				aTranslation.AppendAscii( "0;" );		// Zahl + leerer String
2155 			aTranslation += ';';
2156 
2157 			aTranslation += '\"';
2158 			aTranslation += GetTTSettings()->pTranslateWin->GetOriginalText();
2159 			aTranslation += '\"';
2160 
2161 			aTranslation += ';';
2162 
2163 			aTranslation += '\"';
2164 			aTranslation += GetTTSettings()->pTranslateWin->GetTranslationText();
2165 			aTranslation += '\"';
2166 
2167 			aTranslation += ';';
2168 
2169 			aTranslation += '\"';
2170 			aTranslation += GetTTSettings()->pTranslateWin->GetComment();
2171 			aTranslation += '\"';
2172 
2173 			// alle CRs quoten (NF)
2174 			aTranslation.SearchAndReplaceAll( CUniString("\n"), CUniString("\\n") );
2175 			// alle TABSs quoten ()
2176 			aTranslation.SearchAndReplaceAll( CUniString("\t"), CUniString("\\t") );
2177 
2178 			pRet->GenReturn ( RET_Value, nMethodId, aTranslation );
2179 			GetTTSettings()->pTranslateWin->EnableTranslation();
2180 			GetTTSettings()->bToTop = sal_True;
2181 		}
2182 		else
2183 		{
2184 			pRet->GenReturn ( RET_Value, nMethodId, String() );
2185 			GetTTSettings()->pTranslateWin->EnableTranslation();
2186 			ErrorBox err( GetTTSettings()->pTranslateWin, TTProperties::GetSvtResId( TT_NO_CONTROL ));
2187 			err.Execute();
2188 			GetTTSettings()->bToTop = sal_True;
2189 		}
2190 
2191 	}
2192 	else if ( GetTTSettings()->pTranslateWin->IsNextDialog() )
2193 	{
2194 		pRet->GenReturn ( RET_Value, nMethodId, CUniString("1") );
2195 		GetTTSettings()->pTranslateWin->ResetNextDialog();
2196 		GetTTSettings()->pTranslateWin->LoseFocus();
2197 		GetTTSettings()->bToTop = sal_True;
2198 	}
2199 	else
2200 	{
2201 		GetTTSettings()->pTranslateWin->EnableTranslation();
2202 		pRet->GenReturn ( RET_Value, nMethodId, String() );
2203 	}
2204 }
2205 
2206 Window* StatementCommand::GetNextOverlap( Window* pBase )
2207 {	// Findet irgendwelche Overlap-Fenster, die schlie�bar aussehen
2208 	// Eventuell mu� noch die Auswahl verfeinert werden.
2209 
2210 	if ( pBase->GetType() != WINDOW_BORDERWINDOW )
2211 		pBase = pBase->GetWindow( WINDOW_OVERLAP );
2212 
2213 	Window *pControl = NULL;
2214 	if ( pBase->GetWindow( WINDOW_FIRSTOVERLAP ) )
2215 	{
2216 		pControl = GetNextOverlap( pBase->GetWindow( WINDOW_FIRSTOVERLAP ) );
2217 	}
2218 
2219 	if ( !pControl && pBase->GetWindow( WINDOW_NEXT ) )
2220 	{
2221 		pControl = GetNextOverlap( pBase->GetWindow( WINDOW_NEXT ) );
2222 	}
2223 
2224 	if ( !pControl )
2225 	{
2226 		Window *pTest = pBase->GetWindow( WINDOW_CLIENT );
2227 		if ( IsAccessable (pTest)
2228 			&& pTest->IsEnabled()
2229 			&& pTest->IsVisible()
2230 			&& ((pTest->GetStyle() & WB_CLOSEABLE ) || (pBase->GetStyle() & WB_CLOSEABLE )) )
2231 			return pTest;
2232 		else
2233 			return NULL;
2234 	}
2235 	else
2236 		return pControl;
2237 }
2238 
2239 Window* StatementCommand::GetNextRecoverWin()
2240 {
2241 	// �ber die TopLevelWindows der App iterieren
2242 	Window* pBase = Application::GetFirstTopLevelWindow();
2243 	Window *pControl = NULL;
2244     Window* pMyFirstDocFrame = NULL;
2245 	while ( pBase )
2246 	{
2247 		// zuerst weitere Fenster auf dem Fenster suchen und schliessen
2248 		pControl = GetNextOverlap( pBase );
2249         if ( pControl && pControl->GetType() == WINDOW_HELPTEXTWINDOW )
2250         {}  // skip it
2251         else
2252         {
2253 		    if ( pControl && pControl->IsVisible() && !IsFirstDocFrame( pControl ) && !IsIMEWin( pControl ) )
2254 		    {
2255                 Window* pTB = pControl->GetChild( 0 );
2256                 if ( pControl->GetChildCount() == 1 && pTB->GetType() == WINDOW_TOOLBOX )
2257 //				    return pTB;
2258                     ;   // do not act on floating toolboxes #i38796
2259 			    else
2260 				    return pControl;
2261 		    }
2262 
2263 		    // dann das Fenster selbst Schliessen
2264        	    // erstes DocWin �berspringen
2265             // Assumption that Doc Windows are Borderwindows and ButtonDialog and such are not
2266 		    if ( pBase->IsVisible() && !IsFirstDocFrame( pBase ) && pBase->GetType() != WINDOW_BORDERWINDOW && !IsIMEWin( pBase ) )
2267 			    return pBase;
2268 
2269             if ( !pMyFirstDocFrame && IsFirstDocFrame( pBase ) )
2270                 pMyFirstDocFrame = pBase;
2271         }
2272 
2273 		pBase = Application::GetNextTopLevelWindow( pBase );
2274 	}
2275 #ifdef RESET_APPLICATION_TO_BACKING_WINDOW
2276     // close the FirstDocFrame last, It will not be closed, but the Document inside will be closed.
2277     if ( IsDocWin( pMyFirstDocFrame ) )
2278         return pMyFirstDocFrame;
2279 #endif // def RESET_APPLICATION_TO_BACKING_WINDOW
2280 
2281 	return NULL;
2282 }
2283 
2284 sal_Bool StatementCommand::Execute()
2285 {
2286 	if ( IsError )
2287 	{
2288 #if OSL_DEBUG_LEVEL > 1
2289 		m_pDbgWin->AddText( "Skipping Command: " );
2290 		m_pDbgWin->AddText( String::CreateFromInt32( nMethodId ) );
2291 		m_pDbgWin->AddText( "\n" );
2292 		#endif
2293 
2294 		Advance();
2295 		delete this;
2296 		return sal_True;
2297 	}
2298 
2299 	InitProfile();
2300 #if OSL_DEBUG_LEVEL > 1
2301 	m_pDbgWin->AddText( "Executing Command: " );
2302 	m_pDbgWin->AddText( String::CreateFromInt32( nMethodId ) );
2303 	m_pDbgWin->AddText( "\n" );
2304 #endif
2305 
2306 
2307 
2308 
2309 
2310 #if OSL_DEBUG_LEVEL > 1
2311 #define	REPORT_WIN_CLOSED(pControl, aInfo)			\
2312 	_REPORT_WIN_CLOSED(pControl, aInfo)				\
2313 	m_pDbgWin->AddText( aInfo.AppendAscii(" \"").Append( pControl->GetText() ).AppendAscii("\" geschlossen, RType = ").Append( TypeString(pControl->GetType()) ).AppendAscii(", UId = ").Append( UIdString( pControl->GetUniqueOrHelpId() ) ) );
2314 #else
2315 #define	REPORT_WIN_CLOSED(pControl, aInfo) _REPORT_WIN_CLOSED(pControl, aInfo)
2316 #endif
2317 
2318 #define	REPORT_WIN_CLOSEDc(pControl, aInfo )		\
2319 	REPORT_WIN_CLOSED(pControl, CUniString(aInfo) )
2320 
2321 #define	_REPORT_WIN_CLOSED(pControl, aInfo)			\
2322 	if ( aString1.Len() )							\
2323 		aString1 += '\n';							\
2324 	aString1 += aInfo;								\
2325 	aString1.AppendAscii(" \"");					\
2326 	aString1 += pControl->GetText();				\
2327 	aString1.AppendAscii("\" geschlossen, RType = ");\
2328 	aString1 += TypeString(pControl->GetType());	\
2329 	aString1.AppendAscii(", UId = ");				\
2330 	aString1 += UIdString(pControl->GetUniqueOrHelpId());
2331 
2332 
2333 	switch ( nMethodId )
2334 	{
2335 		case RC_AppDelay:
2336 			if ( !bBool1 )
2337 			{
2338 				nLNr1 = Time().GetTime() + nNr1/10;
2339 				bBool1 = sal_True;
2340 			}
2341 			if ( Time().GetTime() < long(nLNr1) )	// Aktuelle Zeit kleiner Endzeit
2342 				return sal_False;
2343 			break;
2344 		case RC_DisplayHid:
2345 			if ( DisplayHID() )
2346 				return sal_False;
2347 			break;
2348 		case RC_ResetApplication:
2349 			{
2350 				if ( !bBool1 )
2351 				{
2352 					nRetryCount = 150;		// das sollte reichen.
2353 					bBool1 = sal_True;			// Nur beim ersten mal!
2354 					nNr1 = 1;				// Welcher Button ist dran?
2355 					nLNr1 = 0;				// Speichern des AppWin
2356 					aString1 = UniString();	// Liste der geschlossenen Fenster
2357 
2358 					// So da� nacher auch wieder alles auf Default steht
2359 					nUseBindings = 0;
2360                     bCatchGPF = sal_True;
2361                     bUsePostEvents = sal_True;
2362 
2363 				    aSubMenuId1 = 0;
2364 				    aSubMenuId2 = 0;
2365 				    aSubMenuId3 = 0;
2366                     pMenuWindow = NULL;
2367 				}
2368 				if ( !nRetryCount )
2369 					ReportError( GEN_RES_STR0( S_RESETAPPLICATION_FAILED_COMPLEX ) );
2370 
2371 				Window *pControl = GetNextRecoverWin();
2372 
2373 				if ( pControl )
2374 				{
2375                     bBool2 = sal_False; // flag for wait when all windows are closed
2376 					pControl->GrabFocus();
2377 
2378 					if (	pControl->GetType() != WINDOW_DOCKINGWINDOW
2379 						 && pControl->GetType() != WINDOW_FLOATINGWINDOW
2380 						 && pControl->GetType() != WINDOW_MODELESSDIALOG
2381 						 && pControl->GetType() != WINDOW_WORKWINDOW
2382 						 && pControl->GetType() != WINDOW_TOOLBOX
2383 						 && pControl->GetType() != WINDOW_BORDERWINDOW
2384 						 && nRetryCount-- )
2385 					{
2386 						short nRT = ImpGetRType( pControl );
2387 
2388 						if ( nRT == C_TabControl && pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_TABDIALOG )
2389 						{	// Bei Tabcontrol den zugeh�rigen Tabdialog nehmen
2390 							pControl = pControl->GET_REAL_PARENT();
2391 							nRT = ImpGetRType( pControl );
2392 						}
2393 
2394 						switch( nRT )
2395 						{
2396 							case C_ModalDlg:
2397 							case C_Dialog:
2398 							case C_TabDlg:
2399 								REPORT_WIN_CLOSEDc(pControl, "Dialog");
2400 								SET_WINP_CLOSING(pControl);
2401 								((SystemWindow*)pControl)->Close();
2402 								break;
2403 							case C_WorkWin:
2404 								break;
2405 							case C_MessBox:
2406 							case C_InfoBox:
2407 							case C_WarningBox:
2408 							case C_ErrorBox:
2409 							case C_QueryBox:
2410 							case C_ButtonDialog:
2411 								{
2412 									ButtonDialog* pBD = (ButtonDialog*)pControl;
2413 									// nNr1 >= 10 bedeutet (Custom)-Buttons durchgehen
2414 									if ( nNr1 >= 10+pBD->GetButtonCount() ) nNr1 = 1;
2415 									switch( nNr1 )
2416 									{
2417 										case 5:
2418 											if ( pBD->GetPushButton( BUTTONID_OK ) )
2419 											{
2420 												REPORT_WIN_CLOSEDc(pControl, "Message Box (OK)");
2421 												SET_WINP_CLOSING(pControl);
2422 												pBD->EndDialog(RET_OK);
2423 											}
2424 											nNr1 = 10;	// Nochmal alle Buttons der Reihe nach
2425 											break;
2426 										case 4:
2427 											if ( pBD->GetPushButton( BUTTONID_CANCEL ) )
2428 											{
2429 												REPORT_WIN_CLOSEDc(pControl, "Message Box (Cancel)");
2430 												SET_WINP_CLOSING(pControl);
2431 												pBD->EndDialog(RET_CANCEL);
2432 											}
2433 											nNr1++;
2434 											break;
2435 										case 3:
2436 											if ( pBD->GetPushButton( BUTTONID_YES ) )
2437 											{
2438 												REPORT_WIN_CLOSEDc(pControl, "Message Box (Yes)");
2439 												SET_WINP_CLOSING(pControl);
2440 												pBD->EndDialog(RET_YES);
2441 											}
2442 											nNr1++;
2443 											break;
2444 										case 2:		// BUG 48239
2445 										case 1:
2446 											if ( pBD->GetPushButton( BUTTONID_NO ) )
2447 											{
2448 												REPORT_WIN_CLOSEDc(pControl, "Message Box (No)");
2449 												SET_WINP_CLOSING(pControl);
2450 												pBD->EndDialog(RET_NO);
2451 											}
2452 											nNr1++;
2453 											break;
2454 										default:
2455 											{
2456 												sal_uInt16 nID = pBD->GetButtonId( nNr1-10 );
2457 												if ( nID != BUTTONID_HELP )
2458 												{
2459 													REPORT_WIN_CLOSED(pControl, CUniString("Message Box (").Append( UniString::CreateFromInt32(nID) ).AppendAscii(")"));
2460 													SET_WINP_CLOSING(pControl);
2461 													pBD->EndDialog(nID);
2462 												}
2463 												nNr1++;
2464 											}
2465 									}
2466 									break;
2467 								}
2468 							default:
2469 								DBG_ERROR( "Unknown Windowtype" );
2470 								REPORT_WIN_CLOSEDc(pControl, "Unknown Windowtype");
2471 								ReportError( GEN_RES_STR0( S_RESETAPPLICATION_FAILED_UNKNOWN ), pControl->GetType() );
2472                                 #if OSL_DEBUG_LEVEL > 1
2473 								m_pDbgWin->AddText( " Unbekannter Objekttyp aus UId" );
2474 								#endif
2475 								break;
2476 						}
2477 						return sal_False;
2478 					}
2479 					else
2480 					{
2481 						if ( (pControl->GetType() == WINDOW_DOCKINGWINDOW || pControl->GetType() == WINDOW_TOOLBOX) && nRetryCount-- )
2482 						{
2483 							if ( (((DockingWindow*)pControl)->GetStyle() | ((DockingWindow*)pControl)->GetFloatStyle()) & WB_CLOSEABLE )
2484 							{
2485 								REPORT_WIN_CLOSED(pControl, TypeString(pControl->GetType()));
2486 								SET_WINP_CLOSING(pControl);
2487 								((DockingWindow*)pControl)->Close();
2488 
2489 								// Eigentlich nur bei TaskWindows! Hoffen wir mal, da� keine anderen DockingWindows dazwischen hauen.
2490 								if ( (Window*)nLNr1 != pControl )
2491 									nNr1 = 1;		// Zum durchprobieren der Buttons beim Schlie�en
2492 								nLNr1 = (sal_uLong)pControl;
2493 
2494 								return sal_False;
2495 							}
2496 						}
2497 						if ( nRetryCount--
2498 								&& (	(pControl->GetType() == WINDOW_FLOATINGWINDOW)
2499 									||	(pControl->GetType() == WINDOW_MODELESSDIALOG)
2500 									||	(pControl->GetType() == WINDOW_WORKWINDOW)
2501 									||	(pControl->GetType() == WINDOW_BORDERWINDOW) ) )
2502 						{
2503 	//						if ( pControl->GetStyle() & WB_CLOSEABLE )
2504 							{
2505 #ifdef RESET_APPLICATION_TO_BACKING_WINDOW
2506                                 // Special handling for last Document; do not close the Frame, only the Document
2507                                 if ( GetDocWinCount() == 1 && IsDocFrame( pControl ) )
2508                                 {
2509                                     if ( IsDocWin( pControl ) )
2510                                     {
2511                                         if ( GetDocFrameMenuBar( pControl ) )
2512                                         {
2513                                             MenuBar* pMenu = GetDocFrameMenuBar( pControl );
2514                                             if ( pMenu->HasCloser() )
2515                                             {
2516 								                REPORT_WIN_CLOSED( pControl, TypeString(pControl->GetType()));
2517 								                SET_WINP_CLOSING(pControl);
2518 
2519                                                 pMenu->GetCloserHdl().Call( pMenu );
2520 
2521                                                 // nur bei TaskWindows!
2522                                                 if ( (Window*)nLNr1 != pControl )
2523 									                nNr1 = 1;		// Zum durchprobieren der Buttons beim Schlie�en
2524 								                nLNr1 = (sal_uLong)pControl;
2525 
2526                                                 return sal_False;
2527                                             }
2528                                         }
2529                                     }
2530                                 }
2531                                 else
2532 #endif // def RESET_APPLICATION_TO_BACKING_WINDOW
2533                                 {
2534 								    REPORT_WIN_CLOSED( pControl, TypeString(pControl->GetType()));
2535 								    SET_WINP_CLOSING(pControl);
2536 								    ((SystemWindow*)pControl)->Close();
2537 
2538                                     // Eigentlich nur bei TaskWindows!
2539                                     if ( (Window*)nLNr1 != pControl )
2540 									    nNr1 = 1;		// Zum durchprobieren der Buttons beim Schlie�en
2541 								    nLNr1 = (sal_uLong)pControl;
2542 
2543                                     return sal_False;
2544                                 }
2545 							}
2546 						}
2547 					}
2548 				}
2549                 // wait for some time if more windows show up
2550                 // E.g.: Floating toolbars on a Task which was hidden by another Task before
2551 			    if ( !bBool2 )
2552 			    {
2553 				    nLNr1 = Time().GetTime() + 100; // 100 = 1 Second
2554 				    bBool2 = sal_True;
2555 			    }
2556 			    if ( Time().GetTime() < long(nLNr1) )	// Aktuelle Zeit kleiner Endzeit
2557 				    return sal_False;
2558                 else
2559 				    pRet->GenReturn ( RET_Value, nMethodId, aString1);
2560 			}
2561 		    break;
2562 		case RC_WaitSlot:
2563             {
2564 			    if ( ! (nParams & PARAM_USHORT_1) )
2565 				    nNr1 = 1000;    // defaults to 1000 = 1 Sec.
2566 			    if ( !bBool1 )
2567 			    {
2568 				    nLNr1 = Time().GetTime() + nNr1/10;
2569 				    bBool1 = sal_True;
2570 			    }
2571 
2572                 if ( !bIsSlotInExecute )
2573     			    pRet->GenReturn ( RET_Value, nMethodId, comm_USHORT(CONST_WSFinished) );
2574                 else
2575                 {
2576 			        if ( Time().GetTime() < long(nLNr1) )	// Aktuelle Zeit kleiner Endzeit
2577 				        return sal_False;
2578     			    pRet->GenReturn ( RET_Value, nMethodId, comm_USHORT(CONST_WSTimeout) );
2579                 }
2580             }
2581 		    break;
2582 	}
2583 
2584 
2585 	Advance();
2586 
2587 
2588 	switch ( nMethodId )
2589 	{
2590 		case RC_AppDelay:		// Diese Befehle werden anderswo behandelt
2591 		case RC_DisplayHid:
2592 		case RC_ResetApplication:
2593 		case RC_WaitSlot:
2594 
2595 		case RC_AppAbort:		// Sofortiges L�schen aller Befehle
2596 			break;
2597 		case RC_Assert:
2598             {
2599                 ByteString aAssertion( "Diese Assertion wurde vom Testtool per Befehl ausgel�st" );
2600                 aAssertion = ByteString( String( aAssertion, RTL_TEXTENCODING_MS_1252 ), RTL_TEXTENCODING_UTF8 );
2601 			    DBG_ASSERT( !aString1.Len(), ByteString( aString1, RTL_TEXTENCODING_UTF8 ).GetBuffer() );
2602 			    DBG_ASSERT(  aString1.Len(), aAssertion.GetBuffer() );
2603 			    OSL_ENSURE( !aString1.Len(), ByteString( aString1, RTL_TEXTENCODING_UTF8 ).GetBuffer() );
2604 			    OSL_ENSURE(  aString1.Len(), aAssertion.GetBuffer() );
2605             }
2606 			break;
2607 		case RC_CaptureAssertions:
2608 #ifdef DBG_UTIL
2609 			if( !(nParams & PARAM_BOOL_1) || bBool1 )
2610 			{
2611 				DBG_INSTOUTERROR( DBG_OUT_TESTTOOL );
2612 				osl_setDebugMessageFunc( osl_TestToolDebugPrint );
2613 			}
2614 			else
2615 			{
2616 				DBG_INSTOUTERROR( DBG_OUT_MSGBOX );
2617 				osl_setDebugMessageFunc( pOriginal_osl_DebugMessageFunc );
2618 			}
2619 #endif
2620 			break;
2621 		case RC_Translate:
2622 			Translate();
2623 			break;
2624 		case RC_ApplicationBusy:
2625 		{
2626 			sal_Bool bWait = sal_False;
2627 			ReportError( GEN_RES_STR0( S_NO_ACTIVE_WINDOW ) );
2628 //			if ( Application::GetAppWindow() )
2629 //				bWait = Application::GetAppWindow()->IsWait();
2630 			pRet->GenReturn ( RET_Value, nMethodId, bWait );
2631 			break;
2632 		}
2633 		case RC_GetClipboard:
2634 			{
2635 				::rtl::OUString aTemp;
2636 				::svt::OStringTransfer::PasteString( aTemp, GetFirstDocFrame() );
2637 				pRet->GenReturn ( RET_Value, nMethodId, String( aTemp ) );
2638 			}
2639 			break;
2640 		case RC_SetClipboard:
2641 			::svt::OStringTransfer::CopyString(aString1,GetFirstDocFrame());
2642 			break;
2643 		case RC_WinTree:
2644 			pRet->GenReturn ( RET_Value, nMethodId, Tree( NULL, 0));
2645 			break;
2646     #if OSL_DEBUG_LEVEL > 1
2647 		case RC_NoDebug:
2648 			m_pDbgWin->bQuiet = sal_True;
2649 			m_pDbgWin->Hide();
2650 			m_pDbgWin->Clear();
2651 			break;
2652 		case RC_Debug:
2653 			m_pDbgWin->bQuiet = sal_False;
2654 			m_pDbgWin->Show();
2655 			break;
2656 	#endif
2657 		case RC_GPF:
2658 			((TabControl*)NULL)->SetCurPageId( 12345 );
2659 			break;
2660 		case RC_GetNextCloseWindow:
2661 			{
2662 				Window *pWin = GetActive( WINDOW_BASE );      // WINDOW_ANYTYPE
2663 				if ( !pWin )
2664 					ReportError( GEN_RES_STR0( S_NO_ACTIVE_WINDOW ) );
2665 				else if ( !IsDialog(pWin) )
2666 					ReportError( GEN_RES_STR0( S_NO_DIALOG_IN_GETACTIVE ) );
2667 				else
2668 				{
2669                     pRet->GenReturn( RET_Value, nMethodId, Id2Str(pWin->GetUniqueOrHelpId()) );
2670 				}
2671 			}
2672 			break;
2673 		case RC_UseBindings:
2674 			if( !(nParams & PARAM_BOOL_1) || bBool1 )
2675 				nUseBindings = SFX_USE_BINDINGS;
2676 			else
2677 				nUseBindings = 0;
2678 			break;
2679 		case RC_Profile:
2680 			//	Bei folgenden Parametern passiert folgendes:
2681 			//	ein boolean=false					Alles Profiling stoppen (Ergebnisse liefern)
2682 			//	ein boolean=true, 1-4 ints			Einteilung der Zeiten in K�stchen
2683 			//	kein! boolean keine ints			loggen jeden Befehls
2684 			//	kein! boolean 1 int					loggen alle int Millisekunden
2685 			//  ein String							wird in das Logfile �bernommen(sonst passiert nichts)
2686 			if( !(nParams & PARAM_BOOL_1) || bBool1 )
2687 			{
2688 				if ( !pProfiler )
2689 				{
2690 					pProfiler = new TTProfiler;
2691 					InitProfile();
2692 				}
2693 
2694 				if( !(nParams & PARAM_BOOL_1) && (nParams & PARAM_USHORT_1) )
2695 				{	// Autoprofiling: Profile nNr
2696 					if ( pProfiler->IsProfilingPerCommand() )
2697 					{
2698 						pProfiler->StopProfilingPerCommand();
2699 					}
2700 					pProfiler->StartAutoProfiling( nNr1 );
2701 
2702 					// Der Header ist abh�ngig vom Modus
2703 					pRet->GenReturn( RET_ProfileInfo, 0, pProfiler->GetProfileHeader() );
2704 				}
2705 				else if ( nParams & PARAM_USHORT_1 )
2706 				{	// Partitioning initialisieren: Profile true [,nNr][,nNr][,nNr][,nNr]
2707 					comm_ULONG nAnzahl=0;
2708 					if ( nParams & PARAM_USHORT_1 ) { nAnzahl++; };
2709 					if ( nParams & PARAM_USHORT_2 ) { nAnzahl++; };
2710 					if ( nParams & PARAM_USHORT_3 ) { nAnzahl++; };
2711 					if ( nParams & PARAM_USHORT_4 ) { nAnzahl++; };
2712 
2713 					// Hier werden die Parameter ans Testtool zur�ck �bertragen.
2714 					// Das ist zwar etwas eigenartig, aber ansonsten m�sste man im Testtool
2715 					// die einfache Struktur der Remotebefehle aufbrechen.
2716 					pRet->GenReturn( RET_ProfileInfo, S_ProfileReset, nAnzahl );
2717 
2718 					// Und die einzelnen Grenzen
2719 					if ( nParams & PARAM_USHORT_1 ) { pRet->GenReturn( RET_ProfileInfo, S_ProfileBorder1, (comm_ULONG)nNr1 ); };
2720 					if ( nParams & PARAM_USHORT_2 ) { pRet->GenReturn( RET_ProfileInfo, S_ProfileBorder2, (comm_ULONG)nNr2 ); };
2721 					if ( nParams & PARAM_USHORT_3 ) { pRet->GenReturn( RET_ProfileInfo, S_ProfileBorder3, (comm_ULONG)nNr3 ); };
2722 					if ( nParams & PARAM_USHORT_4 ) { pRet->GenReturn( RET_ProfileInfo, S_ProfileBorder4, (comm_ULONG)nNr4 ); };
2723 
2724 					pProfiler->StartPartitioning();
2725 				}
2726 				else if( nParams == PARAM_STR_1 )	// Genau ein String!
2727 				{	// Nur einen String ins Profiling aufnehmen
2728 					aString1 += '\n';
2729 					pRet->GenReturn( RET_ProfileInfo, 0, aString1 );
2730 				}
2731 				else
2732 				{	// Normales Profiling je Kommando: profile
2733 					if ( pProfiler->IsAutoProfiling() )
2734 					{
2735 						pRet->GenReturn( RET_ProfileInfo, 0, pProfiler->GetAutoProfiling() );
2736 						pProfiler->StopAutoProfiling();
2737 					}
2738 					pProfiler->StartProfilingPerCommand();
2739 
2740 					// Der Header ist abh�ngig vom Modus
2741 					pRet->GenReturn( RET_ProfileInfo, 0, pProfiler->GetProfileHeader() );
2742 				}
2743 			}
2744 			else		// Profiling wieder ausschalten: Profile false
2745 				if ( pProfiler )
2746 				{
2747 					if ( pProfiler->IsProfilingPerCommand() )
2748 						pProfiler->StopProfilingPerCommand();
2749 
2750 					if ( pProfiler->IsAutoProfiling() )
2751 					{
2752 						pRet->GenReturn( RET_ProfileInfo, 0, pProfiler->GetAutoProfiling() );
2753 						pProfiler->StopAutoProfiling();
2754 					}
2755 
2756 					if ( pProfiler->IsPartitioning() )
2757 					{
2758 						pRet->GenReturn( RET_ProfileInfo, S_ProfileDump, (comm_ULONG)0 );
2759 						pProfiler->StopPartitioning();
2760 					}
2761 
2762 					delete pProfiler;
2763 					pProfiler = NULL;
2764 				}
2765 			break;
2766 		case RC_MenuGetItemCount:
2767 		case RC_MenuGetItemId:
2768 		case RC_MenuGetItemPos:
2769 		case RC_MenuIsSeperator:
2770 		case RC_MenuIsItemChecked:
2771 		case RC_MenuIsItemEnabled:
2772 		case RC_MenuGetItemText:
2773 		case RC_MenuGetItemCommand:
2774         case RC_MenuHasSubMenu:
2775         case RC_MenuSelect:
2776 			{
2777                 PopupMenu *pPopup = NULL;
2778                 MenuBar *pMenuBar = NULL;
2779 				Menu *pMenu;
2780 
2781                 sal_uInt16 nErr = GetCurrentMenues( pPopup, pMenuBar, pMenu );
2782 
2783 				if ( !pMenu )
2784 				{
2785                     if ( nErr == 1 )
2786 					    ReportError( GEN_RES_STR0( S_NO_POPUP ) );
2787                     else
2788                         ReportError( GEN_RES_STR0( S_NO_SUBMENU ) );
2789 					break;
2790 				}
2791 
2792 				sal_uInt16 nItemCount = 0;
2793 				switch ( nMethodId )
2794 				{
2795 					case RC_MenuGetItemCount:
2796 					case RC_MenuGetItemId:
2797 					case RC_MenuIsSeperator:
2798 						{
2799 							nItemCount = pMenu->GetItemCount();
2800 							if ( pMenu->GetMenuFlags() & MENU_FLAG_HIDEDISABLEDENTRIES )
2801 							{	// jep, we have to adjust the count
2802 								sal_Bool bLastWasSeperator = sal_True;	// sal_True for Separator at the top
2803 								for ( sal_uInt16 i = 0 ; i < pMenu->GetItemCount() ; i++ )
2804 								{
2805 									if ( !pMenu->IsItemEnabled( pMenu->GetItemId( i ) ) )
2806 										nItemCount--;
2807 									else
2808 									{
2809 										if ( pMenu->GetItemType( i ) == MENUITEM_SEPARATOR && bLastWasSeperator )
2810 											nItemCount--;
2811 										bLastWasSeperator = pMenu->GetItemType( i ) == MENUITEM_SEPARATOR;
2812 									}
2813 								}
2814 								if ( bLastWasSeperator )	// Separator at bottom
2815 									nItemCount--;
2816 							}
2817 						}
2818 						break;
2819 				}
2820 
2821 				// for certain methods calculate the physical index (reinserting the hidden entries)
2822 				sal_uInt16 nPhysicalIndex = 0;
2823 				switch ( nMethodId )
2824 				{
2825 					case RC_MenuGetItemId:
2826 					case RC_MenuIsSeperator:
2827 						{
2828 							nPhysicalIndex = nNr1;
2829 							if ( pMenu->GetMenuFlags() & MENU_FLAG_HIDEDISABLEDENTRIES )
2830 							{	// jep, we have to adjust the position
2831 								sal_Bool bLastWasSeperator = sal_True;	// sal_True for Separator at the top
2832 								sal_uInt16 nVisibleCount = 0;
2833 								for ( sal_uInt16 i = 0 ; i < pMenu->GetItemCount() && nVisibleCount < nNr1 ; i++ )
2834 								{
2835 									if ( pMenu->IsItemEnabled( pMenu->GetItemId( i ) )
2836 										 && !( pMenu->GetItemType( i ) == MENUITEM_SEPARATOR && bLastWasSeperator ) )
2837 									{
2838 										nVisibleCount++;
2839 										bLastWasSeperator = pMenu->GetItemType( i ) == MENUITEM_SEPARATOR;
2840 									}
2841 									else
2842 										nPhysicalIndex++;
2843 								}
2844 								DBG_ASSERT( nVisibleCount == nNr1, "Adaption of Index failed: nVisibleCount != nNr1" );
2845 							}
2846 						}
2847 						break;
2848 				}
2849 
2850 
2851 
2852 				switch ( nMethodId )
2853 				{
2854 					case RC_MenuGetItemCount:
2855 						{
2856 							pRet->GenReturn ( RET_Value, nMethodId, (comm_ULONG)nItemCount );
2857 						}
2858 						break;
2859 					case RC_MenuGetItemId:
2860 						{
2861 							if ( ValueOK( rtl::OString(), RcString( nMethodId ),nNr1,nItemCount) )
2862 								pRet->GenReturn ( RET_Value, nMethodId, (comm_ULONG)pMenu->GetItemId(nPhysicalIndex-1) );
2863 						}
2864 						break;
2865 					case RC_MenuGetItemPos:
2866 						{
2867 							sal_uInt16 nLogicalPos = pMenu->GetItemPos(nNr1);
2868 							if ( MENU_ITEM_NOTFOUND != nLogicalPos && pMenu->GetMenuFlags() & MENU_FLAG_HIDEDISABLEDENTRIES )
2869 							{	// jep, we have to adjust the position
2870 								if ( !pMenu->IsItemEnabled( nNr1 ) )
2871 									nLogicalPos = MENU_ITEM_NOTFOUND;
2872 								else
2873 								{
2874 									sal_Bool bLastWasSeperator = sal_False;
2875 									for ( int i = nLogicalPos ; i >= 0 ; i-- )
2876 									{
2877 										if ( !pMenu->IsItemEnabled( pMenu->GetItemId( sal::static_int_cast< sal_uInt16 >(i) ) ) ||
2878 											 ( pMenu->GetItemType( sal::static_int_cast< sal_uInt16 >(i) ) == MENUITEM_SEPARATOR && bLastWasSeperator ) )
2879 											nLogicalPos--;
2880 										bLastWasSeperator = pMenu->GetItemType( sal::static_int_cast< sal_uInt16 >(i) ) == MENUITEM_SEPARATOR;
2881 									}
2882 								}
2883 							}
2884 							pRet->GenReturn ( RET_Value, nMethodId, (comm_ULONG)(nLogicalPos+1) );
2885 						}
2886 						break;
2887 					case RC_MenuIsSeperator:
2888 						{
2889 							if ( ValueOK( rtl::OString(), RcString( nMethodId ),nNr1,nItemCount) )
2890 								pRet->GenReturn ( RET_Value, nMethodId, (comm_BOOL)(pMenu->GetItemType(nPhysicalIndex-1) == MENUITEM_SEPARATOR) );
2891 						}
2892 						break;
2893 					case RC_MenuIsItemChecked:
2894 						{
2895 							pRet->GenReturn ( RET_Value, nMethodId, (comm_BOOL)pMenu->IsItemChecked(nNr1) );
2896 						}
2897 						break;
2898 					case RC_MenuIsItemEnabled:
2899 						{
2900 							pRet->GenReturn ( RET_Value, nMethodId, (comm_BOOL)pMenu->IsItemEnabled(nNr1) );
2901 						}
2902 						break;
2903 					case RC_MenuGetItemText:
2904 						{
2905 							pRet->GenReturn ( RET_Value, nMethodId, (String)pMenu->GetItemText(nNr1) );
2906 						}
2907 						break;
2908 					case RC_MenuGetItemCommand:
2909 						{
2910 							pRet->GenReturn ( RET_Value, nMethodId, (String)pMenu->GetItemCommand(nNr1) );
2911 						}
2912 						break;
2913                     case RC_MenuHasSubMenu:
2914 						{
2915 							pRet->GenReturn ( RET_Value, nMethodId, (sal_Bool)(pMenu->GetPopupMenu(nNr1) != NULL) );
2916 						}
2917                         break;
2918 					case RC_MenuSelect:
2919 						{
2920 							if ( pMenu->GetPopupMenu(nNr1) )
2921 							{
2922 								if ( !aSubMenuId1 )
2923 									aSubMenuId1 = nNr1;
2924 								else if ( !aSubMenuId2 )
2925 									aSubMenuId2 = nNr1;
2926 								else if ( !aSubMenuId3 )
2927 									aSubMenuId3 = nNr1;
2928 
2929                                 if ( pPopup )
2930 								    pPopup->SelectEntry(nNr1);
2931                                 else
2932                                     pMenuBar->SelectEntry(nNr1);
2933 							}
2934 							else
2935 							{
2936                                 if ( pPopup )
2937                                 {
2938     								pPopup->EndExecute(nNr1);
2939 								    aSubMenuId1 = 0;
2940 								    aSubMenuId2 = 0;
2941 									aSubMenuId3 = 0;
2942 									pMenuWindow = NULL;
2943                                 }
2944                                 else
2945 								{
2946                                     pMenuBar->SelectEntry(nNr1);
2947 								    aSubMenuId1 = 0;
2948 								    aSubMenuId2 = 0;
2949 								    aSubMenuId3 = 0;
2950 									pMenuWindow = NULL;
2951 								}
2952 							}
2953 						}
2954 						break;
2955 				}
2956 			}
2957 			break;
2958 		case RC_SetControlType:
2959 			{
2960                 DirectLog( S_QAError, GEN_RES_STR0( S_DEPRECATED ) );
2961 			}
2962 			break;
2963 		case RC_Kill:
2964 		case RC_RmDir:
2965 		case RC_MkDir:
2966 		case RC_FileCopy:
2967 		case RC_Name:
2968 		case RC_Dir:
2969 		case RC_FileLen:
2970 		case RC_FileDateTime:
2971 			{
2972 				long nErrorcode = FSYS_ERR_OK;
2973 				switch ( nMethodId )
2974 				{
2975 					case RC_Kill:
2976 						{
2977 							DirEntry aFile( aString1 );
2978 							nErrorcode = aFile.GetError();
2979 							if ( FSYS_ERR_OK == nErrorcode && FileStat( aFile ).IsKind( FSYS_KIND_FILE ) )
2980 								nErrorcode = aFile.Kill();
2981 							else
2982 								nErrorcode = FSYS_ERR_NOTAFILE;
2983 						}
2984 						break;
2985 					case RC_RmDir:
2986 						{
2987 							DirEntry aDir( aString1 );
2988 							nErrorcode = aDir.GetError();
2989 							if ( FSYS_ERR_OK == nErrorcode && FileStat( aDir ).IsKind( FSYS_KIND_DIR ) )
2990 								nErrorcode = aDir.Kill();
2991 							else
2992 								nErrorcode = FSYS_ERR_NOTADIRECTORY;
2993 						}
2994 						break;
2995 					case RC_MkDir:
2996 						{
2997 							DirEntry aDir( aString1 );
2998 							nErrorcode = aDir.GetError();
2999 							if ( !nErrorcode && !aDir.MakeDir() )
3000 								nErrorcode = FSYS_ERR_UNKNOWN;
3001 //	Workaround f�r Bug 60693
3002 //								nErrorcode = aDir.GetError();
3003 						}
3004 						break;
3005 					case RC_FileCopy:
3006 						{
3007 							nErrorcode = DirEntry( aString1 ).CopyTo( DirEntry( aString2 ), FSYS_ACTION_COPYFILE );
3008 						}
3009 						break;
3010 					case RC_Name:
3011 						{
3012 							nErrorcode = DirEntry( aString1 ).MoveTo( DirEntry( aString2 ) );
3013 						}
3014 						break;
3015 					case RC_Dir:
3016 						{
3017 
3018                             String aPath;
3019                             sal_uInt16 nDirFlags = 0;
3020 // from basic/source/inc/runtime.hxx
3021 #define Sb_ATTR_NORMAL          0x0000
3022 #define Sb_ATTR_HIDDEN          0x0002
3023 #define Sb_ATTR_SYSTEM          0x0004
3024 #define Sb_ATTR_VOLUME          0x0008
3025 #define Sb_ATTR_DIRECTORY       0x0010
3026 #define Sb_ATTR_ARCHIVE         0x0020
3027                             // copied from Basic and adapted  basic/source/runtime/methods.cxx Revision 1.54
3028 			                if ( (nParams & PARAM_STR_1) )
3029 			                {
3030 				                delete pDir;
3031 								pDir = NULL; // wg. Sonderbehandlung Sb_ATTR_VOLUME
3032 				                DirEntry aEntry( aString1 );
3033 				                FileStat aStat( aEntry );
3034 				                if(!aStat.GetError() && (aStat.GetKind() & FSYS_KIND_FILE))
3035 				                {
3036 					                // OK, only a filename
3037 					                // cut off path (VB4)
3038 					                aPath = aEntry.GetName();
3039 				                }
3040                                 else
3041                                 {
3042 				                    sal_uInt16 nFlags = 0;
3043 				                    if ( (nParams & PARAM_USHORT_1) )
3044 					                    nDirFlags = nFlags = nNr1;
3045 				                    else
3046 					                    nDirFlags = nFlags = Sb_ATTR_HIDDEN | Sb_ATTR_SYSTEM | Sb_ATTR_DIRECTORY;
3047 
3048 				                    // Nur diese Bitmaske ist unter Windows erlaubt
3049 				                    // Sb_ATTR_VOLUME wird getrennt gehandelt
3050 				                    if( nDirFlags & Sb_ATTR_VOLUME )
3051 					                    aPath = aEntry.GetVolume();
3052 				                    else
3053 				                    {
3054 					                    // Die richtige Auswahl treffen
3055 					                    sal_uInt16 nMode = FSYS_KIND_FILE;
3056 					                    if( nFlags & Sb_ATTR_DIRECTORY )
3057 						                    nMode |= FSYS_KIND_DIR;
3058 					                    if( nFlags == Sb_ATTR_DIRECTORY )
3059 						                    nMode = FSYS_KIND_DIR;
3060 					                    pDir = new Dir( aEntry, (DirEntryKind) nMode );
3061                                         nErrorcode = pDir->GetError();
3062 					                    nDirPos = 0;
3063 				                    }
3064                                 }
3065 			                }
3066 
3067 			                if( pDir )
3068 			                {
3069 				                for( ;; )
3070 				                {
3071 					                if( nDirPos >= pDir->Count() )
3072 					                {
3073 						                delete pDir;
3074 						                pDir = NULL;
3075 						                aPath.Erase();
3076 						                break;
3077 					                }
3078 					                DirEntry aNextEntry=(*(pDir))[nDirPos++];
3079 					                aPath = aNextEntry.GetName(); //Full();
3080 					                break;
3081 				                }
3082 			                }
3083 							if ( !nErrorcode )
3084 							{
3085 								pRet->GenReturn ( RET_Value, nMethodId, aPath );
3086                             }
3087 
3088 
3089 
3090 /* keep old Implementation for now
3091                             // neues Verzeichnis einlesen
3092 							if ( (nParams & PARAM_STR_1) )
3093 							{
3094 								if ( pDir )
3095 								{
3096 									delete pDir;
3097 									pDir = NULL;
3098 								}
3099 								DirEntryKind aDirEntryKind = FSYS_KIND_FILE | FSYS_KIND_DIR;
3100 								if ( (nParams & PARAM_USHORT_1) && nNr1 )
3101 								{
3102 									if ( nNr1 & 16 )
3103 										aDirEntryKind = FSYS_KIND_DIR;
3104 									else
3105 										ReportError( GEN_RES_STR0( S_SELECTION_BY_ATTRIBUTE_ONLY_DIRECTORIES ) );
3106 								}
3107 
3108 								DirEntry aEntry( aString1 );
3109 								nErrorcode = aEntry.GetError();
3110 								if ( !nErrorcode )
3111 								{
3112 									nDirPos = 0;
3113 									FileStat aFS( aEntry );
3114 									if ( !aFS.IsKind( FSYS_KIND_WILD ) && !aFS.IsKind( FSYS_KIND_DIR ) && aEntry.Exists() )
3115 									{	// Sonderbehandlung f�r genau einen Eintrag
3116 										if ( !aFS.IsKind( FSYS_KIND_DIR ) && ( aDirEntryKind == FSYS_KIND_DIR ) )
3117 											pRet->GenReturn ( RET_Value, nMethodId, String() );
3118 										else
3119 											pRet->GenReturn ( RET_Value, nMethodId, (String)(aEntry.GetName()) );
3120 
3121 										break;
3122 									}
3123 									else
3124 									{
3125 										pDir = new Dir( aEntry, aDirEntryKind );
3126 										nErrorcode = pDir->GetError();
3127 									}
3128 								}
3129 							}
3130 
3131 							if ( !pDir )
3132 								pDir = new Dir;
3133 
3134 							if ( !nErrorcode && ValueOK( nMethodId, GEN_RES_STR0( S_NO_MORE_FILES ), nDirPos+1, pDir->Count()+1 ) )
3135 							{
3136 								if ( nDirPos == pDir->Count() )
3137 									pRet->GenReturn ( RET_Value, nMethodId, String() );
3138 								else
3139 									pRet->GenReturn ( RET_Value, nMethodId, (String)((*pDir)[ nDirPos ].GetName()) );
3140 								nDirPos++;
3141 							}*/
3142 						}
3143 						break;
3144 					case RC_FileLen:
3145 						{
3146 							DirEntry aFile( aString1 );
3147 							nErrorcode = aFile.GetError();
3148 							if ( FSYS_ERR_OK == nErrorcode )
3149 							{
3150 								FileStat aFS( aFile );
3151 								pRet->GenReturn ( RET_Value, nMethodId, static_cast<comm_ULONG>(aFS.GetSize()) ); //GetSize() sal_uLong != comm_ULONG on 64bit
3152 								nErrorcode = aFS.GetError();
3153 							}
3154 						}
3155 						break;
3156 					case RC_FileDateTime:
3157 						{
3158 							DirEntry aFile( aString1 );
3159 							nErrorcode = aFile.GetError();
3160 							if ( FSYS_ERR_OK == nErrorcode )
3161 							{
3162 								FileStat aStat( aFile );
3163 								Time aTime( aStat.TimeModified() );
3164 								Date aDate( aStat.DateModified() );
3165 								nErrorcode = aStat.GetError();
3166 
3167 								double fSerial = (double)( aDate - Date(30,12,1899) );
3168 								long nSeconds = aTime.GetHour();
3169 								nSeconds *= 3600;
3170 								nSeconds += aTime.GetMin() * 60;
3171 								nSeconds += aTime.GetSec();
3172 								double nDays = ((double)nSeconds) / (double)(24.0*3600.0);
3173 								fSerial += nDays;
3174 
3175 								SbxValueRef xValue = new SbxValue( SbxDATE );
3176 								xValue->PutDate( fSerial );
3177 
3178 								pRet->GenReturn ( RET_Value, nMethodId, *xValue );
3179 							}
3180 						}
3181 						break;
3182 				}
3183 				switch ( nErrorcode )
3184 				{
3185 					case FSYS_ERR_OK:
3186 						break;
3187 					case FSYS_ERR_MISPLACEDCHAR:
3188 						{
3189 							ReportError( CUniString("MISPLACEDCHAR") );
3190 						}
3191 						break;
3192 					case FSYS_ERR_INVALIDCHAR:
3193 						{
3194 							ReportError( CUniString("INVALIDCHAR") );
3195 						}
3196 						break;
3197 					case FSYS_ERR_NOTEXISTS:
3198 						{
3199 							ReportError( CUniString("NOTEXISTS") );
3200 						}
3201 						break;
3202 					case FSYS_ERR_ALREADYEXISTS:
3203 						{
3204 							ReportError( CUniString("ALREADYEXISTS") );
3205 						}
3206 						break;
3207 					case FSYS_ERR_NOTADIRECTORY:
3208 						{
3209 							ReportError( CUniString("NOTADIRECTORY") );
3210 						}
3211 						break;
3212 					case FSYS_ERR_NOTAFILE:
3213 						{
3214 							ReportError( CUniString("NOTAFILE") );
3215 						}
3216 						break;
3217 					case FSYS_ERR_INVALIDDEVICE:
3218 						{
3219 							ReportError( CUniString("INVALIDDEVICE") );
3220 						}
3221 						break;
3222 					case FSYS_ERR_ACCESSDENIED:
3223 						{
3224 							ReportError( CUniString("ACCESSDENIED") );
3225 						}
3226 						break;
3227 					case FSYS_ERR_LOCKVIOLATION:
3228 						{
3229 							ReportError( CUniString("LOCKVIOLATION") );
3230 						}
3231 						break;
3232 					case FSYS_ERR_VOLUMEFULL:
3233 						{
3234 							ReportError( CUniString("VOLUMEFULL") );
3235 						}
3236 						break;
3237 					case FSYS_ERR_ISWILDCARD:
3238 						{
3239 							ReportError( CUniString("ISWILDCARD") );
3240 						}
3241 						break;
3242 					case FSYS_ERR_NOTSUPPORTED:
3243 						{
3244 							ReportError( CUniString("NOTSUPPORTED") );
3245 						}
3246 						break;
3247 					case FSYS_ERR_UNKNOWN:
3248 						{
3249 							ReportError( CUniString("UNKNOWN") );
3250 						}
3251 						break;
3252 					default:
3253 						{
3254 							ReportError( CUniString("Not an FSYS Error") );
3255 						}
3256 				}
3257 
3258 			}
3259 			break;
3260 		case RC_TypeKeysDelay:
3261 			{
3262 				if( (nParams & PARAM_BOOL_1) )
3263 				{
3264 					bDoTypeKeysDelay = bBool1;
3265 				}
3266 				else if( nParams & PARAM_USHORT_1 )
3267 				{
3268 					nMinTypeKeysDelay = nNr1;
3269 					if( nParams & PARAM_USHORT_2 )
3270 						nMaxTypeKeysDelay = nNr2;
3271 					else
3272 						nMaxTypeKeysDelay = nMinTypeKeysDelay;
3273 				}
3274 				else
3275 					ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) );
3276 			}
3277 			break;
3278 		case RC_GetMouseStyle:
3279 			{
3280 				Pointer aPointer;
3281 //				if ( DragManager::GetDragManager() )
3282 //					aPointer = DragManager::GetDragManager()->GetDragPointer();
3283 //				else
3284 				{
3285 					Window *pActualWin = GetMouseWin();
3286 					if ( pActualWin )
3287 						aPointer = pActualWin->GetPointer();
3288 					else
3289 					{
3290 						ReportError( GEN_RES_STR1( S_POINTER_OUTSIDE_APPWIN, RcString( nMethodId ) ) );
3291 						aPointer = Pointer( POINTER_NULL );
3292 					}
3293 				}
3294 				pRet->GenReturn ( RET_Value, nMethodId, (comm_ULONG)aPointer.GetStyle() );
3295 			}
3296 			break;
3297 		case RC_UnpackStorage:
3298 			{
3299 				if( (nParams & PARAM_STR_1) )
3300 				{
3301 					String aFileName( aString1 );
3302 					DirEntry aDestPath;
3303 					if( (nParams & PARAM_STR_2) )
3304 						aDestPath = DirEntry( aString2 );
3305 					else
3306 					{
3307 						aDestPath = DirEntry( aFileName );
3308 						aDestPath.SetExtension( CUniString( "plaintext" ) );
3309 					}
3310 
3311 #if OSL_DEBUG_LEVEL > 1
3312                     sal_uInt16 nEntries = Dir( aDestPath, FSYS_KIND_FILE | FSYS_KIND_DIR ).Count();
3313                     (void) nEntries; /* avoid warning about unused parameter */
3314 #endif
3315                     // The Count is only larger than 2 is the path is a directory which is not empty
3316                     // the Count of 2 results from the "." and ".." directory
3317                     if ( Dir( aDestPath, FSYS_KIND_FILE | FSYS_KIND_DIR ).Count() > 2 )
3318                         DirectLog( S_QAError, GEN_RES_STR1( S_DIRECTORY_NOT_EMPTY, aDestPath.GetFull() ) );
3319 
3320 					SotStorageRef xStorage = new SotStorage( aFileName, STREAM_STD_READ );
3321 					if ( xStorage->GetError() )
3322 						ReportError( GEN_RES_STR2(S_UNPACKING_STORAGE_FAILED, aFileName, aDestPath.GetFull()) );
3323 					else
3324 						UnpackStorage( xStorage, aDestPath );
3325 				}
3326 				else
3327 					ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) );
3328 			}
3329 			break;
3330 		case RC_CloseSysDialog:
3331 		case RC_ExistsSysDialog:
3332 			{
3333 				if( (nParams & PARAM_USHORT_1) )
3334 				{
3335                     Reference < ::com::sun::star::util::XCancellable > xPicker;
3336                     switch( nNr1 )
3337                     {
3338                         case CONST_FilePicker:
3339                             {
3340                                 xPicker.set( Reference < ::com::sun::star::util::XCancellable >( svt::GetTopMostFilePicker(), UNO_QUERY ) );
3341                             }
3342                             break;
3343                         case CONST_FolderPicker:
3344                             {
3345                                 xPicker.set( Reference < ::com::sun::star::util::XCancellable >( svt::GetTopMostFolderPicker(), UNO_QUERY ) );
3346                             }
3347                             break;
3348                         default:
3349     					    ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) );
3350                     }
3351                     switch( nMethodId )
3352                     {
3353 		                case RC_CloseSysDialog:
3354                             {
3355                                 if ( xPicker.is() )
3356                                     xPicker->cancel();
3357                                 else
3358                                     ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) );
3359                             }
3360                             break;
3361 		                case RC_ExistsSysDialog:
3362                             {
3363                 				pRet->GenReturn ( RET_Value, nMethodId, (comm_BOOL)xPicker.is() );
3364                             }
3365                             break;
3366                         default:
3367     					    ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) );
3368                     }
3369 				}
3370 				else
3371 					ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) );
3372 			}
3373 			break;
3374 		case RC_SAXCheckWellformed:
3375 		case RC_SAXReadFile:
3376 
3377 		case RC_SAXGetNodeType:
3378 		case RC_SAXGetAttributeCount:
3379 		case RC_SAXGetAttributeName:
3380 		case RC_SAXGetAttributeValue:
3381 		case RC_SAXGetChildCount:
3382 		case RC_SAXGetElementName:
3383 		case RC_SAXGetChars:
3384 
3385         case RC_SAXSeekElement:
3386 		case RC_SAXHasElement:
3387 		case RC_SAXGetElementPath:
3388 
3389         case RC_SAXRelease:
3390             {
3391                 HandleSAXParser();
3392 			}
3393 			break;
3394         case RC_RecordMacro:
3395             {
3396 				if ( ! (nParams & PARAM_BOOL_1) )
3397 					bBool1 = sal_True;
3398 
3399                 MacroRecorder::GetMacroRecorder()->SetActionRecord( bBool1 );
3400             }
3401             break;
3402         case RC_GetDocumentCount :
3403             {
3404                 pRet->GenReturn ( RET_Value, nMethodId, (comm_USHORT)GetDocWinCount() );
3405             }
3406             break;
3407         case RC_ActivateDocument :
3408             {
3409 				if( nParams & PARAM_USHORT_1 )
3410                 {
3411                     if ( ValueOK( rtl::OString(), RcString( nMethodId ), nNr1, GetDocWinCount() ) )
3412                     {
3413                         Window* pWin = GetDocWin( nNr1-1 );
3414                         if ( pWin )
3415                         {
3416                             pWin->ToTop();
3417                             pWin->GrabFocus();
3418                         }
3419                     }
3420                 }
3421                 else
3422 				    ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) );
3423             }
3424             break;
3425         case RC_GetSystemLanguage :
3426             {
3427                 pRet->GenReturn ( RET_Value, nMethodId, (comm_USHORT)Application::GetSettings().GetLanguage() );
3428             }
3429             break;
3430         case RC_CatchGPF :
3431             {
3432 				if( (nParams & PARAM_BOOL_1) )
3433                     bCatchGPF = bBool1;
3434                 else
3435 					bCatchGPF = sal_True;
3436             }
3437             break;
3438         case RC_IsProduct :
3439             {
3440                 sal_Bool bIsProduct;
3441                 #ifdef DBG_UTIL
3442                     bIsProduct = sal_False;
3443                 #else
3444                     bIsProduct = sal_True;
3445                 #endif
3446                 pRet->GenReturn ( RET_Value, nMethodId, (sal_Bool)bIsProduct );
3447             }
3448             break;
3449         case RC_UsePostEvents :
3450             {
3451 				if( (nParams & PARAM_BOOL_1) )
3452                     bUsePostEvents = bBool1;
3453                 else
3454 					bUsePostEvents = sal_True;
3455             }
3456             break;
3457         default:
3458 			ReportError( GEN_RES_STR1( S_UNKNOWN_COMMAND, RcString( nMethodId ) ) );
3459 	}
3460 	SendProfile( RcString(nMethodId) );
3461 	delete this;
3462 	return sal_True;
3463 }
3464 
3465 
3466 sal_Bool StatementCommand::UnpackStorage( SotStorageRef xStorage, DirEntry &aBaseDir )
3467 {
3468 	SvStorageInfoList aList;
3469 	xStorage->FillInfoList( &aList );
3470 
3471 	for( sal_uInt16 i = 0; i < aList.Count(); i++ )
3472 	{
3473 		SvStorageInfo& rInfo = aList.GetObject( i );
3474 		String aName = rInfo.GetName();
3475 		DirEntry aPath ( aBaseDir );
3476 		aPath += DirEntry( aName );
3477 		sal_Bool bIsStorage = xStorage->IsStorage( aName );
3478 		if ( bIsStorage )
3479 		{
3480 			SotStorageRef xSubStorage = xStorage->OpenSotStorage( aName, STREAM_STD_READ );
3481 				if ( xSubStorage->GetError() )
3482 				{
3483 					ReportError( GEN_RES_STR2(S_UNPACKING_STORAGE_FAILED, aName, aPath.GetFull()) );
3484 					return sal_False;
3485 				}
3486 				UnpackStorage( xSubStorage, aPath );
3487 		}
3488 		else
3489 		{
3490 			if ( !aPath.MakeDir( sal_True ) )
3491 			{
3492 				ReportError( GEN_RES_STR1(S_CANNOT_CREATE_DIRECTORY, aPath.GetFull()) );
3493 				return sal_False;
3494 			}
3495 			SotStorageStreamRef xStream = xStorage->OpenSotStream( aName, STREAM_STD_READ );
3496 			SvFileStream aDestination( aPath.GetFull(), STREAM_STD_READWRITE | STREAM_TRUNC );
3497 			(*xStream) >> aDestination;
3498 			if ( aDestination.GetError() != ERRCODE_NONE )
3499 			{
3500 				ReportError( GEN_RES_STR2(S_UNPACKING_STORAGE_FAILED, aName, aPath.GetFull()) );
3501 				return sal_False;
3502 			}
3503 			aDestination.Close();
3504 		}
3505 	}
3506 	return sal_True;
3507 }
3508 
3509 
3510 // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
3511 
3512 StatementControl::StatementControl( SCmdStream *pCmdIn, sal_uInt16 nControlIdType )
3513 : StatementList()
3514 , nNr1( 0 )
3515 , nNr2( 0 )
3516 , nNr3( 0 )
3517 , nNr4( 0 )
3518 , nLNr1( 0 )
3519 , aString1()
3520 , aString2()
3521 , bBool1(sal_False)
3522 , bBool2(sal_False)
3523 {
3524 	QueStatement( NULL );
3525     //HELPID BACKWARD (SIControl is no longer needed)
3526     if ( nControlIdType == SIControl )
3527     {
3528         comm_ULONG nId;
3529         pCmdIn->Read( nId );
3530         aUId = rtl::OString( nId );
3531         if ( nId == 0 )
3532             aUId = UID_ACTIVE;
3533         else
3534             ReportError( aUId, GEN_RES_STR1c( S_INTERNAL_ERROR, "using numeric HelpID from old Testtool" ) );
3535     }
3536     else if ( nControlIdType == SIStringControl )
3537     {
3538         String aId;
3539         pCmdIn->Read( aId );
3540         aUId = Str2Id( aId );
3541     }
3542     else
3543     {
3544         DBG_ERROR( "Wrong ControlType" );
3545     }
3546 
3547 	pCmdIn->Read( nMethodId );
3548 	pCmdIn->Read( nParams );
3549 
3550 	if( nParams & PARAM_USHORT_1 )	pCmdIn->Read( nNr1 );
3551 	if( nParams & PARAM_USHORT_2 )	pCmdIn->Read( nNr2 );
3552 	if( nParams & PARAM_USHORT_3 )	pCmdIn->Read( nNr3 );
3553 	if( nParams & PARAM_USHORT_4 )	pCmdIn->Read( nNr4 );
3554 	if( nParams & PARAM_ULONG_1 )	pCmdIn->Read( nLNr1 );
3555 	if( nParams & PARAM_STR_1 )		pCmdIn->Read( aString1 );
3556 	if( nParams & PARAM_STR_2 )		pCmdIn->Read( aString2 );
3557 	if( nParams & PARAM_BOOL_1 )	pCmdIn->Read( bBool1 );
3558 	if( nParams & PARAM_BOOL_2 )	pCmdIn->Read( bBool2 );
3559 
3560 #if OSL_DEBUG_LEVEL > 1
3561 	m_pDbgWin->AddText( "Reading Control: UId: " );
3562 	m_pDbgWin->AddText( Id2Str( aUId ) );
3563 	m_pDbgWin->AddText( " Methode: " );
3564 	m_pDbgWin->AddText( String::CreateFromInt32( nMethodId ) );
3565 	m_pDbgWin->AddText( " Params:" );
3566 	if( nParams & PARAM_USHORT_1 )	{m_pDbgWin->AddText( " n1:" );m_pDbgWin->AddText( String::CreateFromInt32( nNr1 ) );}
3567 	if( nParams & PARAM_USHORT_2 )	{m_pDbgWin->AddText( " n2:" );m_pDbgWin->AddText( String::CreateFromInt32( nNr2 ) );}
3568 	if( nParams & PARAM_USHORT_3 )	{m_pDbgWin->AddText( " n3:" );m_pDbgWin->AddText( String::CreateFromInt32( nNr3 ) );}
3569 	if( nParams & PARAM_USHORT_4 )	{m_pDbgWin->AddText( " n4:" );m_pDbgWin->AddText( String::CreateFromInt32( nNr4 ) );}
3570 	if( nParams & PARAM_ULONG_1 )	{m_pDbgWin->AddText( " nl1:" );m_pDbgWin->AddText( String::CreateFromInt64( nLNr1 ) );}
3571 	if( nParams & PARAM_STR_1 )		{m_pDbgWin->AddText( " s1:" );m_pDbgWin->AddText( aString1 );}
3572 	if( nParams & PARAM_STR_2 )		{m_pDbgWin->AddText( " s2:" );m_pDbgWin->AddText( aString2 );}
3573 /*    if( nParams & PARAM_BOOL_1 )    pCmdIn->Read( bBool1 );
3574 	if( nParams & PARAM_BOOL_2 )    pCmdIn->Read( bBool2 );*/
3575 	m_pDbgWin->AddText( "\n" );
3576 #endif
3577 }
3578 
3579 sal_Bool IsDialog(Window *pWin)
3580 {	// Alles was von SystemWindow abgeleitet ist
3581 	if ( !pWin )
3582 		return sal_False;
3583 
3584 	switch (pWin->GetType())
3585 	{
3586 		case WINDOW_FLOATINGWINDOW:
3587 		case WINDOW_DOCKINGWINDOW:
3588 		case WINDOW_MODELESSDIALOG:
3589 		case WINDOW_DIALOG:
3590 		case WINDOW_MODALDIALOG:
3591 		case WINDOW_WORKWINDOW:
3592 		case WINDOW_TABDIALOG:
3593 
3594 		case WINDOW_MESSBOX:
3595 		case WINDOW_INFOBOX:
3596 		case WINDOW_WARNINGBOX:
3597 		case WINDOW_ERRORBOX:
3598 		case WINDOW_QUERYBOX:
3599 		case WINDOW_BUTTONDIALOG:
3600 		case WINDOW_FILEDIALOG:
3601 		case WINDOW_PRINTDIALOG:
3602 		case WINDOW_PRINTERSETUPDIALOG:
3603 
3604 // ab hier nicht ansprechbar (da nicht implementiert)
3605 		case WINDOW_SYSWINDOW:
3606 		case WINDOW_SYSTEMDIALOG:
3607 		case WINDOW_COLORDIALOG:
3608 		case WINDOW_FONTDIALOG:
3609 		case WINDOW_PATHDIALOG:
3610 
3611 
3612 			return sal_True;
3613 //			break;
3614 		default:
3615 			return sal_False;
3616 //			break;
3617 	}
3618 }
3619 
3620 
3621 sal_Bool IsAccessable(Window *pWin)
3622 {
3623 	if ( pWin == NULL )
3624 		return sal_False;
3625 
3626 	return pWin->IsEnabled() && pWin->IsInputEnabled();
3627 }
3628 
3629 
3630 
3631 // neue Hilfsfunktion
3632 static Window*ImpGetButton( Window *pBase, WinBits nMask, WinBits nWinBits )
3633 {
3634 	sal_uInt16 n = pBase->GetChildCount();
3635 	for( sal_uInt16 i = 0 ; i < n; i++ ) {
3636 		Window *pChild = pBase->GetChild(i);
3637 		if(    pChild->GetType() == WINDOW_OKBUTTON
3638 			|| pChild->GetType() == WINDOW_CANCELBUTTON
3639 			|| pChild->GetType() == WINDOW_HELPBUTTON
3640 			|| pChild->GetType() == WINDOW_PUSHBUTTON )
3641 			if( !nMask || ( pChild->GetStyle() & nMask ) == nWinBits )
3642 				return pChild;
3643 	}
3644 	return NULL;
3645 }
3646 
3647 sal_Bool StatementControl::ControlOK( Window *pControl, const sal_Char* cBezeichnung )
3648 {
3649 	if ( pControl && ( ( ( IsAccessable(pControl) || (nMethodId & M_WITH_RETURN) ) &&
3650 						 pControl->IsVisible() ) ||
3651 					     aUId.equals( UID_ACTIVE ) ) )
3652 		return sal_True;
3653 	else
3654 	{
3655 		UniString aBezeichnung( cBezeichnung, RTL_TEXTENCODING_ASCII_US );
3656 		if ( aBezeichnung.Len() > 0 )
3657 		{
3658 			if (!pControl)
3659 				ReportError( aUId, GEN_RES_STR1( S_WIN_NOT_FOUND, aBezeichnung ) );
3660 			else if ( !pControl->IsVisible() )
3661 				ReportError( aUId, GEN_RES_STR1( S_WIN_INVISIBLE, aBezeichnung ) );
3662 			else
3663 				ReportError( aUId, GEN_RES_STR1( S_WIN_DISABLED, aBezeichnung ) );
3664 		}
3665         #if OSL_DEBUG_LEVEL > 1
3666 		m_pDbgWin->AddText( aBezeichnung.AppendAscii(" NotFound or Disabled or Invisible") );
3667 		#endif
3668 
3669 		return sal_False;
3670 	}
3671 }
3672 
3673 
3674 sal_Bool StatementList::ValueOK( rtl::OString aId, String aBezeichnung, sal_uLong nValue, sal_uLong nMax )
3675 {
3676 
3677 	if ( nMax < nValue )
3678 	{
3679         if ( aBezeichnung.Len() > 0 )
3680 		    ReportError( aId, GEN_RES_STR3( S_NUMBER_TOO_BIG, aBezeichnung, UniString::CreateFromInt32( nValue ), UniString::CreateFromInt32( nMax ) ) );
3681 		return sal_False;
3682 	}
3683 	if ( nValue < 1 )
3684 	{
3685         if ( aBezeichnung.Len() > 0 )
3686 			ReportError( aId, GEN_RES_STR3c3( S_NUMBER_TOO_SMALL, aBezeichnung, UniString::CreateFromInt32( nValue ), "1" ) );
3687 		return sal_False;
3688 	}
3689 	return sal_True;
3690 }
3691 
3692 sal_uInt16 StatementList::GetCurrentMenues( PopupMenu *&pPopup, MenuBar *&pMenuBar, Menu *&pMenu )
3693 {
3694     if ( WinPtrValid( pMenuWindow ) )
3695         pMenuBar = pMenuWindow->GetMenuBar();
3696 
3697     if ( pMenuBar )     // use MenuBar as base
3698         pMenu = pMenuBar;
3699     else        // use contextmenu as base
3700     {
3701         pMenu = PopupMenu::GetActivePopupMenu();
3702         pPopup = PopupMenu::GetActivePopupMenu();
3703     }
3704 
3705 	if ( !pMenu )
3706 		return 1;
3707 
3708 	if ( aSubMenuId1 )
3709     {
3710 		pPopup = pMenu->GetPopupMenu( aSubMenuId1 );
3711         pMenu = pPopup;
3712     }
3713 
3714 	if ( pMenu && aSubMenuId2 )
3715     {
3716 		pPopup = pMenu->GetPopupMenu( aSubMenuId2 );
3717         pMenu = pPopup;
3718     }
3719 
3720 	if ( pMenu && aSubMenuId3 )
3721     {
3722 		pPopup = pMenu->GetPopupMenu( aSubMenuId3 );
3723         pMenu = pPopup;
3724     }
3725 
3726     return 0;
3727 }
3728 
3729 void StatementControl::AnimateMouse( Window *pControl, TTHotSpots aWohin )
3730 {
3731 	Point aZiel;
3732 
3733 	switch (aWohin)
3734 	{
3735 		case MitteLinks:
3736 			{
3737 				long nHeight = pControl->GetSizePixel().Height();
3738 				aZiel.X() += 5;
3739 				aZiel.Y() += nHeight / 2;
3740 			}
3741 			break;
3742 		case Mitte:
3743 			{
3744 				Size aSize = pControl->GetOutputSizePixel();
3745 				aZiel.Move( aSize.Width() / 2, aSize.Height() / 2 );
3746 			}
3747 			break;
3748 		case MitteOben:
3749 			{
3750 				long nWidth = pControl->GetSizePixel().Width();
3751 				aZiel.X() += nWidth / 2;
3752 				aZiel.Y() += 5;
3753 			}
3754 			break;
3755 	}
3756 	AnimateMouse( pControl, aZiel );
3757 }
3758 
3759 
3760 void StatementControl::AnimateMouse( Window *pControl, Point aWohin )
3761 {
3762 	Point aAkt = pControl->GetPointerPosPixel();
3763 	Point aZiel = aWohin;
3764 
3765 	long nSteps;
3766 	Point aDiff = aAkt - aZiel;
3767 
3768 	if ( Abs(aDiff.X()) < Abs(aDiff.Y()) )
3769 		nSteps = Abs(aDiff.Y()) / 5;
3770 	else
3771 		nSteps = Abs(aDiff.X()) / 5;
3772 	if ( nSteps == 0 )
3773 		return;
3774 
3775 	aDiff *= 1000;
3776 	aDiff /= nSteps;
3777 
3778 	StatementList::bExecuting = sal_True;		// Bah ist das ein ekliger Hack
3779 												// Das verhindert, da� schon der n�chste Befehl ausgef�hrt wird.
3780 
3781 	for ( ; nSteps ; nSteps-- )
3782 	{
3783 		if ( Abs((aAkt - pControl->GetPointerPosPixel()).X()) > 5 ||
3784 			 Abs((aAkt - pControl->GetPointerPosPixel()).Y()) > 5 )
3785 			nSteps = 1;
3786 		aAkt = aZiel + aDiff * nSteps / 1000;
3787 		pControl->SetPointerPosPixel(aAkt);
3788 		SafeReschedule();
3789 	}
3790 	pControl->SetPointerPosPixel(aZiel);
3791 	StatementList::bExecuting = sal_False;	// Bah ist das ein ekliger Hack
3792 }
3793 
3794 
3795 sal_Bool StatementControl::MaybeDoTypeKeysDelay( Window *pTestWindow )
3796 {
3797 	if ( bDoTypeKeysDelay )
3798 	{
3799 		sal_uLong nTimeWait = nMinTypeKeysDelay;
3800 		if ( nMaxTypeKeysDelay != nMinTypeKeysDelay )
3801 			nTimeWait  += Time::GetSystemTicks() % ( nMaxTypeKeysDelay - nMinTypeKeysDelay );
3802 		Timer aTimer;
3803 		aTimer.SetTimeout( nTimeWait );
3804 		aTimer.Start();
3805 		StatementList::bExecuting = sal_True;		// Bah ist das ein ekliger Hack
3806 													// Das verhindert, da� schon der n�chste Befehl ausgef�hrt wird.
3807 		while ( aTimer.IsActive() )
3808 		{
3809 			SafeReschedule( sal_True );
3810 		}
3811 		StatementList::bExecuting = sal_False;	// Bah ist das ein ekliger Hack
3812 		if ( !WinPtrValid(pTestWindow ) )
3813 		{
3814 			ReportError( aUId, GEN_RES_STR1( S_WINDOW_DISAPPEARED, MethodString( nMethodId ) ) );
3815 			return sal_False;
3816 		}
3817 	}
3818 	return sal_True;
3819 }
3820 
3821 sal_Bool StatementControl::HandleVisibleControls( Window *pControl )
3822 {
3823 	if( pControl )		// Also auch bei Disabled nicht jedoch bei Invisible
3824 	{
3825 		switch( nMethodId )
3826 		{
3827 		case M_IsEnabled:
3828 			pRet->GenReturn ( RET_Value, aUId, IsAccessable(pControl) );
3829 			break;
3830 		case M_IsVisible:
3831 			pRet->GenReturn ( RET_Value, aUId, pControl->IsVisible() );
3832 			break;
3833 		case M_GetPosX:
3834 			if ( pControl->GetType() == WINDOW_DOCKINGWINDOW && pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_FLOATINGWINDOW )
3835 				pControl = pControl->GET_REAL_PARENT();		// Sonderbehandlung f�r FloatingWindows
3836 			if ( pControl->GetType() == WINDOW_TABCONTROL && pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_TABDIALOG )
3837 				pControl = pControl->GET_REAL_PARENT();		// Sonderbehandlung f�r TabDialoge
3838 			if ( pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_BORDERWINDOW )
3839 				pControl = pControl->GET_REAL_PARENT();		// Sonderbehandlung f�r Border
3840             if ( (nParams & PARAM_BOOL_1) && bBool1 )
3841                 pControl = pControl->GetWindow( WINDOW_OVERLAP );
3842 
3843 			if ( pControl->GetType() == WINDOW_DOCKINGWINDOW && pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_SPLITWINDOW )
3844 			{
3845 				Point aPos = pControl->GetPosPixel();
3846 				aPos = pControl->GET_REAL_PARENT()->OutputToScreenPixel( aPos );
3847 				pRet->GenReturn ( RET_Value, aUId, (comm_ULONG)aPos.X() );
3848 			}
3849 			else
3850 				pRet->GenReturn ( RET_Value, aUId, (comm_ULONG)pControl->GetPosPixel().X() );
3851 			break;
3852 		case M_GetPosY:
3853 			if ( pControl->GetType() == WINDOW_DOCKINGWINDOW && pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_FLOATINGWINDOW )
3854 				pControl = pControl->GET_REAL_PARENT();		// Sonderbehandlung f�r FloatingWindows
3855 			if ( pControl->GetType() == WINDOW_TABCONTROL && pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_TABDIALOG )
3856 				pControl = pControl->GET_REAL_PARENT();		// Sonderbehandlung f�r TabDialoge
3857 			if ( pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_BORDERWINDOW )
3858 				pControl = pControl->GET_REAL_PARENT();		// Sonderbehandlung f�r Border
3859             if ( (nParams & PARAM_BOOL_1) && bBool1 )
3860                 pControl = pControl->GetWindow( WINDOW_OVERLAP );
3861 
3862 			if ( pControl->GetType() == WINDOW_DOCKINGWINDOW && pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_SPLITWINDOW )
3863 			{
3864 				Point aPos = pControl->GetPosPixel();
3865 				aPos = pControl->GET_REAL_PARENT()->OutputToScreenPixel( aPos );
3866 				pRet->GenReturn ( RET_Value, aUId, (comm_ULONG)aPos.Y() );
3867 			}
3868 			else
3869 				pRet->GenReturn ( RET_Value, aUId, (comm_ULONG)pControl->GetPosPixel().Y() );
3870 			break;
3871 		case M_GetSizeX:
3872 			if ( pControl->GetType() == WINDOW_DOCKINGWINDOW && pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_FLOATINGWINDOW )
3873 				pControl = pControl->GET_REAL_PARENT();		// Sonderbehandlung f�r FloatingWindows
3874 			if ( pControl->GetType() == WINDOW_TABCONTROL && pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_TABDIALOG )
3875 				pControl = pControl->GET_REAL_PARENT();		// Sonderbehandlung f�r TabDialoge
3876 			if ( pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_BORDERWINDOW )
3877 				pControl = pControl->GET_REAL_PARENT();		// Sonderbehandlung f�r Border
3878             if ( (nParams & PARAM_BOOL_1) && bBool1 )
3879                 pControl = pControl->GetWindow( WINDOW_OVERLAP );
3880 
3881 			pRet->GenReturn ( RET_Value, aUId, (comm_ULONG)pControl->GetSizePixel().Width() );
3882 			break;
3883 		case M_GetSizeY:
3884 			if ( pControl->GetType() == WINDOW_DOCKINGWINDOW && pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_FLOATINGWINDOW )
3885 				pControl = pControl->GET_REAL_PARENT();		// Sonderbehandlung f�r FloatingWindows
3886 			if ( pControl->GetType() == WINDOW_TABCONTROL && pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_TABDIALOG )
3887 				pControl = pControl->GET_REAL_PARENT();		// Sonderbehandlung f�r TabDialoge
3888 			if ( pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_BORDERWINDOW )
3889 				pControl = pControl->GET_REAL_PARENT();		// Sonderbehandlung f�r Border
3890             if ( (nParams & PARAM_BOOL_1) && bBool1 )
3891                 pControl = pControl->GetWindow( WINDOW_OVERLAP );
3892 
3893 			pRet->GenReturn ( RET_Value, aUId, (comm_ULONG)pControl->GetSizePixel().Height() );
3894 			break;
3895 		case M_SnapShot:
3896 			{
3897 				if ( pControl->GetType() == WINDOW_DOCKINGWINDOW && pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_FLOATINGWINDOW )
3898 					pControl = pControl->GET_REAL_PARENT();		// Sonderbehandlung f�r FloatingWindows
3899 				if ( pControl->GetType() == WINDOW_TABCONTROL && pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_TABDIALOG )
3900 					pControl = pControl->GET_REAL_PARENT();		// Sonderbehandlung f�r TabDialoge
3901 				if ( pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_BORDERWINDOW )
3902 					pControl = pControl->GET_REAL_PARENT();		// Sonderbehandlung f�r Border
3903                 if ( (nParams & PARAM_BOOL_1) && bBool1 )
3904                     pControl = pControl->GetWindow( WINDOW_OVERLAP );
3905 
3906 				Bitmap aBmp = pControl->SnapShot();
3907 				if ( pControl->GetType() == WINDOW_WORKWINDOW )
3908 				{
3909 					Point aStart = pControl->GetPosPixel();
3910 					if ( !(nParams & PARAM_USHORT_4) )
3911 					{
3912 						nParams |= PARAM_USHORT_1;
3913 						nParams |= PARAM_USHORT_2;
3914 						nParams |= PARAM_USHORT_3;
3915 						nParams |= PARAM_USHORT_4;
3916 						nNr1 = (sal_uInt16)-aStart.X();
3917 						nNr2 = (sal_uInt16)-aStart.Y();
3918 						nNr3 = (sal_uInt16)pControl->GetSizePixel().Width() + 2*(sal_uInt16)aStart.X();
3919 						nNr4 = (sal_uInt16)pControl->GetSizePixel().Height() + 2*(sal_uInt16)aStart.Y();
3920 					}
3921 					nNr1 = std::max((sal_uInt16)-aStart.X(),nNr1);
3922 					nNr2 = std::max((sal_uInt16)-aStart.Y(),nNr2);
3923 					nNr3 = std::min((sal_uInt16)(pControl->GetSizePixel().Width() + 2*(sal_uInt16)aStart.X()),nNr3);
3924 					nNr4 = std::min((sal_uInt16)(pControl->GetSizePixel().Height() + 2*(sal_uInt16)aStart.Y()),nNr4);
3925 				}
3926 				if( nParams & PARAM_USHORT_4 )
3927 				{	// Zuschneiden
3928 					Point aPt(-nNr1,-nNr2);
3929 					Size aSz(nNr3,nNr4);
3930 					VirtualDevice aVDev( *pControl );
3931 
3932 					aVDev.SetOutputSizePixel( aSz );
3933 					aVDev.DrawBitmap( aPt, aBmp );
3934 					aBmp = aVDev.GetBitmap( Point(), aSz );
3935 				}
3936 
3937 				SvFileStream fOut;
3938 				fOut.Open(aString1,STREAM_STD_WRITE);
3939 				aBmp.Write(fOut);
3940 				if ( fOut.GetError() )
3941 					ReportError( aUId, GEN_RES_STR1( S_ERROR_SAVING_IMAGE, UniString::CreateFromInt32( fOut.GetError() ) ) );
3942 				fOut.Close();
3943 			}
3944 			break;
3945 		case M_GetFixedTextCount:
3946             {
3947     			pRet->GenReturn ( RET_Value, aUId, CountWinByRT( pControl, WINDOW_FIXEDTEXT, sal_True ) );
3948             }
3949 			break;
3950 		case M_GetFixedText:
3951             {
3952 				if( ( nParams & PARAM_USHORT_1 ) == 0 )
3953                     nNr1 = 1;
3954 
3955                 FixedText* pFixedText = (FixedText*)GetWinByRT( pControl, WINDOW_FIXEDTEXT, sal_True, nNr1-1 );
3956                 if ( pFixedText )
3957     			    pRet->GenReturn ( RET_Value, aUId, pFixedText->GetText() );
3958                 else
3959 					ValueOK(aUId, MethodString( nMethodId ),nNr1,CountWinByRT( pControl, WINDOW_FIXEDTEXT, sal_True ) );
3960             }
3961 			break;
3962 		default:
3963 			return sal_False;
3964 		}
3965 		SendProfile( UIdString( aUId ).Append('.').Append( MethodString( nMethodId ) ) );
3966 		return sal_True;
3967 	}
3968 	return sal_False;
3969 }
3970 
3971 sal_Bool StatementControl::HandleCommonMethods( Window *pControl )
3972 {
3973 	switch( nMethodId )		// Diese k�nnen an jedem Window ausgef�hrt werden
3974 	{
3975 		case M_Exists:			// Oben schon Behandelt. Unterdr�ckt hier nur Fehler
3976 		case M_NotExists:
3977 		case M_IsEnabled:
3978 		case M_IsVisible:
3979 		case M_SnapShot:
3980 			break;
3981 		case M_Caption :
3982 			{
3983 				if ( pControl->GetText().Len() == 0 && IsDocFrame( pControl->GetWindow( WINDOW_FRAME ) ) )
3984                     pRet->GenReturn ( RET_Value, aUId, pControl->GetWindow( WINDOW_FRAME )->GetText());
3985                 else
3986                     pRet->GenReturn ( RET_Value, aUId, pControl->GetText());
3987 			}
3988 			break;
3989 		case M_GetRT:
3990 			{
3991 				pRet->GenReturn ( RET_Value, aUId, (comm_ULONG)pControl->GetType() );
3992 			}
3993 			break;
3994 		case M_TypeKeys:
3995 			{
3996 				if( !(nParams & PARAM_USHORT_1) )	// Anzahl wiederholungen
3997 					nNr1 = 1;
3998 				if( !(nParams & PARAM_BOOL_1) )		// Follow Focus
3999 					bBool1 = sal_False;		// so bleibt das bisherige Verhalten
4000 
4001 				if ( !bBool1 )			// Altes Verhalten
4002 					pControl->GrabFocus();
4003                 else    // If focus is not inside given control we grab it once.
4004                 {
4005                     Window *pFocus = GetpApp()->GetFocusWindow();
4006 					if ( !pFocus || !pControl->IsWindowOrChild( pFocus, sal_True ) )
4007     					pControl->GrabFocus();
4008                 }
4009 
4010 
4011                 // maybe this can get removed since we are using GetPreferredKeyInputWindow()
4012 				if ( pControl->GetType() == WINDOW_COMBOBOX )
4013 				{	// Bei COMBOBOX an das Edit direkt liefern
4014 					Window *pTemp = NULL;
4015 					for ( sal_uInt16 i = 0 ; i < pControl->GetChildCount() && !pTemp ; i++ )
4016 						if ( pControl->GetChild( i )->GetType() == WINDOW_EDIT )
4017 							pTemp = pControl->GetChild( i );
4018 					if ( pTemp )
4019 						pControl = pTemp;
4020 				}
4021 
4022 				Window *pDeliverHere = pControl;
4023 				for (int j = 0; j < nNr1; j++)
4024 					for (xub_StrLen i = 0; i < aString1.Len(); i++)
4025 					{
4026  						if ( StatementList::bUsePostEvents )
4027 						{ // grab focus every time
4028 							Window *pFocus = GetpApp()->GetFocusWindow();
4029 							if ( !pFocus || !pControl->IsWindowOrChild( pFocus, sal_True ) )
4030     							pControl->GrabFocus();
4031 						}
4032 						if ( bBool1 )	// Jedesmal das FocusWindow finden
4033 						{
4034 							Window *pFocus = GetpApp()->GetFocusWindow();
4035 							if ( pFocus && pControl->IsWindowOrChild( pFocus, sal_True ) )
4036 								pDeliverHere = pFocus;
4037 							else	// sonst fallback auf das Basisfenster
4038 								pDeliverHere = pControl;
4039 						}
4040                         pDeliverHere = pDeliverHere->GetPreferredKeyInputWindow();
4041 						KeyEvent aEvent;
4042 						if ( ((sal_uInt16)aString1.GetChar(i)) <= 7 )
4043 						{
4044 							sal_uInt16 nVal = 0;
4045 							switch (aString1.GetChar(i))
4046 							{
4047 								case 1: nVal = aString1.GetChar(i+1) + (aString1.GetChar(i+2) << 8);
4048 										i += 2;
4049 										break;
4050 								case 3: nVal = (aString1.GetChar(i+1) << 8);
4051 										i++;
4052 										break;
4053 								case 5: nVal = aString1.GetChar(i+1);
4054 										i++;
4055 										break;
4056 								case 7: nVal = 0;
4057 										break;
4058 							}
4059                             // #105672#
4060                             // find out the keycode
4061                             sal_uInt16 nKeygroup = nVal & KEYGROUP_TYPE;
4062                             sal_uInt16 nKeyCode = nVal & KEY_CODE;
4063 							sal_Unicode aCh;
4064 							switch (nKeygroup)
4065 							{
4066                                 case KEYGROUP_NUM:
4067                                     aCh = nKeyCode - KEY_0 + '0';
4068                                     break;
4069                                 case KEYGROUP_ALPHA:
4070                                     aCh = nKeyCode - KEY_A;
4071                                     if ( nVal & KEY_MOD1 )
4072                                     {}
4073                                     else if ( nVal & KEY_SHIFT )
4074                                         aCh += 'A';
4075                                     else
4076                                         aCh += 'a';
4077                                 break;
4078                                 case KEYGROUP_MISC:
4079 									{							//  CR  ESC TAB BACK
4080                                         ByteString aPrintableMisc("\x0d\x1b\x09\x08 **+-*/.,<>=",16);
4081                                         if ( nKeyCode-KEY_RETURN < aPrintableMisc.Len()
4082                                             && nKeyCode != KEY_INSERT && nKeyCode != KEY_DELETE )
4083                                             aCh = aPrintableMisc.GetChar( nKeyCode-KEY_RETURN );
4084                                         else
4085                                             aCh = 0;
4086                                     }
4087                                     break;
4088                                 case KEYGROUP_CURSOR:
4089                                 case KEYGROUP_FKEYS:
4090                                 default:
4091                                     aCh = 0;
4092                             }
4093 							aEvent = KeyEvent(aCh,KeyCode(nVal & 0xFFF,nVal & 0xF000));
4094 						}
4095 						else
4096 						{
4097 															//   CR  ESC TAB BACK
4098 							String aPrintableMisc = CUniString("\x0d\x1b\x09\x08 xx+-*/.,<>=");
4099 							sal_Unicode aCh = aString1.GetChar(i);
4100 							if ( aCh >= 'a' && aCh <= 'z' )
4101 								aEvent = KeyEvent(aCh, KeyCode(KEYGROUP_ALPHA + aCh-'a', 0));
4102 							else if ( aCh >= 'A' && aCh <= 'Z' )
4103 								aEvent = KeyEvent(aCh, KeyCode(KEYGROUP_ALPHA + aCh-'a', KEY_SHIFT));
4104 							else if ( aCh >= '0' && aCh <= '9' )
4105 								aEvent = KeyEvent(aCh, KeyCode(KEYGROUP_NUM + aCh-'0', 0));
4106 							else if ( aPrintableMisc.Search(aCh) != STRING_NOTFOUND )
4107 								aEvent = KeyEvent(aCh, KeyCode(KEYGROUP_MISC + (sal_uInt16)aPrintableMisc.Search(aCh), 0));
4108 							else	// Sollte eigentlich nicht auftreten
4109 								aEvent = KeyEvent(aCh, KeyCode());
4110 						}
4111 						ImplKeyInput( pDeliverHere, aEvent );
4112 						if ( !MaybeDoTypeKeysDelay( pControl ) )
4113 							break;
4114                         else
4115                             SafeReschedule();SafeReschedule();SafeReschedule();
4116 					}
4117 			}
4118 			break;
4119 
4120 #define CalcMouseButton\
4121 	sal_uInt16 nButton = MOUSE_LEFT;\
4122 	if ( (nParams & PARAM_USHORT_3) )\
4123 	{\
4124 		switch ( nNr3 )\
4125 		{\
4126 			case 1: nButton = MOUSE_LEFT; break;\
4127 			case 2: nButton = MOUSE_MIDDLE; break;\
4128 			case 3: nButton = MOUSE_RIGHT; break;\
4129 		}\
4130 	}\
4131 
4132 		case M_MouseDown:
4133 			{
4134 				CalcMouseButton;
4135 				Size aS = pControl->GetOutputSizePixel();
4136 				Point aPos = Point(aS.Width() * nNr1 / 100,aS.Height() * nNr2 / 100);
4137 				Window *pActualWin = pControl->FindWindow( aPos );
4138 //					AnimateMouse( pControl, aPos );
4139 
4140 				if ( pActualWin )
4141                     aPos = pActualWin->AbsoluteScreenToOutputPixel( pControl->OutputToAbsoluteScreenPixel ( aPos ) );
4142 //					aPos = pActualWin->ScreenToOutputPixel( pControl->OutputToScreenPixel ( aPos ) );
4143 				else
4144 					pActualWin = pControl;
4145 
4146 				AnimateMouse( pActualWin, aPos );
4147 				pActualWin->GrabFocus();
4148 				MouseEvent aMEvnt(aPos,1,MOUSE_SIMPLECLICK|MOUSE_SELECT,nButton);
4149 				ImplMouseButtonDown( pActualWin, aMEvnt );
4150 			}
4151 			break;
4152 		case M_MouseUp:
4153 			{
4154 				CalcMouseButton;
4155 				Size aS = pControl->GetOutputSizePixel();
4156 				Point aPos = Point(aS.Width() * nNr1 / 100,aS.Height() * nNr2 / 100);
4157 				Window *pActualWin = pControl->FindWindow( aPos );
4158 
4159 				if ( pActualWin )
4160                     aPos = pActualWin->AbsoluteScreenToOutputPixel( pControl->OutputToAbsoluteScreenPixel ( aPos ) );
4161 //					aPos = pActualWin->ScreenToOutputPixel( pControl->OutputToScreenPixel ( aPos ) );
4162 				else
4163 					pActualWin = pControl;
4164 
4165 				AnimateMouse( pActualWin, aPos );
4166 //					pActualWin->GrabFocus();
4167 				MouseEvent aMEvt( aPos, 1, MOUSE_SIMPLECLICK|MOUSE_SELECT, nButton );
4168 				ImplMouseButtonUp( pActualWin, aMEvt );
4169 			}
4170 			break;
4171 		case M_MouseMove:
4172 			{
4173 				CalcMouseButton;
4174 				Size aS = pControl->GetOutputSizePixel();
4175 				Point aPos = Point(aS.Width() * nNr1 / 100,aS.Height() * nNr2 / 100);
4176 				Window *pActualWin = pControl->FindWindow( aPos );
4177 
4178 				if ( pActualWin )
4179 				{
4180                     aPos = pActualWin->AbsoluteScreenToOutputPixel( pControl->OutputToAbsoluteScreenPixel ( aPos ) );
4181 //					aPos = pActualWin->ScreenToOutputPixel( pControl->OutputToScreenPixel ( aPos ) );
4182 				}
4183 				else
4184 					pActualWin = pControl;
4185 
4186 				AnimateMouse( pActualWin, aPos );
4187 //					pActualWin->GrabFocus();
4188 				MouseEvent aMEvt( aPos, 0, MOUSE_SIMPLEMOVE|MOUSE_DRAGMOVE, nButton );
4189 				ImplMouseMove( pActualWin, aMEvt );
4190 			}
4191 			break;
4192 		case M_MouseDoubleClick:
4193 			{
4194 				CalcMouseButton;
4195 				Size aS = pControl->GetOutputSizePixel();
4196 				Point aPos = Point(aS.Width() * nNr1 / 100,aS.Height() * nNr2 / 100);
4197 				Window *pActualWin = pControl->FindWindow( aPos );
4198 
4199 				if ( pActualWin )
4200 				{
4201                     aPos = pActualWin->AbsoluteScreenToOutputPixel( pControl->OutputToAbsoluteScreenPixel ( aPos ) );
4202 //					aPos = pActualWin->ScreenToOutputPixel( pControl->OutputToScreenPixel ( aPos ) );
4203 				}
4204 				else
4205 					pActualWin = pControl;
4206 
4207 				AnimateMouse( pActualWin, aPos );
4208 				pActualWin->GrabFocus();
4209 				MouseEvent aMEvnt;
4210 				aMEvnt = MouseEvent(aPos,1,MOUSE_SIMPLECLICK|MOUSE_SELECT,nButton);
4211 				ImplMouseButtonDown( pActualWin, aMEvnt );
4212 				ImplMouseButtonUp  ( pActualWin, aMEvnt );
4213 				aMEvnt = MouseEvent(aPos,2,MOUSE_SIMPLECLICK|MOUSE_SELECT,nButton);
4214 				ImplMouseButtonDown( pActualWin, aMEvnt );
4215 				ImplMouseButtonUp  ( pActualWin, aMEvnt );
4216 			}
4217 			break;
4218 		case M_DisplayPercent:
4219 			{
4220 				ModelessDialog *pDlg = new ModelessDialog(NULL);
4221 				pDlg->SetOutputSizePixel(Size(100,30));
4222 
4223 				Edit *pMyEd = new Edit(pDlg,WB_CENTER | WB_BORDER );
4224 				pMyEd->SetSizePixel(Size(100,30));
4225 				pDlg->SetText(UniString("Schlie�en", RTL_TEXTENCODING_ISO_8859_1));
4226 				pDlg->Show();
4227 				pMyEd->Show();
4228 				sal_uLong nTime = Time().GetTime();
4229 
4230 				while (pDlg->IsVisible())
4231 				{
4232 					pDlg->ToTop();
4233 					for (int i = 1 ; i<10 ; i++)
4234 						SafeReschedule();
4235 					Point Pos = pControl->GetPointerPosPixel();
4236 					Size Siz=pControl->GetOutputSizePixel();
4237 					if ( Time().GetTime() - nTime > 10 )
4238 					{
4239 						nTime = Time().GetTime();
4240 						pMyEd->SetText(UniString::CreateFromInt32(Pos.X()*100/Siz.Width()).AppendAscii("%x").Append( UniString::CreateFromInt32(Pos.Y()*100/Siz.Height()) ).Append('%'));
4241 					}
4242 				}
4243 
4244 				delete pMyEd;
4245 				delete pDlg;
4246 			}
4247 			break;
4248 		case M_OpenContextMenu:
4249 			{
4250 				aSubMenuId1 = 0;
4251 				aSubMenuId2 = 0;
4252 				aSubMenuId3 = 0;
4253                 pMenuWindow = NULL;
4254 				Point aPos;
4255                 ToolBox* pTB = (ToolBox*)pControl;
4256                 if ( (pControl->GetType() == WINDOW_TOOLBOX) && pTB->IsMenuEnabled() )
4257                 {
4258                     pTB->ExecuteCustomMenu();
4259 /*                    Rectangle aRect = pTB->GetMenubuttonRect();
4260 					AnimateMouse( pControl, aRect.Center() );
4261 					MouseEvent aMEvnt(aRect.Center(),1,MOUSE_SIMPLECLICK,MOUSE_LEFT);
4262 					ImplMouseButtonDown( pTB, aMEvnt );*/
4263                 }
4264                 else
4265                 {
4266 				    sal_Bool bAtMousePos = ( nParams & PARAM_BOOL_1 ) && bBool1;
4267 				    if ( bAtMousePos )
4268 				    {
4269 					    aPos = pControl->GetPointerPosPixel();
4270 					    Window *pActualWin = pControl->FindWindow( aPos );
4271 
4272 					    if ( pActualWin )
4273 					    {
4274                             aPos = pActualWin->AbsoluteScreenToOutputPixel( pControl->OutputToAbsoluteScreenPixel ( aPos ) );
4275     //		    			aPos = pActualWin->ScreenToOutputPixel( pControl->OutputToScreenPixel ( aPos ) );
4276 						    pControl = pActualWin;
4277 					    }
4278 				    }
4279 				    CommandEvent aEvent( aPos, COMMAND_CONTEXTMENU, bAtMousePos );
4280 				    ImplCommand( pControl, aEvent );
4281                 }
4282 			}
4283 			break;
4284 		case M_UseMenu:
4285 			{
4286 				aSubMenuId1 = 0;
4287 				aSubMenuId2 = 0;
4288 				aSubMenuId3 = 0;
4289                 pMenuWindow = NULL;
4290 
4291                 while ( pControl && !( ( pControl->GetType() == WINDOW_SYSWINDOW || pControl->GetType() == WINDOW_WORKWINDOW ) && ControlOK( pControl, "" ) ) )
4292                     pControl = pControl->GET_REAL_PARENT();
4293 
4294                 if ( pControl && ((SystemWindow*)pControl)->GetMenuBar() )
4295                     pMenuWindow = ((SystemWindow*)pControl);
4296                 else
4297 					ReportError( GEN_RES_STR1( S_NO_MENU, MethodString( nMethodId ) ) );
4298 			}
4299 			break;
4300 		case M_FadeIn:
4301 		case M_FadeOut:
4302 		case M_Pin:
4303 		case M_IsFadeIn:
4304 		case M_IsPin:
4305 			{
4306 				WindowAlign aWindowAlign = WINDOWALIGN_LEFT;
4307 				if ( (nParams & PARAM_USHORT_1) )
4308 				{
4309 					switch ( nNr1 )
4310 					{
4311 						case CONST_ALIGN_LEFT:
4312 							aWindowAlign = WINDOWALIGN_LEFT;
4313 							break;
4314 						case CONST_ALIGN_TOP:
4315 							aWindowAlign = WINDOWALIGN_TOP;
4316 							break;
4317 						case CONST_ALIGN_RIGHT:
4318 							aWindowAlign = WINDOWALIGN_RIGHT;
4319 							break;
4320 						case CONST_ALIGN_BOTTOM:
4321 							aWindowAlign = WINDOWALIGN_BOTTOM;
4322 							break;
4323 						default:
4324 							ReportError( aUId, GEN_RES_STR1( S_INVALID_POSITION, MethodString( nMethodId ) ) );
4325 					}
4326 				}
4327 
4328 				Window* pTemp = NULL;
4329 				while ( !pTemp && pControl )
4330 				{
4331 					pTemp = GetFadeSplitWin( pControl, aWindowAlign );
4332 					pControl = pControl->GET_REAL_PARENT();
4333 				}
4334 
4335 				if ( !pTemp )
4336 				{
4337 					ReportError( aUId, GEN_RES_STR1( S_SPLITWIN_NOT_FOUND, MethodString( nMethodId ) ) );
4338 					break;
4339 				}
4340 
4341 				pControl = pTemp;	// So da� wir unten ohne Fehler durchkommen
4342 				SplitWindow *pSW = (SplitWindow*) pTemp;
4343 
4344 //	Rectangle			GetAutoHideRect() const;
4345 //	Rectangle			GetFadeInRect() const;
4346 //	Rectangle			GetFadeOutRect() const;
4347 
4348 				switch( nMethodId )
4349 				{
4350 					case M_FadeIn:
4351 						if ( pSW->IsFadeInButtonVisible() )
4352 							pSW->FadeIn();
4353 						break;
4354 					case M_FadeOut:
4355 						if ( pSW->IsFadeOutButtonVisible() )
4356 							pSW->FadeOut();
4357 						break;
4358 					case M_Pin:
4359 						if (   ( pSW->GetAutoHideState() && bBool1 )
4360 							|| ( !pSW->GetAutoHideState() && !bBool1 ) )
4361 						{
4362 							MouseEvent aMEvnt;
4363 							Point aPt( pSW->GetAutoHideRect().Center() );
4364 							aMEvnt = MouseEvent( aPt,1,MOUSE_SIMPLECLICK,MOUSE_LEFT );
4365 							ImplMouseButtonDown( pControl, aMEvnt, FORCE_DIRECT_CALL );
4366 							ImplMouseButtonUp  ( pControl, aMEvnt, FORCE_DIRECT_CALL );
4367 						}
4368 //								pSW->AutoHide();
4369 						break;
4370 					case M_IsFadeIn:
4371 						pRet->GenReturn ( RET_Value, aUId, pSW->IsFadeOutButtonVisible() );
4372 						break;
4373 					case M_IsPin:
4374 						pRet->GenReturn ( RET_Value, aUId, (comm_BOOL)!pSW->GetAutoHideState() );
4375 						break;
4376 					default:
4377 						ReportError( aUId, GEN_RES_STR1( S_INTERNAL_ERROR, MethodString( nMethodId ) ) );
4378 				}
4379 				SendProfile( UIdString( aUId ).Append('.').Append( MethodString( nMethodId ) ) );
4380 			}
4381 			break;
4382 		case M_StatusGetText:
4383 		case M_StatusIsProgress:
4384 		case M_StatusGetItemCount:
4385 		case M_StatusGetItemId:
4386 			{
4387 				StatusBar *pStatus = NULL;
4388 				while ( !pStatus && pControl )
4389 				{
4390 					pStatus = (StatusBar*)GetWinByRT( pControl, WINDOW_STATUSBAR, sal_True );
4391 					pControl = pControl->GET_REAL_PARENT();
4392 				}
4393 
4394 				if ( !pStatus )
4395 				{
4396 					ReportError( aUId, GEN_RES_STR1( S_NO_STATUSBAR, MethodString( nMethodId ) ) );
4397 					break;
4398 				}
4399 
4400 				switch ( nMethodId )
4401 				{
4402 					case M_StatusGetText:
4403 						{
4404 							if ( (nParams & PARAM_USHORT_1) )
4405 							{
4406 								if ( pStatus->AreItemsVisible() )
4407 									pRet->GenReturn ( RET_Value, aUId, String(pStatus->GetItemText(nNr1)));
4408 								else
4409 									ReportError( aUId, GEN_RES_STR1( S_ITEMS_INVISIBLE, MethodString( nMethodId ) ) );
4410 							}
4411 							else
4412 							{
4413 								if ( pStatus->AreItemsVisible() )
4414 								{
4415 									if ( pStatus->GetItemCount() == 1 )
4416 									{
4417 										pRet->GenReturn ( RET_Value, aUId, pStatus->GetItemText( pStatus->GetItemId(0) ));
4418 									}
4419 									else
4420 									{
4421 										pRet->GenReturn ( RET_Value, aUId, String() );
4422 									}
4423 								}
4424 								else
4425 									pRet->GenReturn ( RET_Value, aUId, (String)pStatus->GetText() );
4426 							}
4427 						}
4428 						break;
4429 					case M_StatusIsProgress:
4430 						{
4431 							pRet->GenReturn ( RET_Value, aUId, (comm_BOOL)pStatus->IsProgressMode() );
4432 						}
4433 						break;
4434 					case M_StatusGetItemCount:
4435 						if ( pStatus->AreItemsVisible() )
4436 							pRet->GenReturn ( RET_Value, aUId, comm_ULONG(pStatus->GetItemCount()));
4437 						else
4438 							pRet->GenReturn ( RET_Value, aUId, comm_ULONG(0));
4439 						break;
4440 					case M_StatusGetItemId:
4441 						if ( ValueOK(aUId, MethodString( nMethodId ),nNr1,pStatus->GetItemCount()) )
4442 							pRet->GenReturn ( RET_Value, aUId, comm_ULONG(pStatus->GetItemId(nNr1-1)));
4443 						break;
4444 				}
4445 			}
4446 			break;
4447 		case M_HasScrollBar:
4448 		case M_IsScrollBarEnabled:
4449 			{
4450                 if ( (nParams | PARAM_USHORT_1) != PARAM_USHORT_1 )     // so there are other params
4451                 {
4452 					ReportError( aUId, GEN_RES_STR0( S_INVALID_PARAMETERS ) );
4453                     break;
4454                 }
4455 
4456                 if( !(nParams & PARAM_USHORT_1) )
4457 					nNr1 = CONST_ALIGN_RIGHT;		// default is right Scrollbar(vertical)
4458 
4459                 if ( (nNr1 != CONST_ALIGN_RIGHT) && (nNr1 != CONST_ALIGN_BOTTOM) )
4460                 {
4461 					ReportError( aUId, GEN_RES_STR1( S_INVALID_POSITION, MethodString( nMethodId ) ) );
4462                     break;
4463                 }
4464 
4465                 ScrollBar *pScroll = NULL;
4466 
4467 				sal_uInt16 nSteps = 2;
4468                 while ( !pScroll && pControl && nSteps-- )
4469 				{
4470 					pScroll = GetScrollBar( pControl, nNr1, sal_True );
4471 					pControl = pControl->GET_REAL_PARENT();
4472 				}
4473 
4474 				switch ( nMethodId )
4475 				{
4476 					case M_HasScrollBar:
4477 						{
4478 				            if ( pScroll )
4479     							pRet->GenReturn ( RET_Value, aUId, (comm_BOOL)sal_True );
4480                             else
4481     							pRet->GenReturn ( RET_Value, aUId, (comm_BOOL)sal_False );
4482 						}
4483 						break;
4484 					case M_IsScrollBarEnabled:
4485 						{
4486 				            if ( !pScroll )
4487 				            {
4488 					            ReportError( aUId, GEN_RES_STR1( S_NO_SCROLLBAR, MethodString( nMethodId ) ) );
4489 					            break;
4490 				            }
4491    							pRet->GenReturn ( RET_Value, aUId, pScroll->IsEnabled() );
4492 						}
4493 						break;
4494                 }
4495 			}
4496 			break;
4497 		default:
4498 			return sal_False;
4499 	}
4500 	return sal_True;
4501 }
4502 
4503 
4504 sal_Bool StatementControl::Execute()
4505 {
4506 	Window *pControl;
4507 	sal_Bool bStatementDone = sal_True;
4508 
4509 
4510 	if ( IsError )
4511 	{
4512         #if OSL_DEBUG_LEVEL > 1
4513 		m_pDbgWin->AddText( "Skipping Window: " );
4514 		m_pDbgWin->AddText( Id2Str( aUId ) );
4515 		m_pDbgWin->AddText( " Method: " );
4516 		m_pDbgWin->AddText( String::CreateFromInt32( nMethodId ) );
4517 		m_pDbgWin->AddText( "\n" );
4518 		#endif
4519 		Advance();
4520 		delete this;
4521 		return sal_True;
4522 	}
4523 
4524 	InitProfile();
4525 #if OSL_DEBUG_LEVEL > 1
4526 	m_pDbgWin->AddText( "Executing Window: " );
4527 	m_pDbgWin->AddText( Id2Str( aUId ) );
4528 	m_pDbgWin->AddText( " Method: " );
4529 	m_pDbgWin->AddText( String::CreateFromInt32( nMethodId ) );
4530 	m_pDbgWin->AddText( "\n" );
4531 #endif
4532 
4533 
4534 	if ( aUId.equals( UID_ACTIVE ) )
4535 		pControl = GetAnyActive();
4536 	else
4537 	{
4538 		sal_Bool bSearchButtonOnToolbox = (nParams == PARAM_NONE) && ((M_Click == nMethodId) || (M_TearOff == nMethodId) || (M_IsEnabled == nMethodId) || (M_OpenMenu == nMethodId));
4539 		bSearchButtonOnToolbox |= (nParams == PARAM_USHORT_1) && (M_GetState == nMethodId);
4540         if ( nMethodId == M_TypeKeys || nMethodId == M_MouseDown
4541 			|| nMethodId == M_MouseUp || nMethodId ==  M_MouseMove
4542 			|| nMethodId == M_SnapShot )
4543 		{
4544 			pControl = NULL;
4545 			if ( /*(nMethodId == M_SnapShot || nMethodId == M_TypeKeys) &&*/ !pControl )
4546 				pControl = SearchTree( aUId ,bSearchButtonOnToolbox );
4547 		}
4548 		else
4549 			pControl = SearchTree( aUId ,bSearchButtonOnToolbox );
4550 	}
4551 
4552 
4553 	if ( pControl && pControl->GetType() == WINDOW_TOOLBOX )
4554 	{
4555         if ( !aUId.equals( pControl->GetUniqueOrHelpId() ) )
4556         {   // Also wenn wir irgendwas auf einer Toolbox gefunden haben
4557 		    switch ( nMethodId )
4558 		    {
4559 			    case M_Click:
4560 			    case M_TearOff:
4561 			    case M_OpenMenu:
4562 			    case M_GetState:
4563                     break;
4564 			    case M_IsEnabled:
4565 				    nMethodId = _M_IsEnabled;	// Umlabeln, da die Behandlung essentiell anders ist!
4566 				    break;
4567 			    default:
4568 				    pControl = NULL;
4569 		    }
4570         }
4571 	}
4572 
4573 
4574 	switch ( nMethodId )
4575 	{
4576 		case M_Exists:
4577 		case M_NotExists:
4578 			Time aT;
4579 			sal_uInt16 aSeconds = aT.GetMin()*60+aT.GetSec();
4580 			if ( !bBool2 )			// wurde im Konstruktor auf sal_False gesetzt
4581 			{
4582 				bBool2 = sal_True;
4583 				nNr2 = aSeconds;
4584 				if( !(nParams & PARAM_USHORT_1) )
4585 					nNr1 = 0;		// defaultm��ig sofort zur�ck
4586 			}
4587 			if ( aSeconds < nNr2 )			// Falls die Stunde umgesprungen ist
4588 				aSeconds += 60*60;
4589 
4590 			if ( /* !IsAccessable(pControl)#87019# */ !pControl || !pControl->IsVisible() )
4591 				pControl = NULL;
4592 			if ( ((nMethodId == M_Exists) && pControl) ||
4593 				 ((nMethodId == M_NotExists) && !pControl) )
4594 			{	// Wenn Bedingung erf�llt
4595 				pRet->GenReturn ( RET_Value, aUId, (comm_BOOL)sal_True );
4596 			}
4597 			else
4598 				if ( aSeconds <= nNr2 + nNr1 )		// Zeit ist noch nicht abgelaufen
4599 					return sal_False;
4600 				else
4601 					pRet->GenReturn ( RET_Value, aUId, (comm_BOOL)sal_False );
4602 
4603 			Advance();
4604 			delete this;
4605 			return sal_True;
4606 //			break;
4607 	}
4608 
4609 
4610 	short nRT = 0;
4611 
4612 	if( pControl )			// Das Fenster Existiert irgendwo, kann aber auch hidden sein!
4613 	{
4614 		nRT = ImpGetRType( pControl );
4615 #if OSL_DEBUG_LEVEL > 1
4616 		m_pDbgWin->AddText( "Type is: " );
4617 		m_pDbgWin->AddText( String::CreateFromInt32( nRT ) );
4618 		m_pDbgWin->AddText( "\n" );
4619 #endif
4620 	}
4621 
4622     if (   nRT == C_Window &&       // Search for WorkWindow to satisfy these commands
4623          ( nMethodId == M_Close
4624 //		|| nMethodId == M_Size
4625 //		|| nMethodId == M_Move
4626 		|| nMethodId == M_IsMax
4627 		|| nMethodId == M_IsMin
4628 		|| nMethodId == M_IsRestore
4629 		|| nMethodId == M_Minimize
4630 		|| nMethodId == M_Maximize
4631 		|| nMethodId == M_Restore ) )
4632     {
4633         Window* pNewControl = pControl;
4634         while ( pNewControl && pNewControl->GetType() != WINDOW_WORKWINDOW )
4635             pNewControl = pNewControl->GET_REAL_PARENT();
4636 
4637         if ( pNewControl )
4638         {
4639             pControl = pNewControl;
4640             nRT = C_WorkWin;
4641         }
4642     }
4643 
4644 
4645 	if ( (!ControlOK( pControl, "" )) && ( nMethodId != M_SnapShot ) && (nRetryCount--))
4646 	{
4647 #if OSL_DEBUG_LEVEL > 1
4648 		m_pDbgWin->AddText( CUniString("Reschedule command (").Append( UniString::CreateFromInt32(nRetryCount) ).AppendAscii(")\n") );
4649 #endif
4650 		return sal_False;
4651 	}
4652 
4653 	if( ControlOK( pControl, "" ) )
4654 	{
4655 		if ( nMethodId == M_OpenContextMenu && !bBool2 )
4656         {
4657 			pControl->GrabFocus();  // to get asyncron focus on unix
4658             bBool2 = sal_True;
4659             return sal_False;
4660         }
4661         // TODO: handle GetFocus for all Methods and Windows like this (remove part below)
4662         //       See for impact of changed focus for HandleVisibleControls() (taking Snapshots might be different, possible exclude those methods)
4663 		if (( (nRT == C_TreeListBox) && !bBool2 )
4664 			&& nMethodId != M_TypeKeys			// TypeKeys macht das selbst, falls eigenes Focushandling gew�nscht
4665 			&& nMethodId != M_MouseDown
4666 			&& nMethodId != M_MouseUp
4667 			&& nMethodId != M_MouseMove
4668 			/*&& nMethodId != M_MouseDoubleClick*/ )
4669         {
4670             if ( !pControl->HasFocus() )
4671             {
4672 			    pControl->GrabFocus();
4673                 int i = 10;
4674                 while ( i-- && !pControl->HasFocus() )    // reschedule a bit
4675                 {
4676                     SafeReschedule();
4677                     if ( !WinPtrValid( pControl ) )
4678                         return sal_False;
4679                 }
4680                 if ( !pControl->HasFocus() )  // to get asyncronous focus
4681                 {
4682                     bBool2 = sal_True;
4683                     return sal_False;
4684                 }
4685             }
4686         }
4687     }
4688 
4689     Advance();
4690 
4691 	if ( HandleVisibleControls( pControl ) )
4692 	{
4693 		delete this;
4694 		return sal_True;
4695 	}
4696 	if( ControlOK( pControl, "Window/Control" ) )
4697 	{
4698 		if (((( nRT < C_TabPage && nRT > C_TabControl )
4699               || nRT == C_PatternBox
4700               || nRT == C_ToolBox
4701               || nRT == C_ValueSet
4702               || nRT == C_Control
4703               || nRT == C_TreeListBox
4704              )
4705 			|| nMethodId == M_OpenContextMenu )
4706 			&& nMethodId != M_TypeKeys			// TypeKeys macht das selbst, falls eigenes Focushandling gew�nscht
4707 			&& nMethodId != M_MouseDown
4708 			&& nMethodId != M_MouseUp
4709 			&& nMethodId != M_MouseMove
4710 			/*&& nMethodId != M_MouseDoubleClick*/ )
4711 			pControl->GrabFocus();
4712 
4713 /*  leads to problems because settext sets the text whereas typekeys adds to the text.
4714         if ( bDoTypeKeysDelay && nMethodId == M_SetText && ( nParams & PARAM_STR_1 ) )
4715 		{	// Hier wird das Statement auf ein TypeKeys umgebogen
4716 			nMethodId = M_TypeKeys;
4717 			nParams = PARAM_BOOL_1 | PARAM_STR_1;
4718 			bBool1 = sal_True;
4719 			pControl->GrabFocus();
4720 		}
4721 */
4722 		if ( !HandleCommonMethods( pControl ) )
4723 		{
4724 			switch( nRT )
4725 			{
4726 				case C_TabControl:
4727 					switch( nMethodId )
4728 					{
4729 						case M_GetPageId:
4730 							if ( (nParams & PARAM_USHORT_1) )
4731 							{
4732 								if ( ValueOK(aUId, MethodString( nMethodId ),nNr1,((TabControl*)pControl)->GetPageCount() ) )
4733 									pRet->GenReturn ( RET_Value, aUId, (comm_ULONG)((TabControl*)pControl)->GetPageId(nNr1-1));
4734 							}
4735 							else
4736 								pRet->GenReturn ( RET_Value, aUId, (comm_ULONG)((TabControl*)pControl)->GetCurPageId());
4737 							break;
4738 						case M_GetPageCount:
4739 							pRet->GenReturn ( RET_Value, aUId, (comm_ULONG)((TabControl*)pControl)->GetPageCount());
4740 							break;
4741 						case M_SetPageId:
4742 							if (((TabControl*)pControl)->GetCurPageId())
4743 								((TabControl*)pControl)->DeactivatePage();
4744 							((TabControl*)pControl)->SetCurPageId( nNr1 );
4745 							((TabControl*)pControl)->ActivatePage();
4746 							break;
4747 						case M_SetPageNr:
4748 							if ( ValueOK(aUId, MethodString( nMethodId ),nNr1,((TabControl*)pControl)->GetPageCount() ) )
4749 							{
4750 								if (((TabControl*)pControl)->GetCurPageId())
4751 									((TabControl*)pControl)->DeactivatePage();
4752 								((TabControl*)pControl)->SetCurPageId( ((TabControl*)pControl)->GetPageId( nNr1-1 ) );
4753 								((TabControl*)pControl)->ActivatePage();
4754 							}
4755 							break;
4756 						case M_GetPage:
4757 							pRet->GenReturn ( RET_Value, aUId, Id2Str( ((TabControl*)pControl)->GetTabPage(((TabControl*)pControl)->GetCurPageId())->GetUniqueOrHelpId() ) );
4758 							break;
4759 						case M_SetPage :
4760 							{		// Wegen lokaler Variablen
4761 								TabControl *pTControl = ((TabControl*)pControl);
4762 								sal_uInt16 nActive = pTControl->GetCurPageId();
4763 								sal_uInt16 i,anz;
4764 								rtl::OString aID;
4765 								rtl::OString aWantedID;
4766                                 //HELPID BACKWARD (No numbers please (remove PARAM_ULONG_1 part)
4767 							    if ( (nParams & PARAM_ULONG_1) )
4768 							    {
4769 								    //aWantedID = rtl::OString( nLNr1 );
4770                                     ReportError( aUId, GEN_RES_STR1c( S_INTERNAL_ERROR, "using numeric HelpID from old Testtool" ) );
4771 							    }
4772 							    else if ( (nParams & PARAM_STR_1) )
4773 							    {
4774 								    aWantedID = Str2Id( aString1 );
4775 							    }
4776                                 else
4777     								ReportError( aUId, GEN_RES_STR1( S_INTERNAL_ERROR, MethodString( nMethodId ) ) );
4778 
4779 								i = pTControl->GetPagePos( pTControl->GetCurPageId() );
4780 								for ( anz=0 ; anz < pTControl->GetPageCount() && !aID.equals( aWantedID ) ; anz++ )
4781 								{
4782 									pTControl->SelectTabPage( pTControl->GetPageId(i) );
4783 									/*if (pTControl->GetCurPageId())
4784 										pTControl->DeactivatePage();
4785 									pTControl->SetCurPageId( pTControl->GetPageId(i) );
4786 									pTControl->ActivatePage();*/
4787 									aID = pTControl->GetTabPage(pTControl->GetCurPageId())->GetUniqueOrHelpId();
4788 									i++;
4789 									if ( i >= pTControl->GetPageCount() )
4790 										i = 0;
4791 									if ( !MaybeDoTypeKeysDelay( pTControl ) || !MaybeDoTypeKeysDelay( pTControl ) || !MaybeDoTypeKeysDelay( pTControl ) )	// 3 Mal aufrufen
4792 										break;
4793 								}
4794 								if ( !aID.equals( aWantedID ) )
4795 								{
4796 									pTControl->SelectTabPage( nActive );
4797 									/*if (pTControl->GetCurPageId())
4798 										pTControl->DeactivatePage();
4799 									pTControl->SetCurPageId( nActive );
4800 									pTControl->ActivatePage();*/
4801 									ReportError( aWantedID, GEN_RES_STR1( S_TABPAGE_NOT_FOUND, MethodString( nMethodId ) ) );
4802 								}
4803 							}
4804 							break;
4805 						default:
4806 							ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "TabControl" ) );
4807 							break;
4808 					}
4809 					break;
4810 				case C_RadioButton:
4811 				case C_ImageRadioButton:
4812 					switch( nMethodId )
4813 					{
4814 						case M_AnimateMouse :
4815 							AnimateMouse( pControl, MitteLinks);
4816 							break;
4817 						case M_IsChecked :
4818 							pRet->GenReturn ( RET_Value, aUId, ((RadioButton*)pControl)->IsChecked());
4819 							break;
4820 						case M_Check :
4821 							((RadioButton*)pControl)->Check();
4822 							((RadioButton*)pControl)->Click();
4823 							break;
4824 						default:
4825 							ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "RadioButton" ) );
4826 							break;
4827 					}
4828 					break;
4829 				case C_CheckBox:
4830 				case C_TriStateBox:
4831 					switch( nMethodId )
4832 					{
4833 						case M_AnimateMouse :
4834 							AnimateMouse( pControl, MitteLinks);
4835 							break;
4836 						case M_IsChecked :
4837 							pRet->GenReturn ( RET_Value, aUId, comm_BOOL( ((TriStateBox*)pControl)->GetState() == STATE_CHECK) );
4838 							break;
4839 						case M_IsTristate :
4840 							pRet->GenReturn ( RET_Value, aUId, comm_BOOL( ((TriStateBox*)pControl)->GetState() == STATE_DONTKNOW) );
4841 							break;
4842 						case M_GetState :
4843 							pRet->GenReturn ( RET_Value, aUId, comm_ULONG(((TriStateBox*)pControl)->GetState()));
4844 							break;
4845 						case M_Check :
4846 							((TriStateBox*)pControl)->SetState( STATE_CHECK );
4847 							((TriStateBox*)pControl)->Click();
4848 							break;
4849 						case M_UnCheck :
4850 							((TriStateBox*)pControl)->SetState( STATE_NOCHECK );
4851 							((TriStateBox*)pControl)->Click();
4852 							break;
4853 						case M_TriState :
4854 							if ( ((TriStateBox*)pControl)->IsTriStateEnabled() )
4855 							{
4856 								((TriStateBox*)pControl)->SetState( STATE_DONTKNOW );
4857 								((TriStateBox*)pControl)->Click();
4858 							}
4859 							else
4860 							{
4861 								ReportError( aUId, GEN_RES_STR0( S_TRISTATE_NOT_ALLOWED ) );
4862 							}
4863 							break;
4864 						case M_Click :
4865 							{
4866 								TriStateBox *pTB = ((TriStateBox*)pControl);
4867 								if ( pTB->GetState() == STATE_NOCHECK )
4868 									pTB->SetState( STATE_CHECK );
4869 								else if ( pTB->GetState() == STATE_CHECK )
4870 								{
4871 									if ( pTB->IsTriStateEnabled() )
4872 										pTB->SetState( STATE_DONTKNOW );
4873 									else
4874 										pTB->SetState( STATE_NOCHECK );
4875 								}
4876 								else
4877 									pTB->SetState( STATE_NOCHECK );
4878 								pTB->Click();
4879 								}
4880 							break;
4881 						default:
4882 							ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "TriStateBox" ) );
4883 							break;
4884 					}
4885 					break;
4886 				case C_Edit:
4887 				case C_MultiLineEdit:
4888 					switch( nMethodId )
4889 					{
4890 						case M_AnimateMouse :
4891 							AnimateMouse( pControl, Mitte);
4892 							break;
4893 						case M_GetText :
4894 							pRet->GenReturn ( RET_Value, aUId, ((Edit*)pControl)->GetText());
4895 							break;
4896 						case M_IsWritable:
4897 							pRet->GenReturn ( RET_Value, aUId, (comm_BOOL) !((Edit*)pControl)->IsReadOnly() );
4898 							break;
4899 						default:
4900 							if ( ! ((Edit*)pControl)->IsReadOnly() )
4901 							{
4902 								switch( nMethodId )
4903 								{
4904 									case M_SetText :
4905 										((Edit*)pControl)->SetText( aString1 );
4906                                         if ( nRT == C_MultiLineEdit )   // since SetModifyFlag is not virtual we have to do this
4907                                             ((MultiLineEdit*)pControl)->SetModifyFlag();
4908                                         else
4909                                             ((Edit*)pControl)->SetModifyFlag();
4910 										((Edit*)pControl)->Modify();
4911 										if ( ((Edit*)pControl)->GetText().CompareTo(aString1) != COMPARE_EQUAL )
4912 											ReportError( aUId, GEN_RES_STR1( S_ERROR_IN_SET_TEXT, MethodString( nMethodId ) ) );
4913 										break;
4914 									default:
4915 										ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "(MultiLine)Edit" ) );
4916 										break;
4917 								}
4918 							}
4919 							else
4920 								ReportError( aUId, GEN_RES_STR1c( S_ATTEMPT_TO_WRITE_READONLY, "(MultiLine)Edit" ) );
4921 					}
4922 					break;
4923 				case C_MultiListBox:
4924 				case C_ListBox:
4925 					switch( nMethodId )
4926 					{
4927 						case M_AnimateMouse :
4928 							AnimateMouse( pControl, MitteOben);
4929 							break;
4930 						case M_GetSelCount :
4931 							pRet->GenReturn ( RET_Value, aUId, comm_ULONG(((ListBox*)pControl)->GetSelectEntryCount()));
4932 							break;
4933 						case M_GetSelIndex :
4934 							if ( ! (nParams & PARAM_USHORT_1) )
4935 							{
4936 								if ( ((ListBox*)pControl)->GetSelectEntryCount() == 0 )
4937 								{
4938 									pRet->GenReturn ( RET_Value, aUId, comm_ULONG(0));
4939 									break;
4940 								}
4941 								nNr1 = 1;
4942 							}
4943 							ValueOK(aUId, MethodString( nMethodId ),nNr1,((ListBox*)pControl)->GetSelectEntryCount());
4944 							pRet->GenReturn ( RET_Value, aUId, comm_ULONG(((ListBox*)pControl)->GetSelectEntryPos(nNr1-1)) +1);
4945 							break;
4946 						case M_GetSelText :
4947 							if ( ! (nParams & PARAM_USHORT_1) )
4948 								nNr1 = 1;
4949 							pRet->GenReturn ( RET_Value, aUId, ((ListBox*)pControl)->GetSelectEntry(nNr1-1));
4950 							break;
4951 						case M_GetItemCount :
4952 							pRet->GenReturn ( RET_Value, aUId, comm_ULONG(((ListBox*)pControl)->GetEntryCount()));
4953 							break;
4954 						case M_GetItemText :
4955 							pRet->GenReturn ( RET_Value, aUId, ((ListBox*)pControl)->GetEntry(nNr1-1));
4956 							break;
4957 						case M_Select:
4958 						case M_MultiSelect:
4959 							{
4960 								sal_Bool bUnselectBeforeSelect = ( nMethodId == M_Select );
4961 								sal_Bool bFehler = sal_False;
4962 								if ( ! (nParams & PARAM_BOOL_1) )
4963 									bBool1 = sal_True;
4964 
4965 								if ( nMethodId == M_MultiSelect && nRT == C_ListBox )
4966 								{
4967 									ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "ListBox" ) );
4968 									bFehler = sal_True;
4969 								}
4970 
4971 								if ( !bBool1 && nMethodId == M_Select )
4972 								{
4973 									ReportError( aUId, GEN_RES_STR1( S_NO_SELECT_FALSE, MethodString( nMethodId ) ) );
4974 									bFehler = sal_True;
4975 								}
4976 
4977 								if ( !bFehler )
4978 								{
4979 									if( nParams & PARAM_STR_1 )
4980 									{
4981 										ListBox *pLB = ((ListBox*)pControl);
4982 										sal_uInt16 nPos;
4983 										if ( (nPos = pLB->GetEntryPos( aString1 )) == LISTBOX_ENTRY_NOTFOUND )
4984 											ReportError( aUId, GEN_RES_STR2( S_ENTRY_NOT_FOUND, MethodString( nMethodId ), aString1 ) );
4985 										else
4986 										{
4987 											if ( bUnselectBeforeSelect )
4988 												pLB->SetNoSelection();
4989 											pLB->SelectEntryPos( nPos, bBool1 );
4990 											if ( pLB->IsEntryPosSelected( nPos ) ? !bBool1 : bBool1 )	// XOR rein mit BOOL
4991 												ReportError( aUId, GEN_RES_STR2( S_METHOD_FAILED, MethodString( nMethodId ), aString1 ) );
4992 										}
4993 									}
4994 									else
4995 									{
4996 										ListBox *pLB = ((ListBox*)pControl);
4997 										pLB = static_cast<ListBox*>(pControl);
4998 										if ( ValueOK(aUId, MethodString( nMethodId ),nNr1,pLB->GetEntryCount()) )
4999 										{
5000 											if ( bUnselectBeforeSelect )
5001 												pLB->SetNoSelection();
5002 											pLB->SelectEntryPos( nNr1-1, bBool1 );
5003 											if ( pLB->IsEntryPosSelected( nNr1-1 ) ? !bBool1 : bBool1 )	// XOR rein mit BOOL
5004 												ReportError( aUId, GEN_RES_STR2( S_METHOD_FAILED, MethodString( nMethodId ), UniString::CreateFromInt32( nNr1 ) ) );
5005 										}
5006 									}
5007 									((ListBox*)pControl)->Select();
5008 								}
5009 							}
5010 							break;
5011 						case M_SetNoSelection :
5012 							((ListBox*)pControl)->SetNoSelection();
5013 							((ListBox*)pControl)->Select();
5014 							break;
5015 						default:
5016 							ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "(Multi)ListBox" ) );
5017 							break;
5018 					}
5019 					break;
5020 				case C_ComboBox:
5021 				case C_PatternBox:
5022 				case C_NumericBox:
5023 				case C_MetricBox:
5024 				case C_CurrencyBox:
5025 				case C_DateBox:
5026 				case C_TimeBox:
5027 					switch( nMethodId )
5028 					{
5029 						case M_AnimateMouse :
5030 							AnimateMouse( pControl, MitteOben);
5031 							break;
5032 						case M_GetSelText :
5033 							pRet->GenReturn ( RET_Value, aUId, ((ComboBox*)pControl)->GetText());
5034 							break;
5035 						case M_GetSelIndex :
5036 							{
5037 								sal_uInt16 nPos = ((ComboBox*)pControl)->GetEntryPos(((ComboBox*)pControl)->GetText());
5038 								if ( nPos == COMBOBOX_ENTRY_NOTFOUND )
5039 									nPos = 0;
5040 								else
5041 									nPos++;
5042 								pRet->GenReturn ( RET_Value, aUId, (comm_ULONG) nPos);
5043 							}
5044 							break;
5045 						case M_GetItemCount :
5046 							pRet->GenReturn ( RET_Value, aUId, comm_ULONG(((ComboBox*)pControl)->GetEntryCount()));
5047 							break;
5048 						case M_GetItemText :
5049 							pRet->GenReturn ( RET_Value, aUId, ((ComboBox*)pControl)->GetEntry(nNr1-1));
5050 							break;
5051 						case M_IsWritable:
5052 							pRet->GenReturn ( RET_Value, aUId, (comm_BOOL) !((ComboBox*)pControl)->IsReadOnly() );
5053 							break;
5054 						case M_Select :
5055 							if( nParams & PARAM_USHORT_1 )
5056 							{
5057 								if ( !ValueOK(aUId, MethodString( nMethodId ),nNr1,((ComboBox*)pControl)->GetEntryCount()) )
5058 									break;
5059 								aString1 = ((ComboBox*)pControl)->GetEntry(nNr1-1);
5060 							}
5061 							else
5062 							{
5063 								if ( ((ComboBox*)pControl)->GetEntryPos( aString1 ) == COMBOBOX_ENTRY_NOTFOUND )
5064 								{
5065 									ReportError( aUId, GEN_RES_STR2( S_ENTRY_NOT_FOUND, MethodString( nMethodId ), aString1 ) );
5066 									break;
5067 								}
5068 							}
5069 
5070 
5071 							((ComboBox*)pControl)->SetText( aString1 );
5072 							((ComboBox*)pControl)->SetModifyFlag();
5073 							((ComboBox*)pControl)->Modify();
5074 							break;
5075 						case M_SetText :
5076 							if ( ! ((ComboBox*)pControl)->IsReadOnly() )
5077 							{
5078 								if ( ! (nParams & PARAM_STR_1) )
5079 									aString1 = String();
5080 								((ComboBox*)pControl)->SetText( aString1 );
5081 								((ComboBox*)pControl)->SetModifyFlag();
5082 								((ComboBox*)pControl)->Modify();
5083 							}
5084 							else
5085 								ReportError( aUId, GEN_RES_STR1c( S_ATTEMPT_TO_WRITE_READONLY, "ComboBox" ) );
5086 							break;
5087 						default:
5088 							ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "ComboBox" ) );
5089 							break;
5090 					}
5091 					break;
5092 				case C_PushButton:
5093 				case C_OkButton:
5094 				case C_CancelButton:
5095 				case C_ImageButton:
5096 					switch( nMethodId )
5097 					{
5098 						case M_AnimateMouse :
5099 							AnimateMouse( pControl, Mitte);
5100 							break;
5101 						case M_Click :
5102 							((PushButton*)pControl)->Click();
5103 							break;
5104 						default:
5105 							ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "PushButton" ) );
5106 							break;
5107 					}
5108 					break;
5109 				case C_MoreButton:
5110 					switch( nMethodId )
5111 					{
5112 						case M_AnimateMouse :
5113 							AnimateMouse( pControl, Mitte);
5114 							break;
5115 						case M_IsOpen :
5116 							pRet->GenReturn ( RET_Value, aUId, ((MoreButton*)pControl)->GetState());
5117 							break;
5118 						case M_Click :
5119 							((MoreButton*)pControl)->Click();
5120 							break;
5121 						case M_Open :
5122 							((MoreButton*)pControl)->SetState(sal_True);
5123 							break;
5124 						case M_Close :
5125 							((MoreButton*)pControl)->SetState(sal_False);
5126 							break;
5127 						default:
5128 							ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "MoreButton" ) );
5129 							break;
5130 					}
5131 					break;
5132 				case C_SpinField:
5133 				case C_PatternField:
5134 				case C_NumericField:
5135 				case C_MetricField:
5136 				case C_CurrencyField:
5137 				case C_DateField:
5138 				case C_TimeField:
5139 					switch( nMethodId )
5140 					{
5141 						case M_AnimateMouse :
5142 							AnimateMouse( pControl, Mitte);
5143 							break;
5144 						case M_GetText :
5145 							pRet->GenReturn ( RET_Value, aUId, ((SpinField*)pControl)->GetText());
5146 							break;
5147 						case M_IsWritable:
5148 							pRet->GenReturn ( RET_Value, aUId, (comm_BOOL) !((SpinField*)pControl)->IsReadOnly() );
5149 							break;
5150 						case M_SetText :
5151 							if ( ! ((SpinField*)pControl)->IsReadOnly() )
5152 							{
5153 								((SpinField*)pControl)->SetText( aString1 );
5154 								((SpinField*)pControl)->SetModifyFlag();
5155 								((SpinField*)pControl)->Modify();
5156 							}
5157 							else
5158 								ReportError( aUId, GEN_RES_STR1c( S_ATTEMPT_TO_WRITE_READONLY, "SpinField" ) );
5159 							break;
5160 						case M_More :
5161 							{
5162 								if ( !(nParams & PARAM_USHORT_1) )
5163 									nNr1 = 1;
5164 								for (int i = 1; i<= nNr1; i++)
5165 								{
5166 									((SpinField*)pControl)->Up();
5167 									((SpinField*)pControl)->SetModifyFlag();
5168 									((SpinField*)pControl)->Modify();
5169 								}
5170 							}
5171 							break;
5172 						case M_Less :
5173 							{
5174 								if ( !(nParams & PARAM_USHORT_1) )
5175 									nNr1 = 1;
5176 								for (int i = 1; i<= nNr1; i++)
5177 								{
5178 									((SpinField*)pControl)->Down();
5179 									((SpinField*)pControl)->SetModifyFlag();
5180 									((SpinField*)pControl)->Modify();
5181 								}
5182 							}
5183 							break;
5184 						case M_ToMin :
5185 							((SpinField*)pControl)->First();
5186 							((SpinField*)pControl)->SetModifyFlag();
5187 							((SpinField*)pControl)->Modify();
5188 							break;
5189 						case M_ToMax :
5190 							((SpinField*)pControl)->Last();
5191 							((SpinField*)pControl)->SetModifyFlag();
5192 							((SpinField*)pControl)->Modify();
5193 							break;
5194 						default:
5195 							ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "SpinField" ) );
5196 							break;
5197 					}
5198 					break;
5199 
5200 				case C_MenuButton:
5201 						switch( nMethodId )
5202 						{
5203 						case M_AnimateMouse :
5204 							AnimateMouse( pControl, Mitte);
5205 							break;
5206 						case M_Click :
5207 							{
5208 								MouseEvent aMEvnt;
5209 								Point aPt( pControl->GetSizePixel().Width() / 2, pControl->GetSizePixel().Height() / 2 );
5210 								aMEvnt = MouseEvent( aPt,1,MOUSE_SIMPLECLICK,MOUSE_LEFT );
5211 								ImplMouseButtonDown( pControl, aMEvnt, FORCE_DIRECT_CALL );
5212 								ImplMouseButtonUp  ( pControl, aMEvnt, FORCE_DIRECT_CALL );
5213 							}
5214 							break;
5215 						case M_Open :
5216 						case M_OpenMenu :
5217 							{
5218 								MouseEvent aMEvnt;
5219 								Point aPt( pControl->GetSizePixel().Width() / 2, pControl->GetSizePixel().Height() / 2 );
5220 								aMEvnt = MouseEvent( aPt,1,MOUSE_SIMPLECLICK,MOUSE_LEFT );
5221 								ImplMouseButtonDown( pControl, aMEvnt, FORCE_DIRECT_CALL );
5222 
5223 								sal_uLong nStart = Time::GetSystemTicks();
5224 								sal_uLong nDelay = pControl->GetSettings().GetMouseSettings().GetActionDelay();
5225 								while ( ( Time::GetSystemTicks() - nStart ) < nDelay + 100 )
5226 									SafeReschedule();
5227 
5228 								ImplMouseButtonUp  ( pControl, aMEvnt, FORCE_DIRECT_CALL );
5229 
5230                                 aSubMenuId1 = 0;
5231 				                aSubMenuId2 = 0;
5232 				                aSubMenuId3 = 0;
5233                                 pMenuWindow = NULL;
5234 							}
5235 							break;
5236 						default:
5237 							ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "MenuButton" ) );
5238 							break;
5239 					}
5240 					break;
5241 				case C_ToolBox:
5242 					{
5243 						ToolBox *pTB = ((ToolBox*)pControl);
5244 						if ( !aUId.equals( pTB->GetUniqueOrHelpId() ) )	// So we found a Button on the ToolBox
5245 						{
5246 							if ( (nParams == PARAM_NONE) || (nParams == PARAM_USHORT_1) )
5247 							{			// Wir f�lschen einen Parameter
5248 							    nParams |= PARAM_STR_1;
5249                                 aString1 = Id2Str( aUId );
5250 							}
5251 							else
5252 								ReportError( aUId, GEN_RES_STR1( S_INTERNAL_ERROR, MethodString( nMethodId ) ) );
5253 						}
5254 
5255 #define FIND_ITEM\
5256     sal_uInt16 nItemPos = 0;\
5257     sal_Bool bItemFound = sal_False;\
5258 	{\
5259 		rtl::OString aButtonId;\
5260 		if( nParams & PARAM_STR_1 )\
5261             aButtonId = Str2Id( aString1 );\
5262 		else\
5263 			ReportError( aUId, GEN_RES_STR1( S_INTERNAL_ERROR, MethodString( nMethodId ) ) );\
5264 		for ( nItemPos = 0; nItemPos < pTB->GetItemCount() && !aButtonId.equals(Str2Id( pTB->GetItemCommand(pTB->GetItemId(nItemPos)) )) &&\
5265 		                                              !aButtonId.equals(pTB->GetHelpId(pTB->GetItemId(nItemPos))) ; nItemPos++ ) {}\
5266 		bItemFound = aButtonId.equals(Str2Id( pTB->GetItemCommand(pTB->GetItemId(nItemPos)) )) || aButtonId.equals(pTB->GetHelpId(pTB->GetItemId(nItemPos)));\
5267 		if ( !bItemFound )\
5268 			ReportError( aUId, GEN_RES_STR1( S_HELPID_ON_TOOLBOX_NOT_FOUND, MethodString( nMethodId ) ) );\
5269 		else\
5270 		{\
5271 			if ( !pTB->IsItemEnabled( pTB->GetItemId(nItemPos) ) && nMethodId != _M_IsEnabled && nMethodId != M_GetState )\
5272 			{\
5273 				ReportError( aUId, GEN_RES_STR1( S_BUTTON_DISABLED_ON_TOOLBOX, MethodString( nMethodId ) ) );\
5274 				bItemFound = sal_False;\
5275 			}\
5276 			else if ( !pTB->IsItemVisible( pTB->GetItemId(nItemPos) ) && nMethodId != M_GetState )\
5277 			{\
5278 				ReportError( aUId, GEN_RES_STR1( S_BUTTON_HIDDEN_ON_TOOLBOX, MethodString( nMethodId ) ) );\
5279 				bItemFound = sal_False;\
5280 			}\
5281 			else\
5282 			{\
5283                 if ( pTB->IsMenuEnabled() )\
5284                 {   /* button is in Menu */\
5285                 }\
5286                 else\
5287                 {   /* Try the multi line way */\
5288 				    if ( pTB->GetItemRect(pTB->GetItemId(nItemPos)).IsEmpty() )\
5289 				    {\
5290 					    sal_uInt16 nLine = pTB->GetCurLine();\
5291 					    do\
5292 					    {\
5293 						    pTB->ShowLine( sal_False );\
5294 						    for ( int i = 1 ; i < 30 ; i++ )\
5295 							    SafeReschedule();\
5296 					    }\
5297 					    while ( pTB->GetCurLine() != nLine && pTB->GetItemRect(pTB->GetItemId(nItemPos)).IsEmpty() );\
5298 					    pTB->Invalidate( pTB->GetScrollRect() );\
5299 				    }\
5300 				    if ( pTB->GetItemRect(pTB->GetItemId(nItemPos)).IsEmpty() )\
5301 				    {\
5302 					    ReportError( aUId, GEN_RES_STR1( S_CANNOT_MAKE_BUTTON_VISIBLE_IN_TOOLBOX, MethodString( nMethodId ) ) );\
5303 					    bItemFound = sal_False;\
5304 				    }\
5305                 }\
5306 			}\
5307 		}\
5308 	}
5309 
5310 						switch( nMethodId )
5311 						{
5312 							case M_AnimateMouse :
5313 								AnimateMouse( pControl, MitteLinks);
5314 								break;
5315 							case M_Click :
5316 								{
5317                                     FIND_ITEM;
5318 									if ( bItemFound )	// FIND_ITEM Erfolgreich
5319 									{
5320 										Rectangle aRect = pTB->GetItemRect(pTB->GetItemId(nItemPos));
5321                                         if ( aRect.IsEmpty() )
5322                                         {
5323                                             pTB->ExecuteCustomMenu();
5324 /*					                        aRect = pTB->GetMenubuttonRect();
5325 					                        MouseEvent aMEvnt(aRect.Center(),1,MOUSE_SIMPLECLICK,MOUSE_LEFT);
5326 					                        ImplMouseButtonDown( pTB, aMEvnt );*/
5327 
5328 				                            aSubMenuId1 = 0;
5329 				                            aSubMenuId2 = 0;
5330 				                            aSubMenuId3 = 0;
5331                                             pMenuWindow = NULL;
5332 
5333                                             new StatementCommand( this, RC_MenuSelect, PARAM_USHORT_1, pTB->GetItemId(nItemPos) + TOOLBOX_MENUITEM_START );
5334                                         }
5335                                         else
5336                                         {
5337 										    aRect = pTB->GetItemRect(pTB->GetItemId(nItemPos));
5338 										    MouseEvent aMEvnt;
5339 										    aMEvnt = MouseEvent(aRect.Center(),1,MOUSE_SIMPLECLICK,MOUSE_LEFT);
5340 										    ImplMouseButtonDown( pTB, aMEvnt, FORCE_DIRECT_CALL );
5341 										    ImplMouseButtonUp  ( pTB, aMEvnt, FORCE_DIRECT_CALL );
5342                                         }
5343 									}
5344 								}
5345 								break;
5346 							case M_TearOff :
5347 								{
5348                                     FIND_ITEM;
5349 									if ( bItemFound )	// FIND_ITEM Erfolgreich
5350 									{
5351 										Rectangle aRect = pTB->GetItemPosDropDownRect( nItemPos );
5352 										AnimateMouse( pControl, aRect.Center() );
5353 										MouseEvent aMEvnt(aRect.Center(),1,MOUSE_SIMPLECLICK,MOUSE_LEFT);
5354 										ImplMouseButtonDown( pTB, aMEvnt, FORCE_DIRECT_CALL );
5355 
5356 										Window *pWin = NULL;
5357 										// Wait for the window to open.
5358 										StatementList::bExecuting = sal_True;		// Bah ist das ein ekliger Hack
5359 										{											// Das verhindert, da� schon der n�chste Befehl ausgef�hrt wird.
5360 											Time aDelay;
5361 											while ( !pWin && ( (pWin = GetPopupFloatingWin()) == NULL ) && ( Time() - aDelay ).GetSec() < 15 )
5362 												SafeReschedule();
5363 										}
5364 										StatementList::bExecuting = sal_False;	// Bah ist das ein ekliger Hack
5365 
5366 										if ( pWin && pWin->GetType() == WINDOW_FLOATINGWINDOW )
5367 										{
5368 											aMEvnt = MouseEvent(aRect.Center(),1,MOUSE_SIMPLECLICK,MOUSE_LEFT);
5369 											ImplMouseButtonUp( pTB, aMEvnt, FORCE_DIRECT_CALL );
5370 											((FloatingWindow*)pWin)->EndPopupMode( FLOATWIN_POPUPMODEEND_TEAROFF );
5371 										}
5372 										else
5373 										{
5374 											aMEvnt = MouseEvent(Point(1,-10), 1, MOUSE_SIMPLECLICK,MOUSE_LEFT);
5375 											ImplMouseButtonUp( pTB, aMEvnt, FORCE_DIRECT_CALL );
5376 											ReportError( aUId, GEN_RES_STR1( S_TEAROFF_FAILED, MethodString( nMethodId ) ) );
5377 										}
5378 									}
5379 								}
5380 								break;
5381 							case M_OpenMenu :
5382 								{
5383                                     FIND_ITEM;
5384 									if ( bItemFound )	// FIND_ITEM Erfolgreich
5385 									{
5386 										Rectangle aRect = pTB->GetItemPosDropDownRect( nItemPos );
5387 										AnimateMouse( pControl, aRect.Center() );
5388 										MouseEvent aMEvnt(aRect.Center(),1,MOUSE_SIMPLECLICK,MOUSE_LEFT);
5389 										ImplMouseButtonDown( pTB, aMEvnt);
5390 										ImplMouseButtonUp( pTB, aMEvnt);
5391 
5392                                         // Das Fenster ist offen.
5393 				                        aSubMenuId1 = 0;
5394 				                        aSubMenuId2 = 0;
5395 				                        aSubMenuId3 = 0;
5396                                         pMenuWindow = NULL;
5397 									}
5398 								}
5399 								break;
5400 							case _M_IsEnabled:
5401 								{
5402                                     FIND_ITEM;
5403 									if ( bItemFound )	// FIND_ITEM Erfolgreich
5404 									{
5405 										pRet->GenReturn ( RET_Value, aUId, pTB->IsItemEnabled( pTB->GetItemId(nItemPos) ) );
5406 									}
5407 								}
5408 								break;
5409 							case M_GetState :
5410 								{
5411                                     FIND_ITEM;
5412 									if ( bItemFound )	// FIND_ITEM Erfolgreich
5413 									{
5414                                         if ( ValueOK( aUId, CUniString("GetState"), nNr1, 4 ) )
5415 								            switch (nNr1)
5416 								            {
5417 								            case 0:
5418                                                 pRet->GenReturn ( RET_Value, aUId, Id2Str( pTB->GetHelpId(pTB->GetItemId(nItemPos)) ) );
5419 									            break;
5420 								            case 1:
5421 									            pRet->GenReturn ( RET_Value, aUId, (comm_ULONG)pTB->GetItemType(nItemPos));
5422 									            break;
5423 								            case 2:
5424 									            pRet->GenReturn ( RET_Value, aUId, (comm_ULONG)pTB->GetItemState(pTB->GetItemId(nItemPos)));
5425 									            break;
5426 								            case 3:
5427 									            pRet->GenReturn ( RET_Value, aUId, (comm_ULONG)pTB->GetItemId(nItemPos));
5428 									            break;
5429 								            default:
5430 									            ReportError( aUId, GEN_RES_STR1( S_INTERNAL_ERROR, MethodString( nMethodId ) ) );
5431                                                 pRet->GenReturn ( RET_Value, aUId, comm_ULONG(0));
5432 									            break;
5433 								            }
5434 									}
5435 								}
5436 								break;
5437 							case M_GetItemText :
5438 								pRet->GenReturn ( RET_Value, aUId, (String)pTB->GetItemText(nNr1));
5439 								break;
5440 							case M_GetText :
5441 								pRet->GenReturn ( RET_Value, aUId, (String)pTB->GetText());
5442 								break;
5443 							case M_GetItemCount :
5444 								pRet->GenReturn ( RET_Value, aUId, (comm_ULONG)pTB->GetItemCount());
5445 								break;
5446 							case M_SetNextToolBox :
5447 								if ( (nParams & PARAM_STR_1) )
5448 									pTB->SetNextToolBox( aString1 );
5449 								else
5450 									pTB->SetNextToolBox( pTB->GetNextToolBox() );
5451 								pTB->NextToolBox();
5452 								break;
5453 							case M_GetNextToolBox :
5454 								pRet->GenReturn ( RET_Value, aUId, (String)pTB->GetNextToolBox());
5455 								break;
5456 						    case M_Dock :
5457 						    case M_Undock :
5458 						    case M_IsDocked :
5459 						    case M_Close:
5460 						    case M_Size:
5461 						    case M_Move:
5462 						    case M_IsMax:
5463 						    case M_Minimize:
5464 						    case M_Maximize:
5465 						    case M_Help:		// Alles was unten weiterbehandelt werden soll
5466                                 goto DockingWin;
5467 							default:
5468 								ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "ToolBox" ) );
5469 								break;
5470 						}
5471 					}
5472 					break;
5473 
5474 				case C_TreeListBox:
5475 					switch( nMethodId )
5476 					{
5477 
5478 
5479 
5480 #define GET_NTH_ENTRY_LBOX( First, Next, Anzahl)	\
5481 	SvLBoxEntry *pThisEntry = ((SvTreeListBox*)pControl)->First(); \
5482 	{ \
5483 		int niTemp = Anzahl; \
5484 		while ( niTemp-- ) \
5485 		{ \
5486 			pThisEntry = ((SvTreeListBox*)pControl)->Next( pThisEntry ); \
5487 		} \
5488 	}
5489 
5490 						case M_GetText :               // Get the first text of the given (default=1) line
5491 							{                          // should get removed some time
5492 								SvTreeListBox *pTree = (SvTreeListBox*)pControl;
5493 								SvLBoxEntry *pThisEntry = pTree->GetCurEntry();
5494 								if ( ! (nParams & PARAM_USHORT_1) )
5495 									nNr1 = 1;
5496 								if ( pThisEntry )
5497                                 {
5498                                     SvLBoxString* pItem = NULL;
5499                                     sal_uInt16 nValidTextItemCount = 0;
5500                                     {
5501                                         sal_uInt16 nIndex = 0;
5502                                         SvLBoxItem *pMyItem;
5503                                         while ( ( nValidTextItemCount < nNr1 ) && nIndex < pThisEntry->ItemCount() )
5504                                         {
5505                                             pMyItem = pThisEntry->GetItem( nIndex );
5506                                             if ( pMyItem->IsA() == SV_ITEM_ID_LBOXSTRING )
5507                                             {
5508                                                 pItem = (SvLBoxString*)pMyItem;
5509                                                 nValidTextItemCount++;
5510                                             }
5511                                             nIndex++;
5512                                         }
5513                                     }
5514 									if ( ValueOK( aUId, CUniString("GetText"), nNr1, nValidTextItemCount ) )
5515                                         pRet->GenReturn ( RET_Value, aUId, pItem->GetText() );
5516                                 }
5517 								else
5518 									ReportError( aUId, GEN_RES_STR2c2( S_NO_SELECTED_ENTRY, MethodString( nMethodId ), "TreeListBox" ) );
5519 							}
5520 							break;
5521 						case M_GetSelCount :
5522 							pRet->GenReturn ( RET_Value, aUId, comm_ULONG(((SvLBox*)pControl)->GetSelectionCount()));
5523 							break;
5524 						case M_GetItemCount :
5525 							pRet->GenReturn ( RET_Value, aUId, comm_ULONG(((SvLBox*)pControl)->GetVisibleCount()) );
5526 							break;
5527 						case M_GetSelIndex :
5528 							if ( ! (nParams & PARAM_USHORT_1) )
5529 								nNr1 = 1;
5530 							if ( ValueOK(aUId, CUniString("GetSelIndex"),nNr1,((SvLBox*)pControl)->GetSelectionCount()) )
5531 							{
5532 								nNr1--;
5533 								GET_NTH_ENTRY_LBOX( FirstSelected, NextSelected, nNr1);
5534 								pRet->GenReturn ( RET_Value, aUId, comm_ULONG( ((SvTreeListBox*)pControl)->GetVisiblePos( pThisEntry )) +1 );
5535 							}
5536 							break;
5537 						case M_Select :
5538 							if ( ! (nParams & PARAM_BOOL_1) )
5539 								bBool1 = sal_True;
5540 							if( nParams & PARAM_STR_1 )
5541 							{
5542 /*									ListBox *pLB = ((ListBox*)pControl);
5543 								if ( pLB->GetEntryPos( aString1 ) == LISTBOX_ENTRY_NOTFOUND )
5544 									ReportError( aUId, GEN_RES_STR2( S_ENTRY_NOT_FOUND, MethodString( nMethodId ), aString1 ) );
5545 								else
5546 								{
5547 									pLB->SelectEntry( aString1, bBool1 );
5548 									if ( pLB->IsEntrySelected( aString1 ) ? !bBool1 : bBool1 )	// XOR rein mit BOOL
5549 										ReportError( aUId, GEN_RES_STR2( S_METHOD_FAILED, MethodString( nMethodId ), aString1 ) );
5550 								}
5551 */									ReportError( aUId, GEN_RES_STR1( S_SELECT_DESELECT_VIA_STRING_NOT_IMPLEMENTED, MethodString( nMethodId ) ) );
5552 							}
5553 							else
5554 							{
5555 								if ( ValueOK(aUId, MethodString( nMethodId ),nNr1,((SvLBox*)pControl)->GetVisibleCount()) )
5556 								{
5557 									SvLBoxEntry *pEntry = (SvLBoxEntry*)((SvTreeListBox*)pControl)->GetEntryAtVisPos( nNr1-1 );
5558 									((SvTreeListBox*)pControl)->Select ( pEntry, bBool1 );
5559 								}
5560 							}
5561 							break;
5562 						case M_GetSelText :
5563 							if ( ! (nParams & PARAM_USHORT_1) )
5564 								nNr1 = 1;
5565 							if ( ! (nParams & PARAM_USHORT_2) )
5566 								nNr2 = 1;
5567 							if ( ValueOK(aUId, CUniString("GetSelText"),nNr1,((SvLBox*)pControl)->GetSelectionCount()) )
5568 							{
5569 								nNr1--;
5570 								GET_NTH_ENTRY_LBOX( FirstSelected, NextSelected, nNr1);
5571                                 if ( ValueOK( aUId, MethodString( nMethodId ),nNr2,pThisEntry->ItemCount() ) )
5572                                 {
5573                                     SvLBoxString* pItem = NULL;
5574 							        if ( ! (nParams & PARAM_USHORT_2) )
5575 								        pItem = (SvLBoxString*)pThisEntry->GetFirstItem( SV_ITEM_ID_LBOXSTRING );
5576                                     else
5577                                     {
5578                                         SvLBoxItem *pMyItem = pThisEntry->GetItem( nNr2-1 );
5579                                         if ( pMyItem->IsA() == SV_ITEM_ID_LBOXSTRING )
5580                                             pItem = (SvLBoxString*)pMyItem;
5581                                     }
5582 
5583                                     if ( pItem )
5584                                         pRet->GenReturn ( RET_Value, aUId, pItem->GetText() );
5585                                     else
5586                                         ReportError( aUId, GEN_RES_STR1( S_NO_LIST_BOX_STRING, MethodString( nMethodId ) ) );
5587                                 }
5588 							}
5589 							break;
5590 						case M_GetItemText :
5591 							if ( ValueOK(aUId, MethodString( nMethodId ),nNr1,((SvLBox*)pControl)->GetVisibleCount()) )
5592 							{
5593 								SvLBoxEntry *pThisEntry = (SvLBoxEntry*)((SvTreeListBox*)pControl)->GetEntryAtVisPos( nNr1-1 );
5594 								if ( ! (nParams & PARAM_USHORT_2) )
5595 									nNr2 = 1;
5596                                 if ( ValueOK( aUId, MethodString( nMethodId ),nNr2,pThisEntry->ItemCount() ) )
5597                                 {
5598                                     SvLBoxString* pItem = NULL;
5599 							        if ( ! (nParams & PARAM_USHORT_2) )
5600 								        pItem = (SvLBoxString*)pThisEntry->GetFirstItem( SV_ITEM_ID_LBOXSTRING );
5601                                     else
5602                                     {
5603                                         SvLBoxItem *pMyItem = pThisEntry->GetItem( nNr2-1 );
5604                                         if ( pMyItem->IsA() == SV_ITEM_ID_LBOXSTRING )
5605                                             pItem = (SvLBoxString*)pMyItem;
5606                                     }
5607 
5608         						    if ( pItem )
5609                                         pRet->GenReturn ( RET_Value, aUId, pItem->GetText() );
5610                                     else
5611                                         ReportError( aUId, GEN_RES_STR1( S_NO_LIST_BOX_STRING, MethodString( nMethodId ) ) );
5612                                 }
5613 							}
5614 							break;
5615 						case M_IsChecked :
5616 						case M_IsTristate :
5617 						case M_GetState :
5618 						case M_Check :
5619 						case M_UnCheck :
5620 						case M_TriState :
5621 							{
5622 								SvTreeListBox *pTree = (SvTreeListBox*)pControl;
5623                                 SvLBoxEntry *pThisEntry = NULL;
5624 
5625 							    if ( ! (nParams & PARAM_USHORT_1) )
5626                                 {
5627                                     pThisEntry = pTree->GetCurEntry();
5628                                     if ( !pThisEntry )
5629 									    ReportError( aUId, GEN_RES_STR2c2( S_NO_SELECTED_ENTRY, MethodString( nMethodId ), "TreeListBox" ) );
5630                                 }
5631                                 else
5632                                 {
5633 							        if ( ValueOK(aUId, MethodString( nMethodId ),nNr1,((SvLBox*)pControl)->GetVisibleCount()) )
5634 							        {
5635                                         pThisEntry = (SvLBoxEntry*)pTree->GetEntryAtVisPos( nNr1-1 );
5636                                     }
5637                                 }
5638 
5639 							    if ( ! (nParams & PARAM_USHORT_2) )
5640 									nNr2 = 1;
5641 
5642 							    if ( pThisEntry )
5643 							    {
5644                                     if ( ValueOK( aUId, MethodString( nMethodId ),nNr2,pThisEntry->ItemCount() ) )
5645                                     {
5646                                         SvLBoxButton* pItem = NULL;
5647 							            if ( ! (nParams & PARAM_USHORT_2) )
5648 								            pItem = (SvLBoxButton*)pThisEntry->GetFirstItem( SV_ITEM_ID_LBOXBUTTON );
5649                                         else
5650                                         {
5651                                             SvLBoxItem *pMyItem = pThisEntry->GetItem( nNr2-1 );
5652                                             if ( pMyItem->IsA() == SV_ITEM_ID_LBOXBUTTON )
5653                                                 pItem = (SvLBoxButton*)pMyItem;
5654                                         }
5655 
5656                                         if ( pItem )
5657                                         {
5658 										    switch( nMethodId )
5659 										    {
5660 											    case M_IsChecked :
5661 												    pRet->GenReturn ( RET_Value, aUId, comm_BOOL( pItem->IsStateChecked() ) );
5662 												    break;
5663 											    case M_IsTristate :
5664 												    pRet->GenReturn ( RET_Value, aUId, comm_BOOL( pItem->IsStateTristate() ) );
5665 												    break;
5666 											    case M_GetState :
5667 												    pRet->GenReturn ( RET_Value, aUId, comm_ULONG( pItem->GetButtonFlags() & ~SV_STATE_MASK ));
5668 												    break;
5669 											    case M_Check :
5670                                                     if ( !pItem->IsStateChecked() )
5671                                                     {
5672                                                         pItem->SetStateChecked();
5673                                                         pTree->CheckButtonHdl();
5674                                                         pTree->InvalidateEntry( pThisEntry );
5675                                                     }
5676 												    break;
5677 											    case M_UnCheck :
5678                                                     if ( pItem->IsStateChecked() || pItem->IsStateTristate() )
5679                                                     {
5680                                                         pItem->SetStateUnchecked();
5681                                                         pTree->CheckButtonHdl();
5682                                                         pTree->InvalidateEntry( pThisEntry );
5683                                                     }
5684 												    break;
5685 											    case M_TriState :
5686                                                     if ( !pItem->IsStateTristate() )
5687                                                     {
5688                                                         pItem->SetStateTristate();
5689                                                         pTree->CheckButtonHdl();
5690                                                         pTree->InvalidateEntry( pThisEntry );
5691                                                     }
5692 												    break;
5693 											    default:
5694 												    ReportError( aUId, GEN_RES_STR1( S_INTERNAL_ERROR, MethodString( nMethodId ) ) );
5695 												    break;
5696 										    }
5697                                         }
5698 									    else
5699 										    ReportError( aUId, GEN_RES_STR1( S_NO_LIST_BOX_BUTTON, MethodString( nMethodId ) ) );
5700                                     }
5701                                 }
5702 							}
5703 							break;
5704 						case M_GetItemType :
5705                             {
5706 								SvTreeListBox *pTree = (SvTreeListBox*)pControl;
5707                                 SvLBoxEntry *pThisEntry = NULL;
5708 
5709 							    if ( ! (nParams & PARAM_USHORT_1) )
5710                                 {
5711                                     pThisEntry = pTree->GetCurEntry();
5712                                     if ( !pThisEntry )
5713 									    ReportError( aUId, GEN_RES_STR2c2( S_NO_SELECTED_ENTRY, MethodString( nMethodId ), "TreeListBox" ) );
5714                                 }
5715                                 else
5716                                 {
5717 							        if ( ValueOK(aUId, MethodString( nMethodId ),nNr1,((SvLBox*)pControl)->GetVisibleCount()) )
5718 							        {
5719                                         pThisEntry = (SvLBoxEntry*)pTree->GetEntryAtVisPos( nNr1-1 );
5720                                     }
5721                                 }
5722 
5723 							    if ( pThisEntry )
5724 							    {
5725 								    if ( ! (nParams & PARAM_USHORT_2) )
5726 									    nNr2 = 1;
5727                                     if ( ValueOK( aUId, MethodString( nMethodId ),nNr2,pThisEntry->ItemCount() ) )
5728                                     {
5729                                         SvLBoxItem *pMyItem = pThisEntry->GetItem( nNr2-1 );
5730                                         comm_USHORT nType;
5731                                         switch ( pMyItem->IsA() )
5732                                         {
5733                                             case SV_ITEM_ID_LBOXSTRING: nType = CONST_ItemTypeText ; break;
5734                                             case SV_ITEM_ID_LBOXBMP: nType = CONST_ItemTypeBMP ; break;
5735                                             case SV_ITEM_ID_LBOXBUTTON: nType = CONST_ItemTypeCheckbox ; break;
5736                                             case SV_ITEM_ID_LBOXCONTEXTBMP: nType = CONST_ItemTypeContextBMP ; break;
5737                                             default: nType = CONST_ItemTypeUnknown;
5738                                         }
5739                                         pRet->GenReturn ( RET_Value, aUId, nType );
5740                                     }
5741 							    }
5742                             }
5743 							break;
5744 						default:
5745 							ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "TreeListBox" ) );
5746 							break;
5747 					}
5748 					break;
5749 			    case C_Control:
5750                 {
5751                     sal_uInt16 nRealControlType = 0;
5752                     if ( dynamic_cast< EditBrowseBox* >(pControl) )
5753                         nRealControlType = CONST_CTBrowseBox;
5754                     else if ( dynamic_cast< ValueSet* >(pControl) )
5755                         nRealControlType = CONST_CTValueSet;
5756                     else if ( dynamic_cast< ORoadmap* >(pControl) )
5757                         nRealControlType = CONST_CTORoadmap;
5758                     else if ( dynamic_cast< IExtensionListBox* >(pControl) )
5759                         nRealControlType = CONST_CTIExtensionListBox;
5760                     else if ( dynamic_cast< ::svt::table::TableControl* >(pControl) )
5761                         nRealControlType = CONST_CTTableControl;
5762                     else
5763                         nRealControlType = CONST_CTUnknown;
5764 
5765 					switch( nMethodId )
5766 					{
5767 						case M_AnimateMouse :
5768 							AnimateMouse( pControl, MitteOben);
5769 							break;
5770 						default:
5771 							switch( nRealControlType )
5772 							{
5773 								case CONST_CTBrowseBox:
5774                                     {
5775                                         EditBrowseBox* pEBBox = dynamic_cast< EditBrowseBox* >(pControl);
5776                                         switch( nMethodId )
5777 									    {
5778 
5779 
5780     /*
5781 
5782 
5783     sal_Bool			MakeFieldVisible( long nRow, sal_uInt16 nColId, sal_Bool bComplete = sal_False );
5784     // access to dynamic values of cursor row
5785     String          GetColumnTitle( sal_uInt16 nColumnId ) const;
5786     sal_uInt16          GetColumnId( sal_uInt16 nPos ) const;
5787     sal_uInt16          GetColumnPos( sal_uInt16 nColumnId ) const;
5788     // access and movement of cursor
5789     long            GetCurRow() const { return nCurRow; }
5790     sal_uInt16          GetCurColumnId() const { return nCurColId; }
5791     sal_Bool            GoToRow( long nRow );
5792     sal_Bool			GoToRowAndDoNotModifySelection( long nRow );
5793     sal_Bool            GoToColumnId( sal_uInt16 nColId );
5794     sal_Bool            GoToRowColumnId( long nRow, sal_uInt16 nColId );
5795     // selections
5796     void            SetNoSelection();
5797     void            SelectAll();
5798     void            SelectRow( long nRow, sal_Bool bSelect = sal_True, sal_Bool bExpand = sal_True );
5799     void            SelectColumnPos( sal_uInt16 nCol, sal_Bool bSelect = sal_True )
5800 					    { SelectColumnPos( nCol, bSelect, sal_True); }
5801     void            SelectColumnId( sal_uInt16 nColId, sal_Bool bSelect = sal_True )
5802 					    { SelectColumnPos( GetColumnPos(nColId), bSelect, sal_True); }
5803     long            GetSelectRowCount() const;
5804     sal_uInt16          GetSelectColumnCount() const;
5805     sal_Bool            IsRowSelected( long nRow ) const;
5806     sal_Bool            IsColumnSelected( sal_uInt16 nColumnId ) const;
5807     long            FirstSelectedRow( sal_Bool bInverse = sal_False );
5808     long            LastSelectedRow( sal_Bool bInverse = sal_False );
5809     long            PrevSelectedRow();
5810     long            NextSelectedRow();
5811     const MultiSelection* GetSelection() const
5812 				    { return bMultiSelection ? uRow.pSel : 0; }
5813     void			SetSelection( const MultiSelection &rSelection );
5814 
5815     virtual String  GetCellText(long _nRow, sal_uInt16 _nColId) const;
5816     sal_uInt16 GetColumnCount() const { return ColCount(); }
5817 protected:
5818     virtual long    GetRowCount() const;
5819 
5820 
5821     EditBrowseBox
5822 
5823 		    sal_Bool IsEditing() const {return aController.Is();}
5824 		    void InvalidateStatusCell(long nRow) {RowModified(nRow, 0);}
5825 		    void InvalidateHandleColumn();
5826 
5827 		    CellControllerRef Controller() const { return aController; }
5828 		    sal_Int32	GetBrowserFlags() const { return m_nBrowserFlags; }
5829 
5830 		    virtual void ActivateCell(long nRow, sal_uInt16	nCol, sal_Bool bSetCellFocus = sal_True);
5831 		    virtual void DeactivateCell(sal_Bool bUpdate = sal_True);
5832 
5833 
5834 
5835     */
5836 										    case M_GetSelText :
5837 											    {
5838                                                     pRet->GenReturn ( RET_Value, aUId, pEBBox->GetCellText( pEBBox->GetCurrRow(), pEBBox->GetColumnId( pEBBox->GetCurrColumn() )));
5839 											    }
5840 											    break;
5841 										    case M_GetColumnCount :
5842 											    {
5843                                                     sal_uInt16 nColCount = pEBBox->GetColumnCount();
5844                                                     comm_USHORT nUnfrozenColCount = 0;
5845                                                     sal_uInt16 i;
5846                                                     for ( i=0 ; i < nColCount ; i++ )
5847                                                     {
5848                                                         if ( !pEBBox->IsFrozen( pEBBox->GetColumnId( i ) ) )
5849                                                             nUnfrozenColCount++;
5850                                                     }
5851                                                     pRet->GenReturn ( RET_Value, aUId, nUnfrozenColCount );
5852 											    }
5853 											    break;
5854 										    case M_GetRowCount :
5855 											    {
5856                                                     pRet->GenReturn ( RET_Value, aUId, (comm_ULONG)pEBBox->GetRowCount() );
5857 											    }
5858 											    break;
5859 										    case M_IsEditing :
5860 											    {
5861                                                     CellControllerRef aControler;
5862                                                     aControler = pEBBox->Controller();
5863     											    pRet->GenReturn ( RET_Value, aUId, (comm_BOOL)aControler.Is() );
5864 											    }
5865 											    break;
5866 										    case M_Select :
5867 											    {
5868                                                     if ( ValueOK(aUId, MethodString( nMethodId ),nNr1,pEBBox->GetRowCount() ) )
5869                                                     {
5870                                                         sal_uInt16 nColCount = pEBBox->GetColumnCount();
5871                                                         comm_USHORT nUnfrozenColCount = 0;
5872                                                         sal_uInt16 i;
5873                                                         for ( i=0 ; i < nColCount ; i++ )
5874                                                         {
5875                                                             if ( !pEBBox->IsFrozen( pEBBox->GetColumnId( i ) ) )
5876                                                                 nUnfrozenColCount++;
5877                                                         }
5878                                                         if ( ValueOK(aUId, MethodString( nMethodId ),nNr2,nUnfrozenColCount ) )
5879                                                             pEBBox->GoToRowColumnId( nNr1-1, pEBBox->GetColumnId( nNr2 ) );
5880                                                     }
5881 											    }
5882 											    break;
5883 
5884 
5885 
5886                                                 /*
5887 										    case M_GetSelCount :
5888 											    pRet->GenReturn ( RET_Value, aUId, comm_ULONG(((SvLBox*)pControl)->GetSelectionCount()));
5889 											    break;
5890 										    case M_GetSelIndex :
5891 											    if ( ! (nParams & PARAM_USHORT_1) )
5892 												    nNr1 = 1;
5893 											    if ( ValueOK(aUId, CUniString("GetSelIndex"),nNr1,((SvLBox*)pControl)->GetSelectionCount()) )
5894 											    {
5895 												    nNr1--;
5896 												    COUNT_LBOX( FirstSelected, NextSelected, nNr1);
5897 												    pRet->GenReturn ( RET_Value, aUId, comm_ULONG( ((SvTreeListBox*)pControl)->GetVisiblePos( pThisEntry )) +1 );
5898 											    }
5899 											    break;
5900 										    case M_GetSelText :
5901 											    if ( ! (nParams & PARAM_USHORT_1) )
5902 												    nNr1 = 1;
5903 											    if ( ValueOK(aUId, CUniString("GetSelText"),nNr1,((SvLBox*)pControl)->GetSelectionCount()) )
5904 											    {
5905 												    nNr1--;
5906 												    COUNT_LBOX( FirstSelected, NextSelected, nNr1);
5907                                                     GetFirstValidTextItem( pThisEntry );
5908                                                     pRet->GenReturn ( RET_Value, aUId, pItem->GetText() );
5909 											    }
5910 											    break;
5911 										    case M_GetItemCount :
5912 											    pRet->GenReturn ( RET_Value, aUId, comm_ULONG(((SvLBox*)pControl)->GetVisibleCount()) );
5913 											    break;
5914 										    case M_GetItemText :
5915 											    if ( ValueOK(aUId, MethodString( nMethodId ),nNr1,((SvLBox*)pControl)->GetVisibleCount()) )
5916 											    {
5917 												    SvLBoxEntry *pEntry = (SvLBoxEntry*)((SvTreeListBox*)pControl)->GetEntryAtVisPos( nNr1-1 );
5918                                                     GetFirstValidTextItem( pEntry );
5919     											    pRet->GenReturn ( RET_Value, aUId, pItem->GetText() );
5920 											    }
5921 											    break;
5922 										    case M_Select :
5923 											    if ( ! (nParams & PARAM_BOOL_1) )
5924 												    bBool1 = sal_True;
5925 											    if( nParams & PARAM_STR_1 )
5926 											    {
5927 			    / *									ListBox *pLB = ((ListBox*)pControl);
5928 												    if ( pLB->GetEntryPos( aString1 ) == LISTBOX_ENTRY_NOTFOUND )
5929 													    ReportError( aUId, GEN_RES_STR2( S_ENTRY_NOT_FOUND, MethodString( nMethodId ), aString1 ) );
5930 												    else
5931 												    {
5932 													    pLB->SelectEntry( aString1, bBool1 );
5933 													    if ( pLB->IsEntrySelected( aString1 ) ? !bBool1 : bBool1 )	// XOR rein mit BOOL
5934 														    ReportError( aUId, GEN_RES_STR2( S_METHOD_FAILED, MethodString( nMethodId ), aString1 ) );
5935 												    }
5936 			    * /									ReportError( aUId, GEN_RES_STR1( S_SELECT_DESELECT_VIA_STRING_NOT_IMPLEMENTED, MethodString( nMethodId ) ) );
5937 											    }
5938 											    else
5939 											    {
5940 												    if ( ValueOK(aUId, MethodString( nMethodId ),nNr1,((SvLBox*)pControl)->GetVisibleCount()) )
5941 												    {
5942 													    SvLBoxEntry *pEntry = (SvLBoxEntry*)((SvTreeListBox*)pControl)->GetEntryAtVisPos( nNr1-1 );
5943 													    ((SvTreeListBox*)pControl)->Select ( pEntry, bBool1 );
5944 												    }
5945 											    }
5946 											    break;*/
5947 										    default:
5948 											    ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "EditBrowseBox" ) );
5949 											    break;
5950 									    }
5951                                     }
5952 									break;
5953 								case CONST_CTValueSet:
5954                                     {
5955                                         ValueSet *pVS = dynamic_cast< ValueSet* >(pControl);
5956 									    switch ( nMethodId )
5957 									    {
5958                                         case M_GetItemCount:
5959 											pRet->GenReturn ( RET_Value, aUId, comm_ULONG( pVS->GetItemCount()));
5960                                             break;
5961                                         case M_GetItemText:
5962     										if ( ValueOK( aUId, MethodString( nMethodId ), nNr1, pVS->GetItemCount() ))
5963                                              	pRet->GenReturn ( RET_Value, aUId, pVS->GetItemText( pVS->GetItemId( nNr1-1 ) ) );
5964                                             break;
5965                                         case M_Select:
5966     										if ( ValueOK( aUId, MethodString( nMethodId ), nNr1, pVS->GetItemCount() ))
5967                                              	pVS->SelectItem( pVS->GetItemId( nNr1-1 ) );
5968                                             break;
5969 						                case M_GetSelIndex :
5970 								            if ( pVS->IsNoSelection() )
5971 									            pRet->GenReturn ( RET_Value, aUId, comm_ULONG(0));
5972                                             else
5973         							            pRet->GenReturn ( RET_Value, aUId, comm_ULONG( pVS->GetItemPos( pVS->GetSelectItemId() ) +1));
5974 							                break;
5975 						                case M_GetSelText :
5976 								            if ( pVS->IsNoSelection() )
5977 									            pRet->GenReturn ( RET_Value, aUId, String() );
5978                                             else
5979         							            pRet->GenReturn ( RET_Value, aUId, pVS->GetItemText( pVS->GetSelectItemId() ) );
5980 							                break;
5981 						                case M_SetNoSelection :
5982 								            pVS->SetNoSelection();
5983 							                break;
5984                                         default:
5985 											ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "ValueSet" ) );
5986 											break;
5987 									    }
5988                                     }
5989 									break;
5990 								case CONST_CTORoadmap:
5991                                     {
5992                                         ORoadmap *pRM = dynamic_cast< ORoadmap* >(pControl);
5993 									    switch ( nMethodId )
5994 									    {
5995                                         case M_GetItemCount:
5996 											pRet->GenReturn ( RET_Value, aUId, comm_ULONG( pRM->GetItemCount()));
5997                                             break;
5998                                         case M_GetItemText:
5999     										if ( ValueOK( aUId, MethodString( nMethodId ), nNr1, pRM->GetItemCount() ))
6000                                              	pRet->GenReturn ( RET_Value, aUId, pRM->GetRoadmapItemLabel( pRM->GetItemID( nNr1-1 ) ) );
6001                                             break;
6002                                         case M_Select:
6003     										if ( ValueOK( aUId, MethodString( nMethodId ), nNr1, pRM->GetItemCount() ))
6004                                             {
6005                                                 if ( pRM->IsRoadmapItemEnabled( pRM->GetItemID( nNr1-1 ) ) )
6006                                              	    pRM->SelectRoadmapItemByID( pRM->GetItemID( nNr1-1 ) );
6007                                                 else
6008                 									ReportError( aUId, GEN_RES_STR1c( S_WIN_DISABLED, "RoadmapItem" ) );
6009                                             }
6010                                             break;
6011 						                case M_GetSelIndex :
6012         							            pRet->GenReturn ( RET_Value, aUId, comm_ULONG( pRM->GetItemIndex( pRM->GetCurrentRoadmapItemID() ) +1));
6013 							                break;
6014 						                case M_GetSelText :
6015         							            pRet->GenReturn ( RET_Value, aUId, pRM->GetRoadmapItemLabel( pRM->GetCurrentRoadmapItemID() ) );
6016 							                break;
6017 						                case M_IsItemEnabled :
6018     										if ( ValueOK( aUId, MethodString( nMethodId ), nNr1, pRM->GetItemCount() ))
6019         							            pRet->GenReturn ( RET_Value, aUId, (comm_BOOL)pRM->IsRoadmapItemEnabled( pRM->GetItemID( nNr1-1 ) ) );
6020 							                break;
6021                                         default:
6022                                             ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "RoadMap" ) );
6023 											break;
6024 									    }
6025                                     }
6026 									break;
6027 								case CONST_CTIExtensionListBox:
6028                                     {
6029                                         IExtensionListBox *pELB = dynamic_cast< IExtensionListBox* >(pControl);
6030 									    switch ( nMethodId )
6031 									    {
6032                                         case M_GetItemCount:
6033 										    pRet->GenReturn ( RET_Value, aUId, comm_ULONG( pELB->getItemCount()));
6034                                             break;
6035                                         case M_GetItemText:
6036     										if ( ValueOK( aUId, MethodString( nMethodId ), nNr1, pELB->getItemCount() ))
6037                                                 switch ( nNr2 )
6038                                                 {
6039                                                 case 1:
6040                                                     pRet->GenReturn ( RET_Value, aUId, pELB->getItemName( nNr1 -1 ) );
6041                                                     break;
6042                                                 case 2:
6043                                                     pRet->GenReturn ( RET_Value, aUId, pELB->getItemVersion( nNr1 -1 ) );
6044                                                     break;
6045                                                 case 3:
6046                                                     pRet->GenReturn ( RET_Value, aUId, pELB->getItemDescription( nNr1 -1 ) );
6047                                                     break;
6048                                                 case 4:
6049                                                     pRet->GenReturn ( RET_Value, aUId, pELB->getItemPublisher( nNr1 -1 ) );
6050                                                     break;
6051                                                 case 5:
6052                                                     pRet->GenReturn ( RET_Value, aUId, pELB->getItemPublisherLink( nNr1 -1 ) );
6053                                                     break;
6054                                                 default:
6055                                                     ValueOK( aUId, MethodString( nMethodId ).AppendAscii(" String Number"), nNr2, 5 );
6056                                                 }
6057                                             break;
6058                                         case M_Select:
6059                                             if ( (nParams & PARAM_USHORT_1) )
6060                                             {
6061     										    if ( ValueOK( aUId, MethodString( nMethodId ), nNr1, pELB->getItemCount() ))
6062                                                 {
6063                                                     pELB->select( nNr1-1 );
6064                                                 }
6065                                             }
6066                                             else if ( (nParams & PARAM_STR_1) )
6067                                             {
6068                                                 pELB->select( aString1 );
6069                                                 sal_Bool bSuccess = sal_True;
6070                                                 if ( pELB->getSelIndex() == EXTENSION_LISTBOX_ENTRY_NOTFOUND )
6071                                                     bSuccess = sal_False;
6072                                                 else
6073                                                 {
6074                                                     if ( !aString1.Equals( String( pELB->getItemName( pELB->getSelIndex() ) ) ) )
6075                                                         bSuccess = sal_False;
6076                                                 }
6077                                                 if ( !bSuccess )
6078                                                     ReportError( aUId, GEN_RES_STR2( S_ENTRY_NOT_FOUND, MethodString( nMethodId ), aString1 ) );
6079                                             }
6080                                             break;
6081 						                case M_GetSelCount :
6082                                             if ( pELB->getSelIndex() == EXTENSION_LISTBOX_ENTRY_NOTFOUND )
6083                                                 pRet->GenReturn ( RET_Value, aUId, comm_ULONG( 0 ));
6084                                             else
6085                                                 pRet->GenReturn ( RET_Value, aUId, comm_ULONG( 1 ));
6086 							                break;
6087 						                case M_GetSelIndex :
6088                                             if ( pELB->getSelIndex() == EXTENSION_LISTBOX_ENTRY_NOTFOUND )
6089                                                 pRet->GenReturn ( RET_Value, aUId, comm_ULONG( 0 ));
6090                                             else
6091        							                pRet->GenReturn ( RET_Value, aUId, comm_ULONG( pELB->getSelIndex() +1));
6092 							                break;
6093 /*						                xxxcase M_SetNoSelection :
6094 							                ((ListBox*)pControl)->SetNoSelection();
6095 							                ((ListBox*)pControl)->Select();
6096 							                break; */
6097                                         default:
6098                                             ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "RoadMap" ) );
6099 											break;
6100 									    }
6101                                     }
6102 									break;
6103 
6104 								case CONST_CTTableControl:
6105                                     {
6106                                         ::svt::table::TableControl *pTC = dynamic_cast< ::svt::table::TableControl* >(pControl);
6107 									    switch ( nMethodId )
6108 									    {
6109                                            case M_GetItemType :
6110 											    {
6111     										        if ( ValueOK( aUId, MethodString( nMethodId ), nNr1, pTC->GetColumnCount() ) &&
6112                                                          ValueOK( aUId, MethodString( nMethodId ), nNr2, pTC->GetRowCount() ))
6113                                                     {
6114                                                         ::svt::table::PTableModel pModel = pTC->GetModel();
6115                                                         Any aCell;
6116                                                         pModel->getCellContent( nNr1-1, nNr2-1, aCell );
6117                                                         pRet->GenReturn ( RET_Value, aUId, String( aCell.getValueTypeName() ));
6118                                                     }
6119 											    }
6120 											    break;
6121                                            case M_GetItemText :
6122 											    {
6123     										        if ( ValueOK( aUId, MethodString( nMethodId ), nNr1, pTC->GetColumnCount() ) &&
6124                                                          ValueOK( aUId, MethodString( nMethodId ), nNr2, pTC->GetRowCount() ))
6125                                                     {
6126                                                         ::svt::table::PTableModel pModel = pTC->GetModel();
6127                                                         Any aCell;
6128                                                         pModel->getCellContent( nNr1-1, nNr2-1, aCell );
6129                                                         /* doesn't work ATM since it gets casted to SbxDATE in VCLTestTool unfortunately
6130 						                                SbxVariableRef xRes = new SbxVariable( SbxVARIANT );
6131 						                                unoToSbxValue( xRes, aCell );
6132                                                         pRet->GenReturn ( RET_Value, aUId, *xRes );*/
6133 
6134 	                                                    Type aType = aCell.getValueType();
6135 	                                                    TypeClass eTypeClass = aType.getTypeClass();
6136 	                                                    switch( eTypeClass )
6137 	                                                    {
6138                                                             /*case TypeClass_ENUM:
6139                                                                 {
6140                                                                     sal_Int32 nEnum = 0;
6141                                                                     enum2int( nEnum, aValue );
6142                                                                     pRet->GenReturn ( RET_Value, aUId, (comm_ULONG)nEnum );
6143                                                                 }
6144                                                                 break;*/
6145                                                             case TypeClass_BOOLEAN:
6146                                                                 pRet->GenReturn ( RET_Value, aUId, *(sal_Bool*)aCell.getValue() );
6147                                                                 break;
6148                                                             case TypeClass_CHAR:
6149                                                                 {
6150                                                                     ::rtl::OUString aContent( *(sal_Unicode*)aCell.getValue() );
6151                                                                     pRet->GenReturn ( RET_Value, aUId, aContent );
6152                                                                 }
6153                                                                 break;
6154                                                             case TypeClass_STRING:
6155                                                                 {
6156                                                                     ::rtl::OUString aContent;
6157                                                                     aCell >>= aContent;
6158                                                                     pRet->GenReturn ( RET_Value, aUId, aContent );
6159                                                                 }
6160                                                                 break;
6161                                                             //case TypeClass_FLOAT:			break;
6162                                                             //case TypeClass_DOUBLE:		break;
6163                                                             //case TypeClass_OCTET:			break;
6164                                                             case TypeClass_BYTE:
6165                                                             case TypeClass_SHORT:
6166                                                             case TypeClass_LONG:
6167                                                             case TypeClass_HYPER:
6168                                                             case TypeClass_UNSIGNED_LONG:
6169                                                             case TypeClass_UNSIGNED_HYPER:
6170                                                                 {
6171                                                                     comm_ULONG val = 0;
6172                                                                     aCell >>= val;
6173                                                                     pRet->GenReturn ( RET_Value, aUId, val );
6174                                                                 }
6175                                                                 break;
6176                                                             //case TypeClass_UNSIGNED_OCTET:break;
6177                                                             case TypeClass_UNSIGNED_SHORT:
6178                                                                 {
6179                                                                     comm_USHORT val = 0;
6180                                                                     aCell >>= val;
6181                                                                     pRet->GenReturn ( RET_Value, aUId, val );
6182                                                                 }
6183                                                                 break;
6184                                                             default:
6185                                                                 pRet->GenReturn ( RET_Value, aUId, comm_USHORT(0) );
6186                                                                 break;
6187                                                         }
6188                                                     }
6189 											    }
6190 											    break;
6191 										    case M_GetColumnCount :
6192 											    {
6193                                                     pRet->GenReturn ( RET_Value, aUId, (comm_ULONG)pTC->GetColumnCount() );
6194 											    }
6195 											    break;
6196 										    case M_GetRowCount :
6197 											    {
6198                                                     pRet->GenReturn ( RET_Value, aUId, (comm_ULONG)pTC->GetRowCount() );
6199 											    }
6200 											    break;
6201 										    case M_Select :
6202 											    {
6203     										        if ( ValueOK( aUId, MethodString( nMethodId ), nNr1, pTC->GetRowCount() ))
6204                                                     {
6205                                                         if ( pTC->GoToRow( ::svt::table::RowPos( nNr1-1 ) ) )
6206                                                         {
6207                                                             Size aSize( pTC->GetSizePixel() );
6208 //                                                            DirectLog( S_QAError, UniString::CreateFromInt32( aSize.Width() ).Append( UniString::CreateFromInt32( aSize.Height() ) ) );
6209                                                             Point aPos( aSize.Width() / 2, aSize.Height() / 2 );
6210                                                             long nStep = aSize.Height() / 4;
6211                                                             ::svt::table::RowPos nLastPos;
6212                                                             while ( ( nLastPos = pTC->getTableControlInterface().hitTest( aPos ).nRow ) != nNr1-1 && nStep > 0 )
6213                                                             {
6214                                                                 if ( nLastPos > nNr1-1 || nLastPos == ROW_INVALID )
6215                                                                     aPos.Y() -= nStep;
6216                                                                 else
6217                                                                     aPos.Y() += nStep;
6218                                                                 nStep /= 2;
6219                                                             }
6220                                                             if ( pTC->getTableControlInterface().hitTest( aPos ).nRow == nNr1-1 )
6221                                                             {
6222                                                                 MouseEvent aMEvnt(aPos,1,MOUSE_SIMPLECLICK|MOUSE_SELECT,MOUSE_LEFT,KEY_MOD1);
6223                                                                 pTC->getSelEngine()->SelMouseButtonDown( aMEvnt );
6224                                                                 pTC->getSelEngine()->SelMouseButtonUp( aMEvnt );
6225                                                                 if ( pTC->IsRowSelected( nNr1-1 ) )
6226                                                                     pTC->Select();
6227                                                             }
6228                                                             else
6229                                                                 ReportError( aUId, GEN_RES_STR2c2( S_METHOD_FAILED, MethodString( nMethodId ), "find pos" ) );
6230                                                         }
6231                                                         else
6232                                                             ReportError( aUId, GEN_RES_STR2c2( S_METHOD_FAILED, MethodString( nMethodId ), "GoTo" ) );
6233                                                     }
6234 											    }
6235 											    break;
6236 										    case M_GetSelCount :
6237 											    pRet->GenReturn ( RET_Value, aUId, comm_USHORT( pTC->GetSelectedRowCount() ));
6238 											    break;
6239 										    case M_GetSelIndex :
6240 											    if ( ! (nParams & PARAM_USHORT_1) )
6241 												    nNr1 = 1;
6242 											    if ( ValueOK( aUId, CUniString("GetSelIndex"), nNr1, pTC->GetSelectedRowCount() ) )
6243 												    pRet->GenReturn ( RET_Value, aUId, comm_USHORT( pTC->GetSelectedRowIndex( nNr1-1 ) +1 ) );
6244 											    break;
6245 /*										    case M_GetSelText :
6246 											    if ( ! (nParams & PARAM_USHORT_1) )
6247 												    nNr1 = 1;
6248 											    if ( ValueOK(aUId, CUniString("GetSelText"),nNr1,((SvLBox*)pControl)->GetSelectionCount()) )
6249 											    {
6250 												    nNr1--;
6251 												    COUNT_LBOX( FirstSelected, NextSelected, nNr1);
6252                                                     GetFirstValidTextItem( pThisEntry );
6253                                                     pRet->GenReturn ( RET_Value, aUId, pItem->GetText() );
6254 											    }
6255 											    break;
6256                                                 */
6257                                         default:
6258                                             ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "TableControl" ) );
6259 											break;
6260 									    }
6261                                     }
6262 									break;
6263 
6264 								case CONST_CTUnknown:
6265                 					ReportError( aUId, GEN_RES_STR2( S_UNKNOWN_TYPE, UniString::CreateFromInt32( nRT ), MethodString(nMethodId) ) );
6266 									break;
6267 								default:
6268 									ReportError( aUId, GEN_RES_STR1( S_INTERNAL_ERROR, MethodString( nMethodId ) ) );
6269 									break;
6270 							}
6271 					}
6272 					break;
6273                 }
6274 				case C_Window:
6275 					switch( nMethodId )
6276 					{
6277 						case M_AnimateMouse :
6278 							AnimateMouse( pControl, MitteOben);
6279 							break;
6280 						default:
6281 							ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "Window" ) );
6282 							break;
6283 					}
6284 					break;
6285 
6286 				case C_DockingWin:
6287                     DockingWin:
6288 					switch( nMethodId )
6289 					{
6290 						case M_AnimateMouse :
6291 							AnimateMouse( pControl, MitteOben);
6292 							break;
6293 						case M_Dock :
6294 							if ( ((DockingWindow*)pControl)->IsFloatingMode() )
6295 								((DockingWindow*)pControl)->SetFloatingMode(sal_False);
6296 							else
6297 								ReportError( aUId, GEN_RES_STR1( S_ALLOWED_ONLY_IN_FLOATING_MODE, MethodString( nMethodId ) ) );
6298 							break;
6299 						case M_Undock :
6300 							if ( !((DockingWindow*)pControl)->IsFloatingMode() )
6301 								((DockingWindow*)pControl)->SetFloatingMode(sal_True);
6302 							else
6303 								ReportError( aUId, GEN_RES_STR1( S_ALLOWED_ONLY_IN_FLOATING_MODE, MethodString( nMethodId ) ) );
6304 							break;
6305 						case M_IsDocked :
6306 							pRet->GenReturn ( RET_Value, aUId, (comm_BOOL) !((DockingWindow*)pControl)->IsFloatingMode());
6307 							break;
6308 						case M_Close:
6309 								//aWindowWaitUId = aUId;
6310 							DBG_ASSERT( aUId.equals( pControl->GetUniqueOrHelpId() ), "aUID != UniqueOrHelpId");
6311 							SET_WINP_CLOSING(pControl);
6312 							((DockingWindow*)pControl)->Close();
6313 							break;
6314 						case M_Size:
6315 						case M_Move:
6316 						case M_IsMax:
6317 						case M_Minimize:
6318 						case M_Maximize:
6319 							if ( ((DockingWindow*)pControl)->IsFloatingMode() )
6320 							{
6321 								Window* pFloat = ((DockingWindow*)pControl)->GetFloatingWindow();
6322                                 if ( !pFloat && ((DockingWindow*)pControl)->IsFloatingMode() )
6323                                 {
6324                                     if ( pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_FLOATINGWINDOW )
6325                                         pFloat = pControl->GET_REAL_PARENT();
6326                                     else
6327                                     {
6328                                         DBG_ERROR("FloatingMode set but Parent is no FloatingWindow");
6329                                     }
6330                                 }
6331                                 if ( pFloat && pFloat->GetType() == WINDOW_FLOATINGWINDOW )
6332                                 {
6333                                     pControl = pFloat;
6334 								    goto FloatWin;
6335                                 }
6336                                 else
6337     								ReportError( aUId, GEN_RES_STR1( S_CANNOT_FIND_FLOATING_WIN, MethodString( nMethodId ) ) );
6338 							}
6339 							else
6340 								ReportError( aUId, GEN_RES_STR1( S_ALLOWED_ONLY_IN_DOCKING_MODE, MethodString( nMethodId ) ) );
6341 							break;
6342 						case M_Help:		// Alles was unten weiterbehandelt werden soll
6343 							goto MoreDialog;
6344 
6345 						default:
6346 							ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "DockingWindow" ) );
6347 							break;
6348 					}
6349 					break;
6350 				case C_FloatWin:
6351 					FloatWin:
6352 					switch( nMethodId )
6353 					{
6354 						case M_AnimateMouse :
6355 							AnimateMouse( pControl, MitteOben);
6356 							break;
6357 						case M_IsMax :
6358 							pRet->GenReturn ( RET_Value, aUId, (comm_BOOL)!((FloatingWindow*)pControl)->IsRollUp());
6359 							break;
6360 						case M_Minimize :
6361 							((FloatingWindow*)pControl)->RollUp();
6362 							break;
6363 						case M_Maximize :
6364 							((FloatingWindow*)pControl)->RollDown();
6365 							break;
6366 						case M_Size:
6367 						{
6368 							if ( pControl->GetStyle() & WB_SIZEABLE )
6369 							{
6370                                 Size aMin = ((FloatingWindow*)pControl)->GetMinOutputSizePixel();
6371                                 if ( aMin.Width() <= nNr1 && aMin.Height() <= nNr2 )
6372                                 {
6373 								    pControl->SetSizePixel(Size(nNr1,nNr2));
6374 								    pControl->Resize();
6375                                 }
6376                                 else
6377                                 {
6378                                     ReportError( aUId, GEN_RES_STR2( S_SIZE_BELOW_MINIMUM, String::CreateFromInt32( aMin.Width() ), String::CreateFromInt32( aMin.Height() ) ) );
6379                                 }
6380 							}
6381 							else
6382 								ReportError( aUId, GEN_RES_STR1( S_SIZE_NOT_CHANGEABLE, MethodString( nMethodId ) ) );
6383 							break;
6384 						}
6385 						case M_Close:
6386 							DBG_ASSERT( aUId.equals( pControl->GetUniqueOrHelpId() ), "aUID != UniqueOrHelpId");
6387 							SET_WINP_CLOSING(pControl);
6388 							((FloatingWindow*)pControl)->Close();
6389 							break;
6390 						case M_Help:		// Alles was unten weiterbehandelt werden soll
6391 						case M_Move:
6392 							goto MoreDialog;
6393 						default:
6394 							ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "FloatingWin" ) );
6395 							break;
6396 					}
6397 					break;
6398 				case C_ModelessDlg:
6399 				case C_ModalDlg:
6400                 case C_Dialog:
6401                 case C_TabDlg:
6402 					MoreDialog:
6403 					switch( nMethodId )
6404 					{
6405 						case M_AnimateMouse :
6406 							AnimateMouse( pControl, MitteOben);
6407 							break;
6408 						case M_Close:
6409 							DBG_ASSERT( aUId.equals( pControl->GetUniqueOrHelpId() ), "aUID != UniqueOrHelpId");
6410 							SET_WINP_CLOSING(pControl);
6411 							((SystemWindow*)pControl)->Close();
6412 							break;
6413 						case M_OK:
6414 						{
6415 							Window *pChild = GetWinByRT( pControl, WINDOW_OKBUTTON );
6416 							if( ControlOK( pChild, "OK Button" ) )
6417 							{
6418 								DBG_ASSERT( aUId.equals( pControl->GetUniqueOrHelpId() ), "aUID != UniqueOrHelpId");
6419 								SET_WINP_CLOSING(pControl);
6420 								((Button*)pChild)->Click();
6421 							}
6422 							break;
6423 						}
6424 						case M_Cancel:
6425 						{
6426 							Window *pChild = GetWinByRT( pControl, WINDOW_CANCELBUTTON );
6427 							if( ControlOK( pChild, "Cancel Button" ) )
6428 							{
6429 								DBG_ASSERT( aUId.equals( pControl->GetUniqueOrHelpId() ), "aUID != UniqueOrHelpId");
6430 								SET_WINP_CLOSING(pControl);
6431 								((Button*)pChild)->Click();
6432 							}
6433 							break;
6434 						}
6435 						case M_Help:
6436 						{
6437 							Window *pChild = GetWinByRT( pControl, WINDOW_HELPBUTTON );
6438 							if( ControlOK( pChild, "Help Button" ) )
6439 								((Button*)pChild)->Click();
6440 							break;
6441 						}
6442 						case M_Default:
6443 						{
6444 							Window *pChild = ImpGetButton( pControl, WB_DEFBUTTON, WB_DEFBUTTON );
6445 							if( ControlOK( pChild, "Default Button" ) )
6446 								((Button*)pChild)->Click();
6447 							break;
6448 						}
6449 						case M_Move:
6450 						{
6451 							pControl->SetPosPixel(Point(nNr1,nNr2));
6452 							break;
6453 						}
6454 						default:
6455 							ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "Dialog" ) );
6456 							break;
6457 					}
6458 					break;
6459 				case C_WorkWin:
6460 					switch( nMethodId )
6461 					{
6462 						case M_AnimateMouse :
6463 							AnimateMouse( pControl, MitteOben);
6464 							break;
6465 						case M_Close:
6466 							DBG_ASSERT( aUId.equals( pControl->GetUniqueOrHelpId() ), "aUID != UniqueOrHelpId");
6467 							SET_WINP_CLOSING(pControl);
6468 							((WorkWindow*)pControl)->Close();
6469 							break;
6470 						case M_Size:
6471 						case M_Move:
6472 							goto FloatWin;
6473 //							break;
6474 						case M_IsMax :
6475                             pRet->GenReturn ( RET_Value, aUId, ((WorkWindow*)pControl)->IsMaximized() );
6476                             break;
6477 						case M_IsMin :
6478                             pRet->GenReturn ( RET_Value, aUId, ((WorkWindow*)pControl)->IsMinimized() );
6479                             break;
6480 						case M_IsRestore :
6481                             pRet->GenReturn ( RET_Value, aUId, comm_BOOL (!((WorkWindow*)pControl)->IsMaximized() && !((WorkWindow*)pControl)->IsMinimized()) );
6482                             break;
6483                         case M_Minimize :
6484                             ((WorkWindow*)pControl)->Maximize( sal_False );
6485                             ((WorkWindow*)pControl)->Minimize();
6486                             break;
6487 						case M_Maximize :
6488                             ((WorkWindow*)pControl)->Maximize();
6489                             break;
6490 						case M_Restore :
6491                             ((WorkWindow*)pControl)->Maximize( sal_False );
6492                             ((WorkWindow*)pControl)->Restore();
6493                             break;
6494 						case M_Help:		// Alles was unten weiterbehandelt werden soll
6495 							goto MoreDialog;
6496 						default:
6497 							ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "WorkWindow" ) );
6498 							break;
6499 					}
6500 					break;
6501 				case C_TabPage:
6502 					ReportError( aUId, GEN_RES_STR1( S_INTERNAL_ERROR, MethodString( nMethodId ) ) );
6503 					break;
6504 				case C_MessBox:
6505 				case C_InfoBox:
6506 				case C_WarningBox:
6507 				case C_ErrorBox:
6508 				case C_QueryBox:
6509 					{
6510 						sal_Bool bDone = sal_True;
6511 						MessBox* pMB = (MessBox*)pControl;
6512 						switch( nMethodId )
6513 						{
6514 							case M_GetCheckBoxText:
6515 								pRet->GenReturn ( RET_Value, aUId, pMB->GetCheckBoxText() );
6516 								break;
6517 							case M_IsChecked :
6518 								pRet->GenReturn ( RET_Value, aUId, comm_BOOL( pMB->GetCheckBoxState() == STATE_CHECK) );
6519 								break;
6520 							case M_Check :
6521 								pMB->SetCheckBoxState( sal_True );
6522 								break;
6523 							case M_UnCheck :
6524 								pMB->SetCheckBoxState( sal_False );
6525 								break;
6526 							case M_GetText :
6527 								pRet->GenReturn ( RET_Value, aUId, pMB->GetMessText());
6528 								break;
6529 
6530 							default:
6531 								bDone = sal_False;
6532 								break;
6533 						}
6534 						if ( bDone )
6535 							break;	// break the case here else continue at C_ButtonDialog
6536 					}
6537 				case C_ButtonDialog:
6538 					{
6539 						ButtonDialog* pBD = (ButtonDialog*)pControl;
6540 #if OSL_DEBUG_LEVEL > 1
6541 						m_pDbgWin->AddText( "Working MessBox: " );
6542 						if (pControl->IsVisible())
6543 							m_pDbgWin->AddText("*(Visible)\n");
6544 						else
6545 							m_pDbgWin->AddText("*(nicht Visible)\n");
6546 #endif
6547 						switch( nMethodId )
6548 						{
6549 							case M_AnimateMouse :
6550 								AnimateMouse( pControl, Mitte);
6551 								break;
6552 							case M_OK:
6553 								if ( pBD->GetPushButton( BUTTONID_OK ) )
6554 								{
6555 									SET_WINP_CLOSING(pControl);
6556 									pBD->EndDialog(RET_OK);
6557 								}
6558 								else
6559 									ReportError( aUId, GEN_RES_STR1( S_NO_OK_BUTTON, MethodString( nMethodId ) ) );
6560 								break;
6561 							case M_Cancel:
6562 								if ( pBD->GetPushButton( BUTTONID_CANCEL ) )
6563 								{
6564 									SET_WINP_CLOSING(pControl);
6565 									pBD->EndDialog(RET_CANCEL);
6566 								}
6567 								else
6568 									ReportError( aUId, GEN_RES_STR1( S_NO_CANCEL_BUTTON, MethodString( nMethodId ) ) );
6569 								break;
6570 							case M_Yes:
6571 								if ( pBD->GetPushButton( BUTTONID_YES ) )
6572 								{
6573 									SET_WINP_CLOSING(pControl);
6574 									pBD->EndDialog(RET_YES);
6575 								}
6576 								else
6577 									ReportError( aUId, GEN_RES_STR1( S_NO_YES_BUTTON, MethodString( nMethodId ) ) );
6578 								break;
6579 							case M_No:
6580 								if ( pBD->GetPushButton( BUTTONID_NO ) )
6581 								{
6582 									SET_WINP_CLOSING(pControl);
6583 									pBD->EndDialog(RET_NO);
6584 								}
6585 								else
6586 									ReportError( aUId, GEN_RES_STR1( S_NO_NO_BUTTON, MethodString( nMethodId ) ) );
6587 								break;
6588 							case M_Repeat:
6589 								if ( pBD->GetPushButton( BUTTONID_RETRY ) )
6590 								{
6591 									SET_WINP_CLOSING(pControl);
6592 									pBD->EndDialog(RET_RETRY);
6593 								}
6594 								else
6595 									ReportError( aUId, GEN_RES_STR1( S_NO_RETRY_BUTTON, MethodString( nMethodId ) ) );
6596 								break;
6597 							case M_Help:
6598 								if ( pBD->GetPushButton( BUTTONID_HELP ) )
6599 								{
6600 									SET_WINP_CLOSING(pControl);
6601 									pBD->EndDialog(BUTTONID_HELP);
6602 								}
6603 								else
6604 									ReportError( aUId, GEN_RES_STR1( S_NO_HELP_BUTTON, MethodString( nMethodId ) ) );
6605 								break;
6606 							case M_Default:
6607 								{
6608 									WinBits Style = pControl->GetStyle();
6609 									if      ( Style & WB_DEF_OK )
6610 									{
6611 										SET_WINP_CLOSING(pControl);
6612 										pBD->EndDialog(RET_OK);
6613 									}
6614 									else if ( Style & WB_DEF_CANCEL )
6615 									{
6616 										SET_WINP_CLOSING(pControl);
6617 										pBD->EndDialog(RET_CANCEL);
6618 									}
6619 									else if ( Style & WB_DEF_YES )
6620 									{
6621 										SET_WINP_CLOSING(pControl);
6622 										pBD->EndDialog(RET_YES);
6623 									}
6624 									else if ( Style & WB_DEF_NO )
6625 									{
6626 										SET_WINP_CLOSING(pControl);
6627 										pBD->EndDialog(RET_NO);
6628 									}
6629 									else if ( Style & WB_DEF_RETRY )
6630 									{
6631 										SET_WINP_CLOSING(pControl);
6632 										pBD->EndDialog(RET_RETRY);
6633 									}
6634 									else
6635 										ReportError( aUId, GEN_RES_STR1( S_NO_DEFAULT_BUTTON, MethodString( nMethodId ) ) );
6636 								}
6637 								break;
6638 							case M_GetText :
6639 								pRet->GenReturn ( RET_Value, aUId, pControl->GetText());
6640 								break;
6641 							case M_Click:
6642 								if ( nParams & PARAM_USHORT_1 )
6643 								{
6644 									if ( pBD->GetPushButton( nNr1 ) )
6645 									{
6646 										if ( nNr1 != BUTTONID_HELP )
6647 										{
6648 											SET_WINP_CLOSING(pControl);
6649 										}
6650 										pBD->GetPushButton( nNr1 )->Click();
6651 									}
6652 									else
6653 										ReportError( aUId, GEN_RES_STR2( S_NO_DEFAULT_BUTTON, UniString::CreateFromInt32( nNr1 ), MethodString( nMethodId ) ) );
6654 								}
6655 								else
6656 									ReportError( aUId, GEN_RES_STR1( S_BUTTONID_REQUIRED, MethodString( nMethodId ) ) );
6657 								break;
6658 							case M_GetButtonCount :
6659 								pRet->GenReturn ( RET_Value, aUId, comm_ULONG(pBD->GetButtonCount()));
6660 								break;
6661 							case M_GetButtonId :
6662 								if ( ValueOK(aUId, MethodString( nMethodId ),nNr1,pBD->GetButtonCount()) )
6663 									pRet->GenReturn ( RET_Value, aUId, comm_ULONG(pBD->GetButtonId(nNr1-1)));
6664 								break;
6665 							default:
6666 								ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "MessageBox" ) );
6667 								break;
6668 						}
6669 						break;
6670 					}
6671 				default:
6672 					DBG_ERROR( "Unknown Objekttype from UId or Method not suported" );
6673 					ReportError( aUId, GEN_RES_STR2( S_UNKNOWN_TYPE, UniString::CreateFromInt32( nRT ), MethodString(nMethodId) ) );
6674 #if OSL_DEBUG_LEVEL > 1
6675 					m_pDbgWin->AddText( " Unknown Objekttype from UId or Method not suported" );
6676 #endif
6677 					break;
6678 			}
6679 		}
6680 		for( int i = 0; i < 32; i++ )
6681 			SafeReschedule();
6682 	}
6683 #if OSL_DEBUG_LEVEL > 1
6684 	m_pDbgWin->AddText( "\n" );
6685 #endif
6686 	if ( bStatementDone )
6687 	{
6688 		SendProfile( UIdString( aUId ).Append('.').Append( MethodString( nMethodId ) ) );
6689 		delete this;
6690 	}
6691 	else
6692 	{
6693 		if ( nRetryCount-- )
6694 		{
6695 #if OSL_DEBUG_LEVEL > 1
6696 			m_pDbgWin->AddText( CUniString("Reschedule command (requed) (").Append( UniString::CreateFromInt32(nRetryCount) ).AppendAscii(")\n") );
6697 #endif
6698 			QueStatement( this );	// will que at the start of the list
6699 		}
6700 		else
6701 		{
6702 			bStatementDone=sal_True;
6703 		}
6704 	}
6705 	return bStatementDone;
6706 
6707 #define FINISH_NEXT
6708 #define FINISH_SAME
6709 
6710 }
6711