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