update dev300-m58
[ooovba.git] / automation / source / server / statemnt.cxx
blob9497f6151cf3256c7bde2c73dfae6cad4960a305
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: statemnt.cxx,v $
10 * $Revision: 1.40 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_automation.hxx"
33 #include <com/sun/star/frame/XFramesSupplier.hpp>
34 #include <com/sun/star/frame/XDispatch.hpp>
35 #include <com/sun/star/frame/XDispatchProvider.hpp>
36 #include <com/sun/star/util/XURLTransformer.hpp>
37 #include <comphelper/processfactory.hxx>
38 #include <comphelper/uieventslogger.hxx>
40 #include <vcl/wintypes.hxx>
41 #ifndef _DIALOG_HXX //autogen
42 #include <vcl/dialog.hxx>
43 #endif
44 #ifndef _BUTTON_HXX //autogen
45 #include <vcl/button.hxx>
46 #endif
47 #include <vcl/menubtn.hxx>
48 #include <svtools/svtreebx.hxx>
49 #include <svtools/brwbox.hxx>
50 #ifndef _MSGBOX_HXX //autogen
51 #include <vcl/msgbox.hxx>
52 #endif
53 #ifndef _DOCKWIN_HXX //autogen
54 #include <vcl/dockwin.hxx>
55 #endif
56 #ifndef _FLOATWIN_HXX //autogen
57 #include <vcl/floatwin.hxx>
58 #endif
59 #ifndef _LSTBOX_HXX //autogen
60 #include <vcl/lstbox.hxx>
61 #endif
62 #ifndef _COMBOBOX_HXX //autogen
63 #include <vcl/combobox.hxx>
64 #endif
65 #ifndef _MOREBTN_HXX //autogen
66 #include <vcl/morebtn.hxx>
67 #endif
68 #ifndef _FIELD_HXX //autogen
69 #include <vcl/field.hxx>
70 #endif
71 #ifndef _TOOLBOX_HXX //autogen
72 #include <vcl/toolbox.hxx>
73 #endif
74 #include <vcl/tabctrl.hxx>
75 #include <vcl/tabpage.hxx>
76 #include <vcl/menu.hxx>
77 #include <vcl/status.hxx>
78 #include <svtools/prgsbar.hxx>
79 #include <svtools/editbrowsebox.hxx>
80 #include <vcl/splitwin.hxx>
81 #include <vcl/group.hxx>
82 #include <vcl/fixed.hxx>
83 #include <vcl/wrkwin.hxx>
84 #include <osl/diagnose.h>
85 #include <vcl/wintypes.hxx>
86 #include <svtools/valueset.hxx>
87 #include <svtools/roadmap.hxx>
88 #include <svtools/poolitem.hxx>
89 #include <svtools/extensionlistbox.hxx>
90 // Hat keinen Includeschutz
91 #include <svtools/svtdata.hxx>
92 #include <tools/time.hxx>
93 #include <svtools/stringtransfer.hxx>
94 #ifndef _PRINT_HXX //autogen
95 #include <vcl/print.hxx>
96 #endif
97 #ifndef _PRNDLG_HXX //autogen
98 #include <vcl/prndlg.hxx>
99 #endif
100 #include <tools/stream.hxx>
101 #ifndef _SV_DRAG_HXX //autogen
102 //#include <vcl/drag.hxx>
103 #endif
104 #include <tools/fsys.hxx>
105 #include <svtools/stritem.hxx>
106 #include <svtools/ttprops.hxx>
107 #ifndef _BASIC_TTRESHLP_HXX
108 #include <basic/ttstrhlp.hxx>
109 #endif
110 #include <basic/dispdefs.hxx>
111 #include <vos/socket.hxx>
112 #include <svtools/pickerhistory.hxx>
113 #include <com/sun/star/util/XCancellable.hpp>
115 #include <sot/storage.hxx>
116 #include <sot/storinfo.hxx>
117 #include "statemnt.hxx"
118 #include "scmdstrm.hxx"
120 #ifndef _RETSRTM_HXX
121 #include "retstrm.hxx"
122 #endif
124 #if OSL_DEBUG_LEVEL > 1
125 #include "editwin.hxx"
126 #endif
127 #include "rcontrol.hxx"
128 #include <automation/communi.hxx>
129 #include "testtool.hxx"
131 #include "profiler.hxx"
133 #include "recorder.hxx"
135 #include "testtool.hrc"
136 #include <basic/svtmsg.hrc>
138 #include <algorithm>
141 using namespace com::sun::star::frame;
142 using namespace com::sun::star::uno;
143 using namespace com::sun::star::util;
144 using namespace com::sun::star::beans;
145 using namespace svt;
148 #ifndef SBX_VALUE_DECL_DEFINED
149 #define SBX_VALUE_DECL_DEFINED
150 SV_DECL_REF(SbxValue)
151 #endif
152 SV_IMPL_REF(SbxValue)
154 CommunicationLink *StatementFlow::pCommLink = NULL;
155 BOOL StatementFlow::bUseIPC = TRUE;
156 BOOL StatementFlow::bSending = FALSE;
157 ImplRemoteControl *StatementFlow::pRemoteControl = NULL;
159 USHORT StatementCommand::nDirPos = 0;
160 Dir *StatementCommand::pDir = NULL;
161 pfunc_osl_printDebugMessage StatementCommand::pOriginal_osl_DebugMessageFunc = NULL;
164 #define RESET_APPLICATION_TO_BACKING_WINDOW
167 #define SET_WINP_CLOSING(pWin) \
168 pWindowWaitPointer = pWin; \
169 aWindowWaitUId = pControl->GetSmartUniqueOrHelpId(); \
170 aWindowWaitOldHelpId = pWin->GetSmartHelpId(); \
171 aWindowWaitOldUniqueId = pWin->GetSmartUniqueId(); \
172 pWin->SetSmartHelpId( SmartId(4321) ); \
173 pWin->SetSmartUniqueId( SmartId(1234) );
175 // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
177 StatementFlow::StatementFlow( StatementList *pAfterThis, USHORT nArtP )
178 : nArt(nArtP)
179 , nParams(0)
180 , nSNr1(0)
181 , nLNr1(0)
182 , aString1()
183 , bBool1(FALSE)
185 QueStatement( pAfterThis );
188 StatementFlow::StatementFlow( ULONG nServiceId, SCmdStream *pCmdIn, ImplRemoteControl *pRC )
189 : nArt(0)
190 , nParams(0)
191 , nSNr1(0)
192 , nLNr1(0)
193 , aString1()
194 , bBool1(FALSE)
196 QueStatement( NULL );
197 bUseIPC = (nServiceId == SI_IPCCommandBlock);
198 pRemoteControl = pRC;
199 pCmdIn->Read( nArt );
200 pCmdIn->Read( nParams );
202 if( nParams & PARAM_USHORT_1 ) pCmdIn->Read( nSNr1 );
203 if( nParams & PARAM_ULONG_1 ) pCmdIn->Read( nLNr1 );
204 if( nParams & PARAM_STR_1 ) pCmdIn->Read( aString1 );
205 if( nParams & PARAM_BOOL_1 ) pCmdIn->Read( bBool1 ); // sollte nie auftreten!!
207 #if OSL_DEBUG_LEVEL > 1
208 m_pDbgWin->AddText( "Reading FlowControl: " );
209 m_pDbgWin->AddText( String::CreateFromInt32( nArt ) );
210 m_pDbgWin->AddText( " Params:" );
211 if( nParams & PARAM_USHORT_1 ) {m_pDbgWin->AddText( " n1:" );m_pDbgWin->AddText( String::CreateFromInt32( nSNr1 ) );}
212 if( nParams & PARAM_ULONG_1 ) {m_pDbgWin->AddText( " l1:" );m_pDbgWin->AddText( String::CreateFromInt64( nLNr1 ) );}
213 if( nParams & PARAM_STR_1 ) {m_pDbgWin->AddText( " s1:" );m_pDbgWin->AddText( aString1 );}
214 if( nParams & PARAM_BOOL_1 ) {m_pDbgWin->AddText( " b2:" );m_pDbgWin->AddText( bBool1 ? "TRUE" : "FALSE" );}
215 m_pDbgWin->AddText( "\n" );
216 #endif
219 void StatementFlow::SendViaSocket()
221 if ( bSending )
223 #if OSL_DEBUG_LEVEL > 1
224 m_pDbgWin->AddText( "SendViaSocket called recursively. Aborted!!!\n" );
225 #endif
226 DBG_ERROR("SendViaSocket called recursively. Aborted!!!");
227 return;
229 bSending = TRUE;
230 if ( pCommLink )
232 if ( !pCommLink->TransferDataStream( pRet->GetStream() ) ) // tritt ein Fehler auf, so wird sofort gelöscht ...
233 pCommLink = NULL;
235 else
237 // Macht nix. Wenn das Basic nicht mehr da ist, ist sowiso alles egal
238 DBG_ERROR("Cannot send results to TestTool");
241 pRet->Reset();
242 bSending = FALSE;
243 IsError = FALSE;
246 BOOL StatementFlow::Execute()
248 #if OSL_DEBUG_LEVEL > 1
249 m_pDbgWin->AddText( "Executing Flow: " );
250 m_pDbgWin->AddText( String::CreateFromInt32( nArt ) );
251 m_pDbgWin->AddText( "\n" );
252 #endif
253 switch ( nArt )
255 case F_EndCommandBlock:
258 if ( !bUseIPC )
260 // bBool1 wurde im CTOR auf FALSE initialisiert
261 if ( !bBool1 ) // also erster Durchlauf
263 pRemoteControl->pRetStream = pRet->GetStream();
264 bBool1 = TRUE; // wurde im CTOR auf FALSE initialisiert
265 nRetryCount = nRetryCount * 4;
267 if ( pRemoteControl->pRetStream && (nRetryCount--) ) // also solange nicht abgeholt
269 return FALSE; // Bitte einmal vom Callstack runter
274 break;
277 Advance();
278 switch ( nArt )
280 case F_EndCommandBlock:
281 if ( !bUseIPC )
282 { // wird oben abgehandelt
283 pRet->Reset();
284 IsError = FALSE;
286 else
287 SendViaSocket();
289 break;
291 case F_Sequence:
293 pRet->GenReturn(RET_Sequence,nLNr1);
294 #if OSL_DEBUG_LEVEL > 1
295 m_pDbgWin->AddText( "Sending Sequence Nr: " );
296 m_pDbgWin->AddText( String::CreateFromInt64( nLNr1 ) );
297 m_pDbgWin->AddText( "\n" );
298 #endif
300 break;
301 // case RET_:
302 default:
303 DBG_ERROR( "Unknown Flowcontrol" );
304 break;
307 delete this;
308 return TRUE;
311 // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
313 // neue Hilfsfunktion, die stetig erweitert werden muss
314 static short ImpGetRType( Window *pWin, SmartId aUId )
316 ULONG nUId = aUId.GetNum(); // GetNum() is always zero if no num is defined
317 // GGGg gggg::gggg gggg::ggLL LLLl::llll llll
318 DBG_ASSERT( pWin, "missing Parameter" );
319 short nRT;
320 if( (nUId & 0xE0000000) == 0 ) // keine auto ID
321 nRT = C_NoType;
322 else {
323 // if( (nUId & 0x1F) == 0 ) // globale Resource
324 if( (nUId & 0x1FF) == 0 ) // globale Resource GH: soweit ich das verstanden habe 1FF
325 nRT = (short)(C_TabPage - 1 + (nUId >> 29));
326 else
327 nRT = (short)((nUId & 0x00003E00) >> 9);
328 if ( nRT == C_TabPage ) // wegen TabDialog.UId = TabPage.UId
329 nRT = C_NoType;
330 else
332 #ifndef DBG_UTIL
333 return nRT;
334 #endif
338 #ifdef DBG_UTIL
339 short n = nRT;
340 #endif
341 WindowType eRT = pWin->GetType();
342 switch( eRT ) {
343 case WINDOW_WINDOW: nRT = C_Window ; break;
345 case WINDOW_TABCONTROL: nRT = C_TabControl ; break;
346 case WINDOW_RADIOBUTTON: nRT = C_RadioButton ; break;
347 case WINDOW_CHECKBOX: nRT = C_CheckBox ; break;
348 case WINDOW_TRISTATEBOX: nRT = C_TriStateBox ; break;
349 case WINDOW_EDIT: nRT = C_Edit ; break;
350 case WINDOW_MULTILINEEDIT: nRT = C_MultiLineEdit ; break;
351 case WINDOW_MULTILISTBOX: nRT = C_MultiListBox ; break;
352 case WINDOW_LISTBOX: nRT = C_ListBox ; break;
353 case WINDOW_COMBOBOX: nRT = C_ComboBox ; break;
354 case WINDOW_PUSHBUTTON: nRT = C_PushButton ; break;
355 case WINDOW_SPINFIELD: nRT = C_SpinField ; break;
356 case WINDOW_PATTERNFIELD: nRT = C_PatternField ; break;
357 case WINDOW_NUMERICFIELD: nRT = C_NumericField ; break;
358 case WINDOW_METRICFIELD: nRT = C_MetricField ; break;
359 case WINDOW_CURRENCYFIELD: nRT = C_CurrencyField ; break;
360 case WINDOW_DATEFIELD: nRT = C_DateField ; break;
361 case WINDOW_TIMEFIELD: nRT = C_TimeField ; break;
362 case WINDOW_IMAGERADIOBUTTON: nRT = C_ImageRadioButton ; break;
363 case WINDOW_NUMERICBOX: nRT = C_NumericBox ; break;
364 case WINDOW_METRICBOX: nRT = C_MetricBox ; break;
365 case WINDOW_CURRENCYBOX: nRT = C_CurrencyBox ; break;
366 case WINDOW_DATEBOX: nRT = C_DateBox ; break;
367 case WINDOW_TIMEBOX: nRT = C_TimeBox ; break;
368 case WINDOW_IMAGEBUTTON: nRT = C_ImageButton ; break;
369 case WINDOW_MENUBUTTON: nRT = C_MenuButton ; break;
370 case WINDOW_MOREBUTTON: nRT = C_MoreButton ; break;
373 case WINDOW_TABPAGE: nRT = C_TabPage; break;
374 case WINDOW_MODALDIALOG: nRT = C_ModalDlg; break;
375 case WINDOW_FLOATINGWINDOW: nRT = C_FloatWin; break;
376 case WINDOW_MODELESSDIALOG: nRT = C_ModelessDlg; break;
377 case WINDOW_WORKWINDOW: nRT = C_WorkWin; break;
378 case WINDOW_DOCKINGWINDOW: nRT = C_DockingWin; break;
380 case WINDOW_MESSBOX: nRT = C_MessBox; break;
381 case WINDOW_INFOBOX: nRT = C_InfoBox; break;
382 case WINDOW_WARNINGBOX: nRT = C_WarningBox; break;
383 case WINDOW_ERRORBOX: nRT = C_ErrorBox; break;
384 case WINDOW_QUERYBOX: nRT = C_QueryBox; break;
385 #if 0 //ifndef VCL
386 case WINDOW_FILEDIALOG: nRT = C_FileDlg; break;
387 case WINDOW_PATHDIALOG: nRT = C_PathDlg; break;
388 case WINDOW_PRINTDIALOG: nRT = C_PrintDlg; break;
389 case WINDOW_PRINTERSETUPDIALOG: nRT = C_PrinterSetupDlg;break;
390 case WINDOW_COLORDIALOG: nRT = C_ColorDlg; break;
391 #endif
392 case WINDOW_TABDIALOG: nRT = C_TabDlg; break;
393 // case WINDOW_TABDIALOG: nRT = C_SingleTabDlg; break;
395 case WINDOW_PATTERNBOX: nRT = C_PatternBox; break;
396 case WINDOW_TOOLBOX: nRT = C_ToolBox; break;
397 // Gibts nicht case WINDOW_VALUESET: nRT = C_ValueSet; break;
398 case WINDOW_CONTROL: nRT = C_Control; break;
399 case WINDOW_OKBUTTON: nRT = C_OkButton; break;
400 case WINDOW_CANCELBUTTON: nRT = C_CancelButton; break;
401 case WINDOW_BUTTONDIALOG: nRT = C_ButtonDialog; break;
402 case WINDOW_TREELISTBOX: nRT = C_TreeListBox; break;
404 case WINDOW_DIALOG: nRT = C_Dialog; break;
406 #ifdef DBG_UTIL
407 // Die Werte n sind bei den WindowTypen nicht mehr vergeben, werden aber in der AutoID noch verwendet
408 // Sie werden jetzt durch den Typ nRT implementiert.
409 DBG_ASSERT( n == C_NoType || n == nRT
410 || ( n == C_ImageButton && nRT == C_PushButton )
411 || ( n == C_TriStateBox && nRT == C_CheckBox )
412 || ( n == C_ImageRadioButton && nRT == C_RadioButton )
413 , "error in algorithm" );
414 #endif
415 return nRT;
418 // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
420 StatementSlot::StatementSlot( SCmdStream *pCmdIn )
421 : pItemArr(NULL)
423 QueStatement( NULL );
424 pCmdIn->Read( nFunctionId );
425 #if OSL_DEBUG_LEVEL > 1
426 m_pDbgWin->AddText( "Reading Slot: " );
427 m_pDbgWin->AddText( String::CreateFromInt32( nFunctionId ) );
428 m_pDbgWin->AddText( "\n" );
429 #endif
430 pCmdIn->Read( nAnzahl );
431 if ( nAnzahl )
433 switch ( pCmdIn->GetNextType() )
435 case BinUSHORT: // use old calling method
437 nAnzahl++;
438 pItemArr = new SfxPoolItem*[nAnzahl];
439 for (USHORT i = 0 ; i+1 < nAnzahl ; i++)
440 pCmdIn->Read( pItemArr[i] );
441 pItemArr[nAnzahl-1] = NULL;
443 break;
444 case BinString: // new Method
446 aArgs.realloc(nAnzahl);
447 PropertyValue* pArg = aArgs.getArray();
448 for (USHORT i = 0 ; i < nAnzahl ; i++)
449 pCmdIn->Read( pArg[i] );
451 break;
456 // Constructor for UnoSlot
457 StatementSlot::StatementSlot()
458 : nAnzahl( 0 )
459 , pItemArr(NULL)
460 , nFunctionId( 0 )
461 , bMenuClosed(FALSE)
464 StatementSlot::StatementSlot( ULONG nSlot, SfxPoolItem* pItem )
465 : pItemArr(NULL)
466 , bMenuClosed(FALSE)
468 QueStatement( NULL );
469 nFunctionId = USHORT(nSlot);
470 #if OSL_DEBUG_LEVEL > 1
471 m_pDbgWin->AddText( "Reading Slot: " );
472 m_pDbgWin->AddText( String::CreateFromInt32( nFunctionId ) );
473 m_pDbgWin->AddText( "\n" );
474 #endif
475 if ( pItem )
477 nAnzahl = 2;
478 pItemArr = new SfxPoolItem*[2];
479 pItemArr[0] = pItem;
480 pItemArr[1] = NULL;
482 else
483 nAnzahl = 0;
486 StatementSlot::~StatementSlot()
488 if (nAnzahl)
490 if ( pItemArr )
492 for (USHORT i = 0 ; i+1 < nAnzahl ; i++)
493 delete pItemArr[i];
494 delete[] pItemArr;
497 aArgs.realloc( 0 );
501 void StatementSlot::AddReferer()
503 HACK( "only to test!" );
504 // because slot 6102 /*SID_VERB_START*/ crashes when called with Property Referer
505 // We return to the previous behavior (which was a bug realy) of not adding this Property to calls which have no properties at all
506 // according to MBA most likely this Property can be removed at all and is maybe only needed for Slots with URLs
507 if ( !nAnzahl )
508 return;
510 PropertyValue* pArg;
512 nAnzahl++;
513 aArgs.realloc(nAnzahl);
514 pArg = aArgs.getArray();
515 pArg[nAnzahl-1].Name = rtl::OUString::createFromAscii("Referer");
516 pArg[nAnzahl-1].Value <<= ::rtl::OUString::createFromAscii("private:user");
518 nAnzahl++;
519 aArgs.realloc(nAnzahl);
520 pArg = aArgs.getArray();
521 pArg[nAnzahl-1].Name = rtl::OUString::createFromAscii("SynchronMode");
522 pArg[nAnzahl-1].Value <<= sal_Bool( TRUE );
525 class SlotStatusListener : public cppu::WeakImplHelper1< XStatusListener >
527 public:
528 SlotStatusListener();
530 // XStatusListener
531 virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw (::com::sun::star::uno::RuntimeException);
532 // XEventListener
533 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
535 // local Members
536 BOOL bDisposed;
537 BOOL bEnabled;
540 struct FeatureStateEvent : public ::com::sun::star::lang::EventObject
541 ::com::sun::star::util::URL FeatureURL;
542 ::rtl::OUString FeatureDescriptor;
543 sal_Bool IsEnabled;
544 sal_Bool Requery;
545 ::com::sun::star::uno::Any State;
547 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > Source;
550 SlotStatusListener::SlotStatusListener()
551 : bDisposed( FALSE )
552 , bEnabled( TRUE )
555 // XStatusListener
556 void SAL_CALL SlotStatusListener::statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw (::com::sun::star::uno::RuntimeException)
558 // DBG_ERROR1("FeatureURL: %s", ByteString( String( Event.FeatureURL.Complete ), RTL_TEXTENCODING_UTF8 ).GetBuffer() );
559 // DBG_ERROR1("FeatureDescriptor: %s", ByteString( String( Event.FeatureDescriptor ), RTL_TEXTENCODING_UTF8 ).GetBuffer() );
560 bEnabled = Event.IsEnabled;
561 // DBG_ASSERT( Event.IsEnabled, "Not enabled" );
562 // DBG_ASSERT( !Event.Requery, "Requery" );
565 // XEventListener
566 void SAL_CALL SlotStatusListener::disposing( const ::com::sun::star::lang::EventObject& ) throw (::com::sun::star::uno::RuntimeException)
568 bDisposed = TRUE;
571 BOOL StatementSlot::Execute()
573 if ( IsError )
575 #if OSL_DEBUG_LEVEL > 1
576 m_pDbgWin->AddText( "Skipping Slot: " );
577 m_pDbgWin->AddText( String::CreateFromInt32( nFunctionId ) );
578 m_pDbgWin->AddText( "\n" );
579 #endif
581 Advance();
582 delete this;
583 return TRUE;
586 InitProfile();
587 #if OSL_DEBUG_LEVEL > 1
588 m_pDbgWin->AddText( "Executing Slot: " );
589 m_pDbgWin->AddText( String::CreateFromInt32( nFunctionId ) );
590 m_pDbgWin->AddText( "\n" );
591 #endif
593 PopupMenu *pPopup = NULL;
594 MenuBar *pMenuBar = NULL;
595 Menu *pMenu;
597 GetCurrentMenues( pPopup, pMenuBar, pMenu );
598 if ( pPopup )
600 if ( !bMenuClosed )
602 pPopup->EndExecute(0);
603 aSubMenuId1 = SmartId();
604 aSubMenuId2 = SmartId();
605 aSubMenuId3 = SmartId();
606 pMenuWindow = NULL;
607 bMenuClosed = TRUE;
608 #if OSL_DEBUG_LEVEL > 1
609 m_pDbgWin->AddText( "Closed contextmenu\n" );
610 #endif
611 return FALSE;
613 else if ( nRetryCount-- )
615 #if OSL_DEBUG_LEVEL > 1
616 m_pDbgWin->AddText( "Waiting for contextmenu to close\n" );
617 #endif
618 return FALSE;
620 else
621 ReportError( GEN_RES_STR0( S_MENU_NOT_CLOSING ) );
624 Advance();
626 if ( !IsError )
628 if ( ( nAnzahl == 0 && !getenv("OLDSLOTHANDLING") ) || aArgs.hasElements() )
629 { // trying to call slots via uno
630 AddReferer();
631 if ( !aUnoUrl.Len() )
632 aUnoUrl = CUniString("slot:").Append( String::CreateFromInt32( nFunctionId ) );
633 URL aTargetURL;
634 aTargetURL.Complete = aUnoUrl;
635 Reference < XFramesSupplier > xDesktop = Reference < XFramesSupplier >( ::comphelper::getProcessServiceFactory()->createInstance( CUniString("com.sun.star.frame.Desktop") ), UNO_QUERY );
636 Reference < XFrame > xFrame;
638 if ( xDesktop.is() )
640 xFrame = xDesktop->getActiveFrame();
641 if ( !xFrame.is() )
643 Reference < XFrames > xFrames;
644 xFrames = xDesktop->getFrames();
645 if ( xFrames.is() && xFrames->getCount() > 0 )
647 Any aFrame = xFrames->getByIndex( xFrames->getCount() -1 );
648 aFrame >>= xFrame;
651 if ( !xFrame.is() )
653 if ( GetFirstDocFrame() )
654 GetFirstDocFrame()->ToTop();
655 xFrame = xDesktop->getActiveFrame();
659 if ( xFrame.is() )
660 xDesktop = Reference < XFramesSupplier >( xFrame, UNO_QUERY );
661 else
662 xDesktop.clear();
664 while ( xDesktop.is() && xDesktop->getActiveFrame().is() )
666 xFrame = xDesktop->getActiveFrame();
667 #if OSL_DEBUG_LEVEL > 1
668 ::rtl::OUString aName;
669 if ( xFrame.is() )
670 aName = xFrame->getName();
671 #endif
672 xDesktop = Reference < XFramesSupplier >( xFrame, UNO_QUERY );
675 if ( !xFrame.is() )
676 ReportError( GEN_RES_STR1( S_UNO_URL_EXECUTE_FAILED_NO_FRAME, aTargetURL.Complete ) );
677 else
679 Reference < XURLTransformer > xTrans( ::comphelper::getProcessServiceFactory()->createInstance( CUniString("com.sun.star.util.URLTransformer" )), UNO_QUERY );
680 xTrans->parseStrict( aTargetURL );
682 Reference < XDispatchProvider > xProv( xFrame, UNO_QUERY );
683 Reference < XDispatch > xDisp;
684 while ( xProv.is() && !xDisp.is() )
686 xDisp = xProv->queryDispatch( aTargetURL, ::rtl::OUString(), 0 );
687 if ( !xDisp.is() )
689 xFrame = Reference < XFrame > ( xFrame->getCreator(), UNO_QUERY );
690 xProv = Reference < XDispatchProvider > ( xFrame, UNO_QUERY );
694 if ( xDisp.is() )
696 Reference < XStatusListener > xListener = ( XStatusListener* )new SlotStatusListener;
697 xDisp->addStatusListener( xListener, aTargetURL );
698 if ( static_cast< SlotStatusListener* >(xListener.get())->bEnabled )
700 if ( bIsSlotInExecute )
701 ReportError( GEN_RES_STR0( S_SLOT_IN_EXECUTE ) );
702 else
704 bIsSlotInExecute = TRUE;
705 xDisp->dispatch( aTargetURL, aArgs );
706 bIsSlotInExecute = FALSE;
709 else
710 ReportError( GEN_RES_STR1( S_UNO_URL_EXECUTE_FAILED_DISABLED, aTargetURL.Complete ) );
711 xDisp->removeStatusListener( xListener, aTargetURL );
713 else
714 ReportError( GEN_RES_STR1( S_UNO_URL_EXECUTE_FAILED_NO_DISPATCHER, aTargetURL.Complete ) );
717 else
719 DirectLog( S_QAError, GEN_RES_STR0( S_DEPRECATED ) );
720 if ( !pTTProperties )
721 pTTProperties = new TTProperties();
723 switch ( pTTProperties->ExecuteFunction( nFunctionId, pItemArr, EXECUTEMODE_DIALOGASYNCHRON | nUseBindings ) )
725 case TT_PR_ERR_NODISPATCHER:
727 ReportError( SmartId(nFunctionId), GEN_RES_STR0( S_SID_EXECUTE_FAILED_NO_DISPATCHER ) );
729 break;
730 case TT_PR_ERR_NOEXECUTE:
732 ReportError(SmartId(nFunctionId), GEN_RES_STR0( S_SID_EXECUTE_FAILED ) );
734 break;
740 /* Neues Verfahren ab 334!
741 Neue Methode zum einstellen, daß Modale Dialoge immer Asynchron aufgerufen werden
742 und echter Returnwert, ob Slot geklappt hat
743 und Testen ob Slot überhaupt durch UI aufgerufen werden kann */
746 SendProfile( SlotString( nFunctionId ) );
747 delete this;
748 return TRUE;
751 // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
753 StatementUnoSlot::StatementUnoSlot(SCmdStream *pIn)
755 QueStatement( NULL );
757 pIn->Read( aUnoUrl );
759 #if OSL_DEBUG_LEVEL > 1
760 StatementList::m_pDbgWin->AddText( "UnoUrl:" );
761 StatementList::m_pDbgWin->AddText( aUnoUrl );
762 StatementList::m_pDbgWin->AddText( "\n" );
763 #endif
767 // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
769 StatementCommand::StatementCommand( StatementList *pAfterThis, USHORT MethodId, USHORT Params, USHORT Nr1 )
770 : nMethodId( MethodId )
771 , aSmartMethodId()
772 , nParams(Params)
773 , nNr1(Nr1)
774 , nNr2(0)
775 , nNr3(0)
776 , nNr4(0)
777 , nLNr1(0)
778 , aString1()
779 , aString2()
780 , bBool1(FALSE)
781 , bBool2(FALSE)
783 QueStatement( pAfterThis );
784 aSmartMethodId = SmartId( nMethodId );
786 #if OSL_DEBUG_LEVEL > 1
787 m_pDbgWin->AddText( "Directly adding Conmmand:" );
788 m_pDbgWin->AddText( " Methode: " );
789 m_pDbgWin->AddText( aSmartMethodId.GetText() );
790 m_pDbgWin->AddText( " Params:" );
791 if( nParams & PARAM_USHORT_1 ) {m_pDbgWin->AddText( " n1:" );m_pDbgWin->AddText( String::CreateFromInt32( nNr1 ) );}
792 if( nParams & PARAM_USHORT_2 ) {m_pDbgWin->AddText( " n2:" );m_pDbgWin->AddText( String::CreateFromInt32( nNr2 ) );}
793 if( nParams & PARAM_USHORT_3 ) {m_pDbgWin->AddText( " n3:" );m_pDbgWin->AddText( String::CreateFromInt32( nNr3 ) );}
794 if( nParams & PARAM_USHORT_4 ) {m_pDbgWin->AddText( " n4:" );m_pDbgWin->AddText( String::CreateFromInt32( nNr4 ) );}
795 if( nParams & PARAM_ULONG_1 ) {m_pDbgWin->AddText( " nl1:" );m_pDbgWin->AddText( String::CreateFromInt64( nLNr1 ) );}
796 if( nParams & PARAM_STR_1 ) {m_pDbgWin->AddText( " s1:" );m_pDbgWin->AddText( aString1 );}
797 if( nParams & PARAM_STR_2 ) {m_pDbgWin->AddText( " s2:" );m_pDbgWin->AddText( aString2 );}
798 if( nParams & PARAM_BOOL_1 ) {m_pDbgWin->AddText( " b1:" );m_pDbgWin->AddText( bBool1 ? "TRUE" : "FALSE" );}
799 if( nParams & PARAM_BOOL_2 ) {m_pDbgWin->AddText( " b2:" );m_pDbgWin->AddText( bBool2 ? "TRUE" : "FALSE" );}
800 m_pDbgWin->AddText( "\n" );
801 #endif
805 StatementCommand::StatementCommand( SCmdStream *pCmdIn )
806 : nMethodId(0)
807 , aSmartMethodId()
808 , nParams(0)
809 , nNr1(0)
810 , nNr2(0)
811 , nNr3(0)
812 , nNr4(0)
813 , nLNr1(0)
814 , aString1()
815 , aString2()
816 , bBool1(FALSE)
817 , bBool2(FALSE)
819 QueStatement( NULL );
820 pCmdIn->Read( nMethodId );
821 aSmartMethodId = SmartId( nMethodId );
822 pCmdIn->Read( nParams );
824 if( nParams & PARAM_USHORT_1 ) pCmdIn->Read( nNr1 );
825 if( nParams & PARAM_USHORT_2 ) pCmdIn->Read( nNr2 );
826 if( nParams & PARAM_USHORT_3 ) pCmdIn->Read( nNr3 );
827 if( nParams & PARAM_USHORT_4 ) pCmdIn->Read( nNr4 );
828 if( nParams & PARAM_ULONG_1 ) pCmdIn->Read( nLNr1 );
829 if( nParams & PARAM_STR_1 ) pCmdIn->Read( aString1 );
830 if( nParams & PARAM_STR_2 ) pCmdIn->Read( aString2 );
831 if( nParams & PARAM_BOOL_1 ) pCmdIn->Read( bBool1 );
832 if( nParams & PARAM_BOOL_2 ) pCmdIn->Read( bBool2 );
834 #if OSL_DEBUG_LEVEL > 1
835 m_pDbgWin->AddText( "Reading Conmmand:" );
836 m_pDbgWin->AddText( " Methode: " );
837 m_pDbgWin->AddText( aSmartMethodId.GetText() );
838 m_pDbgWin->AddText( " Params:" );
839 if( nParams & PARAM_USHORT_1 ) {m_pDbgWin->AddText( " n1:" );m_pDbgWin->AddText( String::CreateFromInt32( nNr1 ) );}
840 if( nParams & PARAM_USHORT_2 ) {m_pDbgWin->AddText( " n2:" );m_pDbgWin->AddText( String::CreateFromInt32( nNr2 ) );}
841 if( nParams & PARAM_USHORT_3 ) {m_pDbgWin->AddText( " n3:" );m_pDbgWin->AddText( String::CreateFromInt32( nNr3 ) );}
842 if( nParams & PARAM_USHORT_4 ) {m_pDbgWin->AddText( " n4:" );m_pDbgWin->AddText( String::CreateFromInt32( nNr4 ) );}
843 if( nParams & PARAM_ULONG_1 ) {m_pDbgWin->AddText( " nl1:" );m_pDbgWin->AddText( String::CreateFromInt64( nLNr1 ) );}
844 if( nParams & PARAM_STR_1 ) {m_pDbgWin->AddText( " s1:" );m_pDbgWin->AddText( aString1 );}
845 if( nParams & PARAM_STR_2 ) {m_pDbgWin->AddText( " s2:" );m_pDbgWin->AddText( aString2 );}
846 if( nParams & PARAM_BOOL_1 ) {m_pDbgWin->AddText( " b1:" );m_pDbgWin->AddText( bBool1 ? "TRUE" : "FALSE" );}
847 if( nParams & PARAM_BOOL_2 ) {m_pDbgWin->AddText( " b2:" );m_pDbgWin->AddText( bBool2 ? "TRUE" : "FALSE" );}
848 m_pDbgWin->AddText( "\n" );
849 #endif
851 if ( nMethodId == RC_AppAbort )
853 #if OSL_DEBUG_LEVEL > 1
854 m_pDbgWin->AddText( "*Deleting all Commands:\n" );
855 #endif
856 bReadingCommands = FALSE;
857 while ( StatementList::pFirst != this ) // Alles Löschen außer mich selbst
859 StatementList *pDeQue = StatementList::pFirst;
860 pDeQue->Advance();
861 delete pDeQue;
863 bReadingCommands = TRUE;
864 #if OSL_DEBUG_LEVEL > 1
865 m_pDbgWin->AddText( "*Done deleting all Commands:\n" );
866 #endif
871 void StatementCommand::WriteControlData( Window *pBase, ULONG nConf, BOOL bFirst )
874 if ( IsDialog(pBase) && !bFirst )
875 return;
877 if ( bFirst )
878 pRet->GenReturn ( RET_WinInfo, SmartId(), (comm_ULONG)nConf | DH_MODE_DATA_VALID, UniString(), TRUE );
880 { // Klammerung, so daß der String nicht während der Rekursion bestehen bleibt
881 String aName;
882 BOOL bSkip = FALSE;
884 switch ( pBase->GetType() )
886 case WINDOW_RADIOBUTTON:
887 case WINDOW_CHECKBOX:
888 case WINDOW_TRISTATEBOX:
889 case WINDOW_PUSHBUTTON:
890 case WINDOW_OKBUTTON:
891 case WINDOW_CANCELBUTTON:
892 case WINDOW_IMAGERADIOBUTTON:
893 case WINDOW_IMAGEBUTTON:
894 case WINDOW_MENUBUTTON:
895 case WINDOW_MOREBUTTON:
896 case WINDOW_TABPAGE:
897 case WINDOW_MODALDIALOG:
898 case WINDOW_FLOATINGWINDOW:
899 case WINDOW_MODELESSDIALOG:
900 case WINDOW_WORKWINDOW:
901 case WINDOW_DOCKINGWINDOW:
902 case WINDOW_CONTROL:
904 case WINDOW_FILEDIALOG:
905 case WINDOW_PATHDIALOG:
906 case WINDOW_PRINTDIALOG:
907 case WINDOW_PRINTERSETUPDIALOG:
908 case WINDOW_COLORDIALOG:
909 case WINDOW_TABDIALOG:
911 case WINDOW_BUTTONDIALOG:
913 case WINDOW_MENUBARWINDOW:
914 aName = pBase->GetText().EraseAllChars('~');
915 break;
917 case WINDOW_EDIT:
918 case WINDOW_MULTILINEEDIT:
919 case WINDOW_MULTILISTBOX:
920 case WINDOW_LISTBOX:
921 case WINDOW_COMBOBOX:
922 case WINDOW_SPINFIELD:
923 case WINDOW_PATTERNFIELD:
924 case WINDOW_NUMERICFIELD:
925 case WINDOW_METRICFIELD:
926 case WINDOW_CURRENCYFIELD:
927 case WINDOW_DATEFIELD:
928 case WINDOW_TIMEFIELD:
929 case WINDOW_NUMERICBOX:
930 case WINDOW_METRICBOX:
931 case WINDOW_CURRENCYBOX:
932 case WINDOW_DATEBOX:
933 case WINDOW_TIMEBOX:
934 case WINDOW_PATTERNBOX:
935 case WINDOW_TOOLBOX:
936 aName = pBase->GetQuickHelpText();
937 break;
939 case WINDOW_MESSBOX:
940 case WINDOW_INFOBOX:
941 case WINDOW_WARNINGBOX:
942 case WINDOW_ERRORBOX:
943 case WINDOW_QUERYBOX:
944 aName = ((MessBox*)pBase)->GetMessText();
945 break;
947 default:
948 if ( pBase->GetSmartUniqueOrHelpId().Equals( SmartId() ) && !( nConf & DH_MODE_ALLWIN ) )
949 bSkip = TRUE;
952 if ( !bSkip )
954 if ( aName.Len() == 0 )
955 aName = pBase->GetQuickHelpText();
956 if ( aName.Len() == 0 )
957 aName = pBase->GetHelpText();
958 if ( aName.Len() == 0 )
959 aName = pBase->GetText();
962 String aTypeSuffix;
963 if ( pBase->GetType() == WINDOW_CONTROL )
965 if ( dynamic_cast< EditBrowseBox* >(pBase) )
966 aTypeSuffix.AppendAscii( "/BrowseBox", 10 );
967 else if ( dynamic_cast< ValueSet* >(pBase) )
968 aTypeSuffix.AppendAscii( "/ValueSet", 9 );
969 else if ( dynamic_cast< ORoadmap* >(pBase) )
970 aTypeSuffix.AppendAscii( "/RoadMap", 8 );
971 else if ( dynamic_cast< IExtensionListBox* >(pBase) )
972 aTypeSuffix.AppendAscii( "/ExtensionListBox" );
973 else
974 aTypeSuffix.AppendAscii( "/Unknown", 8 );
977 SmartId aId = pBase->GetSmartUniqueOrHelpId();
978 if ( aId.HasString() || ( nConf & DH_MODE_ALLWIN ) )
979 pRet->GenReturn ( RET_WinInfo, SmartId( aId.GetStr() ), (comm_ULONG)pBase->GetType(),
980 TypeString(pBase->GetType()).Append(aTypeSuffix).AppendAscii(": ").Append(aName), FALSE );
981 if ( !aId.HasString() || ( nConf & DH_MODE_ALLWIN ) )
982 pRet->GenReturn ( RET_WinInfo, SmartId( aId.GetNum() ), (comm_ULONG)pBase->GetType(),
983 TypeString(pBase->GetType()).Append(aTypeSuffix).AppendAscii(": ").Append(aName), FALSE );
986 if ( pBase->GetType() == WINDOW_TOOLBOX ) // Buttons und Controls auf Toolboxen.
988 ToolBox *pTB = ((ToolBox*)pBase);
989 USHORT i;
990 for ( i = 0; i < pTB->GetItemCount() ; i++ )
992 aName = String();
993 // if ( aName.Len() == 0 )
994 // aName = pTB->GetQuickHelpText();
995 if ( aName.Len() == 0 )
996 aName = pTB->GetHelpText( pTB->GetItemId( i ) );
997 if ( aName.Len() == 0 )
998 aName = pTB->GetItemText( pTB->GetItemId( i ) );
1000 Window *pItemWin;
1001 pItemWin = pTB->GetItemWindow( pTB->GetItemId( i ) );
1002 if ( pTB->GetItemType( i ) == TOOLBOXITEM_BUTTON && ( !pItemWin || !pItemWin->IsVisible() ) )
1004 if ( pTB->GetItemCommand(pTB->GetItemId( i )).Len() || ( nConf & DH_MODE_ALLWIN ) )
1005 pRet->GenReturn ( RET_WinInfo, SmartId( pTB->GetItemCommand(pTB->GetItemId( i )) ), (comm_ULONG)WINDOW_BUTTON,
1006 TypeString(WINDOW_BUTTON).AppendAscii(": ").Append(aName), FALSE );
1007 if ( !pTB->GetItemCommand(pTB->GetItemId( i )).Len() || ( nConf & DH_MODE_ALLWIN ) )
1008 pRet->GenReturn ( RET_WinInfo, SmartId( pTB->GetHelpId(pTB->GetItemId( i )) ), (comm_ULONG)WINDOW_BUTTON,
1009 TypeString(WINDOW_BUTTON).AppendAscii(": ").Append(aName), FALSE );
1011 else
1013 if ( pItemWin )
1015 if ( pTB->GetItemCommand(pTB->GetItemId( i )).Len() || ( nConf & DH_MODE_ALLWIN ) )
1016 pRet->GenReturn ( RET_WinInfo, SmartId( pTB->GetItemCommand(pTB->GetItemId( i )) ), (comm_ULONG)pItemWin->GetType(),
1017 TypeString(pItemWin->GetType()).AppendAscii(": ").Append(aName), FALSE );
1018 if ( !pTB->GetItemCommand(pTB->GetItemId( i )).Len() || ( nConf & DH_MODE_ALLWIN ) )
1019 pRet->GenReturn ( RET_WinInfo, SmartId( pTB->GetHelpId(pTB->GetItemId( i )) ), (comm_ULONG)pItemWin->GetType(),
1020 TypeString(pItemWin->GetType()).AppendAscii(": ").Append(aName), FALSE );
1021 USHORT ii;
1022 for( ii = 0 ; ii < pItemWin->GetChildCount(); ii++ )
1023 WriteControlData( pItemWin->GetChild(ii), nConf, FALSE );
1025 else
1027 if ( nConf & DH_MODE_ALLWIN )
1029 String aToolBoxItemType;
1030 switch ( pTB->GetItemType( i ) )
1032 case TOOLBOXITEM_DONTKNOW:
1033 aToolBoxItemType.AssignAscii("TOOLBOXITEM_DONTKNOW");
1034 break;
1035 case TOOLBOXITEM_BUTTON:
1036 aToolBoxItemType.AssignAscii("TOOLBOXITEM_BUTTON");
1037 break;
1038 case TOOLBOXITEM_SPACE:
1039 aToolBoxItemType.AssignAscii("TOOLBOXITEM_SPACE");
1040 break;
1041 case TOOLBOXITEM_SEPARATOR:
1042 aToolBoxItemType.AssignAscii("TOOLBOXITEM_SEPARATOR");
1043 break;
1044 case TOOLBOXITEM_BREAK:
1045 aToolBoxItemType.AssignAscii("TOOLBOXITEM_BREAK");
1046 break;
1047 default:
1048 DBG_ERROR1( "Unknown TOOLBOXITEM %i", pTB->GetItemType( i ) );
1050 if ( pTB->GetItemCommand(pTB->GetItemId( i )).Len() || ( nConf & DH_MODE_ALLWIN ) )
1051 pRet->GenReturn ( RET_WinInfo, SmartId( pTB->GetItemCommand(pTB->GetItemId( i )) ), (comm_ULONG)WINDOW_BASE,
1052 aToolBoxItemType.AppendAscii(": ").Append(aName), FALSE );
1053 if ( !pTB->GetItemCommand(pTB->GetItemId( i )).Len() || ( nConf & DH_MODE_ALLWIN ) )
1054 pRet->GenReturn ( RET_WinInfo, SmartId( pTB->GetHelpId(pTB->GetItemId( i )) ), (comm_ULONG)WINDOW_BASE,
1055 aToolBoxItemType.AppendAscii(": ").Append(aName), FALSE );
1061 return; // ToolBox ist hier schon komplett abgehandelt.
1065 if ( pBase->GetType() == WINDOW_BUTTONDIALOG // Buttons auf Buttondialogen mit ID
1066 || pBase->GetType() == WINDOW_MESSBOX
1067 || pBase->GetType() == WINDOW_INFOBOX
1068 || pBase->GetType() == WINDOW_WARNINGBOX
1069 || pBase->GetType() == WINDOW_ERRORBOX
1070 || pBase->GetType() == WINDOW_QUERYBOX )
1072 ButtonDialog *pBD = ((ButtonDialog*)pBase);
1073 USHORT i;
1074 for ( i = 0; i < pBD->GetButtonCount() ; i++ )
1076 aName = String();
1077 if ( aName.Len() == 0 )
1078 aName = pBD->GetPushButton( pBD->GetButtonId(i) )->GetText();
1079 String aID;
1080 switch ( pBD->GetButtonId(i) )
1082 case BUTTONID_OK:
1083 aID.AssignAscii("Ok");
1084 break;
1085 case BUTTONID_CANCEL:
1086 aID.AssignAscii("Cancel");
1087 break;
1088 case BUTTONID_YES:
1089 aID.AssignAscii("Yes");
1090 break;
1091 case BUTTONID_NO:
1092 aID.AssignAscii("No");
1093 break;
1094 case BUTTONID_RETRY:
1095 aID.AssignAscii("Retry");
1096 break;
1097 case BUTTONID_HELP:
1098 aID.AssignAscii("Help");
1099 break;
1100 default:
1101 aID = UniString::CreateFromInt32( pBD->GetButtonId(i) );
1102 break;
1105 pRet->GenReturn ( RET_WinInfo, SmartId( aID ), (comm_ULONG)pBD->GetPushButton( pBD->GetButtonId(i) )->GetType(), // So daß der Text angezeigt wird!
1106 TypeString(pBD->GetPushButton( pBD->GetButtonId(i) )->GetType()).AppendAscii(": ").Append(aName)
1107 .AppendAscii(" ButtonId = ").Append(aID), FALSE );
1110 return; // ButtonDialog ist hier schon komplett abgehandelt.
1114 Menu* pMenu = GetMatchingMenu( pBase );
1116 if ( pMenu ) // Menus
1118 USHORT i;
1119 for ( i = 0; i < pMenu->GetItemCount() ; i++ )
1121 USHORT nID = pMenu->GetItemId( i );
1123 aName = String();
1124 if ( aName.Len() == 0 )
1125 aName = pMenu->GetHelpText( nID );
1126 if ( aName.Len() == 0 )
1127 aName = pMenu->GetItemText( nID );
1130 if ( pMenu->GetItemType( i ) == MENUITEM_STRING || pMenu->GetItemType( i ) == MENUITEM_IMAGE || pMenu->GetItemType( i ) == MENUITEM_STRINGIMAGE || (nConf & DH_MODE_ALLWIN) )
1132 String aMenuItemType;
1133 switch ( pMenu->GetItemType( i ) )
1135 case MENUITEM_STRING:
1136 aMenuItemType.AssignAscii("MENUITEM_STRING");
1137 break;
1138 case MENUITEM_STRINGIMAGE:
1139 aMenuItemType.AssignAscii("MENUITEM_STRINGIMAGE");
1140 break;
1141 case MENUITEM_IMAGE:
1142 aMenuItemType.AssignAscii("MENUITEM_IMAGE");
1143 break;
1144 case MENUITEM_SEPARATOR:
1145 aMenuItemType.AssignAscii("MENUITEM_SEPARATOR");
1146 break;
1147 case MENUITEM_DONTKNOW:
1148 aMenuItemType.AssignAscii("MENUITEM_DONTKNOW");
1149 break;
1150 default:
1151 DBG_ERROR1( "Unknown MENUITEM %i", pMenu->GetItemType( i ) );
1153 if ( pMenu->GetItemCommand(nID).Len() || ( nConf & DH_MODE_ALLWIN ) )
1154 pRet->GenReturn ( RET_WinInfo, SmartId( pMenu->GetItemCommand(nID) ), (comm_ULONG)0,
1155 aMenuItemType.AppendAscii(": ").Append(aName), FALSE );
1156 if ( !pMenu->GetItemCommand(nID).Len() || ( nConf & DH_MODE_ALLWIN ) )
1157 pRet->GenReturn ( RET_WinInfo, SmartId( nID ), (comm_ULONG)0,
1158 aMenuItemType.AppendAscii(": ").Append(aName), FALSE );
1162 return; // Menu ist hier schon komplett abgehandelt.
1167 for( USHORT i = 0 ; i < pBase->GetChildCount(); i++ )
1168 WriteControlData( pBase->GetChild(i), nConf, FALSE );
1171 class SysWinContainer : public WorkWindow
1173 private:
1174 ToolBox *pClientWin;
1175 DockingWindow *pDock;
1176 public:
1177 SysWinContainer( ToolBox *pClient );
1178 ~SysWinContainer();
1179 virtual void Resize();
1180 virtual void Resizing( Size& rSize );
1183 SysWinContainer::SysWinContainer( ToolBox *pClient )
1184 : WorkWindow( NULL, WB_BORDER | WB_SIZEMOVE | WB_CLOSEABLE )
1185 , pClientWin( pClient )
1187 pDock = new DockingWindow( this );
1188 pClientWin->SetParent( pDock );
1189 pClientWin->SetFloatingMode( FALSE );
1190 SetText( pClient->GetText() );
1191 SetPosPixel( Point( 1,40 ) );
1192 Resize();
1193 pDock->Show();
1194 EnableAlwaysOnTop();
1195 Show();
1198 SysWinContainer::~SysWinContainer()
1200 delete pDock;
1203 void SysWinContainer::Resize()
1205 Size aSize( GetOutputSizePixel() );
1206 Resizing( aSize );
1207 // aSize = pClientWin->GetSizePixel();
1208 // aSize = pClientWin->CalcWindowSizePixel();
1209 if ( aSize != GetSizePixel() )
1211 SetOutputSizePixel( aSize );
1212 pDock->SetSizePixel( aSize );
1213 pClientWin->SetSizePixel( aSize );
1217 void SysWinContainer::Resizing( Size& rSize )
1219 Size aSize;
1220 Size aBestSize;
1221 USHORT i;
1222 BOOL bHasValue = FALSE;
1223 ULONG nBestValue = 0;
1224 ULONG nThisValue;
1225 for ( i=1 ; i<=1 ; i++ )
1227 aSize = pClientWin->CalcWindowSizePixel( i );
1228 nThisValue = Abs( aSize.Width() - rSize.Width() ) + Abs( aSize.Height() - rSize.Height() );
1229 if ( !bHasValue || ( nThisValue < nBestValue ) )
1231 nBestValue = nThisValue;
1232 aBestSize = aSize;
1233 bHasValue = TRUE;
1236 rSize = aBestSize;
1240 class DisplayHidWin : public ToolBox
1242 Edit *pEdit;
1243 Size aMinEditSize;
1244 USHORT nLastItemID;
1245 BOOL bIsDraging;
1246 BOOL bIsPermanentDraging;
1247 void SetDraging( BOOL bNewDraging );
1248 Image *pShow, *pShow2;
1249 BOOL bConfigChanged;
1250 void EnableButtons( ULONG nConf );
1252 ULONG nEventHookID;
1253 static long stub_VCLEventHookProc( NotifyEvent& rEvt, void* pData )
1255 return ((DisplayHidWin*)pData)->VCLEventHook( rEvt );
1258 long VCLEventHook( NotifyEvent& rEvt );
1259 Window *pLastMouseMoveWin;
1261 SysWinContainer *pContainer;
1263 // aborting by pressing shist twice
1264 BOOL bOldShift;
1265 Time aLatest;
1266 USHORT nShiftCount;
1268 public:
1269 DisplayHidWin();
1270 ~DisplayHidWin();
1272 virtual void Tracking( const TrackingEvent& rTEvt );
1273 virtual void Click();
1274 virtual void Select();
1275 virtual void SetText( const XubString& rStr );
1277 void SetDisplayText( const String &aNewText ){ pEdit->SetText(aNewText); }
1278 String GetDisplayText() const { return pEdit->GetText(); }
1279 BOOL IsDisplayTextModified() const { return pEdit->IsModified(); }
1280 void ClearDisplayTextModified() const { pEdit->ClearModifyFlag(); }
1282 void SetConfig( ULONG nConf );
1283 ULONG GetConfig();
1285 BOOL IsConfigChanged() { return bConfigChanged; }
1286 void ConfigSent() { bConfigChanged = FALSE; }
1288 BOOL IsSendData() { return GetItemState( TT_SEND_DATA ) == STATE_CHECK; }
1289 // BOOL IsAllWin() { return GetItemState( TT_ALLWIN ) == STATE_CHECK; }
1291 BOOL IsDraging() { return bIsDraging; }
1293 Window* LastMouseMoveWin() { return pLastMouseMoveWin; }
1296 DisplayHidWin::DisplayHidWin()
1297 : ToolBox( StatementList::GetFirstDocFrame(), TTProperties::GetSvtResId(DisplayHidToolBox) )
1298 , bIsDraging( FALSE )
1299 , bIsPermanentDraging( FALSE )
1300 , pShow( NULL )
1301 , pShow2( NULL )
1302 , pLastMouseMoveWin( NULL )
1303 , bOldShift( 0 )
1304 , nShiftCount( 0 )
1306 SetOutStyle( TOOLBOX_STYLE_HANDPOINTER | TOOLBOX_STYLE_FLAT );
1307 pEdit = new Edit( this, WB_CENTER | WB_BORDER );
1308 aMinEditSize = GetItemRect( TT_OUTPUT ).GetSize();
1309 /**/ aMinEditSize=Size(20,20);
1310 aMinEditSize.Width() *= 12;
1311 pEdit->SetSizePixel( aMinEditSize );
1312 pEdit->Show();
1313 SetItemWindow( TT_OUTPUT, pEdit );
1314 Resize();
1315 pContainer = new SysWinContainer( this );
1316 nEventHookID = Application::AddEventHook( stub_VCLEventHookProc, this );
1319 DisplayHidWin::~DisplayHidWin()
1321 Application::RemoveEventHook( nEventHookID );
1322 Hide(); // so GetFirstDocFrame won't return ourselves (needed for SOPlayer)
1323 SetParent( StatementList::GetFirstDocFrame() );
1324 delete pContainer;
1325 delete pEdit;
1328 void DisplayHidWin::SetDraging( BOOL bNewDraging )
1330 if ( !pShow )
1331 pShow = new Image( GetItemImage( TT_SHOW ) );
1332 if ( !pShow2 )
1333 pShow2 = new Image( Bitmap( TTProperties::GetSvtResId( TT_SHOW2 ) ) );
1335 if ( bNewDraging )
1336 SetItemImage( TT_SHOW, *pShow2 );
1337 else
1338 SetItemImage( TT_SHOW, *pShow );
1340 bIsDraging = bNewDraging;
1343 void DisplayHidWin::EnableButtons( ULONG nConf )
1345 BOOL bSend = BOOL(nConf & DH_MODE_SEND_DATA);
1346 EnableItem( TT_ALLWIN, bSend );
1347 EnableItem( TT_KURZNAME, bSend );
1348 EnableItem( TT_LANGNAME, bSend );
1351 void DisplayHidWin::Tracking( const TrackingEvent& rTEvt )
1353 // if ( nLastItemID == TT_SHOW && GetItemState( TT_SHOW ) == STATE_NOCHECK && ( rTEvt.IsTrackingEnded() || rTEvt.IsTrackingCanceled() ) )
1354 // SetDraging( FALSE );
1355 if ( nLastItemID == TT_SHOW && GetItemState( TT_SHOW ) == STATE_NOCHECK )
1356 EndTracking( ENDTRACK_CANCEL );
1357 ToolBox::Tracking( rTEvt);
1360 void DisplayHidWin::Click()
1362 nLastItemID = GetCurItemId();
1363 if ( nLastItemID == TT_SHOW )
1365 SetDraging( TRUE );
1367 ToolBox::Click();
1370 void DisplayHidWin::Select()
1372 if ( GetItemState( GetCurItemId() ) == STATE_NOCHECK )
1374 SetItemState( GetCurItemId(), STATE_CHECK );
1375 if ( GetCurItemId() == TT_SHOW )
1377 bIsPermanentDraging = TRUE;
1378 SetDraging( TRUE );
1381 else
1383 SetItemState( GetCurItemId(), STATE_NOCHECK );
1384 if ( GetCurItemId() == TT_SHOW )
1386 bIsPermanentDraging = FALSE;
1387 SetDraging( FALSE );
1390 if ( GetCurItemId() == TT_SEND_DATA )
1392 EnableButtons( GetConfig() );
1396 void DisplayHidWin::SetConfig( ULONG nConf )
1398 SetItemState( TT_KURZNAME, ( nConf & DH_MODE_KURZNAME ) ? STATE_CHECK : STATE_NOCHECK );
1399 SetItemState( TT_LANGNAME, ( nConf & DH_MODE_LANGNAME ) ? STATE_CHECK : STATE_NOCHECK );
1400 SetItemState( TT_ALLWIN, ( nConf & DH_MODE_ALLWIN ) ? STATE_CHECK : STATE_NOCHECK );
1401 SetItemState( TT_SEND_DATA, ( nConf & DH_MODE_SEND_DATA ) ? STATE_CHECK : STATE_NOCHECK );
1402 EnableButtons( nConf );
1405 ULONG DisplayHidWin::GetConfig()
1407 ULONG nConf = 0;
1408 if ( GetItemState( TT_KURZNAME ) == STATE_CHECK )
1409 nConf |= DH_MODE_KURZNAME;
1410 if ( GetItemState( TT_LANGNAME ) == STATE_CHECK )
1411 nConf |= DH_MODE_LANGNAME;
1412 if ( GetItemState( TT_ALLWIN ) == STATE_CHECK )
1413 nConf |= DH_MODE_ALLWIN;
1414 if ( IsSendData() )
1415 nConf |= DH_MODE_SEND_DATA;
1417 return nConf;
1420 void DisplayHidWin::SetText( const XubString& rStr )
1422 pContainer->SetText( rStr );
1425 long DisplayHidWin::VCLEventHook( NotifyEvent& rEvt )
1427 if ( EVENT_MOUSEMOVE == rEvt.GetType() )
1429 pLastMouseMoveWin = rEvt.GetWindow();
1431 // check if abort with pressing shift twice
1432 MouseEvent* pMEvt = (MouseEvent*)rEvt.GetMouseEvent();
1434 if ( ( pMEvt->IsShift() && !bOldShift ) ) // Shift pressed
1436 if ( aLatest < Time() )
1438 nShiftCount = 0;
1439 aLatest = Time()+Time( 0, 0, 0, 50 );
1441 nShiftCount++;
1443 if ( ( !pMEvt->IsShift() && bOldShift ) ) // Shift released
1445 nShiftCount++;
1446 if ( nShiftCount == 4 && aLatest > Time() )
1448 bIsPermanentDraging = FALSE;
1449 SetDraging( FALSE );
1450 SetItemState( TT_SHOW, STATE_NOCHECK );
1453 bOldShift = pMEvt->IsShift();
1455 if ( ( ( EVENT_MOUSEBUTTONUP == rEvt.GetType() && rEvt.GetMouseEvent()->GetButtons() == MOUSE_LEFT) || ( EVENT_MOUSEMOVE == rEvt.GetType() && !rEvt.GetMouseEvent()->GetButtons() ) )
1456 && IsDraging() && !bIsPermanentDraging )
1457 SetDraging( FALSE );
1458 return 0;
1462 BOOL StatementCommand::DisplayHID()
1464 // Return TRUE -> reexecute command
1466 if ( !bBool2 ) // Wird auf FALSE initialisiert
1468 bBool2 = TRUE; // Wir sind initialisiert.
1469 GetTTSettings()->pDisplayInstance = this; // Und haben die Macht (Alle anderen beenden sich)
1471 if ( !(nParams & PARAM_ULONG_1) )
1473 if( GetTTSettings()->pDisplayHidWin ) // Nichts verändern
1474 nLNr1 = GetTTSettings()->pDisplayHidWin->GetConfig();
1475 else // Beim ersten Aufruf wollen wir alles richtig einstellen
1476 nLNr1 = DH_MODE_KURZNAME | DH_MODE_LANGNAME;
1478 if( ((nParams & PARAM_BOOL_1) && bBool1) )
1479 nLNr1 |= DH_MODE_SEND_DATA;
1480 else
1481 nLNr1 &= ( ~DH_MODE_SEND_DATA );
1484 if ( GetTTSettings()->pDisplayHidWin )
1485 GetTTSettings()->pDisplayHidWin->SetConfig( nLNr1 );
1488 if ( GetTTSettings()->pDisplayInstance && GetTTSettings()->pDisplayInstance != this )
1490 DBG_WARNING("Mehrere DisplayHID am laufen");
1491 return FALSE; // Noch eine andere Instanz macht das gleiche!
1494 if ( !GetTTSettings()->pDisplayHidWin )
1496 GetTTSettings()->pDisplayHidWin = new DisplayHidWin();
1497 GetTTSettings()->aOriginalCaption = GetTTSettings()->pDisplayHidWin->GetText();
1498 GetTTSettings()->pDisplayHidWin->Show();
1499 if ( bBool1 )
1500 nLNr1 |= DH_MODE_SEND_DATA;
1501 GetTTSettings()->pDisplayHidWin->SetConfig( nLNr1 );
1503 GetTTSettings()->Old = NULL;
1504 GetTTSettings()->Act = NULL;
1505 GetTTSettings()->pDisplayInstance = this;
1507 else
1509 GetTTSettings()->pDisplayHidWin->GetWindow( WINDOW_OVERLAP )->Enable( TRUE, TRUE );
1510 GetTTSettings()->pDisplayHidWin->GetWindow( WINDOW_OVERLAP )->EnableInput( TRUE, TRUE );
1514 if ( GetTTSettings()->pDisplayHidWin->IsVisible() && !bDying )
1517 if ( GetTTSettings()->pDisplayHidWin->IsDraging() )
1521 #define HIGHLIGHT_WIN( WinPtr ) \
1523 Color aLineColMem = WinPtr->GetLineColor(); \
1524 WinPtr->SetLineColor( Color( COL_WHITE ) ); \
1525 Color aFillColMem = WinPtr->GetFillColor(); \
1526 WinPtr->SetFillColor( Color( COL_LIGHTRED ) ); \
1527 RasterOp aROp = WinPtr->GetRasterOp(); \
1528 WinPtr->SetRasterOp( ROP_XOR ); \
1529 Size aSz = WinPtr->PixelToLogic( WinPtr->GetSizePixel() );\
1530 ULONG nMaxCornerRadius = WinPtr->PixelToLogic( Point( 80, 0 ) ).X();\
1531 ULONG iCorner = std::max ((ULONG) 8, (ULONG) std::min( nMaxCornerRadius, (ULONG) std::min((ULONG) (aSz.Width() / 6), (ULONG)(aSz.Height() / 6))));\
1532 WinPtr->DrawRect(Rectangle(Point(),aSz), iCorner, iCorner);\
1533 WinPtr->SetLineColor( aLineColMem ); \
1534 WinPtr->SetFillColor( aFillColMem ); \
1535 WinPtr->SetRasterOp( aROp ); \
1539 #define SET_WIN( WinPtr ) \
1540 if ( StatementList::WinPtrValid(WinPtr) ) \
1542 HIGHLIGHT_WIN ( WinPtr ); \
1545 #define RESET_WIN( WinPtr ) \
1546 if ( StatementList::WinPtrValid(WinPtr) ) \
1548 WinPtr->Invalidate( INVALIDATE_NOTRANSPARENT ); \
1549 WinPtr->Update(); \
1553 GetTTSettings()->Old = GetTTSettings()->Act;
1554 // GetTTSettings()->Act = GetMouseWin();
1555 GetTTSettings()->Act = GetTTSettings()->pDisplayHidWin->LastMouseMoveWin();
1557 if ( !StatementList::WinPtrValid ( GetTTSettings()->Old ) )
1558 GetTTSettings()->Old = NULL;
1559 if ( !StatementList::WinPtrValid ( GetTTSettings()->Act ) )
1560 GetTTSettings()->Act = NULL;
1562 if ( GetTTSettings()->Act && GetTTSettings()->Act->GetType() == WINDOW_BORDERWINDOW )
1563 GetTTSettings()->Act = GetTTSettings()->Act->GetWindow( WINDOW_CLIENT );
1565 if ( GetTTSettings()->Act != GetTTSettings()->Old )
1567 if ( GetTTSettings()->Old )
1569 RESET_WIN(GetTTSettings()->Old);
1571 if ( GetTTSettings()->Act )
1573 SET_WIN(GetTTSettings()->Act);
1574 GetTTSettings()->pDisplayHidWin->SetDisplayText(GetTTSettings()->Act->GetSmartUniqueOrHelpId().GetText().AppendAscii(" WinType: ")
1575 .Append(UniString::CreateFromInt64(GetTTSettings()->Act->GetType())).AppendAscii(" ").Append(GetTTSettings()->Act->GetText()));
1576 if ( GetTTSettings()->Act && !GetTTSettings()->Act->GetSmartUniqueId().Equals( GetTTSettings()->Act->GetSmartHelpId() ) )
1577 GetTTSettings()->pDisplayHidWin->SetText(UniString( TTProperties::GetSvtResId( TT_ALTERNATE_CAPTION ) ).Append(GetTTSettings()->Act->GetSmartHelpId().GetText()));
1578 else
1579 GetTTSettings()->pDisplayHidWin->SetText( GetTTSettings()->aOriginalCaption );
1581 else
1582 GetTTSettings()->pDisplayHidWin->SetDisplayText(CUniString("Kein Window/Control gefunden"));
1584 else if ( GetTTSettings()->Act )
1586 // SET_WIN(GetTTSettings()->Act);
1587 if ( GetTTSettings()->pDisplayHidWin->IsDisplayTextModified() && GetTTSettings()->pDisplayHidWin->GetDisplayText().Len() > 0 )
1589 GetTTSettings()->Act->SetSmartUniqueId( SmartId( GetTTSettings()->pDisplayHidWin->GetDisplayText().ToInt32() ) );
1590 GetTTSettings()->pDisplayHidWin->ClearDisplayTextModified();
1593 /* if ( Application::GetLastInputInterval() > 5000 ) // 5 Sekunden lang nix geschehen
1595 GetTTSettings()->pDisplayHidWin->ToTop( TOTOP_NOGRABFOCUS );
1598 if ( GetTTSettings()->pDisplayHidWin->IsSendData() /*&& bBool2*/ && GetTTSettings()->Act )
1600 if ( !StatementFlow::bSending )
1601 { // Normalerweise syncronisierung über Protokoll. Hier ist das aber asyncron!!!
1602 WriteControlData( GetTTSettings()->Act, GetTTSettings()->pDisplayHidWin->GetConfig() );
1603 new StatementFlow( this, F_EndCommandBlock ); // Kommando zum Senden erzeugen und in que eintragen
1606 } //if ( GetTTSettings()->pDisplayHidWin->IsDraging() )
1607 else
1609 if ( GetTTSettings()->Act )
1611 RESET_WIN(GetTTSettings()->Act);
1612 GetTTSettings()->Act = NULL;
1616 if ( pFirst == this ) // Sollte immer so sein, aber besser isses
1617 if ( pNext ) // Befehle warten auf Ausführung
1618 { // An Ende neu einsortieren
1619 Advance();
1620 QueStatement( NULL );
1622 // { // Ersten und 2. austauschen.
1623 // pFirst = pNext;
1624 // pNext = pNext->pNext;
1625 // pFirst->pNext = this;
1626 // }
1629 else
1631 delete GetTTSettings()->pDisplayHidWin;
1632 GetTTSettings()->pDisplayHidWin = NULL;
1633 GetTTSettings()->pDisplayInstance = NULL;
1636 return GetTTSettings()->pDisplayHidWin != NULL;
1639 class TranslateWin : public WorkWindow
1641 private:
1642 DECL_LINK( DoAccept, PushButton* );
1643 DECL_LINK( DoNext, PushButton* );
1644 DECL_LINK( DoSelect, PushButton* );
1645 DECL_LINK( DoRestore, PushButton* );
1646 DECL_LINK( TranslationChanged, Edit* );
1647 DECL_LINK( ShowInplace, Timer* );
1649 Timer InplaceTimer;
1651 // virtual void MouseButtonUp( const MouseEvent& rMEvt );
1652 // virtual void MouseMove( const MouseEvent& rMEvt );
1654 PushButton PushButtonTT_PB_NEXT;
1655 GroupBox GroupBoxTT_GB_TRANSLATION;
1656 Edit EditTT_E_NEW;
1657 GroupBox GroupBoxTT_GB_COMMENT;
1658 Edit EditTT_E_COMMENT;
1659 PushButton PushButtonTT_PB_ACCEPT;
1660 FixedText FixedTextTT_FT_OLD;
1661 PushButton PushButtonTT_PB_SELECT;
1662 PushButton PushButtonTT_PB_RESTORE;
1664 Window *Old;
1665 Window *Act;
1666 Window *pTranslateWin;
1667 BOOL bSelecting;
1669 BOOL bAvailable;
1670 BOOL bNext;
1672 BOOL TestChangedDataSaved();
1675 ULONG nEventHookID;
1676 static long stub_VCLEventHookProc( NotifyEvent& rEvt, void* pData )
1678 return ((TranslateWin*)pData)->VCLEventHook( rEvt );
1681 long VCLEventHook( NotifyEvent& rEvt );
1683 public:
1684 TranslateWin();
1685 ~TranslateWin();
1687 static String MarkShortcutErrors( Window* pBase, BOOL bMark );
1689 BOOL IsTranslationAvailable(){ return bAvailable; }
1690 BOOL IsNextDialog(){ return bNext; }
1691 void ResetNextDialog(){ bNext = FALSE; }
1693 Window* GetTranslationWindow(){ return pTranslateWin; }
1694 String GetOriginalText(){ return FixedTextTT_FT_OLD.GetText(); }
1695 String GetTranslationText(){ return EditTT_E_NEW.GetText(); }
1696 String GetComment(){ return EditTT_E_COMMENT.GetText(); }
1698 void EnableTranslation();
1701 TranslateWin::TranslateWin()
1702 : WorkWindow( NULL, TTProperties::GetSvtResId( TT_INLINE_TRANSLATION ) )
1703 , PushButtonTT_PB_NEXT( this, TTProperties::GetSvtResId( TT_PB_NEXT ) )
1704 , GroupBoxTT_GB_TRANSLATION( this, TTProperties::GetSvtResId( TT_GB_TRANSLATION ) )
1705 , EditTT_E_NEW( this, TTProperties::GetSvtResId( TT_E_NEW ) )
1706 , GroupBoxTT_GB_COMMENT( this, TTProperties::GetSvtResId( TT_GB_COMMENT ) )
1707 , EditTT_E_COMMENT( this, TTProperties::GetSvtResId( TT_E_COMMENT ) )
1708 , PushButtonTT_PB_ACCEPT( this, TTProperties::GetSvtResId( TT_PB_ACCEPT ) )
1709 , FixedTextTT_FT_OLD( this, TTProperties::GetSvtResId( TT_FT_OLD ) )
1710 , PushButtonTT_PB_SELECT( this, TTProperties::GetSvtResId( TT_PB_SELECT ) )
1711 , PushButtonTT_PB_RESTORE( this, TTProperties::GetSvtResId( TT_PB_RESTORE ) )
1712 , Old( NULL )
1713 , Act( NULL )
1714 , pTranslateWin( NULL )
1715 , bSelecting( FALSE )
1716 , bAvailable( FALSE )
1717 , bNext( FALSE )
1719 FreeResource();
1720 PushButtonTT_PB_NEXT.SetClickHdl( LINK( this, TranslateWin, DoNext ) );
1721 PushButtonTT_PB_ACCEPT.SetClickHdl( LINK( this, TranslateWin, DoAccept ) );
1722 PushButtonTT_PB_SELECT.SetClickHdl( LINK( this, TranslateWin, DoSelect ) );
1723 PushButtonTT_PB_RESTORE.SetClickHdl( LINK( this, TranslateWin, DoRestore ) );
1724 EditTT_E_NEW.SetModifyHdl( LINK( this, TranslateWin, TranslationChanged ) );
1725 InplaceTimer.SetTimeout( 250 );
1726 InplaceTimer.SetTimeoutHdl( LINK( this, TranslateWin, ShowInplace ) );
1727 EnableAlwaysOnTop();
1728 nEventHookID = Application::AddEventHook( stub_VCLEventHookProc, this );
1731 TranslateWin::~TranslateWin()
1733 Application::RemoveEventHook( nEventHookID );
1736 BOOL TranslateWin::TestChangedDataSaved()
1738 if ( ( EditTT_E_NEW.GetText().CompareTo( FixedTextTT_FT_OLD.GetText() ) != COMPARE_EQUAL
1739 || EditTT_E_COMMENT.GetText().Len() )
1740 && PushButtonTT_PB_ACCEPT.IsEnabled() )
1742 return MessBox( this, TTProperties::GetSvtResId( TT_DISCARD_CHANGED_DATA ) ).Execute() == RET_YES;
1744 else
1745 return TRUE;
1748 IMPL_LINK( TranslateWin, DoAccept, PushButton*, EMPTYARG )
1750 PushButtonTT_PB_SELECT.Disable();
1751 PushButtonTT_PB_NEXT.Disable();
1752 PushButtonTT_PB_RESTORE.Disable();
1753 EditTT_E_NEW.Disable();
1754 EditTT_E_COMMENT.Disable();
1755 PushButtonTT_PB_ACCEPT.Disable();
1756 bAvailable = TRUE;
1757 return 0;
1760 IMPL_LINK( TranslateWin, DoNext, PushButton*, EMPTYARG )
1762 if ( TestChangedDataSaved() )
1764 PushButtonTT_PB_SELECT.Disable();
1765 PushButtonTT_PB_NEXT.Disable();
1766 PushButtonTT_PB_RESTORE.Disable();
1767 EditTT_E_NEW.Disable();
1768 EditTT_E_COMMENT.Disable();
1769 PushButtonTT_PB_ACCEPT.Disable();
1770 bNext = TRUE;
1772 return 0;
1775 IMPL_LINK( TranslateWin, DoSelect, PushButton*, EMPTYARG )
1777 if ( bSelecting )
1779 // ReleaseMouse();
1780 bSelecting = FALSE;
1782 else
1784 if ( TestChangedDataSaved() )
1786 PushButtonTT_PB_RESTORE.Disable();
1787 // CaptureMouse();
1788 bSelecting = TRUE;
1791 return 0;
1794 IMPL_LINK( TranslateWin, DoRestore, PushButton*, EMPTYARG )
1796 String sTT_E_OLD( FixedTextTT_FT_OLD.GetText());
1797 sTT_E_OLD.SearchAndReplaceAll( CUniString("\\n"), CUniString("\n") );
1798 sTT_E_OLD.SearchAndReplaceAll( CUniString("\\t"), CUniString("\t") );
1800 String sTT_E_NEW( EditTT_E_NEW.GetText());
1801 sTT_E_NEW.SearchAndReplaceAll( CUniString("\\n"), CUniString("\n") );
1802 sTT_E_NEW.SearchAndReplaceAll( CUniString("\\t"), CUniString("\t") );
1804 if ( StatementList::WinPtrValid( pTranslateWin ) && pTranslateWin->GetText().CompareTo( sTT_E_NEW ) == COMPARE_EQUAL )
1805 { // Im ersten schritt nur in der UI zurück
1806 pTranslateWin->SetText( sTT_E_OLD );
1808 else
1809 { // Im zweite Schritt auch den eingegebenen Text
1810 EditTT_E_NEW.SetText( FixedTextTT_FT_OLD.GetText() );
1811 PushButtonTT_PB_RESTORE.Disable();
1813 if ( StatementList::WinPtrValid( pTranslateWin ) )
1814 MarkShortcutErrors( pTranslateWin->GetWindow( WINDOW_OVERLAP ), TRUE );
1815 return 0;
1818 IMPL_LINK( TranslateWin, TranslationChanged, Edit*, pEdit )
1820 (void) pEdit; /* avoid warning about unused parameter */
1821 PushButtonTT_PB_RESTORE.Enable();
1822 InplaceTimer.Start();
1823 return 0;
1826 IMPL_LINK( TranslateWin, ShowInplace, Timer*, EMPTYARG )
1828 PushButtonTT_PB_RESTORE.Enable();
1829 if ( StatementList::WinPtrValid( pTranslateWin ) )
1831 String sTT_E_NEW( EditTT_E_NEW.GetText());
1832 // alle CRs UnQuoten
1833 sTT_E_NEW.SearchAndReplaceAll( CUniString("\\n"), CUniString("\n") );
1834 // alle TABSs UnQuoten
1835 sTT_E_NEW.SearchAndReplaceAll( CUniString("\\t"), CUniString("\t") );
1836 pTranslateWin->SetText( sTT_E_NEW );
1838 MarkShortcutErrors( pTranslateWin->GetWindow( WINDOW_OVERLAP ), TRUE );
1840 return 0;
1843 long TranslateWin::VCLEventHook( NotifyEvent& rEvt )
1845 if ( EVENT_MOUSEMOVE == rEvt.GetType() )
1847 if ( bSelecting )
1849 const MouseEvent *pMEvt = rEvt.GetMouseEvent();
1850 Old = Act;
1851 Act = rEvt.GetWindow();
1853 if ( Act )
1855 Window *pWin = Act;
1856 USHORT i;
1857 for ( i = 0 ; i < Act->GetChildCount() ; i++ )
1859 pWin = Act->GetChild(i);
1860 Rectangle aWinPosSize( pWin->GetPosPixel(), pWin->GetSizePixel() );
1862 if ( ( pWin->IsMouseTransparent() || !pWin->IsEnabled() ) && aWinPosSize.IsInside( pMEvt->GetPosPixel() ) )
1864 Act = pWin;
1865 break;
1870 if ( !StatementList::WinPtrValid ( Old ) )
1871 Old = NULL;
1873 if ( Act != Old )
1875 if ( Old )
1877 Window *pWin;
1878 if ( Old->IsMouseTransparent() && Old->GET_REAL_PARENT() )
1879 pWin = Old->GET_REAL_PARENT();
1880 else
1881 pWin = Old;
1882 RESET_WIN(pWin);
1884 if ( Act )
1886 SET_WIN(Act);
1887 FixedTextTT_FT_OLD.SetText( Act->GetText() );
1889 else
1890 FixedTextTT_FT_OLD.SetText( String() );
1892 else if ( Act )
1894 // SET_WIN(Act);
1896 /* if ( Application::GetLastInputInterval() > 5000 ) // 5 Sekunden lang nix geschehen
1898 ToTop();
1901 } //if ( bSelecting )
1902 else
1904 if ( Act )
1906 if ( Act->IsMouseTransparent() && Act->GET_REAL_PARENT() )
1907 Act = Act->GET_REAL_PARENT();
1908 RESET_WIN(Act);
1909 Act = NULL;
1913 else if ( EVENT_MOUSEBUTTONUP == rEvt.GetType() )
1915 if ( bSelecting )
1917 pTranslateWin = Act;
1918 if ( pTranslateWin )
1920 MarkShortcutErrors( pTranslateWin->GetWindow( WINDOW_OVERLAP ), TRUE );
1921 // alle CRs quoten (NF)
1922 String sTT_E_NEW( pTranslateWin->GetText());
1923 sTT_E_NEW.SearchAndReplaceAll( CUniString("\n"), CUniString("\\n") );
1924 // alle TABSs quoten ()
1925 sTT_E_NEW.SearchAndReplaceAll( CUniString("\t"), CUniString("\\t") );
1927 FixedTextTT_FT_OLD.SetText( sTT_E_NEW );
1928 EditTT_E_NEW.SetText( sTT_E_NEW );
1929 EditTT_E_NEW.Enable();
1930 EditTT_E_NEW.GrabFocus();
1931 EditTT_E_COMMENT.SetText( String() );
1932 EditTT_E_COMMENT.Enable();
1933 PushButtonTT_PB_ACCEPT.Enable();
1935 // ReleaseMouse();
1936 bSelecting = FALSE;
1940 return 0;
1943 #define FDS_ACTION_COLLECT 1
1944 #define FDS_ACTION_MARK 2
1945 #define FDS_ACTION_UNMARK 3
1947 class FindShortcutErrors: public Search
1949 String aShortcuts,aDoubleShortcuts;
1950 USHORT nAction;
1951 public:
1952 FindShortcutErrors();
1953 virtual BOOL IsWinOK( Window *pWin );
1954 void SetAction( USHORT nA );
1955 String GetDoubleShortcuts() { return aDoubleShortcuts; }
1958 FindShortcutErrors::FindShortcutErrors()
1959 : Search( SEARCH_NOOVERLAP | SEARCH_NO_TOPLEVEL_WIN )
1961 SetAction( FDS_ACTION_COLLECT ); // Wir fange immer mit sammeln an, ODER??
1964 void FindShortcutErrors::SetAction( USHORT nA )
1966 nAction = nA;
1967 if ( FDS_ACTION_COLLECT == nAction )
1969 aShortcuts = UniString();
1970 aDoubleShortcuts = UniString();
1974 BOOL FindShortcutErrors::IsWinOK( Window *pWin )
1976 if ( pWin->IsReallyVisible() )
1978 String aText = pWin->GetText();
1979 xub_StrLen nPos = aText.Search('~');
1980 String aShortcut;
1981 BOOL bHasAccel = FALSE;
1982 if ( nPos != STRING_NOTFOUND )
1984 aShortcut = aText.Copy( nPos+1, 1 );
1985 aShortcut.ToLowerAscii();
1986 bHasAccel = aShortcut.Len() == 1;
1989 switch ( nAction )
1991 case FDS_ACTION_COLLECT:
1993 if ( aShortcuts.Search( aShortcut ) != STRING_NOTFOUND )
1994 aDoubleShortcuts += aShortcut;
1995 else
1996 aShortcuts += aShortcut;
1998 break;
1999 case FDS_ACTION_MARK:
2001 BOOL bMissing = FALSE;
2002 if ( !bHasAccel && aText.Len() ) // should there be an accelarator defined
2005 Window* pChild;
2006 pChild = pWin->GetWindow( WINDOW_CLIENT );
2008 if ( (pChild->GetType() == WINDOW_RADIOBUTTON) ||
2009 (pChild->GetType() == WINDOW_IMAGERADIOBUTTON) ||
2010 (pChild->GetType() == WINDOW_CHECKBOX) ||
2011 (pChild->GetType() == WINDOW_TRISTATEBOX) ||
2012 (pChild->GetType() == WINDOW_PUSHBUTTON) )
2014 if ( !pChild->GetText().EqualsAscii( "..." ) )
2015 bMissing = TRUE;
2018 if ( pChild->GetType() == WINDOW_FIXEDTEXT )
2020 Window* pTempChild = pWin->GetWindow( WINDOW_NEXT );
2021 if ( pTempChild )
2022 pTempChild = pTempChild->GetWindow( WINDOW_CLIENT );
2024 if ( pTempChild && pChild->GetText().Len() )
2026 if ( (pTempChild->GetType() == WINDOW_EDIT) ||
2027 (pTempChild->GetType() == WINDOW_MULTILINEEDIT) ||
2028 (pTempChild->GetType() == WINDOW_SPINFIELD) ||
2029 (pTempChild->GetType() == WINDOW_PATTERNFIELD) ||
2030 (pTempChild->GetType() == WINDOW_NUMERICFIELD) ||
2031 (pTempChild->GetType() == WINDOW_METRICFIELD) ||
2032 (pTempChild->GetType() == WINDOW_CURRENCYFIELD) ||
2033 (pTempChild->GetType() == WINDOW_DATEFIELD) ||
2034 (pTempChild->GetType() == WINDOW_TIMEFIELD) ||
2035 (pTempChild->GetType() == WINDOW_LISTBOX) ||
2036 (pTempChild->GetType() == WINDOW_MULTILISTBOX) ||
2037 (pTempChild->GetType() == WINDOW_COMBOBOX) ||
2038 (pTempChild->GetType() == WINDOW_PATTERNBOX) ||
2039 (pTempChild->GetType() == WINDOW_NUMERICBOX) ||
2040 (pTempChild->GetType() == WINDOW_METRICBOX) ||
2041 (pTempChild->GetType() == WINDOW_CURRENCYBOX) ||
2042 (pTempChild->GetType() == WINDOW_DATEBOX) ||
2043 (pTempChild->GetType() == WINDOW_TIMEBOX) )
2045 bMissing = TRUE;
2051 if ( bHasAccel && aDoubleShortcuts.Search( aShortcut ) != STRING_NOTFOUND )
2053 if ( pWin->GetType() == WINDOW_GROUPBOX )
2054 pWin->SetControlForeground( Color( COL_LIGHTRED ) );
2055 else
2057 pWin->SetControlBackground();
2058 Color aCol(COL_GRAY);
2059 aCol.SetRed( 0xff );
2060 pWin->SetControlBackground( aCol );
2063 else if ( bMissing )
2065 pWin->SetControlBackground();
2066 Color aCol(COL_GRAY);
2067 aCol.SetRed( 0xff );
2068 aCol.SetGreen( 0xff );
2069 pWin->SetControlBackground( aCol );
2071 else
2073 pWin->SetControlForeground();
2074 pWin->SetControlBackground();
2077 break;
2078 case FDS_ACTION_UNMARK:
2080 pWin->SetControlForeground();
2081 pWin->SetControlBackground();
2083 break;
2086 else
2087 if ( FDS_ACTION_MARK == nAction || FDS_ACTION_UNMARK == nAction )
2089 pWin->SetControlForeground();
2090 pWin->SetControlBackground();
2093 return FALSE;
2096 String TranslateWin::MarkShortcutErrors( Window* pBase, BOOL bMark )
2098 if ( pBase )
2100 FindShortcutErrors aFinder;
2101 if ( bMark )
2103 StatementList::SearchAllWin( pBase, aFinder, TRUE ); // collect Shortcuts first
2104 aFinder.SetAction( FDS_ACTION_MARK );
2106 else
2107 aFinder.SetAction( FDS_ACTION_UNMARK );
2108 StatementList::SearchAllWin( pBase, aFinder, TRUE );
2109 return aFinder.GetDoubleShortcuts();
2111 return UniString();
2114 void TranslateWin::EnableTranslation()
2116 PushButtonTT_PB_SELECT.Enable();
2117 PushButtonTT_PB_NEXT.Enable();
2118 bAvailable = FALSE;
2119 bNext = FALSE;
2122 void StatementCommand::Translate()
2124 // Es wurde eine initale UniqueId mitgegeben. Dann nur die dopelten Shortcuts liefern
2125 if( (nParams & PARAM_ULONG_1) && nLNr1 )
2127 String aDouble;
2128 Window *pWin = SearchTree( SmartId( nLNr1 ) ,FALSE );
2129 if ( pWin )
2131 pWin = pWin->GetWindow( WINDOW_OVERLAP );
2132 aDouble = TranslateWin::MarkShortcutErrors( pWin, TRUE );
2134 pRet->GenReturn ( RET_Value, aSmartMethodId, aDouble );
2135 return;
2138 if ( !GetTTSettings()->pTranslateWin )
2140 GetTTSettings()->pTranslateWin = new TranslateWin;
2141 GetTTSettings()->bToTop = TRUE;
2144 GetTTSettings()->pTranslateWin->Show();
2145 if ( GetTTSettings()->bToTop )
2147 GetTTSettings()->pTranslateWin->ToTop();
2148 GetTTSettings()->bToTop = FALSE;
2151 // GetTTSettings()->pTranslateWin->GetWindow( WINDOW_OVERLAP )->Enable( TRUE, TRUE );
2152 GetTTSettings()->pTranslateWin->GetWindow( WINDOW_OVERLAP )->EnableInput( TRUE, TRUE );
2154 if ( GetTTSettings()->pTranslateWin->IsTranslationAvailable() )
2156 String aTranslation;
2157 Window* pTranslationWindow = GetTTSettings()->pTranslateWin->GetTranslationWindow();
2159 DBG_ASSERT( pTranslationWindow, "Kein Translation Window" );
2161 if ( WinPtrValid( pTranslationWindow ) )
2163 if ( pTranslationWindow->GetType() == WINDOW_BORDERWINDOW && pTranslationWindow->GetWindow( WINDOW_CLIENT ) )
2165 Window* pNew = pTranslationWindow->GetWindow( WINDOW_CLIENT );
2166 // Bei Dockingwindoes das kanze Geraffel von Docking Floating überspringen
2167 while ( IsDialog( pNew ) && !pNew->GetSmartUniqueOrHelpId().HasAny() && pNew->GetChildCount() == 1 )
2168 pNew = pNew->GetChild( 0 );
2169 pTranslationWindow = pNew;
2172 aTranslation = CUniString("0;");
2174 aTranslation += pTranslationWindow->GetSmartUniqueOrHelpId().GetText();
2175 aTranslation += ';';
2177 aTranslation += TypeString( pTranslationWindow->GetType() );
2178 aTranslation += ';';
2180 Window* pParentDialog = pTranslationWindow;
2181 while ( pParentDialog && !IsDialog( pParentDialog ) )
2183 pParentDialog = pParentDialog->GET_REAL_PARENT();
2186 if ( pParentDialog )
2188 aTranslation += pParentDialog->GetSmartUniqueOrHelpId().GetText();
2189 aTranslation += ';';
2190 aTranslation += TypeString( pParentDialog->GetType() );
2192 else
2193 aTranslation.AppendAscii( "0;" ); // Zahl + leerer String
2194 aTranslation += ';';
2196 aTranslation += '\"';
2197 aTranslation += GetTTSettings()->pTranslateWin->GetOriginalText();
2198 aTranslation += '\"';
2200 aTranslation += ';';
2202 aTranslation += '\"';
2203 aTranslation += GetTTSettings()->pTranslateWin->GetTranslationText();
2204 aTranslation += '\"';
2206 aTranslation += ';';
2208 aTranslation += '\"';
2209 aTranslation += GetTTSettings()->pTranslateWin->GetComment();
2210 aTranslation += '\"';
2212 // alle CRs quoten (NF)
2213 aTranslation.SearchAndReplaceAll( CUniString("\n"), CUniString("\\n") );
2214 // alle TABSs quoten ()
2215 aTranslation.SearchAndReplaceAll( CUniString("\t"), CUniString("\\t") );
2217 pRet->GenReturn ( RET_Value, aSmartMethodId, aTranslation );
2218 GetTTSettings()->pTranslateWin->EnableTranslation();
2219 GetTTSettings()->bToTop = TRUE;
2221 else
2223 pRet->GenReturn ( RET_Value, aSmartMethodId, String() );
2224 GetTTSettings()->pTranslateWin->EnableTranslation();
2225 ErrorBox err( GetTTSettings()->pTranslateWin, TTProperties::GetSvtResId( TT_NO_CONTROL ));
2226 err.Execute();
2227 GetTTSettings()->bToTop = TRUE;
2231 else if ( GetTTSettings()->pTranslateWin->IsNextDialog() )
2233 pRet->GenReturn ( RET_Value, aSmartMethodId, CUniString("1") );
2234 GetTTSettings()->pTranslateWin->ResetNextDialog();
2235 GetTTSettings()->pTranslateWin->LoseFocus();
2236 GetTTSettings()->bToTop = TRUE;
2238 else
2240 GetTTSettings()->pTranslateWin->EnableTranslation();
2241 pRet->GenReturn ( RET_Value, aSmartMethodId, String() );
2245 Window* StatementCommand::GetNextOverlap( Window* pBase )
2246 { // Findet irgendwelche Overlap-Fenster, die schließbar aussehen
2247 // Eventuell muß noch die Auswahl verfeinert werden.
2249 if ( pBase->GetType() != WINDOW_BORDERWINDOW )
2250 pBase = pBase->GetWindow( WINDOW_OVERLAP );
2252 Window *pControl = NULL;
2253 if ( pBase->GetWindow( WINDOW_FIRSTOVERLAP ) )
2255 pControl = GetNextOverlap( pBase->GetWindow( WINDOW_FIRSTOVERLAP ) );
2258 if ( !pControl && pBase->GetWindow( WINDOW_NEXT ) )
2260 pControl = GetNextOverlap( pBase->GetWindow( WINDOW_NEXT ) );
2263 if ( !pControl )
2265 Window *pTest = pBase->GetWindow( WINDOW_CLIENT );
2266 if ( IsAccessable (pTest)
2267 && pTest->IsEnabled()
2268 && pTest->IsVisible()
2269 && ((pTest->GetStyle() & WB_CLOSEABLE ) || (pBase->GetStyle() & WB_CLOSEABLE )) )
2270 return pTest;
2271 else
2272 return NULL;
2274 else
2275 return pControl;
2278 Window* StatementCommand::GetNextRecoverWin()
2280 // über die TopLevelWindows der App iterieren
2281 Window* pBase = Application::GetFirstTopLevelWindow();
2282 Window *pControl = NULL;
2283 Window* pMyFirstDocFrame = NULL;
2284 while ( pBase )
2286 // zuerst weitere Fenster auf dem Fenster suchen und schliessen
2287 pControl = GetNextOverlap( pBase );
2288 if ( pControl && pControl->GetType() == WINDOW_HELPTEXTWINDOW )
2289 {} // skip it
2290 else
2292 if ( pControl && pControl->IsVisible() && !IsFirstDocFrame( pControl ) && !IsIMEWin( pControl ) )
2294 Window* pTB = pControl->GetChild( 0 );
2295 if ( pControl->GetChildCount() == 1 && pTB->GetType() == WINDOW_TOOLBOX )
2296 // return pTB;
2297 ; // do not act on floating toolboxes #i38796
2298 else
2299 return pControl;
2302 // dann das Fenster selbst Schliessen
2303 // erstes DocWin überspringen
2304 // Assumption that Doc Windows are Borderwindows and ButtonDialog and such are not
2305 if ( pBase->IsVisible() && !IsFirstDocFrame( pBase ) && pBase->GetType() != WINDOW_BORDERWINDOW && !IsIMEWin( pBase ) )
2306 return pBase;
2308 if ( !pMyFirstDocFrame && IsFirstDocFrame( pBase ) )
2309 pMyFirstDocFrame = pBase;
2312 pBase = Application::GetNextTopLevelWindow( pBase );
2314 #ifdef RESET_APPLICATION_TO_BACKING_WINDOW
2315 // close the FirstDocFrame last, It will not be closed, but the Document inside will be closed.
2316 if ( IsDocWin( pMyFirstDocFrame ) )
2317 return pMyFirstDocFrame;
2318 #endif // def RESET_APPLICATION_TO_BACKING_WINDOW
2320 return NULL;
2323 BOOL StatementCommand::Execute()
2325 if ( IsError )
2327 #if OSL_DEBUG_LEVEL > 1
2328 m_pDbgWin->AddText( "Skipping Command: " );
2329 m_pDbgWin->AddText( aSmartMethodId.GetText() );
2330 m_pDbgWin->AddText( "\n" );
2331 #endif
2333 Advance();
2334 delete this;
2335 return TRUE;
2338 InitProfile();
2339 #if OSL_DEBUG_LEVEL > 1
2340 m_pDbgWin->AddText( "Executing Command: " );
2341 m_pDbgWin->AddText( aSmartMethodId.GetText() );
2342 m_pDbgWin->AddText( "\n" );
2343 #endif
2349 #if OSL_DEBUG_LEVEL > 1
2350 #define REPORT_WIN_CLOSED(pControl, aInfo) \
2351 _REPORT_WIN_CLOSED(pControl, aInfo) \
2352 m_pDbgWin->AddText( aInfo.AppendAscii(" \"").Append( pControl->GetText() ).AppendAscii("\" geschlossen, RType = ").Append( TypeString(pControl->GetType()) ).AppendAscii(", UId = ").Append( UIdString(pControl->GetSmartUniqueOrHelpId()) ) );
2353 #else
2354 #define REPORT_WIN_CLOSED(pControl, aInfo) _REPORT_WIN_CLOSED(pControl, aInfo)
2355 #endif
2357 #define REPORT_WIN_CLOSEDc(pControl, aInfo ) \
2358 REPORT_WIN_CLOSED(pControl, CUniString(aInfo) )
2360 #define _REPORT_WIN_CLOSED(pControl, aInfo) \
2361 if ( aString1.Len() ) \
2362 aString1 += '\n'; \
2363 aString1 += aInfo; \
2364 aString1.AppendAscii(" \""); \
2365 aString1 += pControl->GetText(); \
2366 aString1.AppendAscii("\" geschlossen, RType = ");\
2367 aString1 += TypeString(pControl->GetType()); \
2368 aString1.AppendAscii(", UId = "); \
2369 aString1 += UIdString(pControl->GetSmartUniqueOrHelpId());
2372 switch ( nMethodId )
2374 case RC_AppDelay:
2375 if ( !bBool1 )
2377 nLNr1 = Time().GetTime() + nNr1/10;
2378 bBool1 = TRUE;
2380 if ( Time().GetTime() < long(nLNr1) ) // Aktuelle Zeit kleiner Endzeit
2381 return FALSE;
2382 break;
2383 case RC_DisplayHid:
2384 if ( DisplayHID() )
2385 return FALSE;
2386 break;
2387 case RC_ResetApplication:
2389 if ( !bBool1 )
2391 nRetryCount = 150; // das sollte reichen.
2392 bBool1 = TRUE; // Nur beim ersten mal!
2393 nNr1 = 1; // Welcher Button ist dran?
2394 nLNr1 = 0; // Speichern des AppWin
2395 aString1 = UniString(); // Liste der geschlossenen Fenster
2397 // So daß nacher auch wieder alles auf Default steht
2398 nUseBindings = 0;
2399 bCatchGPF = TRUE;
2400 bUsePostEvents = TRUE;
2402 aSubMenuId1 = SmartId();
2403 aSubMenuId2 = SmartId();
2404 aSubMenuId3 = SmartId();
2405 pMenuWindow = NULL;
2407 if ( !nRetryCount )
2408 ReportError( GEN_RES_STR0( S_RESETAPPLICATION_FAILED_COMPLEX ) );
2410 Window *pControl = GetNextRecoverWin();
2412 if ( pControl )
2414 bBool2 = FALSE; // flag for wait when all windows are closed
2415 pControl->GrabFocus();
2417 if ( pControl->GetType() != WINDOW_DOCKINGWINDOW
2418 && pControl->GetType() != WINDOW_FLOATINGWINDOW
2419 && pControl->GetType() != WINDOW_MODELESSDIALOG
2420 && pControl->GetType() != WINDOW_WORKWINDOW
2421 && pControl->GetType() != WINDOW_TOOLBOX
2422 && pControl->GetType() != WINDOW_BORDERWINDOW
2423 && nRetryCount-- )
2425 short nRT = ImpGetRType( pControl, pControl->GetSmartUniqueOrHelpId() );
2427 if ( nRT == C_TabControl && pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_TABDIALOG )
2428 { // Bei Tabcontrol den zugehörigen Tabdialog nehmen
2429 pControl = pControl->GET_REAL_PARENT();
2430 nRT = ImpGetRType( pControl, pControl->GetSmartUniqueOrHelpId() );
2433 switch( nRT )
2435 case C_ModalDlg:
2436 case C_Dialog:
2437 case C_TabDlg:
2438 REPORT_WIN_CLOSEDc(pControl, "Dialog");
2439 SET_WINP_CLOSING(pControl);
2440 ((SystemWindow*)pControl)->Close();
2441 break;
2442 case C_WorkWin:
2443 break;
2444 case C_MessBox:
2445 case C_InfoBox:
2446 case C_WarningBox:
2447 case C_ErrorBox:
2448 case C_QueryBox:
2449 case C_ButtonDialog:
2451 ButtonDialog* pBD = (ButtonDialog*)pControl;
2452 // nNr1 >= 10 bedeutet (Custom)-Buttons durchgehen
2453 if ( nNr1 >= 10+pBD->GetButtonCount() ) nNr1 = 1;
2454 switch( nNr1 )
2456 case 5:
2457 if ( pBD->GetPushButton( BUTTONID_OK ) )
2459 REPORT_WIN_CLOSEDc(pControl, "Message Box (OK)");
2460 SET_WINP_CLOSING(pControl);
2461 pBD->EndDialog(RET_OK);
2463 nNr1 = 10; // Nochmal alle Buttons der Reihe nach
2464 break;
2465 case 4:
2466 if ( pBD->GetPushButton( BUTTONID_CANCEL ) )
2468 REPORT_WIN_CLOSEDc(pControl, "Message Box (Cancel)");
2469 SET_WINP_CLOSING(pControl);
2470 pBD->EndDialog(RET_CANCEL);
2472 nNr1++;
2473 break;
2474 case 3:
2475 if ( pBD->GetPushButton( BUTTONID_YES ) )
2477 REPORT_WIN_CLOSEDc(pControl, "Message Box (Yes)");
2478 SET_WINP_CLOSING(pControl);
2479 pBD->EndDialog(RET_YES);
2481 nNr1++;
2482 break;
2483 case 2: // BUG 48239
2484 case 1:
2485 if ( pBD->GetPushButton( BUTTONID_NO ) )
2487 REPORT_WIN_CLOSEDc(pControl, "Message Box (No)");
2488 SET_WINP_CLOSING(pControl);
2489 pBD->EndDialog(RET_NO);
2491 nNr1++;
2492 break;
2493 default:
2495 USHORT nID = pBD->GetButtonId( nNr1-10 );
2496 if ( nID != BUTTONID_HELP )
2498 REPORT_WIN_CLOSED(pControl, CUniString("Message Box (").Append( UniString::CreateFromInt32(nID) ).AppendAscii(")"));
2499 SET_WINP_CLOSING(pControl);
2500 pBD->EndDialog(nID);
2502 nNr1++;
2505 break;
2507 default:
2508 DBG_ERROR( "Unknown Windowtype" );
2509 REPORT_WIN_CLOSEDc(pControl, "Unknown Windowtype");
2510 ReportError( GEN_RES_STR0( S_RESETAPPLICATION_FAILED_UNKNOWN ), pControl->GetType() );
2511 #if OSL_DEBUG_LEVEL > 1
2512 m_pDbgWin->AddText( " Unbekannter Objekttyp aus UId" );
2513 #endif
2514 break;
2516 return FALSE;
2518 else
2520 if ( (pControl->GetType() == WINDOW_DOCKINGWINDOW || pControl->GetType() == WINDOW_TOOLBOX) && nRetryCount-- )
2522 if ( (((DockingWindow*)pControl)->GetStyle() | ((DockingWindow*)pControl)->GetFloatStyle()) & WB_CLOSEABLE )
2524 REPORT_WIN_CLOSED(pControl, TypeString(pControl->GetType()));
2525 SET_WINP_CLOSING(pControl);
2526 ((DockingWindow*)pControl)->Close();
2528 // Eigentlich nur bei TaskWindows! Hoffen wir mal, daß keine anderen DockingWindows dazwischen hauen.
2529 if ( (Window*)nLNr1 != pControl )
2530 nNr1 = 1; // Zum durchprobieren der Buttons beim Schließen
2531 nLNr1 = (ULONG)pControl;
2533 return FALSE;
2536 if ( nRetryCount--
2537 && ( (pControl->GetType() == WINDOW_FLOATINGWINDOW)
2538 || (pControl->GetType() == WINDOW_MODELESSDIALOG)
2539 || (pControl->GetType() == WINDOW_WORKWINDOW)
2540 || (pControl->GetType() == WINDOW_BORDERWINDOW) ) )
2542 // if ( pControl->GetStyle() & WB_CLOSEABLE )
2544 #ifdef RESET_APPLICATION_TO_BACKING_WINDOW
2545 // Special handling for last Document; do not close the Frame, only the Document
2546 if ( GetDocWinCount() == 1 && IsDocFrame( pControl ) )
2548 if ( IsDocWin( pControl ) )
2550 if ( GetDocFrameMenuBar( pControl ) )
2552 MenuBar* pMenu = GetDocFrameMenuBar( pControl );
2553 if ( pMenu->HasCloser() )
2555 REPORT_WIN_CLOSED( pControl, TypeString(pControl->GetType()));
2556 SET_WINP_CLOSING(pControl);
2558 pMenu->GetCloserHdl().Call( pMenu );
2560 // nur bei TaskWindows!
2561 if ( (Window*)nLNr1 != pControl )
2562 nNr1 = 1; // Zum durchprobieren der Buttons beim Schließen
2563 nLNr1 = (ULONG)pControl;
2565 return FALSE;
2570 else
2571 #endif // def RESET_APPLICATION_TO_BACKING_WINDOW
2573 REPORT_WIN_CLOSED( pControl, TypeString(pControl->GetType()));
2574 SET_WINP_CLOSING(pControl);
2575 ((SystemWindow*)pControl)->Close();
2577 // Eigentlich nur bei TaskWindows!
2578 if ( (Window*)nLNr1 != pControl )
2579 nNr1 = 1; // Zum durchprobieren der Buttons beim Schließen
2580 nLNr1 = (ULONG)pControl;
2582 return FALSE;
2588 // wait for some time if more windows show up
2589 // E.g.: Floating toolbars on a Task which was hidden by another Task before
2590 if ( !bBool2 )
2592 nLNr1 = Time().GetTime() + 100; // 100 = 1 Second
2593 bBool2 = TRUE;
2595 if ( Time().GetTime() < long(nLNr1) ) // Aktuelle Zeit kleiner Endzeit
2596 return FALSE;
2597 else
2598 pRet->GenReturn ( RET_Value, aSmartMethodId, aString1);
2600 break;
2601 case RC_WaitSlot:
2603 if ( ! (nParams & PARAM_USHORT_1) )
2604 nNr1 = 1000; // defaults to 1000 = 1 Sec.
2605 if ( !bBool1 )
2607 nLNr1 = Time().GetTime() + nNr1/10;
2608 bBool1 = TRUE;
2611 if ( !bIsSlotInExecute )
2612 pRet->GenReturn ( RET_Value, aSmartMethodId, comm_USHORT(CONST_WSFinished) );
2613 else
2615 if ( Time().GetTime() < long(nLNr1) ) // Aktuelle Zeit kleiner Endzeit
2616 return FALSE;
2617 pRet->GenReturn ( RET_Value, aSmartMethodId, comm_USHORT(CONST_WSTimeout) );
2620 break;
2624 Advance();
2627 switch ( nMethodId )
2629 case RC_AppDelay: // Diese Befehle werden anderswo behandelt
2630 case RC_DisplayHid:
2631 case RC_ResetApplication:
2632 case RC_WaitSlot:
2634 case RC_AppAbort: // Sofortiges Löschen aller Befehle
2635 break;
2636 case RC_Assert:
2638 ByteString aAssertion( "Diese Assertion wurde vom Testtool per Befehl ausgelöst" );
2639 aAssertion = ByteString( String( aAssertion, RTL_TEXTENCODING_MS_1252 ), RTL_TEXTENCODING_UTF8 );
2640 DBG_ASSERT( !aString1.Len(), ByteString( aString1, RTL_TEXTENCODING_UTF8 ).GetBuffer() );
2641 DBG_ASSERT( aString1.Len(), aAssertion.GetBuffer() );
2642 OSL_ENSURE( !aString1.Len(), ByteString( aString1, RTL_TEXTENCODING_UTF8 ).GetBuffer() );
2643 OSL_ENSURE( aString1.Len(), aAssertion.GetBuffer() );
2645 break;
2646 case RC_CaptureAssertions:
2647 #ifdef DBG_UTIL
2648 if( !(nParams & PARAM_BOOL_1) || bBool1 )
2650 DBG_INSTOUTERROR( DBG_OUT_TESTTOOL );
2651 osl_setDebugMessageFunc( osl_TestToolDebugPrint );
2653 else
2655 DBG_INSTOUTERROR( DBG_OUT_MSGBOX );
2656 osl_setDebugMessageFunc( pOriginal_osl_DebugMessageFunc );
2658 #endif
2659 break;
2660 case RC_Translate:
2661 Translate();
2662 break;
2663 case RC_ApplicationBusy:
2665 BOOL bWait = FALSE;
2666 ReportError( GEN_RES_STR0( S_NO_ACTIVE_WINDOW ) );
2667 // if ( Application::GetAppWindow() )
2668 // bWait = Application::GetAppWindow()->IsWait();
2669 pRet->GenReturn ( RET_Value, aSmartMethodId, bWait );
2670 break;
2672 case RC_GetClipboard:
2674 ::rtl::OUString aTemp;
2675 ::svt::OStringTransfer::PasteString( aTemp, GetFirstDocFrame() );
2676 pRet->GenReturn ( RET_Value, aSmartMethodId, String( aTemp ) );
2678 break;
2679 case RC_SetClipboard:
2680 ::svt::OStringTransfer::CopyString(aString1,GetFirstDocFrame());
2681 break;
2682 case RC_WinTree:
2683 pRet->GenReturn ( RET_Value, aSmartMethodId, Tree( NULL, 0));
2684 break;
2685 #if OSL_DEBUG_LEVEL > 1
2686 case RC_NoDebug:
2687 m_pDbgWin->bQuiet = TRUE;
2688 m_pDbgWin->Hide();
2689 m_pDbgWin->Clear();
2690 break;
2691 case RC_Debug:
2692 m_pDbgWin->bQuiet = FALSE;
2693 m_pDbgWin->Show();
2694 break;
2695 #endif
2696 case RC_GPF:
2697 ((TabControl*)NULL)->SetCurPageId( 12345 );
2698 break;
2699 case RC_GetNextCloseWindow:
2701 Window *pWin = GetActive( WINDOW_BASE ); // WINDOW_ANYTYPE
2702 if ( !pWin )
2703 ReportError( GEN_RES_STR0( S_NO_ACTIVE_WINDOW ) );
2704 else if ( !IsDialog(pWin) )
2705 ReportError( GEN_RES_STR0( S_NO_DIALOG_IN_GETACTIVE ) );
2706 else
2707 pRet->GenReturn( RET_Value, aSmartMethodId, static_cast<comm_ULONG>(pWin->GetSmartUniqueOrHelpId().GetNum())); //GetNum() ULONG != comm_ULONG on 64bit
2709 break;
2710 case RC_UseBindings:
2711 if( !(nParams & PARAM_BOOL_1) || bBool1 )
2712 nUseBindings = SFX_USE_BINDINGS;
2713 else
2714 nUseBindings = 0;
2715 break;
2716 case RC_Profile:
2717 // Bei folgenden Parametern passiert folgendes:
2718 // ein boolean=false Alles Profiling stoppen (Ergebnisse liefern)
2719 // ein boolean=true, 1-4 ints Einteilung der Zeiten in Kästchen
2720 // kein! boolean keine ints loggen jeden Befehls
2721 // kein! boolean 1 int loggen alle int Millisekunden
2722 // ein String wird in das Logfile übernommen(sonst passiert nichts)
2723 if( !(nParams & PARAM_BOOL_1) || bBool1 )
2725 if ( !pProfiler )
2727 pProfiler = new TTProfiler;
2728 InitProfile();
2731 if( !(nParams & PARAM_BOOL_1) && (nParams & PARAM_USHORT_1) )
2732 { // Autoprofiling: Profile nNr
2733 if ( pProfiler->IsProfilingPerCommand() )
2735 pProfiler->StopProfilingPerCommand();
2737 pProfiler->StartAutoProfiling( nNr1 );
2739 // Der Header ist abhängig vom Modus
2740 pRet->GenReturn( RET_ProfileInfo, SmartId(), pProfiler->GetProfileHeader() );
2742 else if ( nParams & PARAM_USHORT_1 )
2743 { // Partitioning initialisieren: Profile true [,nNr][,nNr][,nNr][,nNr]
2744 comm_ULONG nAnzahl=0;
2745 if ( nParams & PARAM_USHORT_1 ) { nAnzahl++; };
2746 if ( nParams & PARAM_USHORT_2 ) { nAnzahl++; };
2747 if ( nParams & PARAM_USHORT_3 ) { nAnzahl++; };
2748 if ( nParams & PARAM_USHORT_4 ) { nAnzahl++; };
2750 // Hier werden die Parameter ans Testtool zurück übertragen.
2751 // Das ist zwar etwas eigenartig, aber ansonsten müsste man im Testtool
2752 // die einfache Struktur der Remotebefehle aufbrechen.
2753 pRet->GenReturn( RET_ProfileInfo, SmartId( S_ProfileReset ), nAnzahl );
2755 // Und die einzelnen Grenzen
2756 if ( nParams & PARAM_USHORT_1 ) { pRet->GenReturn( RET_ProfileInfo, SmartId( S_ProfileBorder1 ), (comm_ULONG)nNr1 ); };
2757 if ( nParams & PARAM_USHORT_2 ) { pRet->GenReturn( RET_ProfileInfo, SmartId( S_ProfileBorder2 ), (comm_ULONG)nNr2 ); };
2758 if ( nParams & PARAM_USHORT_3 ) { pRet->GenReturn( RET_ProfileInfo, SmartId( S_ProfileBorder3 ), (comm_ULONG)nNr3 ); };
2759 if ( nParams & PARAM_USHORT_4 ) { pRet->GenReturn( RET_ProfileInfo, SmartId( S_ProfileBorder4 ), (comm_ULONG)nNr4 ); };
2761 pProfiler->StartPartitioning();
2763 else if( nParams == PARAM_STR_1 ) // Genau ein String!
2764 { // Nur einen String ins Profiling aufnehmen
2765 aString1 += '\n';
2766 pRet->GenReturn( RET_ProfileInfo, SmartId(), aString1 );
2768 else
2769 { // Normales Profiling je Kommando: profile
2770 if ( pProfiler->IsAutoProfiling() )
2772 pRet->GenReturn( RET_ProfileInfo, SmartId(), pProfiler->GetAutoProfiling() );
2773 pProfiler->StopAutoProfiling();
2775 pProfiler->StartProfilingPerCommand();
2777 // Der Header ist abhängig vom Modus
2778 pRet->GenReturn( RET_ProfileInfo, SmartId(), pProfiler->GetProfileHeader() );
2781 else // Profiling wieder ausschalten: Profile false
2782 if ( pProfiler )
2784 if ( pProfiler->IsProfilingPerCommand() )
2785 pProfiler->StopProfilingPerCommand();
2787 if ( pProfiler->IsAutoProfiling() )
2789 pRet->GenReturn( RET_ProfileInfo, SmartId(), pProfiler->GetAutoProfiling() );
2790 pProfiler->StopAutoProfiling();
2793 if ( pProfiler->IsPartitioning() )
2795 pRet->GenReturn( RET_ProfileInfo, SmartId( S_ProfileDump ), (comm_ULONG)0 );
2796 pProfiler->StopPartitioning();
2799 delete pProfiler;
2800 pProfiler = NULL;
2802 break;
2803 case RC_MenuGetItemCount:
2804 case RC_MenuGetItemId:
2805 case RC_MenuGetItemPos:
2806 case RC_MenuIsSeperator:
2807 case RC_MenuIsItemChecked:
2808 case RC_MenuIsItemEnabled:
2809 case RC_MenuGetItemText:
2810 case RC_MenuGetItemCommand:
2811 case RC_MenuHasSubMenu:
2812 case RC_MenuSelect:
2814 PopupMenu *pPopup = NULL;
2815 MenuBar *pMenuBar = NULL;
2816 Menu *pMenu;
2818 USHORT nErr = GetCurrentMenues( pPopup, pMenuBar, pMenu );
2820 if ( !pMenu )
2822 if ( nErr == 1 )
2823 ReportError( GEN_RES_STR0( S_NO_POPUP ) );
2824 else
2825 ReportError( GEN_RES_STR0( S_NO_SUBMENU ) );
2826 break;
2829 USHORT nItemCount = 0;
2830 switch ( nMethodId )
2832 case RC_MenuGetItemCount:
2833 case RC_MenuGetItemId:
2834 case RC_MenuIsSeperator:
2836 nItemCount = pMenu->GetItemCount();
2837 if ( pMenu->GetMenuFlags() & MENU_FLAG_HIDEDISABLEDENTRIES )
2838 { // jep, we have to adjust the count
2839 BOOL bLastWasSeperator = TRUE; // TRUE for Separator at the top
2840 for ( USHORT i = 0 ; i < pMenu->GetItemCount() ; i++ )
2842 if ( !pMenu->IsItemEnabled( pMenu->GetItemId( i ) ) )
2843 nItemCount--;
2844 else
2846 if ( pMenu->GetItemType( i ) == MENUITEM_SEPARATOR && bLastWasSeperator )
2847 nItemCount--;
2848 bLastWasSeperator = pMenu->GetItemType( i ) == MENUITEM_SEPARATOR;
2851 if ( bLastWasSeperator ) // Separator at bottom
2852 nItemCount--;
2855 break;
2858 // for certain methods calculate the physical index (reinserting the hidden entries)
2859 USHORT nPhysicalIndex = 0;
2860 switch ( nMethodId )
2862 case RC_MenuGetItemId:
2863 case RC_MenuIsSeperator:
2865 nPhysicalIndex = nNr1;
2866 if ( pMenu->GetMenuFlags() & MENU_FLAG_HIDEDISABLEDENTRIES )
2867 { // jep, we have to adjust the position
2868 BOOL bLastWasSeperator = TRUE; // TRUE for Separator at the top
2869 USHORT nVisibleCount = 0;
2870 for ( USHORT i = 0 ; i < pMenu->GetItemCount() && nVisibleCount < nNr1 ; i++ )
2872 if ( pMenu->IsItemEnabled( pMenu->GetItemId( i ) )
2873 && !( pMenu->GetItemType( i ) == MENUITEM_SEPARATOR && bLastWasSeperator ) )
2875 nVisibleCount++;
2876 bLastWasSeperator = pMenu->GetItemType( i ) == MENUITEM_SEPARATOR;
2878 else
2879 nPhysicalIndex++;
2881 DBG_ASSERT( nVisibleCount == nNr1, "Adaption of Index failed: nVisibleCount != nNr1" );
2884 break;
2889 switch ( nMethodId )
2891 case RC_MenuGetItemCount:
2893 pRet->GenReturn ( RET_Value, aSmartMethodId, (comm_ULONG)nItemCount );
2895 break;
2896 case RC_MenuGetItemId:
2898 if ( ValueOK(aSmartMethodId, RcString( nMethodId ),nNr1,nItemCount) )
2899 pRet->GenReturn ( RET_Value, aSmartMethodId, (comm_ULONG)pMenu->GetItemId(nPhysicalIndex-1) );
2901 break;
2902 case RC_MenuGetItemPos:
2904 USHORT nLogicalPos = pMenu->GetItemPos(nNr1);
2905 if ( MENU_ITEM_NOTFOUND != nLogicalPos && pMenu->GetMenuFlags() & MENU_FLAG_HIDEDISABLEDENTRIES )
2906 { // jep, we have to adjust the position
2907 if ( !pMenu->IsItemEnabled( nNr1 ) )
2908 nLogicalPos = MENU_ITEM_NOTFOUND;
2909 else
2911 BOOL bLastWasSeperator = FALSE;
2912 for ( int i = nLogicalPos ; i >= 0 ; i-- )
2914 if ( !pMenu->IsItemEnabled( pMenu->GetItemId( sal::static_int_cast< USHORT >(i) ) ) ||
2915 ( pMenu->GetItemType( sal::static_int_cast< USHORT >(i) ) == MENUITEM_SEPARATOR && bLastWasSeperator ) )
2916 nLogicalPos--;
2917 bLastWasSeperator = pMenu->GetItemType( sal::static_int_cast< USHORT >(i) ) == MENUITEM_SEPARATOR;
2921 pRet->GenReturn ( RET_Value, aSmartMethodId, (comm_ULONG)(nLogicalPos+1) );
2923 break;
2924 case RC_MenuIsSeperator:
2926 if ( ValueOK(aSmartMethodId, RcString( nMethodId ),nNr1,nItemCount) )
2927 pRet->GenReturn ( RET_Value, aSmartMethodId, (comm_BOOL)(pMenu->GetItemType(nPhysicalIndex-1) == MENUITEM_SEPARATOR) );
2929 break;
2930 case RC_MenuIsItemChecked:
2932 pRet->GenReturn ( RET_Value, aSmartMethodId, (comm_BOOL)pMenu->IsItemChecked(nNr1) );
2934 break;
2935 case RC_MenuIsItemEnabled:
2937 pRet->GenReturn ( RET_Value, aSmartMethodId, (comm_BOOL)pMenu->IsItemEnabled(nNr1) );
2939 break;
2940 case RC_MenuGetItemText:
2942 pRet->GenReturn ( RET_Value, aSmartMethodId, (String)pMenu->GetItemText(nNr1) );
2944 break;
2945 case RC_MenuGetItemCommand:
2947 pRet->GenReturn ( RET_Value, aSmartMethodId, (String)pMenu->GetItemCommand(nNr1) );
2949 break;
2950 case RC_MenuHasSubMenu:
2952 pRet->GenReturn ( RET_Value, aSmartMethodId, (BOOL)(pMenu->GetPopupMenu(nNr1) != NULL) );
2954 break;
2955 case RC_MenuSelect:
2957 if ( pMenu->GetPopupMenu(nNr1) )
2959 if ( !aSubMenuId1.GetNum() )
2960 aSubMenuId1 = SmartId(nNr1);
2961 else if ( !aSubMenuId2.GetNum() )
2962 aSubMenuId2 = SmartId(nNr1);
2963 else if ( !aSubMenuId3.GetNum() )
2964 aSubMenuId3 = SmartId(nNr1);
2966 if ( pPopup )
2967 pPopup->SelectEntry(nNr1);
2968 else
2969 pMenuBar->SelectEntry(nNr1);
2971 else
2973 if ( pPopup )
2975 pPopup->EndExecute(nNr1);
2976 aSubMenuId1 = SmartId();
2977 aSubMenuId2 = SmartId();
2978 aSubMenuId3 = SmartId();
2979 pMenuWindow = NULL;
2981 else
2983 pMenuBar->SelectEntry(nNr1);
2984 aSubMenuId1 = SmartId();
2985 aSubMenuId2 = SmartId();
2986 aSubMenuId3 = SmartId();
2987 pMenuWindow = NULL;
2991 break;
2994 break;
2995 case RC_SetControlType:
2997 DirectLog( S_QAError, GEN_RES_STR0( S_DEPRECATED ) );
2999 break;
3000 case RC_Kill:
3001 case RC_RmDir:
3002 case RC_MkDir:
3003 case RC_FileCopy:
3004 case RC_Name:
3005 case RC_Dir:
3006 case RC_FileLen:
3007 case RC_FileDateTime:
3009 long nErrorcode = FSYS_ERR_OK;
3010 switch ( nMethodId )
3012 case RC_Kill:
3014 DirEntry aFile( aString1 );
3015 nErrorcode = aFile.GetError();
3016 if ( FSYS_ERR_OK == nErrorcode && FileStat( aFile ).IsKind( FSYS_KIND_FILE ) )
3017 nErrorcode = aFile.Kill();
3018 else
3019 nErrorcode = FSYS_ERR_NOTAFILE;
3021 break;
3022 case RC_RmDir:
3024 DirEntry aDir( aString1 );
3025 nErrorcode = aDir.GetError();
3026 if ( FSYS_ERR_OK == nErrorcode && FileStat( aDir ).IsKind( FSYS_KIND_DIR ) )
3027 nErrorcode = aDir.Kill();
3028 else
3029 nErrorcode = FSYS_ERR_NOTADIRECTORY;
3031 break;
3032 case RC_MkDir:
3034 DirEntry aDir( aString1 );
3035 nErrorcode = aDir.GetError();
3036 if ( !nErrorcode && !aDir.MakeDir() )
3037 nErrorcode = FSYS_ERR_UNKNOWN;
3038 // Workaround für Bug 60693
3039 // nErrorcode = aDir.GetError();
3041 break;
3042 case RC_FileCopy:
3044 nErrorcode = DirEntry( aString1 ).CopyTo( DirEntry( aString2 ), FSYS_ACTION_COPYFILE );
3046 break;
3047 case RC_Name:
3049 nErrorcode = DirEntry( aString1 ).MoveTo( DirEntry( aString2 ) );
3051 break;
3052 case RC_Dir:
3055 String aPath;
3056 USHORT nDirFlags = 0;
3057 // from basic/source/inc/runtime.hxx
3058 #define Sb_ATTR_NORMAL 0x0000
3059 #define Sb_ATTR_HIDDEN 0x0002
3060 #define Sb_ATTR_SYSTEM 0x0004
3061 #define Sb_ATTR_VOLUME 0x0008
3062 #define Sb_ATTR_DIRECTORY 0x0010
3063 #define Sb_ATTR_ARCHIVE 0x0020
3064 // copied from Basic and adapted basic/source/runtime/methods.cxx Revision 1.54
3065 if ( (nParams & PARAM_STR_1) )
3067 delete pDir;
3068 pDir = NULL; // wg. Sonderbehandlung Sb_ATTR_VOLUME
3069 DirEntry aEntry( aString1 );
3070 FileStat aStat( aEntry );
3071 if(!aStat.GetError() && (aStat.GetKind() & FSYS_KIND_FILE))
3073 // OK, only a filename
3074 // cut off path (VB4)
3075 aPath = aEntry.GetName();
3077 else
3079 USHORT nFlags = 0;
3080 if ( (nParams & PARAM_USHORT_1) )
3081 nDirFlags = nFlags = nNr1;
3082 else
3083 nDirFlags = nFlags = Sb_ATTR_HIDDEN | Sb_ATTR_SYSTEM | Sb_ATTR_DIRECTORY;
3085 // Nur diese Bitmaske ist unter Windows erlaubt
3086 #ifdef WIN
3087 if( nFlags & ~0x1E )
3089 nDirFlags = 0;
3090 StarBASIC::Error( SbERR_BAD_ARGUMENT );
3092 #endif
3093 // Sb_ATTR_VOLUME wird getrennt gehandelt
3094 if( nDirFlags & Sb_ATTR_VOLUME )
3095 aPath = aEntry.GetVolume();
3096 else
3098 // Die richtige Auswahl treffen
3099 USHORT nMode = FSYS_KIND_FILE;
3100 if( nFlags & Sb_ATTR_DIRECTORY )
3101 nMode |= FSYS_KIND_DIR;
3102 if( nFlags == Sb_ATTR_DIRECTORY )
3103 nMode = FSYS_KIND_DIR;
3104 pDir = new Dir( aEntry, (DirEntryKind) nMode );
3105 nErrorcode = pDir->GetError();
3106 nDirPos = 0;
3111 if( pDir )
3113 for( ;; )
3115 if( nDirPos >= pDir->Count() )
3117 delete pDir;
3118 pDir = NULL;
3119 aPath.Erase();
3120 break;
3122 DirEntry aNextEntry=(*(pDir))[nDirPos++];
3123 aPath = aNextEntry.GetName(); //Full();
3124 #ifdef WIN
3125 aNextEntry.ToAbs();
3126 String sFull(aNextEntry.GetFull());
3127 unsigned nFlags;
3129 if (_dos_getfileattr( sFull.GetStr(), &nFlags ))
3130 nErrorcode = FSYS_ERR_NOTEXISTS;
3131 else
3133 INT16 nCurFlags = nDirFlags;
3134 if( (nCurFlags == Sb_ATTR_NORMAL)
3135 && !(nFlags & ( _A_HIDDEN | _A_SYSTEM | _A_VOLID | _A_SUBDIR ) ) )
3136 break;
3137 else if( (nCurFlags & Sb_ATTR_HIDDEN) && (nFlags & _A_HIDDEN) )
3138 break;
3139 else if( (nCurFlags & Sb_ATTR_SYSTEM) && (nFlags & _A_SYSTEM) )
3140 break;
3141 else if( (nCurFlags & Sb_ATTR_VOLUME) && (nFlags & _A_VOLID) )
3142 break;
3143 else if( (nCurFlags & Sb_ATTR_DIRECTORY) && (nFlags & _A_SUBDIR) )
3144 break;
3146 #else
3147 break;
3148 #endif
3151 if ( !nErrorcode )
3153 pRet->GenReturn ( RET_Value, aSmartMethodId, aPath );
3158 /* keep old Implementation for now
3159 // neues Verzeichnis einlesen
3160 if ( (nParams & PARAM_STR_1) )
3162 if ( pDir )
3164 delete pDir;
3165 pDir = NULL;
3167 DirEntryKind aDirEntryKind = FSYS_KIND_FILE | FSYS_KIND_DIR;
3168 if ( (nParams & PARAM_USHORT_1) && nNr1 )
3170 if ( nNr1 & 16 )
3171 aDirEntryKind = FSYS_KIND_DIR;
3172 else
3173 ReportError( GEN_RES_STR0( S_SELECTION_BY_ATTRIBUTE_ONLY_DIRECTORIES ) );
3176 DirEntry aEntry( aString1 );
3177 nErrorcode = aEntry.GetError();
3178 if ( !nErrorcode )
3180 nDirPos = 0;
3181 FileStat aFS( aEntry );
3182 if ( !aFS.IsKind( FSYS_KIND_WILD ) && !aFS.IsKind( FSYS_KIND_DIR ) && aEntry.Exists() )
3183 { // Sonderbehandlung für genau einen Eintrag
3184 if ( !aFS.IsKind( FSYS_KIND_DIR ) && ( aDirEntryKind == FSYS_KIND_DIR ) )
3185 pRet->GenReturn ( RET_Value, aSmartMethodId, String() );
3186 else
3187 pRet->GenReturn ( RET_Value, aSmartMethodId, (String)(aEntry.GetName()) );
3189 break;
3191 else
3193 pDir = new Dir( aEntry, aDirEntryKind );
3194 nErrorcode = pDir->GetError();
3199 if ( !pDir )
3200 pDir = new Dir;
3202 if ( !nErrorcode && ValueOK( aSmartMethodId, GEN_RES_STR0( S_NO_MORE_FILES ), nDirPos+1, pDir->Count()+1 ) )
3204 if ( nDirPos == pDir->Count() )
3205 pRet->GenReturn ( RET_Value, aSmartMethodId, String() );
3206 else
3207 pRet->GenReturn ( RET_Value, aSmartMethodId, (String)((*pDir)[ nDirPos ].GetName()) );
3208 nDirPos++;
3211 break;
3212 case RC_FileLen:
3214 DirEntry aFile( aString1 );
3215 nErrorcode = aFile.GetError();
3216 if ( FSYS_ERR_OK == nErrorcode )
3218 FileStat aFS( aFile );
3219 pRet->GenReturn ( RET_Value, aSmartMethodId, static_cast<comm_ULONG>(aFS.GetSize()) ); //GetSize() ULONG != comm_ULONG on 64bit
3220 nErrorcode = aFS.GetError();
3223 break;
3224 case RC_FileDateTime:
3226 DirEntry aFile( aString1 );
3227 nErrorcode = aFile.GetError();
3228 if ( FSYS_ERR_OK == nErrorcode )
3230 FileStat aStat( aFile );
3231 Time aTime( aStat.TimeModified() );
3232 Date aDate( aStat.DateModified() );
3233 nErrorcode = aStat.GetError();
3235 double fSerial = (double)( aDate - Date(30,12,1899) );
3236 long nSeconds = aTime.GetHour();
3237 nSeconds *= 3600;
3238 nSeconds += aTime.GetMin() * 60;
3239 nSeconds += aTime.GetSec();
3240 double nDays = ((double)nSeconds) / (double)(24.0*3600.0);
3241 fSerial += nDays;
3243 SbxValueRef xValue = new SbxValue( SbxDATE );
3244 xValue->PutDate( fSerial );
3246 pRet->GenReturn ( RET_Value, aSmartMethodId, *xValue );
3249 break;
3251 switch ( nErrorcode )
3253 case FSYS_ERR_OK:
3254 break;
3255 case FSYS_ERR_MISPLACEDCHAR:
3257 ReportError( CUniString("MISPLACEDCHAR") );
3259 break;
3260 case FSYS_ERR_INVALIDCHAR:
3262 ReportError( CUniString("INVALIDCHAR") );
3264 break;
3265 case FSYS_ERR_NOTEXISTS:
3267 ReportError( CUniString("NOTEXISTS") );
3269 break;
3270 case FSYS_ERR_ALREADYEXISTS:
3272 ReportError( CUniString("ALREADYEXISTS") );
3274 break;
3275 case FSYS_ERR_NOTADIRECTORY:
3277 ReportError( CUniString("NOTADIRECTORY") );
3279 break;
3280 case FSYS_ERR_NOTAFILE:
3282 ReportError( CUniString("NOTAFILE") );
3284 break;
3285 case FSYS_ERR_INVALIDDEVICE:
3287 ReportError( CUniString("INVALIDDEVICE") );
3289 break;
3290 case FSYS_ERR_ACCESSDENIED:
3292 ReportError( CUniString("ACCESSDENIED") );
3294 break;
3295 case FSYS_ERR_LOCKVIOLATION:
3297 ReportError( CUniString("LOCKVIOLATION") );
3299 break;
3300 case FSYS_ERR_VOLUMEFULL:
3302 ReportError( CUniString("VOLUMEFULL") );
3304 break;
3305 case FSYS_ERR_ISWILDCARD:
3307 ReportError( CUniString("ISWILDCARD") );
3309 break;
3310 case FSYS_ERR_NOTSUPPORTED:
3312 ReportError( CUniString("NOTSUPPORTED") );
3314 break;
3315 case FSYS_ERR_UNKNOWN:
3317 ReportError( CUniString("UNKNOWN") );
3319 break;
3320 default:
3322 ReportError( CUniString("Not an FSYS Error") );
3327 break;
3328 case RC_TypeKeysDelay:
3330 if( (nParams & PARAM_BOOL_1) )
3332 bDoTypeKeysDelay = bBool1;
3334 else if( nParams & PARAM_USHORT_1 )
3336 nMinTypeKeysDelay = nNr1;
3337 if( nParams & PARAM_USHORT_2 )
3338 nMaxTypeKeysDelay = nNr2;
3339 else
3340 nMaxTypeKeysDelay = nMinTypeKeysDelay;
3342 else
3343 ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) );
3345 break;
3346 case RC_GetMouseStyle:
3348 Pointer aPointer;
3349 // if ( DragManager::GetDragManager() )
3350 // aPointer = DragManager::GetDragManager()->GetDragPointer();
3351 // else
3353 Window *pActualWin = GetMouseWin();
3354 if ( pActualWin )
3355 aPointer = pActualWin->GetPointer();
3356 else
3358 ReportError( GEN_RES_STR1( S_POINTER_OUTSIDE_APPWIN, RcString( nMethodId ) ) );
3359 aPointer = Pointer( POINTER_NULL );
3362 pRet->GenReturn ( RET_Value, aSmartMethodId, (comm_ULONG)aPointer.GetStyle() );
3364 break;
3365 case RC_UnpackStorage:
3367 if( (nParams & PARAM_STR_1) )
3369 String aFileName( aString1 );
3370 DirEntry aDestPath;
3371 if( (nParams & PARAM_STR_2) )
3372 aDestPath = DirEntry( aString2 );
3373 else
3375 aDestPath = DirEntry( aFileName );
3376 aDestPath.SetExtension( CUniString( "plaintext" ) );
3379 #if OSL_DEBUG_LEVEL > 1
3380 USHORT nEntries = Dir( aDestPath, FSYS_KIND_FILE | FSYS_KIND_DIR ).Count();
3381 (void) nEntries; /* avoid warning about unused parameter */
3382 #endif
3383 // The Count is only larger than 2 is the path is a directory which is not empty
3384 // the Count of 2 results from the "." and ".." directory
3385 if ( Dir( aDestPath, FSYS_KIND_FILE | FSYS_KIND_DIR ).Count() > 2 )
3386 DirectLog( S_QAError, GEN_RES_STR1( S_DIRECTORY_NOT_EMPTY, aDestPath.GetFull() ) );
3388 SotStorageRef xStorage = new SotStorage( aFileName, STREAM_STD_READ );
3389 if ( xStorage->GetError() )
3390 ReportError( GEN_RES_STR2(S_UNPACKING_STORAGE_FAILED, aFileName, aDestPath.GetFull()) );
3391 else
3392 UnpackStorage( xStorage, aDestPath );
3394 else
3395 ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) );
3397 break;
3398 case RC_CloseSysDialog:
3399 case RC_ExistsSysDialog:
3401 if( (nParams & PARAM_USHORT_1) )
3403 Reference < XCancellable > xPicker;
3404 switch( nNr1 )
3406 case CONST_FilePicker:
3408 xPicker.set( Reference < XCancellable >( svt::GetTopMostFilePicker(), UNO_QUERY ) );
3410 break;
3411 case CONST_FolderPicker:
3413 xPicker.set( Reference < XCancellable >( svt::GetTopMostFolderPicker(), UNO_QUERY ) );
3415 break;
3416 default:
3417 ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) );
3419 switch( nMethodId )
3421 case RC_CloseSysDialog:
3423 if ( xPicker.is() )
3424 xPicker->cancel();
3425 else
3426 ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) );
3428 break;
3429 case RC_ExistsSysDialog:
3431 pRet->GenReturn ( RET_Value, aSmartMethodId, (comm_BOOL)xPicker.is() );
3433 break;
3434 default:
3435 ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) );
3438 else
3439 ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) );
3441 break;
3442 case RC_SAXCheckWellformed:
3443 case RC_SAXReadFile:
3445 case RC_SAXGetNodeType:
3446 case RC_SAXGetAttributeCount:
3447 case RC_SAXGetAttributeName:
3448 case RC_SAXGetAttributeValue:
3449 case RC_SAXGetChildCount:
3450 case RC_SAXGetElementName:
3451 case RC_SAXGetChars:
3453 case RC_SAXSeekElement:
3454 case RC_SAXHasElement:
3455 case RC_SAXGetElementPath:
3457 case RC_SAXRelease:
3459 HandleSAXParser();
3461 break;
3462 case RC_RecordMacro:
3464 if ( ! (nParams & PARAM_BOOL_1) )
3465 bBool1 = TRUE;
3467 MacroRecorder::GetMacroRecorder()->SetActionRecord( bBool1 );
3469 break;
3470 case RC_GetDocumentCount :
3472 pRet->GenReturn ( RET_Value, aSmartMethodId, (comm_USHORT)GetDocWinCount() );
3474 break;
3475 case RC_ActivateDocument :
3477 if( nParams & PARAM_USHORT_1 )
3479 if ( ValueOK(aSmartMethodId, RcString( nMethodId ), nNr1, GetDocWinCount() ) )
3481 Window* pWin = GetDocWin( nNr1-1 );
3482 if ( pWin )
3484 pWin->ToTop();
3485 pWin->GrabFocus();
3489 else
3490 ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) );
3492 break;
3493 case RC_GetSystemLanguage :
3495 pRet->GenReturn ( RET_Value, aSmartMethodId, (comm_USHORT)Application::GetSettings().GetLanguage() );
3497 break;
3498 case RC_CatchGPF :
3500 if( (nParams & PARAM_BOOL_1) )
3501 bCatchGPF = bBool1;
3502 else
3503 bCatchGPF = TRUE;
3505 break;
3506 case RC_IsProduct :
3508 BOOL bIsProduct;
3509 #ifdef DBG_UTIL
3510 bIsProduct = FALSE;
3511 #else
3512 bIsProduct = TRUE;
3513 #endif
3514 pRet->GenReturn ( RET_Value, aSmartMethodId, (BOOL)bIsProduct );
3516 break;
3517 case RC_UsePostEvents :
3519 if( (nParams & PARAM_BOOL_1) )
3520 bUsePostEvents = bBool1;
3521 else
3522 bUsePostEvents = TRUE;
3524 break;
3525 default:
3526 ReportError( GEN_RES_STR1( S_UNKNOWN_COMMAND, RcString( nMethodId ) ) );
3528 SendProfile( RcString(nMethodId) );
3529 delete this;
3530 return TRUE;
3534 BOOL StatementCommand::UnpackStorage( SotStorageRef xStorage, DirEntry &aBaseDir )
3536 SvStorageInfoList aList;
3537 xStorage->FillInfoList( &aList );
3539 for( USHORT i = 0; i < aList.Count(); i++ )
3541 SvStorageInfo& rInfo = aList.GetObject( i );
3542 String aName = rInfo.GetName();
3543 DirEntry aPath ( aBaseDir );
3544 aPath += DirEntry( aName );
3545 BOOL bIsStorage = xStorage->IsStorage( aName );
3546 if ( bIsStorage )
3548 SotStorageRef xSubStorage = xStorage->OpenSotStorage( aName, STREAM_STD_READ );
3549 if ( xSubStorage->GetError() )
3551 ReportError( GEN_RES_STR2(S_UNPACKING_STORAGE_FAILED, aName, aPath.GetFull()) );
3552 return FALSE;
3554 UnpackStorage( xSubStorage, aPath );
3556 else
3558 if ( !aPath.MakeDir( TRUE ) )
3560 ReportError( GEN_RES_STR1(S_CANNOT_CREATE_DIRECTORY, aPath.GetFull()) );
3561 return FALSE;
3563 SotStorageStreamRef xStream = xStorage->OpenSotStream( aName, STREAM_STD_READ );
3564 SvFileStream aDestination( aPath.GetFull(), STREAM_STD_READWRITE | STREAM_TRUNC );
3565 (*xStream) >> aDestination;
3566 if ( aDestination.GetError() != ERRCODE_NONE )
3568 ReportError( GEN_RES_STR2(S_UNPACKING_STORAGE_FAILED, aName, aPath.GetFull()) );
3569 return FALSE;
3571 aDestination.Close();
3574 return TRUE;
3578 // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
3580 StatementControl::StatementControl( SCmdStream *pCmdIn, USHORT nControlIdType )
3581 : StatementList()
3582 , nNr1( 0 )
3583 , nNr2( 0 )
3584 , nNr3( 0 )
3585 , nNr4( 0 )
3586 , nLNr1( 0 )
3587 , aString1()
3588 , aString2()
3589 , bBool1(FALSE)
3590 , bBool2(FALSE)
3592 QueStatement( NULL );
3593 if ( nControlIdType == SIControl )
3595 comm_ULONG nId;
3596 pCmdIn->Read( nId );
3597 aUId = SmartId( nId );
3599 else if ( nControlIdType == SIStringControl )
3601 String aId;
3602 pCmdIn->Read( aId );
3603 aUId = SmartId( aId );
3605 else
3607 DBG_ERROR( "Wrong ControlType" );
3610 pCmdIn->Read( nMethodId );
3611 pCmdIn->Read( nParams );
3613 if( nParams & PARAM_USHORT_1 ) pCmdIn->Read( nNr1 );
3614 if( nParams & PARAM_USHORT_2 ) pCmdIn->Read( nNr2 );
3615 if( nParams & PARAM_USHORT_3 ) pCmdIn->Read( nNr3 );
3616 if( nParams & PARAM_USHORT_4 ) pCmdIn->Read( nNr4 );
3617 if( nParams & PARAM_ULONG_1 ) pCmdIn->Read( nLNr1 );
3618 if( nParams & PARAM_STR_1 ) pCmdIn->Read( aString1 );
3619 if( nParams & PARAM_STR_2 ) pCmdIn->Read( aString2 );
3620 if( nParams & PARAM_BOOL_1 ) pCmdIn->Read( bBool1 );
3621 if( nParams & PARAM_BOOL_2 ) pCmdIn->Read( bBool2 );
3623 #if OSL_DEBUG_LEVEL > 1
3624 m_pDbgWin->AddText( "Reading Control: UId: " );
3625 m_pDbgWin->AddText( aUId.GetText() );
3626 m_pDbgWin->AddText( " Methode: " );
3627 m_pDbgWin->AddText( String::CreateFromInt32( nMethodId ) );
3628 m_pDbgWin->AddText( " Params:" );
3629 if( nParams & PARAM_USHORT_1 ) {m_pDbgWin->AddText( " n1:" );m_pDbgWin->AddText( String::CreateFromInt32( nNr1 ) );}
3630 if( nParams & PARAM_USHORT_2 ) {m_pDbgWin->AddText( " n2:" );m_pDbgWin->AddText( String::CreateFromInt32( nNr2 ) );}
3631 if( nParams & PARAM_USHORT_3 ) {m_pDbgWin->AddText( " n3:" );m_pDbgWin->AddText( String::CreateFromInt32( nNr3 ) );}
3632 if( nParams & PARAM_USHORT_4 ) {m_pDbgWin->AddText( " n4:" );m_pDbgWin->AddText( String::CreateFromInt32( nNr4 ) );}
3633 if( nParams & PARAM_ULONG_1 ) {m_pDbgWin->AddText( " nl1:" );m_pDbgWin->AddText( String::CreateFromInt64( nLNr1 ) );}
3634 if( nParams & PARAM_STR_1 ) {m_pDbgWin->AddText( " s1:" );m_pDbgWin->AddText( aString1 );}
3635 if( nParams & PARAM_STR_2 ) {m_pDbgWin->AddText( " s2:" );m_pDbgWin->AddText( aString2 );}
3636 /* if( nParams & PARAM_BOOL_1 ) pCmdIn->Read( bBool1 );
3637 if( nParams & PARAM_BOOL_2 ) pCmdIn->Read( bBool2 );*/
3638 m_pDbgWin->AddText( "\n" );
3639 #endif
3642 BOOL IsDialog(Window *pWin)
3643 { // Alles was von SystemWindow abgeleitet ist
3644 if ( !pWin )
3645 return FALSE;
3647 switch (pWin->GetType())
3649 case WINDOW_FLOATINGWINDOW:
3650 case WINDOW_DOCKINGWINDOW:
3651 case WINDOW_MODELESSDIALOG:
3652 case WINDOW_DIALOG:
3653 case WINDOW_MODALDIALOG:
3654 case WINDOW_WORKWINDOW:
3655 case WINDOW_TABDIALOG:
3657 case WINDOW_MESSBOX:
3658 case WINDOW_INFOBOX:
3659 case WINDOW_WARNINGBOX:
3660 case WINDOW_ERRORBOX:
3661 case WINDOW_QUERYBOX:
3662 case WINDOW_BUTTONDIALOG:
3663 case WINDOW_FILEDIALOG:
3664 case WINDOW_PRINTDIALOG:
3665 case WINDOW_PRINTERSETUPDIALOG:
3667 // ab hier nicht ansprechbar (da nicht implementiert)
3668 case WINDOW_SYSWINDOW:
3669 case WINDOW_SYSTEMDIALOG:
3670 case WINDOW_COLORDIALOG:
3671 case WINDOW_FONTDIALOG:
3672 case WINDOW_PATHDIALOG:
3675 return TRUE;
3676 // break;
3677 default:
3678 return FALSE;
3679 // break;
3684 BOOL IsAccessable(Window *pWin)
3686 if ( pWin == NULL )
3687 return FALSE;
3689 return pWin->IsEnabled() && pWin->IsInputEnabled();
3694 // neue Hilfsfunktion
3695 static Window*ImpGetButton( Window *pBase, WinBits nMask, WinBits nWinBits )
3697 USHORT n = pBase->GetChildCount();
3698 for( USHORT i = 0 ; i < n; i++ ) {
3699 Window *pChild = pBase->GetChild(i);
3700 if( pChild->GetType() == WINDOW_OKBUTTON
3701 || pChild->GetType() == WINDOW_CANCELBUTTON
3702 || pChild->GetType() == WINDOW_HELPBUTTON
3703 || pChild->GetType() == WINDOW_PUSHBUTTON )
3704 if( !nMask || ( pChild->GetStyle() & nMask ) == nWinBits )
3705 return pChild;
3707 return NULL;
3710 BOOL StatementControl::ControlOK( Window *pControl, const sal_Char* cBezeichnung )
3712 if ( pControl && ( ( ( IsAccessable(pControl) || (nMethodId & M_WITH_RETURN) ) &&
3713 pControl->IsVisible() ) ||
3714 aUId.Matches( UID_ACTIVE ) ) )
3715 return TRUE;
3716 else
3718 UniString aBezeichnung( cBezeichnung, RTL_TEXTENCODING_ASCII_US );
3719 if ( aBezeichnung.Len() > 0 )
3721 if (!pControl)
3722 ReportError( aUId, GEN_RES_STR1( S_WIN_NOT_FOUND, aBezeichnung ) );
3723 else if ( !pControl->IsVisible() )
3724 ReportError( aUId, GEN_RES_STR1( S_WIN_INVISIBLE, aBezeichnung ) );
3725 else
3726 ReportError( aUId, GEN_RES_STR1( S_WIN_DISABLED, aBezeichnung ) );
3728 #if OSL_DEBUG_LEVEL > 1
3729 m_pDbgWin->AddText( aBezeichnung.AppendAscii(" NotFound or Disabled or Invisible") );
3730 #endif
3732 return FALSE;
3737 BOOL StatementList::ValueOK( SmartId aId, String aBezeichnung, ULONG nValue, ULONG nMax )
3740 if ( nMax < nValue )
3742 if ( aBezeichnung.Len() > 0 )
3743 ReportError( aId, GEN_RES_STR3( S_NUMBER_TOO_BIG, aBezeichnung, UniString::CreateFromInt32( nValue ), UniString::CreateFromInt32( nMax ) ) );
3744 return FALSE;
3746 if ( nValue < 1 )
3748 if ( aBezeichnung.Len() > 0 )
3749 ReportError( aId, GEN_RES_STR3c3( S_NUMBER_TOO_SMALL, aBezeichnung, UniString::CreateFromInt32( nValue ), "1" ) );
3750 return FALSE;
3752 return TRUE;
3755 USHORT StatementList::GetCurrentMenues( PopupMenu *&pPopup, MenuBar *&pMenuBar, Menu *&pMenu )
3757 if ( WinPtrValid( pMenuWindow ) )
3758 pMenuBar = pMenuWindow->GetMenuBar();
3760 if ( pMenuBar ) // use MenuBar as base
3761 pMenu = pMenuBar;
3762 else // use contextmenu as base
3764 pMenu = PopupMenu::GetActivePopupMenu();
3765 pPopup = PopupMenu::GetActivePopupMenu();
3768 if ( !pMenu )
3769 return 1;
3771 if ( aSubMenuId1.GetNum() )
3773 pPopup = pMenu->GetPopupMenu(
3774 sal::static_int_cast< USHORT >(aSubMenuId1.GetNum()));
3775 pMenu = pPopup;
3778 if ( pMenu && aSubMenuId2.GetNum() )
3780 pPopup = pMenu->GetPopupMenu(
3781 sal::static_int_cast< USHORT >(aSubMenuId2.GetNum()));
3782 pMenu = pPopup;
3785 if ( pMenu && aSubMenuId3.GetNum() )
3787 pPopup = pMenu->GetPopupMenu(
3788 sal::static_int_cast< USHORT >(aSubMenuId3.GetNum()));
3789 pMenu = pPopup;
3792 return 0;
3795 void StatementControl::AnimateMouse( Window *pControl, TTHotSpots aWohin )
3797 Point aZiel;
3799 switch (aWohin)
3801 case MitteLinks:
3803 long nHeight = pControl->GetSizePixel().Height();
3804 aZiel.X() += 5;
3805 aZiel.Y() += nHeight / 2;
3807 break;
3808 case Mitte:
3810 Size aSize = pControl->GetOutputSizePixel();
3811 aZiel.Move( aSize.Width() / 2, aSize.Height() / 2 );
3813 break;
3814 case MitteOben:
3816 long nWidth = pControl->GetSizePixel().Width();
3817 aZiel.X() += nWidth / 2;
3818 aZiel.Y() += 5;
3820 break;
3822 AnimateMouse( pControl, aZiel );
3826 void StatementControl::AnimateMouse( Window *pControl, Point aWohin )
3828 Point aAkt = pControl->GetPointerPosPixel();
3829 Point aZiel = aWohin;
3831 long nSteps;
3832 Point aDiff = aAkt - aZiel;
3834 if ( Abs(aDiff.X()) < Abs(aDiff.Y()) )
3835 nSteps = Abs(aDiff.Y()) / 5;
3836 else
3837 nSteps = Abs(aDiff.X()) / 5;
3838 if ( nSteps == 0 )
3839 return;
3841 aDiff *= 1000;
3842 aDiff /= nSteps;
3844 StatementList::bExecuting = TRUE; // Bah ist das ein ekliger Hack
3845 // Das verhindert, daß schon der nächste Befehl ausgeführt wird.
3847 for ( ; nSteps ; nSteps-- )
3849 if ( Abs((aAkt - pControl->GetPointerPosPixel()).X()) > 5 ||
3850 Abs((aAkt - pControl->GetPointerPosPixel()).Y()) > 5 )
3851 nSteps = 1;
3852 aAkt = aZiel + aDiff * nSteps / 1000;
3853 pControl->SetPointerPosPixel(aAkt);
3854 SafeReschedule();
3856 pControl->SetPointerPosPixel(aZiel);
3857 StatementList::bExecuting = FALSE; // Bah ist das ein ekliger Hack
3861 BOOL StatementControl::MaybeDoTypeKeysDelay( Window *pTestWindow )
3863 if ( bDoTypeKeysDelay )
3865 ULONG nTimeWait = nMinTypeKeysDelay;
3866 if ( nMaxTypeKeysDelay != nMinTypeKeysDelay )
3867 nTimeWait += Time::GetSystemTicks() % ( nMaxTypeKeysDelay - nMinTypeKeysDelay );
3868 Timer aTimer;
3869 aTimer.SetTimeout( nTimeWait );
3870 aTimer.Start();
3871 StatementList::bExecuting = TRUE; // Bah ist das ein ekliger Hack
3872 // Das verhindert, daß schon der nächste Befehl ausgeführt wird.
3873 while ( aTimer.IsActive() )
3875 SafeReschedule( TRUE );
3877 StatementList::bExecuting = FALSE; // Bah ist das ein ekliger Hack
3878 if ( !WinPtrValid(pTestWindow ) )
3880 ReportError( aUId, GEN_RES_STR1( S_WINDOW_DISAPPEARED, MethodString( nMethodId ) ) );
3881 return FALSE;
3884 return TRUE;
3887 BOOL StatementControl::HandleVisibleControls( Window *pControl )
3889 if( pControl ) // Also auch bei Disabled nicht jedoch bei Invisible
3891 switch( nMethodId )
3893 case M_IsEnabled:
3894 pRet->GenReturn ( RET_Value, aUId, IsAccessable(pControl) );
3895 break;
3896 case M_IsVisible:
3897 pRet->GenReturn ( RET_Value, aUId, pControl->IsVisible() );
3898 break;
3899 case M_GetPosX:
3900 if ( pControl->GetType() == WINDOW_DOCKINGWINDOW && pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_FLOATINGWINDOW )
3901 pControl = pControl->GET_REAL_PARENT(); // Sonderbehandlung für FloatingWindows
3902 if ( pControl->GetType() == WINDOW_TABCONTROL && pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_TABDIALOG )
3903 pControl = pControl->GET_REAL_PARENT(); // Sonderbehandlung für TabDialoge
3904 if ( pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_BORDERWINDOW )
3905 pControl = pControl->GET_REAL_PARENT(); // Sonderbehandlung für Border
3906 if ( (nParams & PARAM_BOOL_1) && bBool1 )
3907 pControl = pControl->GetWindow( WINDOW_OVERLAP );
3909 if ( pControl->GetType() == WINDOW_DOCKINGWINDOW && pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_SPLITWINDOW )
3911 Point aPos = pControl->GetPosPixel();
3912 aPos = pControl->GET_REAL_PARENT()->OutputToScreenPixel( aPos );
3913 pRet->GenReturn ( RET_Value, aUId, (comm_ULONG)aPos.X() );
3915 else
3916 pRet->GenReturn ( RET_Value, aUId, (comm_ULONG)pControl->GetPosPixel().X() );
3917 break;
3918 case M_GetPosY:
3919 if ( pControl->GetType() == WINDOW_DOCKINGWINDOW && pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_FLOATINGWINDOW )
3920 pControl = pControl->GET_REAL_PARENT(); // Sonderbehandlung für FloatingWindows
3921 if ( pControl->GetType() == WINDOW_TABCONTROL && pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_TABDIALOG )
3922 pControl = pControl->GET_REAL_PARENT(); // Sonderbehandlung für TabDialoge
3923 if ( pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_BORDERWINDOW )
3924 pControl = pControl->GET_REAL_PARENT(); // Sonderbehandlung für Border
3925 if ( (nParams & PARAM_BOOL_1) && bBool1 )
3926 pControl = pControl->GetWindow( WINDOW_OVERLAP );
3928 if ( pControl->GetType() == WINDOW_DOCKINGWINDOW && pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_SPLITWINDOW )
3930 Point aPos = pControl->GetPosPixel();
3931 aPos = pControl->GET_REAL_PARENT()->OutputToScreenPixel( aPos );
3932 pRet->GenReturn ( RET_Value, aUId, (comm_ULONG)aPos.Y() );
3934 else
3935 pRet->GenReturn ( RET_Value, aUId, (comm_ULONG)pControl->GetPosPixel().Y() );
3936 break;
3937 case M_GetSizeX:
3938 if ( pControl->GetType() == WINDOW_DOCKINGWINDOW && pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_FLOATINGWINDOW )
3939 pControl = pControl->GET_REAL_PARENT(); // Sonderbehandlung für FloatingWindows
3940 if ( pControl->GetType() == WINDOW_TABCONTROL && pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_TABDIALOG )
3941 pControl = pControl->GET_REAL_PARENT(); // Sonderbehandlung für TabDialoge
3942 if ( pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_BORDERWINDOW )
3943 pControl = pControl->GET_REAL_PARENT(); // Sonderbehandlung für Border
3944 if ( (nParams & PARAM_BOOL_1) && bBool1 )
3945 pControl = pControl->GetWindow( WINDOW_OVERLAP );
3947 pRet->GenReturn ( RET_Value, aUId, (comm_ULONG)pControl->GetSizePixel().Width() );
3948 break;
3949 case M_GetSizeY:
3950 if ( pControl->GetType() == WINDOW_DOCKINGWINDOW && pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_FLOATINGWINDOW )
3951 pControl = pControl->GET_REAL_PARENT(); // Sonderbehandlung für FloatingWindows
3952 if ( pControl->GetType() == WINDOW_TABCONTROL && pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_TABDIALOG )
3953 pControl = pControl->GET_REAL_PARENT(); // Sonderbehandlung für TabDialoge
3954 if ( pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_BORDERWINDOW )
3955 pControl = pControl->GET_REAL_PARENT(); // Sonderbehandlung für Border
3956 if ( (nParams & PARAM_BOOL_1) && bBool1 )
3957 pControl = pControl->GetWindow( WINDOW_OVERLAP );
3959 pRet->GenReturn ( RET_Value, aUId, (comm_ULONG)pControl->GetSizePixel().Height() );
3960 break;
3961 case M_SnapShot:
3963 if ( pControl->GetType() == WINDOW_DOCKINGWINDOW && pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_FLOATINGWINDOW )
3964 pControl = pControl->GET_REAL_PARENT(); // Sonderbehandlung für FloatingWindows
3965 if ( pControl->GetType() == WINDOW_TABCONTROL && pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_TABDIALOG )
3966 pControl = pControl->GET_REAL_PARENT(); // Sonderbehandlung für TabDialoge
3967 if ( pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_BORDERWINDOW )
3968 pControl = pControl->GET_REAL_PARENT(); // Sonderbehandlung für Border
3969 if ( (nParams & PARAM_BOOL_1) && bBool1 )
3970 pControl = pControl->GetWindow( WINDOW_OVERLAP );
3972 Bitmap aBmp = pControl->SnapShot();
3973 if ( pControl->GetType() == WINDOW_WORKWINDOW )
3975 Point aStart = pControl->GetPosPixel();
3976 if ( !(nParams & PARAM_USHORT_4) )
3978 nParams |= PARAM_USHORT_1;
3979 nParams |= PARAM_USHORT_2;
3980 nParams |= PARAM_USHORT_3;
3981 nParams |= PARAM_USHORT_4;
3982 nNr1 = (USHORT)-aStart.X();
3983 nNr2 = (USHORT)-aStart.Y();
3984 nNr3 = (USHORT)pControl->GetSizePixel().Width() + 2*(USHORT)aStart.X();
3985 nNr4 = (USHORT)pControl->GetSizePixel().Height() + 2*(USHORT)aStart.Y();
3987 nNr1 = std::max((USHORT)-aStart.X(),nNr1);
3988 nNr2 = std::max((USHORT)-aStart.Y(),nNr2);
3989 nNr3 = std::min((USHORT)(pControl->GetSizePixel().Width() + 2*(USHORT)aStart.X()),nNr3);
3990 nNr4 = std::min((USHORT)(pControl->GetSizePixel().Height() + 2*(USHORT)aStart.Y()),nNr4);
3992 if( nParams & PARAM_USHORT_4 )
3993 { // Zuschneiden
3994 Point aPt(-nNr1,-nNr2);
3995 Size aSz(nNr3,nNr4);
3996 VirtualDevice aVDev( *pControl );
3998 aVDev.SetOutputSizePixel( aSz );
3999 aVDev.DrawBitmap( aPt, aBmp );
4000 aBmp = aVDev.GetBitmap( Point(), aSz );
4003 SvFileStream fOut;
4004 fOut.Open(aString1,STREAM_STD_WRITE);
4005 aBmp.Write(fOut);
4006 if ( fOut.GetError() )
4007 ReportError( aUId, GEN_RES_STR1( S_ERROR_SAVING_IMAGE, UniString::CreateFromInt32( fOut.GetError() ) ) );
4008 fOut.Close();
4010 break;
4011 case M_GetFixedTextCount:
4013 pRet->GenReturn ( RET_Value, aUId, CountWinByRT( pControl, WINDOW_FIXEDTEXT, TRUE ) );
4015 break;
4016 case M_GetFixedText:
4018 if( ( nParams & PARAM_USHORT_1 ) == 0 )
4019 nNr1 = 1;
4021 FixedText* pFixedText = (FixedText*)GetWinByRT( pControl, WINDOW_FIXEDTEXT, TRUE, nNr1-1 );
4022 if ( pFixedText )
4023 pRet->GenReturn ( RET_Value, aUId, pFixedText->GetText() );
4024 else
4025 ValueOK(aUId, MethodString( nMethodId ),nNr1,CountWinByRT( pControl, WINDOW_FIXEDTEXT, TRUE ) );
4027 break;
4028 default:
4029 return FALSE;
4031 SendProfile( UIdString( aUId ).Append('.').Append( MethodString( nMethodId ) ) );
4032 return TRUE;
4034 return FALSE;
4037 BOOL StatementControl::HandleCommonMethods( Window *pControl )
4039 switch( nMethodId ) // Diese können an jedem Window ausgeführt werden
4041 case M_Exists: // Oben schon Behandelt. Unterdrückt hier nur Fehler
4042 case M_NotExists:
4043 case M_IsEnabled:
4044 case M_IsVisible:
4045 case M_SnapShot:
4046 break;
4047 case M_Caption :
4049 if ( pControl->GetText().Len() == 0 && IsDocFrame( pControl->GetWindow( WINDOW_FRAME ) ) )
4050 pRet->GenReturn ( RET_Value, aUId, pControl->GetWindow( WINDOW_FRAME )->GetText());
4051 else
4052 pRet->GenReturn ( RET_Value, aUId, pControl->GetText());
4054 break;
4055 case M_GetRT:
4057 pRet->GenReturn ( RET_Value, aUId, (comm_ULONG)pControl->GetType() );
4059 break;
4060 case M_TypeKeys:
4062 if( !(nParams & PARAM_USHORT_1) ) // Anzahl wiederholungen
4063 nNr1 = 1;
4064 if( !(nParams & PARAM_BOOL_1) ) // Follow Focus
4065 bBool1 = FALSE; // so bleibt das bisherige Verhalten
4067 if ( !bBool1 ) // Altes Verhalten
4068 pControl->GrabFocus();
4069 else // If focus is not inside given control we grab it once.
4071 Window *pFocus = GetpApp()->GetFocusWindow();
4072 if ( !pFocus || !pControl->IsWindowOrChild( pFocus, TRUE ) )
4073 pControl->GrabFocus();
4077 // maybe this can get removed since we are using GetPreferredKeyInputWindow()
4078 if ( pControl->GetType() == WINDOW_COMBOBOX )
4079 { // Bei COMBOBOX an das Edit direkt liefern
4080 Window *pTemp = NULL;
4081 for ( USHORT i = 0 ; i < pControl->GetChildCount() && !pTemp ; i++ )
4082 if ( pControl->GetChild( i )->GetType() == WINDOW_EDIT )
4083 pTemp = pControl->GetChild( i );
4084 if ( pTemp )
4085 pControl = pTemp;
4088 Window *pDeliverHere = pControl;
4089 for (int j = 0; j < nNr1; j++)
4090 for (xub_StrLen i = 0; i < aString1.Len(); i++)
4092 if ( StatementList::bUsePostEvents )
4093 { // grab focus every time
4094 Window *pFocus = GetpApp()->GetFocusWindow();
4095 if ( !pFocus || !pControl->IsWindowOrChild( pFocus, TRUE ) )
4096 pControl->GrabFocus();
4098 if ( bBool1 ) // Jedesmal das FocusWindow finden
4100 Window *pFocus = GetpApp()->GetFocusWindow();
4101 if ( pFocus && pControl->IsWindowOrChild( pFocus, TRUE ) )
4102 pDeliverHere = pFocus;
4103 else // sonst fallback auf das Basisfenster
4104 pDeliverHere = pControl;
4106 pDeliverHere = pDeliverHere->GetPreferredKeyInputWindow();
4107 KeyEvent aEvent;
4108 if ( ((USHORT)aString1.GetChar(i)) <= 7 )
4110 USHORT nVal = 0;
4111 switch (aString1.GetChar(i))
4113 case 1: nVal = aString1.GetChar(i+1) + (aString1.GetChar(i+2) << 8);
4114 i += 2;
4115 break;
4116 case 3: nVal = (aString1.GetChar(i+1) << 8);
4117 i++;
4118 break;
4119 case 5: nVal = aString1.GetChar(i+1);
4120 i++;
4121 break;
4122 case 7: nVal = 0;
4123 break;
4125 // #105672#
4126 // find out the keycode
4127 USHORT nKeygroup = nVal & KEYGROUP_TYPE;
4128 USHORT nKeyCode = nVal & KEY_CODE;
4129 sal_Unicode aCh;
4130 switch (nKeygroup)
4132 case KEYGROUP_NUM:
4133 aCh = nKeyCode - KEY_0 + '0';
4134 break;
4135 case KEYGROUP_ALPHA:
4136 aCh = nKeyCode - KEY_A;
4137 if ( nVal & KEY_MOD1 )
4139 else if ( nVal & KEY_SHIFT )
4140 aCh += 'A';
4141 else
4142 aCh += 'a';
4143 break;
4144 case KEYGROUP_MISC:
4145 { // CR ESC TAB BACK
4146 ByteString aPrintableMisc("\x0d\x1b\x09\x08 **+-*/.,<>=",16);
4147 if ( nKeyCode-KEY_RETURN < aPrintableMisc.Len()
4148 && nKeyCode != KEY_INSERT && nKeyCode != KEY_DELETE )
4149 aCh = aPrintableMisc.GetChar( nKeyCode-KEY_RETURN );
4150 else
4151 aCh = 0;
4153 break;
4154 case KEYGROUP_CURSOR:
4155 case KEYGROUP_FKEYS:
4156 default:
4157 aCh = 0;
4159 aEvent = KeyEvent(aCh,KeyCode(nVal & 0xFFF,nVal & 0xF000));
4161 else
4163 // CR ESC TAB BACK
4164 String aPrintableMisc = CUniString("\x0d\x1b\x09\x08 xx+-*/.,<>=");
4165 sal_Unicode aCh = aString1.GetChar(i);
4166 if ( aCh >= 'a' && aCh <= 'z' )
4167 aEvent = KeyEvent(aCh, KeyCode(KEYGROUP_ALPHA + aCh-'a', 0));
4168 else if ( aCh >= 'A' && aCh <= 'Z' )
4169 aEvent = KeyEvent(aCh, KeyCode(KEYGROUP_ALPHA + aCh-'a', KEY_SHIFT));
4170 else if ( aCh >= '0' && aCh <= '9' )
4171 aEvent = KeyEvent(aCh, KeyCode(KEYGROUP_NUM + aCh-'0', 0));
4172 else if ( aPrintableMisc.Search(aCh) != STRING_NOTFOUND )
4173 aEvent = KeyEvent(aCh, KeyCode(KEYGROUP_MISC + (USHORT)aPrintableMisc.Search(aCh), 0));
4174 else // Sollte eigentlich nicht auftreten
4175 aEvent = KeyEvent(aCh, KeyCode());
4177 ImplKeyInput( pDeliverHere, aEvent );
4178 if ( !MaybeDoTypeKeysDelay( pControl ) )
4179 break;
4180 else
4181 SafeReschedule();SafeReschedule();SafeReschedule();
4184 break;
4186 #define CalcMouseButton\
4187 USHORT nButton = MOUSE_LEFT;\
4188 if ( (nParams & PARAM_USHORT_3) )\
4190 switch ( nNr3 )\
4192 case 1: nButton = MOUSE_LEFT; break;\
4193 case 2: nButton = MOUSE_MIDDLE; break;\
4194 case 3: nButton = MOUSE_RIGHT; break;\
4198 case M_MouseDown:
4200 CalcMouseButton;
4201 Size aS = pControl->GetOutputSizePixel();
4202 Point aPos = Point(aS.Width() * nNr1 / 100,aS.Height() * nNr2 / 100);
4203 Window *pActualWin = pControl->FindWindow( aPos );
4204 // AnimateMouse( pControl, aPos );
4206 if ( pActualWin )
4207 aPos = pActualWin->AbsoluteScreenToOutputPixel( pControl->OutputToAbsoluteScreenPixel ( aPos ) );
4208 // aPos = pActualWin->ScreenToOutputPixel( pControl->OutputToScreenPixel ( aPos ) );
4209 else
4210 pActualWin = pControl;
4212 AnimateMouse( pActualWin, aPos );
4213 pActualWin->GrabFocus();
4214 MouseEvent aMEvnt(aPos,1,MOUSE_SIMPLECLICK|MOUSE_SELECT,nButton);
4215 ImplMouseButtonDown( pActualWin, aMEvnt );
4217 break;
4218 case M_MouseUp:
4220 CalcMouseButton;
4221 Size aS = pControl->GetOutputSizePixel();
4222 Point aPos = Point(aS.Width() * nNr1 / 100,aS.Height() * nNr2 / 100);
4223 Window *pActualWin = pControl->FindWindow( aPos );
4225 if ( pActualWin )
4226 aPos = pActualWin->AbsoluteScreenToOutputPixel( pControl->OutputToAbsoluteScreenPixel ( aPos ) );
4227 // aPos = pActualWin->ScreenToOutputPixel( pControl->OutputToScreenPixel ( aPos ) );
4228 else
4229 pActualWin = pControl;
4231 AnimateMouse( pActualWin, aPos );
4232 // pActualWin->GrabFocus();
4233 MouseEvent aMEvt( aPos, 1, MOUSE_SIMPLECLICK|MOUSE_SELECT, nButton );
4234 ImplMouseButtonUp( pActualWin, aMEvt );
4236 break;
4237 case M_MouseMove:
4239 CalcMouseButton;
4240 Size aS = pControl->GetOutputSizePixel();
4241 Point aPos = Point(aS.Width() * nNr1 / 100,aS.Height() * nNr2 / 100);
4242 Window *pActualWin = pControl->FindWindow( aPos );
4244 if ( pActualWin )
4246 aPos = pActualWin->AbsoluteScreenToOutputPixel( pControl->OutputToAbsoluteScreenPixel ( aPos ) );
4247 // aPos = pActualWin->ScreenToOutputPixel( pControl->OutputToScreenPixel ( aPos ) );
4249 else
4250 pActualWin = pControl;
4252 AnimateMouse( pActualWin, aPos );
4253 // pActualWin->GrabFocus();
4254 MouseEvent aMEvt( aPos, 0, MOUSE_SIMPLEMOVE|MOUSE_DRAGMOVE, nButton );
4255 ImplMouseMove( pActualWin, aMEvt );
4257 break;
4258 case M_MouseDoubleClick:
4260 CalcMouseButton;
4261 Size aS = pControl->GetOutputSizePixel();
4262 Point aPos = Point(aS.Width() * nNr1 / 100,aS.Height() * nNr2 / 100);
4263 Window *pActualWin = pControl->FindWindow( aPos );
4265 if ( pActualWin )
4267 aPos = pActualWin->AbsoluteScreenToOutputPixel( pControl->OutputToAbsoluteScreenPixel ( aPos ) );
4268 // aPos = pActualWin->ScreenToOutputPixel( pControl->OutputToScreenPixel ( aPos ) );
4270 else
4271 pActualWin = pControl;
4273 AnimateMouse( pActualWin, aPos );
4274 pActualWin->GrabFocus();
4275 MouseEvent aMEvnt;
4276 aMEvnt = MouseEvent(aPos,1,MOUSE_SIMPLECLICK|MOUSE_SELECT,nButton);
4277 ImplMouseButtonDown( pActualWin, aMEvnt );
4278 ImplMouseButtonUp ( pActualWin, aMEvnt );
4279 aMEvnt = MouseEvent(aPos,2,MOUSE_SIMPLECLICK|MOUSE_SELECT,nButton);
4280 ImplMouseButtonDown( pActualWin, aMEvnt );
4281 ImplMouseButtonUp ( pActualWin, aMEvnt );
4283 break;
4284 case M_DisplayPercent:
4286 ModelessDialog *pDlg = new ModelessDialog(NULL);
4287 pDlg->SetOutputSizePixel(Size(100,30));
4289 Edit *pMyEd = new Edit(pDlg,WB_CENTER | WB_BORDER );
4290 pMyEd->SetSizePixel(Size(100,30));
4291 pDlg->SetText(CUniString("Schließen"));
4292 pDlg->Show();
4293 pMyEd->Show();
4294 ULONG nTime = Time().GetTime();
4296 while (pDlg->IsVisible())
4298 pDlg->ToTop();
4299 for (int i = 1 ; i<10 ; i++)
4300 SafeReschedule();
4301 Point Pos = pControl->GetPointerPosPixel();
4302 Size Siz=pControl->GetOutputSizePixel();
4303 if ( Time().GetTime() - nTime > 10 )
4305 nTime = Time().GetTime();
4306 pMyEd->SetText(UniString::CreateFromInt32(Pos.X()*100/Siz.Width()).AppendAscii("%x").Append( UniString::CreateFromInt32(Pos.Y()*100/Siz.Height()) ).Append('%'));
4310 delete pMyEd;
4311 delete pDlg;
4313 break;
4314 case M_OpenContextMenu:
4316 aSubMenuId1 = SmartId();
4317 aSubMenuId2 = SmartId();
4318 aSubMenuId3 = SmartId();
4319 pMenuWindow = NULL;
4320 Point aPos;
4321 ToolBox* pTB = (ToolBox*)pControl;
4322 if ( (pControl->GetType() == WINDOW_TOOLBOX) && pTB->IsMenuEnabled() )
4324 pTB->ExecuteCustomMenu();
4325 /* Rectangle aRect = pTB->GetMenubuttonRect();
4326 AnimateMouse( pControl, aRect.Center() );
4327 MouseEvent aMEvnt(aRect.Center(),1,MOUSE_SIMPLECLICK,MOUSE_LEFT);
4328 ImplMouseButtonDown( pTB, aMEvnt );*/
4330 else
4332 BOOL bAtMousePos = ( nParams & PARAM_BOOL_1 ) && bBool1;
4333 if ( bAtMousePos )
4335 aPos = pControl->GetPointerPosPixel();
4336 Window *pActualWin = pControl->FindWindow( aPos );
4338 if ( pActualWin )
4340 aPos = pActualWin->AbsoluteScreenToOutputPixel( pControl->OutputToAbsoluteScreenPixel ( aPos ) );
4341 // aPos = pActualWin->ScreenToOutputPixel( pControl->OutputToScreenPixel ( aPos ) );
4342 pControl = pActualWin;
4345 CommandEvent aEvent( aPos, COMMAND_CONTEXTMENU, bAtMousePos );
4346 ImplCommand( pControl, aEvent );
4349 break;
4350 case M_UseMenu:
4352 aSubMenuId1 = SmartId();
4353 aSubMenuId2 = SmartId();
4354 aSubMenuId3 = SmartId();
4355 pMenuWindow = NULL;
4357 while ( pControl && !( ( pControl->GetType() == WINDOW_SYSWINDOW || pControl->GetType() == WINDOW_WORKWINDOW ) && ControlOK( pControl, "" ) ) )
4358 pControl = pControl->GET_REAL_PARENT();
4360 if ( pControl && ((SystemWindow*)pControl)->GetMenuBar() )
4361 pMenuWindow = ((SystemWindow*)pControl);
4362 else
4363 ReportError( GEN_RES_STR1( S_NO_MENU, MethodString( nMethodId ) ) );
4365 break;
4366 case M_FadeIn:
4367 case M_FadeOut:
4368 case M_Pin:
4369 case M_IsFadeIn:
4370 case M_IsPin:
4372 WindowAlign aWindowAlign = WINDOWALIGN_LEFT;
4373 if ( (nParams & PARAM_USHORT_1) )
4375 switch ( nNr1 )
4377 case CONST_ALIGN_LEFT:
4378 aWindowAlign = WINDOWALIGN_LEFT;
4379 break;
4380 case CONST_ALIGN_TOP:
4381 aWindowAlign = WINDOWALIGN_TOP;
4382 break;
4383 case CONST_ALIGN_RIGHT:
4384 aWindowAlign = WINDOWALIGN_RIGHT;
4385 break;
4386 case CONST_ALIGN_BOTTOM:
4387 aWindowAlign = WINDOWALIGN_BOTTOM;
4388 break;
4389 default:
4390 ReportError( aUId, GEN_RES_STR1( S_INVALID_POSITION, MethodString( nMethodId ) ) );
4394 Window* pTemp = NULL;
4395 while ( !pTemp && pControl )
4397 pTemp = GetFadeSplitWin( pControl, aWindowAlign );
4398 pControl = pControl->GET_REAL_PARENT();
4401 if ( !pTemp )
4403 ReportError( aUId, GEN_RES_STR1( S_SPLITWIN_NOT_FOUND, MethodString( nMethodId ) ) );
4404 break;
4407 pControl = pTemp; // So daß wir unten ohne Fehler durchkommen
4408 SplitWindow *pSW = (SplitWindow*) pTemp;
4410 // Rectangle GetAutoHideRect() const;
4411 // Rectangle GetFadeInRect() const;
4412 // Rectangle GetFadeOutRect() const;
4414 switch( nMethodId )
4416 case M_FadeIn:
4417 if ( pSW->IsFadeInButtonVisible() )
4418 pSW->FadeIn();
4419 break;
4420 case M_FadeOut:
4421 if ( pSW->IsFadeOutButtonVisible() )
4422 pSW->FadeOut();
4423 break;
4424 case M_Pin:
4425 if ( ( pSW->GetAutoHideState() && bBool1 )
4426 || ( !pSW->GetAutoHideState() && !bBool1 ) )
4428 MouseEvent aMEvnt;
4429 Point aPt( pSW->GetAutoHideRect().Center() );
4430 aMEvnt = MouseEvent( aPt,1,MOUSE_SIMPLECLICK,MOUSE_LEFT );
4431 ImplMouseButtonDown( pControl, aMEvnt, FORCE_DIRECT_CALL );
4432 ImplMouseButtonUp ( pControl, aMEvnt, FORCE_DIRECT_CALL );
4434 // pSW->AutoHide();
4435 break;
4436 case M_IsFadeIn:
4437 pRet->GenReturn ( RET_Value, aUId, pSW->IsFadeOutButtonVisible() );
4438 break;
4439 case M_IsPin:
4440 pRet->GenReturn ( RET_Value, aUId, (comm_BOOL)!pSW->GetAutoHideState() );
4441 break;
4442 default:
4443 ReportError( aUId, GEN_RES_STR1( S_INTERNAL_ERROR, MethodString( nMethodId ) ) );
4445 SendProfile( UIdString( aUId ).Append('.').Append( MethodString( nMethodId ) ) );
4447 break;
4448 case M_StatusGetText:
4449 case M_StatusIsProgress:
4450 case M_StatusGetItemCount:
4451 case M_StatusGetItemId:
4453 StatusBar *pStatus = NULL;
4454 while ( !pStatus && pControl )
4456 pStatus = (StatusBar*)GetWinByRT( pControl, WINDOW_STATUSBAR, TRUE );
4457 pControl = pControl->GET_REAL_PARENT();
4460 if ( !pStatus )
4462 ReportError( aUId, GEN_RES_STR1( S_NO_STATUSBAR, MethodString( nMethodId ) ) );
4463 break;
4466 switch ( nMethodId )
4468 case M_StatusGetText:
4470 if ( (nParams & PARAM_USHORT_1) )
4472 if ( pStatus->AreItemsVisible() )
4473 pRet->GenReturn ( RET_Value, aUId, String(pStatus->GetItemText(nNr1)));
4474 else
4475 ReportError( aUId, GEN_RES_STR1( S_ITEMS_INVISIBLE, MethodString( nMethodId ) ) );
4477 else
4479 if ( pStatus->AreItemsVisible() )
4481 if ( pStatus->GetItemCount() == 1 )
4483 pRet->GenReturn ( RET_Value, aUId, pStatus->GetItemText( pStatus->GetItemId(0) ));
4485 else
4487 pRet->GenReturn ( RET_Value, aUId, String() );
4490 else
4491 pRet->GenReturn ( RET_Value, aUId, (String)pStatus->GetText() );
4494 break;
4495 case M_StatusIsProgress:
4497 pRet->GenReturn ( RET_Value, aUId, (comm_BOOL)pStatus->IsProgressMode() );
4499 break;
4500 case M_StatusGetItemCount:
4501 if ( pStatus->AreItemsVisible() )
4502 pRet->GenReturn ( RET_Value, aUId, comm_ULONG(pStatus->GetItemCount()));
4503 else
4504 pRet->GenReturn ( RET_Value, aUId, comm_ULONG(0));
4505 break;
4506 case M_StatusGetItemId:
4507 if ( ValueOK(aUId, MethodString( nMethodId ),nNr1,pStatus->GetItemCount()) )
4508 pRet->GenReturn ( RET_Value, aUId, comm_ULONG(pStatus->GetItemId(nNr1-1)));
4509 break;
4512 break;
4513 case M_HasScrollBar:
4514 case M_IsScrollBarEnabled:
4516 if ( (nParams | PARAM_USHORT_1) != PARAM_USHORT_1 ) // so there are other params
4518 ReportError( aUId, GEN_RES_STR0( S_INVALID_PARAMETERS ) );
4519 break;
4522 if( !(nParams & PARAM_USHORT_1) )
4523 nNr1 = CONST_ALIGN_RIGHT; // default is right Scrollbar(vertical)
4525 if ( (nNr1 != CONST_ALIGN_RIGHT) && (nNr1 != CONST_ALIGN_BOTTOM) )
4527 ReportError( aUId, GEN_RES_STR1( S_INVALID_POSITION, MethodString( nMethodId ) ) );
4528 break;
4531 ScrollBar *pScroll = NULL;
4533 USHORT nSteps = 2;
4534 while ( !pScroll && pControl && nSteps-- )
4536 pScroll = GetScrollBar( pControl, nNr1, TRUE );
4537 pControl = pControl->GET_REAL_PARENT();
4540 switch ( nMethodId )
4542 case M_HasScrollBar:
4544 if ( pScroll )
4545 pRet->GenReturn ( RET_Value, aUId, (comm_BOOL)TRUE );
4546 else
4547 pRet->GenReturn ( RET_Value, aUId, (comm_BOOL)FALSE );
4549 break;
4550 case M_IsScrollBarEnabled:
4552 if ( !pScroll )
4554 ReportError( aUId, GEN_RES_STR1( S_NO_SCROLLBAR, MethodString( nMethodId ) ) );
4555 break;
4557 pRet->GenReturn ( RET_Value, aUId, pScroll->IsEnabled() );
4559 break;
4562 break;
4563 default:
4564 return FALSE;
4566 return TRUE;
4570 BOOL StatementControl::Execute()
4572 Window *pControl;
4573 BOOL bStatementDone = TRUE;
4576 if ( IsError )
4578 #if OSL_DEBUG_LEVEL > 1
4579 m_pDbgWin->AddText( "Skipping Window: " );
4580 m_pDbgWin->AddText( aUId.GetText() );
4581 m_pDbgWin->AddText( " Method: " );
4582 m_pDbgWin->AddText( String::CreateFromInt32( nMethodId ) );
4583 m_pDbgWin->AddText( "\n" );
4584 #endif
4585 Advance();
4586 delete this;
4587 return TRUE;
4590 InitProfile();
4591 #if OSL_DEBUG_LEVEL > 1
4592 m_pDbgWin->AddText( "Executing Window: " );
4593 m_pDbgWin->AddText( aUId.GetText() );
4594 m_pDbgWin->AddText( " Method: " );
4595 m_pDbgWin->AddText( String::CreateFromInt32( nMethodId ) );
4596 m_pDbgWin->AddText( "\n" );
4597 #endif
4600 if ( aUId.Matches( UID_ACTIVE ) )
4601 pControl = GetAnyActive();
4602 else
4604 BOOL bSearchButtonOnToolbox = (nParams == PARAM_NONE) && ((M_Click == nMethodId) || (M_TearOff == nMethodId) || (M_IsEnabled == nMethodId) || (M_OpenMenu == nMethodId));
4605 bSearchButtonOnToolbox |= (nParams == PARAM_USHORT_1) && (M_GetState == nMethodId);
4606 if ( nMethodId == M_TypeKeys || nMethodId == M_MouseDown
4607 || nMethodId == M_MouseUp || nMethodId == M_MouseMove
4608 || nMethodId == M_SnapShot )
4610 pControl = NULL;
4611 if ( /*(nMethodId == M_SnapShot || nMethodId == M_TypeKeys) &&*/ !pControl )
4612 pControl = SearchTree( aUId ,bSearchButtonOnToolbox );
4614 else
4615 pControl = SearchTree( aUId ,bSearchButtonOnToolbox );
4619 if ( pControl && pControl->GetType() == WINDOW_TOOLBOX )
4621 if ( !aUId.Matches( pControl->GetSmartUniqueOrHelpId() ) )
4622 { // Also wenn wir irgendwas auf einer Toolbox gefunden haben
4623 switch ( nMethodId )
4625 case M_Click:
4626 case M_TearOff:
4627 case M_OpenMenu:
4628 case M_GetState:
4629 break;
4630 case M_IsEnabled:
4631 nMethodId = _M_IsEnabled; // Umlabeln, da die Behandlung essentiell anders ist!
4632 break;
4633 default:
4634 pControl = NULL;
4640 switch ( nMethodId )
4642 case M_Exists:
4643 case M_NotExists:
4644 Time aT;
4645 USHORT aSeconds = aT.GetMin()*60+aT.GetSec();
4646 if ( !bBool2 ) // wurde im Konstruktor auf FALSE gesetzt
4648 bBool2 = TRUE;
4649 nNr2 = aSeconds;
4650 if( !(nParams & PARAM_USHORT_1) )
4651 nNr1 = 0; // defaultmäßig sofort zurück
4653 if ( aSeconds < nNr2 ) // Falls die Stunde umgesprungen ist
4654 aSeconds += 60*60;
4656 if ( /* !IsAccessable(pControl)#87019# */ !pControl || !pControl->IsVisible() )
4657 pControl = NULL;
4658 if ( ((nMethodId == M_Exists) && pControl) ||
4659 ((nMethodId == M_NotExists) && !pControl) )
4660 { // Wenn Bedingung erfüllt
4661 pRet->GenReturn ( RET_Value, aUId, (comm_BOOL)TRUE );
4663 else
4664 if ( aSeconds <= nNr2 + nNr1 ) // Zeit ist noch nicht abgelaufen
4665 return FALSE;
4666 else
4667 pRet->GenReturn ( RET_Value, aUId, (comm_BOOL)FALSE );
4669 Advance();
4670 delete this;
4671 return TRUE;
4672 // break;
4676 short nRT = 0;
4678 if( pControl ) // Das Fenster Existiert irgendwo, kann aber auch hidden sein!
4680 nRT = ImpGetRType( pControl, aUId ); // If not Numeric pControl is used
4681 #if OSL_DEBUG_LEVEL > 1
4682 m_pDbgWin->AddText( "Type is: " );
4683 m_pDbgWin->AddText( String::CreateFromInt32( nRT ) );
4684 m_pDbgWin->AddText( "\n" );
4685 #endif
4688 if ( nRT == C_Window && // Search for WorkWindow to satisfy these commands
4689 ( nMethodId == M_Close
4690 // || nMethodId == M_Size
4691 // || nMethodId == M_Move
4692 || nMethodId == M_IsMax
4693 || nMethodId == M_IsMin
4694 || nMethodId == M_IsRestore
4695 || nMethodId == M_Minimize
4696 || nMethodId == M_Maximize
4697 || nMethodId == M_Restore ) )
4699 Window* pNewControl = pControl;
4700 while ( pNewControl && pNewControl->GetType() != WINDOW_WORKWINDOW )
4701 pNewControl = pNewControl->GET_REAL_PARENT();
4703 if ( pNewControl )
4705 pControl = pNewControl;
4706 nRT = C_WorkWin;
4711 if ( (!ControlOK( pControl, "" )) && ( nMethodId != M_SnapShot ) && (nRetryCount--))
4713 #if OSL_DEBUG_LEVEL > 1
4714 m_pDbgWin->AddText( CUniString("Reschedule command (").Append( UniString::CreateFromInt32(nRetryCount) ).AppendAscii(")\n") );
4715 #endif
4716 return FALSE;
4719 if( ControlOK( pControl, "" ) )
4721 if ( nMethodId == M_OpenContextMenu && !bBool2 )
4723 pControl->GrabFocus(); // to get asyncron focus on unix
4724 bBool2 = TRUE;
4725 return FALSE;
4727 // TODO: handle GetFocus for all Methods and Windows like this (remove part below)
4728 // See for impact of changed focus for HandleVisibleControls() (taking Snapshots might be different, possible exclude those methods)
4729 if (( (nRT == C_TreeListBox) && !bBool2 )
4730 && nMethodId != M_TypeKeys // TypeKeys macht das selbst, falls eigenes Focushandling gewünscht
4731 && nMethodId != M_MouseDown
4732 && nMethodId != M_MouseUp
4733 && nMethodId != M_MouseMove
4734 /*&& nMethodId != M_MouseDoubleClick*/ )
4736 if ( !pControl->HasFocus() )
4738 pControl->GrabFocus();
4739 int i = 10;
4740 while ( i-- && !pControl->HasFocus() ) // reschedule a bit
4742 SafeReschedule();
4743 if ( !WinPtrValid( pControl ) )
4744 return FALSE;
4746 if ( !pControl->HasFocus() ) // to get asyncronous focus
4748 bBool2 = TRUE;
4749 return FALSE;
4755 Advance();
4757 if ( HandleVisibleControls( pControl ) )
4759 delete this;
4760 return TRUE;
4762 if( ControlOK( pControl, "Window/Control" ) )
4764 if (((( nRT < C_TabPage && nRT > C_TabControl )
4765 || nRT == C_PatternBox
4766 || nRT == C_ToolBox
4767 || nRT == C_ValueSet
4768 || nRT == C_Control
4769 || nRT == C_TreeListBox
4771 || nMethodId == M_OpenContextMenu )
4772 && nMethodId != M_TypeKeys // TypeKeys macht das selbst, falls eigenes Focushandling gewünscht
4773 && nMethodId != M_MouseDown
4774 && nMethodId != M_MouseUp
4775 && nMethodId != M_MouseMove
4776 /*&& nMethodId != M_MouseDoubleClick*/ )
4777 pControl->GrabFocus();
4779 /* leads to problems because settext sets the text whereas typekeys adds to the text.
4780 if ( bDoTypeKeysDelay && nMethodId == M_SetText && ( nParams & PARAM_STR_1 ) )
4781 { // Hier wird das Statement auf ein TypeKeys umgebogen
4782 nMethodId = M_TypeKeys;
4783 nParams = PARAM_BOOL_1 | PARAM_STR_1;
4784 bBool1 = TRUE;
4785 pControl->GrabFocus();
4788 if ( !HandleCommonMethods( pControl ) )
4790 switch( nRT )
4792 case C_TabControl:
4793 switch( nMethodId )
4795 case M_GetPageId:
4796 if ( (nParams & PARAM_USHORT_1) )
4798 if ( ValueOK(aUId, MethodString( nMethodId ),nNr1,((TabControl*)pControl)->GetPageCount() ) )
4799 pRet->GenReturn ( RET_Value, aUId, (comm_ULONG)((TabControl*)pControl)->GetPageId(nNr1-1));
4801 else
4802 pRet->GenReturn ( RET_Value, aUId, (comm_ULONG)((TabControl*)pControl)->GetCurPageId());
4803 break;
4804 case M_GetPageCount:
4805 pRet->GenReturn ( RET_Value, aUId, (comm_ULONG)((TabControl*)pControl)->GetPageCount());
4806 break;
4807 case M_SetPageId:
4808 if (((TabControl*)pControl)->GetCurPageId())
4809 ((TabControl*)pControl)->DeactivatePage();
4810 ((TabControl*)pControl)->SetCurPageId( nNr1 );
4811 ((TabControl*)pControl)->ActivatePage();
4812 break;
4813 case M_SetPageNr:
4814 if ( ValueOK(aUId, MethodString( nMethodId ),nNr1,((TabControl*)pControl)->GetPageCount() ) )
4816 if (((TabControl*)pControl)->GetCurPageId())
4817 ((TabControl*)pControl)->DeactivatePage();
4818 ((TabControl*)pControl)->SetCurPageId( ((TabControl*)pControl)->GetPageId( nNr1-1 ) );
4819 ((TabControl*)pControl)->ActivatePage();
4821 break;
4822 case M_GetPage:
4823 pRet->GenReturn ( RET_Value, aUId, static_cast<comm_ULONG>(((TabControl*)pControl)->GetTabPage(((TabControl*)pControl)->GetCurPageId())->GetSmartUniqueOrHelpId().GetNum())); //GetNum() ULONG != comm_ULONG on 64bit
4824 break;
4825 case M_SetPage :
4826 { // Wegen lokaler Variablen
4827 TabControl *pTControl = ((TabControl*)pControl);
4828 USHORT nActive = pTControl->GetCurPageId();
4829 USHORT i,anz;
4830 ULONG nID = 0;
4831 i = pTControl->GetPagePos( pTControl->GetCurPageId() );
4832 for ( anz=0 ; anz < pTControl->GetPageCount() && nID != nLNr1 ; anz++ )
4834 pTControl->SelectTabPage( pTControl->GetPageId(i) );
4835 /*if (pTControl->GetCurPageId())
4836 pTControl->DeactivatePage();
4837 pTControl->SetCurPageId( pTControl->GetPageId(i) );
4838 pTControl->ActivatePage();*/
4839 nID = pTControl->GetTabPage(pTControl->GetCurPageId())->GetSmartUniqueOrHelpId().GetNum();
4840 i++;
4841 if ( i >= pTControl->GetPageCount() )
4842 i = 0;
4843 if ( !MaybeDoTypeKeysDelay( pTControl ) || !MaybeDoTypeKeysDelay( pTControl ) || !MaybeDoTypeKeysDelay( pTControl ) ) // 3 Mal aufrufen
4844 break;
4846 if ( nID != nLNr1 )
4848 pTControl->SelectTabPage( nActive );
4849 /*if (pTControl->GetCurPageId())
4850 pTControl->DeactivatePage();
4851 pTControl->SetCurPageId( nActive );
4852 pTControl->ActivatePage();*/
4853 ReportError( SmartId( nLNr1 ), GEN_RES_STR1( S_TABPAGE_NOT_FOUND, MethodString( nMethodId ) ) );
4856 break;
4857 default:
4858 ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "TabControl" ) );
4859 break;
4861 break;
4862 case C_RadioButton:
4863 case C_ImageRadioButton:
4864 switch( nMethodId )
4866 case M_AnimateMouse :
4867 AnimateMouse( pControl, MitteLinks);
4868 break;
4869 case M_IsChecked :
4870 pRet->GenReturn ( RET_Value, aUId, ((RadioButton*)pControl)->IsChecked());
4871 break;
4872 case M_Check :
4873 ((RadioButton*)pControl)->Check();
4874 ((RadioButton*)pControl)->Click();
4875 break;
4876 default:
4877 ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "RadioButton" ) );
4878 break;
4880 break;
4881 case C_CheckBox:
4882 case C_TriStateBox:
4883 switch( nMethodId )
4885 case M_AnimateMouse :
4886 AnimateMouse( pControl, MitteLinks);
4887 break;
4888 case M_IsChecked :
4889 pRet->GenReturn ( RET_Value, aUId, comm_BOOL( ((TriStateBox*)pControl)->GetState() == STATE_CHECK) );
4890 break;
4891 case M_IsTristate :
4892 pRet->GenReturn ( RET_Value, aUId, comm_BOOL( ((TriStateBox*)pControl)->GetState() == STATE_DONTKNOW) );
4893 break;
4894 case M_GetState :
4895 pRet->GenReturn ( RET_Value, aUId, comm_ULONG(((TriStateBox*)pControl)->GetState()));
4896 break;
4897 case M_Check :
4898 ((TriStateBox*)pControl)->SetState( STATE_CHECK );
4899 ((TriStateBox*)pControl)->Click();
4900 break;
4901 case M_UnCheck :
4902 ((TriStateBox*)pControl)->SetState( STATE_NOCHECK );
4903 ((TriStateBox*)pControl)->Click();
4904 break;
4905 case M_TriState :
4906 if ( ((TriStateBox*)pControl)->IsTriStateEnabled() )
4908 ((TriStateBox*)pControl)->SetState( STATE_DONTKNOW );
4909 ((TriStateBox*)pControl)->Click();
4911 else
4913 ReportError( aUId, GEN_RES_STR0( S_TRISTATE_NOT_ALLOWED ) );
4915 break;
4916 case M_Click :
4918 TriStateBox *pTB = ((TriStateBox*)pControl);
4919 if ( pTB->GetState() == STATE_NOCHECK )
4920 pTB->SetState( STATE_CHECK );
4921 else if ( pTB->GetState() == STATE_CHECK )
4923 if ( pTB->IsTriStateEnabled() )
4924 pTB->SetState( STATE_DONTKNOW );
4925 else
4926 pTB->SetState( STATE_NOCHECK );
4928 else
4929 pTB->SetState( STATE_NOCHECK );
4930 pTB->Click();
4932 break;
4933 default:
4934 ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "TriStateBox" ) );
4935 break;
4937 break;
4938 case C_Edit:
4939 case C_MultiLineEdit:
4940 switch( nMethodId )
4942 case M_AnimateMouse :
4943 AnimateMouse( pControl, Mitte);
4944 break;
4945 case M_GetText :
4946 pRet->GenReturn ( RET_Value, aUId, ((Edit*)pControl)->GetText());
4947 break;
4948 case M_IsWritable:
4949 pRet->GenReturn ( RET_Value, aUId, (comm_BOOL) !((Edit*)pControl)->IsReadOnly() );
4950 break;
4951 default:
4952 if ( ! ((Edit*)pControl)->IsReadOnly() )
4954 switch( nMethodId )
4956 case M_SetText :
4957 ((Edit*)pControl)->SetText( aString1 );
4958 if ( nRT == C_MultiLineEdit ) // since SetModifyFlag is not virtual we have to do this
4959 ((MultiLineEdit*)pControl)->SetModifyFlag();
4960 else
4961 ((Edit*)pControl)->SetModifyFlag();
4962 ((Edit*)pControl)->Modify();
4963 if ( ((Edit*)pControl)->GetText().CompareTo(aString1) != COMPARE_EQUAL )
4964 ReportError( aUId, GEN_RES_STR1( S_ERROR_IN_SET_TEXT, MethodString( nMethodId ) ) );
4965 break;
4966 default:
4967 ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "(MultiLine)Edit" ) );
4968 break;
4971 else
4972 ReportError( aUId, GEN_RES_STR1c( S_ATTEMPT_TO_WRITE_READONLY, "(MultiLine)Edit" ) );
4974 break;
4975 case C_MultiListBox:
4976 case C_ListBox:
4977 switch( nMethodId )
4979 case M_AnimateMouse :
4980 AnimateMouse( pControl, MitteOben);
4981 break;
4982 case M_GetSelCount :
4983 pRet->GenReturn ( RET_Value, aUId, comm_ULONG(((ListBox*)pControl)->GetSelectEntryCount()));
4984 break;
4985 case M_GetSelIndex :
4986 if ( ! (nParams & PARAM_USHORT_1) )
4988 if ( ((ListBox*)pControl)->GetSelectEntryCount() == 0 )
4990 pRet->GenReturn ( RET_Value, aUId, comm_ULONG(0));
4991 break;
4993 nNr1 = 1;
4995 ValueOK(aUId, MethodString( nMethodId ),nNr1,((ListBox*)pControl)->GetSelectEntryCount());
4996 pRet->GenReturn ( RET_Value, aUId, comm_ULONG(((ListBox*)pControl)->GetSelectEntryPos(nNr1-1)) +1);
4997 break;
4998 case M_GetSelText :
4999 if ( ! (nParams & PARAM_USHORT_1) )
5000 nNr1 = 1;
5001 pRet->GenReturn ( RET_Value, aUId, ((ListBox*)pControl)->GetSelectEntry(nNr1-1));
5002 break;
5003 case M_GetItemCount :
5004 pRet->GenReturn ( RET_Value, aUId, comm_ULONG(((ListBox*)pControl)->GetEntryCount()));
5005 break;
5006 case M_GetItemText :
5007 pRet->GenReturn ( RET_Value, aUId, ((ListBox*)pControl)->GetEntry(nNr1-1));
5008 break;
5009 case M_Select:
5010 case M_MultiSelect:
5012 BOOL bUnselectBeforeSelect = ( nMethodId == M_Select );
5013 BOOL bFehler = FALSE;
5014 if ( ! (nParams & PARAM_BOOL_1) )
5015 bBool1 = TRUE;
5017 if ( nMethodId == M_MultiSelect && nRT == C_ListBox )
5019 ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "ListBox" ) );
5020 bFehler = TRUE;
5023 if ( !bBool1 && nMethodId == M_Select )
5025 ReportError( aUId, GEN_RES_STR1( S_NO_SELECT_FALSE, MethodString( nMethodId ) ) );
5026 bFehler = TRUE;
5029 if ( !bFehler )
5031 if( nParams & PARAM_STR_1 )
5033 ListBox *pLB = ((ListBox*)pControl);
5034 USHORT nPos;
5035 if ( (nPos = pLB->GetEntryPos( aString1 )) == LISTBOX_ENTRY_NOTFOUND )
5036 ReportError( aUId, GEN_RES_STR2( S_ENTRY_NOT_FOUND, MethodString( nMethodId ), aString1 ) );
5037 else
5039 if ( bUnselectBeforeSelect )
5040 pLB->SetNoSelection();
5041 pLB->SelectEntryPos( nPos, bBool1 );
5042 if ( pLB->IsEntryPosSelected( nPos ) ? !bBool1 : bBool1 ) // XOR rein mit BOOL
5043 ReportError( aUId, GEN_RES_STR2( S_METHOD_FAILED, MethodString( nMethodId ), aString1 ) );
5046 else
5048 ListBox *pLB = ((ListBox*)pControl);
5049 pLB = static_cast<ListBox*>(pControl);
5050 if ( ValueOK(aUId, MethodString( nMethodId ),nNr1,pLB->GetEntryCount()) )
5052 if ( bUnselectBeforeSelect )
5053 pLB->SetNoSelection();
5054 pLB->SelectEntryPos( nNr1-1, bBool1 );
5055 if ( pLB->IsEntryPosSelected( nNr1-1 ) ? !bBool1 : bBool1 ) // XOR rein mit BOOL
5056 ReportError( aUId, GEN_RES_STR2( S_METHOD_FAILED, MethodString( nMethodId ), UniString::CreateFromInt32( nNr1 ) ) );
5059 ((ListBox*)pControl)->Select();
5062 break;
5063 case M_SetNoSelection :
5064 ((ListBox*)pControl)->SetNoSelection();
5065 ((ListBox*)pControl)->Select();
5066 break;
5067 default:
5068 ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "(Multi)ListBox" ) );
5069 break;
5071 break;
5072 case C_ComboBox:
5073 case C_PatternBox:
5074 case C_NumericBox:
5075 case C_MetricBox:
5076 case C_CurrencyBox:
5077 case C_DateBox:
5078 case C_TimeBox:
5079 switch( nMethodId )
5081 case M_AnimateMouse :
5082 AnimateMouse( pControl, MitteOben);
5083 break;
5084 case M_GetSelText :
5085 pRet->GenReturn ( RET_Value, aUId, ((ComboBox*)pControl)->GetText());
5086 break;
5087 case M_GetSelIndex :
5089 USHORT nPos = ((ComboBox*)pControl)->GetEntryPos(((ComboBox*)pControl)->GetText());
5090 if ( nPos == COMBOBOX_ENTRY_NOTFOUND )
5091 nPos = 0;
5092 else
5093 nPos++;
5094 pRet->GenReturn ( RET_Value, aUId, (comm_ULONG) nPos);
5096 break;
5097 case M_GetItemCount :
5098 pRet->GenReturn ( RET_Value, aUId, comm_ULONG(((ComboBox*)pControl)->GetEntryCount()));
5099 break;
5100 case M_GetItemText :
5101 pRet->GenReturn ( RET_Value, aUId, ((ComboBox*)pControl)->GetEntry(nNr1-1));
5102 break;
5103 case M_IsWritable:
5104 pRet->GenReturn ( RET_Value, aUId, (comm_BOOL) !((ComboBox*)pControl)->IsReadOnly() );
5105 break;
5106 case M_Select :
5107 if( nParams & PARAM_USHORT_1 )
5109 if ( !ValueOK(aUId, MethodString( nMethodId ),nNr1,((ComboBox*)pControl)->GetEntryCount()) )
5110 break;
5111 aString1 = ((ComboBox*)pControl)->GetEntry(nNr1-1);
5113 else
5115 if ( ((ComboBox*)pControl)->GetEntryPos( aString1 ) == COMBOBOX_ENTRY_NOTFOUND )
5117 ReportError( aUId, GEN_RES_STR2( S_ENTRY_NOT_FOUND, MethodString( nMethodId ), aString1 ) );
5118 break;
5123 ((ComboBox*)pControl)->SetText( aString1 );
5124 ((ComboBox*)pControl)->SetModifyFlag();
5125 ((ComboBox*)pControl)->Modify();
5126 break;
5127 case M_SetText :
5128 if ( ! ((ComboBox*)pControl)->IsReadOnly() )
5130 if ( ! (nParams & PARAM_STR_1) )
5131 aString1 = String();
5132 ((ComboBox*)pControl)->SetText( aString1 );
5133 ((ComboBox*)pControl)->SetModifyFlag();
5134 ((ComboBox*)pControl)->Modify();
5136 else
5137 ReportError( aUId, GEN_RES_STR1c( S_ATTEMPT_TO_WRITE_READONLY, "ComboBox" ) );
5138 break;
5139 default:
5140 ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "ComboBox" ) );
5141 break;
5143 break;
5144 case C_PushButton:
5145 case C_OkButton:
5146 case C_CancelButton:
5147 case C_ImageButton:
5148 switch( nMethodId )
5150 case M_AnimateMouse :
5151 AnimateMouse( pControl, Mitte);
5152 break;
5153 case M_Click :
5154 ((PushButton*)pControl)->Click();
5155 break;
5156 default:
5157 ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "PushButton" ) );
5158 break;
5160 break;
5161 case C_MoreButton:
5162 switch( nMethodId )
5164 case M_AnimateMouse :
5165 AnimateMouse( pControl, Mitte);
5166 break;
5167 case M_IsOpen :
5168 pRet->GenReturn ( RET_Value, aUId, ((MoreButton*)pControl)->GetState());
5169 break;
5170 case M_Click :
5171 ((MoreButton*)pControl)->Click();
5172 break;
5173 case M_Open :
5174 ((MoreButton*)pControl)->SetState(TRUE);
5175 break;
5176 case M_Close :
5177 ((MoreButton*)pControl)->SetState(FALSE);
5178 break;
5179 default:
5180 ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "MoreButton" ) );
5181 break;
5183 break;
5184 case C_SpinField:
5185 case C_PatternField:
5186 case C_NumericField:
5187 case C_MetricField:
5188 case C_CurrencyField:
5189 case C_DateField:
5190 case C_TimeField:
5191 switch( nMethodId )
5193 case M_AnimateMouse :
5194 AnimateMouse( pControl, Mitte);
5195 break;
5196 case M_GetText :
5197 pRet->GenReturn ( RET_Value, aUId, ((SpinField*)pControl)->GetText());
5198 break;
5199 case M_IsWritable:
5200 pRet->GenReturn ( RET_Value, aUId, (comm_BOOL) !((SpinField*)pControl)->IsReadOnly() );
5201 break;
5202 case M_SetText :
5203 if ( ! ((SpinField*)pControl)->IsReadOnly() )
5205 ((SpinField*)pControl)->SetText( aString1 );
5206 ((SpinField*)pControl)->SetModifyFlag();
5207 ((SpinField*)pControl)->Modify();
5209 else
5210 ReportError( aUId, GEN_RES_STR1c( S_ATTEMPT_TO_WRITE_READONLY, "SpinField" ) );
5211 break;
5212 case M_More :
5214 if ( !(nParams & PARAM_USHORT_1) )
5215 nNr1 = 1;
5216 for (int i = 1; i<= nNr1; i++)
5218 ((SpinField*)pControl)->Up();
5219 ((SpinField*)pControl)->SetModifyFlag();
5220 ((SpinField*)pControl)->Modify();
5223 break;
5224 case M_Less :
5226 if ( !(nParams & PARAM_USHORT_1) )
5227 nNr1 = 1;
5228 for (int i = 1; i<= nNr1; i++)
5230 ((SpinField*)pControl)->Down();
5231 ((SpinField*)pControl)->SetModifyFlag();
5232 ((SpinField*)pControl)->Modify();
5235 break;
5236 case M_ToMin :
5237 ((SpinField*)pControl)->First();
5238 ((SpinField*)pControl)->SetModifyFlag();
5239 ((SpinField*)pControl)->Modify();
5240 break;
5241 case M_ToMax :
5242 ((SpinField*)pControl)->Last();
5243 ((SpinField*)pControl)->SetModifyFlag();
5244 ((SpinField*)pControl)->Modify();
5245 break;
5246 default:
5247 ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "SpinField" ) );
5248 break;
5250 break;
5252 case C_MenuButton:
5253 switch( nMethodId )
5255 case M_AnimateMouse :
5256 AnimateMouse( pControl, Mitte);
5257 break;
5258 case M_Click :
5260 MouseEvent aMEvnt;
5261 Point aPt( pControl->GetSizePixel().Width() / 2, pControl->GetSizePixel().Height() / 2 );
5262 aMEvnt = MouseEvent( aPt,1,MOUSE_SIMPLECLICK,MOUSE_LEFT );
5263 ImplMouseButtonDown( pControl, aMEvnt, FORCE_DIRECT_CALL );
5264 ImplMouseButtonUp ( pControl, aMEvnt, FORCE_DIRECT_CALL );
5266 break;
5267 case M_Open :
5268 case M_OpenMenu :
5270 MouseEvent aMEvnt;
5271 Point aPt( pControl->GetSizePixel().Width() / 2, pControl->GetSizePixel().Height() / 2 );
5272 aMEvnt = MouseEvent( aPt,1,MOUSE_SIMPLECLICK,MOUSE_LEFT );
5273 ImplMouseButtonDown( pControl, aMEvnt, FORCE_DIRECT_CALL );
5275 ULONG nStart = Time::GetSystemTicks();
5276 ULONG nDelay = pControl->GetSettings().GetMouseSettings().GetActionDelay();
5277 while ( ( Time::GetSystemTicks() - nStart ) < nDelay + 100 )
5278 SafeReschedule();
5280 ImplMouseButtonUp ( pControl, aMEvnt, FORCE_DIRECT_CALL );
5282 aSubMenuId1 = SmartId();
5283 aSubMenuId2 = SmartId();
5284 aSubMenuId3 = SmartId();
5285 pMenuWindow = NULL;
5287 break;
5288 default:
5289 ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "MenuButton" ) );
5290 break;
5292 break;
5293 case C_ToolBox:
5295 ToolBox *pTB = ((ToolBox*)pControl);
5296 if ( !aUId.Matches( pTB->GetSmartUniqueOrHelpId() ) ) // Also Button auf der ToolBox gefunden
5298 if ( (nParams == PARAM_NONE) || (nParams == PARAM_USHORT_1) )
5299 { // Wir fälschen einen Parameter
5300 if ( aUId.HasNumeric() )
5302 nParams = PARAM_ULONG_1;
5303 nLNr1 = USHORT( aUId.GetNum() );
5304 DBG_ASSERT( nLNr1 <= 0xFFFF, "ID on ToolBox > 0xFFFF" );
5306 else
5308 nParams = PARAM_STR_1;
5309 aString1 = aUId.GetStr();
5312 else
5313 ReportError( aUId, GEN_RES_STR1( S_INTERNAL_ERROR, MethodString( nMethodId ) ) );
5316 #define FIND_ITEM\
5317 USHORT nItemPos = 0;\
5318 BOOL bItemFound = FALSE;\
5320 SmartId aButtonId;\
5321 if( nParams == PARAM_STR_1 )\
5322 aButtonId = SmartId( aString1 );\
5323 if( nParams == PARAM_ULONG_1 )\
5324 aButtonId = SmartId( nLNr1 );\
5325 for ( nItemPos = 0; nItemPos < pTB->GetItemCount() && !aButtonId.Matches(pTB->GetItemCommand(pTB->GetItemId(nItemPos))) &&\
5326 !aButtonId.Matches(pTB->GetHelpId(pTB->GetItemId(nItemPos))) ; nItemPos++ ) {}\
5327 bItemFound = aButtonId.Matches(pTB->GetItemCommand(pTB->GetItemId(nItemPos))) || aButtonId.Matches(pTB->GetHelpId(pTB->GetItemId(nItemPos)));\
5328 if ( !bItemFound )\
5329 ReportError( aUId, GEN_RES_STR1( S_HELPID_ON_TOOLBOX_NOT_FOUND, MethodString( nMethodId ) ) );\
5330 else\
5332 if ( !pTB->IsItemEnabled( pTB->GetItemId(nItemPos) ) && nMethodId != _M_IsEnabled )\
5334 ReportError( aUId, GEN_RES_STR1( S_BUTTON_DISABLED_ON_TOOLBOX, MethodString( nMethodId ) ) );\
5335 bItemFound = FALSE;\
5337 else if ( !pTB->IsItemVisible( pTB->GetItemId(nItemPos) ) )\
5339 ReportError( aUId, GEN_RES_STR1( S_BUTTON_HIDDEN_ON_TOOLBOX, MethodString( nMethodId ) ) );\
5340 bItemFound = FALSE;\
5342 else\
5344 if ( pTB->IsMenuEnabled() )\
5345 { /* button is in Menu */\
5347 else\
5348 { /* Try the multi line way */\
5349 if ( pTB->GetItemRect(pTB->GetItemId(nItemPos)).IsEmpty() )\
5351 USHORT nLine = pTB->GetCurLine();\
5354 pTB->ShowLine( FALSE );\
5355 for ( int i = 1 ; i < 30 ; i++ )\
5356 SafeReschedule();\
5358 while ( pTB->GetCurLine() != nLine && pTB->GetItemRect(pTB->GetItemId(nItemPos)).IsEmpty() );\
5359 pTB->Invalidate( pTB->GetScrollRect() );\
5361 if ( pTB->GetItemRect(pTB->GetItemId(nItemPos)).IsEmpty() )\
5363 ReportError( aUId, GEN_RES_STR1( S_CANNOT_MAKE_BUTTON_VISIBLE_IN_TOOLBOX, MethodString( nMethodId ) ) );\
5364 bItemFound = FALSE;\
5371 switch( nMethodId )
5373 case M_AnimateMouse :
5374 AnimateMouse( pControl, MitteLinks);
5375 break;
5376 case M_Click :
5378 FIND_ITEM;
5379 if ( bItemFound ) // FIND_ITEM Erfolgreich
5381 Rectangle aRect = pTB->GetItemRect(pTB->GetItemId(nItemPos));
5382 if ( aRect.IsEmpty() )
5384 pTB->ExecuteCustomMenu();
5385 /* aRect = pTB->GetMenubuttonRect();
5386 MouseEvent aMEvnt(aRect.Center(),1,MOUSE_SIMPLECLICK,MOUSE_LEFT);
5387 ImplMouseButtonDown( pTB, aMEvnt );*/
5389 aSubMenuId1 = SmartId();
5390 aSubMenuId2 = SmartId();
5391 aSubMenuId3 = SmartId();
5392 pMenuWindow = NULL;
5394 new StatementCommand( this, RC_MenuSelect, PARAM_USHORT_1, pTB->GetItemId(nItemPos) + TOOLBOX_MENUITEM_START );
5396 else
5398 aRect = pTB->GetItemRect(pTB->GetItemId(nItemPos));
5399 MouseEvent aMEvnt;
5400 aMEvnt = MouseEvent(aRect.Center(),1,MOUSE_SIMPLECLICK,MOUSE_LEFT);
5401 ImplMouseButtonDown( pTB, aMEvnt, FORCE_DIRECT_CALL );
5402 ImplMouseButtonUp ( pTB, aMEvnt, FORCE_DIRECT_CALL );
5406 break;
5407 case M_TearOff :
5409 FIND_ITEM;
5410 if ( bItemFound ) // FIND_ITEM Erfolgreich
5412 Rectangle aRect = pTB->GetItemPosDropDownRect( nItemPos );
5413 AnimateMouse( pControl, aRect.Center() );
5414 MouseEvent aMEvnt(aRect.Center(),1,MOUSE_SIMPLECLICK,MOUSE_LEFT);
5415 ImplMouseButtonDown( pTB, aMEvnt, FORCE_DIRECT_CALL );
5417 Window *pWin = NULL;
5418 // Wait for the window to open.
5419 StatementList::bExecuting = TRUE; // Bah ist das ein ekliger Hack
5420 { // Das verhindert, daß schon der nächste Befehl ausgeführt wird.
5421 Time aDelay;
5422 while ( !pWin && ( (pWin = GetPopupFloatingWin()) == NULL ) && ( Time() - aDelay ).GetSec() < 15 )
5423 SafeReschedule();
5425 StatementList::bExecuting = FALSE; // Bah ist das ein ekliger Hack
5427 if ( pWin && pWin->GetType() == WINDOW_FLOATINGWINDOW )
5429 aMEvnt = MouseEvent(aRect.Center(),1,MOUSE_SIMPLECLICK,MOUSE_LEFT);
5430 ImplMouseButtonUp( pTB, aMEvnt, FORCE_DIRECT_CALL );
5431 ((FloatingWindow*)pWin)->EndPopupMode( FLOATWIN_POPUPMODEEND_TEAROFF );
5433 else
5435 aMEvnt = MouseEvent(Point(1,-10), 1, MOUSE_SIMPLECLICK,MOUSE_LEFT);
5436 ImplMouseButtonUp( pTB, aMEvnt, FORCE_DIRECT_CALL );
5437 ReportError( aUId, GEN_RES_STR1( S_TEAROFF_FAILED, MethodString( nMethodId ) ) );
5441 break;
5442 case M_OpenMenu :
5444 FIND_ITEM;
5445 if ( bItemFound ) // FIND_ITEM Erfolgreich
5447 Rectangle aRect = pTB->GetItemPosDropDownRect( nItemPos );
5448 AnimateMouse( pControl, aRect.Center() );
5449 MouseEvent aMEvnt(aRect.Center(),1,MOUSE_SIMPLECLICK,MOUSE_LEFT);
5450 ImplMouseButtonDown( pTB, aMEvnt);
5451 ImplMouseButtonUp( pTB, aMEvnt);
5453 // Das Fenster ist offen.
5454 aSubMenuId1 = SmartId();
5455 aSubMenuId2 = SmartId();
5456 aSubMenuId3 = SmartId();
5457 pMenuWindow = NULL;
5460 break;
5461 case _M_IsEnabled:
5463 FIND_ITEM;
5464 if ( bItemFound ) // FIND_ITEM Erfolgreich
5466 pRet->GenReturn ( RET_Value, aUId, pTB->IsItemEnabled( pTB->GetItemId(nItemPos) ) );
5469 break;
5470 case M_GetState :
5472 FIND_ITEM;
5473 if ( bItemFound ) // FIND_ITEM Erfolgreich
5475 switch (nNr1)
5477 case 0:
5478 pRet->GenReturn ( RET_Value, aUId, (comm_ULONG)pTB->GetHelpId(pTB->GetItemId(nItemPos)));
5479 break;
5480 case 1:
5481 pRet->GenReturn ( RET_Value, aUId, (comm_ULONG)pTB->GetItemType(nItemPos));
5482 break;
5483 case 2:
5484 pRet->GenReturn ( RET_Value, aUId, (comm_ULONG)pTB->GetItemState(pTB->GetItemId(nItemPos)));
5485 break;
5486 case 3:
5487 pRet->GenReturn ( RET_Value, aUId, (comm_ULONG)pTB->GetItemId(nItemPos));
5488 break;
5489 default:
5490 pRet->GenReturn ( RET_Value, aUId, comm_ULONG(0));
5491 break;
5495 break;
5496 case M_GetItemText :
5497 pRet->GenReturn ( RET_Value, aUId, (String)pTB->GetItemText(nNr1));
5498 break;
5499 case M_GetText :
5500 pRet->GenReturn ( RET_Value, aUId, (String)pTB->GetText());
5501 break;
5502 case M_GetItemCount :
5503 pRet->GenReturn ( RET_Value, aUId, (comm_ULONG)pTB->GetItemCount());
5504 break;
5505 case M_SetNextToolBox :
5506 if ( (nParams & PARAM_STR_1) )
5507 pTB->SetNextToolBox( aString1 );
5508 else
5509 pTB->SetNextToolBox( pTB->GetNextToolBox() );
5510 pTB->NextToolBox();
5511 break;
5512 case M_GetNextToolBox :
5513 pRet->GenReturn ( RET_Value, aUId, (String)pTB->GetNextToolBox());
5514 break;
5515 case M_Dock :
5516 case M_Undock :
5517 case M_IsDocked :
5518 case M_Close:
5519 case M_Size:
5520 case M_Move:
5521 case M_IsMax:
5522 case M_Minimize:
5523 case M_Maximize:
5524 case M_Help: // Alles was unten weiterbehandelt werden soll
5525 goto DockingWin;
5526 default:
5527 ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "ToolBox" ) );
5528 break;
5531 break;
5533 case C_TreeListBox:
5534 switch( nMethodId )
5539 #define GET_NTH_ENTRY_LBOX( First, Next, Anzahl) \
5540 SvLBoxEntry *pThisEntry = ((SvTreeListBox*)pControl)->First(); \
5542 int niTemp = Anzahl; \
5543 while ( niTemp-- ) \
5545 pThisEntry = ((SvTreeListBox*)pControl)->Next( pThisEntry ); \
5549 case M_GetText : // Get the first text of the given (default=1) line
5550 { // should get removed some time
5551 SvTreeListBox *pTree = (SvTreeListBox*)pControl;
5552 SvLBoxEntry *pThisEntry = pTree->GetCurEntry();
5553 if ( ! (nParams & PARAM_USHORT_1) )
5554 nNr1 = 1;
5555 if ( pThisEntry )
5557 SvLBoxString* pItem = NULL;
5558 USHORT nValidTextItemCount = 0;
5560 USHORT nIndex = 0;
5561 SvLBoxItem *pMyItem;
5562 while ( ( nValidTextItemCount < nNr1 ) && nIndex < pThisEntry->ItemCount() )
5564 pMyItem = pThisEntry->GetItem( nIndex );
5565 if ( pMyItem->IsA() == SV_ITEM_ID_LBOXSTRING )
5567 pItem = (SvLBoxString*)pMyItem;
5568 nValidTextItemCount++;
5570 nIndex++;
5573 if ( ValueOK( aUId, CUniString("GetText"), nNr1, nValidTextItemCount ) )
5574 pRet->GenReturn ( RET_Value, aUId, pItem->GetText() );
5576 else
5577 ReportError( aUId, GEN_RES_STR2c2( S_NO_SELECTED_ENTRY, MethodString( nMethodId ), "TreeListBox" ) );
5579 break;
5580 case M_GetSelCount :
5581 pRet->GenReturn ( RET_Value, aUId, comm_ULONG(((SvLBox*)pControl)->GetSelectionCount()));
5582 break;
5583 case M_GetItemCount :
5584 pRet->GenReturn ( RET_Value, aUId, comm_ULONG(((SvLBox*)pControl)->GetVisibleCount()) );
5585 break;
5586 case M_GetSelIndex :
5587 if ( ! (nParams & PARAM_USHORT_1) )
5588 nNr1 = 1;
5589 if ( ValueOK(aUId, CUniString("GetSelIndex"),nNr1,((SvLBox*)pControl)->GetSelectionCount()) )
5591 nNr1--;
5592 GET_NTH_ENTRY_LBOX( FirstSelected, NextSelected, nNr1);
5593 pRet->GenReturn ( RET_Value, aUId, comm_ULONG( ((SvTreeListBox*)pControl)->GetVisiblePos( pThisEntry )) +1 );
5595 break;
5596 case M_Select :
5597 if ( ! (nParams & PARAM_BOOL_1) )
5598 bBool1 = TRUE;
5599 if( nParams & PARAM_STR_1 )
5601 /* ListBox *pLB = ((ListBox*)pControl);
5602 if ( pLB->GetEntryPos( aString1 ) == LISTBOX_ENTRY_NOTFOUND )
5603 ReportError( aUId, GEN_RES_STR2( S_ENTRY_NOT_FOUND, MethodString( nMethodId ), aString1 ) );
5604 else
5606 pLB->SelectEntry( aString1, bBool1 );
5607 if ( pLB->IsEntrySelected( aString1 ) ? !bBool1 : bBool1 ) // XOR rein mit BOOL
5608 ReportError( aUId, GEN_RES_STR2( S_METHOD_FAILED, MethodString( nMethodId ), aString1 ) );
5610 */ ReportError( aUId, GEN_RES_STR1( S_SELECT_DESELECT_VIA_STRING_NOT_IMPLEMENTED, MethodString( nMethodId ) ) );
5612 else
5614 if ( ValueOK(aUId, MethodString( nMethodId ),nNr1,((SvLBox*)pControl)->GetVisibleCount()) )
5616 SvLBoxEntry *pEntry = (SvLBoxEntry*)((SvTreeListBox*)pControl)->GetEntryAtVisPos( nNr1-1 );
5617 ((SvTreeListBox*)pControl)->Select ( pEntry, bBool1 );
5620 break;
5621 case M_GetSelText :
5622 if ( ! (nParams & PARAM_USHORT_1) )
5623 nNr1 = 1;
5624 if ( ! (nParams & PARAM_USHORT_2) )
5625 nNr2 = 1;
5626 if ( ValueOK(aUId, CUniString("GetSelText"),nNr1,((SvLBox*)pControl)->GetSelectionCount()) )
5628 nNr1--;
5629 GET_NTH_ENTRY_LBOX( FirstSelected, NextSelected, nNr1);
5630 if ( ValueOK( aUId, MethodString( nMethodId ),nNr2,pThisEntry->ItemCount() ) )
5632 SvLBoxString* pItem = NULL;
5633 if ( ! (nParams & PARAM_USHORT_2) )
5634 pItem = (SvLBoxString*)pThisEntry->GetFirstItem( SV_ITEM_ID_LBOXSTRING );
5635 else
5637 SvLBoxItem *pMyItem = pThisEntry->GetItem( nNr2-1 );
5638 if ( pMyItem->IsA() == SV_ITEM_ID_LBOXSTRING )
5639 pItem = (SvLBoxString*)pMyItem;
5642 if ( pItem )
5643 pRet->GenReturn ( RET_Value, aUId, pItem->GetText() );
5644 else
5645 ReportError( aUId, GEN_RES_STR1( S_NO_LIST_BOX_STRING, MethodString( nMethodId ) ) );
5648 break;
5649 case M_GetItemText :
5650 if ( ValueOK(aUId, MethodString( nMethodId ),nNr1,((SvLBox*)pControl)->GetVisibleCount()) )
5652 SvLBoxEntry *pThisEntry = (SvLBoxEntry*)((SvTreeListBox*)pControl)->GetEntryAtVisPos( nNr1-1 );
5653 if ( ! (nParams & PARAM_USHORT_2) )
5654 nNr2 = 1;
5655 if ( ValueOK( aUId, MethodString( nMethodId ),nNr2,pThisEntry->ItemCount() ) )
5657 SvLBoxString* pItem = NULL;
5658 if ( ! (nParams & PARAM_USHORT_2) )
5659 pItem = (SvLBoxString*)pThisEntry->GetFirstItem( SV_ITEM_ID_LBOXSTRING );
5660 else
5662 SvLBoxItem *pMyItem = pThisEntry->GetItem( nNr2-1 );
5663 if ( pMyItem->IsA() == SV_ITEM_ID_LBOXSTRING )
5664 pItem = (SvLBoxString*)pMyItem;
5667 if ( pItem )
5668 pRet->GenReturn ( RET_Value, aUId, pItem->GetText() );
5669 else
5670 ReportError( aUId, GEN_RES_STR1( S_NO_LIST_BOX_STRING, MethodString( nMethodId ) ) );
5673 break;
5674 case M_IsChecked :
5675 case M_IsTristate :
5676 case M_GetState :
5677 case M_Check :
5678 case M_UnCheck :
5679 case M_TriState :
5681 SvTreeListBox *pTree = (SvTreeListBox*)pControl;
5682 SvLBoxEntry *pThisEntry = NULL;
5684 if ( ! (nParams & PARAM_USHORT_1) )
5686 pThisEntry = pTree->GetCurEntry();
5687 if ( !pThisEntry )
5688 ReportError( aUId, GEN_RES_STR2c2( S_NO_SELECTED_ENTRY, MethodString( nMethodId ), "TreeListBox" ) );
5690 else
5692 if ( ValueOK(aUId, MethodString( nMethodId ),nNr1,((SvLBox*)pControl)->GetVisibleCount()) )
5694 pThisEntry = (SvLBoxEntry*)pTree->GetEntryAtVisPos( nNr1-1 );
5698 if ( ! (nParams & PARAM_USHORT_2) )
5699 nNr2 = 1;
5701 if ( pThisEntry )
5703 if ( ValueOK( aUId, MethodString( nMethodId ),nNr2,pThisEntry->ItemCount() ) )
5705 SvLBoxButton* pItem = NULL;
5706 if ( ! (nParams & PARAM_USHORT_2) )
5707 pItem = (SvLBoxButton*)pThisEntry->GetFirstItem( SV_ITEM_ID_LBOXBUTTON );
5708 else
5710 SvLBoxItem *pMyItem = pThisEntry->GetItem( nNr2-1 );
5711 if ( pMyItem->IsA() == SV_ITEM_ID_LBOXBUTTON )
5712 pItem = (SvLBoxButton*)pMyItem;
5715 if ( pItem )
5717 switch( nMethodId )
5719 case M_IsChecked :
5720 pRet->GenReturn ( RET_Value, aUId, comm_BOOL( pItem->IsStateChecked() ) );
5721 break;
5722 case M_IsTristate :
5723 pRet->GenReturn ( RET_Value, aUId, comm_BOOL( pItem->IsStateTristate() ) );
5724 break;
5725 case M_GetState :
5726 pRet->GenReturn ( RET_Value, aUId, comm_ULONG( pItem->GetButtonFlags() & ~SV_STATE_MASK ));
5727 break;
5728 case M_Check :
5729 pItem->SetStateChecked();
5730 pTree->CheckButtonHdl();
5731 pTree->InvalidateEntry( pThisEntry );
5732 break;
5733 case M_UnCheck :
5734 pItem->SetStateUnchecked();
5735 pTree->CheckButtonHdl();
5736 pTree->InvalidateEntry( pThisEntry );
5737 break;
5738 case M_TriState :
5739 pItem->SetStateTristate();
5740 pTree->CheckButtonHdl();
5741 pTree->InvalidateEntry( pThisEntry );
5742 break;
5743 default:
5744 ReportError( aUId, GEN_RES_STR1( S_INTERNAL_ERROR, MethodString( nMethodId ) ) );
5745 break;
5748 else
5749 ReportError( aUId, GEN_RES_STR1( S_NO_LIST_BOX_BUTTON, MethodString( nMethodId ) ) );
5753 break;
5754 case M_GetItemType :
5756 SvTreeListBox *pTree = (SvTreeListBox*)pControl;
5757 SvLBoxEntry *pThisEntry = NULL;
5759 if ( ! (nParams & PARAM_USHORT_1) )
5761 pThisEntry = pTree->GetCurEntry();
5762 if ( !pThisEntry )
5763 ReportError( aUId, GEN_RES_STR2c2( S_NO_SELECTED_ENTRY, MethodString( nMethodId ), "TreeListBox" ) );
5765 else
5767 if ( ValueOK(aUId, MethodString( nMethodId ),nNr1,((SvLBox*)pControl)->GetVisibleCount()) )
5769 pThisEntry = (SvLBoxEntry*)pTree->GetEntryAtVisPos( nNr1-1 );
5773 if ( pThisEntry )
5775 if ( ! (nParams & PARAM_USHORT_2) )
5776 nNr2 = 1;
5777 if ( ValueOK( aUId, MethodString( nMethodId ),nNr2,pThisEntry->ItemCount() ) )
5779 SvLBoxItem *pMyItem = pThisEntry->GetItem( nNr2-1 );
5780 comm_USHORT nType;
5781 switch ( pMyItem->IsA() )
5783 case SV_ITEM_ID_LBOXSTRING: nType = CONST_ItemTypeText ; break;
5784 case SV_ITEM_ID_LBOXBMP: nType = CONST_ItemTypeBMP ; break;
5785 case SV_ITEM_ID_LBOXBUTTON: nType = CONST_ItemTypeCheckbox ; break;
5786 case SV_ITEM_ID_LBOXCONTEXTBMP: nType = CONST_ItemTypeContextBMP ; break;
5787 default: nType = CONST_ItemTypeUnknown;
5789 pRet->GenReturn ( RET_Value, aUId, nType );
5793 break;
5794 default:
5795 ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "TreeListBox" ) );
5796 break;
5798 break;
5799 case C_Control:
5801 USHORT nRealControlType = 0;
5802 if ( dynamic_cast< EditBrowseBox* >(pControl) )
5803 nRealControlType = CONST_CTBrowseBox;
5804 else if ( dynamic_cast< ValueSet* >(pControl) )
5805 nRealControlType = CONST_CTValueSet;
5806 else if ( dynamic_cast< ORoadmap* >(pControl) )
5807 nRealControlType = CONST_CTORoadmap;
5808 else if ( dynamic_cast< IExtensionListBox* >(pControl) )
5809 nRealControlType = CONST_CTIExtensionListBox;
5810 else
5811 nRealControlType = CONST_CTUnknown;
5813 switch( nMethodId )
5815 case M_AnimateMouse :
5816 AnimateMouse( pControl, MitteOben);
5817 break;
5818 default:
5819 switch( nRealControlType )
5821 case CONST_CTBrowseBox:
5823 EditBrowseBox* pEBBox = dynamic_cast< EditBrowseBox* >(pControl);
5824 switch( nMethodId )
5831 BOOL MakeFieldVisible( long nRow, USHORT nColId, BOOL bComplete = FALSE );
5832 // access to dynamic values of cursor row
5833 String GetColumnTitle( USHORT nColumnId ) const;
5834 USHORT GetColumnId( USHORT nPos ) const;
5835 USHORT GetColumnPos( USHORT nColumnId ) const;
5836 // access and movement of cursor
5837 long GetCurRow() const { return nCurRow; }
5838 USHORT GetCurColumnId() const { return nCurColId; }
5839 BOOL GoToRow( long nRow );
5840 BOOL GoToRowAndDoNotModifySelection( long nRow );
5841 BOOL GoToColumnId( USHORT nColId );
5842 BOOL GoToRowColumnId( long nRow, USHORT nColId );
5843 // selections
5844 void SetNoSelection();
5845 void SelectAll();
5846 void SelectRow( long nRow, BOOL bSelect = TRUE, BOOL bExpand = TRUE );
5847 void SelectColumnPos( USHORT nCol, BOOL bSelect = TRUE )
5848 { SelectColumnPos( nCol, bSelect, TRUE); }
5849 void SelectColumnId( USHORT nColId, BOOL bSelect = TRUE )
5850 { SelectColumnPos( GetColumnPos(nColId), bSelect, TRUE); }
5851 long GetSelectRowCount() const;
5852 USHORT GetSelectColumnCount() const;
5853 BOOL IsRowSelected( long nRow ) const;
5854 BOOL IsColumnSelected( USHORT nColumnId ) const;
5855 long FirstSelectedRow( BOOL bInverse = FALSE );
5856 long LastSelectedRow( BOOL bInverse = FALSE );
5857 long PrevSelectedRow();
5858 long NextSelectedRow();
5859 const MultiSelection* GetSelection() const
5860 { return bMultiSelection ? uRow.pSel : 0; }
5861 void SetSelection( const MultiSelection &rSelection );
5863 virtual String GetCellText(long _nRow, USHORT _nColId) const;
5864 USHORT GetColumnCount() const { return ColCount(); }
5865 protected:
5866 virtual long GetRowCount() const;
5869 EditBrowseBox
5871 sal_Bool IsEditing() const {return aController.Is();}
5872 void InvalidateStatusCell(long nRow) {RowModified(nRow, 0);}
5873 void InvalidateHandleColumn();
5875 CellControllerRef Controller() const { return aController; }
5876 sal_Int32 GetBrowserFlags() const { return m_nBrowserFlags; }
5878 virtual void ActivateCell(long nRow, sal_uInt16 nCol, sal_Bool bSetCellFocus = sal_True);
5879 virtual void DeactivateCell(sal_Bool bUpdate = sal_True);
5884 case M_GetSelText :
5886 pRet->GenReturn ( RET_Value, aUId, pEBBox->GetCellText( pEBBox->GetCurrRow(), pEBBox->GetColumnId( pEBBox->GetCurrColumn() )));
5888 break;
5889 case M_GetColumnCount :
5891 USHORT nColCount = pEBBox->GetColumnCount();
5892 comm_USHORT nUnfrozenColCount = 0;
5893 USHORT i;
5894 for ( i=0 ; i < nColCount ; i++ )
5896 if ( !pEBBox->IsFrozen( pEBBox->GetColumnId( i ) ) )
5897 nUnfrozenColCount++;
5899 pRet->GenReturn ( RET_Value, aUId, nUnfrozenColCount );
5901 break;
5902 case M_GetRowCount :
5904 pRet->GenReturn ( RET_Value, aUId, (comm_ULONG)pEBBox->GetRowCount() );
5906 break;
5907 case M_IsEditing :
5909 CellControllerRef aControler;
5910 aControler = pEBBox->Controller();
5911 pRet->GenReturn ( RET_Value, aUId, (comm_BOOL)aControler.Is() );
5913 break;
5914 case M_Select :
5916 if ( ValueOK(aUId, MethodString( nMethodId ),nNr1,pEBBox->GetRowCount() ) )
5918 USHORT nColCount = pEBBox->GetColumnCount();
5919 comm_USHORT nUnfrozenColCount = 0;
5920 USHORT i;
5921 for ( i=0 ; i < nColCount ; i++ )
5923 if ( !pEBBox->IsFrozen( pEBBox->GetColumnId( i ) ) )
5924 nUnfrozenColCount++;
5926 if ( ValueOK(aUId, MethodString( nMethodId ),nNr2,nUnfrozenColCount ) )
5927 pEBBox->GoToRowColumnId( nNr1-1, pEBBox->GetColumnId( nNr2 ) );
5930 break;
5935 case M_GetSelCount :
5936 pRet->GenReturn ( RET_Value, aUId, comm_ULONG(((SvLBox*)pControl)->GetSelectionCount()));
5937 break;
5938 case M_GetSelIndex :
5939 if ( ! (nParams & PARAM_USHORT_1) )
5940 nNr1 = 1;
5941 if ( ValueOK(aUId, CUniString("GetSelIndex"),nNr1,((SvLBox*)pControl)->GetSelectionCount()) )
5943 nNr1--;
5944 COUNT_LBOX( FirstSelected, NextSelected, nNr1);
5945 pRet->GenReturn ( RET_Value, aUId, comm_ULONG( ((SvTreeListBox*)pControl)->GetVisiblePos( pThisEntry )) +1 );
5947 break;
5948 case M_GetSelText :
5949 if ( ! (nParams & PARAM_USHORT_1) )
5950 nNr1 = 1;
5951 if ( ValueOK(aUId, CUniString("GetSelText"),nNr1,((SvLBox*)pControl)->GetSelectionCount()) )
5953 nNr1--;
5954 COUNT_LBOX( FirstSelected, NextSelected, nNr1);
5955 GetFirstValidTextItem( pThisEntry );
5956 pRet->GenReturn ( RET_Value, aUId, pItem->GetText() );
5958 break;
5959 case M_GetItemCount :
5960 pRet->GenReturn ( RET_Value, aUId, comm_ULONG(((SvLBox*)pControl)->GetVisibleCount()) );
5961 break;
5962 case M_GetItemText :
5963 if ( ValueOK(aUId, MethodString( nMethodId ),nNr1,((SvLBox*)pControl)->GetVisibleCount()) )
5965 SvLBoxEntry *pEntry = (SvLBoxEntry*)((SvTreeListBox*)pControl)->GetEntryAtVisPos( nNr1-1 );
5966 GetFirstValidTextItem( pEntry );
5967 pRet->GenReturn ( RET_Value, aUId, pItem->GetText() );
5969 break;
5970 case M_Select :
5971 if ( ! (nParams & PARAM_BOOL_1) )
5972 bBool1 = TRUE;
5973 if( nParams & PARAM_STR_1 )
5975 / * ListBox *pLB = ((ListBox*)pControl);
5976 if ( pLB->GetEntryPos( aString1 ) == LISTBOX_ENTRY_NOTFOUND )
5977 ReportError( aUId, GEN_RES_STR2( S_ENTRY_NOT_FOUND, MethodString( nMethodId ), aString1 ) );
5978 else
5980 pLB->SelectEntry( aString1, bBool1 );
5981 if ( pLB->IsEntrySelected( aString1 ) ? !bBool1 : bBool1 ) // XOR rein mit BOOL
5982 ReportError( aUId, GEN_RES_STR2( S_METHOD_FAILED, MethodString( nMethodId ), aString1 ) );
5984 * / ReportError( aUId, GEN_RES_STR1( S_SELECT_DESELECT_VIA_STRING_NOT_IMPLEMENTED, MethodString( nMethodId ) ) );
5986 else
5988 if ( ValueOK(aUId, MethodString( nMethodId ),nNr1,((SvLBox*)pControl)->GetVisibleCount()) )
5990 SvLBoxEntry *pEntry = (SvLBoxEntry*)((SvTreeListBox*)pControl)->GetEntryAtVisPos( nNr1-1 );
5991 ((SvTreeListBox*)pControl)->Select ( pEntry, bBool1 );
5994 break;*/
5995 default:
5996 ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "EditBrowseBox" ) );
5997 break;
6000 break;
6001 case CONST_CTValueSet:
6003 ValueSet *pVS = dynamic_cast< ValueSet* >(pControl);
6004 switch ( nMethodId )
6006 case M_GetItemCount:
6007 pRet->GenReturn ( RET_Value, aUId, comm_ULONG( pVS->GetItemCount()));
6008 break;
6009 case M_GetItemText:
6010 if ( ValueOK( aUId, MethodString( nMethodId ), nNr1, pVS->GetItemCount() ))
6011 pRet->GenReturn ( RET_Value, aUId, pVS->GetItemText( pVS->GetItemId( nNr1-1 ) ) );
6012 break;
6013 case M_Select:
6014 if ( ValueOK( aUId, MethodString( nMethodId ), nNr1, pVS->GetItemCount() ))
6015 pVS->SelectItem( pVS->GetItemId( nNr1-1 ) );
6016 break;
6017 case M_GetSelIndex :
6018 if ( pVS->IsNoSelection() )
6019 pRet->GenReturn ( RET_Value, aUId, comm_ULONG(0));
6020 else
6021 pRet->GenReturn ( RET_Value, aUId, comm_ULONG( pVS->GetItemPos( pVS->GetSelectItemId() ) +1));
6022 break;
6023 case M_GetSelText :
6024 if ( pVS->IsNoSelection() )
6025 pRet->GenReturn ( RET_Value, aUId, String() );
6026 else
6027 pRet->GenReturn ( RET_Value, aUId, pVS->GetItemText( pVS->GetSelectItemId() ) );
6028 break;
6029 case M_SetNoSelection :
6030 pVS->SetNoSelection();
6031 break;
6032 default:
6033 ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "ValueSet" ) );
6034 break;
6037 break;
6038 case CONST_CTORoadmap:
6040 ORoadmap *pRM = dynamic_cast< ORoadmap* >(pControl);
6041 switch ( nMethodId )
6043 case M_GetItemCount:
6044 pRet->GenReturn ( RET_Value, aUId, comm_ULONG( pRM->GetItemCount()));
6045 break;
6046 case M_GetItemText:
6047 if ( ValueOK( aUId, MethodString( nMethodId ), nNr1, pRM->GetItemCount() ))
6048 pRet->GenReturn ( RET_Value, aUId, pRM->GetRoadmapItemLabel( pRM->GetItemID( nNr1-1 ) ) );
6049 break;
6050 case M_Select:
6051 if ( ValueOK( aUId, MethodString( nMethodId ), nNr1, pRM->GetItemCount() ))
6053 if ( pRM->IsRoadmapItemEnabled( pRM->GetItemID( nNr1-1 ) ) )
6054 pRM->SelectRoadmapItemByID( pRM->GetItemID( nNr1-1 ) );
6055 else
6056 ReportError( aUId, GEN_RES_STR1c( S_WIN_DISABLED, "RoadmapItem" ) );
6058 break;
6059 case M_GetSelIndex :
6060 pRet->GenReturn ( RET_Value, aUId, comm_ULONG( pRM->GetItemIndex( pRM->GetCurrentRoadmapItemID() ) +1));
6061 break;
6062 case M_GetSelText :
6063 pRet->GenReturn ( RET_Value, aUId, pRM->GetRoadmapItemLabel( pRM->GetCurrentRoadmapItemID() ) );
6064 break;
6065 case M_IsItemEnabled :
6066 if ( ValueOK( aUId, MethodString( nMethodId ), nNr1, pRM->GetItemCount() ))
6067 pRet->GenReturn ( RET_Value, aUId, (comm_BOOL)pRM->IsRoadmapItemEnabled( pRM->GetItemID( nNr1-1 ) ) );
6068 break;
6069 default:
6070 ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "RoadMap" ) );
6071 break;
6074 break;
6075 case CONST_CTIExtensionListBox:
6077 IExtensionListBox *pELB = dynamic_cast< IExtensionListBox* >(pControl);
6078 switch ( nMethodId )
6080 case M_GetItemCount:
6081 pRet->GenReturn ( RET_Value, aUId, comm_ULONG( pELB->getItemCount()));
6082 break;
6083 case M_GetItemText:
6084 if ( ValueOK( aUId, MethodString( nMethodId ), nNr1, pELB->getItemCount() ))
6085 switch ( nNr2 )
6087 case 1:
6088 pRet->GenReturn ( RET_Value, aUId, pELB->getItemName( nNr1 -1 ) );
6089 break;
6090 case 2:
6091 pRet->GenReturn ( RET_Value, aUId, pELB->getItemVersion( nNr1 -1 ) );
6092 break;
6093 case 3:
6094 pRet->GenReturn ( RET_Value, aUId, pELB->getItemDescription( nNr1 -1 ) );
6095 break;
6096 case 4:
6097 pRet->GenReturn ( RET_Value, aUId, pELB->getItemPublisher( nNr1 -1 ) );
6098 break;
6099 case 5:
6100 pRet->GenReturn ( RET_Value, aUId, pELB->getItemPublisherLink( nNr1 -1 ) );
6101 break;
6102 default:
6103 ValueOK( aUId, MethodString( nMethodId ).AppendAscii(" String Number"), nNr2, 5 );
6105 break;
6106 case M_Select:
6107 if ( (nParams & PARAM_USHORT_1) )
6109 if ( ValueOK( aUId, MethodString( nMethodId ), nNr1, pELB->getItemCount() ))
6111 pELB->select( nNr1-1 );
6114 else if ( (nParams & PARAM_STR_1) )
6116 pELB->select( aString1 );
6117 BOOL bSuccess = TRUE;
6118 if ( pELB->getSelIndex() == EXTENSION_LISTBOX_ENTRY_NOTFOUND )
6119 bSuccess = FALSE;
6120 else
6122 if ( !aString1.Equals( String( pELB->getItemName( pELB->getSelIndex() ) ) ) )
6123 bSuccess = FALSE;
6125 if ( !bSuccess )
6126 ReportError( aUId, GEN_RES_STR2( S_ENTRY_NOT_FOUND, MethodString( nMethodId ), aString1 ) );
6128 break;
6129 case M_GetSelCount :
6130 if ( pELB->getSelIndex() == EXTENSION_LISTBOX_ENTRY_NOTFOUND )
6131 pRet->GenReturn ( RET_Value, aUId, comm_ULONG( 0 ));
6132 else
6133 pRet->GenReturn ( RET_Value, aUId, comm_ULONG( 1 ));
6134 break;
6135 case M_GetSelIndex :
6136 if ( pELB->getSelIndex() == EXTENSION_LISTBOX_ENTRY_NOTFOUND )
6137 pRet->GenReturn ( RET_Value, aUId, comm_ULONG( 0 ));
6138 else
6139 pRet->GenReturn ( RET_Value, aUId, comm_ULONG( pELB->getSelIndex() +1));
6140 break;
6141 /* xxxcase M_SetNoSelection :
6142 ((ListBox*)pControl)->SetNoSelection();
6143 ((ListBox*)pControl)->Select();
6144 break; */
6145 default:
6146 ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "RoadMap" ) );
6147 break;
6150 break;
6151 case CONST_CTUnknown:
6152 ReportError( aUId, GEN_RES_STR2( S_UNKNOWN_TYPE, UniString::CreateFromInt32( nRT ), MethodString(nMethodId) ) );
6153 break;
6154 default:
6155 ReportError( aUId, GEN_RES_STR1( S_INTERNAL_ERROR, MethodString( nMethodId ) ) );
6156 break;
6159 break;
6161 case C_Window:
6162 switch( nMethodId )
6164 case M_AnimateMouse :
6165 AnimateMouse( pControl, MitteOben);
6166 break;
6167 default:
6168 ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "Window" ) );
6169 break;
6171 break;
6173 case C_DockingWin:
6174 DockingWin:
6175 switch( nMethodId )
6177 case M_AnimateMouse :
6178 AnimateMouse( pControl, MitteOben);
6179 break;
6180 case M_Dock :
6181 if ( ((DockingWindow*)pControl)->IsFloatingMode() )
6182 ((DockingWindow*)pControl)->SetFloatingMode(FALSE);
6183 else
6184 ReportError( aUId, GEN_RES_STR1( S_ALLOWED_ONLY_IN_FLOATING_MODE, MethodString( nMethodId ) ) );
6185 break;
6186 case M_Undock :
6187 if ( !((DockingWindow*)pControl)->IsFloatingMode() )
6188 ((DockingWindow*)pControl)->SetFloatingMode(TRUE);
6189 else
6190 ReportError( aUId, GEN_RES_STR1( S_ALLOWED_ONLY_IN_FLOATING_MODE, MethodString( nMethodId ) ) );
6191 break;
6192 case M_IsDocked :
6193 pRet->GenReturn ( RET_Value, aUId, (comm_BOOL) !((DockingWindow*)pControl)->IsFloatingMode());
6194 break;
6195 case M_Close:
6196 //aWindowWaitUId = aUId;
6197 DBG_ASSERT( aUId.Matches( pControl->GetSmartUniqueOrHelpId() ), "aUID != UniqueOrHelpId");
6198 SET_WINP_CLOSING(pControl);
6199 ((DockingWindow*)pControl)->Close();
6200 break;
6201 case M_Size:
6202 case M_Move:
6203 case M_IsMax:
6204 case M_Minimize:
6205 case M_Maximize:
6206 if ( ((DockingWindow*)pControl)->IsFloatingMode() )
6208 Window* pFloat = ((DockingWindow*)pControl)->GetFloatingWindow();
6209 if ( !pFloat && ((DockingWindow*)pControl)->IsFloatingMode() )
6211 if ( pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_FLOATINGWINDOW )
6212 pFloat = pControl->GET_REAL_PARENT();
6213 else
6215 DBG_ERROR("FloatingMode set but Parent is no FloatingWindow");
6218 if ( pFloat && pFloat->GetType() == WINDOW_FLOATINGWINDOW )
6220 pControl = pFloat;
6221 goto FloatWin;
6223 else
6224 ReportError( aUId, GEN_RES_STR1( S_CANNOT_FIND_FLOATING_WIN, MethodString( nMethodId ) ) );
6226 else
6227 ReportError( aUId, GEN_RES_STR1( S_ALLOWED_ONLY_IN_DOCKING_MODE, MethodString( nMethodId ) ) );
6228 break;
6229 case M_Help: // Alles was unten weiterbehandelt werden soll
6230 goto MoreDialog;
6232 default:
6233 ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "DockingWindow" ) );
6234 break;
6236 break;
6237 case C_FloatWin:
6238 FloatWin:
6239 switch( nMethodId )
6241 case M_AnimateMouse :
6242 AnimateMouse( pControl, MitteOben);
6243 break;
6244 case M_IsMax :
6245 pRet->GenReturn ( RET_Value, aUId, (comm_BOOL)!((FloatingWindow*)pControl)->IsRollUp());
6246 break;
6247 case M_Minimize :
6248 ((FloatingWindow*)pControl)->RollUp();
6249 break;
6250 case M_Maximize :
6251 ((FloatingWindow*)pControl)->RollDown();
6252 break;
6253 case M_Size:
6255 if ( pControl->GetStyle() & WB_SIZEABLE )
6257 Size aMin = ((FloatingWindow*)pControl)->GetMinOutputSizePixel();
6258 if ( aMin.Width() <= nNr1 && aMin.Height() <= nNr2 )
6260 pControl->SetSizePixel(Size(nNr1,nNr2));
6261 pControl->Resize();
6263 else
6265 ReportError( aUId, GEN_RES_STR2( S_SIZE_BELOW_MINIMUM, String::CreateFromInt32( aMin.Width() ), String::CreateFromInt32( aMin.Height() ) ) );
6268 else
6269 ReportError( aUId, GEN_RES_STR1( S_SIZE_NOT_CHANGEABLE, MethodString( nMethodId ) ) );
6270 break;
6272 case M_Close:
6273 DBG_ASSERT( aUId.Matches( pControl->GetSmartUniqueOrHelpId() ), "aUID != UniqueOrHelpId");
6274 SET_WINP_CLOSING(pControl);
6275 ((FloatingWindow*)pControl)->Close();
6276 break;
6277 case M_Help: // Alles was unten weiterbehandelt werden soll
6278 case M_Move:
6279 goto MoreDialog;
6280 default:
6281 ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "FloatingWin" ) );
6282 break;
6284 break;
6285 case C_ModelessDlg:
6286 case C_ModalDlg:
6287 case C_Dialog:
6288 case C_TabDlg:
6289 MoreDialog:
6290 switch( nMethodId )
6292 case M_AnimateMouse :
6293 AnimateMouse( pControl, MitteOben);
6294 break;
6295 case M_Close:
6296 DBG_ASSERT( aUId.Matches( pControl->GetSmartUniqueOrHelpId() ), "aUID != UniqueOrHelpId");
6297 SET_WINP_CLOSING(pControl);
6298 ((SystemWindow*)pControl)->Close();
6299 break;
6300 case M_OK:
6302 Window *pChild = GetWinByRT( pControl, WINDOW_OKBUTTON );
6303 if( ControlOK( pChild, "OK Button" ) )
6305 DBG_ASSERT( aUId.Matches( pControl->GetSmartUniqueOrHelpId() ), "aUID != UniqueOrHelpId");
6306 SET_WINP_CLOSING(pControl);
6307 ((Button*)pChild)->Click();
6309 break;
6311 case M_Cancel:
6313 Window *pChild = GetWinByRT( pControl, WINDOW_CANCELBUTTON );
6314 if( ControlOK( pChild, "Cancel Button" ) )
6316 DBG_ASSERT( aUId.Matches( pControl->GetSmartUniqueOrHelpId() ), "aUID != UniqueOrHelpId");
6317 SET_WINP_CLOSING(pControl);
6318 ((Button*)pChild)->Click();
6320 break;
6322 case M_Help:
6324 Window *pChild = GetWinByRT( pControl, WINDOW_HELPBUTTON );
6325 if( ControlOK( pChild, "Help Button" ) )
6326 ((Button*)pChild)->Click();
6327 break;
6329 case M_Default:
6331 Window *pChild = ImpGetButton( pControl, WB_DEFBUTTON, WB_DEFBUTTON );
6332 if( ControlOK( pChild, "Default Button" ) )
6333 ((Button*)pChild)->Click();
6334 break;
6336 case M_Move:
6338 pControl->SetPosPixel(Point(nNr1,nNr2));
6339 break;
6341 default:
6342 ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "Dialog" ) );
6343 break;
6345 break;
6346 case C_WorkWin:
6347 switch( nMethodId )
6349 case M_AnimateMouse :
6350 AnimateMouse( pControl, MitteOben);
6351 break;
6352 case M_Close:
6353 DBG_ASSERT( aUId.Matches( pControl->GetSmartUniqueOrHelpId() ), "aUID != UniqueOrHelpId");
6354 SET_WINP_CLOSING(pControl);
6355 ((WorkWindow*)pControl)->Close();
6356 break;
6357 case M_Size:
6358 case M_Move:
6359 goto FloatWin;
6360 // break;
6361 case M_IsMax :
6362 pRet->GenReturn ( RET_Value, aUId, ((WorkWindow*)pControl)->IsMaximized() );
6363 break;
6364 case M_IsMin :
6365 pRet->GenReturn ( RET_Value, aUId, ((WorkWindow*)pControl)->IsMinimized() );
6366 break;
6367 case M_IsRestore :
6368 pRet->GenReturn ( RET_Value, aUId, comm_BOOL (!((WorkWindow*)pControl)->IsMaximized() && !((WorkWindow*)pControl)->IsMinimized()) );
6369 break;
6370 case M_Minimize :
6371 ((WorkWindow*)pControl)->Maximize( FALSE );
6372 ((WorkWindow*)pControl)->Minimize();
6373 break;
6374 case M_Maximize :
6375 ((WorkWindow*)pControl)->Maximize();
6376 break;
6377 case M_Restore :
6378 ((WorkWindow*)pControl)->Maximize( FALSE );
6379 ((WorkWindow*)pControl)->Restore();
6380 break;
6381 case M_Help: // Alles was unten weiterbehandelt werden soll
6382 goto MoreDialog;
6383 default:
6384 ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "WorkWindow" ) );
6385 break;
6387 break;
6388 case C_TabPage:
6389 ReportError( aUId, GEN_RES_STR1( S_INTERNAL_ERROR, MethodString( nMethodId ) ) );
6390 break;
6391 case C_MessBox:
6392 case C_InfoBox:
6393 case C_WarningBox:
6394 case C_ErrorBox:
6395 case C_QueryBox:
6397 BOOL bDone = TRUE;
6398 MessBox* pMB = (MessBox*)pControl;
6399 switch( nMethodId )
6401 case M_GetCheckBoxText:
6402 pRet->GenReturn ( RET_Value, aUId, pMB->GetCheckBoxText() );
6403 break;
6404 case M_IsChecked :
6405 pRet->GenReturn ( RET_Value, aUId, comm_BOOL( pMB->GetCheckBoxState() == STATE_CHECK) );
6406 break;
6407 case M_Check :
6408 pMB->SetCheckBoxState( TRUE );
6409 break;
6410 case M_UnCheck :
6411 pMB->SetCheckBoxState( FALSE );
6412 break;
6413 case M_GetText :
6414 pRet->GenReturn ( RET_Value, aUId, pMB->GetMessText());
6415 break;
6417 default:
6418 bDone = FALSE;
6419 break;
6421 if ( bDone )
6422 break; // break the case here else continue at C_ButtonDialog
6424 case C_ButtonDialog:
6426 ButtonDialog* pBD = (ButtonDialog*)pControl;
6427 #if OSL_DEBUG_LEVEL > 1
6428 m_pDbgWin->AddText( "Working MessBox: " );
6429 if (pControl->IsVisible())
6430 m_pDbgWin->AddText("*(Visible)\n");
6431 else
6432 m_pDbgWin->AddText("*(nicht Visible)\n");
6433 #endif
6434 switch( nMethodId )
6436 case M_AnimateMouse :
6437 AnimateMouse( pControl, Mitte);
6438 break;
6439 case M_OK:
6440 #if ( BUTTONID_OK != RET_OK )
6441 #error BUTTONID_OK != RET_OK
6442 #endif
6443 if ( pBD->GetPushButton( BUTTONID_OK ) )
6445 SET_WINP_CLOSING(pControl);
6446 pBD->EndDialog(RET_OK);
6448 else
6449 ReportError( aUId, GEN_RES_STR1( S_NO_OK_BUTTON, MethodString( nMethodId ) ) );
6450 break;
6451 case M_Cancel:
6452 if ( pBD->GetPushButton( BUTTONID_CANCEL ) )
6454 SET_WINP_CLOSING(pControl);
6455 pBD->EndDialog(RET_CANCEL);
6457 else
6458 ReportError( aUId, GEN_RES_STR1( S_NO_CANCEL_BUTTON, MethodString( nMethodId ) ) );
6459 break;
6460 case M_Yes:
6461 if ( pBD->GetPushButton( BUTTONID_YES ) )
6463 SET_WINP_CLOSING(pControl);
6464 pBD->EndDialog(RET_YES);
6466 else
6467 ReportError( aUId, GEN_RES_STR1( S_NO_YES_BUTTON, MethodString( nMethodId ) ) );
6468 break;
6469 case M_No:
6470 if ( pBD->GetPushButton( BUTTONID_NO ) )
6472 SET_WINP_CLOSING(pControl);
6473 pBD->EndDialog(RET_NO);
6475 else
6476 ReportError( aUId, GEN_RES_STR1( S_NO_NO_BUTTON, MethodString( nMethodId ) ) );
6477 break;
6478 case M_Repeat:
6479 if ( pBD->GetPushButton( BUTTONID_RETRY ) )
6481 SET_WINP_CLOSING(pControl);
6482 pBD->EndDialog(RET_RETRY);
6484 else
6485 ReportError( aUId, GEN_RES_STR1( S_NO_RETRY_BUTTON, MethodString( nMethodId ) ) );
6486 break;
6487 case M_Help:
6488 if ( pBD->GetPushButton( BUTTONID_HELP ) )
6490 SET_WINP_CLOSING(pControl);
6491 pBD->EndDialog(BUTTONID_HELP);
6493 else
6494 ReportError( aUId, GEN_RES_STR1( S_NO_HELP_BUTTON, MethodString( nMethodId ) ) );
6495 break;
6496 case M_Default:
6498 WinBits Style = pControl->GetStyle();
6499 if ( Style & WB_DEF_OK )
6501 SET_WINP_CLOSING(pControl);
6502 pBD->EndDialog(RET_OK);
6504 else if ( Style & WB_DEF_CANCEL )
6506 SET_WINP_CLOSING(pControl);
6507 pBD->EndDialog(RET_CANCEL);
6509 else if ( Style & WB_DEF_YES )
6511 SET_WINP_CLOSING(pControl);
6512 pBD->EndDialog(RET_YES);
6514 else if ( Style & WB_DEF_NO )
6516 SET_WINP_CLOSING(pControl);
6517 pBD->EndDialog(RET_NO);
6519 else if ( Style & WB_DEF_RETRY )
6521 SET_WINP_CLOSING(pControl);
6522 pBD->EndDialog(RET_RETRY);
6524 else
6525 ReportError( aUId, GEN_RES_STR1( S_NO_DEFAULT_BUTTON, MethodString( nMethodId ) ) );
6527 break;
6528 case M_GetText :
6529 pRet->GenReturn ( RET_Value, aUId, pControl->GetText());
6530 break;
6531 case M_Click:
6532 if ( nParams & PARAM_USHORT_1 )
6534 if ( pBD->GetPushButton( nNr1 ) )
6536 if ( nNr1 != BUTTONID_HELP )
6538 SET_WINP_CLOSING(pControl);
6540 pBD->GetPushButton( nNr1 )->Click();
6542 else
6543 ReportError( aUId, GEN_RES_STR2( S_NO_DEFAULT_BUTTON, UniString::CreateFromInt32( nNr1 ), MethodString( nMethodId ) ) );
6545 else
6546 ReportError( aUId, GEN_RES_STR1( S_BUTTONID_REQUIRED, MethodString( nMethodId ) ) );
6547 break;
6548 case M_GetButtonCount :
6549 pRet->GenReturn ( RET_Value, aUId, comm_ULONG(pBD->GetButtonCount()));
6550 break;
6551 case M_GetButtonId :
6552 if ( ValueOK(aUId, MethodString( nMethodId ),nNr1,pBD->GetButtonCount()) )
6553 pRet->GenReturn ( RET_Value, aUId, comm_ULONG(pBD->GetButtonId(nNr1-1)));
6554 break;
6555 default:
6556 ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "MessageBox" ) );
6557 break;
6559 break;
6561 default:
6562 DBG_ERROR( "Unknown Objekttype from UId or Method not suported" );
6563 ReportError( aUId, GEN_RES_STR2( S_UNKNOWN_TYPE, UniString::CreateFromInt32( nRT ), MethodString(nMethodId) ) );
6564 #if OSL_DEBUG_LEVEL > 1
6565 m_pDbgWin->AddText( " Unknown Objekttype from UId or Method not suported" );
6566 #endif
6567 break;
6570 for( int i = 0; i < 32; i++ )
6571 SafeReschedule();
6573 #if OSL_DEBUG_LEVEL > 1
6574 m_pDbgWin->AddText( "\n" );
6575 #endif
6576 if ( bStatementDone )
6578 SendProfile( UIdString( aUId ).Append('.').Append( MethodString( nMethodId ) ) );
6579 delete this;
6581 else
6583 if ( nRetryCount-- )
6585 #if OSL_DEBUG_LEVEL > 1
6586 m_pDbgWin->AddText( CUniString("Reschedule command (requed) (").Append( UniString::CreateFromInt32(nRetryCount) ).AppendAscii(")\n") );
6587 #endif
6588 QueStatement( this ); // will que at the start of the list
6590 else
6592 bStatementDone=TRUE;
6595 return bStatementDone;
6597 #define FINISH_NEXT
6598 #define FINISH_SAME