19d1279ecSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
39d1279ecSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
49d1279ecSAndrew Rist * or more contributor license agreements. See the NOTICE file
59d1279ecSAndrew Rist * distributed with this work for additional information
69d1279ecSAndrew Rist * regarding copyright ownership. The ASF licenses this file
79d1279ecSAndrew Rist * to you under the Apache License, Version 2.0 (the
89d1279ecSAndrew Rist * "License"); you may not use this file except in compliance
99d1279ecSAndrew Rist * with the License. You may obtain a copy of the License at
109d1279ecSAndrew Rist *
119d1279ecSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
129d1279ecSAndrew Rist *
139d1279ecSAndrew Rist * Unless required by applicable law or agreed to in writing,
149d1279ecSAndrew Rist * software distributed under the License is distributed on an
159d1279ecSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
169d1279ecSAndrew Rist * KIND, either express or implied. See the License for the
179d1279ecSAndrew Rist * specific language governing permissions and limitations
189d1279ecSAndrew Rist * under the License.
199d1279ecSAndrew Rist *
209d1279ecSAndrew Rist *************************************************************/
219d1279ecSAndrew Rist
229d1279ecSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_automation.hxx"
26cdf0e10cSrcweir #include <osl/mutex.hxx>
27cdf0e10cSrcweir
28cdf0e10cSrcweir #include <vcl/window.hxx>
29cdf0e10cSrcweir #include <vcl/vclevent.hxx>
30cdf0e10cSrcweir #include <vcl/button.hxx>
31cdf0e10cSrcweir #include <vcl/edit.hxx>
32cdf0e10cSrcweir #include <vcl/spinfld.hxx>
33cdf0e10cSrcweir #include <vcl/msgbox.hxx>
34cdf0e10cSrcweir #include <vcl/toolbox.hxx>
35cdf0e10cSrcweir #include <vcl/lstbox.hxx>
36cdf0e10cSrcweir #include <vcl/sound.hxx>
37cdf0e10cSrcweir #include <vcl/combobox.hxx>
38cdf0e10cSrcweir #include <vcl/floatwin.hxx>
39cdf0e10cSrcweir #include <basic/ttstrhlp.hxx>
40cdf0e10cSrcweir #include "statemnt.hxx"
41cdf0e10cSrcweir #include "retstrm.hxx"
42cdf0e10cSrcweir #include "rcontrol.hxx"
43cdf0e10cSrcweir #include "recorder.hxx"
44cdf0e10cSrcweir
45cdf0e10cSrcweir #include <comphelper/uieventslogger.hxx>
46cdf0e10cSrcweir
47cdf0e10cSrcweir MacroRecorder* MacroRecorder::pMacroRecorder = NULL;
48cdf0e10cSrcweir
MacroRecorder()49cdf0e10cSrcweir MacroRecorder::MacroRecorder()
50cdf0e10cSrcweir : pLastWin( NULL )
51cdf0e10cSrcweir , pEditModify( NULL )
52cdf0e10cSrcweir , pActionParent( NULL )
53cdf0e10cSrcweir , aKeyUniqueID()
54cdf0e10cSrcweir , pKeyWin( NULL )
55cdf0e10cSrcweir , bKeyFollowFocus( sal_False )
56cdf0e10cSrcweir , m_bRecord( sal_False )
57cdf0e10cSrcweir , m_bLog( sal_False )
58cdf0e10cSrcweir {
59cdf0e10cSrcweir aHookRefresh.SetTimeout( 500 );
60cdf0e10cSrcweir aHookRefresh.SetTimeoutHdl( LINK( this, MacroRecorder, HookRefreshHdl) );
61cdf0e10cSrcweir aHookRefresh.Start();
62cdf0e10cSrcweir aEventListenerHdl = LINK( this, MacroRecorder, EventListener );
63cdf0e10cSrcweir AddEventHooks();
64cdf0e10cSrcweir }
65cdf0e10cSrcweir
~MacroRecorder()66cdf0e10cSrcweir MacroRecorder::~MacroRecorder()
67cdf0e10cSrcweir {
68cdf0e10cSrcweir aHookRefresh.Stop();
69cdf0e10cSrcweir RemoveEventHooks();
70cdf0e10cSrcweir }
71cdf0e10cSrcweir
AddEventHooks()72cdf0e10cSrcweir void MacroRecorder::AddEventHooks()
73cdf0e10cSrcweir {
74cdf0e10cSrcweir Window *pTopLevel = Application::GetFirstTopLevelWindow();
75cdf0e10cSrcweir while ( pTopLevel )
76cdf0e10cSrcweir {
77cdf0e10cSrcweir Window *pParent = pTopLevel;
78cdf0e10cSrcweir while ( pParent->GetParent() )
79cdf0e10cSrcweir pParent = pParent->GetParent();
80cdf0e10cSrcweir
81cdf0e10cSrcweir pParent->RemoveChildEventListener( aEventListenerHdl ); // might be instrumented already
82cdf0e10cSrcweir pParent->AddChildEventListener( aEventListenerHdl );
83cdf0e10cSrcweir
84cdf0e10cSrcweir pTopLevel = Application::GetNextTopLevelWindow( pTopLevel );
85cdf0e10cSrcweir }
86cdf0e10cSrcweir }
87cdf0e10cSrcweir
RemoveEventHooks()88cdf0e10cSrcweir void MacroRecorder::RemoveEventHooks()
89cdf0e10cSrcweir {
90cdf0e10cSrcweir Window *pTopLevel = Application::GetFirstTopLevelWindow();
91cdf0e10cSrcweir while ( pTopLevel )
92cdf0e10cSrcweir {
93cdf0e10cSrcweir pTopLevel->RemoveChildEventListener( aEventListenerHdl );
94cdf0e10cSrcweir pTopLevel = Application::GetNextTopLevelWindow( pTopLevel );
95cdf0e10cSrcweir }
96cdf0e10cSrcweir }
97cdf0e10cSrcweir
IMPL_LINK(MacroRecorder,HookRefreshHdl,void *,EMPTYARG)98cdf0e10cSrcweir IMPL_LINK( MacroRecorder, HookRefreshHdl, void*, EMPTYARG )
99cdf0e10cSrcweir {
100cdf0e10cSrcweir AddEventHooks();
101cdf0e10cSrcweir return 0;
102cdf0e10cSrcweir }
103cdf0e10cSrcweir
LogVCL(rtl::OString aParentID,sal_uInt16 nVCLWindowType,rtl::OString aID,String aMethod,sal_uInt16 nParam)104cdf0e10cSrcweir void MacroRecorder::LogVCL( rtl::OString aParentID, sal_uInt16 nVCLWindowType, rtl::OString aID, String aMethod, sal_uInt16 nParam )
105cdf0e10cSrcweir {
106cdf0e10cSrcweir ::comphelper::UiEventsLogger::logVcl( Id2Str( aParentID ), nVCLWindowType, Id2Str( aID ), aMethod, nParam );
107cdf0e10cSrcweir }
108cdf0e10cSrcweir
LogVCL(rtl::OString aParentID,sal_uInt16 nVCLWindowType,rtl::OString aID,String aMethod)109cdf0e10cSrcweir void MacroRecorder::LogVCL( rtl::OString aParentID, sal_uInt16 nVCLWindowType, rtl::OString aID, String aMethod )
110cdf0e10cSrcweir {
111cdf0e10cSrcweir ::comphelper::UiEventsLogger::logVcl( Id2Str( aParentID ), nVCLWindowType, Id2Str( aID ), aMethod );
112cdf0e10cSrcweir }
113cdf0e10cSrcweir
GetParentWithID(Window * pThis)114cdf0e10cSrcweir Window* MacroRecorder::GetParentWithID( Window* pThis )
115cdf0e10cSrcweir {
116cdf0e10cSrcweir Window *pOverlap = pThis->GetWindow( WINDOW_OVERLAP );
117144e4e62SHerbert Dürr while ( pOverlap != pThis && pThis->GetUniqueOrHelpId().isEmpty() && pThis->GET_REAL_PARENT() )
118cdf0e10cSrcweir pThis = pThis->GET_REAL_PARENT();
119cdf0e10cSrcweir return pThis;
120cdf0e10cSrcweir }
121cdf0e10cSrcweir
GetParentID(Window * pThis)122cdf0e10cSrcweir rtl::OString MacroRecorder::GetParentID( Window* pThis )
123cdf0e10cSrcweir {
124cdf0e10cSrcweir if ( pThis->GetParent() )
125cdf0e10cSrcweir return pThis->GetParent()->GetUniqueOrHelpId();
126cdf0e10cSrcweir else
127cdf0e10cSrcweir return rtl::OString();
128cdf0e10cSrcweir }
129cdf0e10cSrcweir
IMPL_LINK(MacroRecorder,EventListener,VclSimpleEvent *,pEvent)130cdf0e10cSrcweir IMPL_LINK( MacroRecorder, EventListener, VclSimpleEvent*, pEvent )
131cdf0e10cSrcweir {
132cdf0e10cSrcweir sal_Bool bSendData = sal_False;
133cdf0e10cSrcweir
134cdf0e10cSrcweir if ( pEvent->ISA( VclWindowEvent ) )
135cdf0e10cSrcweir {
136cdf0e10cSrcweir VclWindowEvent* pWinEvent = ( VclWindowEvent* ) pEvent;
137cdf0e10cSrcweir Window* pWin = pWinEvent->GetWindow();
138cdf0e10cSrcweir sal_uLong nEventID = pWinEvent->GetId();
139cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
140cdf0e10cSrcweir if ( nEventID >= 1001 && nEventID != VCLEVENT_WINDOW_KEYUP )
141cdf0e10cSrcweir nEventID = pWinEvent->GetId(); // Just something to set a breakpoint
142cdf0e10cSrcweir else
143cdf0e10cSrcweir return 0;
144cdf0e10cSrcweir #endif
145cdf0e10cSrcweir
146cdf0e10cSrcweir // check for different action after collecting keys
147cdf0e10cSrcweir // send if there_is_something_to_send
148cdf0e10cSrcweir // and eather event_is_not_of_interest
149cdf0e10cSrcweir // or ( new_window and new_window_is_interesting ) ( ignore interesting events to uninteresting window )
150cdf0e10cSrcweir
151cdf0e10cSrcweir if ( aKeyString.Len()
152cdf0e10cSrcweir && ( ( nEventID != VCLEVENT_WINDOW_KEYINPUT
153cdf0e10cSrcweir && nEventID != VCLEVENT_WINDOW_MOUSEMOVE
154cdf0e10cSrcweir && nEventID != VCLEVENT_WINDOW_COMMAND
155cdf0e10cSrcweir && nEventID != VCLEVENT_WINDOW_KEYUP )
156cdf0e10cSrcweir || ( pKeyWin != pWin
157cdf0e10cSrcweir && ( pWin->GetType() == WINDOW_CONTROL || pWin->GetType() == WINDOW_WINDOW )
158cdf0e10cSrcweir )
159cdf0e10cSrcweir )
160cdf0e10cSrcweir )
161cdf0e10cSrcweir {
162cdf0e10cSrcweir if ( m_bRecord )
163cdf0e10cSrcweir {
164*07a3d7f1SPedro Giffuni // we cannot access pKeyWin since it might have disappeared
165cdf0e10cSrcweir if ( bKeyFollowFocus )
166cdf0e10cSrcweir StatementList::pRet->GenReturn( RET_MacroRecorder, aKeyUniqueID, (sal_uInt16)M_TypeKeys, aKeyString, bKeyFollowFocus );
167cdf0e10cSrcweir else
168cdf0e10cSrcweir StatementList::pRet->GenReturn( RET_MacroRecorder, aKeyUniqueID, (sal_uInt16)M_TypeKeys, aKeyString );
169cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
170cdf0e10cSrcweir StatementList::pRet->GenReturn( RET_MacroRecorder, aKeyUniqueID, (sal_uInt16)M_TypeKeys, String::CreateFromInt32( nEventID ) );
171cdf0e10cSrcweir #endif
172cdf0e10cSrcweir bSendData = sal_True;
173cdf0e10cSrcweir }
174cdf0e10cSrcweir if ( m_bLog )
175cdf0e10cSrcweir {
176cdf0e10cSrcweir // HACK Too many KeyEvents generated LogVCL( rtl::OString(), 0, aKeyUniqueID, CUniString("TypeKeys"), aKeyString.Len() );
177cdf0e10cSrcweir }
178cdf0e10cSrcweir // cleanup
179cdf0e10cSrcweir aKeyString.Erase();
180cdf0e10cSrcweir pKeyWin = NULL;
181cdf0e10cSrcweir bKeyFollowFocus = sal_False;
182cdf0e10cSrcweir }
183cdf0e10cSrcweir
184cdf0e10cSrcweir switch ( pWin->GetType() )
185cdf0e10cSrcweir {
186cdf0e10cSrcweir case WINDOW_TABPAGE:
187cdf0e10cSrcweir switch( nEventID )
188cdf0e10cSrcweir {
189cdf0e10cSrcweir case VCLEVENT_WINDOW_ACTIVATE:
190cdf0e10cSrcweir if ( m_bRecord )
191cdf0e10cSrcweir {
192cdf0e10cSrcweir StatementList::pRet->GenReturn( RET_MacroRecorder, rtl::OString(), (comm_USHORT)(M_SetPage|M_RET_NUM_CONTROL), Id2Str( pWin->GetUniqueOrHelpId() ) );
193cdf0e10cSrcweir bSendData = sal_True;
194cdf0e10cSrcweir }
195cdf0e10cSrcweir if ( m_bLog )
196cdf0e10cSrcweir {
197cdf0e10cSrcweir LogVCL( rtl::OString(), pWin->GetType(), pWin->GetUniqueOrHelpId(), CUniString("SetPage") );
198cdf0e10cSrcweir }
199cdf0e10cSrcweir break;
200cdf0e10cSrcweir }
201cdf0e10cSrcweir break;
202cdf0e10cSrcweir case WINDOW_RADIOBUTTON:
203cdf0e10cSrcweir case WINDOW_IMAGERADIOBUTTON:
204cdf0e10cSrcweir switch( nEventID )
205cdf0e10cSrcweir {
206cdf0e10cSrcweir case VCLEVENT_BUTTON_CLICK: // VCLEVENT_RADIOBUTTON_TOGGLE
207cdf0e10cSrcweir {
208cdf0e10cSrcweir if ( ((RadioButton*)pWin)->IsChecked() )
209cdf0e10cSrcweir {
210cdf0e10cSrcweir if ( m_bRecord )
211cdf0e10cSrcweir {
212cdf0e10cSrcweir StatementList::pRet->GenReturn( RET_MacroRecorder, pWin->GetUniqueOrHelpId(), (comm_USHORT)M_Check );
213cdf0e10cSrcweir bSendData = sal_True;
214cdf0e10cSrcweir }
215cdf0e10cSrcweir if ( m_bLog )
216cdf0e10cSrcweir {
217cdf0e10cSrcweir LogVCL( GetParentID( pWin ), pWin->GetType(), pWin->GetUniqueOrHelpId(), CUniString("Check") );
218cdf0e10cSrcweir }
219cdf0e10cSrcweir }
220cdf0e10cSrcweir }
221cdf0e10cSrcweir break;
222cdf0e10cSrcweir }
223cdf0e10cSrcweir break;
224cdf0e10cSrcweir case WINDOW_CHECKBOX:
225cdf0e10cSrcweir case WINDOW_TRISTATEBOX:
226cdf0e10cSrcweir switch( nEventID )
227cdf0e10cSrcweir {
228cdf0e10cSrcweir case VCLEVENT_BUTTON_CLICK: //VCLEVENT_CHECKBOX_TOGGLE:
229cdf0e10cSrcweir {
230cdf0e10cSrcweir comm_USHORT nMethod;
231cdf0e10cSrcweir String aMethod;
232cdf0e10cSrcweir switch ( ((TriStateBox*)pWin)->GetState() )
233cdf0e10cSrcweir {
234cdf0e10cSrcweir case STATE_CHECK: nMethod = M_Check; aMethod = CUniString("Check"); break;
235cdf0e10cSrcweir case STATE_NOCHECK: nMethod = M_UnCheck; aMethod = CUniString("UnCheck"); break;
236cdf0e10cSrcweir case STATE_DONTKNOW: nMethod = M_TriState; aMethod = CUniString("TriState"); break;
237cdf0e10cSrcweir default: nMethod = M_Check;
238cdf0e10cSrcweir DBG_ERROR( "Unknown state in TriStateBox::GetState()" );
239cdf0e10cSrcweir }
240cdf0e10cSrcweir if ( m_bRecord )
241cdf0e10cSrcweir {
242cdf0e10cSrcweir StatementList::pRet->GenReturn( RET_MacroRecorder, pWin->GetUniqueOrHelpId(), nMethod );
243cdf0e10cSrcweir bSendData = sal_True;
244cdf0e10cSrcweir }
245cdf0e10cSrcweir if ( m_bLog )
246cdf0e10cSrcweir {
247cdf0e10cSrcweir LogVCL( GetParentID( pWin ), pWin->GetType(), pWin->GetUniqueOrHelpId(), aMethod );
248cdf0e10cSrcweir }
249cdf0e10cSrcweir }
250cdf0e10cSrcweir break;
251cdf0e10cSrcweir }
252cdf0e10cSrcweir break;
253cdf0e10cSrcweir case WINDOW_EDIT:
254cdf0e10cSrcweir case WINDOW_MULTILINEEDIT:
255cdf0e10cSrcweir switch( nEventID )
256cdf0e10cSrcweir {
257cdf0e10cSrcweir case VCLEVENT_EDIT_MODIFY:
258cdf0e10cSrcweir pEditModify = pWin;
259cdf0e10cSrcweir aEditModifyString = ((Edit*)pWin)->GetText();
260cdf0e10cSrcweir break;
261cdf0e10cSrcweir }
262cdf0e10cSrcweir break;
263cdf0e10cSrcweir case WINDOW_MULTILISTBOX:
264cdf0e10cSrcweir switch( nEventID )
265cdf0e10cSrcweir {
266cdf0e10cSrcweir case VCLEVENT_LISTBOX_SELECT:
267cdf0e10cSrcweir Sound::Beep();
268cdf0e10cSrcweir }
269cdf0e10cSrcweir case WINDOW_LISTBOX:
270cdf0e10cSrcweir switch( nEventID )
271cdf0e10cSrcweir {
272cdf0e10cSrcweir // case VCLEVENT_LISTBOX_DOUBLECLICK:
273cdf0e10cSrcweir case VCLEVENT_LISTBOX_SELECT:
274cdf0e10cSrcweir if ( m_bRecord )
275cdf0e10cSrcweir {
276cdf0e10cSrcweir StatementList::pRet->GenReturn( RET_MacroRecorder, pWin->GetUniqueOrHelpId(), (comm_USHORT)M_Select, comm_ULONG( ((ListBox*)pWin)->GetSelectEntryPos() +1 ) );
277cdf0e10cSrcweir bSendData = sal_True;
278cdf0e10cSrcweir }
279cdf0e10cSrcweir if ( m_bLog )
280cdf0e10cSrcweir {
281cdf0e10cSrcweir LogVCL( GetParentID( pWin ), pWin->GetType(), pWin->GetUniqueOrHelpId(), CUniString("Select"), ((ListBox*)pWin)->GetSelectEntryPos() );
282cdf0e10cSrcweir }
283cdf0e10cSrcweir break;
284cdf0e10cSrcweir }
285cdf0e10cSrcweir break;
286cdf0e10cSrcweir case WINDOW_COMBOBOX:
287cdf0e10cSrcweir case WINDOW_PATTERNBOX:
288cdf0e10cSrcweir case WINDOW_NUMERICBOX:
289cdf0e10cSrcweir case WINDOW_METRICBOX:
290cdf0e10cSrcweir case WINDOW_CURRENCYBOX:
291cdf0e10cSrcweir case WINDOW_DATEBOX:
292cdf0e10cSrcweir case WINDOW_TIMEBOX:
293cdf0e10cSrcweir switch( nEventID )
294cdf0e10cSrcweir {
295cdf0e10cSrcweir case VCLEVENT_EDIT_MODIFY:
296cdf0e10cSrcweir pEditModify = pWin;
297cdf0e10cSrcweir aEditModifyString = ((Edit*)pWin)->GetText();
298cdf0e10cSrcweir break;
299cdf0e10cSrcweir case VCLEVENT_COMBOBOX_SELECT:
300cdf0e10cSrcweir {
301cdf0e10cSrcweir pEditModify = NULL;
302cdf0e10cSrcweir aEditModifyString.Erase();
303cdf0e10cSrcweir
304cdf0e10cSrcweir sal_uInt16 nPos = ((ComboBox*)pWin)->GetEntryPos(((ComboBox*)pWin)->GetText());
305cdf0e10cSrcweir if ( m_bRecord )
306cdf0e10cSrcweir {
307cdf0e10cSrcweir if ( nPos == COMBOBOX_ENTRY_NOTFOUND )
308cdf0e10cSrcweir Sound::Beep();
309cdf0e10cSrcweir else
310cdf0e10cSrcweir {
311cdf0e10cSrcweir StatementList::pRet->GenReturn( RET_MacroRecorder, pWin->GetUniqueOrHelpId(), (comm_USHORT)M_Select, (comm_ULONG) nPos+1 );
312cdf0e10cSrcweir bSendData = sal_True;
313cdf0e10cSrcweir }
314cdf0e10cSrcweir }
315cdf0e10cSrcweir if ( m_bLog )
316cdf0e10cSrcweir {
317cdf0e10cSrcweir LogVCL( GetParentID( pWin ), pWin->GetType(), pWin->GetUniqueOrHelpId(), CUniString("Select"), nPos );
318cdf0e10cSrcweir }
319cdf0e10cSrcweir }
320cdf0e10cSrcweir }
321cdf0e10cSrcweir break;
322cdf0e10cSrcweir case WINDOW_PUSHBUTTON:
323cdf0e10cSrcweir case WINDOW_OKBUTTON:
324cdf0e10cSrcweir case WINDOW_CANCELBUTTON:
325cdf0e10cSrcweir case WINDOW_IMAGEBUTTON:
326cdf0e10cSrcweir case WINDOW_MOREBUTTON:
327cdf0e10cSrcweir case WINDOW_HELPBUTTON:
328cdf0e10cSrcweir switch( nEventID )
329cdf0e10cSrcweir {
330cdf0e10cSrcweir case VCLEVENT_BUTTON_CLICK:
331cdf0e10cSrcweir Window* pParent = pWin->GetParent();
332cdf0e10cSrcweir sal_Bool bDone = sal_False;
333144e4e62SHerbert Dürr if ( pParent->IsDialog() && pWin->GetUniqueOrHelpId().isEmpty() )
334cdf0e10cSrcweir {
335cdf0e10cSrcweir switch ( pParent->GetType() )
336cdf0e10cSrcweir {
337cdf0e10cSrcweir case WINDOW_MESSBOX:
338cdf0e10cSrcweir case WINDOW_INFOBOX:
339cdf0e10cSrcweir case WINDOW_WARNINGBOX:
340cdf0e10cSrcweir case WINDOW_ERRORBOX:
341cdf0e10cSrcweir case WINDOW_QUERYBOX:
342cdf0e10cSrcweir case WINDOW_BUTTONDIALOG:
343cdf0e10cSrcweir {
344cdf0e10cSrcweir comm_USHORT nMethod;
345cdf0e10cSrcweir String aMethod;
346cdf0e10cSrcweir ButtonDialog* pBD = (ButtonDialog*)pParent;
347cdf0e10cSrcweir
348cdf0e10cSrcweir // we have to find the current Button ID ourselves since it is not generated at this point :-(
349cdf0e10cSrcweir sal_uInt16 nCurrentButtonId = 0xffff; // Some wild value to wak up people
350cdf0e10cSrcweir sal_uInt16 i;
351cdf0e10cSrcweir for ( i = 0; i < pBD->GetButtonCount() ; i++ )
352cdf0e10cSrcweir {
353cdf0e10cSrcweir if ( pBD->GetPushButton( pBD->GetButtonId(i) ) == pWin )
354cdf0e10cSrcweir {
355cdf0e10cSrcweir nCurrentButtonId = pBD->GetButtonId(i);
356cdf0e10cSrcweir break;
357cdf0e10cSrcweir }
358cdf0e10cSrcweir }
359cdf0e10cSrcweir
360cdf0e10cSrcweir switch ( nCurrentButtonId )
361cdf0e10cSrcweir {
362cdf0e10cSrcweir case BUTTONID_OK: nMethod = M_OK; aMethod = CUniString("OK"); break;
363cdf0e10cSrcweir case BUTTONID_CANCEL: nMethod = M_Cancel; aMethod = CUniString("Cancel"); break;
364cdf0e10cSrcweir case BUTTONID_YES: nMethod = M_Yes; aMethod = CUniString("Yes"); break;
365cdf0e10cSrcweir case BUTTONID_NO: nMethod = M_No; aMethod = CUniString("No"); break;
366cdf0e10cSrcweir case BUTTONID_RETRY: nMethod = M_Repeat; aMethod = CUniString("Repeat"); break;
367cdf0e10cSrcweir case BUTTONID_HELP: nMethod = M_Help; aMethod = CUniString("Help"); break;
368cdf0e10cSrcweir default: nMethod = M_Click; aMethod = CUniString("Click");
369cdf0e10cSrcweir }
370cdf0e10cSrcweir if ( m_bRecord )
371cdf0e10cSrcweir {
372cdf0e10cSrcweir if ( nMethod != M_Click )
373cdf0e10cSrcweir StatementList::pRet->GenReturn( RET_MacroRecorder, UID_ACTIVE, nMethod );
374cdf0e10cSrcweir else
375cdf0e10cSrcweir StatementList::pRet->GenReturn( RET_MacroRecorder, UID_ACTIVE, nMethod, (comm_ULONG)nCurrentButtonId );
376cdf0e10cSrcweir bSendData = sal_True;
377cdf0e10cSrcweir }
378cdf0e10cSrcweir if ( m_bLog )
379cdf0e10cSrcweir {
380cdf0e10cSrcweir if ( nMethod != M_Click )
381cdf0e10cSrcweir LogVCL( rtl::OString(), pWin->GetType(), pWin->GetUniqueOrHelpId(), aMethod );
382cdf0e10cSrcweir else
383cdf0e10cSrcweir LogVCL( rtl::OString(), pWin->GetType(), pWin->GetUniqueOrHelpId(), aMethod, nCurrentButtonId );
384cdf0e10cSrcweir bDone = sal_True;
385cdf0e10cSrcweir }
386cdf0e10cSrcweir }
387cdf0e10cSrcweir break;
388cdf0e10cSrcweir default:
389cdf0e10cSrcweir {
390cdf0e10cSrcweir comm_USHORT nMethod;
391cdf0e10cSrcweir String aMethod;
392cdf0e10cSrcweir switch ( pWin->GetType() )
393cdf0e10cSrcweir {
394cdf0e10cSrcweir case WINDOW_OKBUTTON: nMethod = M_OK; aMethod = CUniString("OK"); break;
395cdf0e10cSrcweir case WINDOW_CANCELBUTTON: nMethod = M_Cancel; aMethod = CUniString("Cancel"); break;
396cdf0e10cSrcweir case WINDOW_HELPBUTTON: nMethod = M_Help; aMethod = CUniString("Help"); break;
397cdf0e10cSrcweir default: nMethod = M_Default;aMethod = CUniString("Unknown Button");
398cdf0e10cSrcweir DBG_ERROR( "Unknown Button" );
399cdf0e10cSrcweir }
400cdf0e10cSrcweir if ( m_bRecord )
401cdf0e10cSrcweir {
402cdf0e10cSrcweir StatementList::pRet->GenReturn( RET_MacroRecorder, pParent->GetUniqueOrHelpId(), nMethod );
403cdf0e10cSrcweir bSendData = sal_True;
404cdf0e10cSrcweir }
405cdf0e10cSrcweir if ( m_bLog )
406cdf0e10cSrcweir {
407cdf0e10cSrcweir LogVCL( GetParentID( pWin ), pWin->GetType(), pWin->GetUniqueOrHelpId(), aMethod );
408cdf0e10cSrcweir bDone = sal_True;
409cdf0e10cSrcweir }
410cdf0e10cSrcweir }
411cdf0e10cSrcweir break;
412cdf0e10cSrcweir }
413cdf0e10cSrcweir }
414cdf0e10cSrcweir if ( m_bRecord )
415cdf0e10cSrcweir {
416144e4e62SHerbert Dürr if ( !bSendData && !pWin->GetUniqueOrHelpId().isEmpty() )
417cdf0e10cSrcweir {
418cdf0e10cSrcweir StatementList::pRet->GenReturn( RET_MacroRecorder, pWin->GetUniqueOrHelpId(), (comm_USHORT)M_Click );
419cdf0e10cSrcweir bSendData = sal_True;
420cdf0e10cSrcweir }
421cdf0e10cSrcweir }
422cdf0e10cSrcweir if ( m_bLog )
423cdf0e10cSrcweir {
424cdf0e10cSrcweir if ( !bDone )
425cdf0e10cSrcweir LogVCL( GetParentID( pWin ), pWin->GetType(), pWin->GetUniqueOrHelpId(), CUniString("Click") );
426cdf0e10cSrcweir }
427cdf0e10cSrcweir }
428cdf0e10cSrcweir break;
429cdf0e10cSrcweir /* case C_MoreButton:
430cdf0e10cSrcweir switch( nEventID )
431cdf0e10cSrcweir {
432cdf0e10cSrcweir case M_IsOpen :
433cdf0e10cSrcweir pRet->GenReturn ( RET_Value, nUId, ((MoreButton*)pControl)->GetState());
434cdf0e10cSrcweir break;
435cdf0e10cSrcweir case M_Click :
436cdf0e10cSrcweir ((MoreButton*)pControl)->Click();
437cdf0e10cSrcweir break;
438cdf0e10cSrcweir case M_Open :
439cdf0e10cSrcweir ((MoreButton*)pControl)->SetState(sal_True);
440cdf0e10cSrcweir break;
441cdf0e10cSrcweir case M_Close :
442cdf0e10cSrcweir ((MoreButton*)pControl)->SetState(sal_False);
443cdf0e10cSrcweir break;
444cdf0e10cSrcweir default:
445cdf0e10cSrcweir ReportError( nUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "MoreButton" ) );
446cdf0e10cSrcweir break;
447cdf0e10cSrcweir }
448cdf0e10cSrcweir break;*/
449cdf0e10cSrcweir case WINDOW_SPINFIELD:
450cdf0e10cSrcweir case WINDOW_PATTERNFIELD:
451cdf0e10cSrcweir case WINDOW_NUMERICFIELD:
452cdf0e10cSrcweir case WINDOW_METRICFIELD:
453cdf0e10cSrcweir case WINDOW_CURRENCYFIELD:
454cdf0e10cSrcweir case WINDOW_DATEFIELD:
455cdf0e10cSrcweir case WINDOW_TIMEFIELD:
456cdf0e10cSrcweir switch( nEventID )
457cdf0e10cSrcweir {
458cdf0e10cSrcweir case VCLEVENT_SPINFIELD_UP:
459cdf0e10cSrcweir case VCLEVENT_SPINFIELD_DOWN:
460cdf0e10cSrcweir case VCLEVENT_SPINFIELD_FIRST:
461cdf0e10cSrcweir case VCLEVENT_SPINFIELD_LAST:
462cdf0e10cSrcweir {
463cdf0e10cSrcweir pEditModify = NULL;
464cdf0e10cSrcweir aEditModifyString.Erase();
465cdf0e10cSrcweir
466cdf0e10cSrcweir comm_USHORT nMethod;
467cdf0e10cSrcweir String aMethod;
468cdf0e10cSrcweir switch ( nEventID )
469cdf0e10cSrcweir {
470cdf0e10cSrcweir case VCLEVENT_SPINFIELD_UP: nMethod = M_More; aMethod = CUniString("More"); break;
471cdf0e10cSrcweir case VCLEVENT_SPINFIELD_DOWN: nMethod = M_Less; aMethod = CUniString("Less"); break;
472cdf0e10cSrcweir case VCLEVENT_SPINFIELD_FIRST: nMethod = M_ToMin; aMethod = CUniString("ToMin"); break;
473cdf0e10cSrcweir case VCLEVENT_SPINFIELD_LAST: nMethod = M_ToMax; aMethod = CUniString("ToMax"); break;
474cdf0e10cSrcweir default: nMethod = M_ToMin; aMethod = CUniString("Unknown");
475cdf0e10cSrcweir DBG_ERROR( "Unknown EventID in Spinfield" );
476cdf0e10cSrcweir }
477cdf0e10cSrcweir if ( m_bRecord )
478cdf0e10cSrcweir {
479cdf0e10cSrcweir StatementList::pRet->GenReturn( RET_MacroRecorder, pWin->GetUniqueOrHelpId(), nMethod );
480cdf0e10cSrcweir bSendData = sal_True;
481cdf0e10cSrcweir }
482cdf0e10cSrcweir if ( m_bLog )
483cdf0e10cSrcweir {
484cdf0e10cSrcweir LogVCL( GetParentID( pWin ), pWin->GetType(), pWin->GetUniqueOrHelpId(), aMethod );
485cdf0e10cSrcweir }
486cdf0e10cSrcweir }
487cdf0e10cSrcweir break;
488cdf0e10cSrcweir case VCLEVENT_EDIT_MODIFY:
489cdf0e10cSrcweir pEditModify = pWin;
490cdf0e10cSrcweir aEditModifyString = ((SpinField*)pWin)->GetText();
491cdf0e10cSrcweir break;
492cdf0e10cSrcweir }
493cdf0e10cSrcweir break;
494cdf0e10cSrcweir
495cdf0e10cSrcweir case WINDOW_MENUBUTTON:
496cdf0e10cSrcweir switch( nEventID )
497cdf0e10cSrcweir {
498cdf0e10cSrcweir case VCLEVENT_BUTTON_CLICK:
499cdf0e10cSrcweir if ( m_bRecord )
500cdf0e10cSrcweir {
501cdf0e10cSrcweir StatementList::pRet->GenReturn( RET_MacroRecorder, pWin->GetUniqueOrHelpId(), (comm_USHORT)M_Click );
502cdf0e10cSrcweir bSendData = sal_True;
503cdf0e10cSrcweir }
504cdf0e10cSrcweir if ( m_bLog )
505cdf0e10cSrcweir {
506cdf0e10cSrcweir LogVCL( GetParentID( pWin ), pWin->GetType(), pWin->GetUniqueOrHelpId(), CUniString("Click") );
507cdf0e10cSrcweir }
508cdf0e10cSrcweir break;
509cdf0e10cSrcweir /* Keyevent or Timeout
510cdf0e10cSrcweir case M_Open :
511cdf0e10cSrcweir {
512cdf0e10cSrcweir MouseEvent aMEvnt;
513cdf0e10cSrcweir Point aPt( pControl->GetSizePixel().Width() / 2, pControl->GetSizePixel().Height() / 2 );
514cdf0e10cSrcweir aMEvnt = MouseEvent( aPt,1,MOUSE_SIMPLECLICK,MOUSE_LEFT );
515cdf0e10cSrcweir ImplMouseButtonDown( pControl, aMEvnt );
516cdf0e10cSrcweir
517cdf0e10cSrcweir sal_uLong nStart = Time::GetSystemTicks();
518cdf0e10cSrcweir sal_uLong nDelay = pControl->GetSettings().GetMouseSettings().GetActionDelay();
519cdf0e10cSrcweir while ( ( Time::GetSystemTicks() - nStart ) < nDelay + 100 )
520cdf0e10cSrcweir SafeReschedule();
521cdf0e10cSrcweir
522cdf0e10cSrcweir ImplMouseButtonUp ( pControl, aMEvnt );
523cdf0e10cSrcweir }
524cdf0e10cSrcweir break;*/
525cdf0e10cSrcweir }
526cdf0e10cSrcweir break;
527cdf0e10cSrcweir case WINDOW_TOOLBOX:
528cdf0e10cSrcweir {
529cdf0e10cSrcweir ToolBox *pTB = ((ToolBox*)pWin);
530cdf0e10cSrcweir switch( nEventID )
531cdf0e10cSrcweir {
532cdf0e10cSrcweir case VCLEVENT_TOOLBOX_SELECT:
533cdf0e10cSrcweir { // a Button has been clicked
534cdf0e10cSrcweir // so this cannot be a tearoff or OpenMenu anymore
535cdf0e10cSrcweir pActionParent = NULL;
536cdf0e10cSrcweir // compare to 1 for floating ToolBoxes
537cdf0e10cSrcweir if ( m_bRecord )
538cdf0e10cSrcweir {
539144e4e62SHerbert Dürr if ( pWin->GetUniqueOrHelpId().isEmpty() /* || pWin->GetUniqueOrHelpId().Matches( 1 ) */ )
540cdf0e10cSrcweir // generate direct Button access
541cdf0e10cSrcweir StatementList::pRet->GenReturn( RET_MacroRecorder, Str2Id( pTB->GetItemCommand( pTB->GetCurItemId() ) ), (comm_USHORT)(M_Click) );
542cdf0e10cSrcweir else
543cdf0e10cSrcweir // access via Toolbox
544cdf0e10cSrcweir StatementList::pRet->GenReturn( RET_MacroRecorder, pTB->GetUniqueOrHelpId(), (comm_USHORT)(M_Click|M_RET_NUM_CONTROL), Id2Str( pTB->GetHelpId( pTB->GetCurItemId() ) ) );
545cdf0e10cSrcweir bSendData = sal_True;
546cdf0e10cSrcweir }
547cdf0e10cSrcweir /* not needed if ( m_bLog )
548cdf0e10cSrcweir {
549cdf0e10cSrcweir }*/
550cdf0e10cSrcweir }
551cdf0e10cSrcweir break;
552cdf0e10cSrcweir case VCLEVENT_TOOLBOX_CLICK: /// ATTENTION this is called during initialisation of toolbox. whoever 'invented' this
553cdf0e10cSrcweir pActionParent = pTB;
554cdf0e10cSrcweir break;
555cdf0e10cSrcweir // case VCLEVENT_WINDOW_SHOW: // not usable ATM. see above
556cdf0e10cSrcweir // if ( pActionParent )
557cdf0e10cSrcweir // { // a new toolbox opens up, might be a tearoff
558cdf0e10cSrcweir // if ( pActionParent != pWin )
559cdf0e10cSrcweir // { // it IS a tearoff not an undock
560cdf0e10cSrcweir // // compare to 1 for floating ToolBoxes
561cdf0e10cSrcweir // if ( m_bRecord )
562cdf0e10cSrcweir // {
563cdf0e10cSrcweir // if ( !pWin->GetSmartUniqueOrHelpId().HasAny() || pWin->GetSmartUniqueOrHelpId().Matches( 1 ) )
564cdf0e10cSrcweir // // generate direct Button access
565cdf0e10cSrcweir // StatementList::pRet->GenReturn( RET_MacroRecorder, rtl::OString( pActionParent->GetHelpId( pActionParent->GetCurItemId() ) ), (comm_USHORT)(M_TearOff) );
566cdf0e10cSrcweir // else
567cdf0e10cSrcweir // // access via Toolbox
568cdf0e10cSrcweir // StatementList::pRet->GenReturn( RET_MacroRecorder, pActionParent->GetSmartUniqueOrHelpId(), (comm_USHORT)(M_TearOff|M_RET_NUM_CONTROL), static_cast<comm_ULONG>(pActionParent->GetHelpId( pActionParent->GetCurItemId() )) ); // GetHelpId() sal_uLong != comm_ULONG on 64bit
569cdf0e10cSrcweir // bSendData = sal_True;
570cdf0e10cSrcweir // }
571cdf0e10cSrcweir // if ( m_bLog )
572cdf0e10cSrcweir // {
573cdf0e10cSrcweir // LogVCL( pActionParent->GetSmartUniqueOrHelpId(), pWin->GetType(), pActionParent->GetHelpId( pActionParent->GetCurItemId() ), CUniString("TearOff") );
574cdf0e10cSrcweir // }
575cdf0e10cSrcweir // }
576cdf0e10cSrcweir // pActionParent = NULL;
577cdf0e10cSrcweir // }
578cdf0e10cSrcweir // break;
579cdf0e10cSrcweir case VCLEVENT_TOOLBOX_DEACTIVATE:
580cdf0e10cSrcweir pActionParent = NULL;
581cdf0e10cSrcweir break;
582cdf0e10cSrcweir }
583cdf0e10cSrcweir }
584cdf0e10cSrcweir break;
585cdf0e10cSrcweir /* ToolBox *pTB = ((ToolBox*)pControl);
586cdf0e10cSrcweir if ( pTB->GetUniqueOrHelpId() != nUId ) // Also Button auf der ToolBox gefunden
587cdf0e10cSrcweir {
588cdf0e10cSrcweir if ( nParams == PARAM_NONE )
589cdf0e10cSrcweir { // Wir f�lschen einen Parameter
590cdf0e10cSrcweir nParams = PARAM_USHORT_1;
591cdf0e10cSrcweir nNr1 = nUId;
592cdf0e10cSrcweir }
593cdf0e10cSrcweir else
594cdf0e10cSrcweir ReportError( nUId, GEN_RES_STR1( S_INTERNAL_ERROR, MethodString( nMethodId ) ) );
595cdf0e10cSrcweir }
596cdf0e10cSrcweir
597cdf0e10cSrcweir #define FIND_HELP\
598cdf0e10cSrcweir {\
599cdf0e10cSrcweir if( nParams == PARAM_USHORT_1 )\
600cdf0e10cSrcweir nLNr1 = nNr1;\
601cdf0e10cSrcweir for ( nNr1 = 0; nNr1 < pTB->GetItemCount() && nLNr1 != pTB->GetHelpId(pTB->GetItemId(nNr1)) ; nNr1++ ) {}\
602cdf0e10cSrcweir bBool1 = nLNr1 == pTB->GetHelpId(pTB->GetItemId(nNr1));\
603cdf0e10cSrcweir if ( !bBool1 )\
604cdf0e10cSrcweir ReportError( nUId, GEN_RES_STR1( S_HELPID_ON_TOOLBOX_NOT_FOUND, MethodString( nMethodId ) ) );\
605cdf0e10cSrcweir else\
606cdf0e10cSrcweir {\
607cdf0e10cSrcweir if ( !pTB->IsItemEnabled( pTB->GetItemId(nNr1) ) && nMethodId != _M_IsEnabled )\
608cdf0e10cSrcweir {\
609cdf0e10cSrcweir ReportError( nUId, GEN_RES_STR1( S_BUTTON_DISABLED_ON_TOOLBOX, MethodString( nMethodId ) ) );\
610cdf0e10cSrcweir bBool1 = sal_False;\
611cdf0e10cSrcweir }\
612cdf0e10cSrcweir else if ( !pTB->IsItemVisible( pTB->GetItemId(nNr1) ) )\
613cdf0e10cSrcweir {\
614cdf0e10cSrcweir ReportError( nUId, GEN_RES_STR1( S_BUTTON_HIDDEN_ON_TOOLBOX, MethodString( nMethodId ) ) );\
615cdf0e10cSrcweir bBool1 = sal_False;\
616cdf0e10cSrcweir }\
617cdf0e10cSrcweir else\
618cdf0e10cSrcweir {\
619cdf0e10cSrcweir if ( pTB->GetItemRect(pTB->GetItemId(nNr1)).IsEmpty() )\
620cdf0e10cSrcweir {\
621cdf0e10cSrcweir sal_uInt16 nLine = pTB->GetCurLine();\
622cdf0e10cSrcweir do\
623cdf0e10cSrcweir {\
624cdf0e10cSrcweir pTB->ShowLine( sal_False );\
625cdf0e10cSrcweir for ( int i = 1 ; i < 30 ; i++ )\
626cdf0e10cSrcweir SafeReschedule();\
627cdf0e10cSrcweir }\
628cdf0e10cSrcweir while ( pTB->GetCurLine() != nLine && pTB->GetItemRect(pTB->GetItemId(nNr1)).IsEmpty() );\
629cdf0e10cSrcweir pTB->Invalidate( pTB->GetScrollRect() );\
630cdf0e10cSrcweir }\
631cdf0e10cSrcweir if ( pTB->GetItemRect(pTB->GetItemId(nNr1)).IsEmpty() )\
632cdf0e10cSrcweir {\
633cdf0e10cSrcweir ReportError( nUId, GEN_RES_STR1( S_CANNOT_MAKE_BUTTON_VISIBLE_IN_TOOLBOX, MethodString( nMethodId ) ) );\
634cdf0e10cSrcweir bBool1 = sal_False;\
635cdf0e10cSrcweir }\
636cdf0e10cSrcweir }\
637cdf0e10cSrcweir }\
638cdf0e10cSrcweir }\
639cdf0e10cSrcweir
640cdf0e10cSrcweir switch( nEventID )
641cdf0e10cSrcweir {
642cdf0e10cSrcweir case M_SetNextToolBox :
643cdf0e10cSrcweir if ( (nParams & PARAM_STR_1) )
644cdf0e10cSrcweir pTB->SetNextToolBox( aString1 );
645cdf0e10cSrcweir else
646cdf0e10cSrcweir pTB->SetNextToolBox( pTB->GetNextToolBox() );
647cdf0e10cSrcweir pTB->NextToolBox();
648cdf0e10cSrcweir break;
649cdf0e10cSrcweir case M_GetNextToolBox :
650cdf0e10cSrcweir pRet->GenReturn ( RET_Value, nUId, (String)pTB->GetNextToolBox());
651cdf0e10cSrcweir break;
652cdf0e10cSrcweir default:
653cdf0e10cSrcweir ReportError( nUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "ToolBox" ) );
654cdf0e10cSrcweir break;
655cdf0e10cSrcweir }
656cdf0e10cSrcweir }
657cdf0e10cSrcweir break;
658cdf0e10cSrcweir */
659cdf0e10cSrcweir case WINDOW_CONTROL:
660cdf0e10cSrcweir case WINDOW_WINDOW:
661cdf0e10cSrcweir switch( nEventID )
662cdf0e10cSrcweir {
663cdf0e10cSrcweir case VCLEVENT_WINDOW_COMMAND:
664cdf0e10cSrcweir break;
665cdf0e10cSrcweir case VCLEVENT_WINDOW_KEYINPUT:
666cdf0e10cSrcweir {
667cdf0e10cSrcweir const KeyEvent *pKeyEvent = ((KeyEvent*)pWinEvent->GetData());
668cdf0e10cSrcweir const KeyCode aKeyCode = pKeyEvent->GetKeyCode();
669cdf0e10cSrcweir if ( pKeyEvent )
670cdf0e10cSrcweir {
671cdf0e10cSrcweir pKeyWin = pWin;
672cdf0e10cSrcweir Window *pIdWin = GetParentWithID( pWin );
673cdf0e10cSrcweir if ( pIdWin != pWin )
674cdf0e10cSrcweir bKeyFollowFocus = sal_True;
675cdf0e10cSrcweir aKeyUniqueID = pIdWin->GetUniqueOrHelpId();
676cdf0e10cSrcweir if ( m_bLog )
677cdf0e10cSrcweir {
678cdf0e10cSrcweir // HACK Too many KeyEvents generated if ( aKeyString.Len() == 0 )
679cdf0e10cSrcweir // HACK Too many KeyEvents generated LogVCL( rtl::OString(), 0, aKeyUniqueID, CUniString("TypeKeysStart") );
680cdf0e10cSrcweir }
681cdf0e10cSrcweir if ( ( !aKeyCode.IsMod1() && !aKeyCode.IsMod2() ) &&
682cdf0e10cSrcweir (( aKeyCode.GetGroup() == KEYGROUP_NUM) ||
683cdf0e10cSrcweir ( aKeyCode.GetGroup() == KEYGROUP_ALPHA) ||
684cdf0e10cSrcweir ( aKeyCode.GetCode() == KEY_SPACE) ||
685cdf0e10cSrcweir ( aKeyCode.GetCode() == KEY_ADD) ||
686cdf0e10cSrcweir ( aKeyCode.GetCode() == KEY_SUBTRACT) ||
687cdf0e10cSrcweir ( aKeyCode.GetCode() == KEY_MULTIPLY) ||
688cdf0e10cSrcweir ( aKeyCode.GetCode() == KEY_DIVIDE) ||
689cdf0e10cSrcweir ( aKeyCode.GetCode() == KEY_POINT) ||
690cdf0e10cSrcweir ( aKeyCode.GetCode() == KEY_COMMA) ||
691cdf0e10cSrcweir ( aKeyCode.GetCode() == KEY_EQUAL) ||
692cdf0e10cSrcweir ( aKeyCode.GetCode() == 0) ) )
693cdf0e10cSrcweir {
694cdf0e10cSrcweir DBG_ASSERT( pKeyEvent->GetCharCode(), "no charcode found" );
695cdf0e10cSrcweir aKeyString += pKeyEvent->GetCharCode();
696cdf0e10cSrcweir }
697cdf0e10cSrcweir else
698cdf0e10cSrcweir { // not a regular key, transfer KeyCode
699cdf0e10cSrcweir aKeyString += sal_Unicode(1); // mask it
700cdf0e10cSrcweir // extra for '>' which is coded as <SHIFT GREATER>
701cdf0e10cSrcweir if ( pKeyEvent->GetCharCode() == '>' )
702cdf0e10cSrcweir aKeyString += sal_Unicode( KEY_GREATER | (aKeyCode.GetAllModifier() & ~KEY_SHIFT) );
703cdf0e10cSrcweir else
704cdf0e10cSrcweir aKeyString += sal_Unicode( aKeyCode.GetCode() | aKeyCode.GetAllModifier() );
705cdf0e10cSrcweir }
706cdf0e10cSrcweir }
707cdf0e10cSrcweir }
708cdf0e10cSrcweir break;
709cdf0e10cSrcweir
710cdf0e10cSrcweir case VCLEVENT_WINDOW_MOUSEMOVE:
711cdf0e10cSrcweir case VCLEVENT_WINDOW_MOUSEBUTTONDOWN:
712cdf0e10cSrcweir case VCLEVENT_WINDOW_MOUSEBUTTONUP:
713cdf0e10cSrcweir {
714cdf0e10cSrcweir }
715cdf0e10cSrcweir break;
716cdf0e10cSrcweir
717cdf0e10cSrcweir
718cdf0e10cSrcweir }
719cdf0e10cSrcweir break;
720cdf0e10cSrcweir case WINDOW_DOCKINGWINDOW:
721cdf0e10cSrcweir // switch( nEventID )
722cdf0e10cSrcweir {
723cdf0e10cSrcweir // case 1 .. 0xffff:
724cdf0e10cSrcweir DBG_TRACE3( "TT_VCLMessage %u %u %X",nEventID, pWin->GetType(), pWin );
725cdf0e10cSrcweir // sal_Bool bx = ((DockingWindow*)pWin)->IsFloatingMode();
726cdf0e10cSrcweir // break;
727cdf0e10cSrcweir /* case M_Dock :
728cdf0e10cSrcweir if ( ((DockingWindow*)pControl)->IsFloatingMode() )
729cdf0e10cSrcweir ((DockingWindow*)pControl)->SetFloatingMode(sal_False);
730cdf0e10cSrcweir else
731cdf0e10cSrcweir ReportError( nUId, GEN_RES_STR1( S_ALLOWED_ONLY_IN_FLOATING_MODE, MethodString( nMethodId ) ) );
732cdf0e10cSrcweir break;
733cdf0e10cSrcweir case M_Undock :
734cdf0e10cSrcweir if ( !((DockingWindow*)pControl)->IsFloatingMode() )
735cdf0e10cSrcweir ((DockingWindow*)pControl)->SetFloatingMode(sal_True);
736cdf0e10cSrcweir else
737cdf0e10cSrcweir ReportError( nUId, GEN_RES_STR1( S_ALLOWED_ONLY_IN_FLOATING_MODE, MethodString( nMethodId ) ) );
738cdf0e10cSrcweir break;
739cdf0e10cSrcweir case M_IsDocked :
740cdf0e10cSrcweir pRet->GenReturn ( RET_Value, nUId, (comm_BOOL) !((DockingWindow*)pControl)->IsFloatingMode());
741cdf0e10cSrcweir break;
742cdf0e10cSrcweir case M_Close:
743cdf0e10cSrcweir //nWindowWaitUId = nUId;
744cdf0e10cSrcweir DBG_ASSERT( nUId == pControl->GetUniqueOrHelpId(), "nUID != UniqueOrHelpId");
745cdf0e10cSrcweir SET_WINP_CLOSING(pControl);
746cdf0e10cSrcweir ((DockingWindow*)pControl)->Close();
747cdf0e10cSrcweir break;
748cdf0e10cSrcweir case M_Size:
749cdf0e10cSrcweir case M_Move:
750cdf0e10cSrcweir case M_IsMax :
751cdf0e10cSrcweir case M_Minimize :
752cdf0e10cSrcweir case M_Maximize :
753cdf0e10cSrcweir if ( ((DockingWindow*)pControl)->IsFloatingMode() )
754cdf0e10cSrcweir {
755cdf0e10cSrcweir pControl = ((DockingWindow*)pControl)->GetFloatingWindow();
756cdf0e10cSrcweir goto FloatWin;
757cdf0e10cSrcweir }
758cdf0e10cSrcweir else
759cdf0e10cSrcweir ReportError( nUId, GEN_RES_STR1( S_ALLOWED_ONLY_IN_DOCKING_MODE, MethodString( nMethodId ) ) );
760cdf0e10cSrcweir break;
761cdf0e10cSrcweir case M_Help: // Alles was unten weiterbehandelt werden soll
762cdf0e10cSrcweir goto MoreDialog;
763cdf0e10cSrcweir
764cdf0e10cSrcweir default:
765cdf0e10cSrcweir ReportError( nUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "DockingWindow" ) );
766cdf0e10cSrcweir break;*/
767cdf0e10cSrcweir }
768cdf0e10cSrcweir break;
769cdf0e10cSrcweir
770cdf0e10cSrcweir
771cdf0e10cSrcweir
772cdf0e10cSrcweir
773cdf0e10cSrcweir
774cdf0e10cSrcweir
775cdf0e10cSrcweir case WINDOW_FLOATINGWINDOW:
776cdf0e10cSrcweir {
777cdf0e10cSrcweir DBG_TRACE3( "TT_VCLMessage %u %u %X",nEventID, pWin->GetType(), pWin );
778cdf0e10cSrcweir // FloatingWindow *pFW = ((FloatingWindow*)pWin);
779cdf0e10cSrcweir /* switch( nEventID )
780cdf0e10cSrcweir {
781cdf0e10cSrcweir
782cdf0e10cSrcweir // M_OpenMenu an einem ToolboxButton
783cdf0e10cSrcweir case VCLEVENT_WINDOW_SHOW:
784cdf0e10cSrcweir if ( pActionParent )
785cdf0e10cSrcweir { // a new FloatingWindow opens up, so we assume an OpenMenu
786cdf0e10cSrcweir // compare to 1 for floating ToolBoxes
787cdf0e10cSrcweir if ( ( pActionParent->GetUniqueOrHelpId() == 0 || pActionParent->GetUniqueOrHelpId() == 1 ) )
788cdf0e10cSrcweir // generate direct Button access
789cdf0e10cSrcweir StatementList::pRet->GenReturn( RET_MacroRecorder, pActionParent->GetHelpId( pActionParent->GetCurItemId() ), (comm_USHORT)(M_OpenMenu) );
790cdf0e10cSrcweir else
791cdf0e10cSrcweir // access via Toolbox
792cdf0e10cSrcweir StatementList::pRet->GenReturn( RET_MacroRecorder, pActionParent->GetUniqueOrHelpId(), (comm_USHORT)(M_OpenMenu|M_RET_NUM_CONTROL), pActionParent->GetHelpId( pActionParent->GetCurItemId() ) );
793cdf0e10cSrcweir bSendData = sal_True;
794cdf0e10cSrcweir }
795cdf0e10cSrcweir break;
796cdf0e10cSrcweir
797cdf0e10cSrcweir }
798cdf0e10cSrcweir */ }
799cdf0e10cSrcweir break;
800cdf0e10cSrcweir /*
801cdf0e10cSrcweir case M_AnimateMouse :
802cdf0e10cSrcweir AnimateMouse( pControl, MitteOben);
803cdf0e10cSrcweir break;
804cdf0e10cSrcweir case M_IsMax :
805cdf0e10cSrcweir pRet->GenReturn ( RET_Value, nUId, (comm_BOOL)!((FloatingWindow*)pControl)->IsRollUp());
806cdf0e10cSrcweir break;
807cdf0e10cSrcweir case M_Minimize :
808cdf0e10cSrcweir ((FloatingWindow*)pControl)->RollUp();
809cdf0e10cSrcweir break;
810cdf0e10cSrcweir case M_Maximize :
811cdf0e10cSrcweir ((FloatingWindow*)pControl)->RollDown();
812cdf0e10cSrcweir break;
813cdf0e10cSrcweir case M_Size:
814cdf0e10cSrcweir {
815cdf0e10cSrcweir if ( pControl->GetStyle() & WB_SIZEABLE )
816cdf0e10cSrcweir {
817cdf0e10cSrcweir pControl->SetSizePixel(Size(nNr1,nNr2));
818cdf0e10cSrcweir pControl->Resize();
819cdf0e10cSrcweir }
820cdf0e10cSrcweir else
821cdf0e10cSrcweir ReportError( nUId, GEN_RES_STR1( S_SIZE_NOT_CHANGEABLE, MethodString( nMethodId ) ) );
822cdf0e10cSrcweir break;
823cdf0e10cSrcweir }
824cdf0e10cSrcweir case M_Close:
825cdf0e10cSrcweir DBG_ASSERT( nUId == pControl->GetUniqueOrHelpId(), "nUID != UniqueOrHelpId");
826cdf0e10cSrcweir SET_WINP_CLOSING(pControl);
827cdf0e10cSrcweir ((FloatingWindow*)pControl)->Close();
828cdf0e10cSrcweir break;
829cdf0e10cSrcweir case M_Help: // Alles was unten weiterbehandelt werden soll
830cdf0e10cSrcweir case M_Move:
831cdf0e10cSrcweir goto MoreDialog;
832cdf0e10cSrcweir default:
833cdf0e10cSrcweir ReportError( nUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "FloatingWin" ) );
834cdf0e10cSrcweir break;
835cdf0e10cSrcweir }
836cdf0e10cSrcweir break;*/
837cdf0e10cSrcweir
838cdf0e10cSrcweir
839cdf0e10cSrcweir
840cdf0e10cSrcweir
841cdf0e10cSrcweir
842cdf0e10cSrcweir
843cdf0e10cSrcweir
844cdf0e10cSrcweir
845cdf0e10cSrcweir /*
846cdf0e10cSrcweir case C_ModelessDlg:
847cdf0e10cSrcweir case C_Dlg:
848cdf0e10cSrcweir case C_TabDlg:
849cdf0e10cSrcweir MoreDialog:
850cdf0e10cSrcweir switch( nEventID )
851cdf0e10cSrcweir {
852cdf0e10cSrcweir
853cdf0e10cSrcweir // (Rect GetRect)
854cdf0e10cSrcweir
855cdf0e10cSrcweir case M_AnimateMouse :
856cdf0e10cSrcweir AnimateMouse( pControl, MitteOben);
857cdf0e10cSrcweir break;
858cdf0e10cSrcweir case M_Close:
859cdf0e10cSrcweir DBG_ASSERT( nUId == pControl->GetUniqueOrHelpId(), "nUID != UniqueOrHelpId");
860cdf0e10cSrcweir SET_WINP_CLOSING(pControl);
861cdf0e10cSrcweir ((SystemWindow*)pControl)->Close();
862cdf0e10cSrcweir break;
863cdf0e10cSrcweir case M_Move:
864cdf0e10cSrcweir {
865cdf0e10cSrcweir pControl->SetPosPixel(Point(nNr1,nNr2));
866cdf0e10cSrcweir break;
867cdf0e10cSrcweir }
868cdf0e10cSrcweir default:
869cdf0e10cSrcweir ReportError( nUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "Dialog" ) );
870cdf0e10cSrcweir break;
871cdf0e10cSrcweir }
872cdf0e10cSrcweir break;*/
873cdf0e10cSrcweir
874cdf0e10cSrcweir
875cdf0e10cSrcweir
876cdf0e10cSrcweir
877cdf0e10cSrcweir
878cdf0e10cSrcweir
879cdf0e10cSrcweir
880cdf0e10cSrcweir
881cdf0e10cSrcweir
882cdf0e10cSrcweir
883cdf0e10cSrcweir
884cdf0e10cSrcweir
885cdf0e10cSrcweir
886cdf0e10cSrcweir /*
887cdf0e10cSrcweir case C_WorkWin:
888cdf0e10cSrcweir switch( nEventID )
889cdf0e10cSrcweir {
890cdf0e10cSrcweir case M_Close:
891cdf0e10cSrcweir DBG_ASSERT( nUId == pControl->GetUniqueOrHelpId(), "nUID != UniqueOrHelpId");
892cdf0e10cSrcweir SET_WINP_CLOSING(pControl);
893cdf0e10cSrcweir ((WorkWindow*)pControl)->Close();
894cdf0e10cSrcweir break;
895cdf0e10cSrcweir case M_Size:
896cdf0e10cSrcweir case M_Move:
897cdf0e10cSrcweir goto FloatWin;
898cdf0e10cSrcweir break;
899cdf0e10cSrcweir case M_Help: // Alles was unten weiterbehandelt werden soll
900cdf0e10cSrcweir goto MoreDialog;
901cdf0e10cSrcweir default:
902cdf0e10cSrcweir ReportError( nUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "WorkWindow" ) );
903cdf0e10cSrcweir break;
904cdf0e10cSrcweir }
905cdf0e10cSrcweir break;
906cdf0e10cSrcweir */
907cdf0e10cSrcweir
908cdf0e10cSrcweir
909cdf0e10cSrcweir /* case C_TabPage:
910cdf0e10cSrcweir switch( nEventID )
911cdf0e10cSrcweir {
912cdf0e10cSrcweir }
913cdf0e10cSrcweir break;*/
914cdf0e10cSrcweir
915cdf0e10cSrcweir
916cdf0e10cSrcweir
917cdf0e10cSrcweir
918cdf0e10cSrcweir
919cdf0e10cSrcweir
920cdf0e10cSrcweir
921cdf0e10cSrcweir
922cdf0e10cSrcweir
923cdf0e10cSrcweir
924cdf0e10cSrcweir
925cdf0e10cSrcweir
926cdf0e10cSrcweir
927cdf0e10cSrcweir /*
928cdf0e10cSrcweir case C_MessBox:
929cdf0e10cSrcweir case C_InfoBox:
930cdf0e10cSrcweir case C_WarningBox:
931cdf0e10cSrcweir case C_ErrorBox:
932cdf0e10cSrcweir case C_QueryBox:
933cdf0e10cSrcweir {
934cdf0e10cSrcweir sal_Bool bDone = sal_True;
935cdf0e10cSrcweir MessBox* pMB = (MessBox*)pControl;
936cdf0e10cSrcweir switch( nEventID )
937cdf0e10cSrcweir {
938cdf0e10cSrcweir case M_GetCheckBoxText:
939cdf0e10cSrcweir pRet->GenReturn ( RET_Value, nUId, pMB->GetCheckBoxText() );
940cdf0e10cSrcweir break;
941cdf0e10cSrcweir case M_IsChecked :
942cdf0e10cSrcweir pRet->GenReturn ( RET_Value, nUId, comm_BOOL( pMB->GetCheckBoxState() == STATE_CHECK) );
943cdf0e10cSrcweir break;
944cdf0e10cSrcweir case M_GetState :
945cdf0e10cSrcweir pRet->GenReturn ( RET_Value, nUId, comm_ULONG( pMB->GetCheckBoxState() ));
946cdf0e10cSrcweir break;
947cdf0e10cSrcweir case M_Check :
948cdf0e10cSrcweir pMB->SetCheckBoxState( STATE_CHECK );
949cdf0e10cSrcweir break;
950cdf0e10cSrcweir case M_UnCheck :
951cdf0e10cSrcweir pMB->SetCheckBoxState( STATE_NOCHECK );
952cdf0e10cSrcweir break;
953cdf0e10cSrcweir case M_GetText :
954cdf0e10cSrcweir pRet->GenReturn ( RET_Value, nUId, pMB->GetMessText());
955cdf0e10cSrcweir break;
956cdf0e10cSrcweir
957cdf0e10cSrcweir default:
958cdf0e10cSrcweir bDone = sal_False;
959cdf0e10cSrcweir break;
960cdf0e10cSrcweir }
961cdf0e10cSrcweir if ( bDone )
962cdf0e10cSrcweir break; // break the case here else continue at C_ButtonDialog
963cdf0e10cSrcweir }
964cdf0e10cSrcweir case C_ButtonDialog:
965cdf0e10cSrcweir {
966cdf0e10cSrcweir ButtonDialog* pBD = (ButtonDialog*)pControl;
967cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
968cdf0e10cSrcweir m_pDbgWin->AddText( "Working MessBox: " );
969cdf0e10cSrcweir if (pControl->IsVisible())
970cdf0e10cSrcweir m_pDbgWin->AddText("*(Visible)\n");
971cdf0e10cSrcweir else
972cdf0e10cSrcweir m_pDbgWin->AddText("*(nicht Visible)\n");
973cdf0e10cSrcweir #endif
974cdf0e10cSrcweir switch( nEventID )
975cdf0e10cSrcweir {
976cdf0e10cSrcweir case M_GetText :
977cdf0e10cSrcweir pRet->GenReturn ( RET_Value, nUId, pControl->GetText());
978cdf0e10cSrcweir break;
979cdf0e10cSrcweir case M_Click:
980cdf0e10cSrcweir if ( nParams & PARAM_USHORT_1 )
981cdf0e10cSrcweir {
982cdf0e10cSrcweir if ( pBD->GetPushButton( nNr1 ) )
983cdf0e10cSrcweir {
984cdf0e10cSrcweir if ( nNr1 != BUTTONID_HELP )
985cdf0e10cSrcweir {
986cdf0e10cSrcweir SET_WINP_CLOSING(pControl);
987cdf0e10cSrcweir }
988cdf0e10cSrcweir pBD->GetPushButton( nNr1 )->Click();
989cdf0e10cSrcweir }
990cdf0e10cSrcweir else
991cdf0e10cSrcweir ReportError( nUId, GEN_RES_STR2( S_NO_DEFAULT_BUTTON, UniString::CreateFromInt32( nNr1 ), MethodString( nMethodId ) ) );
992cdf0e10cSrcweir }
993cdf0e10cSrcweir else
994cdf0e10cSrcweir ReportError( nUId, GEN_RES_STR1( S_BUTTONID_REQUIRED, MethodString( nMethodId ) ) );
995cdf0e10cSrcweir break;
996cdf0e10cSrcweir case M_GetButtonCount :
997cdf0e10cSrcweir pRet->GenReturn ( RET_Value, nUId, comm_ULONG(pBD->GetButtonCount()));
998cdf0e10cSrcweir break;
999cdf0e10cSrcweir case M_GetButtonId :
1000cdf0e10cSrcweir if ( ValueOK(nUId, MethodString( nMethodId ),nNr1,pBD->GetButtonCount()) )
1001cdf0e10cSrcweir pRet->GenReturn ( RET_Value, nUId, comm_ULONG(pBD->GetButtonId(nNr1-1)));
1002cdf0e10cSrcweir break;
1003cdf0e10cSrcweir default:
1004cdf0e10cSrcweir ReportError( nUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "MessageBox" ) );
1005cdf0e10cSrcweir break;
1006cdf0e10cSrcweir }
1007cdf0e10cSrcweir break;
1008cdf0e10cSrcweir
1009cdf0e10cSrcweir
1010cdf0e10cSrcweir */
1011cdf0e10cSrcweir
1012cdf0e10cSrcweir
1013cdf0e10cSrcweir }
1014cdf0e10cSrcweir
1015cdf0e10cSrcweir
1016cdf0e10cSrcweir switch( nEventID )
1017cdf0e10cSrcweir {
1018cdf0e10cSrcweir case VCLEVENT_CONTROL_LOSEFOCUS:
1019cdf0e10cSrcweir if ( pEditModify == pWin )
1020cdf0e10cSrcweir {
1021cdf0e10cSrcweir if ( m_bRecord )
1022cdf0e10cSrcweir {
1023cdf0e10cSrcweir StatementList::pRet->GenReturn( RET_MacroRecorder, pWin->GetUniqueOrHelpId(), M_SetText, aEditModifyString );
1024cdf0e10cSrcweir bSendData = sal_True;
1025cdf0e10cSrcweir }
1026cdf0e10cSrcweir if ( m_bLog )
1027cdf0e10cSrcweir {
1028cdf0e10cSrcweir LogVCL( GetParentID( pWin ), pWin->GetType(), pWin->GetUniqueOrHelpId(), CUniString("Modify") );
1029cdf0e10cSrcweir }
1030cdf0e10cSrcweir pEditModify = NULL;
1031cdf0e10cSrcweir aEditModifyString.Erase(); //could be somewhat lengthy
1032cdf0e10cSrcweir }
1033cdf0e10cSrcweir break;
1034cdf0e10cSrcweir }
1035cdf0e10cSrcweir
1036cdf0e10cSrcweir pLastWin = pWin;
1037cdf0e10cSrcweir
1038cdf0e10cSrcweir } // if
1039cdf0e10cSrcweir else if ( pEvent->ISA( VclMenuEvent ) )
1040cdf0e10cSrcweir {
1041cdf0e10cSrcweir // VclMenuEvent* pMenuEvent = ( VclMenuEvent* ) pEvent;
1042cdf0e10cSrcweir }
1043cdf0e10cSrcweir
1044cdf0e10cSrcweir
1045cdf0e10cSrcweir if ( bSendData )
1046cdf0e10cSrcweir new StatementFlow( NULL, F_EndCommandBlock ); // Kommando zum Senden erzeugen und in que eintragen
1047cdf0e10cSrcweir
1048cdf0e10cSrcweir return 0;
1049cdf0e10cSrcweir }
1050cdf0e10cSrcweir
1051cdf0e10cSrcweir
1052cdf0e10cSrcweir
getRecorderMutex()1053cdf0e10cSrcweir static ::osl::Mutex * getRecorderMutex()
1054cdf0e10cSrcweir {
1055cdf0e10cSrcweir static ::osl::Mutex * pMutex = NULL;
1056cdf0e10cSrcweir if(pMutex==NULL)
1057cdf0e10cSrcweir {
1058cdf0e10cSrcweir ::osl::MutexGuard aGuard(::osl::Mutex::getGlobalMutex());
1059cdf0e10cSrcweir if(pMutex==NULL)
1060cdf0e10cSrcweir pMutex = new ::osl::Mutex();
1061cdf0e10cSrcweir }
1062cdf0e10cSrcweir return pMutex;
1063cdf0e10cSrcweir }
1064cdf0e10cSrcweir
1065cdf0e10cSrcweir
CheckDelete()1066cdf0e10cSrcweir void MacroRecorder::CheckDelete()
1067cdf0e10cSrcweir {
1068cdf0e10cSrcweir ::osl::MutexGuard aGuard( getRecorderMutex() );
1069cdf0e10cSrcweir if ( !m_bRecord && !m_bLog )
1070cdf0e10cSrcweir {
1071cdf0e10cSrcweir pMacroRecorder = NULL;
1072cdf0e10cSrcweir delete this;
1073cdf0e10cSrcweir }
1074cdf0e10cSrcweir }
1075cdf0e10cSrcweir
1076cdf0e10cSrcweir
GetMacroRecorder()1077cdf0e10cSrcweir MacroRecorder* MacroRecorder::GetMacroRecorder()
1078cdf0e10cSrcweir {
1079cdf0e10cSrcweir ::osl::MutexGuard aGuard( getRecorderMutex() );
1080cdf0e10cSrcweir if ( !pMacroRecorder )
1081cdf0e10cSrcweir pMacroRecorder = new MacroRecorder;
1082cdf0e10cSrcweir
1083cdf0e10cSrcweir return pMacroRecorder;
1084cdf0e10cSrcweir }
1085cdf0e10cSrcweir
HasMacroRecorder()1086cdf0e10cSrcweir sal_Bool MacroRecorder::HasMacroRecorder()
1087cdf0e10cSrcweir {
1088cdf0e10cSrcweir ::osl::MutexGuard aGuard( getRecorderMutex() );
1089cdf0e10cSrcweir return pMacroRecorder != NULL;
1090cdf0e10cSrcweir }
1091cdf0e10cSrcweir
1092