1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: recorder.cxx,v $
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 <osl/mutex.hxx>
35 #include <vcl/window.hxx>
36 #include <vcl/vclevent.hxx>
37 #include <vcl/button.hxx>
38 #include <vcl/edit.hxx>
39 #include <vcl/spinfld.hxx>
40 #include <vcl/msgbox.hxx>
41 #include <vcl/toolbox.hxx>
42 #include <vcl/lstbox.hxx>
43 #include <vcl/sound.hxx>
44 #include <vcl/combobox.hxx>
45 #include <vcl/floatwin.hxx>
46 #include <basic/ttstrhlp.hxx>
47 #include "statemnt.hxx"
48 #include "retstrm.hxx"
49 #include "rcontrol.hxx"
50 #include "recorder.hxx"
52 #include <comphelper/uieventslogger.hxx>
54 MacroRecorder
* MacroRecorder::pMacroRecorder
= NULL
;
56 MacroRecorder::MacroRecorder()
59 , pActionParent( NULL
)
62 , bKeyFollowFocus( FALSE
)
66 aHookRefresh
.SetTimeout( 500 );
67 aHookRefresh
.SetTimeoutHdl( LINK( this, MacroRecorder
, HookRefreshHdl
) );
69 aEventListenerHdl
= LINK( this, MacroRecorder
, EventListener
);
73 MacroRecorder::~MacroRecorder()
79 void MacroRecorder::AddEventHooks()
81 Window
*pTopLevel
= Application::GetFirstTopLevelWindow();
84 Window
*pParent
= pTopLevel
;
85 while ( pParent
->GetParent() )
86 pParent
= pParent
->GetParent();
88 pParent
->RemoveChildEventListener( aEventListenerHdl
); // might be instrumented already
89 pParent
->AddChildEventListener( aEventListenerHdl
);
91 pTopLevel
= Application::GetNextTopLevelWindow( pTopLevel
);
95 void MacroRecorder::RemoveEventHooks()
97 Window
*pTopLevel
= Application::GetFirstTopLevelWindow();
100 pTopLevel
->RemoveChildEventListener( aEventListenerHdl
);
101 pTopLevel
= Application::GetNextTopLevelWindow( pTopLevel
);
105 IMPL_LINK( MacroRecorder
, HookRefreshHdl
, void*, EMPTYARG
)
111 void MacroRecorder::LogVCL( SmartId aParentID
, USHORT nVCLWindowType
, SmartId aID
, String aMethod
, USHORT nParam
)
113 ::comphelper::UiEventsLogger::logVcl( aParentID
.GetText(), nVCLWindowType
, aID
.GetText(), aMethod
, nParam
);
116 void MacroRecorder::LogVCL( SmartId aParentID
, USHORT nVCLWindowType
, SmartId aID
, String aMethod
)
118 ::comphelper::UiEventsLogger::logVcl( aParentID
.GetText(), nVCLWindowType
, aID
.GetText(), aMethod
);
121 Window
* MacroRecorder::GetParentWithID( Window
* pThis
)
123 Window
*pOverlap
= pThis
->GetWindow( WINDOW_OVERLAP
);
124 while ( pOverlap
!= pThis
&& !pThis
->GetSmartUniqueOrHelpId().HasAny() && pThis
->GET_REAL_PARENT() )
125 pThis
= pThis
->GET_REAL_PARENT();
129 SmartId
MacroRecorder::GetParentID( Window
* pThis
)
131 if ( pThis
->GetParent() )
132 return pThis
->GetParent()->GetSmartUniqueOrHelpId();
137 IMPL_LINK( MacroRecorder
, EventListener
, VclSimpleEvent
*, pEvent
)
139 BOOL bSendData
= FALSE
;
141 if ( pEvent
->ISA( VclWindowEvent
) )
143 VclWindowEvent
* pWinEvent
= ( VclWindowEvent
* ) pEvent
;
144 Window
* pWin
= pWinEvent
->GetWindow();
145 ULONG nEventID
= pWinEvent
->GetId();
146 #if OSL_DEBUG_LEVEL > 1
147 if ( nEventID
>= 1001 && nEventID
!= VCLEVENT_WINDOW_KEYUP
)
148 nEventID
= pWinEvent
->GetId(); // Just something to set a breakpoint
153 // check for different action after collecting keys
154 // send if there_is_something_to_send
155 // and eather event_is_not_of_interest
156 // or ( new_window and new_window_is_interesting ) ( ignore interesting events to uninteresting window )
158 if ( aKeyString
.Len()
159 && ( ( nEventID
!= VCLEVENT_WINDOW_KEYINPUT
160 && nEventID
!= VCLEVENT_WINDOW_MOUSEMOVE
161 && nEventID
!= VCLEVENT_WINDOW_COMMAND
162 && nEventID
!= VCLEVENT_WINDOW_KEYUP
)
164 && ( pWin
->GetType() == WINDOW_CONTROL
|| pWin
->GetType() == WINDOW_WINDOW
)
171 // we cannot access pKeyWin since it might have dissapeared
172 if ( bKeyFollowFocus
)
173 StatementList::pRet
->GenReturn( RET_MacroRecorder
, aKeyUniqueID
, (USHORT
)M_TypeKeys
, aKeyString
, bKeyFollowFocus
);
175 StatementList::pRet
->GenReturn( RET_MacroRecorder
, aKeyUniqueID
, (USHORT
)M_TypeKeys
, aKeyString
);
176 #if OSL_DEBUG_LEVEL > 1
177 StatementList::pRet
->GenReturn( RET_MacroRecorder
, aKeyUniqueID
, (USHORT
)M_TypeKeys
, String::CreateFromInt32( nEventID
) );
183 // HACK Too many KeyEvents generated LogVCL( SmartId(), 0, aKeyUniqueID, CUniString("TypeKeys"), aKeyString.Len() );
188 bKeyFollowFocus
= FALSE
;
191 switch ( pWin
->GetType() )
196 case VCLEVENT_WINDOW_ACTIVATE
:
199 StatementList::pRet
->GenReturn( RET_MacroRecorder
, SmartId(), (comm_USHORT
)(M_SetPage
|M_RET_NUM_CONTROL
), static_cast<comm_ULONG
>(pWin
->GetSmartUniqueOrHelpId().GetNum()) ); //GetNum() ULONG != comm_ULONG on 64bit
204 LogVCL( SmartId(), pWin
->GetType(), pWin
->GetSmartUniqueOrHelpId(), CUniString("SetPage") );
209 case WINDOW_RADIOBUTTON
:
210 case WINDOW_IMAGERADIOBUTTON
:
213 case VCLEVENT_BUTTON_CLICK
: // VCLEVENT_RADIOBUTTON_TOGGLE
215 if ( ((RadioButton
*)pWin
)->IsChecked() )
219 StatementList::pRet
->GenReturn( RET_MacroRecorder
, pWin
->GetSmartUniqueOrHelpId(), (comm_USHORT
)M_Check
);
224 LogVCL( GetParentID( pWin
), pWin
->GetType(), pWin
->GetSmartUniqueOrHelpId(), CUniString("Check") );
231 case WINDOW_CHECKBOX
:
232 case WINDOW_TRISTATEBOX
:
235 case VCLEVENT_BUTTON_CLICK
: //VCLEVENT_CHECKBOX_TOGGLE:
239 switch ( ((TriStateBox
*)pWin
)->GetState() )
241 case STATE_CHECK
: nMethod
= M_Check
; aMethod
= CUniString("Check"); break;
242 case STATE_NOCHECK
: nMethod
= M_UnCheck
; aMethod
= CUniString("UnCheck"); break;
243 case STATE_DONTKNOW
: nMethod
= M_TriState
; aMethod
= CUniString("TriState"); break;
244 default: nMethod
= M_Check
;
245 DBG_ERROR( "Unknown state in TriStateBox::GetState()" );
249 StatementList::pRet
->GenReturn( RET_MacroRecorder
, pWin
->GetSmartUniqueOrHelpId(), nMethod
);
254 LogVCL( GetParentID( pWin
), pWin
->GetType(), pWin
->GetSmartUniqueOrHelpId(), aMethod
);
261 case WINDOW_MULTILINEEDIT
:
264 case VCLEVENT_EDIT_MODIFY
:
266 aEditModifyString
= ((Edit
*)pWin
)->GetText();
270 case WINDOW_MULTILISTBOX
:
273 case VCLEVENT_LISTBOX_SELECT
:
279 // case VCLEVENT_LISTBOX_DOUBLECLICK:
280 case VCLEVENT_LISTBOX_SELECT
:
283 StatementList::pRet
->GenReturn( RET_MacroRecorder
, pWin
->GetSmartUniqueOrHelpId(), (comm_USHORT
)M_Select
, comm_ULONG( ((ListBox
*)pWin
)->GetSelectEntryPos() +1 ) );
288 LogVCL( GetParentID( pWin
), pWin
->GetType(), pWin
->GetSmartUniqueOrHelpId(), CUniString("Select"), ((ListBox
*)pWin
)->GetSelectEntryPos() );
293 case WINDOW_COMBOBOX
:
294 case WINDOW_PATTERNBOX
:
295 case WINDOW_NUMERICBOX
:
296 case WINDOW_METRICBOX
:
297 case WINDOW_CURRENCYBOX
:
302 case VCLEVENT_EDIT_MODIFY
:
304 aEditModifyString
= ((Edit
*)pWin
)->GetText();
306 case VCLEVENT_COMBOBOX_SELECT
:
309 aEditModifyString
.Erase();
311 USHORT nPos
= ((ComboBox
*)pWin
)->GetEntryPos(((ComboBox
*)pWin
)->GetText());
314 if ( nPos
== COMBOBOX_ENTRY_NOTFOUND
)
318 StatementList::pRet
->GenReturn( RET_MacroRecorder
, pWin
->GetSmartUniqueOrHelpId(), (comm_USHORT
)M_Select
, (comm_ULONG
) nPos
+1 );
324 LogVCL( GetParentID( pWin
), pWin
->GetType(), pWin
->GetSmartUniqueOrHelpId(), CUniString("Select"), nPos
);
329 case WINDOW_PUSHBUTTON
:
330 case WINDOW_OKBUTTON
:
331 case WINDOW_CANCELBUTTON
:
332 case WINDOW_IMAGEBUTTON
:
333 case WINDOW_MOREBUTTON
:
334 case WINDOW_HELPBUTTON
:
337 case VCLEVENT_BUTTON_CLICK
:
338 Window
* pParent
= pWin
->GetParent();
340 if ( pParent
->IsDialog() && !pWin
->GetSmartUniqueOrHelpId().HasAny() )
342 switch ( pParent
->GetType() )
346 case WINDOW_WARNINGBOX
:
347 case WINDOW_ERRORBOX
:
348 case WINDOW_QUERYBOX
:
349 case WINDOW_BUTTONDIALOG
:
353 ButtonDialog
* pBD
= (ButtonDialog
*)pParent
;
355 // we have to find the current Button ID ourselves since it is not generated at this point :-(
356 USHORT nCurrentButtonId
= 0xffff; // Some wild value to wak up people
358 for ( i
= 0; i
< pBD
->GetButtonCount() ; i
++ )
360 if ( pBD
->GetPushButton( pBD
->GetButtonId(i
) ) == pWin
)
362 nCurrentButtonId
= pBD
->GetButtonId(i
);
367 switch ( nCurrentButtonId
)
369 case BUTTONID_OK
: nMethod
= M_OK
; aMethod
= CUniString("OK"); break;
370 case BUTTONID_CANCEL
: nMethod
= M_Cancel
; aMethod
= CUniString("Cancel"); break;
371 case BUTTONID_YES
: nMethod
= M_Yes
; aMethod
= CUniString("Yes"); break;
372 case BUTTONID_NO
: nMethod
= M_No
; aMethod
= CUniString("No"); break;
373 case BUTTONID_RETRY
: nMethod
= M_Repeat
; aMethod
= CUniString("Repeat"); break;
374 case BUTTONID_HELP
: nMethod
= M_Help
; aMethod
= CUniString("Help"); break;
375 default: nMethod
= M_Click
; aMethod
= CUniString("Click");
379 if ( nMethod
!= M_Click
)
380 StatementList::pRet
->GenReturn( RET_MacroRecorder
, SmartId( 0 ), nMethod
);
382 StatementList::pRet
->GenReturn( RET_MacroRecorder
, SmartId( 0 ), nMethod
, (comm_ULONG
)nCurrentButtonId
);
387 if ( nMethod
!= M_Click
)
388 LogVCL( SmartId(), pWin
->GetType(), pWin
->GetSmartUniqueOrHelpId(), aMethod
);
390 LogVCL( SmartId(), pWin
->GetType(), pWin
->GetSmartUniqueOrHelpId(), aMethod
, nCurrentButtonId
);
399 switch ( pWin
->GetType() )
401 case WINDOW_OKBUTTON
: nMethod
= M_OK
; aMethod
= CUniString("OK"); break;
402 case WINDOW_CANCELBUTTON
: nMethod
= M_Cancel
; aMethod
= CUniString("Cancel"); break;
403 case WINDOW_HELPBUTTON
: nMethod
= M_Help
; aMethod
= CUniString("Help"); break;
404 default: nMethod
= M_Default
;aMethod
= CUniString("Unknown Button");
405 DBG_ERROR( "Unknown Button" );
409 StatementList::pRet
->GenReturn( RET_MacroRecorder
, pParent
->GetSmartUniqueOrHelpId(), nMethod
);
414 LogVCL( GetParentID( pWin
), pWin
->GetType(), pWin
->GetSmartUniqueOrHelpId(), aMethod
);
423 if ( !bSendData
&& pWin
->GetSmartUniqueOrHelpId().HasAny() )
425 StatementList::pRet
->GenReturn( RET_MacroRecorder
, pWin
->GetSmartUniqueOrHelpId(), (comm_USHORT
)M_Click
);
432 LogVCL( GetParentID( pWin
), pWin
->GetType(), pWin
->GetSmartUniqueOrHelpId(), CUniString("Click") );
436 /* case C_MoreButton:
440 pRet->GenReturn ( RET_Value, nUId, ((MoreButton*)pControl)->GetState());
443 ((MoreButton*)pControl)->Click();
446 ((MoreButton*)pControl)->SetState(TRUE);
449 ((MoreButton*)pControl)->SetState(FALSE);
452 ReportError( nUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "MoreButton" ) );
456 case WINDOW_SPINFIELD
:
457 case WINDOW_PATTERNFIELD
:
458 case WINDOW_NUMERICFIELD
:
459 case WINDOW_METRICFIELD
:
460 case WINDOW_CURRENCYFIELD
:
461 case WINDOW_DATEFIELD
:
462 case WINDOW_TIMEFIELD
:
465 case VCLEVENT_SPINFIELD_UP
:
466 case VCLEVENT_SPINFIELD_DOWN
:
467 case VCLEVENT_SPINFIELD_FIRST
:
468 case VCLEVENT_SPINFIELD_LAST
:
471 aEditModifyString
.Erase();
477 case VCLEVENT_SPINFIELD_UP
: nMethod
= M_More
; aMethod
= CUniString("More"); break;
478 case VCLEVENT_SPINFIELD_DOWN
: nMethod
= M_Less
; aMethod
= CUniString("Less"); break;
479 case VCLEVENT_SPINFIELD_FIRST
: nMethod
= M_ToMin
; aMethod
= CUniString("ToMin"); break;
480 case VCLEVENT_SPINFIELD_LAST
: nMethod
= M_ToMax
; aMethod
= CUniString("ToMax"); break;
481 default: nMethod
= M_ToMin
; aMethod
= CUniString("Unknown");
482 DBG_ERROR( "Unknown EventID in Spinfield" );
486 StatementList::pRet
->GenReturn( RET_MacroRecorder
, pWin
->GetSmartUniqueOrHelpId(), nMethod
);
491 LogVCL( GetParentID( pWin
), pWin
->GetType(), pWin
->GetSmartUniqueOrHelpId(), aMethod
);
495 case VCLEVENT_EDIT_MODIFY
:
497 aEditModifyString
= ((SpinField
*)pWin
)->GetText();
502 case WINDOW_MENUBUTTON
:
505 case VCLEVENT_BUTTON_CLICK
:
508 StatementList::pRet
->GenReturn( RET_MacroRecorder
, pWin
->GetSmartUniqueOrHelpId(), (comm_USHORT
)M_Click
);
513 LogVCL( GetParentID( pWin
), pWin
->GetType(), pWin
->GetSmartUniqueOrHelpId(), CUniString("Click") );
516 /* Keyevent or Timeout
520 Point aPt( pControl->GetSizePixel().Width() / 2, pControl->GetSizePixel().Height() / 2 );
521 aMEvnt = MouseEvent( aPt,1,MOUSE_SIMPLECLICK,MOUSE_LEFT );
522 ImplMouseButtonDown( pControl, aMEvnt );
524 ULONG nStart = Time::GetSystemTicks();
525 ULONG nDelay = pControl->GetSettings().GetMouseSettings().GetActionDelay();
526 while ( ( Time::GetSystemTicks() - nStart ) < nDelay + 100 )
529 ImplMouseButtonUp ( pControl, aMEvnt );
536 ToolBox
*pTB
= ((ToolBox
*)pWin
);
539 case VCLEVENT_TOOLBOX_SELECT
:
540 { // a Button has been clicked
541 // so this cannot be a tearoff or OpenMenu anymore
542 pActionParent
= NULL
;
543 // compare to 1 for floating ToolBoxes
546 if ( !pWin
->GetSmartUniqueOrHelpId().HasAny() || pWin
->GetSmartUniqueOrHelpId().Matches( 1 ) )
547 // generate direct Button access
548 StatementList::pRet
->GenReturn( RET_MacroRecorder
, SmartId( pTB
->GetItemCommand( pTB
->GetCurItemId() ) ), (comm_USHORT
)(M_Click
) );
550 // access via Toolbox
551 StatementList::pRet
->GenReturn( RET_MacroRecorder
, pTB
->GetSmartUniqueOrHelpId(), (comm_USHORT
)(M_Click
|M_RET_NUM_CONTROL
), static_cast<comm_ULONG
>(pTB
->GetHelpId( pTB
->GetCurItemId() )) ); // GetHelpId() ULONG != comm_ULONG on 64bit
554 /* not needed if ( m_bLog )
559 case VCLEVENT_TOOLBOX_CLICK
: /// ATTENTION this is called during initialisation of toolbox. whoever 'invented' this
562 // case VCLEVENT_WINDOW_SHOW: // not usable ATM. see above
563 // if ( pActionParent )
564 // { // a new toolbox opens up, might be a tearoff
565 // if ( pActionParent != pWin )
566 // { // it IS a tearoff not an undock
567 // // compare to 1 for floating ToolBoxes
570 // if ( !pWin->GetSmartUniqueOrHelpId().HasAny() || pWin->GetSmartUniqueOrHelpId().Matches( 1 ) )
571 // // generate direct Button access
572 // StatementList::pRet->GenReturn( RET_MacroRecorder, SmartId( pActionParent->GetHelpId( pActionParent->GetCurItemId() ) ), (comm_USHORT)(M_TearOff) );
574 // // access via Toolbox
575 // StatementList::pRet->GenReturn( RET_MacroRecorder, pActionParent->GetSmartUniqueOrHelpId(), (comm_USHORT)(M_TearOff|M_RET_NUM_CONTROL), static_cast<comm_ULONG>(pActionParent->GetHelpId( pActionParent->GetCurItemId() )) ); // GetHelpId() ULONG != comm_ULONG on 64bit
580 // LogVCL( pActionParent->GetSmartUniqueOrHelpId(), pWin->GetType(), SmartId( pActionParent->GetHelpId( pActionParent->GetCurItemId() ) ), CUniString("TearOff") );
583 // pActionParent = NULL;
586 case VCLEVENT_TOOLBOX_DEACTIVATE
:
587 pActionParent
= NULL
;
592 /* ToolBox *pTB = ((ToolBox*)pControl);
593 if ( pTB->GetUniqueOrHelpId() != nUId ) // Also Button auf der ToolBox gefunden
595 if ( nParams == PARAM_NONE )
596 { // Wir fälschen einen Parameter
597 nParams = PARAM_USHORT_1;
601 ReportError( nUId, GEN_RES_STR1( S_INTERNAL_ERROR, MethodString( nMethodId ) ) );
606 if( nParams == PARAM_USHORT_1 )\
608 for ( nNr1 = 0; nNr1 < pTB->GetItemCount() && nLNr1 != pTB->GetHelpId(pTB->GetItemId(nNr1)) ; nNr1++ ) {}\
609 bBool1 = nLNr1 == pTB->GetHelpId(pTB->GetItemId(nNr1));\
611 ReportError( nUId, GEN_RES_STR1( S_HELPID_ON_TOOLBOX_NOT_FOUND, MethodString( nMethodId ) ) );\
614 if ( !pTB->IsItemEnabled( pTB->GetItemId(nNr1) ) && nMethodId != _M_IsEnabled )\
616 ReportError( nUId, GEN_RES_STR1( S_BUTTON_DISABLED_ON_TOOLBOX, MethodString( nMethodId ) ) );\
619 else if ( !pTB->IsItemVisible( pTB->GetItemId(nNr1) ) )\
621 ReportError( nUId, GEN_RES_STR1( S_BUTTON_HIDDEN_ON_TOOLBOX, MethodString( nMethodId ) ) );\
626 if ( pTB->GetItemRect(pTB->GetItemId(nNr1)).IsEmpty() )\
628 USHORT nLine = pTB->GetCurLine();\
631 pTB->ShowLine( FALSE );\
632 for ( int i = 1 ; i < 30 ; i++ )\
635 while ( pTB->GetCurLine() != nLine && pTB->GetItemRect(pTB->GetItemId(nNr1)).IsEmpty() );\
636 pTB->Invalidate( pTB->GetScrollRect() );\
638 if ( pTB->GetItemRect(pTB->GetItemId(nNr1)).IsEmpty() )\
640 ReportError( nUId, GEN_RES_STR1( S_CANNOT_MAKE_BUTTON_VISIBLE_IN_TOOLBOX, MethodString( nMethodId ) ) );\
649 case M_SetNextToolBox :
650 if ( (nParams & PARAM_STR_1) )
651 pTB->SetNextToolBox( aString1 );
653 pTB->SetNextToolBox( pTB->GetNextToolBox() );
656 case M_GetNextToolBox :
657 pRet->GenReturn ( RET_Value, nUId, (String)pTB->GetNextToolBox());
660 ReportError( nUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "ToolBox" ) );
670 case VCLEVENT_WINDOW_COMMAND
:
672 case VCLEVENT_WINDOW_KEYINPUT
:
674 const KeyEvent
*pKeyEvent
= ((KeyEvent
*)pWinEvent
->GetData());
675 const KeyCode aKeyCode
= pKeyEvent
->GetKeyCode();
679 Window
*pIdWin
= GetParentWithID( pWin
);
680 if ( pIdWin
!= pWin
)
681 bKeyFollowFocus
= TRUE
;
682 aKeyUniqueID
= pIdWin
->GetSmartUniqueOrHelpId();
685 // HACK Too many KeyEvents generated if ( aKeyString.Len() == 0 )
686 // HACK Too many KeyEvents generated LogVCL( SmartId(), 0, aKeyUniqueID, CUniString("TypeKeysStart") );
688 if ( ( !aKeyCode
.IsMod1() && !aKeyCode
.IsMod2() ) &&
689 (( aKeyCode
.GetGroup() == KEYGROUP_NUM
) ||
690 ( aKeyCode
.GetGroup() == KEYGROUP_ALPHA
) ||
691 ( aKeyCode
.GetCode() == KEY_SPACE
) ||
692 ( aKeyCode
.GetCode() == KEY_ADD
) ||
693 ( aKeyCode
.GetCode() == KEY_SUBTRACT
) ||
694 ( aKeyCode
.GetCode() == KEY_MULTIPLY
) ||
695 ( aKeyCode
.GetCode() == KEY_DIVIDE
) ||
696 ( aKeyCode
.GetCode() == KEY_POINT
) ||
697 ( aKeyCode
.GetCode() == KEY_COMMA
) ||
698 ( aKeyCode
.GetCode() == KEY_EQUAL
) ||
699 ( aKeyCode
.GetCode() == 0) ) )
701 DBG_ASSERT( pKeyEvent
->GetCharCode(), "no charcode found" );
702 aKeyString
+= pKeyEvent
->GetCharCode();
705 { // not a regular key, transfer KeyCode
706 aKeyString
+= sal_Unicode(1); // mask it
707 // extra for '>' which is coded as <SHIFT GREATER>
708 if ( pKeyEvent
->GetCharCode() == '>' )
709 aKeyString
+= sal_Unicode( KEY_GREATER
| (aKeyCode
.GetAllModifier() & ~KEY_SHIFT
) );
711 aKeyString
+= sal_Unicode( aKeyCode
.GetCode() | aKeyCode
.GetAllModifier() );
717 case VCLEVENT_WINDOW_MOUSEMOVE
:
718 case VCLEVENT_WINDOW_MOUSEBUTTONDOWN
:
719 case VCLEVENT_WINDOW_MOUSEBUTTONUP
:
727 case WINDOW_DOCKINGWINDOW
:
728 // switch( nEventID )
731 DBG_TRACE3( "TT_VCLMessage %u %u %X",nEventID
, pWin
->GetType(), pWin
);
732 // BOOL bx = ((DockingWindow*)pWin)->IsFloatingMode();
735 if ( ((DockingWindow*)pControl)->IsFloatingMode() )
736 ((DockingWindow*)pControl)->SetFloatingMode(FALSE);
738 ReportError( nUId, GEN_RES_STR1( S_ALLOWED_ONLY_IN_FLOATING_MODE, MethodString( nMethodId ) ) );
741 if ( !((DockingWindow*)pControl)->IsFloatingMode() )
742 ((DockingWindow*)pControl)->SetFloatingMode(TRUE);
744 ReportError( nUId, GEN_RES_STR1( S_ALLOWED_ONLY_IN_FLOATING_MODE, MethodString( nMethodId ) ) );
747 pRet->GenReturn ( RET_Value, nUId, (comm_BOOL) !((DockingWindow*)pControl)->IsFloatingMode());
750 //nWindowWaitUId = nUId;
751 DBG_ASSERT( nUId == pControl->GetUniqueOrHelpId(), "nUID != UniqueOrHelpId");
752 SET_WINP_CLOSING(pControl);
753 ((DockingWindow*)pControl)->Close();
760 if ( ((DockingWindow*)pControl)->IsFloatingMode() )
762 pControl = ((DockingWindow*)pControl)->GetFloatingWindow();
766 ReportError( nUId, GEN_RES_STR1( S_ALLOWED_ONLY_IN_DOCKING_MODE, MethodString( nMethodId ) ) );
768 case M_Help: // Alles was unten weiterbehandelt werden soll
772 ReportError( nUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "DockingWindow" ) );
782 case WINDOW_FLOATINGWINDOW
:
784 DBG_TRACE3( "TT_VCLMessage %u %u %X",nEventID
, pWin
->GetType(), pWin
);
785 // FloatingWindow *pFW = ((FloatingWindow*)pWin);
786 /* switch( nEventID )
789 // M_OpenMenu an einem ToolboxButton
790 case VCLEVENT_WINDOW_SHOW:
792 { // a new FloatingWindow opens up, so we assume an OpenMenu
793 // compare to 1 for floating ToolBoxes
794 if ( ( pActionParent->GetUniqueOrHelpId() == 0 || pActionParent->GetUniqueOrHelpId() == 1 ) )
795 // generate direct Button access
796 StatementList::pRet->GenReturn( RET_MacroRecorder, pActionParent->GetHelpId( pActionParent->GetCurItemId() ), (comm_USHORT)(M_OpenMenu) );
798 // access via Toolbox
799 StatementList::pRet->GenReturn( RET_MacroRecorder, pActionParent->GetUniqueOrHelpId(), (comm_USHORT)(M_OpenMenu|M_RET_NUM_CONTROL), pActionParent->GetHelpId( pActionParent->GetCurItemId() ) );
808 case M_AnimateMouse :
809 AnimateMouse( pControl, MitteOben);
812 pRet->GenReturn ( RET_Value, nUId, (comm_BOOL)!((FloatingWindow*)pControl)->IsRollUp());
815 ((FloatingWindow*)pControl)->RollUp();
818 ((FloatingWindow*)pControl)->RollDown();
822 if ( pControl->GetStyle() & WB_SIZEABLE )
824 pControl->SetSizePixel(Size(nNr1,nNr2));
828 ReportError( nUId, GEN_RES_STR1( S_SIZE_NOT_CHANGEABLE, MethodString( nMethodId ) ) );
832 DBG_ASSERT( nUId == pControl->GetUniqueOrHelpId(), "nUID != UniqueOrHelpId");
833 SET_WINP_CLOSING(pControl);
834 ((FloatingWindow*)pControl)->Close();
836 case M_Help: // Alles was unten weiterbehandelt werden soll
840 ReportError( nUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "FloatingWin" ) );
862 case M_AnimateMouse :
863 AnimateMouse( pControl, MitteOben);
866 DBG_ASSERT( nUId == pControl->GetUniqueOrHelpId(), "nUID != UniqueOrHelpId");
867 SET_WINP_CLOSING(pControl);
868 ((SystemWindow*)pControl)->Close();
872 pControl->SetPosPixel(Point(nNr1,nNr2));
876 ReportError( nUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "Dialog" ) );
898 DBG_ASSERT( nUId == pControl->GetUniqueOrHelpId(), "nUID != UniqueOrHelpId");
899 SET_WINP_CLOSING(pControl);
900 ((WorkWindow*)pControl)->Close();
906 case M_Help: // Alles was unten weiterbehandelt werden soll
909 ReportError( nUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "WorkWindow" ) );
942 MessBox* pMB = (MessBox*)pControl;
945 case M_GetCheckBoxText:
946 pRet->GenReturn ( RET_Value, nUId, pMB->GetCheckBoxText() );
949 pRet->GenReturn ( RET_Value, nUId, comm_BOOL( pMB->GetCheckBoxState() == STATE_CHECK) );
952 pRet->GenReturn ( RET_Value, nUId, comm_ULONG( pMB->GetCheckBoxState() ));
955 pMB->SetCheckBoxState( STATE_CHECK );
958 pMB->SetCheckBoxState( STATE_NOCHECK );
961 pRet->GenReturn ( RET_Value, nUId, pMB->GetMessText());
969 break; // break the case here else continue at C_ButtonDialog
973 ButtonDialog* pBD = (ButtonDialog*)pControl;
974 #if OSL_DEBUG_LEVEL > 1
975 m_pDbgWin->AddText( "Working MessBox: " );
976 if (pControl->IsVisible())
977 m_pDbgWin->AddText("*(Visible)\n");
979 m_pDbgWin->AddText("*(nicht Visible)\n");
984 pRet->GenReturn ( RET_Value, nUId, pControl->GetText());
987 if ( nParams & PARAM_USHORT_1 )
989 if ( pBD->GetPushButton( nNr1 ) )
991 if ( nNr1 != BUTTONID_HELP )
993 SET_WINP_CLOSING(pControl);
995 pBD->GetPushButton( nNr1 )->Click();
998 ReportError( nUId, GEN_RES_STR2( S_NO_DEFAULT_BUTTON, UniString::CreateFromInt32( nNr1 ), MethodString( nMethodId ) ) );
1001 ReportError( nUId, GEN_RES_STR1( S_BUTTONID_REQUIRED, MethodString( nMethodId ) ) );
1003 case M_GetButtonCount :
1004 pRet->GenReturn ( RET_Value, nUId, comm_ULONG(pBD->GetButtonCount()));
1006 case M_GetButtonId :
1007 if ( ValueOK(nUId, MethodString( nMethodId ),nNr1,pBD->GetButtonCount()) )
1008 pRet->GenReturn ( RET_Value, nUId, comm_ULONG(pBD->GetButtonId(nNr1-1)));
1011 ReportError( nUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "MessageBox" ) );
1025 case VCLEVENT_CONTROL_LOSEFOCUS
:
1026 if ( pEditModify
== pWin
)
1030 StatementList::pRet
->GenReturn( RET_MacroRecorder
, pWin
->GetSmartUniqueOrHelpId(), M_SetText
, aEditModifyString
);
1035 LogVCL( GetParentID( pWin
), pWin
->GetType(), pWin
->GetSmartUniqueOrHelpId(), CUniString("Modify") );
1038 aEditModifyString
.Erase(); //could be somewhat lengthy
1046 else if ( pEvent
->ISA( VclMenuEvent
) )
1048 // VclMenuEvent* pMenuEvent = ( VclMenuEvent* ) pEvent;
1053 new StatementFlow( NULL
, F_EndCommandBlock
); // Kommando zum Senden erzeugen und in que eintragen
1060 static ::osl::Mutex
* getRecorderMutex()
1062 static ::osl::Mutex
* pMutex
= NULL
;
1065 ::osl::MutexGuard
aGuard(::osl::Mutex::getGlobalMutex());
1067 pMutex
= new ::osl::Mutex();
1073 void MacroRecorder::CheckDelete()
1075 ::osl::MutexGuard
aGuard( getRecorderMutex() );
1076 if ( !m_bRecord
&& !m_bLog
)
1078 pMacroRecorder
= NULL
;
1084 MacroRecorder
* MacroRecorder::GetMacroRecorder()
1086 ::osl::MutexGuard
aGuard( getRecorderMutex() );
1087 if ( !pMacroRecorder
)
1088 pMacroRecorder
= new MacroRecorder
;
1090 return pMacroRecorder
;
1093 BOOL
MacroRecorder::HasMacroRecorder()
1095 ::osl::MutexGuard
aGuard( getRecorderMutex() );
1096 return pMacroRecorder
!= NULL
;