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