1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #include <tools/string.hxx>
29 #include <tools/link.hxx>
30 #include <vcl/timer.hxx>
31 
32 class ToolBox;
33 class Window;
34 class VclSimpleEvent;
35 
36 class MacroRecorder
37 {
38 private:
39     Window* GetParentWithID( Window* pThis );
40     rtl::OString GetParentID( Window* pThis );
41 
42     Link aEventListenerHdl;
43     DECL_LINK( EventListener, VclSimpleEvent* );
44 
45     Window* pLastWin;
46     Window* pEditModify;
47     String aEditModifyString;
48 
49     ToolBox *pActionParent;      // toolbox from which a tearoff or OpenMenu might happen
50 
51     // record keys
52     String aKeyString;
53     rtl::OString aKeyUniqueID;     // has to be remembered seperately since Window might be gone when needed
54     Window* pKeyWin;
55     sal_Bool bKeyFollowFocus;
56 
57     AutoTimer aHookRefresh;
58     void AddEventHooks();
59     void RemoveEventHooks();
60     DECL_LINK( HookRefreshHdl, void* );
61 
62     void LogVCL( rtl::OString aParentID, sal_uInt16 nVCLWindowType, rtl::OString aID, String aMethod, sal_uInt16 aParam );
63     void LogVCL( rtl::OString aParentID, sal_uInt16 nVCLWindowType, rtl::OString aID, String aMethod );
64 
65     static MacroRecorder *pMacroRecorder;
66 
67     MacroRecorder();
68     ~MacroRecorder();
69     void CheckDelete();
70 
71 	// Actions to perform
72 	sal_Bool m_bRecord;
73 	sal_Bool m_bLog;
74 
75 public:
76 
77     void SetActionRecord( sal_Bool bRecord = sal_True ) { m_bRecord = bRecord; CheckDelete(); };
78     void SetActionLog( sal_Bool bLog = sal_True ) { m_bLog = bLog; CheckDelete(); };
79 
80     static MacroRecorder* GetMacroRecorder();
81     static sal_Bool HasMacroRecorder();
82 };
83 
84