update dev300-m58
[ooovba.git] / automation / source / server / statemnt.hxx
blob1b06abc2c75038e5a9075e54ecce75f38ccae604
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.hxx,v $
10 * $Revision: 1.23 $
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 ************************************************************************/
30 /***************************************************************************
32 ** Von StatementList werden alle Statements abgeleitet.
33 ** Es gibt immer nur eine Statementliste, die verpointert ist.
34 ** jederzeit kann das der Anfang der Kette abgefragt werden.
42 ***************************************************************************/
43 #ifndef _STATEMNT_HXX
44 #define _STATEMNT_HXX
46 #include <vcl/wintypes.hxx>
47 #include <tools/string.hxx>
48 #include <tools/debug.hxx>
49 #include <tools/time.hxx>
50 #ifndef _SV_DRAG_HXX //autogen
51 //#include <vcl/drag.hxx>
52 #endif
53 #include <vcl/menu.hxx>
54 #include <vcl/svapp.hxx>
55 #include <tools/fsys.hxx>
56 #include <sot/storage.hxx>
57 #include <basic/sbstar.hxx>
58 #include <vcl/event.hxx>
59 #include <com/sun/star/beans/PropertyValue.hpp>
60 #include <vcl/smartid.hxx>
61 #include <automation/commtypes.hxx>
63 class Window;
64 class SystemWindow;
65 class Point;
66 class SfxPoolItem;
68 class ScrollBar;
70 class SCmdStream;
71 class RetStream;
72 class ImplRemoteControl;
74 class TTProfiler;
75 class TTProperties;
77 class Dir;
79 class CommunicationLink;
81 #if OSL_DEBUG_LEVEL > 1
82 class EditWindow;
83 #endif
85 #ifdef __cplusplus
86 extern "C"
88 #endif
89 void SAL_CALL osl_TestToolDebugPrint( const sal_Char *pString );
90 #ifdef __cplusplus
92 #endif
95 #define IsVisible IsReallyVisible
96 #define GET_REAL_PARENT() GetWindow( WINDOW_REALPARENT )
98 // switch behaviour of ImplMouse* and ImplKeyInput
99 #define FORCE_DIRECT_CALL TRUE
101 typedef USHORT SearchFlags;
102 #define SEARCH_NOOVERLAP ((SearchFlags) 0x0001)
103 #define SEARCH_NO_TOPLEVEL_WIN ((SearchFlags) 0x0002)
104 #define SEARCH_FOCUS_FIRST ((SearchFlags) 0x0004)
105 #define SEARCH_FIND_DISABLED ((SearchFlags) 0x0008)
107 class Search
109 SearchFlags nmSearchFlags;
110 public:
111 Search( SearchFlags nSearchFlags = 0): nmSearchFlags(nSearchFlags) {}
112 virtual ~Search() {}
114 virtual BOOL IsWinOK( Window *pWin ) = 0;
115 SearchFlags GetSearchFlags() { return nmSearchFlags; }
116 void AddSearchFlags( SearchFlags aNewFlags ) { nmSearchFlags |= aNewFlags; }
117 void RemoveSearchFlags( SearchFlags aRemoveFlags ) { nmSearchFlags &= ( ~aRemoveFlags ); }
118 BOOL HasSearchFlag( SearchFlags aQueryFlag ) { return (nmSearchFlags & aQueryFlag) == aQueryFlag; }
121 BOOL IsDialog(Window *pWin); // Ist *pWin von SystemWindow abgeleitet (Kann es Active sein)
122 BOOL IsAccessable(Window *pWin); // Ist *pWin Zugreifbar (über IsEnabled und Parents geprüft)
125 //class SafePointer : CriticalSection
126 class SafePointer
128 SafePointer *pSelf;
129 public:
130 SafePointer() { pSelf = this; }
131 virtual ~SafePointer() { DBG_ASSERT(pSelf==this,"Destructor von Nicht existierendem Objekt aufgerufen");
132 pSelf = NULL; }
133 // static BOOL IsValid( SafePointer *pThis ) { return pThis == pThis->pSelf; }
134 // virtual operator -> (); { DBG_ASSERT(pMyself == this,"-> von Nicht existierendem Objekt aufgerufen"); }
138 class DisplayHidWin;
139 class StatementCommand;
140 class TranslateWin;
142 struct TTSettings
144 // DisplayHID
145 StatementCommand *pDisplayInstance;
146 DisplayHidWin *pDisplayHidWin;
147 Window *Old;
148 Window *Act;
149 String aOriginalCaption;
151 // Translate
152 TranslateWin *pTranslateWin;
153 BOOL bToTop;
157 TTSettings* GetTTSettings();
160 #define MAX_RETRIES 9
161 class StatementList : public SafePointer
163 private:
164 StatementList(const StatementList&);
165 StatementList & operator=(const StatementList&);
167 protected:
168 StatementList();
169 USHORT nRetryCount;
170 void QueStatement(StatementList *pAfterThis);
171 BOOL bStatementInQue;
172 static USHORT nUseBindings;
174 static TTProfiler *pProfiler;
175 void InitProfile();
176 void SendProfile( String aText );
177 static StatementList *pCurrentProfileStatement;
179 static BOOL bIsInReschedule;
180 static USHORT nModalCount;
181 static Window *pLastFocusWindow; // Wenn dieses sich ändert wird Safe Reschedule abgebrochen
182 static BOOL bWasDragManager; // Wenn dieses sich ändert wird Safe Reschedule abgebrochen
183 static BOOL bWasPopupMenu; // Wenn dieses sich ändert wird Safe Reschedule abgebrochen
184 static BOOL bBasicWasRunning;
186 static USHORT nMinTypeKeysDelay; /// Verzögerung der einzelnen Anschläge für TypeKeys
187 static USHORT nMaxTypeKeysDelay;
188 static BOOL bDoTypeKeysDelay;
190 static Window* pFirstDocFrame;
192 static BOOL bIsSlotInExecute;
194 public:
195 static BOOL IsInReschedule() { return bIsInReschedule; }
196 void SafeReschedule( BOOL bYield = FALSE ) // Setzt Flag, so daß nicht schon der nächste Befehl ausgeführt wird
198 nModalCount = Application::GetModalModeCount();
199 bIsInReschedule = TRUE;
200 pLastFocusWindow = GetpApp()->GetFocusWindow();
201 bWasDragManager = false /*!= DragManager::GetDragManager()*/;
202 bWasPopupMenu = NULL != PopupMenu::GetActivePopupMenu();
203 bBasicWasRunning = StarBASIC::IsRunning();
204 bWasExecuting = bExecuting;
205 if ( bYield )
206 GetpApp()->Yield();
207 else
208 GetpApp()->Reschedule();
209 bExecuting = bWasExecuting;
210 bBasicWasRunning = FALSE;
211 bWasPopupMenu = FALSE;
212 bWasDragManager = FALSE;
213 pLastFocusWindow = NULL;
214 bIsInReschedule = FALSE;
215 nModalCount = 0;
217 static BOOL MaybeResetSafeReschedule()
218 { // Implementierung muß hier zwar nicht sein, ist aber übersichtlicher so
219 if ( !bIsInReschedule )
220 return FALSE;
222 if ( pLastFocusWindow != GetpApp()->GetFocusWindow()
223 || ( Application::GetModalModeCount() > nModalCount )
224 // || ( DragManager::GetDragManager() && !bWasDragManager )
225 || ( PopupMenu::GetActivePopupMenu() && !bWasPopupMenu )
226 || ( StarBASIC::IsRunning() && !bBasicWasRunning ) )
228 bIsInReschedule = FALSE;
229 pLastFocusWindow = NULL;
230 return TRUE;
232 else
233 return FALSE;
235 static void NormalReschedule() // Setzt das flag nicht
237 GetpApp()->Reschedule();
239 #define Reschedule RescheduleNichtBenutzen_StattdessenSafeRescheduleAnStatementList
241 static Window* GetMouseWin();
242 static BOOL WinPtrValid(Window *pTest);
243 static Window* SearchAllWin( Window *pBase, Search &aSearch, BOOL MaybeBase = TRUE );
244 protected:
245 static Window* SearchClientWin( Window *pBase, Search &aSearch, BOOL MaybeBase = TRUE );
247 Window* SearchTree( SmartId aUId, BOOL bSearchButtonOnToolbox = FALSE );
248 Window* GetActive( WindowType nRT, BOOL MaybeBase = TRUE );
249 Window* GetFocus( WindowType nRT, BOOL MaybeBase = TRUE );
250 Window* GetAnyActive( BOOL MaybeBase = TRUE );
251 ScrollBar* GetScrollBar( Window *pBase, USHORT nDirection, BOOL MaybeBase = TRUE );
252 Window* GetPopupFloatingWin( BOOL MaybeBase = TRUE );
253 Menu* GetMatchingMenu( Window* pWin, Menu* pBaseMenu = NULL );
254 Window* GetWinByRT( Window *pBase, WindowType nRT, BOOL MaybeBase = TRUE, USHORT nSkip = 0, BOOL bSearchAll = FALSE );
255 USHORT CountWinByRT( Window *pBase, WindowType nRT, BOOL MaybeBase = TRUE );
256 Window* GetDocWin( USHORT nNr );
257 USHORT GetDocWinCount();
258 Window* GetFadeSplitWin( Window *pBase, WindowAlign nAlign, BOOL MaybeBase = TRUE );
259 BOOL ValueOK(SmartId nId, String aBezeichnung, ULONG nValue, ULONG nMax);
261 USHORT GetCurrentMenues( PopupMenu *&pPopup, MenuBar *&pMenuBar, Menu *&pMenu );
263 public:
264 // void AddStatement( StatementList *pNewStatement );
266 virtual ~StatementList();
267 void Advance();
268 virtual BOOL Execute() = 0;
269 /***************************************************************************
270 ** Bestimmt erst den nächsten Befehl, setzt Current
271 ** und führt dann aus.
272 ** Returnwert gibt an, ob Befehl nochmal ausgeführt
273 ** werden soll. Dann muß auch der UserEvent verlassen werden, um der Applikation
274 ** normales Arbeiten zu ermöglichen (Dialog schliessen)
275 ** TRUE bedeutet, dass alles klar gegangen ist
276 ** FALSE bedeutet nochmal Bitte
277 ***************************************************************************/
279 void ReportError(String aMessage);
280 void ReportError(SmartId aUId, String aMessage);
281 void ReportError(String aMessage, ULONG nWhatever);
283 static void DirectLog( ULONG nType, String aString );
285 String Tree(Window *pBase, int Indent);
286 String ClientTree(Window *pBase, int Indent);
288 StatementList *pNext;
289 static StatementList /**pCurrent,*/ *pFirst;
290 static BOOL bReadingCommands;
291 static SmartId aWindowWaitUId;
292 static Window *pWindowWaitPointer;
293 static SmartId aWindowWaitOldHelpId;
294 static SmartId aWindowWaitOldUniqueId;
295 static RetStream *pRet;
296 static BOOL IsError;
297 static BOOL bDying;
298 static BOOL bExecuting; // Gesetzt, wenn ein Befehl rescheduled ohne einen neuen Befehl zu erlauben
299 BOOL bWasExecuting; // Wurde bei einem MaybeResetSafeReschedule resettet, so wird der Zustand danach wiederhergestellt
300 static SmartId aSubMenuId1; // Untermenüs bei PopupMenus
301 static SmartId aSubMenuId2; // erstmal 2-Stufig
302 static SmartId aSubMenuId3; // and now even 3 levels #i31512#
303 static SystemWindow *pMenuWindow; // when using MenuBar as base for MenuCommands
304 static TTProperties *pTTProperties; // Hier stehen die SlotIDs aus dem SFX drin
306 BOOL CheckWindowWait(); //True heisst, dass Window noch existiert
307 //False -> Window weg;
308 static void SetFirstDocFrame( Window* pWin );
309 static Window* GetFirstDocFrame();
310 static BOOL IsFirstDocFrame( Window* pWin );
311 static BOOL IsDocWin( Window* pWin );
312 static BOOL IsIMEWin( Window* pWin ); // Input Window for CJK under Solaris
313 static BOOL IsDocFrame( Window* pWin );
314 static MenuBar* GetDocFrameMenuBar( Window* pWin );
315 static USHORT GetDocFrameCount();
317 static BOOL bCatchGPF;
319 static BOOL bUsePostEvents; // use Application::Post*Event or own impl to handle key and mouseevents
321 #if OSL_DEBUG_LEVEL > 1
322 static EditWindow *m_pDbgWin;
323 #endif
326 class StatementSlot : public StatementList //Slots aufrufen
328 protected:
329 USHORT nAnzahl;
330 SfxPoolItem **pItemArr;
331 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue> aArgs;
332 USHORT nFunctionId; // can get removed when the old (numeric) slothandling is removed
333 String aUnoUrl;
334 BOOL bMenuClosed;
336 StatementSlot();
337 void AddReferer();
338 public:
339 StatementSlot( SCmdStream *pIn );
340 StatementSlot( ULONG nSlot, SfxPoolItem* pItem = NULL );
341 virtual ~StatementSlot();
342 virtual BOOL Execute();
345 class StatementUnoSlot : public StatementSlot //Uno Slots aufrufen
347 public:
348 StatementUnoSlot(SCmdStream *pIn);
351 class StatementCommand : public StatementList // Befehl ausführen (wintree, resetaplication ...)
353 friend class ImplRemoteControl;
354 protected:
355 USHORT nMethodId;
356 SmartId aSmartMethodId;
357 USHORT nParams;
358 comm_USHORT nNr1,nNr2,nNr3,nNr4;
359 comm_ULONG nLNr1;
360 String aString1,aString2;
361 BOOL bBool1,bBool2;
363 Window* GetNextOverlap( Window* pBase );
364 Window* GetNextRecoverWin();
366 static USHORT nDirPos;
367 static Dir *pDir;
368 static pfunc_osl_printDebugMessage pOriginal_osl_DebugMessageFunc;
371 BOOL UnpackStorage( SotStorageRef xStorage, DirEntry &aBaseDir );
373 void HandleSAXParser();
375 public:
376 StatementCommand( SCmdStream *pIn );
377 StatementCommand( StatementList *pAfterThis, USHORT MethodId, USHORT Params, USHORT Nr1 );
378 virtual BOOL Execute();
379 BOOL DisplayHID();
380 void Translate();
381 void WriteControlData( Window *pBase, ULONG nConf, BOOL bFirst = TRUE );
386 enum TTHotSpots { MitteLinks, Mitte, MitteOben };
388 class StatementControl : public StatementList
390 protected:
391 SmartId aUId;
392 USHORT nMethodId;
393 USHORT nParams;
394 comm_USHORT nNr1,nNr2,nNr3,nNr4;
395 comm_ULONG nLNr1;
396 String aString1,aString2;
397 BOOL bBool1,bBool2;
398 BOOL ControlOK( Window *pControl, const sal_Char* aBezeichnung );
399 void AnimateMouse( Window *pControl, TTHotSpots aWohin );
400 void AnimateMouse( Window *pControl, Point aWohin );
402 BOOL MaybeDoTypeKeysDelay( Window *pTestWindow );
404 BOOL HandleVisibleControls( Window *pControl );
405 BOOL HandleCommonMethods( Window *pControl );
407 public:
408 StatementControl( SCmdStream *pIn, USHORT nControlType );
409 virtual BOOL Execute();
413 class StatementFlow : public StatementList // Kommunikation mit Sequence
415 USHORT nArt;
417 USHORT nParams;
418 comm_USHORT nSNr1;
419 comm_ULONG nLNr1;
420 String aString1;
421 BOOL bBool1;
424 public:
425 StatementFlow (ULONG nServiceId, SCmdStream *pIn, ImplRemoteControl *pRC );
426 StatementFlow( StatementList *pAfterThis, USHORT nArtP );
427 virtual BOOL Execute();
428 static CommunicationLink *pCommLink;
429 static BOOL bSending;
431 static BOOL bUseIPC; // Soll zur rückmeldung IPC verwendet werden?
432 static ImplRemoteControl *pRemoteControl; // Static für 2. Constructor
434 private:
435 void SendViaSocket();
438 class SearchUID : public Search
440 Window *pMaybeResult;
441 Window *pAlternateResult;
442 SmartId aUId;
443 BOOL bSearchButtonOnToolbox;
444 public:
445 SearchUID( SmartId aUIdP, BOOL bSearchButtonOnToolboxP ): Search( SEARCH_FOCUS_FIRST ), pMaybeResult(NULL), pAlternateResult(NULL), aUId(aUIdP), bSearchButtonOnToolbox(bSearchButtonOnToolboxP) {}
446 virtual BOOL IsWinOK( Window *pWin );
447 Window* GetMaybeWin() { return pMaybeResult; }
448 Window* GetAlternateResultWin() { return pAlternateResult; }
450 class SearchActive : public Search
452 WindowType nRT;
453 public:
454 SearchActive( WindowType nRTP ): nRT(nRTP) {}
455 virtual BOOL IsWinOK( Window *pWin );
457 class SearchPopupFloatingWin : public Search
459 public:
460 SearchPopupFloatingWin(): Search( SEARCH_FOCUS_FIRST ) {}
461 virtual BOOL IsWinOK( Window *pWin );
463 class SearchRT : public Search
465 WindowType mnRT;
466 USHORT mnSkip;
467 USHORT mnCount;
468 public:
469 SearchRT( WindowType nRTP, SearchFlags nSearchFlags, USHORT nSkip = 0 ): Search(nSearchFlags), mnRT(nRTP), mnSkip( nSkip ), mnCount( 0 ) {}
470 virtual BOOL IsWinOK( Window *pWin );
471 USHORT GetCount(){ return mnCount; }
473 class SearchScroll : public SearchRT
475 USHORT nDirection;
476 public:
477 SearchScroll( USHORT nDir, SearchFlags nSearchFlags ): SearchRT(WINDOW_SCROLLBAR, nSearchFlags), nDirection(nDir) {}
478 virtual BOOL IsWinOK( Window *pWin );
480 class SearchWinPtr : public Search
482 Window *pTest;
483 public:
484 SearchWinPtr( Window *pTestP ): pTest(pTestP) {}
485 virtual BOOL IsWinOK( Window *pWin );
487 class SearchFadeSplitWin : public Search
489 WindowAlign nAlign;
490 public:
491 SearchFadeSplitWin( WindowAlign nAlignP ): nAlign(nAlignP) {}
492 virtual BOOL IsWinOK( Window *pWin );
496 void ImplKeyInput( Window* pWin, KeyEvent &aKEvnt, BOOL bForceDirect=FALSE );
497 void ImplMouseMove( Window* pWin, MouseEvent &aMEvnt, BOOL bForceDirect=FALSE );
498 void ImplMouseButtonDown( Window* pWin, MouseEvent &aMEvnt, BOOL bForceDirect=FALSE );
499 void ImplMouseButtonUp( Window* pWin, MouseEvent &aMEvnt, BOOL bForceDirect=FALSE );
500 void ImplCommand( Window* pWin, CommandEvent &aCmdEvnt );
501 void ImplEventWait( ULONG nID );
503 #endif