summaryrefslogtreecommitdiff
path: root/automation
diff options
context:
space:
mode:
Diffstat (limited to 'automation')
-rw-r--r--automation/inc/automation/automation.hxx52
-rw-r--r--automation/inc/automation/commdefines.hxx148
-rw-r--r--automation/inc/automation/commtypes.hxx76
-rw-r--r--automation/inc/automation/communi.hxx180
-rw-r--r--automation/inc/automation/simplecm.hxx393
-rw-r--r--automation/inc/makefile.mk47
-rw-r--r--automation/inc/pch/precompiled_automation.cxx29
-rw-r--r--automation/inc/pch/precompiled_automation.hxx32
-rw-r--r--automation/packimages/makefile.mk63
-rw-r--r--automation/prj/build.lst11
-rw-r--r--automation/prj/d.lst27
-rw-r--r--automation/prj/l10n1
-rw-r--r--automation/source/app/makefile.mk52
-rw-r--r--automation/source/app/testbasi.cxx161
-rw-r--r--automation/source/app/testbasi.hxx64
-rw-r--r--automation/source/communi/communi.cxx596
-rw-r--r--automation/source/communi/makefile.mk44
-rw-r--r--automation/source/inc/cmdbasestream.hxx90
-rw-r--r--automation/source/inc/icommstream.hxx64
-rw-r--r--automation/source/inc/rcontrol.hxx496
-rw-r--r--automation/source/inc/sttresid.hxx42
-rw-r--r--automation/source/inc/svcommstream.hxx56
-rw-r--r--automation/source/inc/testapp.hxx194
-rw-r--r--automation/source/inc/testtool.hxx72
-rw-r--r--automation/source/miniapp/editwin.cxx127
-rw-r--r--automation/source/miniapp/editwin.hxx70
-rw-r--r--automation/source/miniapp/hid.lst27
-rw-r--r--automation/source/miniapp/makefile.mk54
-rw-r--r--automation/source/miniapp/servres.cxx60
-rw-r--r--automation/source/miniapp/servres.hrc40
-rw-r--r--automation/source/miniapp/servres.hxx81
-rw-r--r--automation/source/miniapp/servres.src233
-rw-r--r--automation/source/miniapp/servuid.hxx37
-rw-r--r--automation/source/miniapp/test.bas126
-rw-r--r--automation/source/miniapp/test.sid5
-rw-r--r--automation/source/miniapp/test.win13
-rw-r--r--automation/source/miniapp/testapp.cxx351
-rw-r--r--automation/source/miniapp/testapp.hxx125
-rw-r--r--automation/source/mozillaserver/makefile.mk153
-rw-r--r--automation/source/mozillaserver/mozillatesttoolserver.idl52
-rw-r--r--automation/source/mozillaserver/xmozillatesttoolserver.idl157
-rw-r--r--automation/source/server/XMLParser.cxx695
-rw-r--r--automation/source/server/cmdbasestream.cxx350
-rw-r--r--automation/source/server/editwin.cxx164
-rw-r--r--automation/source/server/editwin.hxx74
-rw-r--r--automation/source/server/makefile.mk71
-rw-r--r--automation/source/server/prof_nul.cxx96
-rw-r--r--automation/source/server/prof_usl.cxx136
-rw-r--r--automation/source/server/profiler.cxx264
-rw-r--r--automation/source/server/profiler.hxx137
-rw-r--r--automation/source/server/recorder.cxx1095
-rw-r--r--automation/source/server/recorder.hxx83
-rw-r--r--automation/source/server/retstrm.cxx127
-rw-r--r--automation/source/server/retstrm.hxx87
-rw-r--r--automation/source/server/scmdstrm.cxx215
-rw-r--r--automation/source/server/scmdstrm.hxx61
-rw-r--r--automation/source/server/server.cxx981
-rw-r--r--automation/source/server/server.hxx81
-rw-r--r--automation/source/server/sta_list.cxx1228
-rw-r--r--automation/source/server/statemnt.cxx6710
-rw-r--r--automation/source/server/statemnt.hxx498
-rw-r--r--automation/source/server/svcommstream.cxx48
-rw-r--r--automation/source/server/testtool.hrc55
-rw-r--r--automation/source/simplecm/communiio.hxx65
-rw-r--r--automation/source/simplecm/makefile.mk46
-rw-r--r--automation/source/simplecm/packethandler.cxx334
-rw-r--r--automation/source/simplecm/packethandler.hxx69
-rw-r--r--automation/source/simplecm/simplecm.cxx702
-rw-r--r--automation/source/simplecm/tcpio.cxx71
-rw-r--r--automation/source/simplecm/tcpio.hxx61
-rw-r--r--automation/source/testtool/cmdstrm.cxx471
-rw-r--r--automation/source/testtool/cmdstrm.hxx78
-rw-r--r--automation/source/testtool/comm_bas.cxx442
-rw-r--r--automation/source/testtool/comm_bas.hxx120
-rw-r--r--automation/source/testtool/cretstrm.cxx73
-rw-r--r--automation/source/testtool/cretstrm.hxx55
-rw-r--r--automation/source/testtool/filter.pl125
-rw-r--r--automation/source/testtool/httprequest.cxx239
-rw-r--r--automation/source/testtool/httprequest.hxx85
-rw-r--r--automation/source/testtool/makefile.mk109
-rw-r--r--automation/source/testtool/objtest.cxx4366
-rw-r--r--automation/source/testtool/objtest.hxx402
-rw-r--r--automation/source/testtool/registry_win.cxx89
-rw-r--r--automation/source/testtool/registry_win.hxx31
-rw-r--r--automation/source/testtool/sysdir_win.cxx105
-rw-r--r--automation/source/testtool/sysdir_win.hxx31
-rw-r--r--automation/source/testtool/tcommuni.cxx200
-rw-r--r--automation/source/testtool/tcommuni.hxx67
-rw-r--r--automation/source/testtool/testtool.ini19
-rw-r--r--automation/util/makefile.mk288
-rw-r--r--automation/util/manually_added_ids.hid8
91 files changed, 26708 insertions, 0 deletions
diff --git a/automation/inc/automation/automation.hxx b/automation/inc/automation/automation.hxx
new file mode 100644
index 000000000000..38babd58849e
--- /dev/null
+++ b/automation/inc/automation/automation.hxx
@@ -0,0 +1,52 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef AUTOMATION_HXX
+#define AUTOMATION_HXX
+
+class ImplRemoteControl;
+
+class RemoteControl
+{
+ ImplRemoteControl* pImpl;
+public:
+ RemoteControl();
+ ~RemoteControl();
+};
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+ typedef void ( *pfunc_CreateRemoteControl)();
+ typedef void ( *pfunc_DestroyRemoteControl)();
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // AUTOMATION_HXX
diff --git a/automation/inc/automation/commdefines.hxx b/automation/inc/automation/commdefines.hxx
new file mode 100644
index 000000000000..98ebf308c3a7
--- /dev/null
+++ b/automation/inc/automation/commdefines.hxx
@@ -0,0 +1,148 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+/*************************************************************************
+ *
+ * ATTENTION
+ * This file is intended to work inside and outside the StarOffice environment.
+ * Only adaption of file commtypes.hxx should be necessary. Else it is a bug!
+ *
+ ************************************************************************/
+
+#include <automation/commtypes.hxx>
+#include <osl/endian.h>
+
+#ifndef MAKEDWORD
+#define MAKEDWORD(wl, wh) ((comm_DWORD)((wl) & 0xFFFF) | (((comm_DWORD)(wh) & 0xFFFF) << 16))
+#endif
+#ifndef LOWORD
+#define LOWORD(d) ((comm_WORD)((comm_DWORD)(d) & 0xFFFF))
+#endif
+#ifndef HIWORD
+#define HIWORD(d) ((comm_WORD)(((comm_DWORD)(d) >> 16) & 0xFFFF))
+#endif
+#ifndef MAKEWORD
+#define MAKEWORD(bl, bh) ((comm_WORD)((bl) & 0xFF) | (((comm_WORD)(bh) & 0xFF) << 8))
+#endif
+#ifndef LOBYTE
+#define LOBYTE(w) ((comm_BYTE)((comm_WORD)(w) & 0xFF))
+#endif
+#ifndef HIBYTE
+#define HIBYTE(w) ((comm_BYTE)(((comm_WORD)(w) >> 8) & 0xFF))
+#endif
+#ifndef MAKEBYTE
+#define MAKEBYTE(nl, nh) ((comm_BYTE)(((nl) & 0x0F) | (((nh) & 0x0F) << 4)))
+#endif
+#ifndef LONIBBLE
+#define LONIBBLE(b) ((comm_BYTE)((b) & 0x0F))
+#endif
+#ifndef HINIBBLE
+#define HINIBBLE(b) ((comm_BYTE)(((b) >> 4) & 0x0F))
+#endif
+
+#ifndef SWAPWORD
+#define SWAPWORD(w) MAKEWORD(HIBYTE(w),LOBYTE(w))
+#endif
+#ifndef SWAPDWORD
+#define SWAPDWORD(d) MAKEDWORD(SWAPWORD(HIWORD(d)),SWAPWORD(LOWORD(d)))
+#endif
+
+#ifdef OSL_BIGENDIAN
+#ifndef NETWORD
+#define NETWORD(w) (comm_WORD)(w)
+#endif
+#ifndef NETDWORD
+#define NETDWORD(d) (comm_DWORD)(d)
+#endif
+#endif // OSL_BIGENDIAN
+
+#ifdef OSL_LITENDIAN
+#ifndef NETWORD
+#define NETWORD(w) MAKEWORD(HIBYTE(w),LOBYTE(w))
+#endif
+#ifndef NETDWORD
+#define NETDWORD(d) MAKEDWORD(NETWORD(HIWORD(d)),NETWORD(LOWORD(d)))
+#endif
+#endif // OSL_LITENDIAN
+
+/**
+ Es gibt zwei arten von Datenpaketen
+ die erste enthält in den ersten 4 Byte die Längenangabe und in den Darauffolgenden die Daten
+ Die Längenangabe bezieht sich nur auf die Daten ohne die Längenangabe selbst.
+
+ Die Zweite Art von Datenpaketen enthält Header mit weitere Informationen
+ wie unten beschrieben.
+
+ Umgeschaltet wird mit dem Boolean bUseMultiChannel im Konstruktor des Managers.
+**/
+/**
+Defines für Header Typen:
+
+Allgemeiner Header:
+ Byte Länge Inhalt
+ 0..3 4 Länge des Paketes ohne diese 4 Byte
+ 4 1 Prüfsumme über die Länge. Stimmt sie nicht wird die Verbindung geschlossen
+ 5..6 2 Länge des Headers ohne diese 2 Byte
+ 7..8 2 Typ des Headers
+
+CH_SimpleMultiChannel:
+ 9..10 2 Channel
+CH_Handshake Internal Use ONLY
+ Keine Weiteren Daten!
+
+**/
+typedef comm_UINT16 CMProtocol;
+
+#define CM_PROTOCOL_OLDSTYLE (CMProtocol)0x0001
+#define CM_PROTOCOL_MARS (CMProtocol)0x0001
+#define CM_PROTOCOL_BROADCASTER (CMProtocol)0x0002
+#define CM_PROTOCOL_USER_START (CMProtocol)0x0100
+
+typedef comm_USHORT HandshakeType;
+typedef comm_USHORT CommunicationOption;
+
+#define CH_NoHeader 0x0000
+#define CH_SimpleMultiChannel 0x0001
+#define CH_Handshake 0x0002
+
+#define CH_REQUEST_HandshakeAlive ((HandshakeType)0x0101) /// Fordert eine Alive Antwort an
+#define CH_RESPONSE_HandshakeAlive ((HandshakeType)0x0102) /// Alive Antwort
+
+/**
+ Announce supported options:
+ Client announces available options
+ Server returns subset of these options (note that the sbset can be the entire set also)
+**/
+#define CH_SUPPORT_OPTIONS ((HandshakeType)0x0103)
+#define OPT_USE_SHUTDOWN_PROTOCOL ((CommunicationOption)0x0001)
+
+/// these are for making sure all Data is read prior to shutting sown the link
+#define CH_REQUEST_ShutdownLink ((HandshakeType)0x0104) /// Request to Shutdown this link
+#define CH_ShutdownLink ((HandshakeType)0x0105) /// Shutdown this link
+
+#define CH_SetApplication ((HandshakeType)0x0106) /// Set Description of Client
+
diff --git a/automation/inc/automation/commtypes.hxx b/automation/inc/automation/commtypes.hxx
new file mode 100644
index 000000000000..2e035ba91bfa
--- /dev/null
+++ b/automation/inc/automation/commtypes.hxx
@@ -0,0 +1,76 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+/*************************************************************************
+ *
+ * ATTENTION
+ * This file is intended to supply the types and defines for Environment independent
+ * building of the packethandler
+ * Only adaption of this file should be necessary. Else it is a bug!
+ * Ether including apropriate files or defining the types when not available in the environment
+ *
+ ************************************************************************/
+
+/** defines al least types
+ comm_BYTE
+ comm_WORD;
+ comm_DWORD;
+ comm_BOOL
+ comm_ULONG
+ comm_USHORT
+ comm_UINT16
+ comm_UINT32
+ comm_UniChar
+**/
+
+#ifndef _COMMTYPES_HXX
+#define _COMMTYPES_HXX
+
+#include <sal/types.h>
+typedef sal_Unicode comm_UniChar;
+#include "rtl/string.hxx"
+
+//#define DBG_ASSERT( cond, text )
+//#define DBG_ERROR( text )
+#include <tools/debug.hxx>
+
+#include <tools/solar.h>
+typedef sal_uInt8 comm_BYTE;
+typedef sal_Bool comm_BOOL;
+typedef sal_uInt32 comm_ULONG;
+typedef sal_uInt16 comm_USHORT;
+typedef sal_uInt16 comm_UINT16;
+typedef sal_uInt32 comm_UINT32;
+
+typedef sal_uInt16 comm_WORD;
+typedef sal_uInt32 comm_DWORD;
+
+class rtl::OString;
+class String;
+#define comm_String String
+
+#endif
diff --git a/automation/inc/automation/communi.hxx b/automation/inc/automation/communi.hxx
new file mode 100644
index 000000000000..1590bb9f58fb
--- /dev/null
+++ b/automation/inc/automation/communi.hxx
@@ -0,0 +1,180 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _COMMUNI_HXX
+#define _COMMUNI_HXX
+
+#include <svl/svarray.hxx>
+#include <vos/thread.hxx>
+#include <vos/mutex.hxx>
+#include <vcl/timer.hxx>
+#include <automation/simplecm.hxx>
+
+class SvStream;
+class SvMemoryStream;
+//class Application;
+
+class CommunicationManagerServerAcceptThread;
+SV_DECL_PTRARR_SORT( CommunicationLinkList, CommunicationLink*, 1, 10 )
+
+class MultiCommunicationManager : public CommunicationManager
+{
+public:
+ MultiCommunicationManager( sal_Bool bUseMultiChannel = sal_False );
+ virtual ~MultiCommunicationManager();
+ virtual sal_Bool StopCommunication(); // Hält alle CommunicationLinks an
+ virtual sal_Bool IsLinkValid( CommunicationLink* pCL );
+ virtual sal_uInt16 GetCommunicationLinkCount();
+ virtual CommunicationLinkRef GetCommunicationLink( sal_uInt16 nNr );
+
+ void DoQuickShutdown( sal_Bool bQuickShutdown = sal_True) { bGracefullShutdown = !bQuickShutdown; }
+
+protected:
+ virtual void CallConnectionOpened( CommunicationLink* pCL );
+ virtual void CallConnectionClosed( CommunicationLink* pCL );
+ CommunicationLinkList *ActiveLinks;
+ CommunicationLinkList *InactiveLinks; /// Hier sind die CommunicationLinks drin, die sich noch nicht selbst abgemeldet haben.
+ /// allerdings schon ein StopCommunication gekriegt haben, bzw ein ConnectionTerminated
+ virtual void DestroyingLink( CommunicationLink *pCL ); // Link trägt sich im Destruktor aus
+
+ sal_Bool bGracefullShutdown;
+};
+
+class CommunicationManagerServer : public MultiCommunicationManager
+{
+public:
+ CommunicationManagerServer( sal_Bool bUseMultiChannel = sal_False ):MultiCommunicationManager( bUseMultiChannel ){;}
+};
+
+class CommunicationManagerClient : public MultiCommunicationManager, public ICommunicationManagerClient
+{
+public:
+ CommunicationManagerClient( sal_Bool bUseMultiChannel = sal_False );
+};
+
+class CommunicationLinkViaSocket : public SimpleCommunicationLinkViaSocket, public vos::OThread
+{
+public:
+ CommunicationLinkViaSocket( CommunicationManager *pMan, vos::OStreamSocket *pSocket );
+ virtual ~CommunicationLinkViaSocket();
+
+ virtual sal_Bool IsCommunicationError();
+ virtual sal_Bool DoTransferDataStream( SvStream *pDataStream, CMProtocol nProtocol = CM_PROTOCOL_OLDSTYLE );
+
+ // Diese sind Virtuelle Links!!!!
+ virtual long ConnectionClosed( void* = NULL );
+ virtual long DataReceived( void* = NULL );
+
+ virtual sal_Bool StopCommunication();
+
+ void SetPutDataReceivedHdl( Link lPutDataReceived ){ mlPutDataReceived = lPutDataReceived; }
+ Link GetDataReceivedLink () {Link aLink = LINK( this, CommunicationLinkViaSocket, DataReceived ); return aLink;}
+ DECL_LINK( PutDataReceivedHdl, CommunicationLinkViaSocket* );
+
+protected:
+ virtual void SAL_CALL run();
+
+ virtual sal_Bool ShutdownCommunication();
+ sal_uLong nConnectionClosedEventId;
+ sal_uLong nDataReceivedEventId;
+ vos::OMutex aMConnectionClosed; // Notwendig, da Event verarbeitet werden kann bevor Variable gesetzt ist
+ vos::OMutex aMDataReceived; // Notwendig, da Event verarbeitet werden kann bevor Variable gesetzt ist
+ virtual void WaitForShutdown();
+
+ DECL_LINK( ShutdownLink, void* );
+ Timer aShutdownTimer;
+ sal_Bool bShutdownStarted;
+ sal_Bool bDestroying;
+ Link mlPutDataReceived;
+};
+
+class CommunicationManagerServerViaSocket : public CommunicationManagerServer
+{
+ friend class CommunicationManagerServerAcceptThread;
+public:
+ using CommunicationManager::StartCommunication;
+
+ CommunicationManagerServerViaSocket( sal_uLong nPort, sal_uInt16 nMaxCon, sal_Bool bUseMultiChannel = sal_False );
+ virtual ~CommunicationManagerServerViaSocket();
+
+ virtual sal_Bool StartCommunication();
+ virtual sal_Bool StopCommunication();
+
+protected:
+ sal_uLong nPortToListen;
+ sal_uInt16 nMaxConnections;
+
+private:
+ CommunicationManagerServerAcceptThread *pAcceptThread;
+ void AddConnection( CommunicationLink *pNewConnection );
+};
+
+class CommunicationManagerServerAcceptThread: public vos::OThread
+{
+public:
+ CommunicationManagerServerAcceptThread( CommunicationManagerServerViaSocket* pServer, sal_uLong nPort, sal_uInt16 nMaxCon = CM_UNLIMITED_CONNECTIONS );
+ virtual ~CommunicationManagerServerAcceptThread();
+ CommunicationLinkRef GetNewConnection(){ CommunicationLinkRef xTemp = xmNewConnection; xmNewConnection.Clear(); return xTemp; }
+
+protected:
+ virtual void SAL_CALL run();
+
+private:
+ CommunicationManagerServerViaSocket* pMyServer;
+ vos::OAcceptorSocket *pAcceptorSocket;
+ sal_uLong nPortToListen;
+ sal_uInt16 nMaxConnections;
+ sal_uLong nAddConnectionEventId;
+ vos::OMutex aMAddConnection; // Notwendig, da Event verarbeitet werden kann bevor Variable gesetzt ist
+ void CallInfoMsg( InfoString aMsg ){ pMyServer->CallInfoMsg( aMsg ); }
+ CM_InfoType GetInfoType(){ return pMyServer->GetInfoType(); }
+
+ // Diese beiden werden zum Transport der Connection vom Thread zum Mainthread verwendet.
+ CommunicationLinkRef xmNewConnection;
+ DECL_LINK( AddConnection, void* );
+};
+
+class CommunicationManagerClientViaSocket : public CommunicationManagerClient, CommonSocketFunctions
+{
+public:
+ using CommunicationManager::StartCommunication;
+
+ CommunicationManagerClientViaSocket( ByteString aHost, sal_uLong nPort, sal_Bool bUseMultiChannel = sal_False );
+ CommunicationManagerClientViaSocket( sal_Bool bUseMultiChannel = sal_False );
+ virtual ~CommunicationManagerClientViaSocket();
+
+ virtual sal_Bool StartCommunication(){ return StartCommunication( aHostToTalk, nPortToTalk );}
+ virtual sal_Bool StartCommunication( ByteString aHost, sal_uLong nPort ){ return DoStartCommunication( this, (ICommunicationManagerClient*) this, aHost, nPort );}
+
+private:
+ ByteString aHostToTalk;
+ sal_uLong nPortToTalk;
+protected:
+ virtual CommunicationLink *CreateCommunicationLink( CommunicationManager *pCM, vos::OConnectorSocket *pCS ){ return new CommunicationLinkViaSocket( pCM, pCS ); }
+};
+
+#endif
diff --git a/automation/inc/automation/simplecm.hxx b/automation/inc/automation/simplecm.hxx
new file mode 100644
index 000000000000..657357431f9f
--- /dev/null
+++ b/automation/inc/automation/simplecm.hxx
@@ -0,0 +1,393 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _SIMPLECM_HXX
+#define _SIMPLECM_HXX
+
+#include <tools/link.hxx>
+#include <tools/string.hxx>
+#include <tools/stream.hxx>
+#include <vos/socket.hxx>
+#include <tools/debug.hxx>
+#include <tools/datetime.hxx>
+
+#include <automation/commdefines.hxx>
+
+// CM steht für CommunicationManager
+#define CM_UNLIMITED_CONNECTIONS 0xffff
+
+typedef sal_uInt16 CM_NameType;
+#define CM_DOTTED ( (CM_NameType) 01 )
+#define CM_FQDN ( (CM_NameType) 02 )
+
+typedef sal_uInt16 CM_InfoType;
+// nur eines dieser 3 defines darf verwendet werden
+#define CM_NO_TEXT ( (CM_InfoType) 01 )
+#define CM_SHORT_TEXT ( (CM_InfoType) 02 )
+#define CM_VERBOSE_TEXT ( (CM_InfoType) 03 )
+
+#define CM_OPEN ( (CM_InfoType) 0x0004 )
+#define CM_CLOSE ( (CM_InfoType) 0x0008 )
+#define CM_RECEIVE ( (CM_InfoType) 0x0010 )
+#define CM_SEND ( (CM_InfoType) 0x0020 )
+#define CM_ERROR ( (CM_InfoType) 0x0040 )
+#define CM_MISC ( (CM_InfoType) 0x0080 )
+
+#define CM_USER_1 ( (CM_InfoType) 0x0100 )
+#define CM_USER_2 ( (CM_InfoType) 0x0200 )
+#define CM_USER_3 ( (CM_InfoType) 0x0400 )
+#define CM_USER_4 ( (CM_InfoType) 0x0800 )
+
+#define CM_ALL ( CM_OPEN | CM_CLOSE | CM_RECEIVE | CM_SEND | CM_ERROR | CM_MISC )
+#define CM_NONE ( 0 )
+
+#define CByteString( constAsciiStr ) ByteString( RTL_CONSTASCII_STRINGPARAM ( constAsciiStr ) )
+
+#define INFO_MSG( Short, Long, Type, CLink ) \
+{ \
+ if ( (Type & GetInfoType()) > 0 ) \
+ { \
+ switch ( GetInfoType() & 03 ) \
+ { \
+ case CM_NO_TEXT: \
+ { \
+ ByteString aByteString; \
+ CallInfoMsg( InfoString( aByteString, Type, CLink ) ); \
+ } \
+ break; \
+ case CM_SHORT_TEXT: \
+ { \
+ ByteString aByteString( Short ); \
+ CallInfoMsg( InfoString( aByteString, Type, CLink ) ); \
+ } \
+ break; \
+ case CM_VERBOSE_TEXT: \
+ { \
+ ByteString aByteString( Long ); \
+ CallInfoMsg( InfoString( aByteString, Type, CLink ) ); \
+ } \
+ break; \
+ default: \
+ break; \
+ } \
+ } \
+}\
+
+class CommunicationLink;
+
+/*#undef PRV_SV_DECL_REF_LOCK
+#define PRV_SV_DECL_REF_LOCK(ClassName, Ref) \
+protected: \
+ ClassName * pObj; \
+public: \
+PRV_SV_DECL_REF_SIGNATURE(ClassName, Ref) \
+ inline ClassName##Ref( void * pObjP ){ClassName##Ref ((ClassName *) pObjP);} \
+*/
+
+SV_DECL_REF( CommunicationLink )
+
+class InfoString : public ByteString
+{
+public:
+ InfoString( ByteString &nMsg, CM_InfoType nIT, CommunicationLink *pCL = NULL ): ByteString( nMsg ), nInfoType( nIT ), pCommLink( pCL ) {;}
+ CM_InfoType GetInfoType(){ return nInfoType; }
+ CommunicationLinkRef GetCommunicationLink(){ return pCommLink; }
+private:
+ CM_InfoType nInfoType;
+ CommunicationLinkRef pCommLink;
+};
+
+class PacketHandler;
+class CommunicationManager;
+class SingleCommunicationManager;
+class MultiCommunicationManager;
+class CommunicationManagerServerAcceptThread;
+class CommunicationLink : public SvRefBase
+{
+protected:
+ friend class CommunicationManager;
+ friend class SingleCommunicationManager;
+ friend class MultiCommunicationManager;
+ friend class CommunicationManagerServerAcceptThread;
+ // Darf nicht abgeräumt werden zwischen Empfang des Streams und ende des Callbacks
+
+protected: // so daß nur über Ref gelöscht werden kann
+ virtual ~CommunicationLink();
+ void InvalidateManager() { pMyManager = NULL; }
+
+ PacketHandler* pPacketHandler;
+
+public:
+ CommunicationLink( CommunicationManager *pMan );
+
+ virtual sal_Bool StopCommunication()=0;
+ virtual sal_Bool IsCommunicationError()=0;
+ CommunicationManager* GetCommunicationManager(){ return pMyManager; }
+
+// Der Name oder die IP-Adresse oder sonstwas um den Communikationspartner zu identifizieren
+ virtual ByteString GetCommunicationPartner( CM_NameType eType )=0;
+
+// Der Name oder die IP-Adresse oder sonstwas um den Communikationspartner zu identifizieren
+ virtual ByteString GetMyName( CM_NameType eType )=0;
+
+// Liefert einen neuen Stream zum Versenden von Daten.
+ virtual SvStream* GetBestCommunicationStream()=0;
+
+ /** will call virtual function DoTransferDataStream to do actual work
+ Purpos is to allow housekeeping
+ **/
+ sal_Bool TransferDataStream( SvStream *pDataStream, CMProtocol nProtocol = CM_PROTOCOL_OLDSTYLE );
+
+ // Liefert die ID, die vom Sender angegeben wurde.
+ // Dadurch lassen sich virtuelle Kommunikationen über einen physikalischen Link realisiren.
+ // Da die Kommunikation zu älteren Versionen kompatibel bleiben muß, muß der Empfänger raten,
+ // die neue oder die alte verwendet wird, da sich der Kopf eines Auftrages dann ändert.
+ sal_uInt16 GetProtocol(){ return nServiceProtocol; }
+
+ // Der Stream wird hier übergeben. Der Aufrufer ist für dessen Löschung zuständig
+ // Die Methode MUSS gerufen werden, da sonst keine weiteren Daten empfangen werden.
+ SvStream* GetServiceData(){ SvStream *pTemp = pServiceData; pServiceData = NULL; return pTemp; }
+
+ /// Ermöglicht das Auslösen des nächsten Callbacks. Wird auch Implizit gerufen.
+ void FinishCallback(){ bIsInsideCallback = sal_False; }
+
+ /// Syncrones Empfangen der Daten. Nur für Kommandozeile, sonst leer implementiert
+ virtual sal_Bool ReceiveDataStream(){ return sal_False; }
+
+ /// Statistics
+ DateTime GetStart() { return aStart; }
+ sal_uLong GetTotalBytes() { return nTotalBytes; }
+ DateTime GetLastAccess() { return aLastAccess; }
+ const ByteString& GetApplication() { return maApplication; }
+ virtual void SetApplication( const ByteString& aApp );
+
+protected:
+ void CallInfoMsg( InfoString aMsg );
+ CM_InfoType GetInfoType();
+ CommunicationManager *pMyManager;
+// Diese Methoden werden im Main Kontext gerufen und an den Manager weitergereicht.
+ virtual DECL_LINK( ConnectionClosed, void* = NULL );
+ virtual DECL_LINK( DataReceived, void* = NULL );
+
+ virtual sal_Bool DoTransferDataStream( SvStream *pDataStream, CMProtocol nProtocol = CM_PROTOCOL_OLDSTYLE );
+
+ SvStream *pServiceData;
+ sal_uInt16 nServiceProtocol;
+ sal_uInt16 nServiceHeaderType;
+
+ /// Verhindert das vorzeitige Auslösen des nächsten Callbacks.
+ void StartCallback(){ bIsInsideCallback = sal_True; }
+ sal_Bool bIsInsideCallback;
+
+ virtual sal_Bool SendHandshake( HandshakeType aHandshakeType, SvStream* pData = NULL)=0;
+
+ virtual sal_Bool ShutdownCommunication() = 0; /// Really stop the Communication
+
+ /// Statistics
+ DateTime aStart;
+ sal_uLong nTotalBytes;
+ DateTime aLastAccess;
+
+private:
+ ByteString maApplication;
+
+#if OSL_DEBUG_LEVEL > 1
+public:
+ // misc (debuging) purposes
+ sal_Bool bFlag;
+ sal_uLong nSomething;
+#endif
+
+};
+
+SV_IMPL_REF( CommunicationLink );
+
+class CommonSocketFunctions;
+class CommunicationManager
+{
+ friend class CommunicationLink;
+ friend class CommonSocketFunctions;
+public:
+ CommunicationManager( sal_Bool bUseMultiChannel = sal_False );
+ virtual ~CommunicationManager();
+
+ virtual sal_Bool StartCommunication()=0;
+ virtual sal_Bool StartCommunication( String aApp, String aParams );
+ virtual sal_Bool StartCommunication( ByteString aHost, sal_uLong nPort );
+ virtual sal_Bool StopCommunication()=0; // Hält alle CommunicationLinks an
+ virtual sal_Bool IsCommunicationRunning() { return bIsCommunicationRunning; }
+// virtual sal_Bool IsCommunicationError();
+
+// Der Name oder die IP-Adresse oder sonstwas um den Communikationspartner zu identifizieren
+ virtual ByteString GetMyName( CM_NameType eType );
+
+ virtual sal_Bool IsLinkValid( CommunicationLink* pCL )=0; // Notwendig für call im Destruktor
+
+ virtual sal_uInt16 GetCommunicationLinkCount()=0;
+ virtual CommunicationLinkRef GetCommunicationLink( sal_uInt16 nNr )=0;
+
+ // Liefert den letzten neuen Link oder NULL wenn dieser schon wieder geschlossen ist.
+ CommunicationLinkRef GetLastNewLink() { return xLastNewLink; }
+
+ void SetConnectionOpenedHdl( Link lConnectionOpened ){ mlConnectionOpened = lConnectionOpened; }
+ void SetConnectionClosedHdl( Link lConnectionClosed ){ mlConnectionClosed = lConnectionClosed; }
+ void SetDataReceivedHdl( Link lDataReceived ){ mlDataReceived = lDataReceived; }
+ void SetInfoMsgHdl( Link lInfoMsg ){ mlInfoMsg = lInfoMsg; }
+
+ void SetInfoType( CM_InfoType nIT ){ nInfoType = nIT; }
+ CM_InfoType GetInfoType(){ return nInfoType; }
+
+ sal_Bool IsMultiChannel(){ return bIsMultiChannel; }
+ void SetApplication( const ByteString& aApp, sal_Bool bRunningLinks = sal_False );
+ const ByteString& GetApplication() { return maApplication; }
+
+protected:
+ // Diese Methoden werden innerhalb gerufen. Sie erledigen eventuelles Housekeeping
+ // und rufen dann die entsprechende Methode
+ virtual void CallConnectionOpened( CommunicationLink* pCL );
+ virtual void CallConnectionClosed( CommunicationLink* pCL );
+ void CallDataReceived( CommunicationLink* pCL );
+ void CallInfoMsg( InfoString aMsg );
+
+ CM_InfoType nInfoType;
+
+ // Diese Routinen rufen den Link oder sind überladen
+ virtual void ConnectionOpened( CommunicationLink* pCL ){ mlConnectionOpened.Call( pCL ); }
+ virtual void ConnectionClosed( CommunicationLink* pCL ){ mlConnectionClosed.Call( pCL ); }
+ virtual void DataReceived( CommunicationLink* pCL ){ mlDataReceived.Call( pCL ); }
+ virtual void InfoMsg( InfoString aMsg ){ mlInfoMsg.Call( &aMsg ); }
+
+ sal_Bool bIsCommunicationRunning;
+
+ virtual void DestroyingLink( CommunicationLink *pCL )=0; // Link trägt sich im Destruktor aus
+
+private:
+ ByteString maApplication;
+ Link mlConnectionOpened;
+ Link mlConnectionClosed;
+ Link mlDataReceived;
+ Link mlInfoMsg;
+ CommunicationLinkRef xLastNewLink;
+
+ sal_Bool bIsMultiChannel;
+};
+
+class SingleCommunicationManager : public CommunicationManager
+{
+public:
+ SingleCommunicationManager( sal_Bool bUseMultiChannel = sal_False );
+ virtual ~SingleCommunicationManager();
+ virtual sal_Bool StopCommunication(); // Hält alle CommunicationLinks an
+ virtual sal_Bool IsLinkValid( CommunicationLink* pCL );
+ virtual sal_uInt16 GetCommunicationLinkCount();
+ virtual CommunicationLinkRef GetCommunicationLink( sal_uInt16 nNr );
+
+protected:
+ virtual void CallConnectionOpened( CommunicationLink* pCL );
+ virtual void CallConnectionClosed( CommunicationLink* pCL );
+ CommunicationLinkRef xActiveLink;
+ CommunicationLink *pInactiveLink;
+ virtual void DestroyingLink( CommunicationLink *pCL ); // Link trägt sich im Destruktor aus
+};
+
+class ICommunicationManagerClient
+{
+ friend class CommonSocketFunctions;
+protected:
+ virtual sal_Bool RetryConnect() { return sal_False; } // Kann dann eventuell die Applikation starten
+};
+
+class TCPIO;
+class SimpleCommunicationLinkViaSocket : public CommunicationLink
+{
+public:
+ virtual sal_Bool IsCommunicationError();
+ virtual sal_Bool StopCommunication();
+
+ virtual ByteString GetCommunicationPartner( CM_NameType eType );
+ virtual ByteString GetMyName( CM_NameType eType );
+ virtual SvStream* GetBestCommunicationStream();
+ virtual void SetApplication( const ByteString& aApp );
+
+private:
+ ByteString aCommunicationPartner;
+ ByteString aMyName;
+
+ TCPIO* pTCPIO;
+ vos::OStreamSocket *pStreamSocket;
+
+protected:
+ SimpleCommunicationLinkViaSocket( CommunicationManager *pMan, vos::OStreamSocket *pSocket );
+ virtual ~SimpleCommunicationLinkViaSocket();
+
+ vos::OStreamSocket* GetStreamSocket() { return pStreamSocket; }
+ void SetStreamSocket( vos::OStreamSocket* pSocket );
+
+ SvStream *pReceiveStream;
+ sal_Bool DoReceiveDataStream(); /// Recieve DataPacket from Socket
+ virtual sal_Bool SendHandshake( HandshakeType aHandshakeType, SvStream* pData = NULL);
+ void SetFinalRecieveTimeout();
+ sal_Bool bIsRequestShutdownPending;
+ virtual void WaitForShutdown()=0;
+ void SetNewPacketAsCurrent();
+};
+
+class SimpleCommunicationLinkViaSocketWithReceiveCallbacks : public SimpleCommunicationLinkViaSocket
+{
+public:
+ SimpleCommunicationLinkViaSocketWithReceiveCallbacks( CommunicationManager *pMan, vos::OStreamSocket *pSocket );
+ ~SimpleCommunicationLinkViaSocketWithReceiveCallbacks();
+ virtual sal_Bool ReceiveDataStream();
+protected:
+ virtual sal_Bool ShutdownCommunication(); /// Really stop the Communication
+ virtual void WaitForShutdown();
+};
+
+class CommonSocketFunctions
+{
+public:
+ sal_Bool DoStartCommunication( CommunicationManager *pCM, ICommunicationManagerClient *pCMC, ByteString aHost, sal_uLong nPort );
+protected:
+ virtual CommunicationLink *CreateCommunicationLink( CommunicationManager *pCM, vos::OConnectorSocket *pCS )=0;
+};
+
+class SingleCommunicationManagerClientViaSocket : public SingleCommunicationManager, public ICommunicationManagerClient, CommonSocketFunctions
+{
+public:
+ using CommunicationManager::StartCommunication;
+
+ SingleCommunicationManagerClientViaSocket( ByteString aHost, sal_uLong nPort, sal_Bool bUseMultiChannel = sal_False );
+ SingleCommunicationManagerClientViaSocket( sal_Bool bUseMultiChannel = sal_False );
+ virtual sal_Bool StartCommunication(){ return DoStartCommunication( this, (ICommunicationManagerClient*) this, aHostToTalk, nPortToTalk );}
+ virtual sal_Bool StartCommunication( ByteString aHost, sal_uLong nPort ){ return DoStartCommunication( this, (ICommunicationManagerClient*) this, aHost, nPort );}
+private:
+ ByteString aHostToTalk;
+ sal_uLong nPortToTalk;
+protected:
+ virtual CommunicationLink *CreateCommunicationLink( CommunicationManager *pCM, vos::OConnectorSocket *pCS ){ return new SimpleCommunicationLinkViaSocketWithReceiveCallbacks( pCM, pCS ); }
+};
+
+#endif
diff --git a/automation/inc/makefile.mk b/automation/inc/makefile.mk
new file mode 100644
index 000000000000..782b6a805b9b
--- /dev/null
+++ b/automation/inc/makefile.mk
@@ -0,0 +1,47 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+PRJ=..
+
+PRJNAME=automation
+TARGET=inc
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files --------------------------------------------------------
+# --- Targets -------------------------------------------------------
+
+.INCLUDE : target.mk
+
+.IF "$(ENABLE_PCH)"!=""
+ALLTAR : \
+ $(SLO)$/precompiled.pch \
+ $(SLO)$/precompiled_ex.pch
+
+.ENDIF # "$(ENABLE_PCH)"!=""
+
diff --git a/automation/inc/pch/precompiled_automation.cxx b/automation/inc/pch/precompiled_automation.cxx
new file mode 100644
index 000000000000..9ceb299f199c
--- /dev/null
+++ b/automation/inc/pch/precompiled_automation.cxx
@@ -0,0 +1,29 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "precompiled_automation.hxx"
+
diff --git a/automation/inc/pch/precompiled_automation.hxx b/automation/inc/pch/precompiled_automation.hxx
new file mode 100644
index 000000000000..ac38a7ce5cc8
--- /dev/null
+++ b/automation/inc/pch/precompiled_automation.hxx
@@ -0,0 +1,32 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): Generated on 2006-09-01 17:49:30.061723
+
+#ifdef PRECOMPILED_HEADERS
+#endif
+
diff --git a/automation/packimages/makefile.mk b/automation/packimages/makefile.mk
new file mode 100644
index 000000000000..928155039773
--- /dev/null
+++ b/automation/packimages/makefile.mk
@@ -0,0 +1,63 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+PRJ=..
+PRJNAME=automation
+TARGET=packimages
+RSCCUSTOMIMG*=$(PRJ)$/util
+
+# point to an existing directory as default that poses no threat
+# to a "find" that looks for "*.png"
+RSCCUSTOMIMG*=$(PRJNAME)$/util
+
+# point to an existing directory as default that poses no threat
+# to a "find" that looks for "*.png"
+RSCCUSTOMIMG*=$(PRJNAME)$/util
+
+.INCLUDE: settings.mk
+
+.INCLUDE: target.mk
+
+ALLTAR : \
+ $(subst,$(OUTPATH),$(COMMON_OUTDIR) $(BIN))$/images_tt.zip
+
+#solarenv = j:\so-cwsserv04\gh7\SRC680\src.m50\solenv
+#outpath = wntmsci10
+#common_outdir = common
+#solarresdir = j:\so-cwsserv04\gh7\SRC680\wntmsci10\res.m50
+
+
+$(subst,$(OUTPATH),$(COMMON_OUTDIR) $(BIN))$/images_tt.zip .PHONY:
+ @echo ------------------------------
+ @echo Making: $@
+ $(COPY) $(subst,$(OUTPATH),$(COMMON_OUTDIR) $(SOLARRESDIR))$/img$/stt*.ilst $(MISC)
+ $(COPY) $(subst,$(OUTPATH),$(COMMON_OUTDIR) $(SOLARRESDIR))$/img$/svt*.ilst $(MISC)
+ $(COPY) $(subst,$(OUTPATH),$(COMMON_OUTDIR) $(SOLARRESDIR))$/img$/fps*.ilst $(MISC)
+ $(COPY) $(subst,$(OUTPATH),$(COMMON_OUTDIR) $(SOLARRESDIR))$/img$/vcl*.ilst $(MISC)
+ $(COPY) $(subst,$(OUTPATH),$(COMMON_OUTDIR) $(SOLARRESDIR))$/img$/sb*.ilst $(MISC)
+ -$(MKDIR) $(subst,$(OUTPATH),$(COMMON_OUTDIR) $(BIN))
+ $(PERL) $(SOLARENV)$/bin$/packimages.pl -g $(SOLARSRC)$/$(RSCDEFIMG) -m $(SOLARSRC)$/$(RSCDEFIMG) -c $(RSCCUSTOMIMG) -l $(MISC) -o $@
+
diff --git a/automation/prj/build.lst b/automation/prj/build.lst
new file mode 100644
index 000000000000..b019873f07d9
--- /dev/null
+++ b/automation/prj/build.lst
@@ -0,0 +1,11 @@
+au automation : basic fpicker NULL
+au automation usr1 - all au_mkout NULL
+au automation\inc nmake - all au_inc NULL
+au automation\source\simplecm nmake - all au_scom au_inc NULL
+au automation\source\communi nmake - all au_comm au_inc NULL
+au automation\source\app nmake - all au_app au_inc NULL
+au automation\source\server nmake - all au_server au_inc NULL
+au automation\source\testtool nmake - all au_tt au_inc NULL
+au automation\source\miniapp nmake - all au_mini au_inc NULL
+au automation\packimages nmake - all au_pack NULL
+au automation\util nmake - all au_util au_scom au_comm au_app au_mini au_server au_tt NULL
diff --git a/automation/prj/d.lst b/automation/prj/d.lst
new file mode 100644
index 000000000000..c83a2284e34b
--- /dev/null
+++ b/automation/prj/d.lst
@@ -0,0 +1,27 @@
+mkdir: %COMMON_DEST%\bin%_EXT%\hid
+mkdir: %_DEST%\inc%_EXT%\automation
+
+#..\%COMMON_OUTDIR%\misc\*.hid %COMMON_DEST%\bin%_EXT%\hid\*.hid
+..\util\manually_added_ids.hid %COMMON_DEST%\bin%_EXT%\hid\manually_added_ids.hid
+..\%__SRC%\bin\*.dll %_DEST%\bin%_EXT%\*.dll
+..\%__SRC%\lib\lib* %_DEST%\lib%_EXT%\*
+..\%__SRC%\lib\ists.lib %_DEST%\lib%_EXT%\ists.lib
+..\%__SRC%\lib\isimplecm.lib %_DEST%\lib%_EXT%\isimplecm.lib
+..\%__SRC%\lib\icommuni.lib %_DEST%\lib%_EXT%\icommuni.lib
+
+..\inc\automation\automation.hxx %_DEST%\inc%_EXT%\automation\automation.hxx
+..\inc\automation\commdefines.hxx %_DEST%\inc%_EXT%\automation\commdefines.hxx
+..\inc\automation\commtypes.hxx %_DEST%\inc%_EXT%\automation\commtypes.hxx
+..\inc\automation\communi.hxx %_DEST%\inc%_EXT%\automation\communi.hxx
+..\inc\automation\simplecm.hxx %_DEST%\inc%_EXT%\automation\simplecm.hxx
+
+..\%__SRC%\bin\testtool.exe %_DEST%\bin%_EXT%\testtool.bin
+..\%__SRC%\bin\testtool %_DEST%\bin%_EXT%\testtool.bin
+..\%__SRC%\inc\classes %_DEST%\bin%_EXT%\classes
+..\%__SRC%\inc\keycodes %_DEST%\bin%_EXT%\keycodes
+..\%__SRC%\inc\res_type %_DEST%\bin%_EXT%\res_type
+
+..\%COMMON_OUTDIR%\bin\images_tt.zip %COMMON_DEST%\bin%_EXT%\images_tt.zip
+
+..\%__SRC%\bin\testtoolrc %_DEST%\lib%_EXT%\testtoolrc
+..\%__SRC%\bin\testtool.ini %_DEST%\bin%_EXT%\testtool.ini
diff --git a/automation/prj/l10n b/automation/prj/l10n
new file mode 100644
index 000000000000..69f0d9e5e24e
--- /dev/null
+++ b/automation/prj/l10n
@@ -0,0 +1 @@
+#i49922# In this module en-US and de are used as source language
diff --git a/automation/source/app/makefile.mk b/automation/source/app/makefile.mk
new file mode 100644
index 000000000000..8a430b3c3a96
--- /dev/null
+++ b/automation/source/app/makefile.mk
@@ -0,0 +1,52 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..
+
+PRJNAME=automation
+TARGET=app
+
+# --- Settings ------------------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Allgemein ------------------------------------------------------------
+
+CXXFILES = \
+ testbasi.cxx
+
+
+OBJFILES = \
+ $(OBJ)$/testbasi.obj
+
+
+LIBTARGET = NO
+
+
+# --- Targets ------------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/automation/source/app/testbasi.cxx b/automation/source/app/testbasi.cxx
new file mode 100644
index 000000000000..c2efb51589a4
--- /dev/null
+++ b/automation/source/app/testbasi.cxx
@@ -0,0 +1,161 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_automation.hxx"
+#include <basic/sbx.hxx>
+
+#ifndef _BASIC_TTRESHLP_HXX
+#include <basic/ttstrhlp.hxx>
+#endif
+#include <basic/testtool.hxx>
+#include "testbasi.hxx"
+//#include "app.hxx"
+//#include "basic.hrc"
+//#include "appbased.hxx"
+#define P_FEHLERLISTE TestToolObj::pFehlerListe
+
+//#include "status.hxx"
+//#include "basic.hrc"
+
+//#include "object.hxx"
+
+#include <testapp.hxx>
+#include <testtool.hxx>
+#ifndef _SB_INTERN_HXX
+//#include "sbintern.hxx"
+#endif
+
+//#include "comm_bas.hxx"
+//#include "processw.hxx"
+
+TYPEINIT1(TTBasic,MyBasic)
+
+/*class MyFactory : public SbxFactory
+{
+public:
+ virtual SbxBase* Create( sal_uInt16 nSbxId, sal_uInt32 = SBXCR_SBX );
+};
+
+static SampleObjectFac aFac1;
+static MyFactory aFac2;
+static CommunicationFactory aComManFac;
+static ProcessFactory aProcessFac;
+static short nInst = 0;
+
+SbxBase* MyFactory::Create( sal_uInt16 nSbxId, sal_uInt32 nCr )
+{
+ if( nCr == SBXCR_TEST && nSbxId == SBXID_MYBASIC )
+ return new MyBasic;
+ else
+ return NULL;
+} */
+
+TTBasic::TTBasic() : MyBasic()
+{
+// Eigenes Objekt reinbraten
+ TestToolObj* pTTO = new TestToolObj( CUniString("App"), this );
+ pTTO->SetLogHdl( GenLogHdl() );
+ pTTO->SetWinInfoHdl( GenWinInfoHdl() );
+ pTTO->SetModuleWinExistsHdl( GenModuleWinExistsHdl() );
+ pTTO->SetWriteStringHdl( GenWriteStringHdl() );
+ pTTO->SetCErrorHdl( LINK( this, TTBasic, CErrorImpl ) );
+
+ StartListeningTT( pTTO->GetTTBroadcaster() );
+
+ pTestObject = pTTO;
+ pTestObject->SetFlag( SBX_EXTSEARCH );
+ Insert( pTestObject );
+}
+
+MyBasic* TTBasic::CreateMyBasic()
+{
+ return new TTBasic();
+}
+
+void TTBasic::LoadIniFile()
+{
+ ((TestToolObj*)pTestObject)->LoadIniFile();
+}
+
+SbTextType TTBasic::GetSymbolType( const String &rSymbol, sal_Bool bWasTTControl )
+{
+ return ((TestToolObj*)pTestObject)->GetSymbolType( rSymbol, bWasTTControl );
+}
+
+
+TTBasic::~TTBasic()
+{
+}
+
+IMPL_LINK( TTBasic, CErrorImpl, ErrorEntry*, pData )
+{
+ return CError( pData->nError, pData->aText, pData->nLine, pData->nCol1, pData->nCol2 );
+}
+
+sal_Bool TTBasic::Compile( SbModule* p )
+{
+ p->SetComment( ((TestToolObj*)pTestObject)->GetRevision(p->GetSource()) );
+ SbModule* pOldModule = GetCompileModule();
+ SetCompileModule( p );
+ p->SetSource( ((TestToolObj*)pTestObject)->PreCompile(p->GetSource()) );
+ SetCompileModule( pOldModule );
+ if ( ((TestToolObj*)pTestObject)->WasPrecompilerError() )
+ return sal_False;
+ return MyBasic::Compile( p );
+}
+
+const String TTBasic::GetSpechialErrorText()
+{
+ String nErrorText;
+ if ( pTestObject && IS_ERROR() && GetErrorCode() == GET_ERROR()->nError )
+ {
+ nErrorText = GenRealString( GET_ERROR()->aText );
+ nErrorText.AppendAscii( ": " );
+ nErrorText += String::CreateFromInt64( GET_ERROR()->nError );
+ }
+ else
+ {
+ nErrorText = GetErrorText();
+ }
+ return nErrorText;
+}
+
+void TTBasic::ReportRuntimeError( AppBasEd *pEditWin )
+{
+ SbxVariableRef aDummy = new SbxVariable;
+ aDummy->SetUserData( 24 ); // ID_MaybeAddErr
+ ((TestToolObj*)pTestObject)->Notify( pTestObject->GetBroadcaster(), SbxHint( SBX_HINT_DATAWANTED, aDummy ) );
+ aDummy->SetUserData( 18 ); // ID_ExceptLog
+ ((TestToolObj*)pTestObject)->Notify( pTestObject->GetBroadcaster(), SbxHint( SBX_HINT_DATAWANTED, aDummy ) );
+ MyBasic::ReportRuntimeError( pEditWin );
+}
+
+void TTBasic::DebugFindNoErrors( sal_Bool bDebugFindNoErrors )
+{
+ ((TestToolObj*)pTestObject)->DebugFindNoErrors( bDebugFindNoErrors );
+}
diff --git a/automation/source/app/testbasi.hxx b/automation/source/app/testbasi.hxx
new file mode 100644
index 000000000000..e649dab0950b
--- /dev/null
+++ b/automation/source/app/testbasi.hxx
@@ -0,0 +1,64 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _TTBASIC_HXX
+#define _TTBASIC_HXX
+
+#include <basic/sbstar.hxx>
+#include <basic/mybasic.hxx>
+
+class ErrorEntry;
+
+#define SBXID_TTBASIC 0x5454 // TTBasic: TT
+
+#define SBXCR_TEST2 0x54534554L // TEST
+
+class TTBasic : public MyBasic
+{
+public:
+ SBX_DECL_PERSIST_NODATA(SBXCR_TEST2,SBXID_TTBASIC,1);
+ TYPEINFO();
+ TTBasic();
+ ~TTBasic();
+ sal_Bool Compile( SbModule* );
+ static MyBasic* CreateMyBasic();
+
+ // nicht mit #ifdefs klammern, da diese Headerdatei für testtool und basic
+ // gleichermaßen verwendet wird.
+ DECL_LINK( CErrorImpl, ErrorEntry* );
+// SbxObject *pTestObject; // für das Testtool; ansonsten NULL
+
+ void LoadIniFile();
+ SbTextType GetSymbolType( const String &Symbol, sal_Bool bWasTTControl ); // Besimmt den erweiterten Symboltyp für das Syntaxhighlighting
+ virtual const String GetSpechialErrorText();
+ virtual void ReportRuntimeError( AppBasEd *pEditWin );
+ virtual void DebugFindNoErrors( sal_Bool bDebugFindNoErrors );
+};
+
+SV_DECL_IMPL_REF(TTBasic)
+
+#endif
diff --git a/automation/source/communi/communi.cxx b/automation/source/communi/communi.cxx
new file mode 100644
index 000000000000..36f79bb4fa55
--- /dev/null
+++ b/automation/source/communi/communi.cxx
@@ -0,0 +1,596 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_automation.hxx"
+#include <stdio.h>
+#if OSL_DEBUG_LEVEL > 1
+#define DEBUGPRINTF(x) { printf(x); fflush( stdout ); }
+#else
+#define DEBUGPRINTF(x)
+#endif
+#include <tools/debug.hxx>
+#include <vcl/svapp.hxx>
+#include <vos/socket.hxx>
+#include <tools/stream.hxx>
+#include <vcl/timer.hxx>
+#include <tools/fsys.hxx>
+
+#include <automation/communi.hxx>
+
+
+/* Um den Destruktor protected zu machen wurde unten das delete entfernt.
+ Die Methode wird ohnehin hucht benutzt.
+// delete *((AE*)pData+n);
+*/
+
+#undef SV_IMPL_PTRARR_SORT
+#define SV_IMPL_PTRARR_SORT( nm,AE )\
+_SV_IMPL_SORTAR_ALG( nm,AE )\
+ void nm::DeleteAndDestroy( sal_uInt16 nP, sal_uInt16 nL ) { \
+ if( nL ) {\
+ DBG_ASSERT( nP < nA && nP + nL <= nA, "ERR_VAR_DEL" );\
+ for( sal_uInt16 n=nP; n < nP + nL; n++ ) \
+ DBG_ERROR("Das Element der Liste wurde nicht gelöscht"); \
+ SvPtrarr::Remove( nP, nL ); \
+ } \
+ } \
+_SV_SEEK_PTR( nm, AE )
+
+
+
+
+SV_IMPL_PTRARR_SORT( CommunicationLinkList, CommunicationLink* );
+
+vos::OMutex *pMPostUserEvent=NULL; // Notwendig, da nicht threadfest
+
+CommunicationLinkViaSocket::CommunicationLinkViaSocket( CommunicationManager *pMan, vos::OStreamSocket *pSocket )
+: SimpleCommunicationLinkViaSocket( pMan, pSocket )
+, nConnectionClosedEventId( 0 )
+, nDataReceivedEventId( 0 )
+, bShutdownStarted( sal_False )
+, bDestroying( sal_False )
+{
+ SetPutDataReceivedHdl(LINK( this, CommunicationLinkViaSocket, PutDataReceivedHdl ));
+ if ( !pMPostUserEvent )
+ pMPostUserEvent = new vos::OMutex;
+ // this is necassary to prevent the running thread from sending the close event
+ // before the open event has been sent.
+ StartCallback();
+
+ create();
+}
+
+CommunicationLinkViaSocket::~CommunicationLinkViaSocket()
+{
+ bDestroying = sal_True;
+ StopCommunication();
+ while ( nConnectionClosedEventId || nDataReceivedEventId )
+ GetpApp()->Yield();
+ {
+ vos::OGuard aGuard( aMConnectionClosed );
+ if ( nConnectionClosedEventId )
+ {
+ GetpApp()->RemoveUserEvent( nConnectionClosedEventId );
+ nConnectionClosedEventId = 0;
+ INFO_MSG( CByteString("Event gelöscht"),
+ CByteString( "ConnectionClosedEvent aus Queue gelöscht"),
+ CM_MISC, NULL );
+ }
+ }
+ {
+ vos::OGuard aGuard( aMDataReceived );
+ if ( nDataReceivedEventId )
+ {
+ GetpApp()->RemoveUserEvent( nDataReceivedEventId );
+ nDataReceivedEventId = 0;
+ delete GetServiceData();
+ INFO_MSG( CByteString("Event gelöscht"),
+ CByteString( "DataReceivedEvent aus Queue gelöscht"),
+ CM_MISC, NULL );
+ }
+ }
+}
+
+sal_Bool CommunicationLinkViaSocket::ShutdownCommunication()
+{
+ if ( isRunning() )
+ {
+
+ terminate();
+ if ( GetStreamSocket() )
+ GetStreamSocket()->shutdown();
+
+ if ( GetStreamSocket() ) // Mal wieder nach oben verschoben, da sonst nicht vom Read runtergesprungen wird.
+ GetStreamSocket()->close();
+
+ resume(); // So daß das run auch die Schleife verlassen kann
+
+ join();
+
+ vos::OStreamSocket *pTempSocket = GetStreamSocket();
+ SetStreamSocket( NULL );
+ delete pTempSocket;
+
+// ConnectionClosed(); Wird am Ende des Thread gerufen
+
+ }
+ else
+ {
+ join();
+ }
+
+ return sal_True;
+}
+
+sal_Bool CommunicationLinkViaSocket::StopCommunication()
+{
+ if ( !bShutdownStarted )
+ {
+ return SimpleCommunicationLinkViaSocket::StopCommunication();
+ }
+ else
+ {
+ WaitForShutdown();
+ return sal_True;
+ }
+}
+
+
+IMPL_LINK( CommunicationLinkViaSocket, ShutdownLink, void*, EMPTYARG )
+{
+ if ( !IsCommunicationError() )
+ ShutdownCommunication();
+ return 0;
+}
+
+
+void CommunicationLinkViaSocket::WaitForShutdown()
+{
+ if ( !bShutdownStarted )
+ {
+ aShutdownTimer.SetTimeout( 30000 ); // Should be 30 Seconds
+ aShutdownTimer.SetTimeoutHdl( LINK( this, CommunicationLinkViaSocket, ShutdownLink ) );
+ aShutdownTimer.Start();
+ bShutdownStarted = sal_True;
+ }
+ if ( bDestroying )
+ {
+ while ( pMyManager && aShutdownTimer.IsActive() )
+ {
+ if ( IsCommunicationError() )
+ return;
+ GetpApp()->Yield();
+ }
+ ShutdownCommunication();
+ }
+}
+
+sal_Bool CommunicationLinkViaSocket::IsCommunicationError()
+{
+ return !isRunning() || SimpleCommunicationLinkViaSocket::IsCommunicationError();
+}
+
+void CommunicationLinkViaSocket::run()
+{
+ sal_Bool bWasError = sal_False;
+ while ( schedule() && !bWasError && GetStreamSocket() )
+ {
+ if ( bWasError |= !DoReceiveDataStream() )
+ continue;
+
+ TimeValue sNochEins = {0, 1000000};
+ while ( schedule() && bIsInsideCallback ) // solange der letzte Callback nicht beendet ist
+ sleep( sNochEins );
+ SetNewPacketAsCurrent();
+ StartCallback();
+ {
+ vos::OGuard aGuard( aMDataReceived );
+ vos::OGuard aGuard2( *pMPostUserEvent );
+ mlPutDataReceived.Call(this);
+ }
+ }
+ TimeValue sNochEins = {0, 1000000};
+ while ( schedule() && bIsInsideCallback ) // solange der letzte Callback nicht beendet ist
+ sleep( sNochEins );
+
+ StartCallback();
+ {
+ vos::OGuard aGuard( aMConnectionClosed );
+ vos::OGuard aGuard2( *pMPostUserEvent );
+ nConnectionClosedEventId = GetpApp()->PostUserEvent( LINK( this, CommunicationLinkViaSocket, ConnectionClosed ) );
+ }
+}
+
+sal_Bool CommunicationLinkViaSocket::DoTransferDataStream( SvStream *pDataStream, CMProtocol nProtocol )
+{
+ if ( !isRunning() )
+ return sal_False;
+
+ return SimpleCommunicationLinkViaSocket::DoTransferDataStream( pDataStream, nProtocol );
+}
+
+/// Dies ist ein virtueller Link!!!
+long CommunicationLinkViaSocket::ConnectionClosed( void* EMPTYARG )
+{
+ {
+ vos::OGuard aGuard( aMConnectionClosed );
+ nConnectionClosedEventId = 0; // Achtung!! alles andere muß oben gemacht werden.
+ }
+ ShutdownCommunication();
+ return CommunicationLink::ConnectionClosed( );
+}
+
+/// Dies ist ein virtueller Link!!!
+long CommunicationLinkViaSocket::DataReceived( void* EMPTYARG )
+{
+ {
+ vos::OGuard aGuard( aMDataReceived );
+ nDataReceivedEventId = 0; // Achtung!! alles andere muß oben gemacht werden.
+ }
+ return CommunicationLink::DataReceived( );
+}
+
+IMPL_LINK( CommunicationLinkViaSocket, PutDataReceivedHdl, CommunicationLinkViaSocket*, EMPTYARG )
+{
+ nDataReceivedEventId = GetpApp()->PostUserEvent( LINK( this, CommunicationLink, DataReceived ) );
+ return 0;
+}
+
+
+
+MultiCommunicationManager::MultiCommunicationManager( sal_Bool bUseMultiChannel )
+: CommunicationManager( bUseMultiChannel )
+, bGracefullShutdown( sal_True )
+{
+ ActiveLinks = new CommunicationLinkList;
+ InactiveLinks = new CommunicationLinkList;
+}
+
+MultiCommunicationManager::~MultiCommunicationManager()
+{
+ StopCommunication();
+
+ if ( bGracefullShutdown ) // first try to collect all callbacks for closing channels
+ {
+ Timer aTimeout;
+ aTimeout.SetTimeout( 40000 );
+ aTimeout.Start();
+ sal_uInt16 nLinkCount = 0;
+ sal_uInt16 nNewLinkCount = 0;
+ while ( aTimeout.IsActive() )
+ {
+ GetpApp()->Yield();
+ nNewLinkCount = GetCommunicationLinkCount();
+ if ( nNewLinkCount == 0 )
+ aTimeout.Stop();
+ if ( nNewLinkCount != nLinkCount )
+ {
+ aTimeout.Start();
+ nLinkCount = nNewLinkCount;
+ }
+ }
+ }
+
+ // Alles weghauen, was nicht rechtzeitig auf die Bäume gekommen ist
+ // Was bei StopCommunication übrig geblieben ist, da es sich asynchron austragen wollte
+ sal_uInt16 i = ActiveLinks->Count();
+ while ( i-- )
+ {
+ CommunicationLinkRef rTempLink = ActiveLinks->GetObject( i );
+ ActiveLinks->Remove( i );
+ rTempLink->InvalidateManager();
+ rTempLink->ReleaseReference();
+ }
+ delete ActiveLinks;
+
+ /// Die Links zwischen ConnectionClosed und Destruktor.
+ /// Hier NICHT gerefcounted, da sie sich sonst im Kreis festhaten würden,
+ /// da die Links sich erst in ihrem Destruktor austragen
+ i = InactiveLinks->Count();
+ while ( i-- )
+ {
+ CommunicationLinkRef rTempLink = InactiveLinks->GetObject( i );
+ InactiveLinks->Remove( i );
+ rTempLink->InvalidateManager();
+ }
+ delete InactiveLinks;
+}
+
+sal_Bool MultiCommunicationManager::StopCommunication()
+{
+ // Alle Verbindungen abbrechen
+ // ConnectionClosed entfernt die Links aus der Liste. Je nach Implementation syncron
+ // oder asyncron. Daher Von oben nach unten Abräumen, so daß sich nichts verschiebt.
+ sal_uInt16 i = ActiveLinks->Count();
+ int nFail = 0;
+ while ( i )
+ {
+ if ( !ActiveLinks->GetObject(i-1)->StopCommunication() )
+ nFail++; // Hochzählen, da Verbindung sich nicht (sofort) beenden lässt.
+ i--;
+ }
+
+ return nFail == 0;
+}
+
+sal_Bool MultiCommunicationManager::IsLinkValid( CommunicationLink* pCL )
+{
+ if ( ActiveLinks->Seek_Entry( pCL ) )
+ return sal_True;
+ else
+ return sal_False;
+}
+
+sal_uInt16 MultiCommunicationManager::GetCommunicationLinkCount()
+{
+ return ActiveLinks->Count();
+}
+
+CommunicationLinkRef MultiCommunicationManager::GetCommunicationLink( sal_uInt16 nNr )
+{
+ return ActiveLinks->GetObject( nNr );
+}
+
+void MultiCommunicationManager::CallConnectionOpened( CommunicationLink* pCL )
+{
+ CommunicationLinkRef rHold(pCL); // Hält den Zeiger bis zum Ende des calls
+ ActiveLinks->C40_PTR_INSERT(CommunicationLink, pCL);
+ rHold->AddRef();
+
+ CommunicationManager::CallConnectionOpened( pCL );
+}
+
+void MultiCommunicationManager::CallConnectionClosed( CommunicationLink* pCL )
+{
+ CommunicationLinkRef rHold(pCL); // Hält denm Zeiger bis zum Ende des calls
+
+ CommunicationManager::CallConnectionClosed( pCL );
+
+ sal_uInt16 nPos;
+ if ( ActiveLinks->Seek_Entry( pCL, &nPos ) )
+ {
+ InactiveLinks->C40_PTR_INSERT(CommunicationLink, pCL); // Ohne Reference
+ ActiveLinks->Remove( nPos );
+ }
+ pCL->ReleaseReference();
+
+ bIsCommunicationRunning = ActiveLinks->Count() > 0;
+// delete pCL;
+#if OSL_DEBUG_LEVEL > 1
+ rHold->bFlag = sal_True;
+#endif
+}
+
+void MultiCommunicationManager::DestroyingLink( CommunicationLink *pCL )
+{
+ sal_uInt16 nPos;
+ if ( InactiveLinks->Seek_Entry( pCL, &nPos ) )
+ InactiveLinks->Remove( nPos );
+ pCL->InvalidateManager();
+}
+
+
+
+CommunicationManagerClient::CommunicationManagerClient( sal_Bool bUseMultiChannel )
+: MultiCommunicationManager( bUseMultiChannel )
+{
+ ByteString aApplication("Something inside ");
+ aApplication.Append( ByteString( DirEntry( Application::GetAppFileName() ).GetName(), gsl_getSystemTextEncoding() ) );
+ SetApplication( aApplication );
+}
+
+
+
+CommunicationManagerServerViaSocket::CommunicationManagerServerViaSocket( sal_uLong nPort, sal_uInt16 nMaxCon, sal_Bool bUseMultiChannel )
+: CommunicationManagerServer( bUseMultiChannel )
+, nPortToListen( nPort )
+, nMaxConnections( nMaxCon )
+, pAcceptThread( NULL )
+{
+}
+
+CommunicationManagerServerViaSocket::~CommunicationManagerServerViaSocket()
+{
+ StopCommunication();
+}
+
+sal_Bool CommunicationManagerServerViaSocket::StartCommunication()
+{
+ if ( !pAcceptThread )
+ pAcceptThread = new CommunicationManagerServerAcceptThread( this, nPortToListen, nMaxConnections );
+ return sal_True;
+}
+
+
+sal_Bool CommunicationManagerServerViaSocket::StopCommunication()
+{
+ // Erst den Acceptor anhalten
+ delete pAcceptThread;
+ pAcceptThread = NULL;
+
+ // Dann alle Verbindungen kappen
+ return CommunicationManagerServer::StopCommunication();
+}
+
+
+void CommunicationManagerServerViaSocket::AddConnection( CommunicationLink *pNewConnection )
+{
+ CallConnectionOpened( pNewConnection );
+}
+
+
+CommunicationManagerServerAcceptThread::CommunicationManagerServerAcceptThread( CommunicationManagerServerViaSocket* pServer, sal_uLong nPort, sal_uInt16 nMaxCon )
+: pMyServer( pServer )
+, pAcceptorSocket( NULL )
+, nPortToListen( nPort )
+, nMaxConnections( nMaxCon )
+, nAddConnectionEventId( 0 )
+, xmNewConnection( NULL )
+{
+ if ( !pMPostUserEvent )
+ pMPostUserEvent = new vos::OMutex;
+ create();
+}
+
+
+CommunicationManagerServerAcceptThread::~CommunicationManagerServerAcceptThread()
+{
+#ifndef aUNX // Weil das Accept nicht abgebrochen werden kann, so terminiert wenigstens das Prog
+ // #62855# pl: gilt auch bei anderen Unixen
+ // die richtige Loesung waere natuerlich, etwas auf die pipe zu schreiben,
+ // was der thread als Abbruchbedingung erkennt
+ // oder wenigstens ein kill anstatt join
+ terminate();
+ if ( pAcceptorSocket )
+ pAcceptorSocket->close(); // Dann das Accept unterbrechen
+
+ join(); // Warten bis fertig
+
+ if ( pAcceptorSocket )
+ {
+ delete pAcceptorSocket;
+ pAcceptorSocket = NULL;
+ }
+#else
+ DEBUGPRINTF ("Destructor CommunicationManagerServerAcceptThread Übersprungen!!!! (wegen Solaris BUG)\n");
+#endif
+ {
+ vos::OGuard aGuard( aMAddConnection );
+ if ( nAddConnectionEventId )
+ {
+ GetpApp()->RemoveUserEvent( nAddConnectionEventId );
+ nAddConnectionEventId = 0;
+ CommunicationLinkRef xNewConnection = GetNewConnection();
+ INFO_MSG( CByteString("Event gelöscht"),
+ CByteString( "AddConnectionEvent aus Queue gelöscht"),
+ CM_MISC, xNewConnection );
+ xNewConnection->InvalidateManager();
+ xNewConnection.Clear(); // sollte das Objekt hier löschen
+ }
+ }
+}
+
+void CommunicationManagerServerAcceptThread::run()
+{
+ if ( !nPortToListen )
+ return;
+
+ pAcceptorSocket = new vos::OAcceptorSocket();
+ vos::OInetSocketAddr Addr;
+ Addr.setPort( nPortToListen );
+ pAcceptorSocket->setReuseAddr( 1 );
+ if ( !pAcceptorSocket->bind( Addr ) )
+ {
+ return;
+ }
+ if ( !pAcceptorSocket->listen( nMaxConnections ) )
+ {
+ return;
+ }
+
+
+ vos::OStreamSocket *pStreamSocket = NULL;
+
+ while ( schedule() )
+ {
+ pStreamSocket = new vos::OStreamSocket;
+ switch ( pAcceptorSocket->acceptConnection( *pStreamSocket ) )
+ {
+ case vos::ISocketTypes::TResult_Ok:
+ {
+ pStreamSocket->setTcpNoDelay( 1 );
+
+ TimeValue sNochEins = {0, 100};
+ while ( schedule() && xmNewConnection.Is() ) // Solange die letzte Connection nicht abgeholt wurde warten wir
+ sleep( sNochEins );
+ xmNewConnection = new CommunicationLinkViaSocket( pMyServer, pStreamSocket );
+ xmNewConnection->StartCallback();
+ {
+ vos::OGuard aGuard( aMAddConnection );
+ vos::OGuard aGuard2( *pMPostUserEvent );
+ nAddConnectionEventId = GetpApp()->PostUserEvent( LINK( this, CommunicationManagerServerAcceptThread, AddConnection ) );
+ }
+ }
+ break;
+ case vos::ISocketTypes::TResult_TimedOut:
+ delete pStreamSocket;
+ pStreamSocket = NULL;
+ break;
+ case vos::ISocketTypes::TResult_Error:
+ delete pStreamSocket;
+ pStreamSocket = NULL;
+ break;
+
+ case vos::ISocketTypes::TResult_Interrupted:
+ case vos::ISocketTypes::TResult_InProgress:
+ break; // -Wall not handled...
+ }
+ }
+}
+
+
+IMPL_LINK( CommunicationManagerServerAcceptThread, AddConnection, void*, EMPTYARG )
+{
+ {
+ vos::OGuard aGuard( aMAddConnection );
+ nAddConnectionEventId = 0;
+ }
+ pMyServer->AddConnection( xmNewConnection );
+ xmNewConnection.Clear();
+ return 1;
+}
+
+
+#define GETSET(aVar, KeyName, Dafault) \
+ aVar = aConf.ReadKey(KeyName,"No Entry"); \
+ if ( aVar == "No Entry" ) \
+ { \
+ aVar = Dafault; \
+ aConf.WriteKey(KeyName, aVar); \
+ }
+
+
+CommunicationManagerClientViaSocket::CommunicationManagerClientViaSocket( ByteString aHost, sal_uLong nPort, sal_Bool bUseMultiChannel )
+: CommunicationManagerClient( bUseMultiChannel )
+, aHostToTalk( aHost )
+, nPortToTalk( nPort )
+{
+}
+
+CommunicationManagerClientViaSocket::CommunicationManagerClientViaSocket( sal_Bool bUseMultiChannel )
+: CommunicationManagerClient( bUseMultiChannel )
+, aHostToTalk( "" )
+, nPortToTalk( 0 )
+{
+}
+
+CommunicationManagerClientViaSocket::~CommunicationManagerClientViaSocket()
+{
+}
+
+
diff --git a/automation/source/communi/makefile.mk b/automation/source/communi/makefile.mk
new file mode 100644
index 000000000000..1d01badab455
--- /dev/null
+++ b/automation/source/communi/makefile.mk
@@ -0,0 +1,44 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..
+
+PRJNAME=automation
+TARGET=communi
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files --------------------------------------------------------
+
+SLOFILES= \
+ $(SLO)$/communi.obj
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/automation/source/inc/cmdbasestream.hxx b/automation/source/inc/cmdbasestream.hxx
new file mode 100644
index 000000000000..408492cd8ac9
--- /dev/null
+++ b/automation/source/inc/cmdbasestream.hxx
@@ -0,0 +1,90 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+/*************************************************************************
+ *
+ * ATTENTION
+ * This file is intended to work inside and outside the StarOffice environment.
+ * Only adaption of file commtypes.hxx should be necessary. Else it is a bug!
+ *
+ ************************************************************************/
+
+#ifndef _CMDBASESTREAM_HXX_
+#define _CMDBASESTREAM_HXX_
+
+#include <automation/commtypes.hxx>
+#include "icommstream.hxx"
+
+class CmdBaseStream
+{
+protected:
+ ICommStream* pCommStream;
+ CmdBaseStream();
+ virtual ~CmdBaseStream();
+
+public:
+
+ void GenError( rtl::OString *pUId, comm_String *pString );
+
+ void GenReturn( comm_USHORT nRet, comm_ULONG nNr );
+ void GenReturn( comm_USHORT nRet, rtl::OString *pUId, comm_ULONG nNr );
+ void GenReturn( comm_USHORT nRet, rtl::OString *pUId, comm_String *pString );
+ void GenReturn( comm_USHORT nRet, rtl::OString *pUId, comm_BOOL bBool );
+ void GenReturn( comm_USHORT nRet, rtl::OString *pUId, comm_ULONG nNr, comm_String *pString, comm_BOOL bBool );
+
+ void GenReturn( comm_USHORT nRet, comm_USHORT nMethod, comm_ULONG nNr );
+ void GenReturn( comm_USHORT nRet, comm_USHORT nMethod, comm_String *pString );
+ void GenReturn( comm_USHORT nRet, comm_USHORT nMethod, comm_BOOL bBool );
+ void GenReturn( comm_USHORT nRet, comm_USHORT nMethod, comm_USHORT nNr );
+
+// MacroRecorder
+ void GenReturn( comm_USHORT nRet, rtl::OString *pUId, comm_USHORT nMethod ); // also used outside MacroRecorder
+ void GenReturn( comm_USHORT nRet, rtl::OString *pUId, comm_USHORT nMethod, comm_String *pString );
+ void GenReturn( comm_USHORT nRet, rtl::OString *pUId, comm_USHORT nMethod, comm_String *pString, comm_BOOL bBool );
+ void GenReturn( comm_USHORT nRet, rtl::OString *pUId, comm_USHORT nMethod, comm_BOOL bBool );
+ void GenReturn( comm_USHORT nRet, rtl::OString *pUId, comm_USHORT nMethod, comm_ULONG nNr );
+
+ void Read ( comm_USHORT &nNr );
+ void Read ( comm_ULONG &nNr );
+ void Read (comm_UniChar* &aString, comm_USHORT &nLenInChars );
+ void Read ( comm_BOOL &bBool );
+ comm_USHORT GetNextType();
+
+ void Write( comm_USHORT nNr );
+ void Write( comm_ULONG nNr );
+ void Write( const comm_UniChar* aString, comm_USHORT nLenInChars );
+ void Write( comm_BOOL bBool );
+
+// Complex Datatypes to be handled system dependent
+ virtual void Read ( comm_String *&pString );
+ virtual void Read ( rtl::OString* &pId );
+
+ virtual void Write( comm_String *pString );
+ virtual void Write( rtl::OString* pId );
+};
+
+#endif
diff --git a/automation/source/inc/icommstream.hxx b/automation/source/inc/icommstream.hxx
new file mode 100644
index 000000000000..efc1315bc9b1
--- /dev/null
+++ b/automation/source/inc/icommstream.hxx
@@ -0,0 +1,64 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+/*************************************************************************
+ *
+ * ATTENTION
+ * This file is intended to work inside and outside the StarOffice environment.
+ * Only adaption of file commtypes.hxx should be necessary. Else it is a bug!
+ *
+ ************************************************************************/
+
+#ifndef _AUTOMATION_ICOMMSTREAM_HXX_
+#define _AUTOMATION_ICOMMSTREAM_HXX_
+
+#include <automation/commtypes.hxx>
+
+class ICommStream
+{
+public:
+
+ ICommStream(){}
+ virtual ~ICommStream(){}
+
+ virtual ICommStream& operator>>( comm_USHORT& rUShort )=0;
+ virtual ICommStream& operator>>( comm_ULONG& rULong )=0;
+ virtual ICommStream& operator>>( comm_BOOL& rChar )=0;
+
+ virtual ICommStream& operator<<( comm_USHORT nUShort )=0;
+ virtual ICommStream& operator<<( comm_ULONG nULong )=0;
+ virtual ICommStream& operator<<( comm_BOOL nChar )=0;
+
+ virtual comm_ULONG Read( void* pData, comm_ULONG nSize )=0;
+ virtual comm_ULONG Write( const void* pData, comm_ULONG nSize )=0;
+
+ virtual comm_BOOL IsEof() const=0;
+ virtual comm_ULONG SeekRel( long nPos )=0;
+
+};
+
+#endif
diff --git a/automation/source/inc/rcontrol.hxx b/automation/source/inc/rcontrol.hxx
new file mode 100644
index 000000000000..cf13fdadd469
--- /dev/null
+++ b/automation/source/inc/rcontrol.hxx
@@ -0,0 +1,496 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+/*************************************************************************
+ *
+ * ATTENTION
+ * This file is intended to work inside and outside the StarOffice environment.
+ * Only adaption of file commtypes.hxx should be necessary. Else it is a bug!
+ *
+ ************************************************************************/
+
+#ifndef _RCONTROL_HXX
+#define _RCONTROL_HXX
+
+
+#define UID_ACTIVE "UID_ACTIVE"
+
+
+#define SI_IPCCommandBlock 1
+#define SI_SocketCommandBlock SI_IPCCommandBlock // Zumindest erstmal
+#define SI_DirectCommandBlock 2
+#define SIControl 3 // remove after numeric HelpIDs are completely removed and no legacy testtool is used anymore
+#define SISlot 4
+#define SIFlow 5
+#define SICommand 6
+#define SIUnoSlot 7
+#define SIStringControl 8
+
+#define SIReturnBlock 11
+#define SIReturn 12
+#define SIReturnError 13
+
+// Typisierung im Stream
+#define BinUSHORT 11
+#define BinULONG 14
+#define BinString 12
+#define BinBool 13
+#define BinSbxValue 15
+
+
+// Classes
+// !!!Diese Defines duerfen niemals geaendert werden!!!
+#define C_NoType -1
+// Maximale 32 einfache Controls
+#define C_TabControl 0
+#define C_RadioButton 1
+#define C_CheckBox 2
+#define C_TriStateBox 3
+#define C_Edit 4
+#define C_MultiLineEdit 5
+#define C_MultiListBox 6
+#define C_ListBox 7
+#define C_ComboBox 8
+#define C_PushButton 9
+
+#define C_SpinField 10
+#define C_PatternField 11
+#define C_NumericField 12
+#define C_MetricField 13
+#define C_CurrencyField 14
+#define C_DateField 15
+#define C_TimeField 16
+
+#define C_ImageRadioButton 17
+#define C_NumericBox 18
+#define C_MetricBox 19
+#define C_CurrencyBox 20
+#define C_DateBox 21
+#define C_TimeBox 22
+
+#define C_ImageButton 23
+#define C_MenuButton 24
+#define C_MoreButton 25
+
+// Maximale 7 Container
+#define C_TabPage 32
+#define C_ModalDlg 33
+#define C_FloatWin 34
+#define C_ModelessDlg 35
+#define C_WorkWin 36
+#define C_DockingWin 37
+
+// Diese Defines koennen geaendert werden
+#define C_MessBox 40
+#define C_InfoBox 41
+#define C_WarningBox 42
+#define C_ErrorBox 43
+#define C_QueryBox 44
+
+#define C_TabDlg 45
+#define C_SingleTabDlg 46
+
+#define C_Window 47
+
+
+#define C_PatternBox 60
+#define C_ToolBox 61
+#define C_ValueSet 62
+#define C_Control 63
+#define C_TreeListBox 64 // Hurray the TreeListBox finally got its own Window Type
+
+#define C_OkButton 65
+#define C_CancelButton 66
+#define C_ButtonDialog 67
+
+#define C_Dialog 68
+
+
+
+
+#define M_WITH_RETURN 0x0200 // Die Variable wird zum Aufnehmen des Wertes gespeichert
+#define M_KEY_STRING 0x0400 // Key Befehle werden umgewandelt i.e. "<return><up>"
+#define M_SOFFICE 0x0800 // Command valid for Star/Open Office
+#define M_MOZILLA 0x1000 // Command valid for Mozilla
+// for MacroRecorder
+#define M_RET_NUM_CONTROL 0x2000 // decode ULong as Control (For Tabpages, Toolboxes, ... )
+
+// Methoden
+#define M_Select 21
+#define M_SetNoSelection 22
+#define M_SetText 23
+#define M_More 24
+#define M_Less 25
+#define M_ToMin 26
+#define M_ToMax 27
+#define M_Check 28
+#define M_UnCheck 29
+#define M_TriState 30
+#define M_SetPage 31
+#define M_Click 32
+
+#define M_Close 33 // Push Buttons on Dialog (Auch More Button)
+#define M_Cancel 34
+#define M_OK 35
+#define M_Help 36
+#define M_Default 37 // Push defaultbutton on Dialog
+
+#define M_Yes 38
+#define M_No 39
+#define M_Repeat 40
+
+#define M_Open 41
+#define M_Pick 42
+#define M_Move 43
+#define M_Size 44
+#define M_Minimize 45
+#define M_Maximize 46
+#define M_Dock 47
+#define M_Undock 48
+
+
+
+#define M_TypeKeys ( M_KEY_STRING | 50 )
+#define M_MouseDown 51
+#define M_MouseUp 52
+#define M_MouseMove 53
+#define M_MouseDoubleClick 54
+#define M_SnapShot 55
+#define M_SetNextToolBox 56
+#define M_OpenContextMenu 57
+#define M_MultiSelect 58
+
+// Filedialog
+#define M_SetPath 60
+#define M_SetCurFilter 61
+
+// Printdialog
+#define M_SetPrinter 70
+#define M_CheckRange 71
+#define M_SetRangeText 72
+#define M_SetFirstPage 73
+#define M_SetLastPage 74
+#define M_CheckCollate 75
+#define M_SetPageId 76
+#define M_SetPageNr 77
+
+#define M_AnimateMouse 78
+#define M_TearOff 79
+
+#define M_FadeIn 80
+#define M_FadeOut 81
+#define M_Pin 82
+
+#define M_UseMenu 83 // Use the menu of the next possible parent of given Window
+
+#define M_OpenMenu 84 // MenuButtons and Menus in ToolBoxes
+
+#define M_Restore 85 // Window Control together with M_Maximize and M_Minimize
+
+#define M_DisplayPercent 200 // Zum Anzeigen der Prozente des Windows
+
+#define M_LAST_NO_RETURN 200
+
+#if ( M_LAST_NO_RETURN >= M_WITH_RETURN )
+#error "Bereich überschritten"
+#endif
+
+#define M_Exists ( M_WITH_RETURN | 1 )
+#define M_NotExists ( M_WITH_RETURN | 2 )
+#define M_IsEnabled ( M_WITH_RETURN | 3 )
+#define M_IsVisible ( M_WITH_RETURN | 4 )
+#define M_IsWritable ( M_WITH_RETURN | 5 )
+
+#define M_GetPage ( M_WITH_RETURN | 6 )
+#define M_IsChecked ( M_WITH_RETURN | 7 )
+#define M_IsTristate ( M_WITH_RETURN | 8 )
+#define M_GetState ( M_WITH_RETURN | 9 )
+#define M_GetText ( M_WITH_RETURN | 10 )
+#define M_GetSelCount ( M_WITH_RETURN | 11 )
+#define M_GetSelIndex ( M_WITH_RETURN | 12 )
+#define M_GetSelText ( M_WITH_RETURN | 13 )
+#define M_GetItemCount ( M_WITH_RETURN | 14 )
+#define M_GetItemText ( M_WITH_RETURN | 15 )
+#define M_IsOpen ( M_WITH_RETURN | 16 )
+#define M_Caption ( M_WITH_RETURN | 17 )
+#define M_IsMax ( M_WITH_RETURN | 18 )
+#define M_IsDocked ( M_WITH_RETURN | 19 )
+#define M_GetRT ( M_WITH_RETURN | 20 )
+#define M_GetPageId ( M_WITH_RETURN | 21 )
+#define M_GetPageCount ( M_WITH_RETURN | 22 )
+#define M_GetPosX ( M_WITH_RETURN | 23 )
+#define M_GetPosY ( M_WITH_RETURN | 24 )
+#define M_GetSizeX ( M_WITH_RETURN | 25 )
+#define M_GetSizeY ( M_WITH_RETURN | 26 )
+#define M_GetNextToolBox ( M_WITH_RETURN | 27 )
+#define M_GetButtonCount ( M_WITH_RETURN | 28 )
+#define M_GetButtonId ( M_WITH_RETURN | 29 )
+
+#define M_IsFadeIn ( M_WITH_RETURN | 30 )
+#define M_IsPin ( M_WITH_RETURN | 31 )
+
+// Statusbar
+#define M_StatusGetText ( M_WITH_RETURN | 32 )
+#define M_StatusIsProgress ( M_WITH_RETURN | 33 )
+#define M_StatusGetItemCount ( M_WITH_RETURN | 34 )
+#define M_StatusGetItemId ( M_WITH_RETURN | 35 )
+
+//
+#define M_GetMouseStyle ( M_WITH_RETURN | 36 )
+
+// support for Messagebox with checkbox
+#define M_GetCheckBoxText ( M_WITH_RETURN | 37 )
+
+// Scrollbars
+#define M_HasScrollBar ( M_WITH_RETURN | 38 )
+#define M_IsScrollBarEnabled ( M_WITH_RETURN | 39 )
+
+// Dieser befehl wird nur intern im Controller (sts library) verwendet. Sie tauchen nicht im Testtool auf!
+#define _M_IsEnabled ( M_WITH_RETURN | 50 )
+
+
+#define M_GetFixedTextCount ( M_WITH_RETURN | 51 )
+#define M_GetFixedText ( M_WITH_RETURN | 52 )
+
+
+#define M_IsMin ( M_WITH_RETURN | 53 )
+#define M_IsRestore ( M_WITH_RETURN | 54 )
+
+#define M_GetItemType ( M_WITH_RETURN | 55 )
+
+// Commands for (Edit)BrowseBox
+#define M_GetColumnCount ( M_WITH_RETURN | 56 )
+#define M_GetRowCount ( M_WITH_RETURN | 57 )
+#define M_IsEditing ( M_WITH_RETURN | 58 )
+
+#define M_IsItemEnabled ( M_WITH_RETURN | 59 )
+
+//#define M_SOFFICE 0x0800 // Command valid for Star/Open Office
+//#define M_MOZILLA 0x1000 // Command valid for Mozilla
+
+
+// RemoteCommands
+#define RC_AppAbort ( M_SOFFICE | M_MOZILLA | 1 )
+#define RC_SetClipboard ( M_SOFFICE | M_MOZILLA | 2 )
+#define RC_NoDebug ( M_SOFFICE | M_MOZILLA | 3 )
+#define RC_Debug ( M_SOFFICE | M_MOZILLA | 4 )
+#define RC_GPF ( M_SOFFICE | M_MOZILLA | 5 )
+#define RC_DisplayHid ( M_SOFFICE | M_MOZILLA | 6 )
+#define RC_AppDelay ( M_SOFFICE | M_MOZILLA | 7 )
+#define RC_UseBindings ( M_SOFFICE | 8 )
+#define RC_Profile ( M_SOFFICE | M_MOZILLA | 9 )
+// (Popup)Menu
+#define RC_MenuSelect ( M_SOFFICE | M_MOZILLA | 10 )
+#define RC_SetControlType ( M_SOFFICE | 11 ) // deprecated since RTTI
+// RemoteFileAccess
+#define RC_Kill ( M_SOFFICE | 12 )
+#define RC_RmDir ( M_SOFFICE | 13 )
+#define RC_MkDir ( M_SOFFICE | 14 )
+#define RC_FileCopy ( M_SOFFICE | 15 )
+#define RC_Name ( M_SOFFICE | 16 )
+
+#define RC_CaptureAssertions (M_SOFFICE | M_MOZILLA | 17 )
+#define RC_Assert ( M_SOFFICE | M_MOZILLA | 18 )
+
+#define RC_MenuOpen ( M_SOFFICE | M_MOZILLA | 19 )
+
+#define RC_TypeKeysDelay ( M_SOFFICE | M_MOZILLA | 20 )
+
+#define RC_ShowBar ( M_MOZILLA | 21 )
+
+#define RC_LoadURL ( M_MOZILLA | 22 )
+
+#define RC_CloseSysDialog ( M_SOFFICE | 23 )
+
+#define RC_SAXRelease ( M_SOFFICE | 24 )
+
+#define RC_RecordMacro ( M_SOFFICE | 25 )
+
+#define RC_ActivateDocument ( M_SOFFICE | 26 )
+
+#define RC_CatchGPF ( M_SOFFICE | 27 )
+
+#define _RC_LAST_NO_RETURN 27
+
+#if ( _RC_LAST_NO_RETURN >= M_WITH_RETURN )
+#error "Bereich überschritten"
+#endif
+
+// Befehle mit Returnwert
+#define RC_GetClipboard ( M_SOFFICE | M_MOZILLA | M_WITH_RETURN | 1 )
+#define RC_WinTree ( M_SOFFICE | M_MOZILLA | M_WITH_RETURN | 2 )
+#define RC_ResetApplication ( M_SOFFICE | M_MOZILLA | M_WITH_RETURN | 3 )
+#define RC_GetNextCloseWindow ( M_SOFFICE | M_WITH_RETURN | 4 )
+#define RC_ApplicationBusy ( M_SOFFICE | M_MOZILLA | M_WITH_RETURN | 5 )
+// (Popup)Menu
+#define RC_MenuGetItemCount ( M_SOFFICE | M_MOZILLA | M_WITH_RETURN | 6 )
+#define RC_MenuGetItemId ( M_SOFFICE | M_MOZILLA | M_WITH_RETURN | 7 )
+#define RC_MenuGetItemPos ( M_SOFFICE | M_MOZILLA | M_WITH_RETURN | 8 )
+#define RC_MenuIsSeperator ( M_SOFFICE | M_MOZILLA | M_WITH_RETURN | 9 )
+#define RC_MenuIsItemChecked ( M_SOFFICE | M_MOZILLA | M_WITH_RETURN | 10 )
+#define RC_MenuIsItemEnabled ( M_SOFFICE | M_MOZILLA | M_WITH_RETURN | 11 )
+#define RC_MenuGetItemText ( M_SOFFICE | M_MOZILLA | M_WITH_RETURN | 12 )
+// RemoteFileAccess
+#define RC_Dir ( M_SOFFICE | M_WITH_RETURN | 18 )
+#define RC_FileLen ( M_SOFFICE | M_WITH_RETURN | 19 )
+#define RC_FileDateTime ( M_SOFFICE | M_WITH_RETURN | 20 )
+
+#define RC_Translate ( M_SOFFICE | M_MOZILLA | M_WITH_RETURN | 21 )
+#define RC_GetMouseStyle ( M_SOFFICE | M_MOZILLA | M_WITH_RETURN | 22 )
+#define RC_UnpackStorage ( M_SOFFICE | M_WITH_RETURN | 23 )
+
+#define RC_IsBarVisible ( M_MOZILLA | M_WITH_RETURN | 24 )
+
+#define RC_MenuGetItemCommand ( M_SOFFICE | M_MOZILLA | M_WITH_RETURN | 25 )
+
+#define RC_ExistsSysDialog ( M_SOFFICE | M_WITH_RETURN | 26 )
+
+#define RC_SAXCheckWellformed ( M_SOFFICE | M_WITH_RETURN | 27 )
+#define RC_SAXReadFile ( M_SOFFICE | M_WITH_RETURN | 28 )
+
+#define RC_SAXGetNodeType ( M_SOFFICE | M_WITH_RETURN | 29 )
+#define RC_SAXGetElementName ( M_SOFFICE | M_WITH_RETURN | 30 )
+#define RC_SAXGetChars ( M_SOFFICE | M_WITH_RETURN | 31 )
+#define RC_SAXGetChildCount ( M_SOFFICE | M_WITH_RETURN | 32 )
+#define RC_SAXGetAttributeCount ( M_SOFFICE | M_WITH_RETURN | 33 )
+#define RC_SAXGetAttributeName ( M_SOFFICE | M_WITH_RETURN | 34 )
+#define RC_SAXGetAttributeValue ( M_SOFFICE | M_WITH_RETURN | 35 )
+#define RC_SAXSeekElement ( M_SOFFICE | M_WITH_RETURN | 36 )
+#define RC_SAXHasElement ( M_SOFFICE | M_WITH_RETURN | 37 )
+#define RC_SAXGetElementPath ( M_SOFFICE | M_WITH_RETURN | 38 )
+
+#define RC_GetDocumentCount ( M_SOFFICE | M_WITH_RETURN | 39 )
+
+#define RC_GetSystemLanguage ( M_SOFFICE | M_WITH_RETURN | 40 )
+
+#define RC_IsProduct ( M_SOFFICE | M_WITH_RETURN | 41 )
+
+#define RC_MenuHasSubMenu ( M_SOFFICE | M_WITH_RETURN | 42 )
+
+#define RC_UsePostEvents ( M_SOFFICE | M_WITH_RETURN | 43 )
+
+#define RC_WaitSlot ( M_SOFFICE | M_WITH_RETURN | 44 )
+
+// Flow Control
+#define F_EndCommandBlock 101 // Initiiert Rückmeldung des Status
+#define F_Sequence 102 // Übergibt Sequence Nummer (1. in jedem Stream)
+
+// Return codes
+#define RET_Sequence 132 // Übergibt Sequence Nummer (1. in jedem Stream)
+#define RET_Value 133 // Übergibt Return-wert
+#define RET_WinInfo 134 // Information über aktuelles Fenster/Control
+#define RET_ProfileInfo 135 // Profile Information
+#define RET_DirectLoging 136 // Direktes Übertragen von Informationen in das Log
+#define RET_MacroRecorder 137 // MakroRecorder Befehl übertragen
+
+
+
+// Subcodes die in nUId geliefert werden
+// für F_ProfileInfo
+#define S_ProfileReset 201 // nNr1 = Anzahl Borders
+ // Achtung!! Diese Defines müssen aufeinanderfolgende Nummern haben!!
+#define S_ProfileBorder1 202 // nNr1 = Border1 in ms
+#define S_ProfileBorder2 203 // nNr1 = Border2 in ms
+#define S_ProfileBorder3 204 // nNr1 = Border3 in ms
+#define S_ProfileBorder4 205 // nNr1 = Border4 in ms
+ // Achtung Ende
+#define S_ProfileTime 210 // nNr1 = remote Zeit des Befehls
+#define S_ProfileDump 211 // Gibt die daten aus.
+
+// für F_DirectLoging
+#define S_AssertError 220
+#define S_AssertWarning 221
+#define S_AssertTrace 222
+#define S_QAError 223
+
+
+
+// Constants which are available in VCLTestTool scripts
+
+// Different types of controls recognized via RTTI
+#define CONST_CTBrowseBox 100
+#define CONST_CTValueSet 103
+#define CONST_CTORoadmap 104
+#define CONST_CTIExtensionListBox 105
+#define CONST_CTTableControl 106
+#define CONST_CTUnknown 199
+
+// Konstanten für das ALignment des gesuchten Splitters
+#define CONST_ALIGN_LEFT 120
+#define CONST_ALIGN_TOP 121
+#define CONST_ALIGN_RIGHT 122
+#define CONST_ALIGN_BOTTOM 123
+
+/// What dialog to use in RC_CloseSysDialog or RC_ExistsSysDialog
+#define CONST_FilePicker 301
+#define CONST_FolderPicker 302
+
+/// NodeTypes of the SAX Parser
+#define CONST_NodeTypeCharacter 555
+#define CONST_NodeTypeElement 556
+#define CONST_NodeTypeComment 557
+
+/// ItemTypes for TreeListBox and maybe others
+#define CONST_ItemTypeText 602
+#define CONST_ItemTypeBMP 601
+#define CONST_ItemTypeCheckbox 600
+#define CONST_ItemTypeContextBMP 603
+#define CONST_ItemTypeUnknown 604
+
+/// Return values for WaitSlot
+#define CONST_WSTimeout 701
+#define CONST_WSAborted 702
+#define CONST_WSFinished 703
+
+// Beschreibt die Parametertypen als Bitfeld Reihenfolge immer!
+// wie hier Aufgelistet
+#define PARAM_NONE 0x0000
+#define PARAM_USHORT_1 0x0001
+#define PARAM_USHORT_2 0x0002
+#define PARAM_USHORT_3 0x0100 // Nicht in der Reihe!!
+#define PARAM_USHORT_4 0x0200 // Nicht in der Reihe!!
+#define PARAM_ULONG_1 0x0004
+#define PARAM_ULONG_2 0x0008
+#define PARAM_STR_1 0x0010
+#define PARAM_STR_2 0x0020
+#define PARAM_BOOL_1 0x0040
+#define PARAM_BOOL_2 0x0080
+#define PARAM_SBXVALUE_1 0x0400 // hier mit 0x0400 Weiter!!! Siehe Oben!
+
+// Zusätzliche Beschreibung!! wird auch mit dem Rest verodert
+//#define PARAM_STR_RAW 0x8000 // Der Zeichensatz der Strings wird nicht konvertiert(für Fareastern)
+
+
+#define ERR_SEND_TIMEOUT 100
+#define ERR_EXEC_TIMEOUT 101
+#define ERR_RESTART_FAIL 102
+#define ERR_RESTART 103
+#define ERR_NO_WIN 104 // Keine *.Win Dateien gefunden
+#define ERR_NO_SID 105 // Keine *.Sid Dateien gefunden
+#define ERR_NO_FILE 106 // Datei nicht gefunden
+
+#endif
diff --git a/automation/source/inc/sttresid.hxx b/automation/source/inc/sttresid.hxx
new file mode 100644
index 000000000000..4bfa73cdc2c9
--- /dev/null
+++ b/automation/source/inc/sttresid.hxx
@@ -0,0 +1,42 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _STTRESID_HXX_
+#define _STTRESID_HXX_
+
+#include <tools/resmgr.hxx>
+#include <tools/resid.hxx>
+
+class SttResId : public ResId
+{
+ static ResMgr* getSttResMgr();
+ public:
+ SttResId( sal_uInt32 nId ) : ResId( nId, *getSttResMgr() ) {}
+};
+
+
+#endif
diff --git a/automation/source/inc/svcommstream.hxx b/automation/source/inc/svcommstream.hxx
new file mode 100644
index 000000000000..545f8adc7887
--- /dev/null
+++ b/automation/source/inc/svcommstream.hxx
@@ -0,0 +1,56 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include <tools/stream.hxx>
+
+#include <automation/commtypes.hxx>
+#include "icommstream.hxx"
+
+
+class SvCommStream : public ICommStream
+{
+protected:
+ SvStream* pStream;
+public:
+
+ SvCommStream( SvStream* pIO );
+ ~SvCommStream();
+
+ ICommStream& operator>>( comm_USHORT& rUShort );
+ ICommStream& operator>>( comm_ULONG& rULong );
+ ICommStream& operator>>( comm_BOOL& rChar );
+
+ ICommStream& operator<<( comm_USHORT nUShort );
+ ICommStream& operator<<( comm_ULONG nULong );
+ ICommStream& operator<<( comm_BOOL nChar );
+
+ comm_ULONG Read( void* pData, comm_ULONG nSize );
+ comm_ULONG Write( const void* pData, comm_ULONG nSize );
+
+ comm_BOOL IsEof() const;
+ comm_ULONG SeekRel( long nPos );
+};
diff --git a/automation/source/inc/testapp.hxx b/automation/source/inc/testapp.hxx
new file mode 100644
index 000000000000..bf4d35626102
--- /dev/null
+++ b/automation/source/inc/testapp.hxx
@@ -0,0 +1,194 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef TESTAPP_HXX
+#define TESTAPP_HXX
+
+#include <basic/sbmod.hxx>
+#include <basic/testtool.hxx>
+
+class CommunicationLink;
+class CommunicationManagerClientViaSocketTT;
+class CNames;
+class ControlItemUId;
+class CRevNames;
+//class SbxTransportVariableRef;
+class ControlsRef;
+class CmdStream;
+class FloatingLoadConf;
+class TestToolObj;
+class ControlDef;
+
+class SbxTransportMethod;
+class Application;
+
+class SotStorage;
+
+class ImplTestToolObj;
+class MyBasic;
+
+class ErrorEntry
+{
+public:
+ ErrorEntry(sal_uLong nNr, String aStr = String()) : nError(nNr),aText(aStr),nLine(0),nCol1(0),nCol2(0) {}
+ ErrorEntry(sal_uLong nNr, String aStr, xub_StrLen l, xub_StrLen c1, xub_StrLen c2 )
+ : nError(nNr),aText(aStr),nLine(l),nCol1(c1),nCol2(c2) {}
+ sal_uLong nError;
+ String aText;
+ xub_StrLen nLine;
+ xub_StrLen nCol1;
+ xub_StrLen nCol2;
+};
+
+SV_DECL_PTRARR_DEL(CErrors, ErrorEntry*, 1, 1)
+
+struct ControlDefLoad {
+ const char* Kurzname;
+ sal_uLong nUId;
+};
+
+class TestToolObj: public SbxObject
+{
+ friend class TTBasic;
+ friend class Controls;
+public:
+ TestToolObj( String aName, String aFilePath ); // Alle Dateien in FilePath, Kein IPC
+ TestToolObj( String aName, MyBasic* pBas ); // Pfade aus INI, IPC benutzen
+ ~TestToolObj();
+ void LoadIniFile(); // Laden der IniEinstellungen, die durch den ConfigDialog geändert werden können
+ void DebugFindNoErrors( sal_Bool bDebugFindNoErrors );
+
+private:
+ sal_Bool bWasPrecompilerError; // True wenn beim letzten Precompile ein Fehler auftrat
+ sal_Bool CError( sal_uLong, const String&, xub_StrLen, xub_StrLen, xub_StrLen );
+ void CalcPosition( String const &aSource, xub_StrLen nPos, xub_StrLen &l, xub_StrLen &c );
+ xub_StrLen ImplSearch( const String &aSource, const xub_StrLen nStart, const xub_StrLen nEnd, const String &aSearch, const xub_StrLen nSearchStart = 0 );
+ xub_StrLen PreCompilePart( String &aSource, xub_StrLen nStart, xub_StrLen nEnd, String aFinalErrorLabel, sal_uInt16 &nLabelCount );
+ void PreCompileDispatchParts( String &aSource, String aStart, String aEnd, String aFinalLable );
+public:
+ String GetRevision(String const &aSourceIn); // find Revision in the sourcecode
+ String PreCompile(String const &aSourceIn); // try catch; testcase endcase ..
+ sal_Bool WasPrecompilerError(); // True wenn beim letzten Precompile ein Fehler auftrat
+ void SFX_NOTIFY( SfxBroadcaster&, const TypeId&, const SfxHint& rHint, const TypeId& );
+ virtual SbxVariable* Find( const String&, SbxClassType );
+// String aKeyPlusClasses; // Pfad für keycodes & classes & res_type (Aus Configdatei)
+ DECL_LINK( ReturnResultsLink, CommunicationLink* );
+ sal_Bool ReturnResults( SvStream *pIn ); // Rücklieferung des Antwortstreams über IPC oder TCP/IP oder direkt
+
+ void SetLogHdl( const Link& rLink ) { aLogHdl = rLink; }
+ const Link& GetLogHdl() const { return aLogHdl; }
+
+ void SetWinInfoHdl( const Link& rLink ) { aWinInfoHdl = rLink; }
+ const Link& GetWinInfoHdl() const { return aWinInfoHdl; }
+
+ void SetModuleWinExistsHdl( const Link& rLink ) { aModuleWinExistsHdl = rLink; }
+ const Link& GetModuleWinExistsHdl() const { return aModuleWinExistsHdl; }
+
+ void SetCErrorHdl( const Link& rLink ) { aCErrorHdl = rLink; }
+ const Link& GetCErrorHdl() const { return aCErrorHdl; }
+
+ void SetWriteStringHdl( const Link& rLink ) { aWriteStringHdl = rLink; }
+ const Link& GetWriteStringHdl() const { return aWriteStringHdl; }
+
+ SfxBroadcaster& GetTTBroadcaster();
+
+private:
+ ImplTestToolObj *pImpl; // Alles was von der Implementation abhängt
+ static const CErrors* GetFehlerListe() { return pFehlerListe; }
+ sal_Bool bUseIPC;
+ Link aLogHdl; // Zum Logen der Fehlermeldungen im Testtool
+ Link aWinInfoHdl; // Anzeigen der Windows/Controls der zu testenden App
+ Link aModuleWinExistsHdl; // Prüft ob das Modul schon im Editor geladen ist
+ Link aCErrorHdl; // Melden von Compilererror
+ Link aWriteStringHdl; // Schreiben von text (e.g. MakroRecorder)
+ sal_Bool bReturnOK; // Bricht WaitForAnswer ab
+ CRevNames *pShortNames; // Aktuell verwendete Controls, zur gewinnung des Namens aus Fehlermeldung
+ sal_uLong nSequence; // Sequence um Antwort und Anfrage zu syncronisieren
+ rtl::OString aNextReturnId; // Id des Returnwertes i.e. UId
+ void ReplaceNumbers(String &aText); // Zahlen im String mit speziellem Format in Namen umwandeln
+
+ String aLastRecordedKontext;// Keeps the last kontext recorded by the Macro Recorder
+
+#define FLAT sal_True
+ String ProgPath; // Dateiname der zu Testenden APP; Gesetzt über Start
+ String aLogFileName; // Momentaner Logfilename (Wie Programmdatei aber mit .res)
+ sal_Bool IsBlock; // Innerhalb Begin/EndBlock
+ sal_Bool SingleCommandBlock; // Implizit um jedes kommando ein Begin/EndBlock
+ CmdStream *In;
+
+ void AddName(String &aBisher, String &aNeu ); // Name eventuell mit / anhängen
+ void AddToListByNr( CNames *&pControls, ControlItemUId *&pNewItem ); //
+ CNames *m_pControls;
+ CNames *m_pNameKontext; // Zeigt auf den aktuellen Namenskontext, der über 'Kontext' gesetzt wurde
+ CNames *m_pSIds;
+ CNames *m_pReverseSlots; // Slots mit Kurznamen nach Nummer
+ CNames *m_pReverseControls; // Controls mit Kurznamen nach Nummer
+ CNames *m_pReverseControlsSon;// Controls mit Kurznamen nach Nummer nach Fenstern (Son)
+ CNames *m_pReverseUIds; // Langnamen nach Nummer
+
+
+ sal_uInt16 nMyVar; // Wievielte Var aus Pool ist dran
+
+ void InitTestToolObj();
+ CommunicationManagerClientViaSocketTT *pCommunicationManager;
+ void SendViaSocket();
+
+ sal_Bool Load( String aFileName, SbModule *pMod );
+
+ void ReadNames( String Filename, CNames *&pNames, CNames *&pUIds, sal_Bool bIsFlat = sal_False );
+ void ReadFlat( String Filename, CNames *&pNames, sal_Bool bSortByName );
+ sal_Bool ReadNamesBin( String Filename, CNames *&pSIds, CNames *&pControls );
+ sal_Bool WriteNamesBin( String Filename, CNames *pSIds, CNames *pControls );
+ void ReadHidLstByNumber();
+ void SortControlsByNumber( sal_Bool bIncludeActive = sal_False );
+
+ String GetMethodName( sal_uLong nMethodId );
+ String GetKeyName( sal_uInt16 nKeyCode );
+
+ void WaitForAnswer ();
+ DECL_LINK( IdleHdl, Application* );
+ DECL_LINK( CallDialogHandler, Application* );
+ String aDialogHandlerName;
+ sal_uInt16 nWindowHandlerCallLevel;
+
+ sal_uInt16 nIdleCount;
+ // wenn DialogHandler gesetzt wird er im IdleHandler inkrementiert und
+ // in WaitForAnswer rückgesetzt. Übersteigt er einen gewissen wert, gehe ich davon aus,
+ // daß WaitForAnswer still ligt und rufe die DialogHander Sub im BASIC auf.
+
+ void BeginBlock();
+ void EndBlock();
+
+ SbTextType GetSymbolType( const String &rSymbol, sal_Bool bWasControl );
+ static ControlDefLoad const arR_Cmds[];
+ static CNames *pRCommands;
+
+ static CErrors *pFehlerListe; // Hier werden die Fehler des Testtools gespeichert
+
+};
+
+#endif
diff --git a/automation/source/inc/testtool.hxx b/automation/source/inc/testtool.hxx
new file mode 100644
index 000000000000..9454f57f05f7
--- /dev/null
+++ b/automation/source/inc/testtool.hxx
@@ -0,0 +1,72 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SVTOOLS_TESTTOOL_HXX
+#define SVTOOLS_TESTTOOL_HXX
+
+#include <tools/solar.h>
+#include <tools/link.hxx>
+#include <vcl/timer.hxx>
+
+class Application;
+class SvStream;
+
+class StatementFlow;
+class CommunicationManager;
+class CommunicationLink;
+#if OSL_DEBUG_LEVEL > 1
+class EditWindow;
+#endif
+class ImplRC;
+
+class ImplRemoteControl
+{
+ friend class StatementFlow;
+
+ sal_Bool m_bIdleInserted;
+ AutoTimer m_aIdleTimer;
+ sal_Bool m_bInsideExecutionLoop;
+#if OSL_DEBUG_LEVEL > 1
+ EditWindow *m_pDbgWin;
+#endif
+
+public:
+ ImplRemoteControl();
+ ~ImplRemoteControl();
+ sal_Bool QueCommands( sal_uLong nServiceId, SvStream *pIn );
+ SvStream* GetReturnStream();
+
+ DECL_LINK( IdleHdl, Application* );
+ DECL_LINK( CommandHdl, Application* );
+
+ DECL_LINK( QueCommandsEvent, CommunicationLink* );
+
+protected:
+ CommunicationManager *pServiceMgr;
+ SvStream *pRetStream;
+};
+
+#endif // SVTOOLS_TESTTOOL_HXX
diff --git a/automation/source/miniapp/editwin.cxx b/automation/source/miniapp/editwin.cxx
new file mode 100644
index 000000000000..67476c09bf6a
--- /dev/null
+++ b/automation/source/miniapp/editwin.cxx
@@ -0,0 +1,127 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_automation.hxx"
+
+#include "editwin.hxx"
+#include <tools/stream.hxx>
+#ifndef _MSGBOX_HXX //autogen
+#include <vcl/msgbox.hxx>
+#endif
+
+
+sal_Bool GHEditWindow::Close()
+{
+ if (aInhalt.IsModified())
+ {
+ }
+ delete(this);
+ return sal_True;
+}
+
+void GHEditWindow::Resize()
+{
+ aInhalt.SetPosSizePixel(Point(1,1),GetOutputSizePixel());
+}
+
+GHEditWindow::GHEditWindow(Window * pParent, String aName, WinBits iWstyle)
+: FloatingWindow(pParent)
+, aInhalt(this,iWstyle)
+{
+ SetOutputSizePixel( Size( 120,80 ) );
+ Show();
+ Resize();
+ aInhalt.Show();
+ SetText(aName);
+}
+
+void GHEditWindow::Clear()
+{
+ aInhalt.SetText(String());
+}
+
+void GHEditWindow::AddText( String aNew, sal_Bool bMoveToEnd)
+{
+ String aOld = aInhalt.GetText();
+
+ aOld += aNew;
+ aOld.ConvertLineEnd();
+ aInhalt.SetText(aOld);
+ if (bMoveToEnd)
+ aInhalt.SetSelection(Selection(SELECTION_MAX,SELECTION_MAX));
+}
+
+
+EditFileWindow::EditFileWindow(Window * pParent, String aName, WinBits iWstyle)
+: GHEditWindow(pParent, aName, iWstyle)
+, aFileName(aName)
+{
+ LoadFile();
+}
+
+void EditFileWindow::LoadFile()
+{
+
+ SvFileStream Stream;
+ String All,Line;
+
+ Stream.Open(aFileName, STREAM_STD_READ);
+
+ if (!Stream.IsOpen())
+ {
+ AddText(CUniString("could not open ").Append(aFileName).AppendAscii("\n"));
+ aFileName.Erase();
+ return;
+ }
+
+ while (!Stream.IsEof())
+ {
+
+ Stream.ReadByteStringLine( Line, RTL_TEXTENCODING_UTF8 );
+
+ All += Line;
+ All += '\n';
+
+ }
+
+ All.ConvertLineEnd();
+
+ AddText(All,sal_False);
+
+}
+
+sal_Bool EditFileWindow::Close()
+{
+
+ if (aInhalt.IsModified() && QueryBox(this,WB_DEF_YES | WB_YES_NO_CANCEL, String(aFileName).AppendAscii("\nhas been changed.\n\nSave file?")).Execute())
+ {
+
+ }
+ return GHEditWindow::Close();
+}
+
diff --git a/automation/source/miniapp/editwin.hxx b/automation/source/miniapp/editwin.hxx
new file mode 100644
index 000000000000..9547695fcc9d
--- /dev/null
+++ b/automation/source/miniapp/editwin.hxx
@@ -0,0 +1,70 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _editwin
+#define _editwin
+
+#ifndef _BASIC_TTRESHLP_HXX
+#include <basic/ttstrhlp.hxx>
+#endif
+#include <vcl/floatwin.hxx>
+#include <svtools/svmedit.hxx>
+
+class GHEditWindow : public FloatingWindow
+{
+
+protected:
+
+ MultiLineEdit aInhalt;
+
+ virtual sal_Bool Close(); // derived
+ void Resize();
+
+public:
+
+ GHEditWindow();
+ GHEditWindow(Window * pParent, String aName = CUniString("Neues Fenster"), WinBits iWstyle = WB_STDWORK);
+
+ void Clear();
+ void AddText( String aNew, sal_Bool bMoveToEnd = sal_True);
+};
+
+
+
+class EditFileWindow : public GHEditWindow
+{
+
+ String aFileName;
+ virtual sal_Bool Close(); // derived
+ void LoadFile();
+
+public:
+ EditFileWindow(Window * pParent, String aName = CUniString("Neue Datei"), WinBits iWstyle = WB_STDWORK);
+
+};
+
+#endif
+
diff --git a/automation/source/miniapp/hid.lst b/automation/source/miniapp/hid.lst
new file mode 100644
index 000000000000..99964dba02e8
--- /dev/null
+++ b/automation/source/miniapp/hid.lst
@@ -0,0 +1,27 @@
+MENU_CLIENT 256
+IDM_FILE 1
+IDM_FILE_OPEN_TEST 2
+IDM_FILE_EXIT 3
+IDM_FILE_EXIT_HELP 0
+IDM_FILE_OPEN_TEST_HELP 1
+IDM_FILE_HELP 3
+GROSSER_TEST_DLG 256
+IDM_TEST 5
+IDM_TEST_GROSS 6
+IDM_SYS_DLG 7
+IDM_TEST_WINTREE 8
+
+
+
+UID_GROSSER_TEST_DLG 101
+UID_CheckBox 202
+UID_TriStateBox 303
+UID_OKButton 404
+UID_TimeField 505
+UID_MultiLineEdit 606
+UID_RadioButton1 707
+UID_RadioButton2 708
+UID_MultiListBox 809
+UID_ComboBox 910
+UID_DateBox 1011
+
diff --git a/automation/source/miniapp/makefile.mk b/automation/source/miniapp/makefile.mk
new file mode 100644
index 000000000000..14a6d1ff0e1d
--- /dev/null
+++ b/automation/source/miniapp/makefile.mk
@@ -0,0 +1,54 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..
+
+PRJNAME=automation
+TARGET=miniapp
+
+# --- Settings ------------------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Allgemein ------------------------------------------------------------
+
+OBJFILES = \
+ $(OBJ)$/testapp.obj \
+ $(OBJ)$/editwin.obj \
+ $(OBJ)$/servres.obj
+
+
+EXCEPTIONSFILES= \
+ $(OBJ)$/testapp.obj
+
+SRS1NAME=$(TARGET)
+SRC1FILES = \
+ servres.src
+
+# --- Targets ------------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/automation/source/miniapp/servres.cxx b/automation/source/miniapp/servres.cxx
new file mode 100644
index 000000000000..f01d5d8c79b1
--- /dev/null
+++ b/automation/source/miniapp/servres.cxx
@@ -0,0 +1,60 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_automation.hxx"
+#include <string.h>
+
+#include "servres.hrc"
+#include "servuid.hxx"
+#include "servres.hxx"
+
+
+ModalDialogGROSSER_TEST_DLG::ModalDialogGROSSER_TEST_DLG( Window * pParent, const ResId & rResId, sal_Bool bFreeRes )
+ : ModalDialog( pParent, rResId ),
+ aCheckBox1( this, ResId( 1, *rResId.GetResMgr() ) ),
+ aTriStateBox1( this, ResId( 1, *rResId.GetResMgr() ) ),
+ aOKButton1( this, ResId( 1, *rResId.GetResMgr() ) ),
+ aTimeField1( this, ResId( 1, *rResId.GetResMgr() ) ),
+ aMultiLineEdit1( this, ResId( 1, *rResId.GetResMgr() ) ),
+ aGroupBox1( this, ResId( 1, *rResId.GetResMgr() ) ),
+ aRadioButton1( this, ResId( 1, *rResId.GetResMgr() ) ),
+ aRadioButton2( this, ResId( 2, *rResId.GetResMgr() ) ),
+ aMultiListBox1( this, ResId( 1, *rResId.GetResMgr() ) ),
+ aComboBox1( this, ResId( 1, *rResId.GetResMgr() ) ),
+ aDateBox1( this, ResId( 1, *rResId.GetResMgr() ) ),
+ aFixedText1( this, ResId( 1, *rResId.GetResMgr() ) )
+{
+ if( bFreeRes ) FreeResource();
+}
+
+MenuMENU_CLIENT::MenuMENU_CLIENT( const ResId & rResId, sal_Bool )
+ : MenuBar( rResId )
+{
+ // No subresources, automatic free resource
+}
+
diff --git a/automation/source/miniapp/servres.hrc b/automation/source/miniapp/servres.hrc
new file mode 100644
index 000000000000..6efd2ce57460
--- /dev/null
+++ b/automation/source/miniapp/servres.hrc
@@ -0,0 +1,40 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+/* StarView ressource header file */
+#define MENU_CLIENT 256
+#define IDM_FILE 1
+#define IDM_FILE_OPEN_TEST 2
+#define IDM_FILE_EXIT 3
+#define IDM_FILE_EXIT_HELP "AUTOMATION_IDM_FILE_EXIT_HELP"
+#define IDM_FILE_OPEN_TEST_HELP "AUTOMATION_IDM_FILE_OPEN_TEST_HELP"
+#define IDM_FILE_HELP "AUTOMATION_IDM_FILE_HELP"
+#define GROSSER_TEST_DLG 256
+#define IDM_TEST 5
+#define IDM_TEST_GROSS 6
+#define IDM_SYS_DLG 7
+#define IDM_TEST_WINTREE 8
+
diff --git a/automation/source/miniapp/servres.hxx b/automation/source/miniapp/servres.hxx
new file mode 100644
index 000000000000..9262b50d946a
--- /dev/null
+++ b/automation/source/miniapp/servres.hxx
@@ -0,0 +1,81 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include <svtools/svmedit.hxx>
+#ifndef _DIALOG_HXX //autogen
+#include <vcl/dialog.hxx>
+#endif
+#ifndef _BUTTON_HXX //autogen
+#include <vcl/button.hxx>
+#endif
+#ifndef _FIELD_HXX //autogen
+#include <vcl/field.hxx>
+#endif
+#ifndef _EDIT_HXX //autogen
+#include <vcl/edit.hxx>
+#endif
+#ifndef _GROUP_HXX //autogen
+#include <vcl/group.hxx>
+#endif
+#ifndef _COMBOBOX_HXX //autogen
+#include <vcl/combobox.hxx>
+#endif
+#ifndef _FIXED_HXX //autogen
+#include <vcl/fixed.hxx>
+#endif
+#ifndef _MENU_HXX //autogen
+#include <vcl/menu.hxx>
+#endif
+#ifndef _LSTBOX_HXX //autogen
+#include <vcl/lstbox.hxx>
+#endif
+
+class ModalDialogGROSSER_TEST_DLG : public ModalDialog
+{
+protected:
+ CheckBox aCheckBox1;
+ TriStateBox aTriStateBox1;
+ OKButton aOKButton1;
+ TimeField aTimeField1;
+ MultiLineEdit aMultiLineEdit1;
+ GroupBox aGroupBox1;
+ RadioButton aRadioButton1;
+ RadioButton aRadioButton2;
+ MultiListBox aMultiListBox1;
+ ComboBox aComboBox1;
+ DateBox aDateBox1;
+ FixedText aFixedText1;
+public:
+ ModalDialogGROSSER_TEST_DLG( Window * pParent, const ResId & rResId, sal_Bool bFreeRes = sal_True );
+};
+
+class MenuMENU_CLIENT : public MenuBar
+{
+protected:
+public:
+ MenuMENU_CLIENT( const ResId & rResId, sal_Bool bFreeRes = sal_True );
+};
+
diff --git a/automation/source/miniapp/servres.src b/automation/source/miniapp/servres.src
new file mode 100644
index 000000000000..c1af1caa775a
--- /dev/null
+++ b/automation/source/miniapp/servres.src
@@ -0,0 +1,233 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "servres.hrc"
+#include "servuid.hxx"
+ModalDialog GROSSER_TEST_DLG
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ HelpID = UID_GROSSER_TEST_DLG ;
+ Pos = MAP_APPFONT ( 14 , 7 ) ;
+ Size = MAP_APPFONT ( 273 , 110 ) ;
+ Text = "Großer Testdialog" ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ CheckBox 1
+ {
+ HelpID = UID_CheckBox ;
+ Pos = MAP_APPFONT ( 9 , 17 ) ;
+ Size = MAP_APPFONT ( 55 , 12 ) ;
+ Text = "CheckBox" ;
+ TabStop = TRUE ;
+ };
+ TriStateBox 1
+ {
+ HelpID = UID_TriStateBox ;
+ Pos = MAP_APPFONT ( 9 , 29 ) ;
+ Size = MAP_APPFONT ( 62 , 12 ) ;
+ Text = "TriStateBox" ;
+ TabStop = TRUE ;
+ };
+ OKButton 1
+ {
+ HelpID = "hid1" ;
+ Pos = MAP_APPFONT ( 132 , 92 ) ;
+ Size = MAP_APPFONT ( 64 , 12 ) ;
+ TabStop = TRUE ;
+ };
+ TimeField 1
+ {
+ Border = TRUE ;
+ HelpID = UID_TimeField ;
+ Pos = MAP_APPFONT ( 9 , 92 ) ;
+ Size = MAP_APPFONT ( 40 , 12 ) ;
+ TabStop = TRUE ;
+ Spin = TRUE ;
+ };
+ MultiLineEdit 1
+ {
+ Border = TRUE ;
+ HelpID = UID_MultiLineEdit ;
+ Pos = MAP_APPFONT ( 172 , 6 ) ;
+ Size = MAP_APPFONT ( 94 , 48 ) ;
+ Text = "MultiLineEdit" ;
+ TabStop = TRUE ;
+ VScroll = TRUE ;
+ };
+ GroupBox 1
+ {
+ Pos = MAP_APPFONT ( 9 , 42 ) ;
+ Size = MAP_APPFONT ( 58 , 44 ) ;
+ Text = "GroupBox" ;
+ Group = TRUE ;
+ };
+ RadioButton 2
+ {
+ HelpID = UID_RadioButton2 ;
+ Pos = MAP_APPFONT ( 16 , 68 ) ;
+ Size = MAP_APPFONT ( 40 , 12 ) ;
+ Text = "Radio2" ;
+ TabStop = TRUE ;
+ };
+ RadioButton 1
+ {
+ HelpID = UID_RadioButton1 ;
+ Pos = MAP_APPFONT ( 16 , 54 ) ;
+ Size = MAP_APPFONT ( 42 , 12 ) ;
+ Text = "Radio1" ;
+ TabStop = TRUE ;
+ };
+ MultiListBox 1
+ {
+ Border = TRUE ;
+ HelpID = UID_MultiListBox ;
+ Pos = MAP_APPFONT ( 76 , 6 ) ;
+ Size = MAP_APPFONT ( 86 , 48 ) ;
+ TabStop = TRUE ;
+ StringList =
+ {
+ < "MultiListBox" ; Default ; > ;
+ < "Zeile 2" ; Default ; > ;
+ < "Zeile 3" ; Default ; > ;
+ < "Zeile 4" ; Default ; > ;
+ < "Zeile 5" ; Default ; > ;
+ < "Zeile 6" ; Default ; > ;
+ < "Zeile 7" ; Default ; > ;
+ < "Zeile 8" ; Default ; > ;
+ < "Zeile 9" ; Default ; > ;
+ < "Zeile 10" ; Default ; > ;
+ };
+ };
+ ComboBox 1
+ {
+ HelpID = UID_ComboBox ;
+ Pos = MAP_APPFONT ( 76 , 58 ) ;
+ Size = MAP_APPFONT ( 86 , 55 ) ;
+ Text = "ComboBox" ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ AutoHScroll = TRUE ;
+ StringList =
+ {
+ "ComboBox" ;
+ "Erster" ;
+ "Zweiter" ;
+ "Dritter" ;
+ };
+ };
+ DateBox 1
+ {
+ HelpID = UID_DateBox ;
+ Pos = MAP_APPFONT ( 76 , 72 ) ;
+ Size = MAP_APPFONT ( 86 , 54 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ AutoHScroll = TRUE ;
+ StringList =
+ {
+ "1.1.91" ;
+ "2.2.92" ;
+ "3.3.93" ;
+ };
+ };
+ FixedText 1
+ {
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 19 , 6 ) ;
+ Size = MAP_APPFONT ( 39 , 9 ) ;
+ Text = "FixedText" ;
+ Center = TRUE ;
+ };
+ CancelButton 1
+ {
+ Pos = MAP_APPFONT ( 202 , 92 ) ;
+ Size = MAP_APPFONT ( 64 , 12 ) ;
+ TabStop = TRUE ;
+ };
+};
+Menu MENU_CLIENT
+{
+ ItemList =
+ {
+ MenuItem
+ {
+ Identifier = IDM_FILE ;
+ HelpID = IDM_FILE_HELP ;
+ Text = "~File" ;
+ SubMenu = Menu
+ {
+ ItemList =
+ {
+ MenuItem
+ {
+ Identifier = IDM_FILE_OPEN_TEST ;
+ HelpID = IDM_FILE_OPEN_TEST_HELP ;
+ Text = "~Open Test Window" ;
+ };
+ MenuItem
+ {
+ Identifier = 4 ;
+ Separator = TRUE ;
+ };
+ MenuItem
+ {
+ Identifier = IDM_FILE_EXIT ;
+ HelpID = IDM_FILE_EXIT_HELP ;
+ Text = "~Beenden" ;
+ AccelKey = KeyCode
+ {
+ Code = KEY_F4 ;
+ Modifier2 = TRUE ;
+ };
+ };
+ };
+ };
+ };
+ MenuItem
+ {
+ Identifier = IDM_TEST ;
+ Text = "~Test" ;
+ SubMenu = Menu
+ {
+ ItemList =
+ {
+ MenuItem
+ {
+ Identifier = IDM_TEST_GROSS ;
+ Text = "~Großer Testdialog" ;
+ };
+ MenuItem
+ {
+ Identifier = IDM_SYS_DLG ;
+ Text = "~Sysdialoge" ;
+ };
+ };
+ };
+ };
+ };
+};
+
diff --git a/automation/source/miniapp/servuid.hxx b/automation/source/miniapp/servuid.hxx
new file mode 100644
index 000000000000..c1ba920f3667
--- /dev/null
+++ b/automation/source/miniapp/servuid.hxx
@@ -0,0 +1,37 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#define UID_GROSSER_TEST_DLG "AUTOMATION_UID_GROSSER_TEST_DLG"
+#define UID_CheckBox "AUTOMATION_UID_CheckBox"
+#define UID_TriStateBox "AUTOMATION_UID_TriStateBox"
+#define UID_OKButton "AUTOMATION_UID_OKButton"
+#define UID_TimeField "AUTOMATION_UID_TimeField"
+#define UID_MultiLineEdit "AUTOMATION_UID_MultiLineEdit"
+#define UID_RadioButton1 "AUTOMATION_UID_RadioButton1"
+#define UID_RadioButton2 "AUTOMATION_UID_RadioButton2"
+#define UID_MultiListBox "AUTOMATION_UID_MultiListBox"
+#define UID_ComboBox "AUTOMATION_UID_ComboBox"
+#define UID_DateBox "AUTOMATION_UID_DateBox"
diff --git a/automation/source/miniapp/test.bas b/automation/source/miniapp/test.bas
new file mode 100644
index 000000000000..6d00e892fcb3
--- /dev/null
+++ b/automation/source/miniapp/test.bas
@@ -0,0 +1,126 @@
+'encoding UTF-8 Do not remove or change this line!
+sub main
+' cMassentest
+' DisplayHid
+ cTestdialog
+ cSysDlgTest
+ cFileOpenTest
+ SidWintree
+
+ FileExit
+end sub
+
+testcase cMassentest
+
+DisplayHid
+resetapplication
+FileDialog
+kontext "GrosserTestDlg"
+dim c,t,lang,i
+c = 0
+lang = "0123456789abcdef"
+lang = lang + lang
+lang = lang + lang
+lang = lang + lang
+lang = lang + lang
+lang = lang + lang
+lang = lang + lang
+
+lang = lang + lang
+lang = lang + lang
+nodebug
+while 1
+ c = c + 1
+ t = str(c)
+ MultiLineEdit.SetText t
+ CheckBox.check lang
+ CheckBox.uncheck lang
+ for i = 1 to 200 : next
+ beep
+wend
+
+endcase
+
+
+testcase cFileOpenTest
+
+ FileOpenTest
+ setclipboard wintree
+ kontext
+ active.cancel
+
+endcase
+
+
+testcase cSysDlgTest
+
+ SysDialogs
+ setclipboard wintree
+ kontext
+ active.yes
+ setclipboard wintree
+ active.ok
+ active.Cancel
+
+ SysDialogs
+ active.Cancel
+ active.ok
+
+endcase
+
+testcase cTestdialog
+
+ FileDialog
+
+ kontext "GrosserTestDlg"
+ CheckBox.uncheck
+ TriStateBox.tristate
+ 'OKButton
+' TimeField.settext("fhsdjk")
+ MultiLineEdit.SetText "Das war der Text: '"+MultiLineEdit.GetText+"'"
+ RadioButton1.check
+ RadioButton2.check
+' MultiListBox.select 2
+ ComboBox.select("Dritter")
+ DateBox.select("1.1.91")
+
+ GrosserTestDlg.ok
+
+endcase
+
+
+sub LoadIncludeFiles
+
+ start "miniapp.exe", "-enableautomation"
+
+ use "test.win"
+ use "test.sid"
+
+ testexit
+
+end sub
+
+sub testenter
+end sub
+
+sub testexit
+
+ dim xx
+ xx = resetapplication
+ if xx > "" then warnlog xx
+
+end sub
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/automation/source/miniapp/test.sid b/automation/source/miniapp/test.sid
new file mode 100644
index 000000000000..3af8966aa06b
--- /dev/null
+++ b/automation/source/miniapp/test.sid
@@ -0,0 +1,5 @@
+FileOpenTest IDM_FILE_OPEN_TEST
+FileExit IDM_FILE_EXIT
+FileDialog IDM_TEST_GROSS
+SidWintree IDM_TEST_WINTREE
+SysDialogs IDM_SYS_DLG
diff --git a/automation/source/miniapp/test.win b/automation/source/miniapp/test.win
new file mode 100644
index 000000000000..224ca5ad2d44
--- /dev/null
+++ b/automation/source/miniapp/test.win
@@ -0,0 +1,13 @@
+*active
+*GrosserTestDlg UID_GROSSER_TEST_DLG
+CheckBox UID_CheckBox
+TriStateBox UID_TriStateBox
+OKButton UID_OKButton
+TimeField UID_TimeField
+MultiLineEdit UID_MultiLineEdit
+RadioButton1 UID_RadioButton1
+RadioButton2 UID_RadioButton2
+MultiListBox UID_MultiListBox
+ComboBox UID_ComboBox
+DateBox UID_DateBox
+
diff --git a/automation/source/miniapp/testapp.cxx b/automation/source/miniapp/testapp.cxx
new file mode 100644
index 000000000000..6711ffe8b333
--- /dev/null
+++ b/automation/source/miniapp/testapp.cxx
@@ -0,0 +1,351 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_automation.hxx"
+#include <svtools/filedlg.hxx>
+#include <stdio.h>
+#ifndef _MSGBOX_HXX //autogen
+#include <vcl/msgbox.hxx>
+#endif
+#include <tools/debug.hxx>
+#include <svtools/testtool.hxx>
+#include <svtools/ttprops.hxx>
+#include <rtl/ustring.hxx>
+#include <rtl/ustrbuf.hxx>
+#include <osl/process.h>
+#include <ucbhelper/contentbroker.hxx>
+#include <ucbhelper/configurationkeys.hxx>
+#include <comphelper/regpathhelper.hxx>
+#include <comphelper/processfactory.hxx>
+#include <cppuhelper/servicefactory.hxx>
+#include <com/sun/star/registry/XImplementationRegistration.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/ucb/XContentProviderManager.hpp>
+
+#include "servres.hrc"
+#include "servres.hxx"
+#include "testapp.hxx"
+
+using namespace comphelper;
+using namespace cppu;
+using namespace rtl;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::registry;
+using namespace com::sun::star::ucb;
+
+static ResMgr* pAppMgr = NULL;
+
+MainWindow::MainWindow(MyApp *pAppl)
+: WorkWindow(NULL, WB_STDWORK)
+, pApp(pAppl)
+{}
+
+IMPL_LINK(MainWindow,MenuSelectHdl,MenuBar*,aMenu)
+{
+
+ return pApp->GetDispatcher()->ExecuteFunction(aMenu->GetCurItemId());
+
+}
+
+void MainWindow::FileOpen()
+{
+ FileDialog Dlg(this,WB_OPEN );
+
+ Dlg.AddFilter(CUniString("Alle Dateien"), CUniString("*.*"));
+ Dlg.SetCurFilter (CUniString("*.*"));
+
+ if (Dlg.Execute() == RET_OK)
+ {
+ new EditFileWindow(this,Dlg.GetPath());
+ }
+}
+
+
+void MainWindow::TestGross()
+{
+ ModalDialogGROSSER_TEST_DLG Dlg(this,ResId(GROSSER_TEST_DLG, *pAppMgr));
+
+ if (Dlg.Execute() == RET_OK)
+ {
+ }
+}
+
+
+sal_Bool MainWindow::Close()
+{
+ WorkWindow::Close();
+ FileExit();
+ return sal_True;
+}
+
+void MainWindow::FileExit()
+{
+/* WriteSTBProfile();*/
+
+// if (pApp->CloseAll())
+ pApp->Quit();
+}
+
+
+void MainWindow::Tree(GHEditWindow *aEditWin, Window *pBase, sal_uInt16 Indent)
+{
+ String sIndent,aText;
+ sIndent.Expand(5*Indent);
+
+ aText = pBase->GetText();
+ aText.SearchAndReplaceAllAscii("\n",CUniString("\\n"));
+
+ aEditWin->AddText(String(sIndent).AppendAscii("Text: ").Append(aText).AppendAscii("\n"));
+ // FIXME: HELPID
+ aEditWin->AddText(String(sIndent).AppendAscii("Help: ").Append(String(rtl::OStringToOUString(pBase->GetHelpId(), RTL_TEXTENCODING_UTF8))).AppendAscii(":").Append(pBase->GetQuickHelpText()).AppendAscii(":").Append(pBase->GetHelpText()).AppendAscii("\n"));
+
+ sal_uInt16 i;
+ for (i = 0 ; i < pBase->GetChildCount() ; i++)
+ {
+ Tree(aEditWin,pBase->GetChild(i),Indent+1);
+ }
+}
+
+void MainWindow::WinTree()
+{
+
+ GHEditWindow * aEditWin = new GHEditWindow(this,CUniString("Window Tree"));
+ Tree(aEditWin,this,0);
+
+}
+
+void MainWindow::SysDlg()
+{
+ switch (QueryBox(this,WB_YES_NO_CANCEL | WB_DEF_YES, CUniString("Want to open another Dialog?")).Execute())
+ {
+ case RET_YES:
+ while ( WarningBox(this,WB_OK_CANCEL | WB_DEF_OK,CUniString("Well this is the last box now!")).Execute() == RET_OK ) ;
+ break;
+ case RET_NO:
+ break;
+ case RET_CANCEL:InfoBox(this,CUniString("Oh well..")).Execute();
+ break;
+ }
+
+/*
+
+#define WB_OK ((WinBits)0x0010)
+#define WB_OK_CANCEL ((WinBits)0x0020)
+#define WB_YES_NO ((WinBits)0x0040)
+#define WB_YES_NO_CANCEL ((WinBits)0x0080)
+#define WB_RETRY_CANCEL ((WinBits)0x0100)
+
+#define WB_DEF_OK ((WinBits)0x0200)
+#define WB_DEF_CANCEL ((WinBits)0x0400)
+#define WB_DEF_RETRY ((WinBits)0x0800)
+#define WB_DEF_YES ((WinBits)0x1000)
+#define WB_DEF_NO ((WinBits)0x2000)
+
+#define RET_OK TRUE
+#define RET_CANCEL FALSE
+#define RET_YES 2
+#define RET_NO 3
+#define RET_RETRY 4
+*/
+}
+
+MyApp aApp;
+
+MyApp::MyApp()
+{
+ pMainWin = NULL;
+}
+
+void MyApp::Property( ApplicationProperty& rProp )
+{
+ TTProperties* pTTProperties = PTR_CAST( TTProperties, &rProp );
+ if ( pTTProperties )
+ {
+ pTTProperties->nPropertyVersion = TT_PROPERTIES_VERSION;
+ switch ( pTTProperties->nActualPR )
+ {
+/* case TT_PR_SLOTS:
+ {
+ pTTProperties->nSidOpenUrl = SID_OPENURL;
+ pTTProperties->nSidFileName = SID_FILE_NAME;
+ pTTProperties->nSidNewDocDirect = SID_NEWDOCDIRECT;
+ pTTProperties->nSidCopy = SID_COPY;
+ pTTProperties->nSidPaste = SID_PASTE;
+ pTTProperties->nSidSourceView = SID_SOURCEVIEW;
+ pTTProperties->nSidSelectAll = SID_SELECTALL;
+ pTTProperties->nSidReferer = SID_REFERER;
+ pTTProperties->nActualPR = 0;
+ }
+ break;*/
+ case TT_PR_DISPATCHER:
+ {
+ PlugInDispatcher* pDispatcher = GetDispatcher();
+ if ( !pDispatcher )
+ pTTProperties->nActualPR = TT_PR_ERR_NODISPATCHER;
+ else
+ {
+ pDispatcher->SetExecuteMode(EXECUTEMODE_DIALOGASYNCHRON);
+ if ( pDispatcher->ExecuteFunction(
+ pTTProperties->mnSID, pTTProperties->mppArgs, pTTProperties->mnMode )
+ == EXECUTE_NO )
+ pTTProperties->nActualPR = TT_PR_ERR_NOEXECUTE;
+ else
+ pTTProperties->nActualPR = 0;
+ }
+ }
+ break;
+/* case TT_PR_IMG:
+ {
+ SvDataMemberObjectRef aDataObject = new SvDataMemberObject();
+ SvData* pDataBmp = new SvData( FORMAT_BITMAP );
+ pDataBmp->SetData( pTTProperties->mpBmp );
+ aDataObject->Append( pDataBmp );
+ aDataObject->CopyClipboard();
+ pTTProperties->nActualPR = 0;
+ }
+ break;*/
+ default:
+ {
+ pTTProperties->nPropertyVersion = 0;
+ }
+ }
+ return;
+ }
+}
+
+
+sal_uInt16 MyDispatcher::ExecuteFunction( sal_uInt16 nSID, SfxPoolItem** ppArgs, sal_uInt16 nMode)
+{
+ (void) ppArgs; /* avoid warning about unused parameter */
+ (void) nMode; /* avoid warning about unused parameter */
+
+ switch (nSID)
+ {
+ case IDM_FILE_EXIT: pMainWin->FileExit(); break;
+ case IDM_FILE_OPEN_TEST: pMainWin->FileOpen(); break;
+ case IDM_TEST_GROSS: pMainWin->TestGross(); break;
+ case IDM_TEST_WINTREE: pMainWin->WinTree(); break;
+ case IDM_SYS_DLG: pMainWin->SysDlg(); break;
+ default:
+ {
+ DBG_ERROR1("Dispatcher kennt Funktion nicht %s",ByteString::CreateFromInt64(nSID).GetBuffer());
+ return EXECUTE_NO;
+ }
+
+ }
+ return EXECUTE_YES;
+}
+
+PlugInDispatcher* MyApp::GetDispatcher()
+{
+ return pMyDispatcher;
+}
+
+Reference< XContentProviderManager > InitializeUCB( void )
+{
+ OUString path;
+ if( osl_Process_E_None != osl_getExecutableFile( (rtl_uString**)&path ) )
+ {
+ InfoBox( NULL, String::CreateFromAscii( "Couldn't retrieve directory of executable" ) ).Execute();
+ exit( 1 );
+ }
+ OSL_ASSERT( path.lastIndexOf( '/' ) >= 0 );
+
+
+ ::rtl::OUStringBuffer bufServices( path.copy( 0, path.lastIndexOf( '/' )+1 ) );
+ bufServices.appendAscii("services.rdb");
+ OUString services = bufServices.makeStringAndClear();
+
+ ::rtl::OUStringBuffer bufTypes( path.copy( 0, path.lastIndexOf( '/' )+1 ) );
+ bufTypes.appendAscii("types.rdb");
+ OUString types = bufTypes.makeStringAndClear();
+
+
+ Reference< XMultiServiceFactory > xSMgr;
+ try
+ {
+ xSMgr = createRegistryServiceFactory( types, services, sal_True );
+ }
+ catch( com::sun::star::uno::Exception & exc )
+ {
+ fprintf( stderr, "Couldn't bootstrap uno servicemanager for reason : %s\n" ,
+ OUStringToOString( exc.Message, RTL_TEXTENCODING_ASCII_US ).getStr() );
+ InfoBox( NULL, String( exc.Message ) ).Execute();
+ throw ;
+ }
+
+
+ //////////////////////////////////////////////////////////////////////
+ // set global factory
+ setProcessServiceFactory( xSMgr );
+
+// Create unconfigured Ucb:
+ Sequence< Any > aArgs;
+ ucbhelper::ContentBroker::initialize( xSMgr, aArgs );
+ Reference< XContentProviderManager > xUcb =
+ ucbhelper::ContentBroker::get()->getContentProviderManagerInterface();
+
+ Reference< XContentProvider > xFileProvider
+ ( xSMgr->createInstance( OUString::createFromAscii( "com.sun.star.ucb.FileContentProvider" ) ), UNO_QUERY );
+ xUcb->registerContentProvider( xFileProvider, OUString::createFromAscii( "file" ), sal_True );
+
+ return xUcb;
+}
+
+void MyApp::Main()
+{
+ Reference< XContentProviderManager > xUcb = InitializeUCB();
+ LanguageType aRequestedLanguage;
+ aRequestedLanguage = LanguageType( LANGUAGE_GERMAN );
+
+ AllSettings aSettings = GetSettings();
+ aSettings.SetUILanguage( aRequestedLanguage );
+ aSettings.SetLanguage( aRequestedLanguage );
+ SetSettings( aSettings );
+ pAppMgr = CREATEVERSIONRESMGR( tma );
+
+ MainWindow MainWin(this);
+ pMainWin = &MainWin;
+
+ MenuBar aMenu(ResId(MENU_CLIENT,*pAppMgr));
+ MainWin.SetMenuBar( &aMenu );
+ aMenu.GetPopupMenu( IDM_FILE )->SetSelectHdl(LINK(&MainWin, MainWindow, MenuSelectHdl));
+ aMenu.GetPopupMenu( IDM_TEST )->SetSelectHdl(LINK(&MainWin, MainWindow, MenuSelectHdl));
+
+ MyDispatcher MyDsp(pMainWin);
+ pMyDispatcher = &MyDsp;
+
+ MainWin.SetText(CUniString("Star Division Test Tool Client Window"));
+ MainWin.Show();
+
+ RemoteControl aRC;
+
+ Execute();
+}
+
diff --git a/automation/source/miniapp/testapp.hxx b/automation/source/miniapp/testapp.hxx
new file mode 100644
index 000000000000..a3c33ed359d3
--- /dev/null
+++ b/automation/source/miniapp/testapp.hxx
@@ -0,0 +1,125 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _TESTAPP_HXX
+#define _TESTAPP_HXX
+
+#include <vcl/svapp.hxx>
+#ifndef _DIALOG_HXX //autogen
+#include <vcl/dialog.hxx>
+#endif
+#ifndef _BUTTON_HXX //autogen
+#include <vcl/button.hxx>
+#endif
+#ifndef _FIELD_HXX //autogen
+#include <vcl/field.hxx>
+#endif
+#ifndef _EDIT_HXX //autogen
+#include <vcl/edit.hxx>
+#endif
+#ifndef _GROUP_HXX //autogen
+#include <vcl/group.hxx>
+#endif
+#ifndef _COMBOBOX_HXX //autogen
+#include <vcl/combobox.hxx>
+#endif
+#ifndef _FIXED_HXX //autogen
+#include <vcl/fixed.hxx>
+#endif
+#ifndef _MENU_HXX //autogen
+#include <vcl/menu.hxx>
+#endif
+#ifndef _WRKWIN_HXX //autogen
+#include <vcl/wrkwin.hxx>
+#endif
+#include <svl/poolitem.hxx>
+
+
+#include "editwin.hxx"
+
+
+#define EXECUTE_NO 0
+#define EXECUTE_POSSIBLE 1
+#define EXECUTE_YES 2
+#define EXECUTEMODE_ASYNCHRON 1
+#define EXECUTEMODE_DIALOGASYNCHRON 2
+
+
+class MyApp;
+class MainWindow : public WorkWindow
+{
+ MyApp *pApp;
+
+public:
+ MainWindow(MyApp *pAppl);
+ virtual sal_Bool Close(); // derived
+
+ void FileExit();
+ void FileOpen();
+ void TestGross();
+ void Tree(GHEditWindow *aEditWin, Window *pBase, sal_uInt16 Indent);
+ void WinTree();
+ void SysDlg();
+ DECL_LINK(MenuSelectHdl,MenuBar*);
+
+};
+#define PlugInDispatcher MyDispatcher
+class MyDispatcher
+{
+ MainWindow *pMainWin;
+
+public:
+ MyDispatcher(MainWindow *MainWin) : pMainWin(MainWin) {};
+ virtual ~MyDispatcher() {};
+ virtual sal_uInt16 ExecuteFunction( sal_uInt16 nSID, SfxPoolItem** ppArgs = 0, sal_uInt16 nMode = 0);
+ virtual void SetExecuteMode( sal_uInt16 nMode )
+ {
+ (void) nMode; /* avoid warning about unused parameter */
+ }; // Ist hier sowieso egal
+};
+
+class MyApp : public Application
+{
+ PopupMenu *MyMenu;
+ Timer aCommandTimer;
+ PlugInDispatcher *pMyDispatcher;
+
+public:
+ MyApp();
+ void Main();
+
+ virtual void Property( ApplicationProperty& );
+ virtual PlugInDispatcher* GetDispatcher();
+
+ MainWindow *pMainWin;
+};
+
+// -----------------------------------------------------------------------
+
+extern MyApp aApp;
+
+#endif
+
diff --git a/automation/source/mozillaserver/makefile.mk b/automation/source/mozillaserver/makefile.mk
new file mode 100644
index 000000000000..fee12e3e6649
--- /dev/null
+++ b/automation/source/mozillaserver/makefile.mk
@@ -0,0 +1,153 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..
+
+PRJNAME=automation
+TARGET=xxx
+USE_DEFFILE=TRUE
+NO_BSYMBOLIC=TRUE
+ENABLE_EXCEPTIONS=TRUE
+LIBTARGET=NO
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# ------------------------------------------------------------------
+
+PACKAGE := com$/sun$/star$/testtool
+TARGET := com_sun_star_testtool
+
+
+#RDB=$(SOLARBINDIR)$/applicat.rdb
+RDB=$(BIN)$/mozillatesttool.rdb
+
+
+GENJAVACLASSFILES = \
+ $(CLASSDIR)$/$(PACKAGE)$/XAction.class \
+ $(CLASSDIR)$/$(PACKAGE)$/XActionControl.class \
+ $(CLASSDIR)$/$(PACKAGE)$/XActionCommand.class \
+ $(CLASSDIR)$/$(PACKAGE)$/XActionControl.class \
+ $(CLASSDIR)$/$(PACKAGE)$/XActionFlow.class \
+ $(CLASSDIR)$/$(PACKAGE)$/XResult.class \
+ $(CLASSDIR)$/$(PACKAGE)$/ResultType.class \
+ $(CLASSDIR)$/$(PACKAGE)$/XMozillaTesttoolServer.class
+
+
+TYPES={$(subst,.class, $(subst,$/,. $(subst,$(CLASSDIR)$/,-T $(GENJAVACLASSFILES))))}
+GENJAVAFILES = {$(subst,.class,.java $(subst,$/class, $(GENJAVACLASSFILES)))}
+#JAVAFILES= $(GENJAVAFILES)
+
+
+
+UNOUCRDEP=$(RDB)
+UNOUCRRDB=$(RDB)
+
+UNOUCROUT=$(OUT)$/inc
+INCPRE+=$(OUT)$/inc
+
+UNOTYPES= \
+ com.sun.star.uno.TypeClass \
+ com.sun.star.uno.XAggregation \
+ com.sun.star.uno.XWeak \
+ com.sun.star.lang.XTypeProvider \
+ com.sun.star.lang.XServiceInfo \
+ com.sun.star.lang.XSingleServiceFactory \
+ com.sun.star.lang.XMultiServiceFactory \
+ com.sun.star.lang.XComponent \
+ com.sun.star.lang.XMain \
+ com.sun.star.loader.XImplementationLoader \
+ com.sun.star.registry.XRegistryKey \
+ com.sun.star.bridge.XUnoUrlResolver \
+ com.sun.star.container.XSet \
+ com.sun.star.testtool.XAction \
+ com.sun.star.testtool.XActionControl \
+ com.sun.star.testtool.XActionCommand \
+ com.sun.star.testtool.XActionControl \
+ com.sun.star.testtool.XActionFlow \
+ com.sun.star.testtool.XResult \
+ com.sun.star.testtool.ResultType \
+ com.sun.star.testtool.XMozillaTesttoolServer
+
+
+
+#SLOFILES= \
+# $(SLO)$/iserverproxy.obj \
+# $(SLO)$/broadcastclient.obj \
+# $(SLO)$/genericinformation.obj \
+# $(SLO)$/informationclient.obj
+
+# ---- test ----
+
+#LIB1TARGET=$(SLB)$/iserverproxy.lib
+#LIB1OBJFILES=$(SLOFILES)
+
+#SHL1TARGET=iserverproxy
+#SHL1STDLIBS= \
+# $(VOSLIB) $(OSLLIB) $(RTLLIB) $(TOOLSLIB) \
+# $(CPPULIB) \
+# $(CPPUHELPERLIB) \
+# $(UNOLIB) \
+# $(SVTOOLLIB) \
+# $(SALLIB) \
+# $(BOOTSTRP)
+
+#SHL1LIBS= $(LIB1TARGET) $(LB)$/ico.lib
+#SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+#DEF1NAME= $(SHL1TARGET)
+#DEF1EXPORTFILE= exports.dxp
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
+ALLTAR : $(GENJAVAFILES)
+
+ALLIDLFILES= \
+ mozillatesttoolserver.idl \
+ xmozillatesttoolserver.idl
+
+$(RDB): $(ALLIDLFILES)
+ $(TOUCH) $@
+ $(RM) $@
+ unoidl -I$(PRJ) -I$(SOLARIDLDIR) -Burd -OH$(BIN) $?
+ $(REGMERGE) $@ /UCR $(BIN)$/{$(ALLIDLFILES:f:s/.idl/.urd/)}
+ $(REGMERGE) $@ / $(SOLARBINDIR)$/applicat.rdb
+ $(REGCOMP) -register -r $@ -c $(DLLPRE)connectr$(DLLPOST)
+ $(REGCOMP) -register -r $@ -c $(DLLPRE)acceptor$(DLLPOST)
+ $(REGCOMP) -register -r $@ -c $(DLLPRE)brdgfctr$(DLLPOST)
+ $(REGCOMP) -register -r $@ -c $(DLLPRE)remotebridge$(DLLPOST)
+ $(TOUCH) $@
+
+
+$(GENJAVAFILES): $(RDB)
+ @echo Types: $(TYPES)
+ @echo Javafiles: $(GENJAVAFILES)
+ $(JAVAMAKER) -BUCR -O$(OUT) $(TYPES) $(RDB)
+
+
diff --git a/automation/source/mozillaserver/mozillatesttoolserver.idl b/automation/source/mozillaserver/mozillatesttoolserver.idl
new file mode 100644
index 000000000000..5b5b5acc1e16
--- /dev/null
+++ b/automation/source/mozillaserver/mozillatesttoolserver.idl
@@ -0,0 +1,52 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef __com_sun_star_testtool_MozillaTesttoolServer_idl__
+#define __com_sun_star_testtool_MozillaTesttoolServer_idl__
+
+#include <xmozillatesttoolserver.idl>
+
+//=============================================================================
+
+module com { module sun { module star { module testtool {
+
+//=============================================================================
+/**
+ * This service provides the ability to control Mozilla
+ *<BR>
+ */
+service MozillaTesttoolServer
+{
+ /** resolve objects via this interface.
+ */
+ interface com::sun::star::testtool::XMozillaTesttoolServer;
+};
+
+//=============================================================================
+
+}; }; }; };
+
+#endif
diff --git a/automation/source/mozillaserver/xmozillatesttoolserver.idl b/automation/source/mozillaserver/xmozillatesttoolserver.idl
new file mode 100644
index 000000000000..51755a67a35d
--- /dev/null
+++ b/automation/source/mozillaserver/xmozillatesttoolserver.idl
@@ -0,0 +1,157 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef __com_sun_star_testtool_XMozillaTesttoolServer_idl__
+#define __com_sun_star_testtool_XMozillaTesttoolServer_idl__
+
+#include <com/sun/star/uno/XInterface.idl>
+#include <com/sun/star/lang/IllegalArgumentException.idl>
+#include <com/sun/star/connection/NoConnectException.idl>
+
+//=============================================================================
+
+module com { module sun { module star { module testtool {
+
+//=============================================================================
+/** Service com.sun.star.devtools.IServerProxy implements this interface.
+ */
+[ uik(E2423753-33D6-11D1-AABE00A0-259D5623), ident( "XMozillaTesttoolServer", 1.0 ) ]
+interface XAction : com::sun::star::uno::XInterface
+{
+ /** execute one command
+ <BR>
+ */
+ void execute();
+
+};
+
+//=============================================================================
+
+
+//=============================================================================
+/** Service com.sun.star.devtools.IServerProxy implements this interface.
+ */
+[ uik(E2423753-33D6-11D1-AABE00A0-259D5623), ident( "XMozillaTesttoolServer", 1.0 ) ]
+interface XActionControl : XAction
+{
+ /** execute one command
+ <BR>
+ */
+ void execute();
+
+};
+
+//=============================================================================
+
+
+//=============================================================================
+/** Service com.sun.star.devtools.IServerProxy implements this interface.
+ */
+[ uik(E2423753-33D6-11D1-AABE00A0-259D5623), ident( "XMozillaTesttoolServer", 1.0 ) ]
+interface XActionCommand : XAction
+{
+ /** execute one command
+ <BR>
+ */
+ void execute();
+
+};
+
+//=============================================================================
+/** Service com.sun.star.devtools.IServerProxy implements this interface.
+ */
+[ uik(E2423743-33D6-11D1-AABE00A0-259D5623), ident( "XActionFlow", 1.0 ) ]
+interface XActionFlow : XAction
+{
+ /** execute one command
+ <BR>
+ */
+ void execute();
+
+};
+
+//=============================================================================
+
+}; }; }; };
+
+//=============================================================================
+
+module com { module sun { module star { module testtool {
+
+
+enum ResultType
+ {
+ SEQUENCE, /// command with SEQUENCE has been executed
+ ERROR, /// An error has ocured
+ RESULT, /// Result of a request
+ ASSERTION, /// An Assertion has been captured
+ UI_INFO /// Info about the UserInterfaace
+ };
+
+//=============================================================================
+/** Service com.sun.star.devtools.IServerProxy implements this interface.
+ */
+[ uik(E2426453-33D6-11D1-AABE00A0-259D5623), ident( "XResult", 1.0 ) ]
+interface XResult : com::sun::star::uno::XInterface
+{
+ /** execute one command
+ <BR>
+ */
+ void SetResultType( [in] ResultType aType );
+ ResultType GetResultType();
+
+ void SetValue( [in] any Value );
+ any GetValue();
+};
+
+//=============================================================================
+
+}; }; }; };
+
+//=============================================================================
+
+module com { module sun { module star { module testtool {
+
+//=============================================================================
+/** Service com.sun.star.devtools.IServerProxy implements this interface.
+ */
+[ uik(E2446735-33D6-11D1-AABE00A0-259D5623), ident( "XMozillaTesttoolServer", 1.0 ) ]
+interface XMozillaTesttoolServer : com::sun::star::uno::XInterface
+{
+ /** Control the Mozilla Browser
+ <BR>
+ */
+ [oneway] void execute( [in] XAction aAction );
+// sequence < XResult > getResults( [in] boolean bBlock ); /// bBoch = TRUE means to wait for at least 1 result
+
+};
+
+//=============================================================================
+
+}; }; }; };
+
+
+#endif
diff --git a/automation/source/server/XMLParser.cxx b/automation/source/server/XMLParser.cxx
new file mode 100644
index 000000000000..a2aab7ab1e94
--- /dev/null
+++ b/automation/source/server/XMLParser.cxx
@@ -0,0 +1,695 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_automation.hxx"
+#include <tools/stream.hxx>
+#include "statemnt.hxx"
+#include "rcontrol.hxx"
+#include "retstrm.hxx"
+#include <basic/svtmsg.hrc>
+
+#ifndef _BASIC_TTRESHLP_HXX
+#include <basic/ttstrhlp.hxx>
+#endif
+
+#include <com/sun/star/xml/sax/XParser.hpp>
+#include <com/sun/star/xml/sax/SAXException.hpp>
+#include <com/sun/star/io/XInputStream.hpp>
+#include <com/sun/star/io/XInputStream.hpp>
+#include <com/sun/star/util/XCloneable.hpp>
+#include <comphelper/processfactory.hxx>
+#include <cppuhelper/implbase2.hxx>
+#include <cppuhelper/implbase1.hxx>
+#include <com/sun/star/xml/sax/SAXParseException.hpp>
+
+using namespace com::sun::star::xml::sax;
+using namespace com::sun::star::io;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::util;
+using namespace rtl;
+
+class SVInputStream : public cppu::WeakImplHelper1< XInputStream >
+{
+ SvStream* pStream;
+public:
+ SVInputStream( SvStream* pSt ):pStream( pSt ){};
+ ~SVInputStream(){ delete pStream; pStream=NULL; }
+
+ // Methods XInputStream
+ virtual sal_Int32 SAL_CALL readBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead ) throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL readSomeBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead ) throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL skipBytes( sal_Int32 nBytesToSkip ) throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL available( ) throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL closeInput( ) throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+};
+
+
+sal_Int32 SAL_CALL SVInputStream::readBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead ) throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException)
+{
+ aData.realloc( nBytesToRead );
+ sal_Int32 nRead = pStream->Read( aData.getArray(), nBytesToRead );
+ aData.realloc( nRead );
+ return nRead;
+}
+
+sal_Int32 SAL_CALL SVInputStream::readSomeBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead ) throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException)
+{
+ return readBytes( aData, nMaxBytesToRead );
+}
+
+void SAL_CALL SVInputStream::skipBytes( sal_Int32 nBytesToSkip ) throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException)
+{
+ if ( nBytesToSkip > 0 )
+ pStream->SeekRel( nBytesToSkip );
+}
+
+sal_Int32 SAL_CALL SVInputStream::available( ) throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException)
+{
+ sal_uLong nCurrent = pStream->Tell();
+ sal_uLong nSize = pStream->Seek( STREAM_SEEK_TO_END );
+ sal_uLong nAvailable = nSize - nCurrent;
+ pStream->Seek( nCurrent );
+ return nAvailable;
+}
+
+void SAL_CALL SVInputStream::closeInput( ) throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException)
+{
+// pStream->Close(); // automatically done in destructor
+ delete pStream;
+ pStream = NULL;
+}
+
+class Node;
+SV_DECL_REF(Node)
+
+enum NodeType { NODE_CHARACTER = CONST_NodeTypeCharacter,
+ NODE_ELEMENT = CONST_NodeTypeElement,
+ NODE_COMMENT = CONST_NodeTypeComment };
+
+class Node : public SvRefBase
+{
+ NodeType aNodeType;
+ Node* pParent; // Use pointer to prevent cyclic references resulting in undeleted objects
+
+protected:
+ Node( NodeType aType ): aNodeType( aType ), pParent( NULL ){};
+ virtual ~Node();
+
+public:
+ NodeType GetNodeType() { return aNodeType; }
+ void SetParent( NodeRef xNewParent );
+ NodeRef GetParent();
+};
+
+SV_IMPL_REF(Node)
+// generate NodeRefMemberList
+SV_DECL_IMPL_REF_LIST( NodeRef, Node* )
+
+Node::~Node()
+{
+}
+
+void Node::SetParent( NodeRef xNewParent )
+{
+ pParent = &xNewParent;
+}
+
+NodeRef Node::GetParent()
+{
+ return NodeRef( pParent );
+}
+
+class CharacterNode : public Node
+{
+ String aCharacters;
+public:
+ CharacterNode( const String& aChars ): Node( NODE_CHARACTER ), aCharacters( aChars ){};
+
+ String GetCharacters() { return aCharacters; }
+};
+
+class ElementNode : public Node
+{
+ String aNodeName;
+ Reference < XAttributeList > xAttributeList;
+ NodeRefMemberList aDocumentNodeList;
+public:
+ ElementNode( const String& aName, Reference < XAttributeList > xAttributes );
+ void AppendNode( NodeRef xNewNode );
+ sal_uLong GetChildCount(){ return aDocumentNodeList.Count(); }
+ NodeRef GetChild( sal_uInt16 nIndex ){ return aDocumentNodeList.GetObject( nIndex ); }
+ Reference < XAttributeList > GetAttributes(){ return xAttributeList; }
+
+ String GetNodeName() { return aNodeName; }
+};
+
+ElementNode::ElementNode( const String& aName, Reference < XAttributeList > xAttributes )
+: Node( NODE_ELEMENT )
+, aNodeName( aName )
+{
+ if ( xAttributes.is() )
+ {
+ Reference < XCloneable > xAttributeCloner( xAttributes, UNO_QUERY );
+ if ( xAttributeCloner.is() )
+ xAttributeList = Reference < XAttributeList > ( xAttributeCloner->createClone() , UNO_QUERY );
+ else
+ {
+ DBG_ERROR("Unable to clone AttributeList");
+ }
+ }
+};
+
+void ElementNode::AppendNode( NodeRef xNewNode )
+{
+ aDocumentNodeList.Insert ( xNewNode, LIST_APPEND );
+ xNewNode->SetParent( this );
+}
+
+// XIndexAccess
+
+
+
+
+
+enum ParseAction { COLLECT_DATA, COLLECT_DATA_IGNORE_WHITESPACE, PARSE_ONLY };
+
+class SAXParser : public cppu::WeakImplHelper2< XErrorHandler, XDocumentHandler >
+{
+ String aFilename;
+ Reference < XParser > xParser;
+
+ // XErrorHandler
+ void AddToList( const sal_Char* cuType, const ::com::sun::star::uno::Any& aSAXParseException );
+ String aErrors;
+
+ NodeRef xTreeRoot;
+ NodeRef xCurrentNode;
+ sal_uLong nTimestamp;
+ ParseAction aAction;
+
+public:
+ SAXParser( const String &rFilename );
+ ~SAXParser();
+
+ // Access Methods
+ NodeRef GetCurrentNode(){ return xCurrentNode; }
+ void SetCurrentNode( NodeRef xCurrent ){ xCurrentNode = xCurrent; }
+ NodeRef GetRootNode(){ return xTreeRoot; }
+ sal_uLong GetTimestamp(){ return nTimestamp; }
+ void Touch(){ nTimestamp = Time::GetSystemTicks(); }
+
+ // Methods SAXParser
+ sal_Bool Parse( ParseAction aAct );
+ String GetErrors(){ return aErrors; }
+
+ // Methods XErrorHandler
+ virtual void SAL_CALL error( const ::com::sun::star::uno::Any& aSAXParseException ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL fatalError( const ::com::sun::star::uno::Any& aSAXParseException ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL warning( const ::com::sun::star::uno::Any& aSAXParseException ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
+
+ // Methods XDocumentHandler
+ virtual void SAL_CALL startDocument( ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL endDocument( ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL startElement( const ::rtl::OUString& aName, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttribs ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL endElement( const ::rtl::OUString& aName ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL characters( const ::rtl::OUString& aChars ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL ignorableWhitespace( const ::rtl::OUString& aWhitespaces ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL processingInstruction( const ::rtl::OUString& aTarget, const ::rtl::OUString& aData ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setDocumentLocator( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XLocator >& xLocator ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
+};
+
+
+SAXParser::SAXParser( const String &rFilename )
+: aFilename( rFilename )
+{
+ Touch();
+}
+
+SAXParser::~SAXParser()
+{
+ xParser.clear();
+}
+
+sal_Bool SAXParser::Parse( ParseAction aAct )
+{
+ aAction = aAct;
+ Touch();
+ SvStream* pStream = new SvFileStream( aFilename, STREAM_STD_READ );
+ if ( pStream->GetError() )
+ return sal_False;
+
+ InputSource sSource;
+ sSource.aInputStream = new SVInputStream( pStream ); // is refcounted and hence deletet appropriately
+ sSource.sPublicId = OUString( aFilename );
+
+ xParser = Reference < XParser > ( ::comphelper::getProcessServiceFactory()->createInstance( CUniString("com.sun.star.xml.sax.Parser") ), UNO_QUERY );
+ if ( xParser.is() )
+ {
+ xParser->setErrorHandler( ( XErrorHandler*) this );
+ if ( aAction == COLLECT_DATA || aAction == COLLECT_DATA_IGNORE_WHITESPACE )
+ xParser->setDocumentHandler( ( XDocumentHandler*) this );
+
+ try
+ {
+ xParser->parseStream ( sSource );
+ }
+ catch( class SAXParseException & rPEx)
+ {
+#ifdef DBG_ERROR
+ String aMemo( rPEx.Message );
+ aMemo = String( aMemo );
+#endif
+ }
+ catch( class Exception & rEx)
+ {
+#ifdef DBG_ERROR
+ String aMemo( rEx.Message );
+ aMemo = String( aMemo );
+#endif
+ }
+ xParser->setErrorHandler( NULL ); // otherwile Object holds itself
+ if ( aAction == COLLECT_DATA || aAction == COLLECT_DATA_IGNORE_WHITESPACE )
+ xParser->setDocumentHandler( NULL ); // otherwile Object holds itself
+ }
+ else
+ return sal_False;
+ return sal_True;
+}
+
+
+// Helper Methods XErrorHandler
+void SAXParser::AddToList( const sal_Char* cuType, const ::com::sun::star::uno::Any& aSAXParseException )
+{
+ SAXParseException aException;
+ aSAXParseException >>= aException;
+
+ aErrors.Append( String( aException.PublicId ) );
+ aErrors.AppendAscii( "(" );
+ aErrors.Append( String::CreateFromInt64( aException.LineNumber ) );
+ aErrors.AppendAscii( ":" );
+ aErrors.Append( String::CreateFromInt64( aException.ColumnNumber ) );
+ aErrors.AppendAscii( ") : " );
+ aErrors.AppendAscii( cuType );
+ aErrors.AppendAscii( ": " );
+ aErrors.Append( String( aException.Message ) );
+ aErrors.AppendAscii( "\n" );
+}
+
+// Methods XErrorHandler
+void SAL_CALL SAXParser::error( const ::com::sun::star::uno::Any& aSAXParseException ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException)
+{
+ AddToList( "error", aSAXParseException );
+}
+
+void SAL_CALL SAXParser::fatalError( const ::com::sun::star::uno::Any& aSAXParseException ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException)
+{
+ AddToList( "fatal error", aSAXParseException );
+}
+
+void SAL_CALL SAXParser::warning( const ::com::sun::star::uno::Any& aSAXParseException ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException)
+{
+ AddToList( "warning", aSAXParseException );
+}
+
+
+// Methods XDocumentHandler
+void SAXParser::startDocument( ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException)
+{
+ xTreeRoot = new ElementNode( CUniString("/"), Reference < XAttributeList > (NULL) );
+ xCurrentNode = xTreeRoot;
+ Touch();
+}
+
+void SAXParser::endDocument( ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException)
+{
+}
+
+void SAXParser::startElement( const ::rtl::OUString& aName, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttribs ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException)
+{
+ NodeRef xNewNode = new ElementNode ( String(aName), xAttribs );
+ ((ElementNode*)(&xCurrentNode))->AppendNode( xNewNode );
+ xCurrentNode = xNewNode;
+}
+
+void SAXParser::endElement( const ::rtl::OUString& aName ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException)
+{
+ (void) aName; /* avoid warning about unused parameter */
+ xCurrentNode = xCurrentNode->GetParent();
+}
+
+void SAXParser::characters( const ::rtl::OUString& aChars ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException)
+{
+ if ( aAction == COLLECT_DATA_IGNORE_WHITESPACE )
+ { // check for whitespace
+ sal_Bool bAllWhitespace = sal_True;
+ for ( int i = 0 ; bAllWhitespace && i < aChars.getLength() ; i++ )
+ if ( aChars[i] != 10 // LF
+ && aChars[i] != 13 // CR
+ && aChars[i] != ' ' // Blank
+ && aChars[i] != '\t' ) // Tab
+ bAllWhitespace = sal_False;
+ if ( bAllWhitespace )
+ return;
+ }
+ NodeRef xNewNode = new CharacterNode ( String(aChars) );
+ ((ElementNode*)(&xCurrentNode))->AppendNode( xNewNode );
+}
+
+void SAXParser::ignorableWhitespace( const ::rtl::OUString& aWhitespaces ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException)
+{
+ (void) aWhitespaces; /* avoid warning about unused parameter */
+}
+
+void SAXParser::processingInstruction( const ::rtl::OUString& aTarget, const ::rtl::OUString& aData ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException)
+{
+ (void) aTarget; /* avoid warning about unused parameter */
+ (void) aData; /* avoid warning about unused parameter */
+}
+
+void SAXParser::setDocumentLocator( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XLocator >& xLocator ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException)
+{
+ (void) xLocator; /* avoid warning about unused parameter */
+#if OSL_DEBUG_LEVEL > 1
+ ::rtl::OUString aTester;
+ aTester = xLocator->getPublicId();
+ aTester = xLocator->getSystemId();
+#endif
+}
+
+
+
+
+void StatementCommand::HandleSAXParser()
+{
+ static Reference < XReference > xParserKeepaliveReference; // this is to keep the Object alive only
+ static SAXParser* pSAXParser;
+
+ // We need spechial prerequisites for these!
+
+ ElementNode* pElementNode = NULL;
+ switch ( nMethodId )
+ {
+ case RC_SAXGetNodeType:
+ case RC_SAXGetAttributeCount:
+ case RC_SAXGetAttributeName:
+ case RC_SAXGetAttributeValue:
+ case RC_SAXGetChildCount:
+ case RC_SAXGetElementName:
+ case RC_SAXGetChars:
+
+ case RC_SAXSeekElement:
+ case RC_SAXHasElement:
+ case RC_SAXGetElementPath:
+ {
+ if ( xParserKeepaliveReference.is() && pSAXParser->GetCurrentNode().Is() )
+ {
+ if ( pSAXParser->GetCurrentNode()->GetNodeType() == NODE_ELEMENT )
+ {
+ NodeRef xNode=pSAXParser->GetCurrentNode();
+ pElementNode = (ElementNode*)(&xNode);
+ }
+ }
+ else
+ {
+ ReportError( GEN_RES_STR1( S_NO_SAX_PARSER, RcString( nMethodId ) ) );
+ return;
+ }
+
+ }
+ }
+
+ switch ( nMethodId )
+ {
+ case RC_SAXCheckWellformed:
+ {
+ if( (nParams & PARAM_STR_1) )
+ {
+ xParserKeepaliveReference.clear();
+ pSAXParser = new SAXParser( aString1 );
+ xParserKeepaliveReference = ( XReference* )pSAXParser;
+ if ( !xParserKeepaliveReference.is() )
+ ReportError( GEN_RES_STR1( S_NO_SAX_PARSER, RcString( nMethodId ) ) );
+ else
+ {
+ if ( !pSAXParser->Parse( PARSE_ONLY ) )
+ ReportError( GEN_RES_STR1( S_NO_SAX_PARSER, RcString( nMethodId ) ) );
+ pRet->GenReturn ( RET_Value, nMethodId, pSAXParser->GetErrors() );
+ }
+
+ xParserKeepaliveReference.clear();
+ }
+ else
+ ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) );
+ }
+ break;
+
+ case RC_SAXReadFile:
+ {
+ if( (nParams & PARAM_STR_1) )
+ {
+ ParseAction aAction;
+ if( (nParams & PARAM_BOOL_1) && bBool1 )
+ aAction = COLLECT_DATA;
+ else
+ aAction = COLLECT_DATA_IGNORE_WHITESPACE;
+
+ xParserKeepaliveReference.clear();
+ pSAXParser = new SAXParser( aString1 );
+ xParserKeepaliveReference = ( XReference* )pSAXParser;
+ if ( !xParserKeepaliveReference.is() )
+ ReportError( GEN_RES_STR1( S_NO_SAX_PARSER, RcString( nMethodId ) ) );
+ else
+ {
+
+ if ( !pSAXParser->Parse( aAction ) )
+ ReportError( GEN_RES_STR1( S_NO_SAX_PARSER, RcString( nMethodId ) ) );
+ pRet->GenReturn ( RET_Value, nMethodId, pSAXParser->GetErrors() );
+ }
+ }
+ else
+ ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) );
+ }
+ break;
+ case RC_SAXGetNodeType:
+ {
+ pRet->GenReturn ( RET_Value, nMethodId, (comm_ULONG)pSAXParser->GetCurrentNode()->GetNodeType() );
+ }
+ break;
+ case RC_SAXGetAttributeCount:
+ case RC_SAXGetAttributeName:
+ case RC_SAXGetAttributeValue:
+ case RC_SAXGetChildCount:
+ case RC_SAXGetElementName:
+ {
+ if ( pElementNode )
+ {
+ Reference < XAttributeList > xAttributeList = pElementNode->GetAttributes();
+ switch ( nMethodId )
+ {
+ case RC_SAXGetElementName:
+ pRet->GenReturn ( RET_Value, nMethodId, pElementNode->GetNodeName() );
+ break;
+ case RC_SAXGetChildCount:
+ pRet->GenReturn ( RET_Value, nMethodId, (comm_ULONG)pElementNode->GetChildCount() );
+ break;
+ case RC_SAXGetAttributeCount:
+ if ( xAttributeList.is() )
+ pRet->GenReturn ( RET_Value, nMethodId, (comm_ULONG)xAttributeList->getLength() );
+ else
+ pRet->GenReturn ( RET_Value, nMethodId, (comm_ULONG)0 );
+ break;
+ case RC_SAXGetAttributeName:
+ {
+ if( (nParams & PARAM_USHORT_1) && ValueOK( rtl::OString(), RcString( nMethodId ), nNr1, xAttributeList.is()?xAttributeList->getLength():0 ) )
+ {
+ String aRet( xAttributeList->getNameByIndex( nNr1-1 ) );
+ pRet->GenReturn ( RET_Value, nMethodId, aRet );
+ }
+ else
+ ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) );
+ }
+ break;
+ case RC_SAXGetAttributeValue:
+ // Number or String
+ {
+ if( (nParams & PARAM_USHORT_1) && ValueOK( rtl::OString(), RcString( nMethodId ), nNr1, xAttributeList.is()?xAttributeList->getLength():0 ) )
+ {
+ String aRet( xAttributeList->getValueByIndex( nNr1-1 ) );
+ pRet->GenReturn ( RET_Value, nMethodId, aRet );
+ }
+ else if( (nParams & PARAM_STR_1) && xAttributeList.is() )
+ {
+ String aRet( xAttributeList->getValueByName( aString1 ) );
+ pRet->GenReturn ( RET_Value, nMethodId, aRet );
+ }
+ else
+ ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) );
+ }
+ break;
+
+ default:
+ ReportError( GEN_RES_STR1( S_INTERNAL_ERROR, RcString( nMethodId ) ) );
+ }
+ }
+ else
+ ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) );
+ }
+ break;
+ case RC_SAXGetChars:
+ {
+ if ( pSAXParser->GetCurrentNode()->GetNodeType() == NODE_CHARACTER )
+ {
+ NodeRef xNode=pSAXParser->GetCurrentNode();
+ CharacterNode* aCharacterNode = (CharacterNode*)(&xNode);
+ pRet->GenReturn ( RET_Value, nMethodId, aCharacterNode->GetCharacters() );
+ }
+ else
+ ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) );
+ }
+ break;
+
+ case RC_SAXSeekElement:
+ case RC_SAXHasElement:
+ // Number or String
+ {
+ sal_Bool bCheckOnly = nMethodId == RC_SAXHasElement;
+
+ if( (nParams & PARAM_USHORT_1) && !(nParams & PARAM_STR_1) )
+ {
+ if ( nNr1 == 0 )
+ {
+ if ( bCheckOnly )
+ pRet->GenReturn ( RET_Value, nMethodId, pSAXParser->GetCurrentNode()->GetParent().Is() );
+ else if ( pSAXParser->GetCurrentNode()->GetParent().Is() )
+ pSAXParser->SetCurrentNode( pSAXParser->GetCurrentNode()->GetParent() );
+ }
+ else if ( !pElementNode )
+ ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) );
+ else if ( bCheckOnly )
+ pRet->GenReturn ( RET_Value, nMethodId, ValueOK( rtl::OString(), RcString( nMethodId ), nNr1, pElementNode->GetChildCount() ) );
+ else if ( ValueOK( rtl::OString(), RcString( nMethodId ), nNr1, pElementNode->GetChildCount() ) )
+ pSAXParser->SetCurrentNode( pElementNode->GetChild( nNr1-1 ) );
+ }
+ else if( (nParams & PARAM_STR_1) )
+ {
+ if ( aString1.EqualsAscii( "/" ) )
+ {
+ if ( bCheckOnly )
+ pRet->GenReturn ( RET_Value, nMethodId, (comm_BOOL)sal_True );
+ else
+ pSAXParser->SetCurrentNode( pSAXParser->GetRootNode() );
+ }
+ else if ( aString1.Copy(0,2).EqualsAscii( "*:" ) )
+ {
+ sal_uLong nTimestamp = (sal_uLong)aString1.GetToken( 1, ':' ).ToInt64();
+ sal_uLong nPointer = (sal_uLong)aString1.GetToken( 2, ':' ).ToInt64();
+ if ( bCheckOnly )
+ pRet->GenReturn ( RET_Value, nMethodId, (comm_BOOL)(pSAXParser->GetTimestamp() == nTimestamp) );
+ else
+ if ( pSAXParser->GetTimestamp() == nTimestamp )
+ {
+ {
+ Node* pNode = (Node*)nPointer;
+ pSAXParser->SetCurrentNode( NodeRef( pNode ) );
+ }
+ }
+ else
+ ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) );
+ }
+ else if ( pElementNode )
+ {
+ sal_uInt16 nNthOccurance;
+ if( (nParams & PARAM_USHORT_1) )
+ nNthOccurance = nNr1;
+ else
+ nNthOccurance = 1;
+
+ sal_uInt16 i;
+ NodeRef xNew;
+ for ( i = 0 ; i < pElementNode->GetChildCount() && !xNew.Is() ; i++ )
+ {
+ xNew = pElementNode->GetChild( i );
+ if ( xNew->GetNodeType() == NODE_ELEMENT )
+ {
+ ElementNode* pNewElement = (ElementNode*)(&xNew);
+ if ( aString1.Equals( pNewElement->GetNodeName() ) )
+ {
+ if ( nNthOccurance > 1 )
+ {
+ xNew.Clear();
+ nNthOccurance--;
+ }
+ }
+ else
+ xNew.Clear();
+ }
+ else
+ xNew.Clear();
+ }
+ if ( bCheckOnly )
+ pRet->GenReturn ( RET_Value, nMethodId, xNew.Is() );
+ else
+ if ( xNew.Is() )
+ pSAXParser->SetCurrentNode( xNew );
+ else
+ ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) );
+ }
+ else
+ if ( bCheckOnly )
+ pRet->GenReturn ( RET_Value, nMethodId, (comm_BOOL)sal_False );
+ else
+ ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) );
+ }
+ else
+ ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) );
+ }
+ break;
+ case RC_SAXGetElementPath:
+ {
+ DBG_ASSERT( sizeof( sal_uIntPtr ) == sizeof ( void* ), "Pointertype has different size than sal_uIntPtr");
+ String aPath;
+ aPath.AppendAscii( "*:" );
+ aPath.Append( String::CreateFromInt64( pSAXParser->GetTimestamp() ) );
+ aPath.AppendAscii( ":" );
+ NodeRef xNode=pSAXParser->GetCurrentNode();
+ Node* pNode = (Node*)(&xNode);
+ aPath.Append( String::CreateFromInt64( (sal_uIntPtr)pNode ) );
+ pRet->GenReturn ( RET_Value, nMethodId, aPath );
+ }
+ break;
+
+ case RC_SAXRelease:
+ {
+ xParserKeepaliveReference.clear();
+ }
+ break;
+ default:
+ ReportError( GEN_RES_STR1( S_INTERNAL_ERROR, RcString( nMethodId ) ) );
+ }
+}
+
diff --git a/automation/source/server/cmdbasestream.cxx b/automation/source/server/cmdbasestream.cxx
new file mode 100644
index 000000000000..b17bf66c0597
--- /dev/null
+++ b/automation/source/server/cmdbasestream.cxx
@@ -0,0 +1,350 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_automation.hxx"
+
+/*************************************************************************
+ *
+ * ATTENTION
+ * This file is intended to work inside and outside the StarOffice environment.
+ * Only adaption of file commtypes.hxx should be necessary. Else it is a bug!
+ *
+ ************************************************************************/
+#include <osl/endian.h>
+
+#include "cmdbasestream.hxx"
+#include "rcontrol.hxx"
+
+CmdBaseStream::CmdBaseStream()
+: pCommStream( NULL )
+{
+}
+
+CmdBaseStream::~CmdBaseStream()
+{
+}
+
+void CmdBaseStream::GenError (rtl::OString *pUId, comm_String *pString )
+{
+ Write(comm_USHORT(SIReturnError));
+ Write(pUId);
+ Write(pString);
+}
+
+void CmdBaseStream::GenReturn (comm_USHORT nRet, comm_ULONG nUId )
+{
+ Write(comm_USHORT(SIReturn));
+ Write(nRet);
+ Write(nUId);
+ Write(comm_USHORT(PARAM_NONE)); // Typ der folgenden Parameter
+}
+
+void CmdBaseStream::GenReturn (comm_USHORT nRet, rtl::OString *pUId, comm_ULONG nNr )
+{
+ Write(comm_USHORT(SIReturn));
+ Write(nRet);
+ if ( pUId->equals( rtl::OString( "UID_ACTIVE" ) ) )
+ Write(comm_ULONG(0));
+ else
+ Write(pUId);
+ Write(comm_USHORT(PARAM_ULONG_1)); // Typ der folgenden Parameter
+ Write(nNr);
+}
+
+void CmdBaseStream::GenReturn (comm_USHORT nRet, rtl::OString *pUId, comm_String *pString )
+{
+ Write(comm_USHORT(SIReturn));
+ Write(nRet);
+ if ( pUId->equals( rtl::OString( "UID_ACTIVE" ) ) )
+ Write(comm_ULONG(0));
+ else
+ Write(pUId);
+ Write(comm_USHORT(PARAM_STR_1)); // Typ der folgenden Parameter
+ Write(pString);
+}
+
+void CmdBaseStream::GenReturn (comm_USHORT nRet, rtl::OString *pUId, comm_BOOL bBool )
+{
+ Write(comm_USHORT(SIReturn));
+ Write(nRet);
+ if ( pUId->equals( rtl::OString( "UID_ACTIVE" ) ) )
+ Write(comm_ULONG(0));
+ else
+ Write(pUId);
+ Write(comm_USHORT(PARAM_BOOL_1)); // Typ der folgenden Parameter
+ Write(bBool);
+}
+
+void CmdBaseStream::GenReturn (comm_USHORT nRet, rtl::OString *pUId, comm_ULONG nNr, comm_String *pString, comm_BOOL bBool )
+{
+ Write(comm_USHORT(SIReturn));
+ Write(nRet);
+ if ( pUId->equals( rtl::OString( "UID_ACTIVE" ) ) )
+ Write(comm_ULONG(0));
+ else
+ Write(pUId);
+ Write(comm_USHORT(PARAM_ULONG_1|PARAM_STR_1|PARAM_BOOL_1)); // Typ der folgenden Parameter
+ Write(nNr);
+ Write(pString);
+ Write(bBool);
+}
+
+void CmdBaseStream::GenReturn (comm_USHORT nRet, comm_USHORT nMethod, comm_ULONG nNr )
+{
+ Write(comm_USHORT(SIReturn));
+ Write(nRet);
+ Write((comm_ULONG)nMethod); //HELPID BACKWARD (no sal_uLong needed)
+ Write(comm_USHORT(PARAM_ULONG_1)); // Typ der folgenden Parameter
+ Write(nNr);
+}
+
+void CmdBaseStream::GenReturn (comm_USHORT nRet, comm_USHORT nMethod, comm_String *pString )
+{
+ Write(comm_USHORT(SIReturn));
+ Write(nRet);
+ Write((comm_ULONG)nMethod); //HELPID BACKWARD (no sal_uLong needed)
+ Write(comm_USHORT(PARAM_STR_1)); // Typ der folgenden Parameter
+ Write(pString);
+}
+
+void CmdBaseStream::GenReturn (comm_USHORT nRet, comm_USHORT nMethod, comm_BOOL bBool )
+{
+ Write(comm_USHORT(SIReturn));
+ Write(nRet);
+ Write((comm_ULONG)nMethod); //HELPID BACKWARD (no sal_uLong needed)
+ Write(comm_USHORT(PARAM_BOOL_1)); // Typ der folgenden Parameter
+ Write(bBool);
+}
+
+void CmdBaseStream::GenReturn (comm_USHORT nRet, comm_USHORT nMethod, comm_USHORT nNr )
+{
+ Write(comm_USHORT(SIReturn));
+ Write(nRet);
+ Write((comm_ULONG)nMethod); //HELPID BACKWARD (no sal_uLong needed)
+ Write(comm_USHORT(PARAM_USHORT_1)); // Typ der folgenden Parameter
+ Write(nNr);
+}
+
+
+// MacroRecorder
+void CmdBaseStream::GenReturn( comm_USHORT nRet, rtl::OString *pUId, comm_USHORT nMethod )
+{
+ Write(comm_USHORT(SIReturn));
+ Write(nRet);
+ Write(pUId);
+ Write(comm_USHORT(PARAM_USHORT_1)); // Typ der folgenden Parameter
+ Write(nMethod);
+}
+
+void CmdBaseStream::GenReturn( comm_USHORT nRet, rtl::OString *pUId, comm_USHORT nMethod, comm_String *pString )
+{
+ Write(comm_USHORT(SIReturn));
+ Write(nRet);
+ Write(pUId);
+ Write(comm_USHORT(PARAM_USHORT_1|PARAM_STR_1)); // Typ der folgenden Parameter
+ Write(nMethod);
+ Write(pString);
+}
+
+void CmdBaseStream::GenReturn( comm_USHORT nRet, rtl::OString *pUId, comm_USHORT nMethod, comm_String *pString, comm_BOOL bBool )
+{
+ Write(comm_USHORT(SIReturn));
+ Write(nRet);
+ Write(pUId);
+ Write(comm_USHORT(PARAM_USHORT_1|PARAM_STR_1|PARAM_BOOL_1)); // Typ der folgenden Parameter
+ Write(nMethod);
+ Write(pString);
+ Write(bBool);
+}
+
+void CmdBaseStream::GenReturn( comm_USHORT nRet, rtl::OString *pUId, comm_USHORT nMethod, comm_BOOL bBool )
+{
+ Write(comm_USHORT(SIReturn));
+ Write(nRet);
+ Write(pUId);
+ Write(comm_USHORT(PARAM_USHORT_1|PARAM_BOOL_1)); // Typ der folgenden Parameter
+ Write(nMethod);
+ Write(bBool);
+}
+
+void CmdBaseStream::GenReturn( comm_USHORT nRet, rtl::OString *pUId, comm_USHORT nMethod, comm_ULONG nNr )
+{
+ Write(comm_USHORT(SIReturn));
+ Write(nRet);
+ Write(pUId);
+ Write(comm_USHORT(PARAM_USHORT_1|PARAM_ULONG_1)); // Typ der folgenden Parameter
+ Write(nMethod);
+ Write(nNr);
+}
+
+
+
+void CmdBaseStream::Read (comm_USHORT &nNr)
+{
+ comm_USHORT nId;
+ *pCommStream >> nId;
+ if (pCommStream->IsEof()) return;
+#ifdef DBG_UTIL
+ if (nId != BinUSHORT) DBG_ERROR1( "Falscher Typ im Stream: Erwartet USHORT, gefunden :%hu", nId );
+#endif
+ *pCommStream >> nNr;
+}
+
+void CmdBaseStream::Read (comm_ULONG &nNr)
+{
+ comm_USHORT nId;
+ *pCommStream >> nId;
+ if (pCommStream->IsEof()) return;
+#ifdef DBG_UTIL
+ if (nId != BinULONG) DBG_ERROR1( "Falscher Typ im Stream: Erwartet ULONG, gefunden :%hu", nId );
+#endif
+ *pCommStream >> nNr;
+}
+
+void CmdBaseStream::Read (comm_UniChar* &aString, comm_USHORT &nLenInChars )
+{
+ comm_USHORT nId;
+ *pCommStream >> nId;
+#ifdef DBG_UTIL
+ if (nId != BinString) DBG_ERROR1( "Falscher Typ im Stream: Erwartet String, gefunden :%hu", nId );
+#endif
+
+ *pCommStream >> nLenInChars;
+
+ aString = new comm_UniChar [nLenInChars];
+ pCommStream->Read( aString, ((comm_ULONG)nLenInChars) * sizeof( comm_UniChar ) );
+#ifdef OSL_BIGENDIAN
+ // we have to change the byteorder
+ comm_USHORT n;
+ for ( n = 0 ; n < nLenInChars ; n++ )
+ aString[ n ] = aString[ n ] >> 8 | aString[ n ] << 8;
+#endif
+}
+
+void CmdBaseStream::Read (comm_BOOL &bBool)
+{
+ comm_USHORT nId;
+ *pCommStream >> nId;
+#ifdef DBG_UTIL
+ if (nId != BinBool) DBG_ERROR1( "Falscher Typ im Stream: Erwartet BOOL, gefunden :%hu", nId );
+#endif
+ *pCommStream >> bBool;
+}
+
+comm_USHORT CmdBaseStream::GetNextType()
+{
+ comm_USHORT nId;
+ *pCommStream >> nId;
+ pCommStream->SeekRel(-2);
+ return nId;
+}
+
+
+void CmdBaseStream::Write( comm_USHORT nNr )
+{
+ *pCommStream << comm_USHORT( BinUSHORT );
+ *pCommStream << nNr;
+}
+
+void CmdBaseStream::Write( comm_ULONG nNr )
+{
+ *pCommStream << comm_USHORT( BinULONG );
+ *pCommStream << nNr;
+}
+
+void CmdBaseStream::Write( const comm_UniChar* aString, comm_USHORT nLenInChars )
+{
+ *pCommStream << comm_USHORT(BinString);
+
+ comm_USHORT n;
+
+ // remove BiDi and zero-width-markers 0x200B - 0x200F
+ // remove BiDi and paragraph-markers 0x2028 - 0x202E
+
+ comm_UniChar* aNoBiDiString;
+ aNoBiDiString = new comm_UniChar [nLenInChars];
+ comm_USHORT nNewLenInChars = 0;
+ for ( n = 0 ; n < nLenInChars ; n++ )
+ {
+ comm_UniChar c = aString[ n ];
+ if ( ((c >= 0x200B) && (c <= 0x200F))
+ ||((c >= 0x2028) && (c <= 0x202E)) )
+ { //Ignore character
+ }
+ else
+ {
+ aNoBiDiString[ nNewLenInChars ] = c;
+ nNewLenInChars++;
+ }
+ }
+
+ *pCommStream << nNewLenInChars;
+
+#ifdef OSL_BIGENDIAN
+ // we have to change the byteorder
+ comm_UniChar* aNewString;
+ aNewString = new comm_UniChar [nNewLenInChars];
+ for ( n = 0 ; n < nNewLenInChars ; n++ )
+ aNewString[ n ] = aNoBiDiString[ n ] >> 8 | aNoBiDiString[ n ] << 8;
+ pCommStream->Write( aNewString, ((comm_ULONG)nNewLenInChars) * sizeof( comm_UniChar ) );
+ delete [] aNewString;
+#else
+ pCommStream->Write( aNoBiDiString, ((comm_ULONG)nNewLenInChars) * sizeof( comm_UniChar ) );
+#endif
+
+ delete [] aNoBiDiString;
+}
+
+void CmdBaseStream::Write( comm_BOOL bBool )
+{
+ *pCommStream << comm_USHORT( BinBool );
+ *pCommStream << bBool;
+}
+
+void CmdBaseStream::Read ( comm_String* &pString )
+{
+ (void) pString; /* avoid warning about unused parameter */
+ DBG_ERROR("Read ( comm_String* &pString ) Not Implemented");
+}
+void CmdBaseStream::Read ( rtl::OString* &pId )
+{
+ (void) pId; /* avoid warning about unused parameter */
+ DBG_ERROR("Read ( rtl::OString* &pId ) Not Implemented");
+}
+
+void CmdBaseStream::Write( comm_String *pString )
+{
+ (void) pString; /* avoid warning about unused parameter */
+ DBG_ERROR("Write( comm_String *pString ) Not Implemented");
+}
+void CmdBaseStream::Write( rtl::OString* pId )
+{
+ (void) pId; /* avoid warning about unused parameter */
+ DBG_ERROR("Write( rtl::OString* pId ) Not Implemented");
+}
+
diff --git a/automation/source/server/editwin.cxx b/automation/source/server/editwin.cxx
new file mode 100644
index 000000000000..b1897152a337
--- /dev/null
+++ b/automation/source/server/editwin.cxx
@@ -0,0 +1,164 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_automation.hxx"
+
+#if OSL_DEBUG_LEVEL > 1
+#include <vcl/svapp.hxx>
+#include "editwin.hxx"
+
+
+class ImpWorkWindow : public WorkWindow
+{
+public:
+ MultiLineEdit m_aInhalt;
+ ImpWorkWindow( WorkWindow *pParent, const UniString &rName, WinBits );
+ ~ImpWorkWindow();
+ void Resize();
+};
+
+ImpWorkWindow::ImpWorkWindow( WorkWindow *pParent, const String &rName, WinBits iWstyle )
+: WorkWindow( pParent , WB_SIZEMOVE )
+, m_aInhalt( this, iWstyle )
+{
+ m_aInhalt.Show();
+ SetText(rName);
+ SetPosSizePixel( Point( 1,40 ), Size(500,150) );
+ Resize();
+}
+
+ImpWorkWindow::~ImpWorkWindow()
+{
+ Hide();
+}
+
+void ImpWorkWindow::Resize()
+{
+ m_aInhalt.SetPosSizePixel( Point(), GetOutputSizePixel() );
+}
+
+sal_Bool EditWindow::Close()
+{
+ if ( pImpWorkWindow )
+ {
+ delete pImpWorkWindow;
+ pImpWorkWindow = NULL;
+ }
+ return sal_True;
+}
+
+void EditWindow::Show()
+{
+ if ( Check() )
+ pImpWorkWindow->Show();
+ else
+ bShowWin = sal_True;
+}
+
+void EditWindow::Hide()
+{
+ if ( Check() )
+ pImpWorkWindow->Hide();
+ else
+ bShowWin = sal_False;
+}
+
+EditWindow::EditWindow( WorkWindow *pParent, const String &rName, WinBits iWstyle )
+: pImpWorkWindow(NULL)
+, pMemParent(pParent)
+, aMemName(rName)
+, iMemWstyle(iWstyle)
+, nTextLen(0)
+, bQuiet(sal_False)
+{
+}
+
+EditWindow::~EditWindow()
+{
+ Close();
+}
+
+sal_Bool EditWindow::Check()
+{
+ if ( ! pImpWorkWindow && Application::IsInExecute() )
+ {
+ pImpWorkWindow = new ImpWorkWindow( pMemParent, aMemName, iMemWstyle );
+ pImpWorkWindow->m_aInhalt.SetText( aMemPreWinText );
+ nTextLen = aMemPreWinText.Len();
+ aMemPreWinText.Erase();
+ if ( bShowWin )
+ pImpWorkWindow->Show();
+ return sal_True;
+ }
+ return pImpWorkWindow != NULL;
+}
+
+void EditWindow::Clear()
+{
+ if ( Check() )
+ {
+ pImpWorkWindow->m_aInhalt.SetText( String() );
+ nTextLen = 0;
+ }
+ aMemPreWinText.Erase();
+}
+
+void EditWindow::AddText( const sal_Char* rNew )
+{
+ AddText( UniString::CreateFromAscii( rNew ) );
+}
+
+void EditWindow::AddText( const String &rNew )
+{
+ if ( bQuiet ) return;
+
+ String aText = rNew;
+ aText.ConvertLineEnd();
+
+ if ( Check() )
+ {
+ if ( nTextLen > 5000 )
+ {
+ pImpWorkWindow->m_aInhalt.SetText( pImpWorkWindow->m_aInhalt.GetText().Erase(0,1000) );
+ nTextLen = pImpWorkWindow->m_aInhalt.GetText().Len(); // Absolut, um Fehler sonstwo auszubügeln
+ }
+
+
+ pImpWorkWindow->m_aInhalt.SetSelection( Selection( SELECTION_MAX, SELECTION_MAX ) );
+ pImpWorkWindow->m_aInhalt.ReplaceSelected( aText );
+ nTextLen = nTextLen + aText.Len();
+ pImpWorkWindow->m_aInhalt.SetSelection( Selection( SELECTION_MAX, SELECTION_MAX ) );
+ }
+ else
+ {
+ aMemPreWinText += aText;
+ }
+}
+
+#endif
+
diff --git a/automation/source/server/editwin.hxx b/automation/source/server/editwin.hxx
new file mode 100644
index 000000000000..d02e96276507
--- /dev/null
+++ b/automation/source/server/editwin.hxx
@@ -0,0 +1,74 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _EDITWIN_HXX
+#define _EDITWIN_HXX
+
+#if OSL_DEBUG_LEVEL > 1
+
+#ifndef _WRKWIN_HXX //autogen
+#include <vcl/wrkwin.hxx>
+#endif
+
+#ifndef _EDIT_HXX //autogen
+#include <svtools/svmedit.hxx>
+#endif
+
+class ImpWorkWindow;
+
+class EditWindow
+{
+protected:
+ ImpWorkWindow *pImpWorkWindow;
+ sal_Bool check();
+
+ WorkWindow *pMemParent;
+ String aMemName;
+ WinBits iMemWstyle;
+
+ String aMemPreWinText;
+ sal_Bool bShowWin;
+
+ xub_StrLen nTextLen; // aus Performanzgründen eigene Länge mitführen
+
+public:
+ EditWindow( WorkWindow *pParent, const UniString &rName = UniString( RTL_CONSTASCII_USTRINGPARAM ( "Debug" ) ), WinBits iWstyle = WB_HSCROLL | WB_VSCROLL );
+ virtual ~EditWindow();
+
+ void Clear();
+ void Show();
+ void Hide();
+ void AddText( const String &rNew );
+ void AddText( const sal_Char* rNew );
+
+ virtual sal_Bool Close(); // derived
+ sal_Bool bQuiet;
+ sal_Bool Check();
+};
+
+#endif
+#endif
+
diff --git a/automation/source/server/makefile.mk b/automation/source/server/makefile.mk
new file mode 100644
index 000000000000..bced075be72a
--- /dev/null
+++ b/automation/source/server/makefile.mk
@@ -0,0 +1,71 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+PRJ=..$/..
+
+PRJNAME=automation
+TARGET=server
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files --------------------------------------------------------
+
+SLOFILES = \
+ $(SLO)$/XMLParser.obj \
+ $(SLO)$/recorder.obj \
+ $(SLO)$/svcommstream.obj \
+ $(SLO)$/cmdbasestream.obj \
+ $(SLO)$/scmdstrm.obj \
+ $(SLO)$/statemnt.obj \
+ $(SLO)$/sta_list.obj \
+ $(SLO)$/editwin.obj \
+ $(SLO)$/server.obj \
+ $(SLO)$/retstrm.obj \
+ $(SLO)$/profiler.obj
+
+
+OBJFILES = \
+ $(OBJ)$/cmdbasestream.obj \
+ $(OBJ)$/svcommstream.obj
+
+EXCEPTIONSFILES = \
+ $(SLO)$/statemnt.obj \
+ $(SLO)$/server.obj \
+ $(SLO)$/XMLParser.obj
+
+NOOPTFILES = $(SLO)$/statemnt.obj
+
+.IF "$(OS)"=="SOLARIS"
+SLOFILES += $(SLO)$/prof_usl.obj
+.ELSE
+SLOFILES += $(SLO)$/prof_nul.obj
+.ENDIF
+
+# --- Tagets -------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/automation/source/server/prof_nul.cxx b/automation/source/server/prof_nul.cxx
new file mode 100644
index 000000000000..314b2d0c41e5
--- /dev/null
+++ b/automation/source/server/prof_nul.cxx
@@ -0,0 +1,96 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_automation.hxx"
+
+
+#include "profiler.hxx"
+#include "rcontrol.hxx"
+#include <basic/ttstrhlp.hxx>
+
+struct SysdepProfileSnapshot
+{
+ // Hier stehen alle Felder zum Speichern eines Snapshot
+};
+
+
+struct SysdepStaticData
+{
+ // Hier steht alles, was während des Profiles ständig gebraucht wird
+};
+
+
+void TTProfiler::InitSysdepProfiler()
+{
+ if ( !pSysDepStatic ) // Sollte immer so sein!!
+ pSysDepStatic = new SysdepStaticData;
+ // Hier initialisieren
+
+};
+
+void TTProfiler::DeinitSysdepProfiler()
+{
+ if ( pSysDepStatic ) // Sollte immer so sein!!
+ {
+ // Hier aufräumen und eventuell Speicher freigeben
+
+ delete pSysDepStatic;
+ }
+};
+
+SysdepProfileSnapshot *TTProfiler::NewSysdepSnapshotData()
+{
+ return new SysdepProfileSnapshot;
+};
+
+void TTProfiler::DeleteSysdepSnapshotData( SysdepProfileSnapshot *pSysdepProfileSnapshot )
+{
+ delete pSysdepProfileSnapshot;
+};
+
+
+// Titelzeile für Logdatei
+String TTProfiler::GetSysdepProfileHeader()
+{
+ return String(CUniString("(noch) keine weiteren Daten Implementiert"));
+};
+
+
+// Zustand merken
+void TTProfiler::GetSysdepProfileSnapshot( SysdepProfileSnapshot *, sal_uInt16 )
+{};
+
+
+// Informationszeile zusammenbauen
+String TTProfiler::GetSysdepProfileLine( SysdepProfileSnapshot *, SysdepProfileSnapshot * )
+{
+ return String();
+};
+
+
+
diff --git a/automation/source/server/prof_usl.cxx b/automation/source/server/prof_usl.cxx
new file mode 100644
index 000000000000..cccf196b795b
--- /dev/null
+++ b/automation/source/server/prof_usl.cxx
@@ -0,0 +1,136 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_automation.hxx"
+
+
+#include <procfs.h>
+#include <tools/stream.hxx>
+#include "profiler.hxx"
+
+
+struct SysdepProfileSnapshot
+{
+ pstatus mpstatus;
+ psinfo mpsinfo;
+ prusage mprusage;
+};
+
+
+struct SysdepStaticData
+{
+ // Hier steht alles, was während des Profiles ständig gebraucht wird
+};
+
+
+void TTProfiler::InitSysdepProfiler()
+{
+ if ( !pSysDepStatic ) // Sollte immer so sein!!
+ pSysDepStatic = new SysdepStaticData;
+ // Hier initialisieren
+
+};
+
+void TTProfiler::DeinitSysdepProfiler()
+{
+ if ( pSysDepStatic ) // Sollte immer so sein!!
+ {
+ // Hier aufräumen und eventuell Speicher freigeben
+
+ delete pSysDepStatic;
+ }
+};
+
+SysdepProfileSnapshot *TTProfiler::NewSysdepSnapshotData()
+{
+ return new SysdepProfileSnapshot;
+};
+
+void TTProfiler::DeleteSysdepSnapshotData( SysdepProfileSnapshot *pSysdepProfileSnapshot )
+{
+ delete pSysdepProfileSnapshot;
+};
+
+
+// Titelzeile für Logdatei
+String TTProfiler::GetSysdepProfileHeader()
+{
+ return String::CreateFromAscii(" Size(Kb) ResidentSZ rtime ktime utime total");
+};
+
+
+// Zustand merken
+void TTProfiler::GetSysdepProfileSnapshot( SysdepProfileSnapshot *pSysdepProfileSnapshot, sal_uInt16 )
+{
+ SvFileStream aStream( String::CreateFromAscii("/proc/self/psinfo"), STREAM_READ ); // Das ist ein expliziter Pfad für UNXSOL!
+ if ( aStream.IsOpen() )
+ {
+ aStream.Read( &(pSysdepProfileSnapshot->mpsinfo), sizeof( psinfo ) );
+ aStream.Close();
+ }
+ SvFileStream anotherStream( String::CreateFromAscii("/proc/self/status"), STREAM_READ ); // Das ist ein expliziter Pfad für UNXSOL!
+ if ( anotherStream.IsOpen() )
+ {
+ anotherStream.Read( &(pSysdepProfileSnapshot->mpstatus), sizeof( pstatus ) );
+ anotherStream.Close();
+ }
+ SvFileStream YetAnotherStream( String::CreateFromAscii("/proc/self/usage"), STREAM_READ ); // Das ist ein expliziter Pfad für UNXSOL!
+ if ( YetAnotherStream.IsOpen() )
+ {
+ YetAnotherStream.Read( &(pSysdepProfileSnapshot->mprusage), sizeof( prusage ) );
+ YetAnotherStream.Close();
+ }
+};
+
+#define DIFF2( aFirst, aSecond, Membername ) ( aSecond.Membername - aFirst.Membername )
+#define CALC_MS( nSec, nNSec ) ( nSec * 1000 + (nNSec+500000) / 1000000 )
+#define DIFF_MS( pStart, pEnd, Member ) ( CALC_MS( pEnd->Member.tv_sec, pEnd->Member.tv_nsec ) - CALC_MS( pStart->Member.tv_sec, pStart->Member.tv_nsec ) )
+// Informationszeile zusammenbauen
+String TTProfiler::GetSysdepProfileLine( SysdepProfileSnapshot *pStart, SysdepProfileSnapshot *pStop )
+{
+ String aProfile;
+
+ aProfile += Pad( String::CreateFromInt64(pStop->mpsinfo.pr_size), 9);
+ aProfile += Pad( String::CreateFromInt64(pStop->mpsinfo.pr_rssize), 11);
+
+
+ aProfile += Pad( String::CreateFromInt64(DIFF_MS( pStart, pStop, mprusage.pr_rtime ) / AVER( pStart, pStop, mprusage.pr_count )), 7 );
+
+
+ sal_uLong d_utime = DIFF_MS( pStart, pStop, mpstatus.pr_utime ) + DIFF_MS( pStart, pStop, mpstatus.pr_cutime );
+ sal_uLong d_stime = DIFF_MS( pStart, pStop, mpstatus.pr_stime ) + DIFF_MS( pStart, pStop, mpstatus.pr_cstime );
+
+ aProfile += Pad( String::CreateFromInt64(d_utime), 7 );
+ aProfile += Pad( String::CreateFromInt64(d_stime), 7 );
+ aProfile += Pad( String::CreateFromInt64(d_utime + d_stime), 7 );
+
+ return aProfile;
+};
+
+
+
diff --git a/automation/source/server/profiler.cxx b/automation/source/server/profiler.cxx
new file mode 100644
index 000000000000..8bd4e76401fe
--- /dev/null
+++ b/automation/source/server/profiler.cxx
@@ -0,0 +1,264 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_automation.hxx"
+
+
+#include <tools/time.hxx>
+#include <tools/string.hxx>
+#include <unotools/localedatawrapper.hxx>
+#include <vcl/svapp.hxx>
+#ifndef _BASIC_TTRESHLP_HXX
+#include <basic/ttstrhlp.hxx>
+#endif
+
+
+#include "profiler.hxx"
+
+
+TTProfiler::TTProfiler()
+: mpStart( NULL )
+, mpEnd( NULL )
+, bIsProfileIntervalStarted( sal_False )
+, bIsProfilingPerCommand( sal_False )
+, bIsPartitioning( sal_False )
+, bIsAutoProfiling( sal_False )
+, pSysDepStatic( NULL )
+{
+ InitSysdepProfiler();
+ mpStart = new ProfileSnapshot;
+ mpStart->pSysdepProfileSnapshot = NewSysdepSnapshotData();
+ mpEnd = new ProfileSnapshot;
+ mpEnd->pSysdepProfileSnapshot = NewSysdepSnapshotData();
+ StartProfileInterval();
+}
+
+TTProfiler::~TTProfiler()
+{
+ if ( IsAutoProfiling() )
+ StopAutoProfiling();
+ if ( mpStart )
+ {
+ if ( mpStart->pSysdepProfileSnapshot )
+ DeleteSysdepSnapshotData( mpStart->pSysdepProfileSnapshot );
+ delete mpStart;
+ mpStart = NULL;
+ }
+ if ( mpEnd )
+ {
+ if ( mpEnd->pSysdepProfileSnapshot )
+ DeleteSysdepSnapshotData( mpEnd->pSysdepProfileSnapshot );
+ delete mpEnd;
+ mpEnd = NULL;
+ }
+ DeinitSysdepProfiler();
+}
+
+
+String TTProfiler::GetProfileHeader()
+{
+ UniString aReturn;
+ aReturn += '\n';
+ if ( !IsAutoProfiling() )
+ aReturn.AppendAscii("Befehl").Append(TabString(36));
+
+ aReturn.AppendAscii(" Zeitdauer");
+ aReturn.AppendAscii(" Ticks in %");
+ aReturn.Append( GetSysdepProfileHeader() );
+ aReturn.AppendAscii("\n");
+ return aReturn;
+}
+
+
+void TTProfiler::StartProfileInterval( sal_Bool bReadAnyway )
+{
+ if ( !bIsProfileIntervalStarted || bReadAnyway )
+ {
+ GetProfileSnapshot( mpStart );
+ GetSysdepProfileSnapshot( mpStart->pSysdepProfileSnapshot, PROFILE_START );
+ bIsProfileIntervalStarted = sal_True;
+ }
+}
+
+String TTProfiler::GetProfileLine( ProfileSnapshot *pStart, ProfileSnapshot *pEnd )
+{
+ String aProfileString;
+
+ aProfileString += Pad(GetpApp()->GetAppLocaleDataWrapper().getDuration( DIFF( pStart, pEnd, aTime) , sal_True, sal_True ), 12);
+
+ sal_uLong nProcessTicks = DIFF( pStart, pEnd, nProcessTicks );
+ sal_uLong nSystemTicks = DIFF( pStart, pEnd, nSystemTicks );
+ if ( nSystemTicks )
+ {
+ aProfileString += Pad(UniString::CreateFromInt32( (100 * nProcessTicks) / nSystemTicks ), 11);
+ aProfileString += '%';
+ }
+ else
+ aProfileString += Pad(CUniString("?? "), 12);
+
+ return aProfileString;
+}
+
+
+String TTProfiler::GetProfileLine( String &aPrefix )
+{
+ String aProfileString;
+ if ( IsProfilingPerCommand() || IsAutoProfiling() )
+ {
+ aProfileString = aPrefix;
+ aProfileString += TabString(35);
+
+
+ aProfileString += GetProfileLine( mpStart, mpEnd );
+ aProfileString += GetSysdepProfileLine( mpStart->pSysdepProfileSnapshot, mpEnd->pSysdepProfileSnapshot );
+ aProfileString += '\n';
+ }
+
+ return aProfileString;
+}
+
+
+void TTProfiler::EndProfileInterval()
+{
+ GetProfileSnapshot( mpEnd );
+ GetSysdepProfileSnapshot( mpEnd->pSysdepProfileSnapshot, PROFILE_END );
+ bIsProfileIntervalStarted = sal_False;
+}
+
+
+void TTProfiler::GetProfileSnapshot( ProfileSnapshot *pProfileSnapshot )
+{
+ pProfileSnapshot->aTime = Time();
+ pProfileSnapshot->nProcessTicks = Time::GetProcessTicks();
+ pProfileSnapshot->nSystemTicks = Time::GetSystemTicks();
+}
+
+
+void TTProfiler::StartProfilingPerCommand() // Jeden Befehl mitschneiden
+{
+ bIsProfilingPerCommand = sal_True;
+}
+
+void TTProfiler::StopProfilingPerCommand()
+{
+ bIsProfilingPerCommand = sal_False;
+}
+
+void TTProfiler::StartPartitioning()
+{
+ bIsPartitioning = sal_True;
+}
+
+void TTProfiler::StopPartitioning()
+{
+ bIsPartitioning = sal_True;
+}
+
+sal_uLong TTProfiler::GetPartitioningTime()
+{
+ return DIFF( mpStart, mpEnd, nSystemTicks );
+}
+
+
+
+void TTProfiler::StartAutoProfiling( sal_uLong nMSec )
+{
+ if ( !bIsAutoProfiling )
+ {
+ pAutoStart = new ProfileSnapshot;
+ pAutoStart->pSysdepProfileSnapshot = NewSysdepSnapshotData();
+ pAutoEnd = new ProfileSnapshot;
+ pAutoEnd->pSysdepProfileSnapshot = NewSysdepSnapshotData();
+ GetProfileSnapshot( pAutoStart );
+ GetSysdepProfileSnapshot( pAutoStart->pSysdepProfileSnapshot, PROFILE_START );
+ SetTimeout( nMSec );
+ bIsAutoProfiling = sal_True;
+ Start();
+ }
+
+}
+
+void TTProfiler::Timeout()
+{
+ GetProfileSnapshot( pAutoEnd );
+ GetSysdepProfileSnapshot( pAutoEnd->pSysdepProfileSnapshot, PROFILE_END );
+ String aLine;
+
+ aLine += GetProfileLine( pAutoStart, pAutoEnd );
+ aLine += GetSysdepProfileLine( pAutoStart->pSysdepProfileSnapshot, pAutoEnd->pSysdepProfileSnapshot );
+ aLine += '\n';
+
+ aAutoProfileBuffer += aLine;
+
+ ProfileSnapshot *pTemp = pAutoStart; // Tauschen, so daß jetziges Ende nächsten Start wird
+ pAutoStart = pAutoEnd;
+ pAutoEnd = pTemp;
+
+ Start(); // Timer neu starten
+}
+
+String TTProfiler::GetAutoProfiling()
+{
+ String aTemp(aAutoProfileBuffer);
+ aAutoProfileBuffer.Erase();
+ return aTemp;
+}
+
+void TTProfiler::StopAutoProfiling()
+{
+ if ( bIsAutoProfiling )
+ {
+ Stop();
+ bIsAutoProfiling = sal_False;
+ }
+}
+
+
+
+//String TTProfiler::Hex( sal_uLong nNr )
+String TTProfiler::Dec( sal_uLong nNr )
+{
+ String aRet(UniString::CreateFromInt32(nNr));
+ if ( nNr < 100 )
+ {
+ aRet = Pad( aRet, 3);
+ aRet.SearchAndReplaceAll(' ','0');
+ }
+ aRet.Insert( ',', aRet.Len() - 2 );
+ return aRet;
+}
+
+String TTProfiler::Pad( const String aS, xub_StrLen nLen )
+{
+ if ( nLen > aS.Len() )
+ return UniString().Fill( nLen - aS.Len() ).Append( aS );
+ else
+ return CUniString(" ").Append( aS );
+}
+
+
diff --git a/automation/source/server/profiler.hxx b/automation/source/server/profiler.hxx
new file mode 100644
index 000000000000..3903ac5fee42
--- /dev/null
+++ b/automation/source/server/profiler.hxx
@@ -0,0 +1,137 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+
+#define AVER( pFirst, pSecond, Membername ) (( pFirst->Membername + pSecond->Membername ) / 2 )
+#define DIFF( pFirst, pSecond, Membername ) ( pSecond->Membername - pFirst->Membername )
+#define S_SAFEDIV( a,b ) ((b)==0?CUniString("#DIV"):UniString::CreateFromInt32( (ULONG) ((a)/(b))))
+#define S_SAFEDIV_DEC( a,b ) ((b)==0?CUniString("#DIV"):Dec((ULONG) ((a)/(b))))
+
+#include <tools/time.hxx>
+#include <tools/string.hxx>
+#include <vcl/timer.hxx>
+
+#define PROFILE_START 0x01
+#define PROFILE_END 0x02
+
+
+struct SysdepProfileSnapshot;
+struct SysdepStaticData; // Nicht wirklich statisch, sondern statisch über mehrere Snapshots
+
+struct ProfileSnapshot
+{
+ Time aTime;
+ SysdepProfileSnapshot *pSysdepProfileSnapshot;
+ sal_uLong nProcessTicks;
+ sal_uLong nSystemTicks;
+};
+
+
+class TTProfiler : private Timer
+{
+public:
+ TTProfiler();
+ ~TTProfiler();
+
+ String GetProfileHeader(); // Titelzeile für Logdatei
+ void StartProfileInterval( sal_Bool bReadAnyway = sal_False ); // Zustand merken
+ void EndProfileInterval(); // Informationszeile zusammenbauen
+ String GetProfileLine( String &aPrefix );
+
+
+ void StartProfilingPerCommand(); // Jeden Befehl mitschneiden
+ void StopProfilingPerCommand();
+ sal_Bool IsProfilingPerCommand() { return bIsProfilingPerCommand; }
+
+ void StartPartitioning();
+ void StopPartitioning();
+ sal_Bool IsPartitioning() { return bIsPartitioning; }
+ sal_uLong GetPartitioningTime();
+
+ void StartAutoProfiling( sal_uLong nMSec ); // Automatisch alle nMSec Milisekunden sampeln
+ String GetAutoProfiling(); // Aktuelle `Sammlung` abholen
+ void StopAutoProfiling(); // Sampeln beenden
+ sal_Bool IsAutoProfiling() { return bIsAutoProfiling; }
+
+private:
+
+ void GetProfileSnapshot( ProfileSnapshot *pProfileSnapshot );
+
+ // Informationszeile zusammenbauen
+ String GetProfileLine( ProfileSnapshot *pStart, ProfileSnapshot *pStop );
+
+
+ ProfileSnapshot *mpStart;
+ ProfileSnapshot *mpEnd;
+ sal_Bool bIsProfileIntervalStarted;
+
+
+
+//
+ sal_Bool bIsProfilingPerCommand;
+ sal_Bool bIsPartitioning;
+
+
+// Für das Automatische Profiling in festen Intervallen
+
+ ProfileSnapshot *pAutoStart;
+ ProfileSnapshot *pAutoEnd;
+ sal_Bool bIsAutoProfiling;
+ String aAutoProfileBuffer;
+
+ virtual void Timeout();
+
+
+// Einige Hilfsfunktionen
+
+// String Hex( sal_uLong nNr );
+ String Dec( sal_uLong nNr ); // Ergebnis = nNr / 100 mit 2 Dezimalen
+ String Pad( const String aS, xub_StrLen nLen ); // Fügt blanks links an den String an
+
+/* Ab hier werden die Methoden Systemabhängig in den entsprechenden cxx implementiert
+ Sie werden von den oberen Methoden gerufen.
+*/
+
+ SysdepStaticData *pSysDepStatic;
+
+ void InitSysdepProfiler();
+ void DeinitSysdepProfiler();
+
+ SysdepProfileSnapshot *NewSysdepSnapshotData();
+ void DeleteSysdepSnapshotData( SysdepProfileSnapshot *pSysdepProfileSnapshot );
+
+ // Titelzeile für Logdatei
+ String GetSysdepProfileHeader();
+
+ // Zustand merken
+ void GetSysdepProfileSnapshot( SysdepProfileSnapshot *pSysdepProfileSnapshot, sal_uInt16 nMode = PROFILE_START | PROFILE_END );
+
+ // Informationszeile zusammenbauen
+ String GetSysdepProfileLine( SysdepProfileSnapshot *pStart, SysdepProfileSnapshot *pStop );
+};
+
diff --git a/automation/source/server/recorder.cxx b/automation/source/server/recorder.cxx
new file mode 100644
index 000000000000..4546ba966a1d
--- /dev/null
+++ b/automation/source/server/recorder.cxx
@@ -0,0 +1,1095 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_automation.hxx"
+#include <osl/mutex.hxx>
+
+#include <vcl/window.hxx>
+#include <vcl/vclevent.hxx>
+#include <vcl/button.hxx>
+#include <vcl/edit.hxx>
+#include <vcl/spinfld.hxx>
+#include <vcl/msgbox.hxx>
+#include <vcl/toolbox.hxx>
+#include <vcl/lstbox.hxx>
+#include <vcl/sound.hxx>
+#include <vcl/combobox.hxx>
+#include <vcl/floatwin.hxx>
+#include <basic/ttstrhlp.hxx>
+#include "statemnt.hxx"
+#include "retstrm.hxx"
+#include "rcontrol.hxx"
+#include "recorder.hxx"
+
+#include <comphelper/uieventslogger.hxx>
+
+MacroRecorder* MacroRecorder::pMacroRecorder = NULL;
+
+MacroRecorder::MacroRecorder()
+: pLastWin( NULL )
+, pEditModify( NULL )
+, pActionParent( NULL )
+, aKeyUniqueID()
+, pKeyWin( NULL )
+, bKeyFollowFocus( sal_False )
+, m_bRecord( sal_False )
+, m_bLog( sal_False )
+{
+ aHookRefresh.SetTimeout( 500 );
+ aHookRefresh.SetTimeoutHdl( LINK( this, MacroRecorder, HookRefreshHdl) );
+ aHookRefresh.Start();
+ aEventListenerHdl = LINK( this, MacroRecorder, EventListener );
+ AddEventHooks();
+}
+
+MacroRecorder::~MacroRecorder()
+{
+ aHookRefresh.Stop();
+ RemoveEventHooks();
+}
+
+void MacroRecorder::AddEventHooks()
+{
+ Window *pTopLevel = Application::GetFirstTopLevelWindow();
+ while ( pTopLevel )
+ {
+ Window *pParent = pTopLevel;
+ while ( pParent->GetParent() )
+ pParent = pParent->GetParent();
+
+ pParent->RemoveChildEventListener( aEventListenerHdl ); // might be instrumented already
+ pParent->AddChildEventListener( aEventListenerHdl );
+
+ pTopLevel = Application::GetNextTopLevelWindow( pTopLevel );
+ }
+}
+
+void MacroRecorder::RemoveEventHooks()
+{
+ Window *pTopLevel = Application::GetFirstTopLevelWindow();
+ while ( pTopLevel )
+ {
+ pTopLevel->RemoveChildEventListener( aEventListenerHdl );
+ pTopLevel = Application::GetNextTopLevelWindow( pTopLevel );
+ }
+}
+
+IMPL_LINK( MacroRecorder, HookRefreshHdl, void*, EMPTYARG )
+{
+ AddEventHooks();
+ return 0;
+}
+
+void MacroRecorder::LogVCL( rtl::OString aParentID, sal_uInt16 nVCLWindowType, rtl::OString aID, String aMethod, sal_uInt16 nParam )
+{
+ ::comphelper::UiEventsLogger::logVcl( Id2Str( aParentID ), nVCLWindowType, Id2Str( aID ), aMethod, nParam );
+}
+
+void MacroRecorder::LogVCL( rtl::OString aParentID, sal_uInt16 nVCLWindowType, rtl::OString aID, String aMethod )
+{
+ ::comphelper::UiEventsLogger::logVcl( Id2Str( aParentID ), nVCLWindowType, Id2Str( aID ), aMethod );
+}
+
+Window* MacroRecorder::GetParentWithID( Window* pThis )
+{
+ Window *pOverlap = pThis->GetWindow( WINDOW_OVERLAP );
+ while ( pOverlap != pThis && !pThis->GetUniqueOrHelpId().getLength() && pThis->GET_REAL_PARENT() )
+ pThis = pThis->GET_REAL_PARENT();
+ return pThis;
+}
+
+rtl::OString MacroRecorder::GetParentID( Window* pThis )
+{
+ if ( pThis->GetParent() )
+ return pThis->GetParent()->GetUniqueOrHelpId();
+ else
+ return rtl::OString();
+}
+
+IMPL_LINK( MacroRecorder, EventListener, VclSimpleEvent*, pEvent )
+{
+ sal_Bool bSendData = sal_False;
+
+ if ( pEvent->ISA( VclWindowEvent ) )
+ {
+ VclWindowEvent* pWinEvent = ( VclWindowEvent* ) pEvent;
+ Window* pWin = pWinEvent->GetWindow();
+ sal_uLong nEventID = pWinEvent->GetId();
+#if OSL_DEBUG_LEVEL > 1
+ if ( nEventID >= 1001 && nEventID != VCLEVENT_WINDOW_KEYUP )
+ nEventID = pWinEvent->GetId(); // Just something to set a breakpoint
+ else
+ return 0;
+#endif
+
+// check for different action after collecting keys
+ // send if there_is_something_to_send
+ // and eather event_is_not_of_interest
+ // or ( new_window and new_window_is_interesting ) ( ignore interesting events to uninteresting window )
+
+ if ( aKeyString.Len()
+ && ( ( nEventID != VCLEVENT_WINDOW_KEYINPUT
+ && nEventID != VCLEVENT_WINDOW_MOUSEMOVE
+ && nEventID != VCLEVENT_WINDOW_COMMAND
+ && nEventID != VCLEVENT_WINDOW_KEYUP )
+ || ( pKeyWin != pWin
+ && ( pWin->GetType() == WINDOW_CONTROL || pWin->GetType() == WINDOW_WINDOW )
+ )
+ )
+ )
+ {
+ if ( m_bRecord )
+ {
+ // we cannot access pKeyWin since it might have dissapeared
+ if ( bKeyFollowFocus )
+ StatementList::pRet->GenReturn( RET_MacroRecorder, aKeyUniqueID, (sal_uInt16)M_TypeKeys, aKeyString, bKeyFollowFocus );
+ else
+ StatementList::pRet->GenReturn( RET_MacroRecorder, aKeyUniqueID, (sal_uInt16)M_TypeKeys, aKeyString );
+#if OSL_DEBUG_LEVEL > 1
+ StatementList::pRet->GenReturn( RET_MacroRecorder, aKeyUniqueID, (sal_uInt16)M_TypeKeys, String::CreateFromInt32( nEventID ) );
+#endif
+ bSendData = sal_True;
+ }
+ if ( m_bLog )
+ {
+// HACK Too many KeyEvents generated LogVCL( rtl::OString(), 0, aKeyUniqueID, CUniString("TypeKeys"), aKeyString.Len() );
+ }
+ // cleanup
+ aKeyString.Erase();
+ pKeyWin = NULL;
+ bKeyFollowFocus = sal_False;
+ }
+
+ switch ( pWin->GetType() )
+ {
+ case WINDOW_TABPAGE:
+ switch( nEventID )
+ {
+ case VCLEVENT_WINDOW_ACTIVATE:
+ if ( m_bRecord )
+ {
+ StatementList::pRet->GenReturn( RET_MacroRecorder, rtl::OString(), (comm_USHORT)(M_SetPage|M_RET_NUM_CONTROL), Id2Str( pWin->GetUniqueOrHelpId() ) );
+ bSendData = sal_True;
+ }
+ if ( m_bLog )
+ {
+ LogVCL( rtl::OString(), pWin->GetType(), pWin->GetUniqueOrHelpId(), CUniString("SetPage") );
+ }
+ break;
+ }
+ break;
+ case WINDOW_RADIOBUTTON:
+ case WINDOW_IMAGERADIOBUTTON:
+ switch( nEventID )
+ {
+ case VCLEVENT_BUTTON_CLICK: // VCLEVENT_RADIOBUTTON_TOGGLE
+ {
+ if ( ((RadioButton*)pWin)->IsChecked() )
+ {
+ if ( m_bRecord )
+ {
+ StatementList::pRet->GenReturn( RET_MacroRecorder, pWin->GetUniqueOrHelpId(), (comm_USHORT)M_Check );
+ bSendData = sal_True;
+ }
+ if ( m_bLog )
+ {
+ LogVCL( GetParentID( pWin ), pWin->GetType(), pWin->GetUniqueOrHelpId(), CUniString("Check") );
+ }
+ }
+ }
+ break;
+ }
+ break;
+ case WINDOW_CHECKBOX:
+ case WINDOW_TRISTATEBOX:
+ switch( nEventID )
+ {
+ case VCLEVENT_BUTTON_CLICK: //VCLEVENT_CHECKBOX_TOGGLE:
+ {
+ comm_USHORT nMethod;
+ String aMethod;
+ switch ( ((TriStateBox*)pWin)->GetState() )
+ {
+ case STATE_CHECK: nMethod = M_Check; aMethod = CUniString("Check"); break;
+ case STATE_NOCHECK: nMethod = M_UnCheck; aMethod = CUniString("UnCheck"); break;
+ case STATE_DONTKNOW: nMethod = M_TriState; aMethod = CUniString("TriState"); break;
+ default: nMethod = M_Check;
+ DBG_ERROR( "Unknown state in TriStateBox::GetState()" );
+ }
+ if ( m_bRecord )
+ {
+ StatementList::pRet->GenReturn( RET_MacroRecorder, pWin->GetUniqueOrHelpId(), nMethod );
+ bSendData = sal_True;
+ }
+ if ( m_bLog )
+ {
+ LogVCL( GetParentID( pWin ), pWin->GetType(), pWin->GetUniqueOrHelpId(), aMethod );
+ }
+ }
+ break;
+ }
+ break;
+ case WINDOW_EDIT:
+ case WINDOW_MULTILINEEDIT:
+ switch( nEventID )
+ {
+ case VCLEVENT_EDIT_MODIFY:
+ pEditModify = pWin;
+ aEditModifyString = ((Edit*)pWin)->GetText();
+ break;
+ }
+ break;
+ case WINDOW_MULTILISTBOX:
+ switch( nEventID )
+ {
+ case VCLEVENT_LISTBOX_SELECT:
+ Sound::Beep();
+ }
+ case WINDOW_LISTBOX:
+ switch( nEventID )
+ {
+// case VCLEVENT_LISTBOX_DOUBLECLICK:
+ case VCLEVENT_LISTBOX_SELECT:
+ if ( m_bRecord )
+ {
+ StatementList::pRet->GenReturn( RET_MacroRecorder, pWin->GetUniqueOrHelpId(), (comm_USHORT)M_Select, comm_ULONG( ((ListBox*)pWin)->GetSelectEntryPos() +1 ) );
+ bSendData = sal_True;
+ }
+ if ( m_bLog )
+ {
+ LogVCL( GetParentID( pWin ), pWin->GetType(), pWin->GetUniqueOrHelpId(), CUniString("Select"), ((ListBox*)pWin)->GetSelectEntryPos() );
+ }
+ break;
+ }
+ break;
+ case WINDOW_COMBOBOX:
+ case WINDOW_PATTERNBOX:
+ case WINDOW_NUMERICBOX:
+ case WINDOW_METRICBOX:
+ case WINDOW_CURRENCYBOX:
+ case WINDOW_DATEBOX:
+ case WINDOW_TIMEBOX:
+ switch( nEventID )
+ {
+ case VCLEVENT_EDIT_MODIFY:
+ pEditModify = pWin;
+ aEditModifyString = ((Edit*)pWin)->GetText();
+ break;
+ case VCLEVENT_COMBOBOX_SELECT:
+ {
+ pEditModify = NULL;
+ aEditModifyString.Erase();
+
+ sal_uInt16 nPos = ((ComboBox*)pWin)->GetEntryPos(((ComboBox*)pWin)->GetText());
+ if ( m_bRecord )
+ {
+ if ( nPos == COMBOBOX_ENTRY_NOTFOUND )
+ Sound::Beep();
+ else
+ {
+ StatementList::pRet->GenReturn( RET_MacroRecorder, pWin->GetUniqueOrHelpId(), (comm_USHORT)M_Select, (comm_ULONG) nPos+1 );
+ bSendData = sal_True;
+ }
+ }
+ if ( m_bLog )
+ {
+ LogVCL( GetParentID( pWin ), pWin->GetType(), pWin->GetUniqueOrHelpId(), CUniString("Select"), nPos );
+ }
+ }
+ }
+ break;
+ case WINDOW_PUSHBUTTON:
+ case WINDOW_OKBUTTON:
+ case WINDOW_CANCELBUTTON:
+ case WINDOW_IMAGEBUTTON:
+ case WINDOW_MOREBUTTON:
+ case WINDOW_HELPBUTTON:
+ switch( nEventID )
+ {
+ case VCLEVENT_BUTTON_CLICK:
+ Window* pParent = pWin->GetParent();
+ sal_Bool bDone = sal_False;
+ if ( pParent->IsDialog() && !pWin->GetUniqueOrHelpId().getLength() )
+ {
+ switch ( pParent->GetType() )
+ {
+ case WINDOW_MESSBOX:
+ case WINDOW_INFOBOX:
+ case WINDOW_WARNINGBOX:
+ case WINDOW_ERRORBOX:
+ case WINDOW_QUERYBOX:
+ case WINDOW_BUTTONDIALOG:
+ {
+ comm_USHORT nMethod;
+ String aMethod;
+ ButtonDialog* pBD = (ButtonDialog*)pParent;
+
+ // we have to find the current Button ID ourselves since it is not generated at this point :-(
+ sal_uInt16 nCurrentButtonId = 0xffff; // Some wild value to wak up people
+ sal_uInt16 i;
+ for ( i = 0; i < pBD->GetButtonCount() ; i++ )
+ {
+ if ( pBD->GetPushButton( pBD->GetButtonId(i) ) == pWin )
+ {
+ nCurrentButtonId = pBD->GetButtonId(i);
+ break;
+ }
+ }
+
+ switch ( nCurrentButtonId )
+ {
+ case BUTTONID_OK: nMethod = M_OK; aMethod = CUniString("OK"); break;
+ case BUTTONID_CANCEL: nMethod = M_Cancel; aMethod = CUniString("Cancel"); break;
+ case BUTTONID_YES: nMethod = M_Yes; aMethod = CUniString("Yes"); break;
+ case BUTTONID_NO: nMethod = M_No; aMethod = CUniString("No"); break;
+ case BUTTONID_RETRY: nMethod = M_Repeat; aMethod = CUniString("Repeat"); break;
+ case BUTTONID_HELP: nMethod = M_Help; aMethod = CUniString("Help"); break;
+ default: nMethod = M_Click; aMethod = CUniString("Click");
+ }
+ if ( m_bRecord )
+ {
+ if ( nMethod != M_Click )
+ StatementList::pRet->GenReturn( RET_MacroRecorder, UID_ACTIVE, nMethod );
+ else
+ StatementList::pRet->GenReturn( RET_MacroRecorder, UID_ACTIVE, nMethod, (comm_ULONG)nCurrentButtonId );
+ bSendData = sal_True;
+ }
+ if ( m_bLog )
+ {
+ if ( nMethod != M_Click )
+ LogVCL( rtl::OString(), pWin->GetType(), pWin->GetUniqueOrHelpId(), aMethod );
+ else
+ LogVCL( rtl::OString(), pWin->GetType(), pWin->GetUniqueOrHelpId(), aMethod, nCurrentButtonId );
+ bDone = sal_True;
+ }
+ }
+ break;
+ default:
+ {
+ comm_USHORT nMethod;
+ String aMethod;
+ switch ( pWin->GetType() )
+ {
+ case WINDOW_OKBUTTON: nMethod = M_OK; aMethod = CUniString("OK"); break;
+ case WINDOW_CANCELBUTTON: nMethod = M_Cancel; aMethod = CUniString("Cancel"); break;
+ case WINDOW_HELPBUTTON: nMethod = M_Help; aMethod = CUniString("Help"); break;
+ default: nMethod = M_Default;aMethod = CUniString("Unknown Button");
+ DBG_ERROR( "Unknown Button" );
+ }
+ if ( m_bRecord )
+ {
+ StatementList::pRet->GenReturn( RET_MacroRecorder, pParent->GetUniqueOrHelpId(), nMethod );
+ bSendData = sal_True;
+ }
+ if ( m_bLog )
+ {
+ LogVCL( GetParentID( pWin ), pWin->GetType(), pWin->GetUniqueOrHelpId(), aMethod );
+ bDone = sal_True;
+ }
+ }
+ break;
+ }
+ }
+ if ( m_bRecord )
+ {
+ if ( !bSendData && pWin->GetUniqueOrHelpId().getLength() )
+ {
+ StatementList::pRet->GenReturn( RET_MacroRecorder, pWin->GetUniqueOrHelpId(), (comm_USHORT)M_Click );
+ bSendData = sal_True;
+ }
+ }
+ if ( m_bLog )
+ {
+ if ( !bDone )
+ LogVCL( GetParentID( pWin ), pWin->GetType(), pWin->GetUniqueOrHelpId(), CUniString("Click") );
+ }
+ }
+ break;
+/* case C_MoreButton:
+ switch( nEventID )
+ {
+ case M_IsOpen :
+ pRet->GenReturn ( RET_Value, nUId, ((MoreButton*)pControl)->GetState());
+ break;
+ case M_Click :
+ ((MoreButton*)pControl)->Click();
+ break;
+ case M_Open :
+ ((MoreButton*)pControl)->SetState(sal_True);
+ break;
+ case M_Close :
+ ((MoreButton*)pControl)->SetState(sal_False);
+ break;
+ default:
+ ReportError( nUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "MoreButton" ) );
+ break;
+ }
+ break;*/
+ case WINDOW_SPINFIELD:
+ case WINDOW_PATTERNFIELD:
+ case WINDOW_NUMERICFIELD:
+ case WINDOW_METRICFIELD:
+ case WINDOW_CURRENCYFIELD:
+ case WINDOW_DATEFIELD:
+ case WINDOW_TIMEFIELD:
+ switch( nEventID )
+ {
+ case VCLEVENT_SPINFIELD_UP:
+ case VCLEVENT_SPINFIELD_DOWN:
+ case VCLEVENT_SPINFIELD_FIRST:
+ case VCLEVENT_SPINFIELD_LAST:
+ {
+ pEditModify = NULL;
+ aEditModifyString.Erase();
+
+ comm_USHORT nMethod;
+ String aMethod;
+ switch ( nEventID )
+ {
+ case VCLEVENT_SPINFIELD_UP: nMethod = M_More; aMethod = CUniString("More"); break;
+ case VCLEVENT_SPINFIELD_DOWN: nMethod = M_Less; aMethod = CUniString("Less"); break;
+ case VCLEVENT_SPINFIELD_FIRST: nMethod = M_ToMin; aMethod = CUniString("ToMin"); break;
+ case VCLEVENT_SPINFIELD_LAST: nMethod = M_ToMax; aMethod = CUniString("ToMax"); break;
+ default: nMethod = M_ToMin; aMethod = CUniString("Unknown");
+ DBG_ERROR( "Unknown EventID in Spinfield" );
+ }
+ if ( m_bRecord )
+ {
+ StatementList::pRet->GenReturn( RET_MacroRecorder, pWin->GetUniqueOrHelpId(), nMethod );
+ bSendData = sal_True;
+ }
+ if ( m_bLog )
+ {
+ LogVCL( GetParentID( pWin ), pWin->GetType(), pWin->GetUniqueOrHelpId(), aMethod );
+ }
+ }
+ break;
+ case VCLEVENT_EDIT_MODIFY:
+ pEditModify = pWin;
+ aEditModifyString = ((SpinField*)pWin)->GetText();
+ break;
+ }
+ break;
+
+ case WINDOW_MENUBUTTON:
+ switch( nEventID )
+ {
+ case VCLEVENT_BUTTON_CLICK:
+ if ( m_bRecord )
+ {
+ StatementList::pRet->GenReturn( RET_MacroRecorder, pWin->GetUniqueOrHelpId(), (comm_USHORT)M_Click );
+ bSendData = sal_True;
+ }
+ if ( m_bLog )
+ {
+ LogVCL( GetParentID( pWin ), pWin->GetType(), pWin->GetUniqueOrHelpId(), CUniString("Click") );
+ }
+ break;
+/* Keyevent or Timeout
+ case M_Open :
+ {
+ MouseEvent aMEvnt;
+ Point aPt( pControl->GetSizePixel().Width() / 2, pControl->GetSizePixel().Height() / 2 );
+ aMEvnt = MouseEvent( aPt,1,MOUSE_SIMPLECLICK,MOUSE_LEFT );
+ ImplMouseButtonDown( pControl, aMEvnt );
+
+ sal_uLong nStart = Time::GetSystemTicks();
+ sal_uLong nDelay = pControl->GetSettings().GetMouseSettings().GetActionDelay();
+ while ( ( Time::GetSystemTicks() - nStart ) < nDelay + 100 )
+ SafeReschedule();
+
+ ImplMouseButtonUp ( pControl, aMEvnt );
+ }
+ break;*/
+ }
+ break;
+ case WINDOW_TOOLBOX:
+ {
+ ToolBox *pTB = ((ToolBox*)pWin);
+ switch( nEventID )
+ {
+ case VCLEVENT_TOOLBOX_SELECT:
+ { // a Button has been clicked
+ // so this cannot be a tearoff or OpenMenu anymore
+ pActionParent = NULL;
+ // compare to 1 for floating ToolBoxes
+ if ( m_bRecord )
+ {
+ if ( !pWin->GetUniqueOrHelpId().getLength() /* || pWin->GetUniqueOrHelpId().Matches( 1 ) */ )
+ // generate direct Button access
+ StatementList::pRet->GenReturn( RET_MacroRecorder, Str2Id( pTB->GetItemCommand( pTB->GetCurItemId() ) ), (comm_USHORT)(M_Click) );
+ else
+ // access via Toolbox
+ StatementList::pRet->GenReturn( RET_MacroRecorder, pTB->GetUniqueOrHelpId(), (comm_USHORT)(M_Click|M_RET_NUM_CONTROL), Id2Str( pTB->GetHelpId( pTB->GetCurItemId() ) ) );
+ bSendData = sal_True;
+ }
+/* not needed if ( m_bLog )
+ {
+ }*/
+ }
+ break;
+ case VCLEVENT_TOOLBOX_CLICK: /// ATTENTION this is called during initialisation of toolbox. whoever 'invented' this
+ pActionParent = pTB;
+ break;
+// case VCLEVENT_WINDOW_SHOW: // not usable ATM. see above
+// if ( pActionParent )
+// { // a new toolbox opens up, might be a tearoff
+// if ( pActionParent != pWin )
+// { // it IS a tearoff not an undock
+// // compare to 1 for floating ToolBoxes
+// if ( m_bRecord )
+// {
+// if ( !pWin->GetSmartUniqueOrHelpId().HasAny() || pWin->GetSmartUniqueOrHelpId().Matches( 1 ) )
+// // generate direct Button access
+// StatementList::pRet->GenReturn( RET_MacroRecorder, rtl::OString( pActionParent->GetHelpId( pActionParent->GetCurItemId() ) ), (comm_USHORT)(M_TearOff) );
+// else
+// // access via Toolbox
+// 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
+// bSendData = sal_True;
+// }
+// if ( m_bLog )
+// {
+// LogVCL( pActionParent->GetSmartUniqueOrHelpId(), pWin->GetType(), pActionParent->GetHelpId( pActionParent->GetCurItemId() ), CUniString("TearOff") );
+// }
+// }
+// pActionParent = NULL;
+// }
+// break;
+ case VCLEVENT_TOOLBOX_DEACTIVATE:
+ pActionParent = NULL;
+ break;
+ }
+ }
+ break;
+/* ToolBox *pTB = ((ToolBox*)pControl);
+ if ( pTB->GetUniqueOrHelpId() != nUId ) // Also Button auf der ToolBox gefunden
+ {
+ if ( nParams == PARAM_NONE )
+ { // Wir fälschen einen Parameter
+ nParams = PARAM_USHORT_1;
+ nNr1 = nUId;
+ }
+ else
+ ReportError( nUId, GEN_RES_STR1( S_INTERNAL_ERROR, MethodString( nMethodId ) ) );
+ }
+
+#define FIND_HELP\
+{\
+ if( nParams == PARAM_USHORT_1 )\
+ nLNr1 = nNr1;\
+ for ( nNr1 = 0; nNr1 < pTB->GetItemCount() && nLNr1 != pTB->GetHelpId(pTB->GetItemId(nNr1)) ; nNr1++ ) {}\
+ bBool1 = nLNr1 == pTB->GetHelpId(pTB->GetItemId(nNr1));\
+ if ( !bBool1 )\
+ ReportError( nUId, GEN_RES_STR1( S_HELPID_ON_TOOLBOX_NOT_FOUND, MethodString( nMethodId ) ) );\
+ else\
+ {\
+ if ( !pTB->IsItemEnabled( pTB->GetItemId(nNr1) ) && nMethodId != _M_IsEnabled )\
+ {\
+ ReportError( nUId, GEN_RES_STR1( S_BUTTON_DISABLED_ON_TOOLBOX, MethodString( nMethodId ) ) );\
+ bBool1 = sal_False;\
+ }\
+ else if ( !pTB->IsItemVisible( pTB->GetItemId(nNr1) ) )\
+ {\
+ ReportError( nUId, GEN_RES_STR1( S_BUTTON_HIDDEN_ON_TOOLBOX, MethodString( nMethodId ) ) );\
+ bBool1 = sal_False;\
+ }\
+ else\
+ {\
+ if ( pTB->GetItemRect(pTB->GetItemId(nNr1)).IsEmpty() )\
+ {\
+ sal_uInt16 nLine = pTB->GetCurLine();\
+ do\
+ {\
+ pTB->ShowLine( sal_False );\
+ for ( int i = 1 ; i < 30 ; i++ )\
+ SafeReschedule();\
+ }\
+ while ( pTB->GetCurLine() != nLine && pTB->GetItemRect(pTB->GetItemId(nNr1)).IsEmpty() );\
+ pTB->Invalidate( pTB->GetScrollRect() );\
+ }\
+ if ( pTB->GetItemRect(pTB->GetItemId(nNr1)).IsEmpty() )\
+ {\
+ ReportError( nUId, GEN_RES_STR1( S_CANNOT_MAKE_BUTTON_VISIBLE_IN_TOOLBOX, MethodString( nMethodId ) ) );\
+ bBool1 = sal_False;\
+ }\
+ }\
+ }\
+}\
+
+ switch( nEventID )
+ {
+ case M_SetNextToolBox :
+ if ( (nParams & PARAM_STR_1) )
+ pTB->SetNextToolBox( aString1 );
+ else
+ pTB->SetNextToolBox( pTB->GetNextToolBox() );
+ pTB->NextToolBox();
+ break;
+ case M_GetNextToolBox :
+ pRet->GenReturn ( RET_Value, nUId, (String)pTB->GetNextToolBox());
+ break;
+ default:
+ ReportError( nUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "ToolBox" ) );
+ break;
+ }
+ }
+ break;
+*/
+ case WINDOW_CONTROL:
+ case WINDOW_WINDOW:
+ switch( nEventID )
+ {
+ case VCLEVENT_WINDOW_COMMAND:
+ break;
+ case VCLEVENT_WINDOW_KEYINPUT:
+ {
+ const KeyEvent *pKeyEvent = ((KeyEvent*)pWinEvent->GetData());
+ const KeyCode aKeyCode = pKeyEvent->GetKeyCode();
+ if ( pKeyEvent )
+ {
+ pKeyWin = pWin;
+ Window *pIdWin = GetParentWithID( pWin );
+ if ( pIdWin != pWin )
+ bKeyFollowFocus = sal_True;
+ aKeyUniqueID = pIdWin->GetUniqueOrHelpId();
+ if ( m_bLog )
+ {
+// HACK Too many KeyEvents generated if ( aKeyString.Len() == 0 )
+// HACK Too many KeyEvents generated LogVCL( rtl::OString(), 0, aKeyUniqueID, CUniString("TypeKeysStart") );
+ }
+ if ( ( !aKeyCode.IsMod1() && !aKeyCode.IsMod2() ) &&
+ (( aKeyCode.GetGroup() == KEYGROUP_NUM) ||
+ ( aKeyCode.GetGroup() == KEYGROUP_ALPHA) ||
+ ( aKeyCode.GetCode() == KEY_SPACE) ||
+ ( aKeyCode.GetCode() == KEY_ADD) ||
+ ( aKeyCode.GetCode() == KEY_SUBTRACT) ||
+ ( aKeyCode.GetCode() == KEY_MULTIPLY) ||
+ ( aKeyCode.GetCode() == KEY_DIVIDE) ||
+ ( aKeyCode.GetCode() == KEY_POINT) ||
+ ( aKeyCode.GetCode() == KEY_COMMA) ||
+ ( aKeyCode.GetCode() == KEY_EQUAL) ||
+ ( aKeyCode.GetCode() == 0) ) )
+ {
+ DBG_ASSERT( pKeyEvent->GetCharCode(), "no charcode found" );
+ aKeyString += pKeyEvent->GetCharCode();
+ }
+ else
+ { // not a regular key, transfer KeyCode
+ aKeyString += sal_Unicode(1); // mask it
+ // extra for '>' which is coded as <SHIFT GREATER>
+ if ( pKeyEvent->GetCharCode() == '>' )
+ aKeyString += sal_Unicode( KEY_GREATER | (aKeyCode.GetAllModifier() & ~KEY_SHIFT) );
+ else
+ aKeyString += sal_Unicode( aKeyCode.GetCode() | aKeyCode.GetAllModifier() );
+ }
+ }
+ }
+ break;
+
+ case VCLEVENT_WINDOW_MOUSEMOVE:
+ case VCLEVENT_WINDOW_MOUSEBUTTONDOWN:
+ case VCLEVENT_WINDOW_MOUSEBUTTONUP:
+ {
+ }
+ break;
+
+
+ }
+ break;
+ case WINDOW_DOCKINGWINDOW:
+// switch( nEventID )
+ {
+// case 1 .. 0xffff:
+ DBG_TRACE3( "TT_VCLMessage %u %u %X",nEventID, pWin->GetType(), pWin );
+// sal_Bool bx = ((DockingWindow*)pWin)->IsFloatingMode();
+// break;
+/* case M_Dock :
+ if ( ((DockingWindow*)pControl)->IsFloatingMode() )
+ ((DockingWindow*)pControl)->SetFloatingMode(sal_False);
+ else
+ ReportError( nUId, GEN_RES_STR1( S_ALLOWED_ONLY_IN_FLOATING_MODE, MethodString( nMethodId ) ) );
+ break;
+ case M_Undock :
+ if ( !((DockingWindow*)pControl)->IsFloatingMode() )
+ ((DockingWindow*)pControl)->SetFloatingMode(sal_True);
+ else
+ ReportError( nUId, GEN_RES_STR1( S_ALLOWED_ONLY_IN_FLOATING_MODE, MethodString( nMethodId ) ) );
+ break;
+ case M_IsDocked :
+ pRet->GenReturn ( RET_Value, nUId, (comm_BOOL) !((DockingWindow*)pControl)->IsFloatingMode());
+ break;
+ case M_Close:
+ //nWindowWaitUId = nUId;
+ DBG_ASSERT( nUId == pControl->GetUniqueOrHelpId(), "nUID != UniqueOrHelpId");
+ SET_WINP_CLOSING(pControl);
+ ((DockingWindow*)pControl)->Close();
+ break;
+ case M_Size:
+ case M_Move:
+ case M_IsMax :
+ case M_Minimize :
+ case M_Maximize :
+ if ( ((DockingWindow*)pControl)->IsFloatingMode() )
+ {
+ pControl = ((DockingWindow*)pControl)->GetFloatingWindow();
+ goto FloatWin;
+ }
+ else
+ ReportError( nUId, GEN_RES_STR1( S_ALLOWED_ONLY_IN_DOCKING_MODE, MethodString( nMethodId ) ) );
+ break;
+ case M_Help: // Alles was unten weiterbehandelt werden soll
+ goto MoreDialog;
+
+ default:
+ ReportError( nUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "DockingWindow" ) );
+ break;*/
+ }
+ break;
+
+
+
+
+
+
+ case WINDOW_FLOATINGWINDOW:
+ {
+ DBG_TRACE3( "TT_VCLMessage %u %u %X",nEventID, pWin->GetType(), pWin );
+// FloatingWindow *pFW = ((FloatingWindow*)pWin);
+/* switch( nEventID )
+ {
+
+// M_OpenMenu an einem ToolboxButton
+ case VCLEVENT_WINDOW_SHOW:
+ if ( pActionParent )
+ { // a new FloatingWindow opens up, so we assume an OpenMenu
+ // compare to 1 for floating ToolBoxes
+ if ( ( pActionParent->GetUniqueOrHelpId() == 0 || pActionParent->GetUniqueOrHelpId() == 1 ) )
+ // generate direct Button access
+ StatementList::pRet->GenReturn( RET_MacroRecorder, pActionParent->GetHelpId( pActionParent->GetCurItemId() ), (comm_USHORT)(M_OpenMenu) );
+ else
+ // access via Toolbox
+ StatementList::pRet->GenReturn( RET_MacroRecorder, pActionParent->GetUniqueOrHelpId(), (comm_USHORT)(M_OpenMenu|M_RET_NUM_CONTROL), pActionParent->GetHelpId( pActionParent->GetCurItemId() ) );
+ bSendData = sal_True;
+ }
+ break;
+
+ }
+ */ }
+ break;
+/*
+ case M_AnimateMouse :
+ AnimateMouse( pControl, MitteOben);
+ break;
+ case M_IsMax :
+ pRet->GenReturn ( RET_Value, nUId, (comm_BOOL)!((FloatingWindow*)pControl)->IsRollUp());
+ break;
+ case M_Minimize :
+ ((FloatingWindow*)pControl)->RollUp();
+ break;
+ case M_Maximize :
+ ((FloatingWindow*)pControl)->RollDown();
+ break;
+ case M_Size:
+ {
+ if ( pControl->GetStyle() & WB_SIZEABLE )
+ {
+ pControl->SetSizePixel(Size(nNr1,nNr2));
+ pControl->Resize();
+ }
+ else
+ ReportError( nUId, GEN_RES_STR1( S_SIZE_NOT_CHANGEABLE, MethodString( nMethodId ) ) );
+ break;
+ }
+ case M_Close:
+ DBG_ASSERT( nUId == pControl->GetUniqueOrHelpId(), "nUID != UniqueOrHelpId");
+ SET_WINP_CLOSING(pControl);
+ ((FloatingWindow*)pControl)->Close();
+ break;
+ case M_Help: // Alles was unten weiterbehandelt werden soll
+ case M_Move:
+ goto MoreDialog;
+ default:
+ ReportError( nUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "FloatingWin" ) );
+ break;
+ }
+ break;*/
+
+
+
+
+
+
+
+
+/*
+ case C_ModelessDlg:
+ case C_Dlg:
+ case C_TabDlg:
+ MoreDialog:
+ switch( nEventID )
+ {
+
+ // (Rect GetRect)
+
+ case M_AnimateMouse :
+ AnimateMouse( pControl, MitteOben);
+ break;
+ case M_Close:
+ DBG_ASSERT( nUId == pControl->GetUniqueOrHelpId(), "nUID != UniqueOrHelpId");
+ SET_WINP_CLOSING(pControl);
+ ((SystemWindow*)pControl)->Close();
+ break;
+ case M_Move:
+ {
+ pControl->SetPosPixel(Point(nNr1,nNr2));
+ break;
+ }
+ default:
+ ReportError( nUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "Dialog" ) );
+ break;
+ }
+ break;*/
+
+
+
+
+
+
+
+
+
+
+
+
+
+/*
+ case C_WorkWin:
+ switch( nEventID )
+ {
+ case M_Close:
+ DBG_ASSERT( nUId == pControl->GetUniqueOrHelpId(), "nUID != UniqueOrHelpId");
+ SET_WINP_CLOSING(pControl);
+ ((WorkWindow*)pControl)->Close();
+ break;
+ case M_Size:
+ case M_Move:
+ goto FloatWin;
+ break;
+ case M_Help: // Alles was unten weiterbehandelt werden soll
+ goto MoreDialog;
+ default:
+ ReportError( nUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "WorkWindow" ) );
+ break;
+ }
+ break;
+ */
+
+
+/* case C_TabPage:
+ switch( nEventID )
+ {
+ }
+ break;*/
+
+
+
+
+
+
+
+
+
+
+
+
+
+/*
+ case C_MessBox:
+ case C_InfoBox:
+ case C_WarningBox:
+ case C_ErrorBox:
+ case C_QueryBox:
+ {
+ sal_Bool bDone = sal_True;
+ MessBox* pMB = (MessBox*)pControl;
+ switch( nEventID )
+ {
+ case M_GetCheckBoxText:
+ pRet->GenReturn ( RET_Value, nUId, pMB->GetCheckBoxText() );
+ break;
+ case M_IsChecked :
+ pRet->GenReturn ( RET_Value, nUId, comm_BOOL( pMB->GetCheckBoxState() == STATE_CHECK) );
+ break;
+ case M_GetState :
+ pRet->GenReturn ( RET_Value, nUId, comm_ULONG( pMB->GetCheckBoxState() ));
+ break;
+ case M_Check :
+ pMB->SetCheckBoxState( STATE_CHECK );
+ break;
+ case M_UnCheck :
+ pMB->SetCheckBoxState( STATE_NOCHECK );
+ break;
+ case M_GetText :
+ pRet->GenReturn ( RET_Value, nUId, pMB->GetMessText());
+ break;
+
+ default:
+ bDone = sal_False;
+ break;
+ }
+ if ( bDone )
+ break; // break the case here else continue at C_ButtonDialog
+ }
+ case C_ButtonDialog:
+ {
+ ButtonDialog* pBD = (ButtonDialog*)pControl;
+#if OSL_DEBUG_LEVEL > 1
+ m_pDbgWin->AddText( "Working MessBox: " );
+ if (pControl->IsVisible())
+ m_pDbgWin->AddText("*(Visible)\n");
+ else
+ m_pDbgWin->AddText("*(nicht Visible)\n");
+#endif
+ switch( nEventID )
+ {
+ case M_GetText :
+ pRet->GenReturn ( RET_Value, nUId, pControl->GetText());
+ break;
+ case M_Click:
+ if ( nParams & PARAM_USHORT_1 )
+ {
+ if ( pBD->GetPushButton( nNr1 ) )
+ {
+ if ( nNr1 != BUTTONID_HELP )
+ {
+ SET_WINP_CLOSING(pControl);
+ }
+ pBD->GetPushButton( nNr1 )->Click();
+ }
+ else
+ ReportError( nUId, GEN_RES_STR2( S_NO_DEFAULT_BUTTON, UniString::CreateFromInt32( nNr1 ), MethodString( nMethodId ) ) );
+ }
+ else
+ ReportError( nUId, GEN_RES_STR1( S_BUTTONID_REQUIRED, MethodString( nMethodId ) ) );
+ break;
+ case M_GetButtonCount :
+ pRet->GenReturn ( RET_Value, nUId, comm_ULONG(pBD->GetButtonCount()));
+ break;
+ case M_GetButtonId :
+ if ( ValueOK(nUId, MethodString( nMethodId ),nNr1,pBD->GetButtonCount()) )
+ pRet->GenReturn ( RET_Value, nUId, comm_ULONG(pBD->GetButtonId(nNr1-1)));
+ break;
+ default:
+ ReportError( nUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "MessageBox" ) );
+ break;
+ }
+ break;
+
+
+ */
+
+
+ }
+
+
+ switch( nEventID )
+ {
+ case VCLEVENT_CONTROL_LOSEFOCUS:
+ if ( pEditModify == pWin )
+ {
+ if ( m_bRecord )
+ {
+ StatementList::pRet->GenReturn( RET_MacroRecorder, pWin->GetUniqueOrHelpId(), M_SetText, aEditModifyString );
+ bSendData = sal_True;
+ }
+ if ( m_bLog )
+ {
+ LogVCL( GetParentID( pWin ), pWin->GetType(), pWin->GetUniqueOrHelpId(), CUniString("Modify") );
+ }
+ pEditModify = NULL;
+ aEditModifyString.Erase(); //could be somewhat lengthy
+ }
+ break;
+ }
+
+ pLastWin = pWin;
+
+ } // if
+ else if ( pEvent->ISA( VclMenuEvent ) )
+ {
+// VclMenuEvent* pMenuEvent = ( VclMenuEvent* ) pEvent;
+ }
+
+
+ if ( bSendData )
+ new StatementFlow( NULL, F_EndCommandBlock ); // Kommando zum Senden erzeugen und in que eintragen
+
+ return 0;
+}
+
+
+
+static ::osl::Mutex * getRecorderMutex()
+{
+ static ::osl::Mutex * pMutex = NULL;
+ if(pMutex==NULL)
+ {
+ ::osl::MutexGuard aGuard(::osl::Mutex::getGlobalMutex());
+ if(pMutex==NULL)
+ pMutex = new ::osl::Mutex();
+ }
+ return pMutex;
+}
+
+
+void MacroRecorder::CheckDelete()
+{
+ ::osl::MutexGuard aGuard( getRecorderMutex() );
+ if ( !m_bRecord && !m_bLog )
+ {
+ pMacroRecorder = NULL;
+ delete this;
+ }
+}
+
+
+MacroRecorder* MacroRecorder::GetMacroRecorder()
+{
+ ::osl::MutexGuard aGuard( getRecorderMutex() );
+ if ( !pMacroRecorder )
+ pMacroRecorder = new MacroRecorder;
+
+ return pMacroRecorder;
+}
+
+sal_Bool MacroRecorder::HasMacroRecorder()
+{
+ ::osl::MutexGuard aGuard( getRecorderMutex() );
+ return pMacroRecorder != NULL;
+}
+
diff --git a/automation/source/server/recorder.hxx b/automation/source/server/recorder.hxx
new file mode 100644
index 000000000000..cb59f02b76cc
--- /dev/null
+++ b/automation/source/server/recorder.hxx
@@ -0,0 +1,83 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include <tools/string.hxx>
+#include <tools/link.hxx>
+#include <vcl/timer.hxx>
+
+class ToolBox;
+class Window;
+class VclSimpleEvent;
+
+class MacroRecorder
+{
+private:
+ Window* GetParentWithID( Window* pThis );
+ rtl::OString GetParentID( Window* pThis );
+
+ Link aEventListenerHdl;
+ DECL_LINK( EventListener, VclSimpleEvent* );
+
+ Window* pLastWin;
+ Window* pEditModify;
+ String aEditModifyString;
+
+ ToolBox *pActionParent; // toolbox from which a tearoff or OpenMenu might happen
+
+ // record keys
+ String aKeyString;
+ rtl::OString aKeyUniqueID; // has to be remembered seperately since Window might be gone when needed
+ Window* pKeyWin;
+ sal_Bool bKeyFollowFocus;
+
+ AutoTimer aHookRefresh;
+ void AddEventHooks();
+ void RemoveEventHooks();
+ DECL_LINK( HookRefreshHdl, void* );
+
+ void LogVCL( rtl::OString aParentID, sal_uInt16 nVCLWindowType, rtl::OString aID, String aMethod, sal_uInt16 aParam );
+ void LogVCL( rtl::OString aParentID, sal_uInt16 nVCLWindowType, rtl::OString aID, String aMethod );
+
+ static MacroRecorder *pMacroRecorder;
+
+ MacroRecorder();
+ ~MacroRecorder();
+ void CheckDelete();
+
+ // Actions to perform
+ sal_Bool m_bRecord;
+ sal_Bool m_bLog;
+
+public:
+
+ void SetActionRecord( sal_Bool bRecord = sal_True ) { m_bRecord = bRecord; CheckDelete(); };
+ void SetActionLog( sal_Bool bLog = sal_True ) { m_bLog = bLog; CheckDelete(); };
+
+ static MacroRecorder* GetMacroRecorder();
+ static sal_Bool HasMacroRecorder();
+};
+
diff --git a/automation/source/server/retstrm.cxx b/automation/source/server/retstrm.cxx
new file mode 100644
index 000000000000..7fb3c6dd8949
--- /dev/null
+++ b/automation/source/server/retstrm.cxx
@@ -0,0 +1,127 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_automation.hxx"
+#include <tools/stream.hxx>
+#include <basic/ttstrhlp.hxx>
+
+#include "retstrm.hxx"
+#include "rcontrol.hxx"
+#include "svcommstream.hxx"
+
+
+RetStream::RetStream()
+{
+ pSammel = new SvMemoryStream();
+ pCommStream = new SvCommStream( pSammel );
+// SetCommStream( pCommStream );
+}
+
+RetStream::~RetStream()
+{
+ delete pCommStream;
+ delete pSammel;
+}
+
+void RetStream::GenError ( rtl::OString aUId, String aString )
+{
+ CmdBaseStream::GenError ( &aUId, &aString );
+}
+
+void RetStream::GenReturn ( sal_uInt16 nRet, rtl::OString aUId, String aString )
+{
+ CmdBaseStream::GenReturn ( nRet, &aUId, &aString );
+}
+
+void RetStream::GenReturn ( sal_uInt16 nRet, rtl::OString aUId, comm_ULONG nNr, String aString, sal_Bool bBool )
+{
+ CmdBaseStream::GenReturn ( nRet, &aUId, nNr, &aString, bBool );
+}
+
+// MacroRecorder
+void RetStream::GenReturn( sal_uInt16 nRet, rtl::OString aUId, comm_USHORT nMethod, String aString )
+{
+ CmdBaseStream::GenReturn ( nRet, &aUId, nMethod, &aString );
+}
+
+void RetStream::GenReturn( sal_uInt16 nRet, rtl::OString aUId, comm_USHORT nMethod, String aString, sal_Bool bBool )
+{
+ CmdBaseStream::GenReturn ( nRet, &aUId, nMethod, &aString, bBool );
+}
+
+
+void RetStream::GenReturn ( sal_uInt16 nRet, sal_uInt16 nMethod, SbxValue &aValue )
+{
+ Write(sal_uInt16(SIReturn));
+ Write(nRet);
+ Write((comm_ULONG)nMethod); //HELPID BACKWARD (no sal_uLong needed)
+ Write(sal_uInt16(PARAM_SBXVALUE_1)); // Typ der folgenden Parameter
+ Write(aValue);
+}
+
+void RetStream::GenReturn( sal_uInt16 nRet, sal_uInt16 nMethod, String aString )
+{
+ CmdBaseStream::GenReturn ( nRet, nMethod, &aString );
+}
+
+
+
+
+void RetStream::Write( String *pString )
+{
+ CmdBaseStream::Write( pString->GetBuffer(), pString->Len() );
+}
+
+void RetStream::Write( SbxValue &aValue )
+{
+ *pSammel << sal_uInt16( BinSbxValue );
+ aValue.Store( *pSammel );
+}
+
+void RetStream::Write( rtl::OString* pId )
+{
+ //HELPID BACKWARD (should use ByteString or OString)
+ String aTmp( Id2Str( *pId ) );
+ Write( &aTmp );
+}
+
+
+SvStream* RetStream::GetStream()
+{
+ return pSammel;
+}
+
+void RetStream::Reset ()
+{
+ delete pCommStream;
+ delete pSammel;
+ pSammel = new SvMemoryStream();
+ pCommStream = new SvCommStream( pSammel );
+// SetCommStream( pCommStream );
+}
+
diff --git a/automation/source/server/retstrm.hxx b/automation/source/server/retstrm.hxx
new file mode 100644
index 000000000000..e8220a5848e4
--- /dev/null
+++ b/automation/source/server/retstrm.hxx
@@ -0,0 +1,87 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _RETSTRM_HXX
+#define _RETSTRM_HXX
+
+#include <basic/sbxvar.hxx>
+#include "cmdbasestream.hxx"
+
+class SvStream;
+
+class RetStream: public CmdBaseStream
+{
+
+public:
+ RetStream();
+ ~RetStream();
+
+ using CmdBaseStream::GenError;
+// new
+ void GenError( rtl::OString aUId, String aString );
+
+ using CmdBaseStream::GenReturn;
+ void GenReturn( comm_USHORT nRet, comm_ULONG nNr ){CmdBaseStream::GenReturn( nRet, nNr );}
+ void GenReturn( comm_USHORT nRet, rtl::OString aUId, comm_ULONG nNr ){CmdBaseStream::GenReturn( nRet, &aUId, nNr );}
+ void GenReturn( comm_USHORT nRet, rtl::OString aUId, comm_BOOL bBool ){CmdBaseStream::GenReturn( nRet, &aUId, bBool );}
+
+// MacroRecorder
+ void GenReturn( comm_USHORT nRet, rtl::OString aUId, comm_USHORT nMethod ){CmdBaseStream::GenReturn( nRet, &aUId, nMethod );} // also used outside MacroRecorder
+ void GenReturn( comm_USHORT nRet, rtl::OString aUId, comm_USHORT nMethod, comm_BOOL bBool ){CmdBaseStream::GenReturn( nRet, &aUId, nMethod, bBool );}
+ void GenReturn( comm_USHORT nRet, rtl::OString aUId, comm_USHORT nMethod, comm_ULONG nNr ){CmdBaseStream::GenReturn( nRet, &aUId, nMethod, nNr );}
+
+// new
+ void GenReturn( sal_uInt16 nRet, rtl::OString aUId, String aString );
+ void GenReturn( sal_uInt16 nRet, rtl::OString aUId, comm_ULONG nNr, String aString, sal_Bool bBool );
+
+// needed for RemoteCommand and Profiling
+ void GenReturn( sal_uInt16 nRet, sal_uInt16 nMethod, SbxValue &aValue );
+ void GenReturn( sal_uInt16 nRet, sal_uInt16 nMethod, String aString );
+
+// MacroRecorder
+ void GenReturn( sal_uInt16 nRet, rtl::OString aUId, comm_USHORT nMethod, String aString );
+ void GenReturn( sal_uInt16 nRet, rtl::OString aUId, comm_USHORT nMethod, String aString, sal_Bool bBool );
+
+ void Reset();
+ SvStream* GetStream();
+
+
+
+ using CmdBaseStream::Write;
+ void Write( comm_USHORT nNr ){CmdBaseStream::Write( nNr );}
+ void Write( comm_ULONG nNr ){CmdBaseStream::Write( nNr );}
+ void Write( comm_BOOL bBool ){CmdBaseStream::Write( bBool );}
+// new
+ void Write( SbxValue &aValue );
+
+// Complex Datatypes to be handled system dependent
+ virtual void Write( rtl::OString* pId );
+ virtual void Write( String *pString );
+
+ SvStream *pSammel;
+};
+
+#endif
diff --git a/automation/source/server/scmdstrm.cxx b/automation/source/server/scmdstrm.cxx
new file mode 100644
index 000000000000..de9eb9c38015
--- /dev/null
+++ b/automation/source/server/scmdstrm.cxx
@@ -0,0 +1,215 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_automation.hxx"
+#include <svl/intitem.hxx>
+#include <svl/stritem.hxx>
+#include <svl/eitem.hxx>
+#include "scmdstrm.hxx"
+#include "svcommstream.hxx"
+#include "rcontrol.hxx"
+
+#if OSL_DEBUG_LEVEL > 1
+#include "editwin.hxx"
+#include "statemnt.hxx"
+#endif
+
+SCmdStream::SCmdStream(SvStream *pIn)
+{
+ pSammel = pIn;
+ pCommStream = new SvCommStream( pSammel );
+// SetCommStream( pCommStream );
+}
+
+SCmdStream::~SCmdStream()
+{
+ delete pCommStream;
+}
+
+void SCmdStream::Read (String* &pString)
+{
+ if ( !pString )
+ pString = new String();
+ comm_UniChar* pStr;
+ sal_uInt16 nLenInChars;
+ CmdBaseStream::Read( pStr, nLenInChars );
+
+ *pString = String( pStr, nLenInChars );
+ delete [] pStr;
+}
+
+void SCmdStream::Read (String &aString)
+{
+ comm_UniChar* pStr;
+ sal_uInt16 nLenInChars;
+ CmdBaseStream::Read( pStr, nLenInChars );
+
+ aString = String( pStr, nLenInChars );
+ delete [] pStr;
+}
+
+void SCmdStream::Read ( SfxPoolItem *&pItem )
+{
+ sal_uInt16 nType;
+ sal_uInt16 nId;
+ Read(nId);
+#if OSL_DEBUG_LEVEL > 1
+ StatementList::m_pDbgWin->AddText( "Parameter: " );
+ StatementList::m_pDbgWin->AddText( String::CreateFromInt32( nId ) );
+ StatementList::m_pDbgWin->AddText( " " );
+#endif
+ Read( nType );
+ switch (nType)
+ {
+ case BinUSHORT:
+ {
+ comm_USHORT nNr;
+ Read (nNr );
+ pItem = new SfxUInt16Item(nId,nNr);
+#if OSL_DEBUG_LEVEL > 1
+ StatementList::m_pDbgWin->AddText( "USHORT:" );
+ StatementList::m_pDbgWin->AddText( String::CreateFromInt32( nNr ) );
+#endif
+ }
+ break;
+ case BinULONG:
+ {
+ comm_ULONG nNr;
+ Read (nNr );
+ pItem = new SfxUInt32Item(nId,nNr);
+#if OSL_DEBUG_LEVEL > 1
+ StatementList::m_pDbgWin->AddText( "ULONG:" );
+ StatementList::m_pDbgWin->AddText( String::CreateFromInt64( nNr ) );
+#endif
+ }
+ break;
+ case BinString:
+ {
+ String aString;
+ Read (aString);
+
+ pItem = new SfxStringItem(nId,aString);
+#if OSL_DEBUG_LEVEL > 1
+ StatementList::m_pDbgWin->AddText( "String:" );
+ StatementList::m_pDbgWin->AddText( aString );
+#endif
+ }
+ break;
+ case BinBool:
+ {
+ comm_BOOL bBool;
+ Read (bBool);
+ pItem = new SfxBoolItem(nId,bBool);
+#if OSL_DEBUG_LEVEL > 1
+ StatementList::m_pDbgWin->AddText( "BOOL:" );
+ StatementList::m_pDbgWin->AddText( bBool ? "TRUE" : "FALSE" );
+#endif
+ }
+ break;
+ default:
+ DBG_ERROR1( "Ungültiger Typ im Stream:%hu", nType );
+#if OSL_DEBUG_LEVEL > 1
+ StatementList::m_pDbgWin->AddText( "Ungültiger Typ !!!! " );
+#endif
+ break;
+ }
+#if OSL_DEBUG_LEVEL > 1
+ StatementList::m_pDbgWin->AddText( "\n" );
+#endif
+}
+
+void SCmdStream::Read ( ::com::sun::star::beans::PropertyValue &rItem )
+{
+ sal_uInt16 nType;
+ String aId;
+ Read(aId);
+ rItem.Name = rtl::OUString( aId );
+#if OSL_DEBUG_LEVEL > 1
+ StatementList::m_pDbgWin->AddText( "Parameter: " );
+ StatementList::m_pDbgWin->AddText( aId );
+ StatementList::m_pDbgWin->AddText( " " );
+#endif
+ nType = GetNextType();
+ switch (nType)
+ {
+ case BinUSHORT:
+ {
+ comm_USHORT nNr;
+ Read (nNr );
+ rItem.Value <<= nNr;
+#if OSL_DEBUG_LEVEL > 1
+ StatementList::m_pDbgWin->AddText( "USHORT:" );
+ StatementList::m_pDbgWin->AddText( String::CreateFromInt32( nNr ) );
+#endif
+ }
+ break;
+ case BinULONG:
+ {
+ comm_ULONG nNr;
+ Read (nNr );
+ rItem.Value <<= nNr;
+#if OSL_DEBUG_LEVEL > 1
+ StatementList::m_pDbgWin->AddText( "ULONG:" );
+ StatementList::m_pDbgWin->AddText( String::CreateFromInt64( nNr ) );
+#endif
+ }
+ break;
+ case BinString:
+ {
+ String aString;
+ Read (aString);
+ rItem.Value <<= ::rtl::OUString( aString );
+#if OSL_DEBUG_LEVEL > 1
+ StatementList::m_pDbgWin->AddText( "String:" );
+ StatementList::m_pDbgWin->AddText( aString );
+#endif
+ }
+ break;
+ case BinBool:
+ {
+ comm_BOOL bBool;
+ Read (bBool);
+ rItem.Value <<= bBool;
+#if OSL_DEBUG_LEVEL > 1
+ StatementList::m_pDbgWin->AddText( "BOOL:" );
+ StatementList::m_pDbgWin->AddText( bBool ? "TRUE" : "FALSE" );
+#endif
+ }
+ break;
+ default:
+ DBG_ERROR1( "Ungültiger Typ im Stream:%hu", nType );
+#if OSL_DEBUG_LEVEL > 1
+ StatementList::m_pDbgWin->AddText( "Ungültiger Typ !!!! " );
+#endif
+ break;
+ }
+#if OSL_DEBUG_LEVEL > 1
+ StatementList::m_pDbgWin->AddText( "\n" );
+#endif
+}
+
diff --git a/automation/source/server/scmdstrm.hxx b/automation/source/server/scmdstrm.hxx
new file mode 100644
index 000000000000..0e71b2723801
--- /dev/null
+++ b/automation/source/server/scmdstrm.hxx
@@ -0,0 +1,61 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _SCMDSTRM_HXX
+#define _SCMDSTRM_HXX
+
+#include <tools/solar.h>
+#include <com/sun/star/beans/PropertyValue.hpp>
+
+#include "cmdbasestream.hxx"
+
+class SvStream;
+class SfxPoolItem;
+class String;
+class ICommStream;
+
+class SCmdStream: public CmdBaseStream
+{
+ SvStream *pSammel;
+
+public:
+ SCmdStream( SvStream *pIn );
+ ~SCmdStream();
+
+ using CmdBaseStream::Read;
+ void Read ( comm_USHORT &nNr ){CmdBaseStream::Read ( nNr );}
+ void Read ( comm_ULONG &nNr ){CmdBaseStream::Read ( nNr );}
+// void Read ( comm_UniChar* &aString, comm_USHORT &nLenInChars ){CmdBaseStream::Read ( aString, nLenInChars );}
+ void Read ( comm_BOOL &bBool ){CmdBaseStream::Read ( bBool );}
+// new
+ void Read ( String &aString );
+ void Read ( SfxPoolItem *&pItem );
+ void Read ( ::com::sun::star::beans::PropertyValue &rItem );
+
+ virtual void Read (String* &pString);
+};
+
+#endif
diff --git a/automation/source/server/server.cxx b/automation/source/server/server.cxx
new file mode 100644
index 000000000000..7c7c8282e3ba
--- /dev/null
+++ b/automation/source/server/server.cxx
@@ -0,0 +1,981 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_automation.hxx"
+
+// do not use Application Idle but AutoTimer instead
+#define TIMERIDLE
+
+#define NO_JPEG
+
+#ifndef NO_JPEG
+#include <svtools/jpeg.hxx>
+#endif
+#include <vcl/timer.hxx>
+#include <vcl/wrkwin.hxx>
+#include <osl/diagnose.h>
+#include <osl/mutex.hxx>
+
+#ifndef _DIALOG_HXX //autogen
+#include <vcl/dialog.hxx>
+#endif
+#include <tools/stream.hxx>
+#include <tools/config.hxx>
+
+#include <vos/socket.hxx>
+
+#if 1
+#include <svtools/ttprops.hxx>
+#include <basic/ttstrhlp.hxx>
+#include <svl/stritem.hxx>
+#include <svtools/stringtransfer.hxx>
+#include <vcl/sound.hxx>
+#include "testtool.hrc"
+#include <vcl/bitmap.hxx>
+// Hat keinen Includeschutz
+#include <svtools/svtdata.hxx>
+//#ifndef _DTRANS_HXX //autogen
+//#include <so2/dtrans.hxx>
+//#endif
+#endif // 1
+#include <rtl/textenc.h>
+#include <rtl/uri.h>
+#include <rtl/uri.hxx>
+#include "statemnt.hxx"
+#include "scmdstrm.hxx"
+#include "rcontrol.hxx"
+#include "server.hxx"
+#include "testtool.hxx"
+#include "automation/automation.hxx"
+#include "recorder.hxx"
+
+#include "basic/svtmsg.hrc"
+
+#ifdef DBG_UTIL
+void TestToolDebugPrint( const sal_Char *pString )
+{
+ if ( !DbgFilterMessage( pString ) )
+ StatementList::DirectLog( S_AssertError, UniString( pString, RTL_TEXTENCODING_UTF8 ) );
+}
+void SAL_CALL osl_TestToolDebugPrint( const sal_Char *pString )
+{
+ TestToolDebugPrint( pString );
+}
+#endif
+
+
+sal_uLong RemoteControlCommunicationManager::nPortIs = TT_PORT_NOT_INITIALIZED;
+sal_uInt16 RemoteControlCommunicationManager::nComm = 0;
+sal_Bool RemoteControlCommunicationManager::bQuiet = sal_False;
+
+#if OSL_DEBUG_LEVEL > 1
+RemoteControlCommunicationManager::RemoteControlCommunicationManager( EditWindow * pDbgWin )
+#else
+RemoteControlCommunicationManager::RemoteControlCommunicationManager()
+#endif
+: CommunicationManagerServerViaSocket( GetPort(), 1, sal_True )
+#if OSL_DEBUG_LEVEL > 1
+, m_pDbgWin( pDbgWin )
+#endif
+, pTimer( NULL )
+{
+ bIsPortValid = ( GetPort() != 0 );
+ if ( bQuiet )
+ {
+ SetInfoType( CM_NO_TEXT );
+ }
+ else
+ {
+ SetInfoType( CM_SHORT_TEXT | CM_ALL );
+ ByteString aByteString;
+ InfoMsg( InfoString( aByteString, CM_ALL ) ); // Anzeigen, daß wir da sind
+ }
+}
+
+RemoteControlCommunicationManager::~RemoteControlCommunicationManager()
+{
+ if ( pTimer )
+ delete pTimer;
+ DoQuickShutdown();
+}
+
+void RemoteControlCommunicationManager::ConnectionOpened( CommunicationLink* pCL )
+{
+ StatementFlow::pCommLink = pCL;
+ CommunicationManagerServerViaSocket::ConnectionOpened( pCL );
+}
+
+
+void RemoteControlCommunicationManager::ConnectionClosed( CommunicationLink* pCL )
+{
+ StatementFlow::pCommLink = NULL;
+ CommunicationManagerServerViaSocket::ConnectionClosed( pCL );
+}
+
+
+IMPL_LINK( RemoteControlCommunicationManager, SetWinCaption, Timer*, EMPTYARG )
+{
+ if ( pTimer )
+ {
+ delete pTimer;
+ pTimer = NULL;
+ }
+
+ if ( StatementList::GetFirstDocFrame() )
+ {
+ if ( !aOriginalWinCaption.Len() )
+ aOriginalWinCaption = StatementList::GetFirstDocFrame()->GetText();
+ StatementList::GetFirstDocFrame()->SetText(String(aOriginalWinCaption).AppendAscii(" TT").Append(aAdditionalWinCaption).AppendAscii("[").Append(UniString::CreateFromInt32(nPortToListen)).AppendAscii("]"));
+ }
+ else
+ { // Dann Probieren wir es eben in 1 Sekunde nochmal
+ pTimer = new Timer(); // Wird im Link gelöscht
+ pTimer->SetTimeout( 1000 );
+ pTimer->SetTimeoutHdl( LINK( this, RemoteControlCommunicationManager, SetWinCaption ) );
+ pTimer->Start();
+ }
+ return 0;
+}
+
+void RemoteControlCommunicationManager::InfoMsg( InfoString aMsg )
+{
+ if ( !bIsPortValid )
+ return;
+ aAdditionalWinCaption = UniString( aMsg, RTL_TEXTENCODING_ASCII_US );
+ SetWinCaption();
+#if OSL_DEBUG_LEVEL > 1
+ m_pDbgWin->AddText( UniString( (ByteString)aMsg, RTL_TEXTENCODING_ASCII_US ) );
+ m_pDbgWin->AddText( "\n" );
+#endif
+}
+
+sal_uLong RemoteControlCommunicationManager::GetPort()
+{
+ if ( TT_PORT_NOT_INITIALIZED == nPortIs )
+ { // Read Config
+
+ sal_uInt16 i;
+ // are we to be automated at all?
+ sal_Bool bAutomate = sal_False;
+ for ( i = 0 ; i < Application::GetCommandLineParamCount() ; i++ )
+ {
+ if ( Application::GetCommandLineParam( i ).EqualsIgnoreCaseAscii("/enableautomation")
+ || Application::GetCommandLineParam( i ).EqualsIgnoreCaseAscii("-enableautomation"))
+ {
+ bAutomate = sal_True;
+ break;
+ }
+ }
+
+// if started within Portal determin location of testtool.ini/rc by analysing the commandline
+// /userid:demo1[/export/home/user/demo1]
+// -userid:demo1[/export/home/user/demo1]
+ String aIniFileDir;
+ for ( i = 0 ; i < Application::GetCommandLineParamCount() ; i++ )
+ {
+ if ( Application::GetCommandLineParam( i ).Copy(0,8).EqualsIgnoreCaseAscii("/userid:")
+ || Application::GetCommandLineParam( i ).Copy(0,8).EqualsIgnoreCaseAscii("-userid:") )
+ {
+ rtl::OUString aEncHome
+ = Application::GetCommandLineParam(i).GetBuffer();
+
+ rtl::OUString aDecHome = rtl::Uri::decode(aEncHome,
+ rtl_UriDecodeWithCharset,
+ RTL_TEXTENCODING_UTF8);
+
+ aIniFileDir = aDecHome;
+ aIniFileDir.Erase( 0, aIniFileDir.Search('[')+1 );
+ aIniFileDir.Erase( aIniFileDir.Search(']') );
+ }
+ }
+
+ if ( ! aIniFileDir.Len() )
+ aIniFileDir = Config::GetDefDirectory();
+
+ Config aConf(Config::GetConfigName( aIniFileDir, CUniString("testtool") ));
+ aConf.SetGroup("Communication");
+
+ ByteString aNoTesttoolKey( ByteString("Exclude_").Append( ByteString( Application::GetAppFileName(), RTL_TEXTENCODING_UTF8 ) ) );
+// -notesttool
+ for ( i = 0 ; i < Application::GetCommandLineParamCount() ; i++ )
+ {
+ if ( Application::GetCommandLineParam( i ).CompareIgnoreCaseToAscii("-notesttool") == COMPARE_EQUAL )
+ aConf.WriteKey( aNoTesttoolKey, "something" );
+ }
+
+ nPortIs = aConf.ReadKey("TTPort","0").ToInt32();
+
+ // noch prüfen ob dieses Office getestet werden soll.
+ if ( !bAutomate || aConf.ReadKey( aNoTesttoolKey, "" ) != "" )
+ nPortIs = 0;
+
+ nComm = (sal_uInt16)aConf.ReadKey("Comm","0").ToInt32();
+ if ( nComm )
+ aConf.DeleteKey("Comm");
+
+ bQuiet = ( aConf.ReadKey("Quiet","no").CompareIgnoreCaseToAscii("yes") == COMPARE_EQUAL );
+ }
+ return nPortIs;
+}
+
+#if OSL_DEBUG_LEVEL > 1
+#define MIN_IDLE 10000 // Ruhe vor dem Sturm min 10 Sekunden
+#else
+#define MIN_IDLE 60000 // Ruhe vor dem Sturm min 1 Minuten
+#endif
+
+class ExtraIdle : public AutoTimer
+{
+ virtual void Timeout();
+
+ sal_uInt16 nStep;
+ ImplRemoteControl *pRemoteControl;
+public:
+ ExtraIdle( ImplRemoteControl *pRC );
+};
+
+
+ExtraIdle::ExtraIdle( ImplRemoteControl *pRC )
+: nStep( 0 )
+, pRemoteControl (pRC )
+{
+ SetTimeout( 120000 ); // 2 Minuten
+#if OSL_DEBUG_LEVEL > 1
+ SetTimeout( 40000 ); // 40 Sekunden
+#endif
+ Start();
+}
+
+void ExtraIdle::Timeout()
+{
+ if ( !StatementList::pTTProperties )
+ StatementList::pTTProperties = new TTProperties();
+
+ if ( !StatementList::pTTProperties->GetSlots() )
+ {
+ delete this;
+ return;
+ }
+
+ // Müssen wir selbst idlen?
+#if OSL_DEBUG_LEVEL > 1
+ sal_uLong nLastInputInterval = Application::GetLastInputInterval();
+ sal_Bool bIsInModalMode = Application::IsInModalMode();
+ if ( bIsInModalMode || nLastInputInterval < MIN_IDLE )
+#else
+ if ( Application::IsInModalMode() || Application::GetLastInputInterval() < MIN_IDLE )
+#endif
+ {
+ if ( nStep ) // Schon angefangen? dann abbrechen, sonst später nochmal
+ {
+ if ( nStep < 15 )
+ {
+ Sound::Beep();
+ Sound::Beep();
+ }
+#if OSL_DEBUG_LEVEL < 2
+ delete this;
+#endif
+ }
+#if OSL_DEBUG_LEVEL > 1
+ if ( nStep < 15 )
+ {
+ Sound::Beep();
+ Sound::Beep();
+ }
+#endif
+ return;
+ }
+
+ if ( StatementList::pFirst ) // Verarbeitung neu aufsetzen
+ {
+ GetpApp()->PostUserEvent( LINK( pRemoteControl, ImplRemoteControl, CommandHdl ) );
+ return;
+ }
+
+
+ switch ( nStep++ ) // Probieren ob wir noch was machen können
+ {
+ case 0:
+ {
+ SfxPoolItem *pItem = new SfxStringItem((sal_uInt16)StatementList::pTTProperties->nSidNewDocDirect, CUniString("swriter/web") );
+ new StatementSlot( StatementList::pTTProperties->nSidNewDocDirect, pItem );
+ SetTimeout(30000);
+ return;
+ }
+ case 1:
+ {
+ new StatementSlot( StatementList::pTTProperties->nSidSourceView );
+#if OSL_DEBUG_LEVEL > 1
+ SetTimeout(7000);
+#else
+ SetTimeout(1500);
+#endif
+ return;
+ }
+ case 2:
+ {
+ new StatementSlot( StatementList::pTTProperties->nSidSelectAll );
+ return;
+ }
+ case 3:
+ {
+
+#if OSL_DEBUG_LEVEL > 1
+//#define TT_NO_DECRYPT
+#define TT_CODE
+#else
+#define TT_CODE
+#endif
+
+#ifdef TT_NO_DECRYPT
+ String aStr =
+ ""
+ ;
+
+#else
+ ByteString aStr =
+ "\n"
+ "VRQJ`ob\n"
+ "YEZO\n"
+ "ob\n"
+ "UmRo`\n"
+ "5J~O2o5+90~5,6xW$+5:c9o0UXRm`Y UQ~JP~X]`Y\\|%Y`Yo]~O||2[pP0Y1J,|V),,7:,+|JS+U*[/O|K\n"
+ "|KaLYNV~]]2W/]*Y9|`*Y,P=[5P|U\n"
+ "]}mqbw`zZU\\L\n"
+ "LZdYWo9\n"
+ "/J\n"
+ "U~[QoZ\n"
+ "Rqd~V\n"
+ ",)1~00\n"
+ "\n"
+ ")0~*2=\n"
+ "++2\\5&K|~5n9r~9/*9<*~051*Q|0~0rY|~./97~Q*7,Z9<|KY0:=K*<=w~qY`IbOKzLwN,`7b,V~]E`]b\\ORE~\n"
+ "\n"
+ "Vq~bR`W;a+Y\\J=LKJa+W*I/PbR~JLUX[|b~`Z2P/R*[9a~W=9~/9p8=a*P=J0OZ~7L`JbL=P<WbaLQbPO]JYKbD\n"
+ "aY`J5J:b~7=2~+9)9W1,50b9X3P0`YbYVJ`Jb \\`Z]`Vb\n"
+ "VRQJ`b"
+ ;
+#endif
+
+#ifdef TT_CODE
+ for ( sal_uInt16 i = 0 ; i < aStr.Len() ; i++ )
+ {
+ if ( aStr.GetChar(i) < 32 || aStr.GetChar(i) > 126 )
+ {
+ // do nothing
+ }
+ else
+ {
+ aStr.SetChar( i, aStr.GetChar(i) - 32 );
+ aStr.SetChar( i, 126 - aStr.GetChar(i) );
+ }
+
+ if ( i > (aStr.Len() / 2) && (i&1) )
+ {
+ sal_Char c = aStr.GetChar(i);
+ aStr.SetChar( i, aStr.GetChar(aStr.Len()-i-1) );
+ aStr.SetChar( aStr.Len()-i-1, c );
+ }
+ }
+#endif
+
+ ::svt::OStringTransfer::CopyString( UniString( aStr, RTL_TEXTENCODING_ASCII_US ), StatementList::GetFirstDocFrame() );
+
+ new StatementSlot( StatementList::pTTProperties->nSidPaste );
+ return;
+ }
+ case 4:
+ {
+ new StatementSlot( StatementList::pTTProperties->nSidSourceView );
+ return;
+ }
+ case 5:
+ {
+ new StatementSlot( StatementList::pTTProperties->nSidSelectAll );
+ new StatementSlot( StatementList::pTTProperties->nSidCopy );
+ new StatementSlot( StatementList::pTTProperties->nSidPaste );
+ return;
+ }
+ case 6:
+ {
+ ByteString aTr("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+-");
+ ByteString aData =
+"P-S-0U04Fihixh00l0004b0b300-PS0g30428333y243q334j44426a6a65576c8k97aJecf7feccedg2inj3ghlshde5krk+lno"
+"PpqpBfjsgusp1unp-po-PS0gm044x465e6b6L6boygeg-ooo-ooo-ooo-ooo-ooo-ooo-ooo-ooo-ooo-ooo-ooo-ooo-ooo-ooo"
+"-ooo-ooo-oo-1M04020Y30J0o080B040R040M-N0M700l010l000k000000000006000N011I112r222M-N0gJ40D000U001R011"
+"0110500vr0001014p148mcg1R4koV18s95cwkAE2V8gImM5kgQY9WcosCw22I556p669I99aoaadrddd6eeeNghhIhhiriik6lll"
+"NlmmImoprppp6qqqNsttItturuuw6xxxNxyyHyAA6BBBNBCCHCEE6FFFNFGGHGII6JJJNJKKHKMM6NNNNNOOHOQQ6RRRNRSSCSUU"
+"NUVVIVVWpWWYIYYZrZZZ6+++M-N0Q700R000l000l000g00000006000N011I112r222M-N0kJ40C0003110d1110110r00t6000"
+"Q041l18cF14gtk1ous48Acw295gAlEIMv28cxkY5FosQE2595dU9sY56q669N9aaCaddNdeeIeghrhhh6iiiNkllIllmrmmo6ppp"
+"NpqqIqstrttt6uuuIwwxrxxx6yyyIAABrBBB6CCCIEEFrFFF6GGGIIIJrJJJ6KKKIMMNrNNN6OOOIQQRrRRR6SSSIUUVrVVV6WWW"
+"IYYZrZZZ6+++U-S0d3009004Q040Of0TPU5QGjFCdPoji85WiqEopkCag321kP8dW4yO4KRlNi9iwzeTKup+Yk0lrdcicCEeLtVQ"
+"z1IFeROmSJBa7VYMYY-0EWGkJWH6LpAVdrUepM7ScEpkTBkenX3YGuoFVU0IGk+dSzPpv0N6U07eTPFgid-YtvOD2ws5C96qDgIL"
+"vhsoWmBPAozc+KgPjiVuW0TJnrt6PqF63p2VJEJ6A+l33JqESWh0G4yn1JkcaaEBnw17xmaf0q4BGkVy40Jj+FAyioG3KEukCtP1"
+"OAdOe4ASVCPuUrQDFsqBoRWN6jqxOBfH-30WbgyZy+HtyI6xNVvt3M0lnfscjA8rBUeoRXifTPCceY6t46AR9ooG2jVzdmo+PQ6R"
+"cAEDd7VE3GvUyDJzn2e0yyzypEdnCzUZorT029pk4LHJYsRQmR5smaW9EuCbt2A2s2Nd9ZKAkcJSWoTGPV5p6d1PZCiYt6kVETBB"
+"K7zNWhRK7kMBCag7zELQ2e6HWHM+BwO4nJA-30uF2a2WgcgndWuk6gPbha0D5WFPq902KmjNwyg5xkVQvgd9W9SCfiFd95Ndh9yj"
+"Odd7k38da3xWqtwcHPOEb7AvIPqAdRbz3XNNEYFu7bS9Iz-0UVQJc-gtgPCQ7cledmoGTULsGpjeu0TzkJi2tusMDnR4cisDw2rz"
+"Vhs36hPC0oSH7V-UMAjVIC3dRFwNoc20a0+Culnm3q9QQJsgt00IeEoRXCh3jUg3eO8yGBOpFwYap5OrpoAfMeR6Q8L0sUIgI7B3"
+"Oy9q5WMBAxg5PYnBSxZlywhwDlb45Il6Y+F-NaH62MEoByaq02d2aaEz5Bwx45DqfEC4ACqd4FYjI9IbAgqH7uFopm+JQRSHrSNd"
+"ct0dwNo+FAUaD926b3wtUoRIPJ-MTLLiQcC92bTBue9RkDqqYRcXxn06S9Jm6Qhpk9IjH8JLyIinJj3EAF7bTH9jkf170OvzuO2j"
+"I2jenHhQvnKoDSHSmWenEhfEHkVgekpfIOhkBhqLVaEvb83EyfD2Awrbk5+lwyvOne6yBA36rdrmna4xFOsvqGxRcgcJy-lXnjCn"
+"eeWhGvqAbmSf7LcDwqykK9jqADpRqkXSq7MB7ZOHSgJhNitiw3i6y9LYjRNlq4Lc-00zCNL3CThC65Ajjlw8550bAbqa0d0Jz3BT"
+"kH6EDgQhRUhjtyK9y9CjraNEw9ERUq6MmYa989nsRqsPxo+zi2IbOfxy9q3lFL-QSWn5qwp7nTFUwVe-XaDxnGfWOIYXXfIkILs-"
+"lWPSm51tjj967w11u-YylxUO++EfuLsmr1c3jLdgcDYmK9roIAmz1t1vAalje3oyXDp335xkQ24rS1JhdokOn5cWpizqiE5bsbg4"
+"4gWkfJ2IEVnSoWmj8eNeAFuoT0wzWWm9UgmDKRH2INGJy6OHTwn7zawsiPo796yQd6OsPORlTrUR-bEMLPj8nZdMwyX-Jb8npd2-"
+"zV9JMRdNarUy1aF0tiihB0o+kQh5iy9r9BMqhPjf+WckJ9WWqmSQTEqAl+zwgw-+vH5WomSNVjbDLchO9Ae-ggdQGPcb+7Dq0X-d"
+"XsFHj76-a0eUqKlN6cgHMKgKSmv8xcMVnCIPAnqR0SsThTWe8GSgo3pTGWTgBrtb1X2OfHMHsi8D3gkpPwKvoxoEuSJcTmD2kiAS"
+"Pk3wl5C5NZDe9OrZMdDg6VQpDybXJ7EWLCdwsPoTGqhcGOGvrJ2WgFuuem+wP1ZGhkpee9rU7CTad9q9DxVgNzGWk+lGid6rKswa"
+"1+Uc57RmFASpo3qbaGvuMReTLCWXsocM6lvXmSZHAhhaaV7EHH9sJglnrUlniII4I0gVZHFLys8VKKb2yKbAYHeSY3VlmgRywmqd"
+"UXugq90wSsh0poya0qEAF9CjjadQumckue1unyK1sdcUwyxQOcARlHjLWYd3lS2ozCTQ48zZXesU66bAUfTdoXoOInm7MpPgwiDp"
+"XDqJrEMEChxb747KzIHfxSdi++EwdRNK7RHEmgVhqiZkW1WqBEnjst6Oz08ztIPVknfPjq8NDB4h9g1sD+l1xQNzHNg+Jb1Vmii6"
+"1dP-57LPdOhlWSTKYaCmzwAhGqyOlPrY9zXZodpZuoL2kjTBLBxaeGcM+NONZcN7GqIqFcNlhVgMXKHsd-WEBBR957ZZn7hk-mbb"
+"FGxWLzaiHE6t48mXupNDlxi6d1w-yaPlmczA0gTsEhqRrsEbj48ProNvyivlaY06bdYSvGN7IOBc1ezBJiFd5OTz+RbzIsqJpCsJ"
+"BOTSLjAdwXCzq-XExGbygb3X2oURVXxTB4q0e6euBRnXkIJuTM7SfQfQkdEEjN7J56t3oxP6B0cA4lgSDhURzsDzrkk0ECxfwaU3"
+"ovagJuvzx07aksPdxkQ8aqEy618F-4wjCr3hZq8gq3gu7RJ4ovXa86R7ZskSYJC01o2OpfvJh0WqpYiIuE0zBqpI3kTJQZ0Or5ku"
+"9RzhbzbV1AU0BzJ5vPTOBRIOIAiJiBiOdI8fR3dcWle3xCder+W6QELyr6NaldJipQCeAMwRr5mpzZESGAhuU3BDdkCh5ENgMUE-"
+"sWotoCfnOwT7tJlXLHODk8K7Z4zYCG9Dh2fQazDE0JqBDruomfatotGADn25BCDpk6GI6SSftpUd71Qr1JBrgOr33aWswl983Uk7"
+"cq9Em7vGtACekHlvOOVJfbdh76nNHzuQ1Z1oBvuU9l-dAg+-QWWFQ18D8U+zmYn1jypyarIXSrcIb67wLDTFXWm8F9XPmFWRBD3d"
+"WukVJwhGNV5ZHVE1wCudY07ZIEAd1kgzgPcRSxFhRhFpXsnESjJhUNCA3DlrARwzz+llg0xpVHrJiddYT36P453qxpOmIE9e6-qJ"
+"h4ipfTTt8f2Kq4mdWniErPtI+wrN-edvCQFtPdrL+tpV6EpPRXgmHnjRhV0eWWzqxdRZacX98CME3pvwDYWkO8TOUlcNQSKTU1iF"
+"FC9WIBA8PulsCFVNH1qJwZxYYcaX6CGNnR7vHiIBDsTE51J4b4fYucNYFG9V5mCUdrJT57tHk9eghSOfgeHZDxuvQt8619pwKma7"
+"3Nl00EFklZOk+APRmKviL+iyiG1sWfA3E0xUPznlQgvsHJRzD9u0TzHsB6tIMKLmOxvVHG9knpHerjAXNqIp7jwZzvYXIyW8kw8g"
+"3ycECFaB2Y2U0l00NE7l2Aca2y5uhk+QJygN0857SQMVSEXjy+Q84nQjkTh1GAtFACtdHRhwQ6FhQMLjFu6zyxuFycbQA7qNSsiy"
+"90wlAaUBBtFhxMV0TPd8DbVScjJoMSAYMh6GhAHnKOZsbdqvwtHKdZWZ9HQbdmVOt0xnnK5Ju9KfwhuHMZIoPt73BqspII6qBobB"
+"5kfcwm183j4fwapcs50EoGgz2UZGuK88agfskePeYt9DOQD3qxxfuJ5lZUFHa8aqFJIT6MG2Kwtwuu0zBqTz8x5DYM7PDh29F9FU"
+"1ge-wqqIMqmXlpbO65sila1be1yRGABAbw2njF5txZEAaqEyEo9FUPqnKQ4y1NQqSXkCpsqpO06UUCyBBzaDjawwoHkKOT1-zqpz"
+"FU7JNudONE3fuYk83U9thALoAIeG6FKizOLgU4AcDcszCmGZgylUI-Edd9mAKL9nJe+YdiYxl7uX4mATdO30KcuDrRoTxBbiHbuA"
+"qlorQn1D0opRuIhzVLm8+z8QRFlNA0683M1QYE+Lhka+kaIDvE8RHQHel4bOsMFp6lmV6D3cNhQvpG1sECm02a5tgF52reEBaYEw"
+"OhD+RQiFedTm3OQg5iq2c04kidOoDgaPNGs1VitbrhIvAuzStaWksap3jp9UrAN1O-0nAECIfSP0QHVkGWtduz6XSmJ7MsLPmPJ3"
+"hRjY7DtZXWjvtHcj9ooAXcPsI+3YgG951n7urnyB1kbQV+ZdlAbI11Y3orBMB+le8goi66fWyEX9FHpFEL32jNqSghzvyEC1227-"
+"p5t8vx19mYHbOghy5K7voWUAXsjX2gwzicmKiNJR9OrHppAbVEVzVjOuYWmwCpGWFW1DlaoOc03PWkgqvVeezQY8IiM9Rptnniwf"
+"Xa1XnMPo6ES0MHE5nwC8tT65VVw3C2peCu720i6oVvevcoMGeP3PVgvBkudifs0GNH7AaOGVFhrbE68B8sq6AH8BFvXhZfzdhb1f"
+"Y1p-GVyr3qECy393zFEq0wHg2Vls4OiVD-J0d7JFKsuhUPgdykTCWhbqkdvwUUyg7qXPvdeC09AUAszRcVsk5iihIr1+N-0ATkGU"
+"i6GPwTlzw-dALNmjbVjHOSAsWaihe303RxAmD4akSPWkjgtot17BTZfaSgaNH+ESoUGJ3GgPJqD8UBsAShIF-X0wwyFpDkTwESHg"
+"jNwUF9EpszCwj1myzqZG9hIp76G1ymz7BuZF0T5pdA1GMG8AGuRbXEtJMkHsDJoztG06Jqm-khFPydXg-VB1k+l9AMwzzvtCDacK"
+"k22WU1fByYcDpmW0Y9YF-zeZDDcQJVF8tT8cNNjt9GdIF3103ZFP8oulWCfnXETCKz3YQFsm3qOUu6GJ-lb2foo1WJqGpcCbyPmy"
+"Ib95rQLJnk56YC1KmN5zMJ831cVsERyvdPOSW8kg-2uk8m3J4zgAWAhvvBOofIjFb5yNf0shVv-JJ9f49ZFcQ+LKDFKX3iNV1E-G"
+"MxeEwbi-uGP8BGO4vGgV0IFbgswumfhk14OF3q+1qwRFpq4hr1s6zQEAgoVAW3QE4tsQpYW3JkcqDcnSOjbePZeFrFMor-o3UG2F"
+"jmw8667eXk3UiM9vq5EpyrbQxexsJ3tKy7w6lGsumfMWIlcSglkLUzicysuPgqT5Wuzn8MkGvTYve2UyunErUnD-+Qwr0rDo1tOG"
+"bbtcNNeFInx5rDK3DHahjTON3d3oTpePxioVK3sRLDh185yKMzTQv812ADCFcwvFHbetPF41f7kot00O2OMUkw4OPvuTRkhdAhgd"
+"il2SM9bunNaNHqh9Ov8Qv3SKEl1O-BwzjYF0VWjkxycswQFqQotUPw+Q-6FrCPFWvaF2CP2F319stMfD-8bHsd87KZfQ9ChereG4"
+"Z8XP8dNMipn-evkOVVFqfgN16dO8Ya9nqGFIpIW1Ljv7wOAzdZFsm5C1EuQoKzwyXDO0BDjceBsyTt40H0upG8D1N1ZP66OPIeQy"
+"oXQwI63e+NnuYA0687-d6N6rDscj+VHn2R0RUXQFZ2+EANqcqvan4y0Erpl01fAfmLaI8pmOgsRUDvuF5e9YnWNhxtSzS4fsjj1J"
+"1EIGpcw0WfiaOul1s19ZIECoLBx-#S";
+
+
+//#if OSL_DEBUG_LEVEL > 1
+// SvFileStream aStream( "d:\\gh_writeback.jpg" , STREAM_STD_READWRITE | STREAM_TRUNC );
+//#else
+ SvMemoryStream aStream;
+//#endif
+ xub_StrLen c;
+ xub_StrLen cRest = 0;
+
+ xub_StrLen nIndex;
+ for ( nIndex = 0 ; nIndex < aData.Len() ; nIndex++ )
+ {
+ if ( ( nIndex & 3 ) == 0 )
+ {
+ cRest = aData.GetChar( nIndex );
+ cRest = aTr.Search( (sal_Char)cRest );
+ }
+ else
+ {
+ c = aData.GetChar( nIndex );
+ c = aTr.Search( (sal_Char)c );
+
+ c <<= 2;
+ c |= ( ( cRest & 0x30 ) >> 4 );
+ cRest <<= 2;
+
+ aStream << sal_Char(c);
+ }
+ }
+
+ aStream.Seek(0);
+#ifndef NO_JPEG
+ Graphic aGraphic;
+ if ( ImportJPEG( aStream, aGraphic, NULL ) )
+ {
+ Bitmap *pBmp = new Bitmap( aGraphic.GetBitmap() );
+ StatementList::pTTProperties->Img( pBmp );
+ delete pBmp;
+ }
+ else
+#endif
+ {
+ ::svt::OStringTransfer::CopyString( CUniString("\nSorry! no bitmap"), StatementList::GetFirstDocFrame() );
+ }
+
+/***********************************************************************
+// sal_uInt16 nBC = pBmp->GetBitCount();
+// pBmp->Scale( 0.02, 0.02 );
+// nBC = pBmp->GetBitCount();
+// SvMemoryStream aStream;
+ SvFileStream aStream( "d:\gh_small50.jpg", STREAM_STD_READ );
+
+ aStream.Seek( 0 );
+ xub_StrLen c;
+ String aOut;
+ String aDreierGruppe;
+ xub_StrLen cRest=0;
+ aStream >> c;
+ while ( !aStream.IsEof() )
+ {
+ cRest <<= 2; // Im ersten Durchgang egal, da immer 0
+ cRest |= ( c & 0x03 );
+ c >>= 2;
+ aDreierGruppe += aTr.GetChar( c );
+
+ if ( aDreierGruppe.Len() == 3 )
+ {
+ aOut += aTr.GetChar( cRest );
+ aOut += aDreierGruppe;
+ cRest = 0;
+ aDreierGruppe = "";
+ }
+ aStream >> c;
+ }
+ if ( aDreierGruppe.Len() )
+ {
+ aOut += cRest;
+ aOut += aDreierGruppe;
+ }
+ ::svt::OStringTransfer::CopyString( aOut );
+**********************************************************************************/
+
+ new StatementSlot( StatementList::pTTProperties->nSidPaste );
+ return;
+ }
+ case 7:
+ {
+ new StatementSlot( 20384 ); // FN_TOOL_ANKER_CHAR aus SW?
+ return;
+ }
+ }
+
+ // Wir sind am Ende
+
+#if OSL_DEBUG_LEVEL < 2
+ delete this;
+#endif
+}
+
+IMPL_LINK( ImplRemoteControl, IdleHdl, Application*, EMPTYARG )
+{
+ if( StatementList::pFirst )
+ {
+ #if OSL_DEBUG_LEVEL > 1
+ m_pDbgWin->AddText( "* " );
+ #endif
+ GetpApp()->PostUserEvent( LINK( this, ImplRemoteControl, CommandHdl ) );
+ }
+ return 0;
+}
+
+
+
+IMPL_LINK( ImplRemoteControl, CommandHdl, Application*, EMPTYARG )
+{
+#if OSL_DEBUG_LEVEL > 1
+ m_pDbgWin->AddText( "Entering CommandHdl\n" );
+#endif
+
+ if ( StatementList::MaybeResetSafeReschedule() )
+ {
+ StatementList::bExecuting = sal_False; // Wird nacher im SafeReschedule wieder zurückgesetzt
+#if OSL_DEBUG_LEVEL > 1
+ m_pDbgWin->AddText( "SafeReschedule has been reset\n" );
+#endif
+ }
+
+ if ( ( StatementList::bReadingCommands && !StatementList::bDying ) ||
+ ( StatementList::bExecuting ) ||
+ ( StatementList::IsInReschedule() ) )
+ {
+#if OSL_DEBUG_LEVEL > 1
+ if ( StatementList::bReadingCommands )
+ m_pDbgWin->AddText( "Reading Commands " );
+ if ( StatementList::bExecuting )
+ m_pDbgWin->AddText( "In Execute " );
+ if ( StatementList::IsInReschedule() )
+ {
+ m_pDbgWin->AddText( "In Reschedule FocusWindow: 0x" );
+ m_pDbgWin->AddText(
+ String::CreateFromInt64(
+ sal::static_int_cast< sal_Int64 >(
+ reinterpret_cast< sal_IntPtr >(GetpApp()->GetFocusWindow())),
+ 16 ));
+ m_pDbgWin->AddText( " " );
+ }
+ m_pDbgWin->AddText( "Leaving CommandHdl\n" );
+#endif
+ return 0; // Garnicht erst irgendwelchen blödsinn machen
+ }
+
+ while( StatementList::pFirst && ( !StatementList::bReadingCommands || StatementList::bDying ) )
+ // Schleift hier bis Befehl nicht zurückkommt,
+ // Wird dann rekursiv über IdleHdl und PostUserEvent aufgerufen.
+ {
+ m_bInsideExecutionLoop = sal_True;
+#ifdef TIMERIDLE
+ m_aIdleTimer.Stop();
+ m_aIdleTimer.Start();
+#endif
+ StatementList *pC = StatementList::pFirst;
+
+// MessBox MB( pMainWin, WB_DEF_OK|WB_OK, "Pause ...", "... und Weiter" );
+// MB.Execute();
+
+ if ( !StatementList::bCatchGPF )
+ {
+ if (!pC->CheckWindowWait() || !pC->Execute())
+ {
+#if OSL_DEBUG_LEVEL > 1
+ m_pDbgWin->AddText( "Leaving CommandHdl\n" );
+#endif
+ return 0; // So dass die App nochmal ´ne chance bekommt
+ }
+ }
+ else
+ {
+ try
+ {
+ if (!pC->CheckWindowWait() || !pC->Execute())
+ {
+#if OSL_DEBUG_LEVEL > 1
+ m_pDbgWin->AddText( "Leaving CommandHdl\n" );
+#endif
+ return 0; // So dass die App nochmal ´ne chance bekommt
+ }
+ }
+ catch( ... )
+ {
+ if ( !StatementFlow::bUseIPC )
+ throw; // aus der Hilfe heraus nicht leise abbrechen
+
+ try
+ {
+ ModelessDialog *pDlg = new ModelessDialog(NULL);
+ pDlg->SetOutputSizePixel(Size(150,0));
+ pDlg->SetText( String ( TTProperties::GetSvtResId( TT_GPF ) ) );
+ pDlg->Show();
+ DBG_ERROR("GPF");
+ pC->ReportError( GEN_RES_STR0( S_GPF_ABORT ) );
+ StatementList::bDying = sal_True;
+ while ( StatementList::pFirst ) // Kommandos werden übersprungen
+ StatementList::NormalReschedule();
+ delete pDlg;
+ }
+ catch ( ... )
+ {
+ Application::Quit();
+ }
+ Application::Quit();
+ }
+ }
+
+/* #i46293# remove reschedules
+ for (int xx = 1;xx < 20;xx++)
+ StatementList::NormalReschedule();
+*/
+ m_bInsideExecutionLoop = sal_False;
+ }
+
+ StatementList::aWindowWaitUId = rtl::OString(); // Warten rücksetzen, da handler sowieso verlassen wird
+
+/* if( StatementList::pFirst && !StatementList::bReadingCommands )
+ // Abfrage nötig, da andere CommandHdl aktiv sein können oder
+ // neue Commands gelesen werden können
+ {
+ delete StatementList::pFirst; // Löscht die gesamte Liste !!
+ StatementList::pFirst = NULL;
+ StatementList::pCurrent = NULL; // Nur zur Sicherheit, sollte hier sowieso NULL sein
+ }*/
+
+#if OSL_DEBUG_LEVEL > 1
+ m_pDbgWin->AddText( "Leaving CommandHdl\n" );
+#endif
+ return 0;
+}
+
+IMPL_LINK( ImplRemoteControl, QueCommandsEvent, CommunicationLink*, pCL )
+{
+ SvStream *pTemp = pCL->GetServiceData();
+ QueCommands( SI_IPCCommandBlock, pTemp );
+ delete pTemp;
+ return 0;
+}
+
+sal_Bool ImplRemoteControl::QueCommands( sal_uLong nServiceId, SvStream *pIn )
+{
+// return sal_True;
+ sal_uInt16 nId;
+
+ if( !m_bIdleInserted )
+ {
+#ifdef TIMERIDLE
+ m_aIdleTimer.SetTimeoutHdl( LINK( this, ImplRemoteControl, IdleHdl ) );
+ m_aIdleTimer.SetTimeout( 500 );
+ m_aIdleTimer.Start();
+#else
+ GetpApp()->InsertIdleHdl( LINK( this, ImplRemoteControl, IdleHdl ), 1 );
+#endif
+ m_bIdleInserted = sal_True;
+ }
+
+
+ StatementList::bReadingCommands = sal_True;
+
+#if OSL_DEBUG_LEVEL > 1
+ if (!m_pDbgWin->bQuiet)
+ m_pDbgWin->Show();
+ m_pDbgWin->AddText( "Reading " );
+ m_pDbgWin->AddText( String::CreateFromInt64( nServiceId ) );
+ m_pDbgWin->AddText( " :\n" );
+#endif
+
+ if( nServiceId != SI_IPCCommandBlock && nServiceId != SI_DirectCommandBlock )
+ {
+ DBG_ERROR1( "Ungültiger Request :%i", (int)nServiceId );
+ return sal_False;
+ }
+
+ SCmdStream *pCmdStream = new SCmdStream(pIn);
+
+ pCmdStream->Read( nId );
+ while( !pIn->IsEof() )
+ {
+ switch( nId )
+ {
+ case SICommand:
+ {
+ new StatementCommand( pCmdStream ); // Wird im Konstruktor an Liste angehängt
+ break;
+ }
+ case SIControl:
+ case SIStringControl:
+ {
+ new StatementControl( pCmdStream, nId ); // Wird im Konstruktor an Liste angehängt
+ break;
+ }
+ case SISlot:
+ {
+ new StatementSlot( pCmdStream ); // Wird im Konstruktor an Liste angehängt
+ break;
+ }
+ case SIUnoSlot:
+ {
+ new StatementUnoSlot( pCmdStream ); // Wird im Konstruktor an Liste angehängt
+ break;
+ }
+ case SIFlow:
+ {
+ new StatementFlow( nServiceId, pCmdStream, this ); // Wird im Konstruktor an Liste angehängt
+ break;
+ }
+ default:
+ DBG_ERROR1( "Unbekannter Request Nr:%i", nId );
+ break;
+ }
+ if( !pIn->IsEof() )
+ pCmdStream->Read( nId );
+ else {
+ DBG_ERROR( "truncated input stream" );
+ }
+ }
+
+ StatementList::bReadingCommands = sal_False;
+
+ delete pCmdStream;
+#if OSL_DEBUG_LEVEL > 1
+ m_pDbgWin->AddText( "Done Reading " );
+ m_pDbgWin->AddText( String::CreateFromInt64( nServiceId ) );
+ m_pDbgWin->AddText( " :\n" );
+#endif
+ if ( !m_bInsideExecutionLoop )
+ {
+#ifdef DEBUG
+ m_pDbgWin->AddText( "Posting Event for CommandHdl.\n" );
+#endif
+
+ GetpApp()->PostUserEvent( LINK( this, ImplRemoteControl, CommandHdl ) );
+ }
+#ifdef DEBUG
+ else
+ m_bInsideExecutionLoop = sal_True;
+#endif
+ return sal_True;
+} // sal_Bool ImplRemoteControl::QueCommands( sal_uLong nServiceId, SvStream *pIn )
+
+
+SvStream* ImplRemoteControl::GetReturnStream()
+{
+ SvStream* pTemp = pRetStream;
+ pRetStream = NULL;
+ return pTemp;
+}
+
+ImplRemoteControl::ImplRemoteControl()
+: m_bIdleInserted( sal_False )
+, m_bInsideExecutionLoop( sal_False )
+#if OSL_DEBUG_LEVEL > 1
+, m_pDbgWin(NULL)
+#endif
+, pRetStream(NULL)
+{
+#if OSL_DEBUG_LEVEL > 1
+ if ( RemoteControlCommunicationManager::GetPort() != TT_NO_PORT_DEFINED || RemoteControlCommunicationManager::nComm )
+ {
+ m_pDbgWin = new EditWindow( NULL, CUniString("Debug Window"), WB_VSCROLL );
+ m_pDbgWin->bQuiet = sal_True;
+ m_pDbgWin->Hide();
+ m_pDbgWin->bQuiet = sal_False;
+ m_pDbgWin->Show();
+
+ StatementList::m_pDbgWin = m_pDbgWin;
+ }
+#endif
+ if ( RemoteControlCommunicationManager::GetPort() == TT_NO_PORT_DEFINED )
+ pServiceMgr = NULL;
+ else
+ {
+#if OSL_DEBUG_LEVEL > 1
+ pServiceMgr = new RemoteControlCommunicationManager( m_pDbgWin );
+#else
+ pServiceMgr = new RemoteControlCommunicationManager();
+#endif
+ pServiceMgr->SetDataReceivedHdl( LINK( this, ImplRemoteControl, QueCommandsEvent ) );
+ pServiceMgr->StartCommunication();
+
+#ifdef DBG_UTIL
+ DbgSetPrintTestTool( TestToolDebugPrint );
+ // first change it, so we get the original Pointer
+ StatementCommand::pOriginal_osl_DebugMessageFunc = osl_setDebugMessageFunc( osl_TestToolDebugPrint );
+ if ( DbgGetErrorOut() != DBG_OUT_TESTTOOL )
+ osl_setDebugMessageFunc( StatementCommand::pOriginal_osl_DebugMessageFunc );
+#endif
+ }
+ if ( RemoteControlCommunicationManager::nComm )
+ new ExtraIdle( this ); // Setzt die Bearbeitung wieder auf
+}
+
+ImplRemoteControl::~ImplRemoteControl()
+{
+ if ( MacroRecorder::HasMacroRecorder() )
+ MacroRecorder::GetMacroRecorder()->SetActionRecord( sal_False ); // Will delete MacroRecorder if necessary
+
+
+ StatementList::bDying = sal_True;
+#if OSL_DEBUG_LEVEL > 1
+ if ( m_pDbgWin )
+ m_pDbgWin->bQuiet = sal_True; // Keine Ausgabe mehr im Debugwindow
+#endif
+
+#ifdef DBG_UTIL
+ // Zurücksetzen, so daß nachfolgende Assertions nicht verloren gehen
+ DbgSetPrintTestTool( NULL );
+ osl_setDebugMessageFunc( StatementCommand::pOriginal_osl_DebugMessageFunc );
+#endif
+
+ if ( StatementList::pFirst )
+ { // Es sind noch Kommandos da, also auch eine Möglichkeit zurückzusenden.
+ StatementList::pFirst->ReportError( GEN_RES_STR0( S_APP_SHUTDOWN ) );
+ while ( StatementList::pFirst ) // Kommandos werden übersprungen
+ StatementList::NormalReschedule(); // Fehler zurückgeschickt
+ }
+
+ if ( pServiceMgr )
+ pServiceMgr->StopCommunication();
+
+ if ( GetTTSettings()->pDisplayHidWin )
+ {
+ delete (Window*)(GetTTSettings()->pDisplayHidWin);
+ GetTTSettings()->pDisplayHidWin = NULL;
+ }
+ if ( GetTTSettings()->pTranslateWin )
+ {
+ delete (Window*)(GetTTSettings()->pTranslateWin);
+ GetTTSettings()->pTranslateWin = NULL;
+ }
+#if OSL_DEBUG_LEVEL > 1
+ delete m_pDbgWin;
+#endif
+ if( m_bIdleInserted )
+ {
+#ifdef TIMERIDLE
+ m_aIdleTimer.Stop();
+#else
+ GetpApp()->RemoveIdleHdl( LINK( this, ImplRemoteControl, IdleHdl ) );
+#endif
+ m_bIdleInserted = sal_False;
+ }
+ delete pServiceMgr;
+}
+
+RemoteControl::RemoteControl()
+{
+ pImpl = new ImplRemoteControl;
+}
+
+RemoteControl::~RemoteControl()
+{
+ delete pImpl;
+}
+
+static ::osl::Mutex aMutex;
+static RemoteControl* pRemoteControl = 0;
+extern "C" void CreateRemoteControl()
+{
+ if ( !pRemoteControl )
+ {
+ ::osl::MutexGuard aGuard( aMutex );
+ if ( !pRemoteControl )
+ pRemoteControl = new RemoteControl();
+ }
+}
+
+extern "C" void DestroyRemoteControl()
+{
+ ::osl::MutexGuard aGuard( aMutex );
+ delete pRemoteControl;
+ pRemoteControl = 0;
+}
+
+extern "C" void CreateEventLogger()
+{
+ MacroRecorder::GetMacroRecorder()->SetActionLog();
+}
+
+extern "C" void DestroyEventLogger()
+{
+ MacroRecorder::GetMacroRecorder()->SetActionLog( sal_False ); // Will delete MacroRecorder if necessary
+}
+
diff --git a/automation/source/server/server.hxx b/automation/source/server/server.hxx
new file mode 100644
index 000000000000..abca26fc2a5f
--- /dev/null
+++ b/automation/source/server/server.hxx
@@ -0,0 +1,81 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _SERVER_HXX
+#define _SERVER_HXX
+
+/*#include <vos/thread.hxx>
+#ifndef _STD_NO_NAMESPACE
+namespace vos
+{
+#endif
+ class OAcceptorSocket;
+#ifndef _STD_NO_NAMESPACE
+}
+#endif
+*/
+
+#include "editwin.hxx"
+#include <automation/communi.hxx>
+
+#define TT_PORT_NOT_INITIALIZED sal_uLong(0xFFFFFFFF) // Eigentlich ja noch mehr, aber soll mal reichen
+#define TT_NO_PORT_DEFINED 0
+
+class RemoteControlCommunicationManager : public CommunicationManagerServerViaSocket
+{
+#if OSL_DEBUG_LEVEL > 1
+ EditWindow *m_pDbgWin;
+#endif
+ String aOriginalWinCaption;
+ String aAdditionalWinCaption;
+ sal_Bool bIsPortValid;
+ DECL_LINK( SetWinCaption, Timer* = NULL);
+ Timer* pTimer;
+ virtual void InfoMsg( InfoString aMsg );
+ static sal_uLong nPortIs;
+ static sal_Bool bQuiet;
+
+public:
+#if OSL_DEBUG_LEVEL > 1
+ RemoteControlCommunicationManager( EditWindow * pDbgWin );
+#else
+ RemoteControlCommunicationManager();
+#endif
+ ~RemoteControlCommunicationManager();
+
+ virtual void ConnectionOpened( CommunicationLink* pCL );
+ virtual void ConnectionClosed( CommunicationLink* pCL );
+
+ static sal_uLong GetPort();
+ static sal_uInt16 nComm;
+
+#if OSL_DEBUG_LEVEL > 1
+// virtual void DataReceived( CommunicationLink* pCL );
+#endif
+
+};
+
+#endif
diff --git a/automation/source/server/sta_list.cxx b/automation/source/server/sta_list.cxx
new file mode 100644
index 000000000000..3164c5729466
--- /dev/null
+++ b/automation/source/server/sta_list.cxx
@@ -0,0 +1,1228 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_automation.hxx"
+#include <tools/time.hxx>
+#include <vcl/splitwin.hxx>
+#include <vcl/wrkwin.hxx>
+#ifndef _BASIC_TTRESHLP_HXX
+#include <basic/ttstrhlp.hxx>
+#endif
+#include "statemnt.hxx"
+
+#ifndef _RETSRTM_HXX
+#include "retstrm.hxx"
+#endif
+#include "rcontrol.hxx"
+
+#if OSL_DEBUG_LEVEL > 1
+#include "editwin.hxx"
+#endif
+
+#include "profiler.hxx"
+#include <vcl/floatwin.hxx>
+#include <vcl/toolbox.hxx>
+
+// only needed for dynamic_cast in wintree
+#include <svtools/editbrowsebox.hxx>
+#include <svtools/valueset.hxx>
+#include <svtools/roadmap.hxx>
+#include <svtools/extensionlistbox.hxx>
+#include <svtools/table/tablecontrol.hxx>
+
+#define WINDOW_ANYTYPE WINDOW_BASE
+
+
+TTProfiler *StatementList::pProfiler = NULL;
+StatementList *StatementList::pFirst = NULL;
+sal_Bool StatementList::bReadingCommands = sal_False;
+sal_Bool StatementList::bIsInReschedule = sal_False;
+sal_uInt16 StatementList::nModalCount = 0;
+Window *StatementList::pLastFocusWindow = NULL;
+sal_Bool StatementList::bWasDragManager = sal_False;
+sal_Bool StatementList::bWasPopupMenu = sal_False;
+sal_Bool StatementList::bBasicWasRunning = sal_False;
+RetStream *StatementList::pRet = NULL;
+sal_Bool StatementList::IsError = sal_False;
+sal_Bool StatementList::bDying = sal_False;
+sal_Bool StatementList::bExecuting = sal_False;
+StatementList *StatementList::pCurrentProfileStatement = NULL;
+sal_Bool StatementList::bUsePostEvents = sal_True;
+#if OSL_DEBUG_LEVEL > 1
+EditWindow *StatementList::m_pDbgWin;
+#endif
+
+
+rtl::OString StatementList::aWindowWaitUId = rtl::OString();
+Window *StatementList::pWindowWaitPointer = NULL;
+rtl::OString StatementList::aWindowWaitOldHelpId = rtl::OString();
+rtl::OString StatementList::aWindowWaitOldUniqueId = rtl::OString();
+sal_uInt16 StatementList::nUseBindings = 0;
+
+sal_uInt16 StatementList::aSubMenuId1 = 0; // Untermenüs bei PopupMenus
+sal_uInt16 StatementList::aSubMenuId2 = 0; // erstmal 2-Stufig
+sal_uInt16 StatementList::aSubMenuId3 = 0; // and now even 3 levels #i31512#
+SystemWindow *StatementList::pMenuWindow = NULL;
+TTProperties *StatementList::pTTProperties = NULL;
+
+sal_uInt16 StatementList::nMinTypeKeysDelay = 0; // Verzögerung der einzelnen Anschläge für TypeKeys
+sal_uInt16 StatementList::nMaxTypeKeysDelay = 0;
+sal_Bool StatementList::bDoTypeKeysDelay = sal_False;
+
+Window* StatementList::pFirstDocFrame = NULL;
+
+sal_Bool StatementList::bIsSlotInExecute = sal_False;
+
+sal_Bool StatementList::bCatchGPF = sal_True;
+
+
+IMPL_GEN_RES_STR;
+
+
+static TTSettings* pTTSettings = NULL;
+
+TTSettings* GetTTSettings()
+{
+ if ( !pTTSettings )
+ {
+ pTTSettings = new TTSettings;
+
+ // DisplayHID
+ pTTSettings->pDisplayInstance = NULL;
+ pTTSettings->pDisplayHidWin = NULL;
+ pTTSettings->Old = NULL;
+ pTTSettings->Act = NULL;
+ pTTSettings->aOriginalCaption.Erase();
+
+ // Translate
+ pTTSettings->pTranslateWin = NULL;
+ pTTSettings->bToTop = sal_True;
+ }
+
+ return pTTSettings;
+}
+
+
+
+
+// FIXME: HELPID
+#define IS_WINP_CLOSING(pWin) (pWin->GetHelpId().equals( "TT_Win_is_closing_HID" ) && pWin->GetUniqueId().equals( "TT_Win_is_closing_UID" ))
+
+/*
+UniString GEN_RES_STR0( sal_uLong nResId ) { return ResString( nResId ); }
+UniString GEN_RES_STR1( sal_uLong nResId, const UniString &Text1 ) { return GEN_RES_STR0( nResId ).Append( ArgString( 1, Text1 ) ); }
+UniString GEN_RES_STR2( sal_uLong nResId, const UniString &Text1, const UniString &Text2 ) { return GEN_RES_STR1( nResId, Text1 ).Append( ArgString( 2, Text2 ) ); }
+UniString GEN_RES_STR3( sal_uLong nResId, const UniString &Text1, const UniString &Text2, const UniString &Text3 ) { return GEN_RES_STR2( nResId, Text1, Text2 ).Append( ArgString( 3, Text3 ) );}
+*/
+StatementList::StatementList()
+: nRetryCount(MAX_RETRIES)
+, bStatementInQue(sal_False)
+{
+ if (!pRet)
+ pRet = new RetStream; // so Spät wie möglich, aber dennoch Zentral und auf jeden Fall rechtzeitig, da pRet private ist.
+}
+
+void StatementList::InitProfile()
+{
+ if ( pProfiler )
+ {
+ if ( pProfiler->IsProfilingPerCommand() || pProfiler->IsPartitioning() )
+ pProfiler->StartProfileInterval( pCurrentProfileStatement != this );
+
+#if OSL_DEBUG_LEVEL > 1
+ if ( pCurrentProfileStatement != NULL && pCurrentProfileStatement != this )
+ pRet->GenReturn( RET_ProfileInfo, 0, CUniString("InitProfile von anderem Statement gerufen ohne SendProfile\n") );
+#endif
+ pCurrentProfileStatement = this;
+ }
+}
+
+void StatementList::SendProfile( String aText )
+{
+ if ( pProfiler )
+ {
+ if ( pCurrentProfileStatement == this )
+ {
+ if ( pProfiler->IsProfilingPerCommand() || pProfiler->IsPartitioning() )
+ pProfiler->EndProfileInterval();
+
+ if ( pProfiler->IsProfilingPerCommand() )
+ pRet->GenReturn( RET_ProfileInfo, 0, pProfiler->GetProfileLine( aText ) );
+
+ if ( pProfiler->IsPartitioning() )
+ // FIXME: HELPID
+ pRet->GenReturn( RET_ProfileInfo, S_ProfileTime, static_cast<comm_ULONG>(pProfiler->GetPartitioningTime()) ); // GetPartitioningTime() sal_uLong != comm_ULONG on 64bit
+ }
+
+ if ( pProfiler->IsAutoProfiling() )
+ pRet->GenReturn( RET_ProfileInfo, 0, pProfiler->GetAutoProfiling() );
+
+#if OSL_DEBUG_LEVEL > 1
+ if ( pCurrentProfileStatement == NULL )
+ pRet->GenReturn( RET_ProfileInfo, 0, CUniString("SendProfile ohne InitProfile\n") );
+#endif
+ pCurrentProfileStatement = NULL;
+ }
+}
+
+void StatementList::QueStatement(StatementList *pAfterThis)
+{
+ DBG_ASSERT(!bStatementInQue,"QueStatement für bereits eingetragenes Statement -> Abgebrochen");
+ if ( bStatementInQue )
+ return;
+
+ bStatementInQue = sal_True;
+ if ( pAfterThis )
+ {
+ if ( pAfterThis->bStatementInQue )
+ {
+ pNext = pAfterThis->pNext;
+ pAfterThis->pNext = this;
+ }
+ else
+ { // pAfterThis not in que -> already dequed -> add to front of list
+ pNext = pFirst;
+ pFirst = this;
+ }
+ }
+ else // am Ende einfügen
+ {
+ pNext = NULL;
+ if( !pFirst )
+ pFirst = this;
+ else
+ {
+ StatementList *pList;
+ pList = pFirst;
+ while( pList->pNext )
+ pList = pList->pNext;
+ pList->pNext = this;
+ }
+ }
+}
+
+void StatementList::Advance()
+{ // pFirst ist static!
+ pFirst = pNext;
+ bStatementInQue = sal_False;
+ pNext = NULL;
+}
+
+
+StatementList::~StatementList()
+{
+#if OSL_DEBUG_LEVEL > 1
+ m_pDbgWin->AddText( "Deleting \n" );
+#endif
+ DBG_ASSERT(!bReadingCommands,"Deleting commands while reading them!");
+}
+
+Window* StatementList::GetDocWin( sal_uInt16 nNr )
+{
+ Window* pBase = Application::GetFirstTopLevelWindow();
+
+ while ( pBase )
+ {
+ if ( IsDocWin( pBase ) )
+ {
+ if ( !nNr )
+ return pBase;
+ nNr--;
+ }
+ pBase = Application::GetNextTopLevelWindow( pBase );
+ }
+ return NULL;
+}
+
+sal_uInt16 StatementList::GetDocFrameCount()
+{
+ Window* pBase = Application::GetFirstTopLevelWindow();
+ sal_uInt16 nCount = 0;
+
+ while ( pBase )
+ {
+ if ( IsDocFrame( pBase ) )
+ nCount++;
+ pBase = Application::GetNextTopLevelWindow( pBase );
+ }
+ return nCount;
+}
+
+sal_uInt16 StatementList::GetDocWinCount()
+{
+ Window* pBase = Application::GetFirstTopLevelWindow();
+ sal_uInt16 nCount = 0;
+
+ while ( pBase )
+ {
+ if ( IsDocWin( pBase ) )
+ nCount++;
+ pBase = Application::GetNextTopLevelWindow( pBase );
+ }
+ return nCount;
+}
+
+Window* StatementList::SearchAllWin( Window *pBase, Search &aSearch, sal_Bool MaybeBase )
+{
+
+ if ( !pBase && !aSearch.HasSearchFlag( SEARCH_NO_TOPLEVEL_WIN ) )
+ {
+ sal_Bool bSearchFocusFirst = aSearch.HasSearchFlag( SEARCH_FOCUS_FIRST );
+
+ Window *pControl = NULL;
+ if ( bSearchFocusFirst )
+ {
+ // first test Parent of Focus Window
+ pBase = Application::GetFocusWindow();
+ if ( pBase )
+ {
+ DBG_ASSERT( WinPtrValid( pBase ), "GetFocusWindow is no valid WindowPointer" );
+ Window *pPParent = pBase;
+ while ( pPParent->GET_REAL_PARENT() )
+ pPParent = pPParent->GET_REAL_PARENT();
+
+// if ( !IsFirstDocFrame( pPParent ) )
+// {
+ // get overlap window. Will be dialog else document itself
+ pBase = pBase->GetWindow( WINDOW_OVERLAP );
+
+ // set flag to find disabled elements.
+ // This is better than an enabled one on another Window
+ aSearch.AddSearchFlags( SEARCH_FIND_DISABLED );
+
+ // search on current Dialog first
+ pControl = SearchAllWin( pBase, aSearch );
+
+ // search on current Document
+ if ( !pControl && pBase != pPParent )
+ pControl = SearchAllWin( pPParent, aSearch );
+
+ aSearch.RemoveSearchFlags( SEARCH_FIND_DISABLED );
+
+ if ( pControl )
+ return pControl;
+// }
+ }
+ }
+
+ pBase = Application::GetFirstTopLevelWindow();
+
+ // Skip FirstDocFrame
+// if ( bSearchFocusFirst && IsFirstDocFrame( pBase ) )
+// pBase = Application::GetNextTopLevelWindow( pBase );
+
+ while ( pBase )
+ {
+ pControl = SearchAllWin( pBase, aSearch );
+ if ( pControl )
+ return pControl;
+
+ pBase = Application::GetNextTopLevelWindow( pBase );
+ // Skip FirstDocFrame
+// if ( bSearchFocusFirst && IsFirstDocFrame( pBase ) )
+// pBase = Application::GetNextTopLevelWindow( pBase );
+ }
+ return NULL;
+ }
+
+
+ Window *pResult = NULL;
+ pResult = SearchClientWin( pBase, aSearch, MaybeBase );
+ if ( pResult )
+ return pResult;
+
+// if ( pBase->GetType() != WINDOW_BORDERWINDOW )
+// return NULL;
+
+ if ( !aSearch.HasSearchFlag( SEARCH_NOOVERLAP ) )
+ {
+ if ( pBase->GetWindow( WINDOW_FIRSTOVERLAP ) )
+ pResult = SearchAllWin( pBase->GetWindow( WINDOW_FIRSTOVERLAP ), aSearch );
+
+ if ( !pResult && pBase->GetWindow( WINDOW_NEXT ) )
+ pResult = SearchAllWin( pBase->GetWindow( WINDOW_NEXT ), aSearch );
+ }
+
+ return pResult;
+}
+
+
+Window* StatementList::SearchClientWin( Window *pBase, Search &aSearch, sal_Bool MaybeBase )
+{
+ if ( !pBase )
+ return NULL;
+
+ if ( MaybeBase && aSearch.IsWinOK( pBase ) )
+ return pBase;
+
+ Window *pResult = NULL;
+
+ sal_uInt16 i;
+ for( i = 0 ; i < pBase->GetChildCount() && !pResult; i++ )
+ pResult = SearchClientWin( pBase->GetChild(i), aSearch );
+
+ return pResult;
+}
+
+
+sal_Bool SearchUID::IsWinOK( Window *pWin )
+{
+ if ( aUId.equals( pWin->GetUniqueOrHelpId() ) )
+ {
+ if ( ( pWin->IsEnabled() || HasSearchFlag( SEARCH_FIND_DISABLED ) ) && pWin->IsVisible() )
+ return sal_True;
+ else
+ {
+ if ( !pMaybeResult )
+ pMaybeResult = pWin;
+ return sal_False;
+ }
+ }
+ else if ( pWin->GetType() == WINDOW_TOOLBOX ) // Buttons and Controls on ToolBox.
+ {
+ ToolBox *pTB = ((ToolBox*)pWin);
+ sal_uInt16 i;
+ for ( i = 0; i < pTB->GetItemCount() ; i++ )
+ {
+ if ( aUId.equals( Str2Id( pTB->GetItemCommand(pTB->GetItemId( i )) ) ) || aUId.equals( pTB->GetHelpId(pTB->GetItemId( i )) ) )
+ { // ID matches.
+ Window *pItemWin;
+ pItemWin = pTB->GetItemWindow( pTB->GetItemId( i ) );
+
+ if ( bSearchButtonOnToolbox && pTB->GetItemType( i ) == TOOLBOXITEM_BUTTON && !pItemWin )
+ { // We got a Control, see if its valid also.
+ // Same as above.
+ if ( ( pTB->IsEnabled() || HasSearchFlag( SEARCH_FIND_DISABLED ) ) && pTB->IsVisible() )
+ { // We got a Button, see if its valid also.
+ if ( ( pTB->IsItemEnabled(pTB->GetItemId(i)) || HasSearchFlag( SEARCH_FIND_DISABLED ) )
+ && pTB->IsItemVisible(pTB->GetItemId(i)) )
+ return sal_True; // We got a Button.
+ else
+ { // better a disabled Button on a valid ToolBox than an invalid ToolBox as below
+ pMaybeResult = pTB;
+ return sal_False;
+ }
+ }
+ else if ( !pMaybeResult )
+ { // invalid ToolBox
+ pMaybeResult = pTB;
+ return sal_False;
+ }
+ }
+ if ( pItemWin )
+ { // We got a Control, see if its valid also.
+ // Same as above.
+ if ( ( pItemWin->IsEnabled() || HasSearchFlag( SEARCH_FIND_DISABLED ) ) && pItemWin->IsVisible() )
+ {
+ if ( !pAlternateResult ) // only take the first found ItemWindow #i35365
+ pAlternateResult = pItemWin; // since we cannot return a Window here
+ return sal_False; // continue searching to prefer a window with the right ID #i32292
+ }
+ else if ( !pMaybeResult )
+ {
+ pMaybeResult = pItemWin;
+ return sal_False;
+ }
+ }
+ }
+ }
+ return sal_False;
+ }
+ else
+ return sal_False;
+}
+
+Window* StatementList::SearchTree( rtl::OString aUId ,sal_Bool bSearchButtonOnToolbox )
+{
+ SearchUID aSearch(aUId,bSearchButtonOnToolbox);
+
+ Window *pResult = SearchAllWin( NULL, aSearch );
+ if ( pResult )
+ return pResult;
+ else if ( aSearch.GetAlternateResultWin() )
+ return aSearch.GetAlternateResultWin();
+ else
+ return aSearch.GetMaybeWin();
+}
+
+
+sal_Bool SearchWinPtr::IsWinOK( Window *pWin )
+{
+ return pWin == pTest;
+}
+
+sal_Bool StatementList::WinPtrValid(Window *pTest)
+{
+ SearchWinPtr aSearch( pTest );
+ return SearchAllWin( NULL, aSearch ) != NULL;
+}
+
+
+sal_Bool SearchRT::IsWinOK( Window *pWin )
+{
+ if ( pWin->IsVisible() && pWin->GetType() == mnRT )
+ {
+ mnCount++;
+ if ( mnSkip )
+ {
+ mnSkip--;
+ return sal_False;
+ }
+ else
+ return sal_True;
+ }
+ return sal_False;
+}
+
+Window* StatementList::GetWinByRT( Window *pBase, WindowType nRT, sal_Bool MaybeBase, sal_uInt16 nSkip, sal_Bool bSearchAll )
+{
+ SearchRT aSearch( nRT, 0, nSkip );
+ if ( bSearchAll )
+ aSearch.AddSearchFlags( SEARCH_FOCUS_FIRST | SEARCH_FIND_DISABLED );
+ else
+ aSearch.AddSearchFlags( SEARCH_NOOVERLAP | SEARCH_NO_TOPLEVEL_WIN );
+
+ return SearchAllWin( pBase, aSearch, MaybeBase );
+}
+
+sal_uInt16 StatementList::CountWinByRT( Window *pBase, WindowType nRT, sal_Bool MaybeBase )
+{
+ SearchRT aSearch( nRT, SEARCH_NOOVERLAP | SEARCH_NO_TOPLEVEL_WIN, 0xFFFF );
+
+ SearchAllWin( pBase, aSearch, MaybeBase );
+ return aSearch.GetCount();
+}
+
+sal_Bool SearchScroll::IsWinOK( Window *pWin )
+{
+ if ( SearchRT::IsWinOK( pWin ) )
+ {
+ DBG_ASSERT( pWin->GetStyle() & ( WB_HORZ | WB_VERT ), "Nither WB_HORZ nor WB_VERT set on ScrollBar");
+ return (( pWin->GetStyle() & WB_HORZ ) && ( nDirection == CONST_ALIGN_BOTTOM ))
+ || (( pWin->GetStyle() & WB_VERT ) && ( nDirection == CONST_ALIGN_RIGHT ));
+ }
+ return sal_False;
+}
+
+ScrollBar* StatementList::GetScrollBar( Window *pBase, sal_uInt16 nDirection, sal_Bool MaybeBase )
+{
+ SearchScroll aSearch( nDirection, SEARCH_NOOVERLAP | SEARCH_NO_TOPLEVEL_WIN );
+
+ return (ScrollBar*)SearchAllWin( pBase, aSearch, MaybeBase );
+}
+
+
+sal_Bool SearchPopupFloatingWin::IsWinOK( Window *pWin )
+{
+ return pWin->IsVisible() && pWin->GetType() == WINDOW_FLOATINGWINDOW && ((FloatingWindow*)pWin)->IsInPopupMode();
+}
+
+Window* StatementList::GetPopupFloatingWin( sal_Bool MaybeBase )
+{
+ SearchPopupFloatingWin aSearch;
+
+ return SearchAllWin( NULL, aSearch, MaybeBase );
+}
+
+
+Menu* StatementList::GetMatchingMenu( Window* pWin, Menu* pBaseMenu )
+{
+ if ( pBaseMenu )
+ {
+ if ( pBaseMenu->GetWindow() == pWin )
+ return pBaseMenu;
+
+ sal_uInt16 i;
+// while ( pBaseMenu )
+// {
+ i = 0;
+ while ( i < pBaseMenu->GetItemCount() )
+ {
+ PopupMenu* pPopup = pBaseMenu->GetPopupMenu( pBaseMenu->GetItemId( i ) );
+ if ( pPopup && pPopup->GetWindow() )
+ {
+ if ( pPopup->GetWindow() == pWin )
+ return pPopup;
+ else
+ {
+ pBaseMenu = pPopup;
+ i = 0;
+ }
+ }
+ else
+ i++;
+ }
+// }
+ }
+ else
+ {
+ if ( PopupMenu::GetActivePopupMenu() )
+ {
+ Menu* pMenu = GetMatchingMenu( pWin, PopupMenu::GetActivePopupMenu() );
+ if ( pMenu )
+ return pMenu;
+ }
+
+ sal_uInt16 nSkip = 0;
+ Window* pMenuBarWin = NULL;
+ while ( (pMenuBarWin = GetWinByRT( NULL, WINDOW_MENUBARWINDOW, sal_True, nSkip++, sal_True )) != NULL )
+ {
+ Window* pParent = pMenuBarWin->GET_REAL_PARENT();
+ if ( pParent && pParent->GetType() == WINDOW_BORDERWINDOW && pParent->IsVisible() )
+ {
+ Menu* pMenu = NULL;
+ // find Menu of MenuBarWindow
+ sal_uInt16 nCount;
+ for ( nCount = 0 ; nCount < pParent->GetChildCount() ; nCount++ )
+ {
+ if ( pParent->GetChild( nCount )->GetType() == WINDOW_WORKWINDOW )
+ pMenu = ((WorkWindow*)(pParent->GetChild( nCount )))->GetMenuBar();
+ }
+ if ( pMenu )
+ {
+ // check for menu bar in Task Window
+ if ( pMenuBarWin == pWin )
+ return pMenu;
+
+ // search submenues
+ pMenu = GetMatchingMenu( pWin, pMenu );
+ if ( pMenu )
+ return pMenu;
+ }
+ }
+ }
+ }
+ return NULL;
+}
+
+
+sal_Bool SearchActive::IsWinOK( Window *pWin )
+{
+// return pWin->IsVisible() && ( (nRT == WINDOW_ANYTYPE && IsDialog(pWin) ) || pWin->GetType() == nRT ) && (nRT == WINDOW_FILEDIALOG || nRT == WINDOW_PATHDIALOG || nRT == WINDOW_PRINTDIALOG || nRT == WINDOW_PRINTERSETUPDIALOG || nRT == WINDOW_COLORDIALOG || ((SystemWindow*)pWin)->IsActive());
+ // only matches ResID due to problems with UNIX Window Managers
+ return pWin->IsVisible() && ( (nRT == WINDOW_ANYTYPE && IsDialog(pWin) ) || pWin->GetType() == nRT );
+}
+
+Window* StatementList::GetActive( WindowType nRT, sal_Bool MaybeBase )
+{
+ SearchActive aSearch( nRT );
+
+ return SearchAllWin( NULL, aSearch, MaybeBase );
+}
+
+sal_Bool SearchFadeSplitWin::IsWinOK( Window *pWin )
+{
+#if OSL_DEBUG_LEVEL > 1
+ if ( pWin->GetType() == WINDOW_SPLITWINDOW )
+ {
+ sal_Bool bResult;
+ WindowAlign aAlign;
+ bResult = pWin->IsVisible();
+ bResult = ((SplitWindow*)pWin)->IsFadeInButtonVisible();
+ bResult = ((SplitWindow*)pWin)->IsFadeOutButtonVisible();
+ bResult = ((SplitWindow*)pWin)->IsAutoHideButtonVisible();
+ aAlign = ((SplitWindow*)pWin)->GetAlign();
+ }
+#endif
+ return pWin->IsVisible() && ( pWin->GetType() == WINDOW_SPLITWINDOW )
+ && (((SplitWindow*)pWin)->IsFadeInButtonVisible() || ((SplitWindow*)pWin)->IsFadeOutButtonVisible() )
+ /*&& ((SplitWindow*)pWin)->IsAutoHideButtonVisible()*/ && ((SplitWindow*)pWin)->GetAlign() == nAlign;
+}
+
+Window* StatementList::GetFadeSplitWin( Window *pBase, WindowAlign nAlign, sal_Bool MaybeBase )
+{
+ SearchFadeSplitWin aSearch( nAlign );
+
+ if ( GetpApp()->GetAppWindow() == pBase && pBase->GetType() != WINDOW_BORDERWINDOW )
+ pBase = pBase->GetWindow( WINDOW_OVERLAP );
+
+ return SearchAllWin( pBase, aSearch, MaybeBase );
+}
+
+Window* StatementList::GetMouseWin()
+{
+ Window *pBase = Application::GetFirstTopLevelWindow();
+ Window *pControl = NULL;
+ while ( pBase )
+ {
+ Window *pBaseFrame = pBase->GetWindow( WINDOW_OVERLAP );
+
+ Point aP = pBaseFrame->GetPointerPosPixel();
+ pControl = pBaseFrame->FindWindow( aP );
+ if ( pControl )
+ return pControl;
+
+ pBase = Application::GetNextTopLevelWindow( pBase );
+ }
+ return NULL;
+}
+
+Window* StatementList::GetFocus( WindowType nRT, sal_Bool MaybeBase )
+{
+
+ if ( nRT == WINDOW_TABCONTROL )
+ {
+ Window *pResult = GetActive( WINDOW_TABDIALOG, MaybeBase);
+ for( sal_uInt16 i = 0 ; pResult && i < pResult->GetChildCount(); i++ )
+ if ( pResult->GetChild(i)->GetType() == nRT )
+ return pResult->GetChild(i);
+ }
+
+ return NULL;
+}
+
+Window* StatementList::GetAnyActive( sal_Bool MaybeBase )
+{
+ Window *pControl;
+
+ pControl = GetActive( WINDOW_MESSBOX, MaybeBase);
+ if ( !pControl )
+ {
+ pControl = GetActive( WINDOW_INFOBOX, MaybeBase);
+ }
+ if ( !pControl )
+ {
+ pControl = GetActive( WINDOW_WARNINGBOX, MaybeBase);
+ }
+ if ( !pControl )
+ {
+ pControl = GetActive( WINDOW_ERRORBOX, MaybeBase);
+ }
+ if ( !pControl )
+ {
+ pControl = GetActive( WINDOW_QUERYBOX, MaybeBase);
+ }
+ if ( !pControl )
+ {
+ pControl = GetActive( WINDOW_BUTTONDIALOG, MaybeBase);
+ }
+ if ( !pControl )
+ {
+ pControl = GetActive( WINDOW_FILEDIALOG, MaybeBase);
+ }
+ if ( !pControl )
+ {
+ pControl = GetActive( WINDOW_PATHDIALOG, MaybeBase);
+ }
+ if ( !pControl )
+ {
+ pControl = GetActive( WINDOW_PRINTDIALOG, MaybeBase);
+ }
+ if ( !pControl )
+ {
+ pControl = GetActive( WINDOW_PRINTERSETUPDIALOG, MaybeBase);
+ }
+ if ( !pControl )
+ {
+ pControl = GetActive( WINDOW_COLORDIALOG, MaybeBase);
+ }
+ if ( !pControl )
+ {
+ pControl = GetFocus( WINDOW_TABCONTROL, MaybeBase);
+ }
+
+ return pControl;
+}
+
+void StatementList::SetFirstDocFrame( Window* pWin )
+{
+ DBG_ASSERT( IsDocFrame( pWin ), "Non Document Frame set as first Document Frame" );
+ pFirstDocFrame = pWin;
+}
+
+Window* StatementList::GetFirstDocFrame()
+{
+
+ if ( pFirstDocFrame && !WinPtrValid( pFirstDocFrame ) )
+ pFirstDocFrame = NULL;
+ if ( pFirstDocFrame && !pFirstDocFrame->IsVisible() )
+ pFirstDocFrame = NULL;
+ if ( pFirstDocFrame && !IsDocFrame( pFirstDocFrame ) )
+ pFirstDocFrame = NULL;
+ if ( !pFirstDocFrame )
+ {
+ Window* pBase = Application::GetFirstTopLevelWindow();
+ while ( pBase && !IsDocFrame( pBase ) )
+ pBase = Application::GetNextTopLevelWindow( pBase );
+
+ if ( pBase )
+ SetFirstDocFrame( pBase );
+
+ if ( !pBase ) // find just something
+ {
+ pBase = Application::GetFirstTopLevelWindow();
+ while ( pBase && !pBase->IsVisible() )
+ pBase = Application::GetNextTopLevelWindow( pBase );
+
+ return pBase; // just for now, later we will hopefully have a Window
+ }
+ }
+ return pFirstDocFrame;
+}
+
+sal_Bool StatementList::IsFirstDocFrame( Window* pWin )
+{
+ return pWin && ( pWin == GetFirstDocFrame() || ( GetFirstDocFrame() && pWin == GetFirstDocFrame()->GetWindow( WINDOW_CLIENT ) ) ) && ( GetFirstDocFrame() && IsDocFrame( GetFirstDocFrame() ) );
+}
+
+MenuBar* StatementList::GetDocFrameMenuBar( Window* pWin )
+{
+ if ( pWin && pWin->IsVisible() && pWin->GetType() == WINDOW_BORDERWINDOW )
+ {
+ sal_uInt16 nCount;
+ for ( nCount = 0 ; nCount < pWin->GetChildCount() ; nCount++ )
+ {
+ if ( pWin->GetChild( nCount )->GetType() == WINDOW_WORKWINDOW )
+ return ((WorkWindow*)(pWin->GetChild( nCount )))->GetMenuBar();
+ }
+ }
+ return NULL;
+}
+
+// a Doc Frame is a Document or the Backing Window
+sal_Bool StatementList::IsDocFrame( Window* pWin )
+{
+ if ( pWin && pWin->IsVisible() && pWin->GetType() == WINDOW_BORDERWINDOW )
+ {
+ sal_uInt16 nCount;
+ sal_Bool bHasWorkWindow = sal_False;
+ sal_Bool bHasMenuBar = sal_False;
+ // #91724# it is now necessary to sort out the IME WIndow in Solaris as well.
+ // so now we check for existence of WINDOW_WORKWINDOW and newly for
+ // WINDOW_MENUBARWINDOW which contains the Menu and the close/min/max buttons
+ for ( nCount = 0 ; nCount < pWin->GetChildCount() ; nCount++ )
+ {
+ if ( pWin->GetChild( nCount )->GetType() == WINDOW_WORKWINDOW )
+ bHasWorkWindow = sal_True;
+ if ( pWin->GetChild( nCount )->GetType() == WINDOW_MENUBARWINDOW )
+ bHasMenuBar = sal_True;
+ }
+ return bHasWorkWindow && bHasMenuBar;
+ }
+ return sal_False;
+}
+
+// a Doc Win is a real document (not the Backing Window)
+sal_Bool StatementList::IsDocWin( Window* pWin )
+{
+ if ( pWin && IsDocFrame( pWin ) )
+ {
+ if ( GetDocFrameCount() != 1 )
+ return sal_True;
+ else
+ {
+ // check for the close button to see if we are the last one or only the backing Window
+ if ( GetDocFrameMenuBar( pWin ) )
+ return GetDocFrameMenuBar( pWin )->HasCloser();
+ }
+ }
+ return sal_False;
+}
+
+sal_Bool StatementList::IsIMEWin( Window* pWin ) // Input Window for CJK under Solaris
+{
+ if ( pWin && pWin->IsVisible() && pWin->GetType() == WINDOW_BORDERWINDOW )
+ {
+ sal_uInt16 nCount;
+ sal_Bool bHasWorkWindow = sal_False;
+ sal_Bool bHasWindow = sal_False;
+ // #91724# it is now necessary to sort out the IME WIndow in Solaris as well.
+ // so now we check for existence of WINDOW_WORKWINDOW and newly for
+ // WINDOW_WINDOW which contains the Menu and the close/min/max buttons
+ for ( nCount = 0 ; nCount < pWin->GetChildCount() ; nCount++ )
+ if ( pWin->GetChild( nCount )->GetType() == WINDOW_WORKWINDOW )
+ bHasWorkWindow = sal_True;
+ for ( nCount = 0 ; nCount < pWin->GetChildCount() ; nCount++ )
+ if ( pWin->GetChild( nCount )->GetType() == WINDOW_WINDOW )
+ bHasWindow = sal_True;
+ return bHasWorkWindow && !bHasWindow;
+ }
+ return sal_False;
+}
+
+UniString StatementList::Tree(Window *pBase, int Indent)
+{
+
+ String aReturn, aSep;
+ if ( !pBase )
+ {
+ aSep.AssignAscii("============================\n");
+ aSep.ConvertLineEnd();
+ pBase = Application::GetFirstTopLevelWindow();
+ while ( pBase )
+ {
+ Window *pBaseFrame = pBase->GetWindow( WINDOW_OVERLAP );
+
+ aReturn += aSep;
+ aReturn += Tree( pBaseFrame, Indent+1 );
+
+ pBase = Application::GetNextTopLevelWindow( pBase );
+ }
+ return aReturn;
+ }
+
+
+ aSep.AssignAscii("----------------------------\n");
+ aSep.ConvertLineEnd();
+
+ aReturn += ClientTree( pBase, Indent );
+
+ if ( pBase->GetWindow( WINDOW_FIRSTOVERLAP ) )
+ {
+ aReturn += aSep;
+ aReturn += Tree( pBase->GetWindow( WINDOW_FIRSTOVERLAP ), Indent+1 );
+ }
+
+ if ( pBase->GetWindow( WINDOW_NEXT ) )
+ {
+ aReturn += aSep;
+ aReturn += Tree( pBase->GetWindow( WINDOW_NEXT ), Indent );
+ }
+
+ return aReturn;
+}
+
+String StatementList::ClientTree(Window *pBase, int Indent)
+{
+#if OSL_DEBUG_LEVEL > 1
+#define WRITE(Text) { m_pDbgWin->AddText(Text); aReturn += Text; }
+#define WRITEc(Text) { m_pDbgWin->AddText(Text); aReturn.AppendAscii(Text); }
+#else
+#define WRITE(Text) { aReturn += Text; }
+#define WRITEc(Text) { aReturn.AppendAscii(Text); }
+#endif
+
+ String sIndent,aText,aReturn;
+ sIndent.Expand(sal::static_int_cast< xub_StrLen >(2*Indent));
+
+ aText = pBase->GetText();
+
+
+ UniString t1,t2;t1 = CUniString("\n"); t2 = CUniString("\\n");
+ aText.SearchAndReplaceAll(t1,t2 );
+
+ WRITE(sIndent);
+
+ if (pBase->IsDialog())
+ {
+ WRITEc("*(Dialog(TH))");
+ }
+ if (IsDialog( pBase ))
+ {
+ WRITEc("*(Dialog(GH))");
+ }
+ if (pBase->HasFocus())
+ {
+ WRITEc("*(Focus)");
+ }
+ if (!pBase->IsEnabled())
+ {
+ WRITEc("*(Disab)");
+ }
+ if (pBase->IsVisible())
+ {
+ WRITEc("*(Visible)");
+ }
+ if ( IsDialog(pBase) && ((SystemWindow*)pBase)->IsActive() )
+ {
+ WRITEc("*(Active)");
+ }
+ if ( pBase->GetStyle() & WB_CLOSEABLE )
+ {
+ WRITEc("*(Closable)");
+ }
+ if ( pBase->GetType() == WINDOW_DOCKINGWINDOW &&
+ ((((DockingWindow*)pBase)->GetFloatStyle()) & WB_CLOSEABLE) )
+ {
+ WRITEc("*(Closable Docking in Floatingstyle)");
+ }
+ if ( pBase->GetStyle() & WB_DOCKABLE )
+ {
+ WRITEc("*(Dockable)");
+ }
+ if ( pBase->GetType() == WINDOW_SPLITWINDOW &&
+ (((SplitWindow*)pBase)->IsFadeInButtonVisible() || ((SplitWindow*)pBase)->IsFadeOutButtonVisible()) )
+ {
+ WRITEc("*(FadeIn/Out)");
+ }
+ WRITEc("Text: ");
+ WRITE(aText);
+ WRITEc("\n");
+
+ WRITE(sIndent);
+ WRITEc("UId : ");
+ WRITE(Id2Str(pBase->GetUniqueOrHelpId()));
+ WRITEc(":0x");
+ WRITE(
+ String::CreateFromInt64(
+ sal::static_int_cast< sal_Int64 >(
+ reinterpret_cast< sal_IntPtr >(pBase)),
+ 16 ));
+ WRITEc(":");
+ WRITE(pBase->GetQuickHelpText());
+ WRITEc(":");
+ WRITE(pBase->GetHelpText());
+ WRITEc("\n");
+
+ WRITE(sIndent);
+ WRITEc("RTyp: ");
+ WRITE(MakeStringNumber(TypeKenn,pBase->GetType()));
+ if ( pBase->GetType() == WINDOW_CONTROL )
+ {
+ if ( dynamic_cast< svt::EditBrowseBox* >(pBase) )
+ WRITEc("/BrowseBox")
+ else if ( dynamic_cast< ValueSet* >(pBase) )
+ WRITEc("/ValueSet")
+ else if ( dynamic_cast< svt::ORoadmap* >(pBase) )
+ WRITEc("/RoadMap")
+ else if ( dynamic_cast< svt::IExtensionListBox* >(pBase) )
+ WRITEc("/ExtensionListBox")
+ else if ( dynamic_cast< svt::table::TableControl* >(pBase) )
+ WRITEc("/TableControl")
+ else
+ WRITEc("/Unknown")
+ }
+ WRITEc("\n");
+
+ aReturn.ConvertLineEnd();
+ sal_uInt16 i;
+ for (i = 0 ; i < pBase->GetChildCount() ; i++)
+ {
+ aReturn += ClientTree(pBase->GetChild(i),Indent+1);
+ }
+ return aReturn;
+}
+
+
+sal_Bool StatementList::CheckWindowWait()
+{
+ static Time StartTime = Time(0L); // Abbruch wenn Fenster absolut nicht schliesst.
+ if ( StartTime == Time(0L) )
+ StartTime = Time();
+
+ if ( pWindowWaitPointer )
+ {
+#if OSL_DEBUG_LEVEL > 1
+ m_pDbgWin->AddText( "Waiting for Window to close ... " );
+#endif
+ if ( WinPtrValid(pWindowWaitPointer) && IS_WINP_CLOSING(pWindowWaitPointer) )
+ {
+#if OSL_DEBUG_LEVEL > 1
+ m_pDbgWin->AddText( Id2Str(aWindowWaitUId).AppendAscii(" Still Open. RType=") );
+ m_pDbgWin->AddText( String::CreateFromInt32( pWindowWaitPointer->GetType() ).AppendAscii("\n") );
+#endif
+
+ // Ist die Zeit schonn abgelaufen?
+ if ( StartTime + Time(0,0,10) < Time() ) // 10 Sekunden reichen wohl
+ {
+#if OSL_DEBUG_LEVEL > 1
+ m_pDbgWin->AddText( "Close timed out. Going on!! " );
+#endif
+ pWindowWaitPointer->SetHelpId(aWindowWaitOldHelpId);
+ pWindowWaitPointer->SetUniqueId(aWindowWaitOldUniqueId);
+
+ aWindowWaitUId = rtl::OString();
+ pWindowWaitPointer = NULL;
+ StartTime = Time(0L);
+ return sal_True;
+ }
+
+ return sal_False;
+ }
+ pWindowWaitPointer = NULL;
+ aWindowWaitUId = rtl::OString();
+#if OSL_DEBUG_LEVEL > 1
+ m_pDbgWin->AddText( "Closed, Going on.\n" );
+#endif
+ }
+ StartTime = Time(0L);
+ return sal_True;
+}
+
+void StatementList::ReportError(String aMessage)
+{
+ ReportError ( rtl::OString(), aMessage );
+}
+
+void StatementList::ReportError(rtl::OString aUId, String aMessage)
+{
+ pRet->GenError ( aUId, aMessage );
+ IsError = sal_True;
+}
+
+void StatementList::ReportError(String aMessage, sal_uLong nWhatever)
+{
+ ReportError ( aMessage.AppendAscii(" ").Append(UniString::CreateFromInt32(nWhatever)));
+}
+
+void StatementList::DirectLog( sal_uLong nType, String aMessage )
+{
+ if ( pRet )
+ pRet->GenReturn( RET_DirectLoging, (sal_uInt16) nType, aMessage );
+}
+
+
+#define CALL_EVENT_WITH_NOTIFY( EventType, Event, WinP, Method ) \
+{ \
+ if ( StatementList::WinPtrValid( WinP ) ) \
+ { \
+ NotifyEvent aNEvt( EventType, WinP, &Event ); \
+ if ( !WinP->PreNotify( aNEvt ) ) \
+ WinP->Method( Event ); \
+ } \
+}
+
+void ImplKeyInput( Window* pWin, KeyEvent &aKEvnt, sal_Bool bForceDirect )
+{
+
+ if ( StatementList::bUsePostEvents && !bForceDirect )
+ {
+ if ( StatementList::WinPtrValid( pWin ) )
+ {
+ sal_uLong nID1;
+ sal_uLong nID2;
+ nID1 = Application::PostKeyEvent( VCLEVENT_WINDOW_KEYINPUT, pWin, &aKEvnt );
+ nID2 = Application::PostKeyEvent( VCLEVENT_WINDOW_KEYUP, pWin, &aKEvnt );
+ // wait after posting both events so deleting pWin will remove the second event also
+ ImplEventWait( nID1 );
+ ImplEventWait( nID2 );
+ }
+ }
+ else
+ {
+ if ( !Application::CallAccel( aKEvnt.GetKeyCode() ) )
+ {
+ CALL_EVENT_WITH_NOTIFY( EVENT_KEYINPUT, aKEvnt, pWin, KeyInput )
+
+ KeyCode aCode = aKEvnt.GetKeyCode();
+ if ( (aCode.GetCode() == KEY_CONTEXTMENU) || ((aCode.GetCode() == KEY_F10) && aCode.IsShift()) )
+ {
+ if ( StatementList::WinPtrValid( pWin ) )
+ {
+ Point aPos;
+ // simulate mouseposition at center of window
+ Size aSize = pWin->GetOutputSize();
+ aPos = Point( aSize.getWidth()/2, aSize.getHeight()/2 );
+
+ CommandEvent aEvent( aPos, COMMAND_CONTEXTMENU, sal_False );
+ ImplCommand( pWin, aEvent );
+ }
+ }
+ }
+
+ CALL_EVENT_WITH_NOTIFY( EVENT_KEYUP, aKEvnt, pWin, KeyUp )
+ }
+};
+
+void ImplMouseMove( Window* pWin, MouseEvent &aMEvnt, sal_Bool bForceDirect )
+{
+ if ( StatementList::bUsePostEvents && !bForceDirect )
+ {
+ if ( StatementList::WinPtrValid( pWin ) )
+ {
+ sal_uLong nID;
+ nID = Application::PostMouseEvent( VCLEVENT_WINDOW_MOUSEMOVE, pWin, &aMEvnt );
+ ImplEventWait( nID );
+ }
+ }
+ else
+ {
+ // DragManager* pDragManager = DragManager::GetDragManager();
+ // if ( pDragManager )
+ // pDragManager->MouseMove( aMEvnt, pWin );
+ // else
+ if ( pWin->IsTracking() )
+ {
+ TrackingEvent aTEvt( aMEvnt );
+ pWin->Tracking( aTEvt );
+ }
+ else
+ CALL_EVENT_WITH_NOTIFY( EVENT_MOUSEMOVE, aMEvnt, pWin, MouseMove )
+ }
+};
+
+void ImplMouseButtonDown( Window* pWin, MouseEvent &aMEvnt, sal_Bool bForceDirect )
+{
+ if ( StatementList::bUsePostEvents && !bForceDirect )
+ {
+ if ( StatementList::WinPtrValid( pWin ) )
+ {
+ sal_uLong nID;
+ nID = Application::PostMouseEvent( VCLEVENT_WINDOW_MOUSEBUTTONDOWN, pWin, &aMEvnt );
+ ImplEventWait( nID );
+ }
+ }
+ else
+ {
+ CALL_EVENT_WITH_NOTIFY( EVENT_MOUSEBUTTONDOWN, aMEvnt, pWin, MouseButtonDown )
+ }
+};
+
+void ImplMouseButtonUp( Window* pWin, MouseEvent &aMEvnt, sal_Bool bForceDirect )
+{
+ if ( StatementList::bUsePostEvents && !bForceDirect )
+ {
+ if ( StatementList::WinPtrValid( pWin ) )
+ {
+ sal_uLong nID;
+ nID = Application::PostMouseEvent( VCLEVENT_WINDOW_MOUSEBUTTONUP, pWin, &aMEvnt );
+ ImplEventWait( nID );
+ }
+ }
+ else
+ {
+ // DragManager* pDragManager = DragManager::GetDragManager();
+ // if ( pDragManager )
+ // pDragManager->ButtonUp( aMEvnt, pWin );
+ // else
+ if ( pWin->IsTracking() )
+ {
+ // siehe #64693 die Position ist für Toolboxen relevant
+ // #60020 Jetzt hoffentlich kein GPF mehr
+ // Zuerst Tracking beenden ohne Event
+ pWin->EndTracking( ENDTRACK_DONTCALLHDL );
+ // dann eigenen Event mit richtigem Maus-Event senden
+ TrackingEvent aTEvt( aMEvnt, ENDTRACK_END );
+ pWin->Tracking( aTEvt );
+ }
+ else
+ CALL_EVENT_WITH_NOTIFY( EVENT_MOUSEBUTTONUP, aMEvnt, pWin, MouseButtonUp )
+ }
+};
+
+void ImplEventWait( sal_uLong nID )
+{
+ while ( !Application::IsProcessedMouseOrKeyEvent( nID ) )
+ Application::Yield();
+}
+
+void ImplCommand( Window* pWin, CommandEvent &aCmdEvnt )
+{
+ CALL_EVENT_WITH_NOTIFY( EVENT_COMMAND, aCmdEvnt, pWin, Command )
+};
+
diff --git a/automation/source/server/statemnt.cxx b/automation/source/server/statemnt.cxx
new file mode 100644
index 000000000000..8b7a57bb4a47
--- /dev/null
+++ b/automation/source/server/statemnt.cxx
@@ -0,0 +1,6710 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_automation.hxx"
+#include <com/sun/star/frame/XFramesSupplier.hpp>
+#include <com/sun/star/frame/XDispatch.hpp>
+#include <com/sun/star/frame/XDispatchProvider.hpp>
+#include <com/sun/star/util/XURLTransformer.hpp>
+#include <comphelper/processfactory.hxx>
+#include <comphelper/uieventslogger.hxx>
+
+#include <tools/wintypes.hxx>
+#ifndef _DIALOG_HXX //autogen
+#include <vcl/dialog.hxx>
+#endif
+#ifndef _BUTTON_HXX //autogen
+#include <vcl/button.hxx>
+#endif
+#include <vcl/menubtn.hxx>
+#include <svtools/svtreebx.hxx>
+#include <svtools/brwbox.hxx>
+#ifndef _MSGBOX_HXX //autogen
+#include <vcl/msgbox.hxx>
+#endif
+#ifndef _DOCKWIN_HXX //autogen
+#include <vcl/dockwin.hxx>
+#endif
+#ifndef _FLOATWIN_HXX //autogen
+#include <vcl/floatwin.hxx>
+#endif
+#ifndef _LSTBOX_HXX //autogen
+#include <vcl/lstbox.hxx>
+#endif
+#ifndef _COMBOBOX_HXX //autogen
+#include <vcl/combobox.hxx>
+#endif
+#ifndef _MOREBTN_HXX //autogen
+#include <vcl/morebtn.hxx>
+#endif
+#ifndef _FIELD_HXX //autogen
+#include <vcl/field.hxx>
+#endif
+#ifndef _TOOLBOX_HXX //autogen
+#include <vcl/toolbox.hxx>
+#endif
+#include <vcl/tabctrl.hxx>
+#include <vcl/tabpage.hxx>
+#include <vcl/menu.hxx>
+#include <vcl/status.hxx>
+#include <svtools/prgsbar.hxx>
+#include <svtools/editbrowsebox.hxx>
+#include <vcl/splitwin.hxx>
+#include <vcl/group.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/wrkwin.hxx>
+#include <osl/diagnose.h>
+#include <svtools/valueset.hxx>
+#include <svtools/roadmap.hxx>
+#include <svtools/table/tablecontrol.hxx>
+#include <svtools/table/tablecontrolinterface.hxx>
+#include <svl/poolitem.hxx>
+#include <svtools/extensionlistbox.hxx>
+// Hat keinen Includeschutz
+#include <svtools/svtdata.hxx>
+#include <tools/time.hxx>
+#include <svtools/stringtransfer.hxx>
+#include <tools/stream.hxx>
+#include <tools/fsys.hxx>
+#include <svl/stritem.hxx>
+#include <svtools/ttprops.hxx>
+#ifndef _BASIC_TTRESHLP_HXX
+#include <basic/ttstrhlp.hxx>
+#endif
+#include <basic/dispdefs.hxx>
+#include <basic/sbuno.hxx>
+#include <vos/socket.hxx>
+#include <svl/pickerhistory.hxx>
+#include <com/sun/star/util/XCancellable.hpp>
+
+#include <sot/storage.hxx>
+#include <sot/storinfo.hxx>
+#include "statemnt.hxx"
+#include "scmdstrm.hxx"
+
+#ifndef _RETSRTM_HXX
+#include "retstrm.hxx"
+#endif
+
+#if OSL_DEBUG_LEVEL > 1
+#include "editwin.hxx"
+#endif
+#include "rcontrol.hxx"
+#include <automation/communi.hxx>
+#include "testtool.hxx"
+
+#include "profiler.hxx"
+
+#include "recorder.hxx"
+
+#include "testtool.hrc"
+#include <basic/svtmsg.hrc>
+
+#include <algorithm>
+
+
+using namespace com::sun::star::frame;
+using namespace com::sun::star::uno;
+//using namespace com::sun::star::util; geht wegen Color nicht
+using namespace com::sun::star::beans;
+using namespace svt;
+//using namespace svt::table;
+
+
+#ifndef SBX_VALUE_DECL_DEFINED
+#define SBX_VALUE_DECL_DEFINED
+SV_DECL_REF(SbxValue)
+#endif
+SV_IMPL_REF(SbxValue)
+
+CommunicationLink *StatementFlow::pCommLink = NULL;
+sal_Bool StatementFlow::bUseIPC = sal_True;
+sal_Bool StatementFlow::bSending = sal_False;
+ImplRemoteControl *StatementFlow::pRemoteControl = NULL;
+
+sal_uInt16 StatementCommand::nDirPos = 0;
+Dir *StatementCommand::pDir = NULL;
+pfunc_osl_printDebugMessage StatementCommand::pOriginal_osl_DebugMessageFunc = NULL;
+
+
+#define RESET_APPLICATION_TO_BACKING_WINDOW
+
+
+#define SET_WINP_CLOSING(pWin) \
+ pWindowWaitPointer = pWin; \
+ aWindowWaitUId = pControl->GetUniqueOrHelpId(); \
+ aWindowWaitOldHelpId = pWin->GetHelpId(); \
+ aWindowWaitOldUniqueId = pWin->GetUniqueId(); \
+ pWin->SetHelpId( rtl::OString("TT_Win_is_closing_HID") ); \
+ pWin->SetUniqueId( rtl::OString("TT_Win_is_closing_UID") );
+
+// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+StatementFlow::StatementFlow( StatementList *pAfterThis, sal_uInt16 nArtP )
+: nArt(nArtP)
+, nParams(0)
+, nSNr1(0)
+, nLNr1(0)
+, aString1()
+, bBool1(sal_False)
+{
+ QueStatement( pAfterThis );
+}
+
+StatementFlow::StatementFlow( sal_uLong nServiceId, SCmdStream *pCmdIn, ImplRemoteControl *pRC )
+: nArt(0)
+, nParams(0)
+, nSNr1(0)
+, nLNr1(0)
+, aString1()
+, bBool1(sal_False)
+{
+ QueStatement( NULL );
+ bUseIPC = (nServiceId == SI_IPCCommandBlock);
+ pRemoteControl = pRC;
+ pCmdIn->Read( nArt );
+ pCmdIn->Read( nParams );
+
+ if( nParams & PARAM_USHORT_1 ) pCmdIn->Read( nSNr1 );
+ if( nParams & PARAM_ULONG_1 ) pCmdIn->Read( nLNr1 );
+ if( nParams & PARAM_STR_1 ) pCmdIn->Read( aString1 );
+ if( nParams & PARAM_BOOL_1 ) pCmdIn->Read( bBool1 ); // sollte nie auftreten!!
+
+#if OSL_DEBUG_LEVEL > 1
+ m_pDbgWin->AddText( "Reading FlowControl: " );
+ m_pDbgWin->AddText( String::CreateFromInt32( nArt ) );
+ m_pDbgWin->AddText( " Params:" );
+ if( nParams & PARAM_USHORT_1 ) {m_pDbgWin->AddText( " n1:" );m_pDbgWin->AddText( String::CreateFromInt32( nSNr1 ) );}
+ if( nParams & PARAM_ULONG_1 ) {m_pDbgWin->AddText( " l1:" );m_pDbgWin->AddText( String::CreateFromInt64( nLNr1 ) );}
+ if( nParams & PARAM_STR_1 ) {m_pDbgWin->AddText( " s1:" );m_pDbgWin->AddText( aString1 );}
+ if( nParams & PARAM_BOOL_1 ) {m_pDbgWin->AddText( " b2:" );m_pDbgWin->AddText( bBool1 ? "TRUE" : "FALSE" );}
+ m_pDbgWin->AddText( "\n" );
+#endif
+}
+
+void StatementFlow::SendViaSocket()
+{
+ if ( bSending )
+ {
+#if OSL_DEBUG_LEVEL > 1
+ m_pDbgWin->AddText( "SendViaSocket called recursively. Aborted!!!\n" );
+#endif
+ DBG_ERROR("SendViaSocket called recursively. Aborted!!!");
+ return;
+ }
+ bSending = sal_True;
+ if ( pCommLink )
+ {
+ if ( !pCommLink->TransferDataStream( pRet->GetStream() ) ) // tritt ein Fehler auf, so wird sofort gelöscht ...
+ pCommLink = NULL;
+ }
+ else
+ {
+ // Macht nix. Wenn das Basic nicht mehr da ist, ist sowiso alles egal
+ DBG_ERROR("Cannot send results to TestTool");
+ }
+
+ pRet->Reset();
+ bSending = sal_False;
+ IsError = sal_False;
+}
+
+sal_Bool StatementFlow::Execute()
+{
+#if OSL_DEBUG_LEVEL > 1
+ m_pDbgWin->AddText( "Executing Flow: " );
+ m_pDbgWin->AddText( String::CreateFromInt32( nArt ) );
+ m_pDbgWin->AddText( "\n" );
+#endif
+ switch ( nArt )
+ {
+ case F_EndCommandBlock:
+ {
+
+ if ( !bUseIPC )
+ {
+ // bBool1 wurde im CTOR auf sal_False initialisiert
+ if ( !bBool1 ) // also erster Durchlauf
+ {
+ pRemoteControl->pRetStream = pRet->GetStream();
+ bBool1 = sal_True; // wurde im CTOR auf sal_False initialisiert
+ nRetryCount = nRetryCount * 4;
+ }
+ if ( pRemoteControl->pRetStream && (nRetryCount--) ) // also solange nicht abgeholt
+ {
+ return sal_False; // Bitte einmal vom Callstack runter
+ }
+ }
+
+ }
+ break;
+ }
+
+ Advance();
+ switch ( nArt )
+ {
+ case F_EndCommandBlock:
+ if ( !bUseIPC )
+ { // wird oben abgehandelt
+ pRet->Reset();
+ IsError = sal_False;
+ }
+ else
+ SendViaSocket();
+
+ break;
+
+ case F_Sequence:
+
+ pRet->GenReturn(RET_Sequence,nLNr1);
+ #if OSL_DEBUG_LEVEL > 1
+ m_pDbgWin->AddText( "Sending Sequence Nr: " );
+ m_pDbgWin->AddText( String::CreateFromInt64( nLNr1 ) );
+ m_pDbgWin->AddText( "\n" );
+ #endif
+
+ break;
+// case RET_:
+ default:
+ DBG_ERROR( "Unknown Flowcontrol" );
+ break;
+ }
+
+ delete this;
+ return sal_True;
+}
+
+// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+// neue Hilfsfunktion, die stetig erweitert werden muss
+static short ImpGetRType( Window *pWin )
+{
+ short nRT = C_NoType;
+ WindowType eRT = pWin->GetType();
+ switch( eRT ) {
+ case WINDOW_WINDOW: nRT = C_Window ; break;
+
+ case WINDOW_TABCONTROL: nRT = C_TabControl ; break;
+ case WINDOW_RADIOBUTTON: nRT = C_RadioButton ; break;
+ case WINDOW_CHECKBOX: nRT = C_CheckBox ; break;
+ case WINDOW_TRISTATEBOX: nRT = C_TriStateBox ; break;
+ case WINDOW_EDIT: nRT = C_Edit ; break;
+ case WINDOW_MULTILINEEDIT: nRT = C_MultiLineEdit ; break;
+ case WINDOW_MULTILISTBOX: nRT = C_MultiListBox ; break;
+ case WINDOW_LISTBOX: nRT = C_ListBox ; break;
+ case WINDOW_COMBOBOX: nRT = C_ComboBox ; break;
+ case WINDOW_PUSHBUTTON: nRT = C_PushButton ; break;
+ case WINDOW_SPINFIELD: nRT = C_SpinField ; break;
+ case WINDOW_PATTERNFIELD: nRT = C_PatternField ; break;
+ case WINDOW_NUMERICFIELD: nRT = C_NumericField ; break;
+ case WINDOW_METRICFIELD: nRT = C_MetricField ; break;
+ case WINDOW_CURRENCYFIELD: nRT = C_CurrencyField ; break;
+ case WINDOW_DATEFIELD: nRT = C_DateField ; break;
+ case WINDOW_TIMEFIELD: nRT = C_TimeField ; break;
+ case WINDOW_IMAGERADIOBUTTON: nRT = C_ImageRadioButton ; break;
+ case WINDOW_NUMERICBOX: nRT = C_NumericBox ; break;
+ case WINDOW_METRICBOX: nRT = C_MetricBox ; break;
+ case WINDOW_CURRENCYBOX: nRT = C_CurrencyBox ; break;
+ case WINDOW_DATEBOX: nRT = C_DateBox ; break;
+ case WINDOW_TIMEBOX: nRT = C_TimeBox ; break;
+ case WINDOW_IMAGEBUTTON: nRT = C_ImageButton ; break;
+ case WINDOW_MENUBUTTON: nRT = C_MenuButton ; break;
+ case WINDOW_MOREBUTTON: nRT = C_MoreButton ; break;
+
+
+ case WINDOW_TABPAGE: nRT = C_TabPage; break;
+ case WINDOW_MODALDIALOG: nRT = C_ModalDlg; break;
+ case WINDOW_FLOATINGWINDOW: nRT = C_FloatWin; break;
+ case WINDOW_MODELESSDIALOG: nRT = C_ModelessDlg; break;
+ case WINDOW_WORKWINDOW: nRT = C_WorkWin; break;
+ case WINDOW_DOCKINGWINDOW: nRT = C_DockingWin; break;
+
+ case WINDOW_MESSBOX: nRT = C_MessBox; break;
+ case WINDOW_INFOBOX: nRT = C_InfoBox; break;
+ case WINDOW_WARNINGBOX: nRT = C_WarningBox; break;
+ case WINDOW_ERRORBOX: nRT = C_ErrorBox; break;
+ case WINDOW_QUERYBOX: nRT = C_QueryBox; break;
+#if 0 //ifndef VCL
+ case WINDOW_FILEDIALOG: nRT = C_FileDlg; break;
+ case WINDOW_PATHDIALOG: nRT = C_PathDlg; break;
+ case WINDOW_PRINTDIALOG: nRT = C_PrintDlg; break;
+ case WINDOW_PRINTERSETUPDIALOG: nRT = C_PrinterSetupDlg;break;
+ case WINDOW_COLORDIALOG: nRT = C_ColorDlg; break;
+#endif
+ case WINDOW_TABDIALOG: nRT = C_TabDlg; break;
+// case WINDOW_TABDIALOG: nRT = C_SingleTabDlg; break;
+
+ case WINDOW_PATTERNBOX: nRT = C_PatternBox; break;
+ case WINDOW_TOOLBOX: nRT = C_ToolBox; break;
+// Gibts nicht case WINDOW_VALUESET: nRT = C_ValueSet; break;
+ case WINDOW_CONTROL: nRT = C_Control; break;
+ case WINDOW_OKBUTTON: nRT = C_OkButton; break;
+ case WINDOW_CANCELBUTTON: nRT = C_CancelButton; break;
+ case WINDOW_BUTTONDIALOG: nRT = C_ButtonDialog; break;
+ case WINDOW_TREELISTBOX: nRT = C_TreeListBox; break;
+
+ case WINDOW_DIALOG: nRT = C_Dialog; break;
+ }
+ return nRT;
+}
+
+// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+StatementSlot::StatementSlot( SCmdStream *pCmdIn )
+: pItemArr(NULL)
+{
+ QueStatement( NULL );
+ pCmdIn->Read( nFunctionId );
+#if OSL_DEBUG_LEVEL > 1
+ m_pDbgWin->AddText( "Reading Slot: " );
+ m_pDbgWin->AddText( String::CreateFromInt32( nFunctionId ) );
+ m_pDbgWin->AddText( "\n" );
+#endif
+ pCmdIn->Read( nAnzahl );
+ if ( nAnzahl )
+ {
+ switch ( pCmdIn->GetNextType() )
+ {
+ case BinUSHORT: // use old calling method
+ {
+ nAnzahl++;
+ pItemArr = new SfxPoolItem*[nAnzahl];
+ for (sal_uInt16 i = 0 ; i+1 < nAnzahl ; i++)
+ pCmdIn->Read( pItemArr[i] );
+ pItemArr[nAnzahl-1] = NULL;
+ }
+ break;
+ case BinString: // new Method
+ {
+ aArgs.realloc(nAnzahl);
+ PropertyValue* pArg = aArgs.getArray();
+ for (sal_uInt16 i = 0 ; i < nAnzahl ; i++)
+ pCmdIn->Read( pArg[i] );
+ }
+ break;
+ }
+ }
+}
+
+// Constructor for UnoSlot
+StatementSlot::StatementSlot()
+: nAnzahl( 0 )
+, pItemArr(NULL)
+, nFunctionId( 0 )
+, bMenuClosed(sal_False)
+{}
+
+StatementSlot::StatementSlot( sal_uLong nSlot, SfxPoolItem* pItem )
+: pItemArr(NULL)
+, bMenuClosed(sal_False)
+{
+ QueStatement( NULL );
+ nFunctionId = sal_uInt16(nSlot);
+#if OSL_DEBUG_LEVEL > 1
+ m_pDbgWin->AddText( "Reading Slot: " );
+ m_pDbgWin->AddText( String::CreateFromInt32( nFunctionId ) );
+ m_pDbgWin->AddText( "\n" );
+#endif
+ if ( pItem )
+ {
+ nAnzahl = 2;
+ pItemArr = new SfxPoolItem*[2];
+ pItemArr[0] = pItem;
+ pItemArr[1] = NULL;
+ }
+ else
+ nAnzahl = 0;
+}
+
+StatementSlot::~StatementSlot()
+{
+ if (nAnzahl)
+ {
+ if ( pItemArr )
+ {
+ for (sal_uInt16 i = 0 ; i+1 < nAnzahl ; i++)
+ delete pItemArr[i];
+ delete[] pItemArr;
+ }
+
+ aArgs.realloc( 0 );
+ }
+}
+
+void StatementSlot::AddReferer()
+{
+ HACK( "only to test!" );
+// because slot 6102 /*SID_VERB_START*/ crashes when called with Property Referer
+// We return to the previous behavior (which was a bug realy) of not adding this Property to calls which have no properties at all
+// according to MBA most likely this Property can be removed at all and is maybe only needed for Slots with URLs
+ if ( !nAnzahl )
+ return;
+
+ PropertyValue* pArg;
+
+ nAnzahl++;
+ aArgs.realloc(nAnzahl);
+ pArg = aArgs.getArray();
+ pArg[nAnzahl-1].Name = rtl::OUString::createFromAscii("Referer");
+ pArg[nAnzahl-1].Value <<= ::rtl::OUString::createFromAscii("private:user");
+
+ nAnzahl++;
+ aArgs.realloc(nAnzahl);
+ pArg = aArgs.getArray();
+ pArg[nAnzahl-1].Name = rtl::OUString::createFromAscii("SynchronMode");
+ pArg[nAnzahl-1].Value <<= sal_Bool( sal_True );
+}
+
+class SlotStatusListener : public cppu::WeakImplHelper1< XStatusListener >
+{
+public:
+ SlotStatusListener();
+
+ // XStatusListener
+ virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw (::com::sun::star::uno::RuntimeException);
+ // XEventListener
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
+
+ // local Members
+ sal_Bool bDisposed;
+ sal_Bool bEnabled;
+};
+/*
+struct FeatureStateEvent : public ::com::sun::star::lang::EventObject
+ ::com::sun::star::util::URL FeatureURL;
+ ::rtl::OUString FeatureDescriptor;
+ sal_Bool IsEnabled;
+ sal_Bool Requery;
+ ::com::sun::star::uno::Any State;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > Source;
+*/
+
+SlotStatusListener::SlotStatusListener()
+: bDisposed( sal_False )
+, bEnabled( sal_True )
+{}
+
+// XStatusListener
+void SAL_CALL SlotStatusListener::statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw (::com::sun::star::uno::RuntimeException)
+{
+// DBG_ERROR1("FeatureURL: %s", ByteString( String( Event.FeatureURL.Complete ), RTL_TEXTENCODING_UTF8 ).GetBuffer() );
+// DBG_ERROR1("FeatureDescriptor: %s", ByteString( String( Event.FeatureDescriptor ), RTL_TEXTENCODING_UTF8 ).GetBuffer() );
+ bEnabled = Event.IsEnabled;
+// DBG_ASSERT( Event.IsEnabled, "Not enabled" );
+// DBG_ASSERT( !Event.Requery, "Requery" );
+}
+
+// XEventListener
+void SAL_CALL SlotStatusListener::disposing( const ::com::sun::star::lang::EventObject& ) throw (::com::sun::star::uno::RuntimeException)
+{
+ bDisposed = sal_True;
+}
+
+sal_Bool StatementSlot::Execute()
+{
+ if ( IsError )
+ {
+ #if OSL_DEBUG_LEVEL > 1
+ m_pDbgWin->AddText( "Skipping Slot: " );
+ m_pDbgWin->AddText( String::CreateFromInt32( nFunctionId ) );
+ m_pDbgWin->AddText( "\n" );
+ #endif
+
+ Advance();
+ delete this;
+ return sal_True;
+ }
+
+ InitProfile();
+#if OSL_DEBUG_LEVEL > 1
+ m_pDbgWin->AddText( "Executing Slot: " );
+ m_pDbgWin->AddText( String::CreateFromInt32( nFunctionId ) );
+ m_pDbgWin->AddText( "\n" );
+#endif
+
+ PopupMenu *pPopup = NULL;
+ MenuBar *pMenuBar = NULL;
+ Menu *pMenu;
+
+ GetCurrentMenues( pPopup, pMenuBar, pMenu );
+ if ( pPopup )
+ {
+ if ( !bMenuClosed )
+ {
+ pPopup->EndExecute(0);
+ aSubMenuId1 = 0;
+ aSubMenuId2 = 0;
+ aSubMenuId3 = 0;
+ pMenuWindow = NULL;
+ bMenuClosed = sal_True;
+#if OSL_DEBUG_LEVEL > 1
+ m_pDbgWin->AddText( "Closed contextmenu\n" );
+#endif
+ return sal_False;
+ }
+ else if ( nRetryCount-- )
+ {
+#if OSL_DEBUG_LEVEL > 1
+ m_pDbgWin->AddText( "Waiting for contextmenu to close\n" );
+#endif
+ return sal_False;
+ }
+ else
+ ReportError( GEN_RES_STR0( S_MENU_NOT_CLOSING ) );
+ }
+
+ Advance();
+
+ if ( !IsError )
+ {
+ if ( ( nAnzahl == 0 && !getenv("OLDSLOTHANDLING") ) || aArgs.hasElements() )
+ { // trying to call slots via uno
+ AddReferer();
+ if ( !aUnoUrl.Len() )
+ aUnoUrl = CUniString("slot:").Append( String::CreateFromInt32( nFunctionId ) );
+ ::com::sun::star::util::URL aTargetURL;
+ aTargetURL.Complete = aUnoUrl;
+ Reference < XFramesSupplier > xDesktop = Reference < XFramesSupplier >( ::comphelper::getProcessServiceFactory()->createInstance( CUniString("com.sun.star.frame.Desktop") ), UNO_QUERY );
+ Reference < XFrame > xFrame;
+
+ if ( xDesktop.is() )
+ {
+ xFrame = xDesktop->getActiveFrame();
+ if ( !xFrame.is() )
+ {
+ Reference < XFrames > xFrames;
+ xFrames = xDesktop->getFrames();
+ if ( xFrames.is() && xFrames->getCount() > 0 )
+ {
+ Any aFrame = xFrames->getByIndex( xFrames->getCount() -1 );
+ aFrame >>= xFrame;
+ }
+ }
+ if ( !xFrame.is() )
+ {
+ if ( GetFirstDocFrame() )
+ GetFirstDocFrame()->ToTop();
+ xFrame = xDesktop->getActiveFrame();
+ }
+ }
+
+ if ( xFrame.is() )
+ xDesktop = Reference < XFramesSupplier >( xFrame, UNO_QUERY );
+ else
+ xDesktop.clear();
+
+ while ( xDesktop.is() && xDesktop->getActiveFrame().is() )
+ {
+ xFrame = xDesktop->getActiveFrame();
+#if OSL_DEBUG_LEVEL > 1
+ ::rtl::OUString aName;
+ if ( xFrame.is() )
+ aName = xFrame->getName();
+#endif
+ xDesktop = Reference < XFramesSupplier >( xFrame, UNO_QUERY );
+ }
+
+ if ( !xFrame.is() )
+ ReportError( GEN_RES_STR1( S_UNO_URL_EXECUTE_FAILED_NO_FRAME, aTargetURL.Complete ) );
+ else
+ {
+ Reference < ::com::sun::star::util::XURLTransformer > xTrans( ::comphelper::getProcessServiceFactory()->createInstance( CUniString("com.sun.star.util.URLTransformer" )), UNO_QUERY );
+ xTrans->parseStrict( aTargetURL );
+
+ Reference < XDispatchProvider > xProv( xFrame, UNO_QUERY );
+ Reference < XDispatch > xDisp;
+ while ( xProv.is() && !xDisp.is() )
+ {
+ xDisp = xProv->queryDispatch( aTargetURL, ::rtl::OUString(), 0 );
+ if ( !xDisp.is() )
+ {
+ xFrame = Reference < XFrame > ( xFrame->getCreator(), UNO_QUERY );
+ xProv = Reference < XDispatchProvider > ( xFrame, UNO_QUERY );
+ }
+ }
+
+ if ( xDisp.is() )
+ {
+ Reference < XStatusListener > xListener = ( XStatusListener* )new SlotStatusListener;
+ xDisp->addStatusListener( xListener, aTargetURL );
+ if ( static_cast< SlotStatusListener* >(xListener.get())->bEnabled )
+ {
+ if ( bIsSlotInExecute )
+ ReportError( GEN_RES_STR0( S_SLOT_IN_EXECUTE ) );
+ else
+ {
+ bIsSlotInExecute = sal_True;
+ xDisp->dispatch( aTargetURL, aArgs );
+ bIsSlotInExecute = sal_False;
+ }
+ }
+ else
+ ReportError( GEN_RES_STR1( S_UNO_URL_EXECUTE_FAILED_DISABLED, aTargetURL.Complete ) );
+ xDisp->removeStatusListener( xListener, aTargetURL );
+ }
+ else
+ ReportError( GEN_RES_STR1( S_UNO_URL_EXECUTE_FAILED_NO_DISPATCHER, aTargetURL.Complete ) );
+ }
+ }
+ else
+ {
+ DirectLog( S_QAError, GEN_RES_STR0( S_DEPRECATED ) );
+ if ( !pTTProperties )
+ pTTProperties = new TTProperties();
+
+ switch ( pTTProperties->ExecuteFunction( nFunctionId, pItemArr, EXECUTEMODE_DIALOGASYNCHRON | nUseBindings ) )
+ {
+ case TT_PR_ERR_NODISPATCHER:
+ {
+ ReportError( rtl::OString::valueOf((sal_Int32)nFunctionId), GEN_RES_STR0( S_SID_EXECUTE_FAILED_NO_DISPATCHER ) );
+ }
+ break;
+ case TT_PR_ERR_NOEXECUTE:
+ {
+ ReportError( rtl::OString::valueOf((sal_Int32)nFunctionId), GEN_RES_STR0( S_SID_EXECUTE_FAILED ) );
+ }
+ break;
+ }
+ }
+ }
+
+
+/* Neues Verfahren ab 334!
+ Neue Methode zum einstellen, daß Modale Dialoge immer Asynchron aufgerufen werden
+ und echter Returnwert, ob Slot geklappt hat
+ und Testen ob Slot überhaupt durch UI aufgerufen werden kann */
+
+
+ SendProfile( SlotString( nFunctionId ) );
+ delete this;
+ return sal_True;
+}
+
+// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+StatementUnoSlot::StatementUnoSlot(SCmdStream *pIn)
+{
+ QueStatement( NULL );
+
+ pIn->Read( aUnoUrl );
+
+#if OSL_DEBUG_LEVEL > 1
+ StatementList::m_pDbgWin->AddText( "UnoUrl:" );
+ StatementList::m_pDbgWin->AddText( aUnoUrl );
+ StatementList::m_pDbgWin->AddText( "\n" );
+#endif
+
+}
+
+// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+StatementCommand::StatementCommand( StatementList *pAfterThis, sal_uInt16 MethodId, sal_uInt16 Params, sal_uInt16 Nr1 )
+: nMethodId( MethodId )
+, nParams(Params)
+, nNr1(Nr1)
+, nNr2(0)
+, nNr3(0)
+, nNr4(0)
+, nLNr1(0)
+, aString1()
+, aString2()
+, bBool1(sal_False)
+, bBool2(sal_False)
+{
+ QueStatement( pAfterThis );
+
+#if OSL_DEBUG_LEVEL > 1
+ m_pDbgWin->AddText( "Directly adding Conmmand:" );
+ m_pDbgWin->AddText( " Methode: " );
+ m_pDbgWin->AddText( String::CreateFromInt32( nMethodId ) );
+ m_pDbgWin->AddText( " Params:" );
+ if( nParams & PARAM_USHORT_1 ) {m_pDbgWin->AddText( " n1:" );m_pDbgWin->AddText( String::CreateFromInt32( nNr1 ) );}
+ if( nParams & PARAM_USHORT_2 ) {m_pDbgWin->AddText( " n2:" );m_pDbgWin->AddText( String::CreateFromInt32( nNr2 ) );}
+ if( nParams & PARAM_USHORT_3 ) {m_pDbgWin->AddText( " n3:" );m_pDbgWin->AddText( String::CreateFromInt32( nNr3 ) );}
+ if( nParams & PARAM_USHORT_4 ) {m_pDbgWin->AddText( " n4:" );m_pDbgWin->AddText( String::CreateFromInt32( nNr4 ) );}
+ if( nParams & PARAM_ULONG_1 ) {m_pDbgWin->AddText( " nl1:" );m_pDbgWin->AddText( String::CreateFromInt64( nLNr1 ) );}
+ if( nParams & PARAM_STR_1 ) {m_pDbgWin->AddText( " s1:" );m_pDbgWin->AddText( aString1 );}
+ if( nParams & PARAM_STR_2 ) {m_pDbgWin->AddText( " s2:" );m_pDbgWin->AddText( aString2 );}
+ if( nParams & PARAM_BOOL_1 ) {m_pDbgWin->AddText( " b1:" );m_pDbgWin->AddText( bBool1 ? "TRUE" : "FALSE" );}
+ if( nParams & PARAM_BOOL_2 ) {m_pDbgWin->AddText( " b2:" );m_pDbgWin->AddText( bBool2 ? "TRUE" : "FALSE" );}
+ m_pDbgWin->AddText( "\n" );
+#endif
+}
+
+
+StatementCommand::StatementCommand( SCmdStream *pCmdIn )
+: nMethodId(0)
+, nParams(0)
+, nNr1(0)
+, nNr2(0)
+, nNr3(0)
+, nNr4(0)
+, nLNr1(0)
+, aString1()
+, aString2()
+, bBool1(sal_False)
+, bBool2(sal_False)
+{
+ QueStatement( NULL );
+ pCmdIn->Read( nMethodId );
+ pCmdIn->Read( nParams );
+
+ if( nParams & PARAM_USHORT_1 ) pCmdIn->Read( nNr1 );
+ if( nParams & PARAM_USHORT_2 ) pCmdIn->Read( nNr2 );
+ if( nParams & PARAM_USHORT_3 ) pCmdIn->Read( nNr3 );
+ if( nParams & PARAM_USHORT_4 ) pCmdIn->Read( nNr4 );
+ if( nParams & PARAM_ULONG_1 ) pCmdIn->Read( nLNr1 );
+ if( nParams & PARAM_STR_1 ) pCmdIn->Read( aString1 );
+ if( nParams & PARAM_STR_2 ) pCmdIn->Read( aString2 );
+ if( nParams & PARAM_BOOL_1 ) pCmdIn->Read( bBool1 );
+ if( nParams & PARAM_BOOL_2 ) pCmdIn->Read( bBool2 );
+
+#if OSL_DEBUG_LEVEL > 1
+ m_pDbgWin->AddText( "Reading Conmmand:" );
+ m_pDbgWin->AddText( " Methode: " );
+ m_pDbgWin->AddText( String::CreateFromInt32( nMethodId ) );
+ m_pDbgWin->AddText( " Params:" );
+ if( nParams & PARAM_USHORT_1 ) {m_pDbgWin->AddText( " n1:" );m_pDbgWin->AddText( String::CreateFromInt32( nNr1 ) );}
+ if( nParams & PARAM_USHORT_2 ) {m_pDbgWin->AddText( " n2:" );m_pDbgWin->AddText( String::CreateFromInt32( nNr2 ) );}
+ if( nParams & PARAM_USHORT_3 ) {m_pDbgWin->AddText( " n3:" );m_pDbgWin->AddText( String::CreateFromInt32( nNr3 ) );}
+ if( nParams & PARAM_USHORT_4 ) {m_pDbgWin->AddText( " n4:" );m_pDbgWin->AddText( String::CreateFromInt32( nNr4 ) );}
+ if( nParams & PARAM_ULONG_1 ) {m_pDbgWin->AddText( " nl1:" );m_pDbgWin->AddText( String::CreateFromInt64( nLNr1 ) );}
+ if( nParams & PARAM_STR_1 ) {m_pDbgWin->AddText( " s1:" );m_pDbgWin->AddText( aString1 );}
+ if( nParams & PARAM_STR_2 ) {m_pDbgWin->AddText( " s2:" );m_pDbgWin->AddText( aString2 );}
+ if( nParams & PARAM_BOOL_1 ) {m_pDbgWin->AddText( " b1:" );m_pDbgWin->AddText( bBool1 ? "TRUE" : "FALSE" );}
+ if( nParams & PARAM_BOOL_2 ) {m_pDbgWin->AddText( " b2:" );m_pDbgWin->AddText( bBool2 ? "TRUE" : "FALSE" );}
+ m_pDbgWin->AddText( "\n" );
+#endif
+
+ if ( nMethodId == RC_AppAbort )
+ {
+ #if OSL_DEBUG_LEVEL > 1
+ m_pDbgWin->AddText( "*Deleting all Commands:\n" );
+ #endif
+ bReadingCommands = sal_False;
+ while ( StatementList::pFirst != this ) // Alles Löschen außer mich selbst
+ {
+ StatementList *pDeQue = StatementList::pFirst;
+ pDeQue->Advance();
+ delete pDeQue;
+ }
+ bReadingCommands = sal_True;
+ #if OSL_DEBUG_LEVEL > 1
+ m_pDbgWin->AddText( "*Done deleting all Commands:\n" );
+ #endif
+ }
+
+}
+
+void StatementCommand::WriteControlData( Window *pBase, sal_uLong nConf, sal_Bool bFirst )
+{
+
+ if ( IsDialog(pBase) && !bFirst )
+ return;
+
+ if ( bFirst )
+ pRet->GenReturn ( RET_WinInfo, rtl::OString(), (comm_ULONG)nConf | DH_MODE_DATA_VALID, UniString(), sal_True );
+
+ if ( bFirst )
+ {
+ if ( pBase->GetType() == WINDOW_WINDOW && pBase->GetParent() && pBase->GetParent()->GetType() == WINDOW_CONTROL &&
+ dynamic_cast< svt::table::TableControl* > ( pBase->GetParent() ) )
+ pBase = pBase->GetParent();
+ }
+
+ { // Klammerung, so daß der String nicht während der Rekursion bestehen bleibt
+ String aName;
+ sal_Bool bSkip = sal_False;
+
+ switch ( pBase->GetType() )
+ {
+ case WINDOW_RADIOBUTTON:
+ case WINDOW_CHECKBOX:
+ case WINDOW_TRISTATEBOX:
+ case WINDOW_PUSHBUTTON:
+ case WINDOW_OKBUTTON:
+ case WINDOW_CANCELBUTTON:
+ case WINDOW_IMAGERADIOBUTTON:
+ case WINDOW_IMAGEBUTTON:
+ case WINDOW_MENUBUTTON:
+ case WINDOW_MOREBUTTON:
+ case WINDOW_TABPAGE:
+ case WINDOW_MODALDIALOG:
+ case WINDOW_FLOATINGWINDOW:
+ case WINDOW_MODELESSDIALOG:
+ case WINDOW_WORKWINDOW:
+ case WINDOW_DOCKINGWINDOW:
+ case WINDOW_CONTROL:
+
+ case WINDOW_FILEDIALOG:
+ case WINDOW_PATHDIALOG:
+ case WINDOW_PRINTDIALOG:
+ case WINDOW_PRINTERSETUPDIALOG:
+ case WINDOW_COLORDIALOG:
+ case WINDOW_TABDIALOG:
+
+ case WINDOW_BUTTONDIALOG:
+
+ case WINDOW_MENUBARWINDOW:
+ aName = pBase->GetText().EraseAllChars('~');
+ break;
+
+ case WINDOW_EDIT:
+ case WINDOW_MULTILINEEDIT:
+ case WINDOW_MULTILISTBOX:
+ case WINDOW_LISTBOX:
+ case WINDOW_COMBOBOX:
+ case WINDOW_SPINFIELD:
+ case WINDOW_PATTERNFIELD:
+ case WINDOW_NUMERICFIELD:
+ case WINDOW_METRICFIELD:
+ case WINDOW_CURRENCYFIELD:
+ case WINDOW_DATEFIELD:
+ case WINDOW_TIMEFIELD:
+ case WINDOW_NUMERICBOX:
+ case WINDOW_METRICBOX:
+ case WINDOW_CURRENCYBOX:
+ case WINDOW_DATEBOX:
+ case WINDOW_TIMEBOX:
+ case WINDOW_PATTERNBOX:
+ case WINDOW_TOOLBOX:
+ aName = pBase->GetQuickHelpText();
+ break;
+
+ case WINDOW_MESSBOX:
+ case WINDOW_INFOBOX:
+ case WINDOW_WARNINGBOX:
+ case WINDOW_ERRORBOX:
+ case WINDOW_QUERYBOX:
+ aName = ((MessBox*)pBase)->GetMessText();
+ break;
+
+ default:
+ if ( ( pBase->GetUniqueOrHelpId().getLength() == 0 ) && !( nConf & DH_MODE_ALLWIN ) )
+ bSkip = sal_True;
+ break;
+ }
+
+ if ( !bSkip )
+ {
+ if ( aName.Len() == 0 )
+ aName = pBase->GetQuickHelpText();
+ if ( aName.Len() == 0 )
+ aName = pBase->GetHelpText();
+ if ( aName.Len() == 0 )
+ aName = pBase->GetText();
+
+
+ String aTypeSuffix;
+ if ( pBase->GetType() == WINDOW_CONTROL )
+ {
+ if ( dynamic_cast< EditBrowseBox* >(pBase) )
+ aTypeSuffix.AppendAscii( "/BrowseBox", 10 );
+ else if ( dynamic_cast< ValueSet* >(pBase) )
+ aTypeSuffix.AppendAscii( "/ValueSet", 9 );
+ else if ( dynamic_cast< ORoadmap* >(pBase) )
+ aTypeSuffix.AppendAscii( "/RoadMap", 8 );
+ else if ( dynamic_cast< IExtensionListBox* >(pBase) )
+ aTypeSuffix.AppendAscii( "/ExtensionListBox" );
+ else if ( dynamic_cast< svt::table::TableControl* >(pBase) )
+ aTypeSuffix.AppendAscii( "/TableControl" );
+ else
+ aTypeSuffix.AppendAscii( "/Unknown", 8 );
+ }
+
+ rtl::OString aId = pBase->GetUniqueOrHelpId();
+ pRet->GenReturn ( RET_WinInfo, aId, (comm_ULONG)pBase->GetType(),
+ TypeString(pBase->GetType()).Append(aTypeSuffix).AppendAscii(": ").Append(aName), sal_False );
+
+
+ if ( pBase->GetType() == WINDOW_TOOLBOX ) // Buttons und Controls auf Toolboxen.
+ {
+ ToolBox *pTB = ((ToolBox*)pBase);
+ sal_uInt16 i;
+ for ( i = 0; i < pTB->GetItemCount() ; i++ )
+ {
+ aName = String();
+// if ( aName.Len() == 0 )
+// aName = pTB->GetQuickHelpText();
+ if ( aName.Len() == 0 )
+ aName = pTB->GetHelpText( pTB->GetItemId( i ) );
+ if ( aName.Len() == 0 )
+ aName = pTB->GetItemText( pTB->GetItemId( i ) );
+
+ Window *pItemWin;
+ pItemWin = pTB->GetItemWindow( pTB->GetItemId( i ) );
+ if ( pTB->GetItemType( i ) == TOOLBOXITEM_BUTTON && ( !pItemWin || !pItemWin->IsVisible() ) )
+ {
+ if ( pTB->GetItemCommand(pTB->GetItemId( i )).Len() || ( nConf & DH_MODE_ALLWIN ) )
+ pRet->GenReturn ( RET_WinInfo, Str2Id(pTB->GetItemCommand(pTB->GetItemId( i ))), (comm_ULONG)WINDOW_BUTTON,
+ TypeString(WINDOW_BUTTON).AppendAscii(": ").Append(aName), sal_False );
+ if ( !pTB->GetItemCommand(pTB->GetItemId( i )).Len() || ( nConf & DH_MODE_ALLWIN ) )
+ pRet->GenReturn ( RET_WinInfo, pTB->GetHelpId(pTB->GetItemId( i )), (comm_ULONG)WINDOW_BUTTON,
+ TypeString(WINDOW_BUTTON).AppendAscii(": ").Append(aName), sal_False );
+ }
+ else
+ {
+ if ( pItemWin )
+ {
+ if ( pTB->GetItemCommand(pTB->GetItemId( i )).Len() || ( nConf & DH_MODE_ALLWIN ) )
+ pRet->GenReturn ( RET_WinInfo, Str2Id(pTB->GetItemCommand(pTB->GetItemId( i ))), (comm_ULONG)pItemWin->GetType(),
+ TypeString(pItemWin->GetType()).AppendAscii(": ").Append(aName), sal_False );
+ if ( !pTB->GetItemCommand(pTB->GetItemId( i )).Len() || ( nConf & DH_MODE_ALLWIN ) )
+ pRet->GenReturn ( RET_WinInfo, pTB->GetHelpId(pTB->GetItemId( i )), (comm_ULONG)pItemWin->GetType(),
+ TypeString(pItemWin->GetType()).AppendAscii(": ").Append(aName), sal_False );
+ sal_uInt16 ii;
+ for( ii = 0 ; ii < pItemWin->GetChildCount(); ii++ )
+ WriteControlData( pItemWin->GetChild(ii), nConf, sal_False );
+ }
+ else
+ {
+ if ( nConf & DH_MODE_ALLWIN )
+ {
+ String aToolBoxItemType;
+ switch ( pTB->GetItemType( i ) )
+ {
+ case TOOLBOXITEM_DONTKNOW:
+ aToolBoxItemType.AssignAscii("TOOLBOXITEM_DONTKNOW");
+ break;
+ case TOOLBOXITEM_BUTTON:
+ aToolBoxItemType.AssignAscii("TOOLBOXITEM_BUTTON");
+ break;
+ case TOOLBOXITEM_SPACE:
+ aToolBoxItemType.AssignAscii("TOOLBOXITEM_SPACE");
+ break;
+ case TOOLBOXITEM_SEPARATOR:
+ aToolBoxItemType.AssignAscii("TOOLBOXITEM_SEPARATOR");
+ break;
+ case TOOLBOXITEM_BREAK:
+ aToolBoxItemType.AssignAscii("TOOLBOXITEM_BREAK");
+ break;
+ default:
+ DBG_ERROR1( "Unknown TOOLBOXITEM %i", pTB->GetItemType( i ) );
+ }
+ if ( pTB->GetItemCommand(pTB->GetItemId( i )).Len() || ( nConf & DH_MODE_ALLWIN ) )
+ pRet->GenReturn ( RET_WinInfo, Str2Id( pTB->GetItemCommand(pTB->GetItemId( i )) ), (comm_ULONG)WINDOW_BASE,
+ aToolBoxItemType.AppendAscii(": ").Append(aName), sal_False );
+ if ( !pTB->GetItemCommand(pTB->GetItemId( i )).Len() || ( nConf & DH_MODE_ALLWIN ) )
+ pRet->GenReturn ( RET_WinInfo, pTB->GetHelpId(pTB->GetItemId( i )), (comm_ULONG)WINDOW_BASE,
+ aToolBoxItemType.AppendAscii(": ").Append(aName), sal_False );
+ }
+ }
+ }
+ }
+
+ return; // ToolBox ist hier schon komplett abgehandelt.
+ }
+
+
+ if ( pBase->GetType() == WINDOW_BUTTONDIALOG // Buttons auf Buttondialogen mit ID
+ || pBase->GetType() == WINDOW_MESSBOX
+ || pBase->GetType() == WINDOW_INFOBOX
+ || pBase->GetType() == WINDOW_WARNINGBOX
+ || pBase->GetType() == WINDOW_ERRORBOX
+ || pBase->GetType() == WINDOW_QUERYBOX )
+ {
+ ButtonDialog *pBD = ((ButtonDialog*)pBase);
+ sal_uInt16 i;
+ for ( i = 0; i < pBD->GetButtonCount() ; i++ )
+ {
+ aName = String();
+ if ( aName.Len() == 0 )
+ aName = pBD->GetPushButton( pBD->GetButtonId(i) )->GetText();
+ ByteString aID;
+ switch ( pBD->GetButtonId(i) )
+ {
+ case BUTTONID_OK:
+ aID.Assign("Ok");
+ break;
+ case BUTTONID_CANCEL:
+ aID.Assign("Cancel");
+ break;
+ case BUTTONID_YES:
+ aID.Assign("Yes");
+ break;
+ case BUTTONID_NO:
+ aID.Assign("No");
+ break;
+ case BUTTONID_RETRY:
+ aID.Assign("Retry");
+ break;
+ case BUTTONID_HELP:
+ aID.Assign("Help");
+ break;
+ default:
+ aID = ByteString::CreateFromInt32( pBD->GetButtonId(i) );
+ break;
+ }
+
+ pRet->GenReturn ( RET_WinInfo, aID, (comm_ULONG)pBD->GetPushButton( pBD->GetButtonId(i) )->GetType(), // So daß der Text angezeigt wird!
+ TypeString(pBD->GetPushButton( pBD->GetButtonId(i) )->GetType()).AppendAscii(": ").Append(aName)
+ .AppendAscii(" ButtonId = ").AppendAscii( aID.GetBuffer() ), sal_False );
+ }
+
+ return; // ButtonDialog ist hier schon komplett abgehandelt.
+ }
+
+
+ Menu* pMenu = GetMatchingMenu( pBase );
+
+ if ( pMenu ) // Menus
+ {
+ sal_uInt16 i;
+ for ( i = 0; i < pMenu->GetItemCount() ; i++ )
+ {
+ sal_uInt16 nID = pMenu->GetItemId( i );
+
+ aName = String();
+ if ( aName.Len() == 0 )
+ aName = pMenu->GetHelpText( nID );
+ if ( aName.Len() == 0 )
+ aName = pMenu->GetItemText( nID );
+
+
+ if ( pMenu->GetItemType( i ) == MENUITEM_STRING || pMenu->GetItemType( i ) == MENUITEM_IMAGE || pMenu->GetItemType( i ) == MENUITEM_STRINGIMAGE || (nConf & DH_MODE_ALLWIN) )
+ {
+ String aMenuItemType;
+ switch ( pMenu->GetItemType( i ) )
+ {
+ case MENUITEM_STRING:
+ aMenuItemType.AssignAscii("MENUITEM_STRING");
+ break;
+ case MENUITEM_STRINGIMAGE:
+ aMenuItemType.AssignAscii("MENUITEM_STRINGIMAGE");
+ break;
+ case MENUITEM_IMAGE:
+ aMenuItemType.AssignAscii("MENUITEM_IMAGE");
+ break;
+ case MENUITEM_SEPARATOR:
+ aMenuItemType.AssignAscii("MENUITEM_SEPARATOR");
+ break;
+ case MENUITEM_DONTKNOW:
+ aMenuItemType.AssignAscii("MENUITEM_DONTKNOW");
+ break;
+ default:
+ DBG_ERROR1( "Unknown MENUITEM %i", pMenu->GetItemType( i ) );
+ }
+ if ( pMenu->GetItemCommand(nID).Len() || ( nConf & DH_MODE_ALLWIN ) )
+ pRet->GenReturn ( RET_WinInfo, Str2Id( pMenu->GetItemCommand(nID) ), (comm_ULONG)0,
+ aMenuItemType.AppendAscii(": ").Append(aName), sal_False );
+ if ( !pMenu->GetItemCommand(nID).Len() || ( nConf & DH_MODE_ALLWIN ) )
+ pRet->GenReturn ( RET_WinInfo, rtl::OString::valueOf( (sal_Int32)nID ), (comm_ULONG)0,
+ aMenuItemType.AppendAscii(": ").Append(aName), sal_False );
+ }
+ }
+
+ return; // Menu ist hier schon komplett abgehandelt.
+ }
+ }
+ }
+
+ for( sal_uInt16 i = 0 ; i < pBase->GetChildCount(); i++ )
+ WriteControlData( pBase->GetChild(i), nConf, sal_False );
+}
+
+class SysWinContainer : public WorkWindow
+{
+private:
+ ToolBox *pClientWin;
+ DockingWindow *pDock;
+public:
+ SysWinContainer( ToolBox *pClient );
+ ~SysWinContainer();
+ virtual void Resize();
+ virtual void Resizing( Size& rSize );
+};
+
+SysWinContainer::SysWinContainer( ToolBox *pClient )
+: WorkWindow( NULL, WB_BORDER | WB_SIZEMOVE | WB_CLOSEABLE )
+, pClientWin( pClient )
+{
+ pDock = new DockingWindow( this );
+ pClientWin->SetParent( pDock );
+ pClientWin->SetFloatingMode( sal_False );
+ SetText( pClient->GetText() );
+ SetPosPixel( Point( 1,40 ) );
+ Resize();
+ pDock->Show();
+ EnableAlwaysOnTop();
+ Show();
+}
+
+SysWinContainer::~SysWinContainer()
+{
+ delete pDock;
+}
+
+void SysWinContainer::Resize()
+{
+ Size aSize( GetOutputSizePixel() );
+ Resizing( aSize );
+// aSize = pClientWin->GetSizePixel();
+// aSize = pClientWin->CalcWindowSizePixel();
+ if ( aSize != GetSizePixel() )
+ {
+ SetOutputSizePixel( aSize );
+ pDock->SetSizePixel( aSize );
+ pClientWin->SetSizePixel( aSize );
+ }
+}
+
+void SysWinContainer::Resizing( Size& rSize )
+{
+ Size aSize;
+ Size aBestSize;
+ sal_uInt16 i;
+ sal_Bool bHasValue = sal_False;
+ sal_uLong nBestValue = 0;
+ sal_uLong nThisValue;
+ for ( i=1 ; i<=1 ; i++ )
+ {
+ aSize = pClientWin->CalcWindowSizePixel( i );
+ nThisValue = Abs( aSize.Width() - rSize.Width() ) + Abs( aSize.Height() - rSize.Height() );
+ if ( !bHasValue || ( nThisValue < nBestValue ) )
+ {
+ nBestValue = nThisValue;
+ aBestSize = aSize;
+ bHasValue = sal_True;
+ }
+ }
+ rSize = aBestSize;
+}
+
+
+class DisplayHidWin : public ToolBox
+{
+ Edit *pEdit;
+ Size aMinEditSize;
+ sal_uInt16 nLastItemID;
+ sal_Bool bIsDraging;
+ sal_Bool bIsPermanentDraging;
+ void SetDraging( sal_Bool bNewDraging );
+ Image *pShow, *pShow2;
+ sal_Bool bConfigChanged;
+ void EnableButtons( sal_uLong nConf );
+
+ sal_uLong nEventHookID;
+ static long stub_VCLEventHookProc( NotifyEvent& rEvt, void* pData )
+ {
+ return ((DisplayHidWin*)pData)->VCLEventHook( rEvt );
+ }
+
+ long VCLEventHook( NotifyEvent& rEvt );
+ Window *pLastMouseMoveWin;
+
+ SysWinContainer *pContainer;
+
+ // aborting by pressing shist twice
+ sal_Bool bOldShift;
+ Time aLatest;
+ sal_uInt16 nShiftCount;
+
+public:
+ DisplayHidWin();
+ ~DisplayHidWin();
+
+ virtual void Tracking( const TrackingEvent& rTEvt );
+ virtual void Click();
+ virtual void Select();
+ virtual void SetText( const XubString& rStr );
+
+ void SetDisplayText( const String &aNewText ){ pEdit->SetText(aNewText); }
+ String GetDisplayText() const { return pEdit->GetText(); }
+ sal_Bool IsDisplayTextModified() const { return pEdit->IsModified(); }
+ void ClearDisplayTextModified() const { pEdit->ClearModifyFlag(); }
+
+ void SetConfig( sal_uLong nConf );
+ sal_uLong GetConfig();
+
+ sal_Bool IsConfigChanged() { return bConfigChanged; }
+ void ConfigSent() { bConfigChanged = sal_False; }
+
+ sal_Bool IsSendData() { return GetItemState( TT_SEND_DATA ) == STATE_CHECK; }
+// sal_Bool IsAllWin() { return GetItemState( TT_ALLWIN ) == STATE_CHECK; }
+
+ sal_Bool IsDraging() { return bIsDraging; }
+
+ Window* LastMouseMoveWin() { return pLastMouseMoveWin; }
+};
+
+DisplayHidWin::DisplayHidWin()
+: ToolBox( StatementList::GetFirstDocFrame(), TTProperties::GetSvtResId(DisplayHidToolBox) )
+, bIsDraging( sal_False )
+, bIsPermanentDraging( sal_False )
+, pShow( NULL )
+, pShow2( NULL )
+, pLastMouseMoveWin( NULL )
+, bOldShift( 0 )
+, nShiftCount( 0 )
+{
+ SetOutStyle( TOOLBOX_STYLE_HANDPOINTER | TOOLBOX_STYLE_FLAT );
+ pEdit = new Edit( this, WB_CENTER | WB_BORDER );
+ aMinEditSize = GetItemRect( TT_OUTPUT ).GetSize();
+/**/ aMinEditSize=Size(20,20);
+ aMinEditSize.Width() *= 12;
+ pEdit->SetSizePixel( aMinEditSize );
+ pEdit->Show();
+ SetItemWindow( TT_OUTPUT, pEdit );
+ Resize();
+ pContainer = new SysWinContainer( this );
+ nEventHookID = Application::AddEventHook( stub_VCLEventHookProc, this );
+}
+
+DisplayHidWin::~DisplayHidWin()
+{
+ Application::RemoveEventHook( nEventHookID );
+ Hide(); // so GetFirstDocFrame won't return ourselves (needed for SOPlayer)
+ SetParent( StatementList::GetFirstDocFrame() );
+ delete pContainer;
+ delete pEdit;
+}
+
+void DisplayHidWin::SetDraging( sal_Bool bNewDraging )
+{
+ if ( !pShow )
+ pShow = new Image( GetItemImage( TT_SHOW ) );
+ if ( !pShow2 )
+ pShow2 = new Image( Bitmap( TTProperties::GetSvtResId( TT_SHOW2 ) ) );
+
+ if ( bNewDraging )
+ SetItemImage( TT_SHOW, *pShow2 );
+ else
+ SetItemImage( TT_SHOW, *pShow );
+
+ bIsDraging = bNewDraging;
+}
+
+void DisplayHidWin::EnableButtons( sal_uLong nConf )
+{
+ sal_Bool bSend = sal_Bool(nConf & DH_MODE_SEND_DATA);
+ EnableItem( TT_ALLWIN, bSend );
+ EnableItem( TT_KURZNAME, bSend );
+ EnableItem( TT_LANGNAME, bSend );
+}
+
+void DisplayHidWin::Tracking( const TrackingEvent& rTEvt )
+{
+// if ( nLastItemID == TT_SHOW && GetItemState( TT_SHOW ) == STATE_NOCHECK && ( rTEvt.IsTrackingEnded() || rTEvt.IsTrackingCanceled() ) )
+// SetDraging( sal_False );
+ if ( nLastItemID == TT_SHOW && GetItemState( TT_SHOW ) == STATE_NOCHECK )
+ EndTracking( ENDTRACK_CANCEL );
+ ToolBox::Tracking( rTEvt);
+}
+
+void DisplayHidWin::Click()
+{
+ nLastItemID = GetCurItemId();
+ if ( nLastItemID == TT_SHOW )
+ {
+ SetDraging( sal_True );
+ }
+ ToolBox::Click();
+}
+
+void DisplayHidWin::Select()
+{
+ if ( GetItemState( GetCurItemId() ) == STATE_NOCHECK )
+ {
+ SetItemState( GetCurItemId(), STATE_CHECK );
+ if ( GetCurItemId() == TT_SHOW )
+ {
+ bIsPermanentDraging = sal_True;
+ SetDraging( sal_True );
+ }
+ }
+ else
+ {
+ SetItemState( GetCurItemId(), STATE_NOCHECK );
+ if ( GetCurItemId() == TT_SHOW )
+ {
+ bIsPermanentDraging = sal_False;
+ SetDraging( sal_False );
+ }
+ }
+ if ( GetCurItemId() == TT_SEND_DATA )
+ {
+ EnableButtons( GetConfig() );
+ }
+}
+
+void DisplayHidWin::SetConfig( sal_uLong nConf )
+{
+ SetItemState( TT_KURZNAME, ( nConf & DH_MODE_KURZNAME ) ? STATE_CHECK : STATE_NOCHECK );
+ SetItemState( TT_LANGNAME, ( nConf & DH_MODE_LANGNAME ) ? STATE_CHECK : STATE_NOCHECK );
+ SetItemState( TT_ALLWIN, ( nConf & DH_MODE_ALLWIN ) ? STATE_CHECK : STATE_NOCHECK );
+ SetItemState( TT_SEND_DATA, ( nConf & DH_MODE_SEND_DATA ) ? STATE_CHECK : STATE_NOCHECK );
+ EnableButtons( nConf );
+}
+
+sal_uLong DisplayHidWin::GetConfig()
+{
+ sal_uLong nConf = 0;
+ if ( GetItemState( TT_KURZNAME ) == STATE_CHECK )
+ nConf |= DH_MODE_KURZNAME;
+ if ( GetItemState( TT_LANGNAME ) == STATE_CHECK )
+ nConf |= DH_MODE_LANGNAME;
+ if ( GetItemState( TT_ALLWIN ) == STATE_CHECK )
+ nConf |= DH_MODE_ALLWIN;
+ if ( IsSendData() )
+ nConf |= DH_MODE_SEND_DATA;
+
+ return nConf;
+}
+
+void DisplayHidWin::SetText( const XubString& rStr )
+{
+ pContainer->SetText( rStr );
+}
+
+long DisplayHidWin::VCLEventHook( NotifyEvent& rEvt )
+{
+ if ( EVENT_MOUSEMOVE == rEvt.GetType() )
+ {
+ pLastMouseMoveWin = rEvt.GetWindow();
+
+ // check if abort with pressing shift twice
+ MouseEvent* pMEvt = (MouseEvent*)rEvt.GetMouseEvent();
+
+ if ( ( pMEvt->IsShift() && !bOldShift ) ) // Shift pressed
+ {
+ if ( aLatest < Time() )
+ {
+ nShiftCount = 0;
+ aLatest = Time()+Time( 0, 0, 0, 50 );
+ }
+ nShiftCount++;
+ }
+ if ( ( !pMEvt->IsShift() && bOldShift ) ) // Shift released
+ {
+ nShiftCount++;
+ if ( nShiftCount == 4 && aLatest > Time() )
+ {
+ bIsPermanentDraging = sal_False;
+ SetDraging( sal_False );
+ SetItemState( TT_SHOW, STATE_NOCHECK );
+ }
+ }
+ bOldShift = pMEvt->IsShift();
+ }
+ if ( ( ( EVENT_MOUSEBUTTONUP == rEvt.GetType() && rEvt.GetMouseEvent()->GetButtons() == MOUSE_LEFT) || ( EVENT_MOUSEMOVE == rEvt.GetType() && !rEvt.GetMouseEvent()->GetButtons() ) )
+ && IsDraging() && !bIsPermanentDraging )
+ SetDraging( sal_False );
+ return 0;
+}
+
+
+sal_Bool StatementCommand::DisplayHID()
+{
+ // Return sal_True -> reexecute command
+
+ if ( !bBool2 ) // Wird auf sal_False initialisiert
+ {
+ bBool2 = sal_True; // Wir sind initialisiert.
+ GetTTSettings()->pDisplayInstance = this; // Und haben die Macht (Alle anderen beenden sich)
+
+ if ( !(nParams & PARAM_ULONG_1) )
+ {
+ if( GetTTSettings()->pDisplayHidWin ) // Nichts verändern
+ nLNr1 = GetTTSettings()->pDisplayHidWin->GetConfig();
+ else // Beim ersten Aufruf wollen wir alles richtig einstellen
+ nLNr1 = DH_MODE_KURZNAME | DH_MODE_LANGNAME;
+
+ if( ((nParams & PARAM_BOOL_1) && bBool1) )
+ nLNr1 |= DH_MODE_SEND_DATA;
+ else
+ nLNr1 &= ( ~DH_MODE_SEND_DATA );
+ }
+
+ if ( GetTTSettings()->pDisplayHidWin )
+ GetTTSettings()->pDisplayHidWin->SetConfig( nLNr1 );
+ }
+
+ if ( GetTTSettings()->pDisplayInstance && GetTTSettings()->pDisplayInstance != this )
+ {
+ DBG_WARNING("Mehrere DisplayHID am laufen");
+ return sal_False; // Noch eine andere Instanz macht das gleiche!
+ }
+
+ if ( !GetTTSettings()->pDisplayHidWin )
+ {
+ GetTTSettings()->pDisplayHidWin = new DisplayHidWin();
+ GetTTSettings()->aOriginalCaption = GetTTSettings()->pDisplayHidWin->GetText();
+ GetTTSettings()->pDisplayHidWin->Show();
+ if ( bBool1 )
+ nLNr1 |= DH_MODE_SEND_DATA;
+ GetTTSettings()->pDisplayHidWin->SetConfig( nLNr1 );
+
+ GetTTSettings()->Old = NULL;
+ GetTTSettings()->Act = NULL;
+ GetTTSettings()->pDisplayInstance = this;
+ }
+ else
+ {
+ GetTTSettings()->pDisplayHidWin->GetWindow( WINDOW_OVERLAP )->Enable( sal_True, sal_True );
+ GetTTSettings()->pDisplayHidWin->GetWindow( WINDOW_OVERLAP )->EnableInput( sal_True, sal_True );
+ }
+
+
+ if ( GetTTSettings()->pDisplayHidWin->IsVisible() && !bDying )
+ {
+
+ if ( GetTTSettings()->pDisplayHidWin->IsDraging() )
+ {
+
+
+#define HIGHLIGHT_WIN( WinPtr ) \
+ { \
+ Color aLineColMem = WinPtr->GetLineColor(); \
+ WinPtr->SetLineColor( Color( COL_WHITE ) ); \
+ Color aFillColMem = WinPtr->GetFillColor(); \
+ WinPtr->SetFillColor( Color( COL_LIGHTRED ) ); \
+ RasterOp aROp = WinPtr->GetRasterOp(); \
+ WinPtr->SetRasterOp( ROP_XOR ); \
+ Size aSz = WinPtr->PixelToLogic( WinPtr->GetSizePixel() );\
+ sal_uLong nMaxCornerRadius = WinPtr->PixelToLogic( Point( 80, 0 ) ).X();\
+ sal_uLong iCorner = std::max ((sal_uLong) 8, (sal_uLong) std::min( nMaxCornerRadius, (sal_uLong) std::min((sal_uLong) (aSz.Width() / 6), (sal_uLong)(aSz.Height() / 6))));\
+ WinPtr->DrawRect(Rectangle(Point(),aSz), iCorner, iCorner);\
+ WinPtr->SetLineColor( aLineColMem ); \
+ WinPtr->SetFillColor( aFillColMem ); \
+ WinPtr->SetRasterOp( aROp ); \
+ }
+
+
+#define SET_WIN( WinPtr ) \
+ if ( StatementList::WinPtrValid(WinPtr) ) \
+ { \
+ HIGHLIGHT_WIN ( WinPtr ); \
+ }
+
+#define RESET_WIN( WinPtr ) \
+ if ( StatementList::WinPtrValid(WinPtr) ) \
+ { \
+ WinPtr->Invalidate( INVALIDATE_NOTRANSPARENT ); \
+ WinPtr->Update(); \
+ }
+
+
+ GetTTSettings()->Old = GetTTSettings()->Act;
+// GetTTSettings()->Act = GetMouseWin();
+ GetTTSettings()->Act = GetTTSettings()->pDisplayHidWin->LastMouseMoveWin();
+
+ if ( !StatementList::WinPtrValid ( GetTTSettings()->Old ) )
+ GetTTSettings()->Old = NULL;
+ if ( !StatementList::WinPtrValid ( GetTTSettings()->Act ) )
+ GetTTSettings()->Act = NULL;
+
+ if ( GetTTSettings()->Act && GetTTSettings()->Act->GetType() == WINDOW_BORDERWINDOW )
+ GetTTSettings()->Act = GetTTSettings()->Act->GetWindow( WINDOW_CLIENT );
+
+ if ( GetTTSettings()->Act != GetTTSettings()->Old )
+ {
+ if ( GetTTSettings()->Old )
+ {
+ RESET_WIN(GetTTSettings()->Old);
+ }
+ if ( GetTTSettings()->Act )
+ {
+ SET_WIN(GetTTSettings()->Act);
+ GetTTSettings()->pDisplayHidWin->SetDisplayText( Id2Str(GetTTSettings()->Act->GetUniqueOrHelpId()).AppendAscii(" WinType: ")
+ .Append(UniString::CreateFromInt64(GetTTSettings()->Act->GetType())).AppendAscii(" ").Append(GetTTSettings()->Act->GetText()));
+ if ( GetTTSettings()->Act && !GetTTSettings()->Act->GetUniqueId().equals( GetTTSettings()->Act->GetHelpId() ) )
+ GetTTSettings()->pDisplayHidWin->SetText(UniString( TTProperties::GetSvtResId( TT_ALTERNATE_CAPTION ) ).AppendAscii(GetTTSettings()->Act->GetHelpId().getStr()));
+ else
+ GetTTSettings()->pDisplayHidWin->SetText( GetTTSettings()->aOriginalCaption );
+ }
+ else
+ GetTTSettings()->pDisplayHidWin->SetDisplayText(CUniString("Kein Window/Control gefunden"));
+ }
+ else if ( GetTTSettings()->Act )
+ {
+// SET_WIN(GetTTSettings()->Act);
+ // allow setting a HelpID manually (just enter the ID in the displayHID Window and terminate it by |
+ if ( GetTTSettings()->pDisplayHidWin->IsDisplayTextModified() && GetTTSettings()->pDisplayHidWin->GetDisplayText().GetTokenCount( '|' ) > 1 )
+ {
+ GetTTSettings()->Act->SetUniqueId( Str2Id( GetTTSettings()->pDisplayHidWin->GetDisplayText().GetToken( '|' ) ) );
+ GetTTSettings()->pDisplayHidWin->ClearDisplayTextModified();
+ }
+ }
+/* if ( Application::GetLastInputInterval() > 5000 ) // 5 Sekunden lang nix geschehen
+ {
+ GetTTSettings()->pDisplayHidWin->ToTop( TOTOP_NOGRABFOCUS );
+ }
+*/
+ if ( GetTTSettings()->pDisplayHidWin->IsSendData() /*&& bBool2*/ && GetTTSettings()->Act )
+ {
+ if ( !StatementFlow::bSending )
+ { // Normalerweise syncronisierung über Protokoll. Hier ist das aber asyncron!!!
+ WriteControlData( GetTTSettings()->Act, GetTTSettings()->pDisplayHidWin->GetConfig() );
+ new StatementFlow( this, F_EndCommandBlock ); // Kommando zum Senden erzeugen und in que eintragen
+ }
+ }
+ } //if ( GetTTSettings()->pDisplayHidWin->IsDraging() )
+ else
+ {
+ if ( GetTTSettings()->Act )
+ {
+ RESET_WIN(GetTTSettings()->Act);
+ GetTTSettings()->Act = NULL;
+ }
+ }
+
+ if ( pFirst == this ) // Sollte immer so sein, aber besser isses
+ if ( pNext ) // Befehle warten auf Ausführung
+ { // An Ende neu einsortieren
+ Advance();
+ QueStatement( NULL );
+ }
+// { // Ersten und 2. austauschen.
+// pFirst = pNext;
+// pNext = pNext->pNext;
+// pFirst->pNext = this;
+// }
+
+ }
+ else
+ {
+ delete GetTTSettings()->pDisplayHidWin;
+ GetTTSettings()->pDisplayHidWin = NULL;
+ GetTTSettings()->pDisplayInstance = NULL;
+ }
+
+ return GetTTSettings()->pDisplayHidWin != NULL;
+}
+
+class TranslateWin : public WorkWindow
+{
+private:
+ DECL_LINK( DoAccept, PushButton* );
+ DECL_LINK( DoNext, PushButton* );
+ DECL_LINK( DoSelect, PushButton* );
+ DECL_LINK( DoRestore, PushButton* );
+ DECL_LINK( TranslationChanged, Edit* );
+ DECL_LINK( ShowInplace, Timer* );
+
+ Timer InplaceTimer;
+
+// virtual void MouseButtonUp( const MouseEvent& rMEvt );
+// virtual void MouseMove( const MouseEvent& rMEvt );
+
+ PushButton PushButtonTT_PB_NEXT;
+ GroupBox GroupBoxTT_GB_TRANSLATION;
+ Edit EditTT_E_NEW;
+ GroupBox GroupBoxTT_GB_COMMENT;
+ Edit EditTT_E_COMMENT;
+ PushButton PushButtonTT_PB_ACCEPT;
+ FixedText FixedTextTT_FT_OLD;
+ PushButton PushButtonTT_PB_SELECT;
+ PushButton PushButtonTT_PB_RESTORE;
+
+ Window *Old;
+ Window *Act;
+ Window *pTranslateWin;
+ sal_Bool bSelecting;
+
+ sal_Bool bAvailable;
+ sal_Bool bNext;
+
+ sal_Bool TestChangedDataSaved();
+
+
+ sal_uLong nEventHookID;
+ static long stub_VCLEventHookProc( NotifyEvent& rEvt, void* pData )
+ {
+ return ((TranslateWin*)pData)->VCLEventHook( rEvt );
+ }
+
+ long VCLEventHook( NotifyEvent& rEvt );
+
+public:
+ TranslateWin();
+ ~TranslateWin();
+
+ static String MarkShortcutErrors( Window* pBase, sal_Bool bMark );
+
+ sal_Bool IsTranslationAvailable(){ return bAvailable; }
+ sal_Bool IsNextDialog(){ return bNext; }
+ void ResetNextDialog(){ bNext = sal_False; }
+
+ Window* GetTranslationWindow(){ return pTranslateWin; }
+ String GetOriginalText(){ return FixedTextTT_FT_OLD.GetText(); }
+ String GetTranslationText(){ return EditTT_E_NEW.GetText(); }
+ String GetComment(){ return EditTT_E_COMMENT.GetText(); }
+
+ void EnableTranslation();
+};
+
+TranslateWin::TranslateWin()
+: WorkWindow( NULL, TTProperties::GetSvtResId( TT_INLINE_TRANSLATION ) )
+, PushButtonTT_PB_NEXT( this, TTProperties::GetSvtResId( TT_PB_NEXT ) )
+, GroupBoxTT_GB_TRANSLATION( this, TTProperties::GetSvtResId( TT_GB_TRANSLATION ) )
+, EditTT_E_NEW( this, TTProperties::GetSvtResId( TT_E_NEW ) )
+, GroupBoxTT_GB_COMMENT( this, TTProperties::GetSvtResId( TT_GB_COMMENT ) )
+, EditTT_E_COMMENT( this, TTProperties::GetSvtResId( TT_E_COMMENT ) )
+, PushButtonTT_PB_ACCEPT( this, TTProperties::GetSvtResId( TT_PB_ACCEPT ) )
+, FixedTextTT_FT_OLD( this, TTProperties::GetSvtResId( TT_FT_OLD ) )
+, PushButtonTT_PB_SELECT( this, TTProperties::GetSvtResId( TT_PB_SELECT ) )
+, PushButtonTT_PB_RESTORE( this, TTProperties::GetSvtResId( TT_PB_RESTORE ) )
+, Old( NULL )
+, Act( NULL )
+, pTranslateWin( NULL )
+, bSelecting( sal_False )
+, bAvailable( sal_False )
+, bNext( sal_False )
+{
+ FreeResource();
+ PushButtonTT_PB_NEXT.SetClickHdl( LINK( this, TranslateWin, DoNext ) );
+ PushButtonTT_PB_ACCEPT.SetClickHdl( LINK( this, TranslateWin, DoAccept ) );
+ PushButtonTT_PB_SELECT.SetClickHdl( LINK( this, TranslateWin, DoSelect ) );
+ PushButtonTT_PB_RESTORE.SetClickHdl( LINK( this, TranslateWin, DoRestore ) );
+ EditTT_E_NEW.SetModifyHdl( LINK( this, TranslateWin, TranslationChanged ) );
+ InplaceTimer.SetTimeout( 250 );
+ InplaceTimer.SetTimeoutHdl( LINK( this, TranslateWin, ShowInplace ) );
+ EnableAlwaysOnTop();
+ nEventHookID = Application::AddEventHook( stub_VCLEventHookProc, this );
+}
+
+TranslateWin::~TranslateWin()
+{
+ Application::RemoveEventHook( nEventHookID );
+}
+
+sal_Bool TranslateWin::TestChangedDataSaved()
+{
+ if ( ( EditTT_E_NEW.GetText().CompareTo( FixedTextTT_FT_OLD.GetText() ) != COMPARE_EQUAL
+ || EditTT_E_COMMENT.GetText().Len() )
+ && PushButtonTT_PB_ACCEPT.IsEnabled() )
+ {
+ return MessBox( this, TTProperties::GetSvtResId( TT_DISCARD_CHANGED_DATA ) ).Execute() == RET_YES;
+ }
+ else
+ return sal_True;
+}
+
+IMPL_LINK( TranslateWin, DoAccept, PushButton*, EMPTYARG )
+{
+ PushButtonTT_PB_SELECT.Disable();
+ PushButtonTT_PB_NEXT.Disable();
+ PushButtonTT_PB_RESTORE.Disable();
+ EditTT_E_NEW.Disable();
+ EditTT_E_COMMENT.Disable();
+ PushButtonTT_PB_ACCEPT.Disable();
+ bAvailable = sal_True;
+ return 0;
+}
+
+IMPL_LINK( TranslateWin, DoNext, PushButton*, EMPTYARG )
+{
+ if ( TestChangedDataSaved() )
+ {
+ PushButtonTT_PB_SELECT.Disable();
+ PushButtonTT_PB_NEXT.Disable();
+ PushButtonTT_PB_RESTORE.Disable();
+ EditTT_E_NEW.Disable();
+ EditTT_E_COMMENT.Disable();
+ PushButtonTT_PB_ACCEPT.Disable();
+ bNext = sal_True;
+ }
+ return 0;
+}
+
+IMPL_LINK( TranslateWin, DoSelect, PushButton*, EMPTYARG )
+{
+ if ( bSelecting )
+ {
+// ReleaseMouse();
+ bSelecting = sal_False;
+ }
+ else
+ {
+ if ( TestChangedDataSaved() )
+ {
+ PushButtonTT_PB_RESTORE.Disable();
+// CaptureMouse();
+ bSelecting = sal_True;
+ }
+ }
+ return 0;
+}
+
+IMPL_LINK( TranslateWin, DoRestore, PushButton*, EMPTYARG )
+{
+ String sTT_E_OLD( FixedTextTT_FT_OLD.GetText());
+ sTT_E_OLD.SearchAndReplaceAll( CUniString("\\n"), CUniString("\n") );
+ sTT_E_OLD.SearchAndReplaceAll( CUniString("\\t"), CUniString("\t") );
+
+ String sTT_E_NEW( EditTT_E_NEW.GetText());
+ sTT_E_NEW.SearchAndReplaceAll( CUniString("\\n"), CUniString("\n") );
+ sTT_E_NEW.SearchAndReplaceAll( CUniString("\\t"), CUniString("\t") );
+
+ if ( StatementList::WinPtrValid( pTranslateWin ) && pTranslateWin->GetText().CompareTo( sTT_E_NEW ) == COMPARE_EQUAL )
+ { // Im ersten schritt nur in der UI zurück
+ pTranslateWin->SetText( sTT_E_OLD );
+ }
+ else
+ { // Im zweite Schritt auch den eingegebenen Text
+ EditTT_E_NEW.SetText( FixedTextTT_FT_OLD.GetText() );
+ PushButtonTT_PB_RESTORE.Disable();
+ }
+ if ( StatementList::WinPtrValid( pTranslateWin ) )
+ MarkShortcutErrors( pTranslateWin->GetWindow( WINDOW_OVERLAP ), sal_True );
+ return 0;
+}
+
+IMPL_LINK( TranslateWin, TranslationChanged, Edit*, pEdit )
+{
+ (void) pEdit; /* avoid warning about unused parameter */
+ PushButtonTT_PB_RESTORE.Enable();
+ InplaceTimer.Start();
+ return 0;
+}
+
+IMPL_LINK( TranslateWin, ShowInplace, Timer*, EMPTYARG )
+{
+ PushButtonTT_PB_RESTORE.Enable();
+ if ( StatementList::WinPtrValid( pTranslateWin ) )
+ {
+ String sTT_E_NEW( EditTT_E_NEW.GetText());
+ // alle CRs UnQuoten
+ sTT_E_NEW.SearchAndReplaceAll( CUniString("\\n"), CUniString("\n") );
+ // alle TABSs UnQuoten
+ sTT_E_NEW.SearchAndReplaceAll( CUniString("\\t"), CUniString("\t") );
+ pTranslateWin->SetText( sTT_E_NEW );
+
+ MarkShortcutErrors( pTranslateWin->GetWindow( WINDOW_OVERLAP ), sal_True );
+ }
+ return 0;
+}
+
+long TranslateWin::VCLEventHook( NotifyEvent& rEvt )
+{
+ if ( EVENT_MOUSEMOVE == rEvt.GetType() )
+ {
+ if ( bSelecting )
+ {
+ const MouseEvent *pMEvt = rEvt.GetMouseEvent();
+ Old = Act;
+ Act = rEvt.GetWindow();
+
+ if ( Act )
+ {
+ Window *pWin = Act;
+ sal_uInt16 i;
+ for ( i = 0 ; i < Act->GetChildCount() ; i++ )
+ {
+ pWin = Act->GetChild(i);
+ Rectangle aWinPosSize( pWin->GetPosPixel(), pWin->GetSizePixel() );
+
+ if ( ( pWin->IsMouseTransparent() || !pWin->IsEnabled() ) && aWinPosSize.IsInside( pMEvt->GetPosPixel() ) )
+ {
+ Act = pWin;
+ break;
+ }
+ }
+ }
+
+ if ( !StatementList::WinPtrValid ( Old ) )
+ Old = NULL;
+
+ if ( Act != Old )
+ {
+ if ( Old )
+ {
+ Window *pWin;
+ if ( Old->IsMouseTransparent() && Old->GET_REAL_PARENT() )
+ pWin = Old->GET_REAL_PARENT();
+ else
+ pWin = Old;
+ RESET_WIN(pWin);
+ }
+ if ( Act )
+ {
+ SET_WIN(Act);
+ FixedTextTT_FT_OLD.SetText( Act->GetText() );
+ }
+ else
+ FixedTextTT_FT_OLD.SetText( String() );
+ }
+ else if ( Act )
+ {
+ // SET_WIN(Act);
+ }
+ /* if ( Application::GetLastInputInterval() > 5000 ) // 5 Sekunden lang nix geschehen
+ {
+ ToTop();
+ }
+ */
+ } //if ( bSelecting )
+ else
+ {
+ if ( Act )
+ {
+ if ( Act->IsMouseTransparent() && Act->GET_REAL_PARENT() )
+ Act = Act->GET_REAL_PARENT();
+ RESET_WIN(Act);
+ Act = NULL;
+ }
+ }
+ }
+ else if ( EVENT_MOUSEBUTTONUP == rEvt.GetType() )
+ {
+ if ( bSelecting )
+ {
+ pTranslateWin = Act;
+ if ( pTranslateWin )
+ {
+ MarkShortcutErrors( pTranslateWin->GetWindow( WINDOW_OVERLAP ), sal_True );
+ // alle CRs quoten (NF)
+ String sTT_E_NEW( pTranslateWin->GetText());
+ sTT_E_NEW.SearchAndReplaceAll( CUniString("\n"), CUniString("\\n") );
+ // alle TABSs quoten ()
+ sTT_E_NEW.SearchAndReplaceAll( CUniString("\t"), CUniString("\\t") );
+
+ FixedTextTT_FT_OLD.SetText( sTT_E_NEW );
+ EditTT_E_NEW.SetText( sTT_E_NEW );
+ EditTT_E_NEW.Enable();
+ EditTT_E_NEW.GrabFocus();
+ EditTT_E_COMMENT.SetText( String() );
+ EditTT_E_COMMENT.Enable();
+ PushButtonTT_PB_ACCEPT.Enable();
+ }
+ // ReleaseMouse();
+ bSelecting = sal_False;
+ }
+ }
+
+ return 0;
+}
+
+#define FDS_ACTION_COLLECT 1
+#define FDS_ACTION_MARK 2
+#define FDS_ACTION_UNMARK 3
+
+class FindShortcutErrors: public Search
+{
+ String aShortcuts,aDoubleShortcuts;
+ sal_uInt16 nAction;
+public:
+ FindShortcutErrors();
+ virtual sal_Bool IsWinOK( Window *pWin );
+ void SetAction( sal_uInt16 nA );
+ String GetDoubleShortcuts() { return aDoubleShortcuts; }
+};
+
+FindShortcutErrors::FindShortcutErrors()
+: Search( SEARCH_NOOVERLAP | SEARCH_NO_TOPLEVEL_WIN )
+{
+ SetAction( FDS_ACTION_COLLECT ); // Wir fange immer mit sammeln an, ODER??
+}
+
+void FindShortcutErrors::SetAction( sal_uInt16 nA )
+{
+ nAction = nA;
+ if ( FDS_ACTION_COLLECT == nAction )
+ {
+ aShortcuts = UniString();
+ aDoubleShortcuts = UniString();
+ }
+}
+
+sal_Bool FindShortcutErrors::IsWinOK( Window *pWin )
+{
+ if ( pWin->IsReallyVisible() )
+ {
+ String aText = pWin->GetText();
+ xub_StrLen nPos = aText.Search('~');
+ String aShortcut;
+ sal_Bool bHasAccel = sal_False;
+ if ( nPos != STRING_NOTFOUND )
+ {
+ aShortcut = aText.Copy( nPos+1, 1 );
+ aShortcut.ToLowerAscii();
+ bHasAccel = aShortcut.Len() == 1;
+ }
+
+ switch ( nAction )
+ {
+ case FDS_ACTION_COLLECT:
+ {
+ if ( aShortcuts.Search( aShortcut ) != STRING_NOTFOUND )
+ aDoubleShortcuts += aShortcut;
+ else
+ aShortcuts += aShortcut;
+ }
+ break;
+ case FDS_ACTION_MARK:
+ {
+ sal_Bool bMissing = sal_False;
+ if ( !bHasAccel && aText.Len() ) // should there be an accelarator defined
+ {
+
+ Window* pChild;
+ pChild = pWin->GetWindow( WINDOW_CLIENT );
+
+ if ( (pChild->GetType() == WINDOW_RADIOBUTTON) ||
+ (pChild->GetType() == WINDOW_IMAGERADIOBUTTON) ||
+ (pChild->GetType() == WINDOW_CHECKBOX) ||
+ (pChild->GetType() == WINDOW_TRISTATEBOX) ||
+ (pChild->GetType() == WINDOW_PUSHBUTTON) )
+ {
+ if ( !pChild->GetText().EqualsAscii( "..." ) )
+ bMissing = sal_True;
+ }
+
+ if ( pChild->GetType() == WINDOW_FIXEDTEXT )
+ {
+ Window* pTempChild = pWin->GetWindow( WINDOW_NEXT );
+ if ( pTempChild )
+ pTempChild = pTempChild->GetWindow( WINDOW_CLIENT );
+
+ if ( pTempChild && pChild->GetText().Len() )
+ {
+ if ( (pTempChild->GetType() == WINDOW_EDIT) ||
+ (pTempChild->GetType() == WINDOW_MULTILINEEDIT) ||
+ (pTempChild->GetType() == WINDOW_SPINFIELD) ||
+ (pTempChild->GetType() == WINDOW_PATTERNFIELD) ||
+ (pTempChild->GetType() == WINDOW_NUMERICFIELD) ||
+ (pTempChild->GetType() == WINDOW_METRICFIELD) ||
+ (pTempChild->GetType() == WINDOW_CURRENCYFIELD) ||
+ (pTempChild->GetType() == WINDOW_DATEFIELD) ||
+ (pTempChild->GetType() == WINDOW_TIMEFIELD) ||
+ (pTempChild->GetType() == WINDOW_LISTBOX) ||
+ (pTempChild->GetType() == WINDOW_MULTILISTBOX) ||
+ (pTempChild->GetType() == WINDOW_COMBOBOX) ||
+ (pTempChild->GetType() == WINDOW_PATTERNBOX) ||
+ (pTempChild->GetType() == WINDOW_NUMERICBOX) ||
+ (pTempChild->GetType() == WINDOW_METRICBOX) ||
+ (pTempChild->GetType() == WINDOW_CURRENCYBOX) ||
+ (pTempChild->GetType() == WINDOW_DATEBOX) ||
+ (pTempChild->GetType() == WINDOW_TIMEBOX) )
+ {
+ bMissing = sal_True;
+ }
+ }
+ }
+ }
+
+ if ( bHasAccel && aDoubleShortcuts.Search( aShortcut ) != STRING_NOTFOUND )
+ {
+ if ( pWin->GetType() == WINDOW_GROUPBOX )
+ pWin->SetControlForeground( Color( COL_LIGHTRED ) );
+ else
+ {
+ pWin->SetControlBackground();
+ Color aCol(COL_GRAY);
+ aCol.SetRed( 0xff );
+ pWin->SetControlBackground( aCol );
+ }
+ }
+ else if ( bMissing )
+ {
+ pWin->SetControlBackground();
+ Color aCol(COL_GRAY);
+ aCol.SetRed( 0xff );
+ aCol.SetGreen( 0xff );
+ pWin->SetControlBackground( aCol );
+ }
+ else
+ {
+ pWin->SetControlForeground();
+ pWin->SetControlBackground();
+ }
+ }
+ break;
+ case FDS_ACTION_UNMARK:
+ {
+ pWin->SetControlForeground();
+ pWin->SetControlBackground();
+ }
+ break;
+ }
+ }
+ else
+ if ( FDS_ACTION_MARK == nAction || FDS_ACTION_UNMARK == nAction )
+ {
+ pWin->SetControlForeground();
+ pWin->SetControlBackground();
+ }
+
+ return sal_False;
+}
+
+String TranslateWin::MarkShortcutErrors( Window* pBase, sal_Bool bMark )
+{
+ if ( pBase )
+ {
+ FindShortcutErrors aFinder;
+ if ( bMark )
+ {
+ StatementList::SearchAllWin( pBase, aFinder, sal_True ); // collect Shortcuts first
+ aFinder.SetAction( FDS_ACTION_MARK );
+ }
+ else
+ aFinder.SetAction( FDS_ACTION_UNMARK );
+ StatementList::SearchAllWin( pBase, aFinder, sal_True );
+ return aFinder.GetDoubleShortcuts();
+ }
+ return UniString();
+}
+
+void TranslateWin::EnableTranslation()
+{
+ PushButtonTT_PB_SELECT.Enable();
+ PushButtonTT_PB_NEXT.Enable();
+ bAvailable = sal_False;
+ bNext = sal_False;
+}
+
+void StatementCommand::Translate()
+{
+ // Es wurde eine initale UniqueId mitgegeben. Dann nur die dopelten Shortcuts liefern
+ if( (nParams & PARAM_STR_1) && nLNr1 )
+ {
+ String aDouble;
+ Window *pWin = SearchTree( Str2Id( aString1 ) ,sal_False );
+ if ( pWin )
+ {
+ pWin = pWin->GetWindow( WINDOW_OVERLAP );
+ aDouble = TranslateWin::MarkShortcutErrors( pWin, sal_True );
+ }
+ pRet->GenReturn ( RET_Value, nMethodId, aDouble );
+ return;
+ }
+
+ if ( !GetTTSettings()->pTranslateWin )
+ {
+ GetTTSettings()->pTranslateWin = new TranslateWin;
+ GetTTSettings()->bToTop = sal_True;
+ }
+
+ GetTTSettings()->pTranslateWin->Show();
+ if ( GetTTSettings()->bToTop )
+ {
+ GetTTSettings()->pTranslateWin->ToTop();
+ GetTTSettings()->bToTop = sal_False;
+ }
+
+// GetTTSettings()->pTranslateWin->GetWindow( WINDOW_OVERLAP )->Enable( sal_True, sal_True );
+ GetTTSettings()->pTranslateWin->GetWindow( WINDOW_OVERLAP )->EnableInput( sal_True, sal_True );
+
+ if ( GetTTSettings()->pTranslateWin->IsTranslationAvailable() )
+ {
+ String aTranslation;
+ Window* pTranslationWindow = GetTTSettings()->pTranslateWin->GetTranslationWindow();
+
+ DBG_ASSERT( pTranslationWindow, "Kein Translation Window" );
+
+ if ( WinPtrValid( pTranslationWindow ) )
+ {
+ if ( pTranslationWindow->GetType() == WINDOW_BORDERWINDOW && pTranslationWindow->GetWindow( WINDOW_CLIENT ) )
+ {
+ Window* pNew = pTranslationWindow->GetWindow( WINDOW_CLIENT );
+ // Bei Dockingwindoes das kanze Geraffel von Docking Floating überspringen
+ while ( IsDialog( pNew ) && !pNew->GetUniqueOrHelpId().getLength() && pNew->GetChildCount() == 1 )
+ pNew = pNew->GetChild( 0 );
+ pTranslationWindow = pNew;
+ }
+
+ aTranslation = CUniString("0;");
+
+ aTranslation += Id2Str( pTranslationWindow->GetUniqueOrHelpId() );
+ aTranslation += ';';
+
+ aTranslation += TypeString( pTranslationWindow->GetType() );
+ aTranslation += ';';
+
+ Window* pParentDialog = pTranslationWindow;
+ while ( pParentDialog && !IsDialog( pParentDialog ) )
+ {
+ pParentDialog = pParentDialog->GET_REAL_PARENT();
+ }
+
+ if ( pParentDialog )
+ {
+ aTranslation += Id2Str(pParentDialog->GetUniqueOrHelpId());
+ aTranslation += ';';
+ aTranslation += TypeString( pParentDialog->GetType() );
+ }
+ else
+ aTranslation.AppendAscii( "0;" ); // Zahl + leerer String
+ aTranslation += ';';
+
+ aTranslation += '\"';
+ aTranslation += GetTTSettings()->pTranslateWin->GetOriginalText();
+ aTranslation += '\"';
+
+ aTranslation += ';';
+
+ aTranslation += '\"';
+ aTranslation += GetTTSettings()->pTranslateWin->GetTranslationText();
+ aTranslation += '\"';
+
+ aTranslation += ';';
+
+ aTranslation += '\"';
+ aTranslation += GetTTSettings()->pTranslateWin->GetComment();
+ aTranslation += '\"';
+
+ // alle CRs quoten (NF)
+ aTranslation.SearchAndReplaceAll( CUniString("\n"), CUniString("\\n") );
+ // alle TABSs quoten ()
+ aTranslation.SearchAndReplaceAll( CUniString("\t"), CUniString("\\t") );
+
+ pRet->GenReturn ( RET_Value, nMethodId, aTranslation );
+ GetTTSettings()->pTranslateWin->EnableTranslation();
+ GetTTSettings()->bToTop = sal_True;
+ }
+ else
+ {
+ pRet->GenReturn ( RET_Value, nMethodId, String() );
+ GetTTSettings()->pTranslateWin->EnableTranslation();
+ ErrorBox err( GetTTSettings()->pTranslateWin, TTProperties::GetSvtResId( TT_NO_CONTROL ));
+ err.Execute();
+ GetTTSettings()->bToTop = sal_True;
+ }
+
+ }
+ else if ( GetTTSettings()->pTranslateWin->IsNextDialog() )
+ {
+ pRet->GenReturn ( RET_Value, nMethodId, CUniString("1") );
+ GetTTSettings()->pTranslateWin->ResetNextDialog();
+ GetTTSettings()->pTranslateWin->LoseFocus();
+ GetTTSettings()->bToTop = sal_True;
+ }
+ else
+ {
+ GetTTSettings()->pTranslateWin->EnableTranslation();
+ pRet->GenReturn ( RET_Value, nMethodId, String() );
+ }
+}
+
+Window* StatementCommand::GetNextOverlap( Window* pBase )
+{ // Findet irgendwelche Overlap-Fenster, die schließbar aussehen
+ // Eventuell muß noch die Auswahl verfeinert werden.
+
+ if ( pBase->GetType() != WINDOW_BORDERWINDOW )
+ pBase = pBase->GetWindow( WINDOW_OVERLAP );
+
+ Window *pControl = NULL;
+ if ( pBase->GetWindow( WINDOW_FIRSTOVERLAP ) )
+ {
+ pControl = GetNextOverlap( pBase->GetWindow( WINDOW_FIRSTOVERLAP ) );
+ }
+
+ if ( !pControl && pBase->GetWindow( WINDOW_NEXT ) )
+ {
+ pControl = GetNextOverlap( pBase->GetWindow( WINDOW_NEXT ) );
+ }
+
+ if ( !pControl )
+ {
+ Window *pTest = pBase->GetWindow( WINDOW_CLIENT );
+ if ( IsAccessable (pTest)
+ && pTest->IsEnabled()
+ && pTest->IsVisible()
+ && ((pTest->GetStyle() & WB_CLOSEABLE ) || (pBase->GetStyle() & WB_CLOSEABLE )) )
+ return pTest;
+ else
+ return NULL;
+ }
+ else
+ return pControl;
+}
+
+Window* StatementCommand::GetNextRecoverWin()
+{
+ // über die TopLevelWindows der App iterieren
+ Window* pBase = Application::GetFirstTopLevelWindow();
+ Window *pControl = NULL;
+ Window* pMyFirstDocFrame = NULL;
+ while ( pBase )
+ {
+ // zuerst weitere Fenster auf dem Fenster suchen und schliessen
+ pControl = GetNextOverlap( pBase );
+ if ( pControl && pControl->GetType() == WINDOW_HELPTEXTWINDOW )
+ {} // skip it
+ else
+ {
+ if ( pControl && pControl->IsVisible() && !IsFirstDocFrame( pControl ) && !IsIMEWin( pControl ) )
+ {
+ Window* pTB = pControl->GetChild( 0 );
+ if ( pControl->GetChildCount() == 1 && pTB->GetType() == WINDOW_TOOLBOX )
+// return pTB;
+ ; // do not act on floating toolboxes #i38796
+ else
+ return pControl;
+ }
+
+ // dann das Fenster selbst Schliessen
+ // erstes DocWin überspringen
+ // Assumption that Doc Windows are Borderwindows and ButtonDialog and such are not
+ if ( pBase->IsVisible() && !IsFirstDocFrame( pBase ) && pBase->GetType() != WINDOW_BORDERWINDOW && !IsIMEWin( pBase ) )
+ return pBase;
+
+ if ( !pMyFirstDocFrame && IsFirstDocFrame( pBase ) )
+ pMyFirstDocFrame = pBase;
+ }
+
+ pBase = Application::GetNextTopLevelWindow( pBase );
+ }
+#ifdef RESET_APPLICATION_TO_BACKING_WINDOW
+ // close the FirstDocFrame last, It will not be closed, but the Document inside will be closed.
+ if ( IsDocWin( pMyFirstDocFrame ) )
+ return pMyFirstDocFrame;
+#endif // def RESET_APPLICATION_TO_BACKING_WINDOW
+
+ return NULL;
+}
+
+sal_Bool StatementCommand::Execute()
+{
+ if ( IsError )
+ {
+#if OSL_DEBUG_LEVEL > 1
+ m_pDbgWin->AddText( "Skipping Command: " );
+ m_pDbgWin->AddText( String::CreateFromInt32( nMethodId ) );
+ m_pDbgWin->AddText( "\n" );
+ #endif
+
+ Advance();
+ delete this;
+ return sal_True;
+ }
+
+ InitProfile();
+#if OSL_DEBUG_LEVEL > 1
+ m_pDbgWin->AddText( "Executing Command: " );
+ m_pDbgWin->AddText( String::CreateFromInt32( nMethodId ) );
+ m_pDbgWin->AddText( "\n" );
+#endif
+
+
+
+
+
+#if OSL_DEBUG_LEVEL > 1
+#define REPORT_WIN_CLOSED(pControl, aInfo) \
+ _REPORT_WIN_CLOSED(pControl, aInfo) \
+ m_pDbgWin->AddText( aInfo.AppendAscii(" \"").Append( pControl->GetText() ).AppendAscii("\" geschlossen, RType = ").Append( TypeString(pControl->GetType()) ).AppendAscii(", UId = ").Append( UIdString( pControl->GetUniqueOrHelpId() ) ) );
+#else
+#define REPORT_WIN_CLOSED(pControl, aInfo) _REPORT_WIN_CLOSED(pControl, aInfo)
+#endif
+
+#define REPORT_WIN_CLOSEDc(pControl, aInfo ) \
+ REPORT_WIN_CLOSED(pControl, CUniString(aInfo) )
+
+#define _REPORT_WIN_CLOSED(pControl, aInfo) \
+ if ( aString1.Len() ) \
+ aString1 += '\n'; \
+ aString1 += aInfo; \
+ aString1.AppendAscii(" \""); \
+ aString1 += pControl->GetText(); \
+ aString1.AppendAscii("\" geschlossen, RType = ");\
+ aString1 += TypeString(pControl->GetType()); \
+ aString1.AppendAscii(", UId = "); \
+ aString1 += UIdString(pControl->GetUniqueOrHelpId());
+
+
+ switch ( nMethodId )
+ {
+ case RC_AppDelay:
+ if ( !bBool1 )
+ {
+ nLNr1 = Time().GetTime() + nNr1/10;
+ bBool1 = sal_True;
+ }
+ if ( Time().GetTime() < long(nLNr1) ) // Aktuelle Zeit kleiner Endzeit
+ return sal_False;
+ break;
+ case RC_DisplayHid:
+ if ( DisplayHID() )
+ return sal_False;
+ break;
+ case RC_ResetApplication:
+ {
+ if ( !bBool1 )
+ {
+ nRetryCount = 150; // das sollte reichen.
+ bBool1 = sal_True; // Nur beim ersten mal!
+ nNr1 = 1; // Welcher Button ist dran?
+ nLNr1 = 0; // Speichern des AppWin
+ aString1 = UniString(); // Liste der geschlossenen Fenster
+
+ // So daß nacher auch wieder alles auf Default steht
+ nUseBindings = 0;
+ bCatchGPF = sal_True;
+ bUsePostEvents = sal_True;
+
+ aSubMenuId1 = 0;
+ aSubMenuId2 = 0;
+ aSubMenuId3 = 0;
+ pMenuWindow = NULL;
+ }
+ if ( !nRetryCount )
+ ReportError( GEN_RES_STR0( S_RESETAPPLICATION_FAILED_COMPLEX ) );
+
+ Window *pControl = GetNextRecoverWin();
+
+ if ( pControl )
+ {
+ bBool2 = sal_False; // flag for wait when all windows are closed
+ pControl->GrabFocus();
+
+ if ( pControl->GetType() != WINDOW_DOCKINGWINDOW
+ && pControl->GetType() != WINDOW_FLOATINGWINDOW
+ && pControl->GetType() != WINDOW_MODELESSDIALOG
+ && pControl->GetType() != WINDOW_WORKWINDOW
+ && pControl->GetType() != WINDOW_TOOLBOX
+ && pControl->GetType() != WINDOW_BORDERWINDOW
+ && nRetryCount-- )
+ {
+ short nRT = ImpGetRType( pControl );
+
+ if ( nRT == C_TabControl && pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_TABDIALOG )
+ { // Bei Tabcontrol den zugehörigen Tabdialog nehmen
+ pControl = pControl->GET_REAL_PARENT();
+ nRT = ImpGetRType( pControl );
+ }
+
+ switch( nRT )
+ {
+ case C_ModalDlg:
+ case C_Dialog:
+ case C_TabDlg:
+ REPORT_WIN_CLOSEDc(pControl, "Dialog");
+ SET_WINP_CLOSING(pControl);
+ ((SystemWindow*)pControl)->Close();
+ break;
+ case C_WorkWin:
+ break;
+ case C_MessBox:
+ case C_InfoBox:
+ case C_WarningBox:
+ case C_ErrorBox:
+ case C_QueryBox:
+ case C_ButtonDialog:
+ {
+ ButtonDialog* pBD = (ButtonDialog*)pControl;
+ // nNr1 >= 10 bedeutet (Custom)-Buttons durchgehen
+ if ( nNr1 >= 10+pBD->GetButtonCount() ) nNr1 = 1;
+ switch( nNr1 )
+ {
+ case 5:
+ if ( pBD->GetPushButton( BUTTONID_OK ) )
+ {
+ REPORT_WIN_CLOSEDc(pControl, "Message Box (OK)");
+ SET_WINP_CLOSING(pControl);
+ pBD->EndDialog(RET_OK);
+ }
+ nNr1 = 10; // Nochmal alle Buttons der Reihe nach
+ break;
+ case 4:
+ if ( pBD->GetPushButton( BUTTONID_CANCEL ) )
+ {
+ REPORT_WIN_CLOSEDc(pControl, "Message Box (Cancel)");
+ SET_WINP_CLOSING(pControl);
+ pBD->EndDialog(RET_CANCEL);
+ }
+ nNr1++;
+ break;
+ case 3:
+ if ( pBD->GetPushButton( BUTTONID_YES ) )
+ {
+ REPORT_WIN_CLOSEDc(pControl, "Message Box (Yes)");
+ SET_WINP_CLOSING(pControl);
+ pBD->EndDialog(RET_YES);
+ }
+ nNr1++;
+ break;
+ case 2: // BUG 48239
+ case 1:
+ if ( pBD->GetPushButton( BUTTONID_NO ) )
+ {
+ REPORT_WIN_CLOSEDc(pControl, "Message Box (No)");
+ SET_WINP_CLOSING(pControl);
+ pBD->EndDialog(RET_NO);
+ }
+ nNr1++;
+ break;
+ default:
+ {
+ sal_uInt16 nID = pBD->GetButtonId( nNr1-10 );
+ if ( nID != BUTTONID_HELP )
+ {
+ REPORT_WIN_CLOSED(pControl, CUniString("Message Box (").Append( UniString::CreateFromInt32(nID) ).AppendAscii(")"));
+ SET_WINP_CLOSING(pControl);
+ pBD->EndDialog(nID);
+ }
+ nNr1++;
+ }
+ }
+ break;
+ }
+ default:
+ DBG_ERROR( "Unknown Windowtype" );
+ REPORT_WIN_CLOSEDc(pControl, "Unknown Windowtype");
+ ReportError( GEN_RES_STR0( S_RESETAPPLICATION_FAILED_UNKNOWN ), pControl->GetType() );
+ #if OSL_DEBUG_LEVEL > 1
+ m_pDbgWin->AddText( " Unbekannter Objekttyp aus UId" );
+ #endif
+ break;
+ }
+ return sal_False;
+ }
+ else
+ {
+ if ( (pControl->GetType() == WINDOW_DOCKINGWINDOW || pControl->GetType() == WINDOW_TOOLBOX) && nRetryCount-- )
+ {
+ if ( (((DockingWindow*)pControl)->GetStyle() | ((DockingWindow*)pControl)->GetFloatStyle()) & WB_CLOSEABLE )
+ {
+ REPORT_WIN_CLOSED(pControl, TypeString(pControl->GetType()));
+ SET_WINP_CLOSING(pControl);
+ ((DockingWindow*)pControl)->Close();
+
+ // Eigentlich nur bei TaskWindows! Hoffen wir mal, daß keine anderen DockingWindows dazwischen hauen.
+ if ( (Window*)nLNr1 != pControl )
+ nNr1 = 1; // Zum durchprobieren der Buttons beim Schließen
+ nLNr1 = (sal_uLong)pControl;
+
+ return sal_False;
+ }
+ }
+ if ( nRetryCount--
+ && ( (pControl->GetType() == WINDOW_FLOATINGWINDOW)
+ || (pControl->GetType() == WINDOW_MODELESSDIALOG)
+ || (pControl->GetType() == WINDOW_WORKWINDOW)
+ || (pControl->GetType() == WINDOW_BORDERWINDOW) ) )
+ {
+ // if ( pControl->GetStyle() & WB_CLOSEABLE )
+ {
+#ifdef RESET_APPLICATION_TO_BACKING_WINDOW
+ // Special handling for last Document; do not close the Frame, only the Document
+ if ( GetDocWinCount() == 1 && IsDocFrame( pControl ) )
+ {
+ if ( IsDocWin( pControl ) )
+ {
+ if ( GetDocFrameMenuBar( pControl ) )
+ {
+ MenuBar* pMenu = GetDocFrameMenuBar( pControl );
+ if ( pMenu->HasCloser() )
+ {
+ REPORT_WIN_CLOSED( pControl, TypeString(pControl->GetType()));
+ SET_WINP_CLOSING(pControl);
+
+ pMenu->GetCloserHdl().Call( pMenu );
+
+ // nur bei TaskWindows!
+ if ( (Window*)nLNr1 != pControl )
+ nNr1 = 1; // Zum durchprobieren der Buttons beim Schließen
+ nLNr1 = (sal_uLong)pControl;
+
+ return sal_False;
+ }
+ }
+ }
+ }
+ else
+#endif // def RESET_APPLICATION_TO_BACKING_WINDOW
+ {
+ REPORT_WIN_CLOSED( pControl, TypeString(pControl->GetType()));
+ SET_WINP_CLOSING(pControl);
+ ((SystemWindow*)pControl)->Close();
+
+ // Eigentlich nur bei TaskWindows!
+ if ( (Window*)nLNr1 != pControl )
+ nNr1 = 1; // Zum durchprobieren der Buttons beim Schließen
+ nLNr1 = (sal_uLong)pControl;
+
+ return sal_False;
+ }
+ }
+ }
+ }
+ }
+ // wait for some time if more windows show up
+ // E.g.: Floating toolbars on a Task which was hidden by another Task before
+ if ( !bBool2 )
+ {
+ nLNr1 = Time().GetTime() + 100; // 100 = 1 Second
+ bBool2 = sal_True;
+ }
+ if ( Time().GetTime() < long(nLNr1) ) // Aktuelle Zeit kleiner Endzeit
+ return sal_False;
+ else
+ pRet->GenReturn ( RET_Value, nMethodId, aString1);
+ }
+ break;
+ case RC_WaitSlot:
+ {
+ if ( ! (nParams & PARAM_USHORT_1) )
+ nNr1 = 1000; // defaults to 1000 = 1 Sec.
+ if ( !bBool1 )
+ {
+ nLNr1 = Time().GetTime() + nNr1/10;
+ bBool1 = sal_True;
+ }
+
+ if ( !bIsSlotInExecute )
+ pRet->GenReturn ( RET_Value, nMethodId, comm_USHORT(CONST_WSFinished) );
+ else
+ {
+ if ( Time().GetTime() < long(nLNr1) ) // Aktuelle Zeit kleiner Endzeit
+ return sal_False;
+ pRet->GenReturn ( RET_Value, nMethodId, comm_USHORT(CONST_WSTimeout) );
+ }
+ }
+ break;
+ }
+
+
+ Advance();
+
+
+ switch ( nMethodId )
+ {
+ case RC_AppDelay: // Diese Befehle werden anderswo behandelt
+ case RC_DisplayHid:
+ case RC_ResetApplication:
+ case RC_WaitSlot:
+
+ case RC_AppAbort: // Sofortiges Löschen aller Befehle
+ break;
+ case RC_Assert:
+ {
+ ByteString aAssertion( "Diese Assertion wurde vom Testtool per Befehl ausgelöst" );
+ aAssertion = ByteString( String( aAssertion, RTL_TEXTENCODING_MS_1252 ), RTL_TEXTENCODING_UTF8 );
+ DBG_ASSERT( !aString1.Len(), ByteString( aString1, RTL_TEXTENCODING_UTF8 ).GetBuffer() );
+ DBG_ASSERT( aString1.Len(), aAssertion.GetBuffer() );
+ OSL_ENSURE( !aString1.Len(), ByteString( aString1, RTL_TEXTENCODING_UTF8 ).GetBuffer() );
+ OSL_ENSURE( aString1.Len(), aAssertion.GetBuffer() );
+ }
+ break;
+ case RC_CaptureAssertions:
+#ifdef DBG_UTIL
+ if( !(nParams & PARAM_BOOL_1) || bBool1 )
+ {
+ DBG_INSTOUTERROR( DBG_OUT_TESTTOOL );
+ osl_setDebugMessageFunc( osl_TestToolDebugPrint );
+ }
+ else
+ {
+ DBG_INSTOUTERROR( DBG_OUT_MSGBOX );
+ osl_setDebugMessageFunc( pOriginal_osl_DebugMessageFunc );
+ }
+#endif
+ break;
+ case RC_Translate:
+ Translate();
+ break;
+ case RC_ApplicationBusy:
+ {
+ sal_Bool bWait = sal_False;
+ ReportError( GEN_RES_STR0( S_NO_ACTIVE_WINDOW ) );
+// if ( Application::GetAppWindow() )
+// bWait = Application::GetAppWindow()->IsWait();
+ pRet->GenReturn ( RET_Value, nMethodId, bWait );
+ break;
+ }
+ case RC_GetClipboard:
+ {
+ ::rtl::OUString aTemp;
+ ::svt::OStringTransfer::PasteString( aTemp, GetFirstDocFrame() );
+ pRet->GenReturn ( RET_Value, nMethodId, String( aTemp ) );
+ }
+ break;
+ case RC_SetClipboard:
+ ::svt::OStringTransfer::CopyString(aString1,GetFirstDocFrame());
+ break;
+ case RC_WinTree:
+ pRet->GenReturn ( RET_Value, nMethodId, Tree( NULL, 0));
+ break;
+ #if OSL_DEBUG_LEVEL > 1
+ case RC_NoDebug:
+ m_pDbgWin->bQuiet = sal_True;
+ m_pDbgWin->Hide();
+ m_pDbgWin->Clear();
+ break;
+ case RC_Debug:
+ m_pDbgWin->bQuiet = sal_False;
+ m_pDbgWin->Show();
+ break;
+ #endif
+ case RC_GPF:
+ ((TabControl*)NULL)->SetCurPageId( 12345 );
+ break;
+ case RC_GetNextCloseWindow:
+ {
+ Window *pWin = GetActive( WINDOW_BASE ); // WINDOW_ANYTYPE
+ if ( !pWin )
+ ReportError( GEN_RES_STR0( S_NO_ACTIVE_WINDOW ) );
+ else if ( !IsDialog(pWin) )
+ ReportError( GEN_RES_STR0( S_NO_DIALOG_IN_GETACTIVE ) );
+ else
+ {
+ pRet->GenReturn( RET_Value, nMethodId, Id2Str(pWin->GetUniqueOrHelpId()) );
+ }
+ }
+ break;
+ case RC_UseBindings:
+ if( !(nParams & PARAM_BOOL_1) || bBool1 )
+ nUseBindings = SFX_USE_BINDINGS;
+ else
+ nUseBindings = 0;
+ break;
+ case RC_Profile:
+ // Bei folgenden Parametern passiert folgendes:
+ // ein boolean=false Alles Profiling stoppen (Ergebnisse liefern)
+ // ein boolean=true, 1-4 ints Einteilung der Zeiten in Kästchen
+ // kein! boolean keine ints loggen jeden Befehls
+ // kein! boolean 1 int loggen alle int Millisekunden
+ // ein String wird in das Logfile übernommen(sonst passiert nichts)
+ if( !(nParams & PARAM_BOOL_1) || bBool1 )
+ {
+ if ( !pProfiler )
+ {
+ pProfiler = new TTProfiler;
+ InitProfile();
+ }
+
+ if( !(nParams & PARAM_BOOL_1) && (nParams & PARAM_USHORT_1) )
+ { // Autoprofiling: Profile nNr
+ if ( pProfiler->IsProfilingPerCommand() )
+ {
+ pProfiler->StopProfilingPerCommand();
+ }
+ pProfiler->StartAutoProfiling( nNr1 );
+
+ // Der Header ist abhängig vom Modus
+ pRet->GenReturn( RET_ProfileInfo, 0, pProfiler->GetProfileHeader() );
+ }
+ else if ( nParams & PARAM_USHORT_1 )
+ { // Partitioning initialisieren: Profile true [,nNr][,nNr][,nNr][,nNr]
+ comm_ULONG nAnzahl=0;
+ if ( nParams & PARAM_USHORT_1 ) { nAnzahl++; };
+ if ( nParams & PARAM_USHORT_2 ) { nAnzahl++; };
+ if ( nParams & PARAM_USHORT_3 ) { nAnzahl++; };
+ if ( nParams & PARAM_USHORT_4 ) { nAnzahl++; };
+
+ // Hier werden die Parameter ans Testtool zurück übertragen.
+ // Das ist zwar etwas eigenartig, aber ansonsten müsste man im Testtool
+ // die einfache Struktur der Remotebefehle aufbrechen.
+ pRet->GenReturn( RET_ProfileInfo, S_ProfileReset, nAnzahl );
+
+ // Und die einzelnen Grenzen
+ if ( nParams & PARAM_USHORT_1 ) { pRet->GenReturn( RET_ProfileInfo, S_ProfileBorder1, (comm_ULONG)nNr1 ); };
+ if ( nParams & PARAM_USHORT_2 ) { pRet->GenReturn( RET_ProfileInfo, S_ProfileBorder2, (comm_ULONG)nNr2 ); };
+ if ( nParams & PARAM_USHORT_3 ) { pRet->GenReturn( RET_ProfileInfo, S_ProfileBorder3, (comm_ULONG)nNr3 ); };
+ if ( nParams & PARAM_USHORT_4 ) { pRet->GenReturn( RET_ProfileInfo, S_ProfileBorder4, (comm_ULONG)nNr4 ); };
+
+ pProfiler->StartPartitioning();
+ }
+ else if( nParams == PARAM_STR_1 ) // Genau ein String!
+ { // Nur einen String ins Profiling aufnehmen
+ aString1 += '\n';
+ pRet->GenReturn( RET_ProfileInfo, 0, aString1 );
+ }
+ else
+ { // Normales Profiling je Kommando: profile
+ if ( pProfiler->IsAutoProfiling() )
+ {
+ pRet->GenReturn( RET_ProfileInfo, 0, pProfiler->GetAutoProfiling() );
+ pProfiler->StopAutoProfiling();
+ }
+ pProfiler->StartProfilingPerCommand();
+
+ // Der Header ist abhängig vom Modus
+ pRet->GenReturn( RET_ProfileInfo, 0, pProfiler->GetProfileHeader() );
+ }
+ }
+ else // Profiling wieder ausschalten: Profile false
+ if ( pProfiler )
+ {
+ if ( pProfiler->IsProfilingPerCommand() )
+ pProfiler->StopProfilingPerCommand();
+
+ if ( pProfiler->IsAutoProfiling() )
+ {
+ pRet->GenReturn( RET_ProfileInfo, 0, pProfiler->GetAutoProfiling() );
+ pProfiler->StopAutoProfiling();
+ }
+
+ if ( pProfiler->IsPartitioning() )
+ {
+ pRet->GenReturn( RET_ProfileInfo, S_ProfileDump, (comm_ULONG)0 );
+ pProfiler->StopPartitioning();
+ }
+
+ delete pProfiler;
+ pProfiler = NULL;
+ }
+ break;
+ case RC_MenuGetItemCount:
+ case RC_MenuGetItemId:
+ case RC_MenuGetItemPos:
+ case RC_MenuIsSeperator:
+ case RC_MenuIsItemChecked:
+ case RC_MenuIsItemEnabled:
+ case RC_MenuGetItemText:
+ case RC_MenuGetItemCommand:
+ case RC_MenuHasSubMenu:
+ case RC_MenuSelect:
+ {
+ PopupMenu *pPopup = NULL;
+ MenuBar *pMenuBar = NULL;
+ Menu *pMenu;
+
+ sal_uInt16 nErr = GetCurrentMenues( pPopup, pMenuBar, pMenu );
+
+ if ( !pMenu )
+ {
+ if ( nErr == 1 )
+ ReportError( GEN_RES_STR0( S_NO_POPUP ) );
+ else
+ ReportError( GEN_RES_STR0( S_NO_SUBMENU ) );
+ break;
+ }
+
+ sal_uInt16 nItemCount = 0;
+ switch ( nMethodId )
+ {
+ case RC_MenuGetItemCount:
+ case RC_MenuGetItemId:
+ case RC_MenuIsSeperator:
+ {
+ nItemCount = pMenu->GetItemCount();
+ if ( pMenu->GetMenuFlags() & MENU_FLAG_HIDEDISABLEDENTRIES )
+ { // jep, we have to adjust the count
+ sal_Bool bLastWasSeperator = sal_True; // sal_True for Separator at the top
+ for ( sal_uInt16 i = 0 ; i < pMenu->GetItemCount() ; i++ )
+ {
+ if ( !pMenu->IsItemEnabled( pMenu->GetItemId( i ) ) )
+ nItemCount--;
+ else
+ {
+ if ( pMenu->GetItemType( i ) == MENUITEM_SEPARATOR && bLastWasSeperator )
+ nItemCount--;
+ bLastWasSeperator = pMenu->GetItemType( i ) == MENUITEM_SEPARATOR;
+ }
+ }
+ if ( bLastWasSeperator ) // Separator at bottom
+ nItemCount--;
+ }
+ }
+ break;
+ }
+
+ // for certain methods calculate the physical index (reinserting the hidden entries)
+ sal_uInt16 nPhysicalIndex = 0;
+ switch ( nMethodId )
+ {
+ case RC_MenuGetItemId:
+ case RC_MenuIsSeperator:
+ {
+ nPhysicalIndex = nNr1;
+ if ( pMenu->GetMenuFlags() & MENU_FLAG_HIDEDISABLEDENTRIES )
+ { // jep, we have to adjust the position
+ sal_Bool bLastWasSeperator = sal_True; // sal_True for Separator at the top
+ sal_uInt16 nVisibleCount = 0;
+ for ( sal_uInt16 i = 0 ; i < pMenu->GetItemCount() && nVisibleCount < nNr1 ; i++ )
+ {
+ if ( pMenu->IsItemEnabled( pMenu->GetItemId( i ) )
+ && !( pMenu->GetItemType( i ) == MENUITEM_SEPARATOR && bLastWasSeperator ) )
+ {
+ nVisibleCount++;
+ bLastWasSeperator = pMenu->GetItemType( i ) == MENUITEM_SEPARATOR;
+ }
+ else
+ nPhysicalIndex++;
+ }
+ DBG_ASSERT( nVisibleCount == nNr1, "Adaption of Index failed: nVisibleCount != nNr1" );
+ }
+ }
+ break;
+ }
+
+
+
+ switch ( nMethodId )
+ {
+ case RC_MenuGetItemCount:
+ {
+ pRet->GenReturn ( RET_Value, nMethodId, (comm_ULONG)nItemCount );
+ }
+ break;
+ case RC_MenuGetItemId:
+ {
+ if ( ValueOK( rtl::OString(), RcString( nMethodId ),nNr1,nItemCount) )
+ pRet->GenReturn ( RET_Value, nMethodId, (comm_ULONG)pMenu->GetItemId(nPhysicalIndex-1) );
+ }
+ break;
+ case RC_MenuGetItemPos:
+ {
+ sal_uInt16 nLogicalPos = pMenu->GetItemPos(nNr1);
+ if ( MENU_ITEM_NOTFOUND != nLogicalPos && pMenu->GetMenuFlags() & MENU_FLAG_HIDEDISABLEDENTRIES )
+ { // jep, we have to adjust the position
+ if ( !pMenu->IsItemEnabled( nNr1 ) )
+ nLogicalPos = MENU_ITEM_NOTFOUND;
+ else
+ {
+ sal_Bool bLastWasSeperator = sal_False;
+ for ( int i = nLogicalPos ; i >= 0 ; i-- )
+ {
+ if ( !pMenu->IsItemEnabled( pMenu->GetItemId( sal::static_int_cast< sal_uInt16 >(i) ) ) ||
+ ( pMenu->GetItemType( sal::static_int_cast< sal_uInt16 >(i) ) == MENUITEM_SEPARATOR && bLastWasSeperator ) )
+ nLogicalPos--;
+ bLastWasSeperator = pMenu->GetItemType( sal::static_int_cast< sal_uInt16 >(i) ) == MENUITEM_SEPARATOR;
+ }
+ }
+ }
+ pRet->GenReturn ( RET_Value, nMethodId, (comm_ULONG)(nLogicalPos+1) );
+ }
+ break;
+ case RC_MenuIsSeperator:
+ {
+ if ( ValueOK( rtl::OString(), RcString( nMethodId ),nNr1,nItemCount) )
+ pRet->GenReturn ( RET_Value, nMethodId, (comm_BOOL)(pMenu->GetItemType(nPhysicalIndex-1) == MENUITEM_SEPARATOR) );
+ }
+ break;
+ case RC_MenuIsItemChecked:
+ {
+ pRet->GenReturn ( RET_Value, nMethodId, (comm_BOOL)pMenu->IsItemChecked(nNr1) );
+ }
+ break;
+ case RC_MenuIsItemEnabled:
+ {
+ pRet->GenReturn ( RET_Value, nMethodId, (comm_BOOL)pMenu->IsItemEnabled(nNr1) );
+ }
+ break;
+ case RC_MenuGetItemText:
+ {
+ pRet->GenReturn ( RET_Value, nMethodId, (String)pMenu->GetItemText(nNr1) );
+ }
+ break;
+ case RC_MenuGetItemCommand:
+ {
+ pRet->GenReturn ( RET_Value, nMethodId, (String)pMenu->GetItemCommand(nNr1) );
+ }
+ break;
+ case RC_MenuHasSubMenu:
+ {
+ pRet->GenReturn ( RET_Value, nMethodId, (sal_Bool)(pMenu->GetPopupMenu(nNr1) != NULL) );
+ }
+ break;
+ case RC_MenuSelect:
+ {
+ if ( pMenu->GetPopupMenu(nNr1) )
+ {
+ if ( !aSubMenuId1 )
+ aSubMenuId1 = nNr1;
+ else if ( !aSubMenuId2 )
+ aSubMenuId2 = nNr1;
+ else if ( !aSubMenuId3 )
+ aSubMenuId3 = nNr1;
+
+ if ( pPopup )
+ pPopup->SelectEntry(nNr1);
+ else
+ pMenuBar->SelectEntry(nNr1);
+ }
+ else
+ {
+ if ( pPopup )
+ {
+ pPopup->EndExecute(nNr1);
+ aSubMenuId1 = 0;
+ aSubMenuId2 = 0;
+ aSubMenuId3 = 0;
+ pMenuWindow = NULL;
+ }
+ else
+ {
+ pMenuBar->SelectEntry(nNr1);
+ aSubMenuId1 = 0;
+ aSubMenuId2 = 0;
+ aSubMenuId3 = 0;
+ pMenuWindow = NULL;
+ }
+ }
+ }
+ break;
+ }
+ }
+ break;
+ case RC_SetControlType:
+ {
+ DirectLog( S_QAError, GEN_RES_STR0( S_DEPRECATED ) );
+ }
+ break;
+ case RC_Kill:
+ case RC_RmDir:
+ case RC_MkDir:
+ case RC_FileCopy:
+ case RC_Name:
+ case RC_Dir:
+ case RC_FileLen:
+ case RC_FileDateTime:
+ {
+ long nErrorcode = FSYS_ERR_OK;
+ switch ( nMethodId )
+ {
+ case RC_Kill:
+ {
+ DirEntry aFile( aString1 );
+ nErrorcode = aFile.GetError();
+ if ( FSYS_ERR_OK == nErrorcode && FileStat( aFile ).IsKind( FSYS_KIND_FILE ) )
+ nErrorcode = aFile.Kill();
+ else
+ nErrorcode = FSYS_ERR_NOTAFILE;
+ }
+ break;
+ case RC_RmDir:
+ {
+ DirEntry aDir( aString1 );
+ nErrorcode = aDir.GetError();
+ if ( FSYS_ERR_OK == nErrorcode && FileStat( aDir ).IsKind( FSYS_KIND_DIR ) )
+ nErrorcode = aDir.Kill();
+ else
+ nErrorcode = FSYS_ERR_NOTADIRECTORY;
+ }
+ break;
+ case RC_MkDir:
+ {
+ DirEntry aDir( aString1 );
+ nErrorcode = aDir.GetError();
+ if ( !nErrorcode && !aDir.MakeDir() )
+ nErrorcode = FSYS_ERR_UNKNOWN;
+// Workaround für Bug 60693
+// nErrorcode = aDir.GetError();
+ }
+ break;
+ case RC_FileCopy:
+ {
+ nErrorcode = DirEntry( aString1 ).CopyTo( DirEntry( aString2 ), FSYS_ACTION_COPYFILE );
+ }
+ break;
+ case RC_Name:
+ {
+ nErrorcode = DirEntry( aString1 ).MoveTo( DirEntry( aString2 ) );
+ }
+ break;
+ case RC_Dir:
+ {
+
+ String aPath;
+ sal_uInt16 nDirFlags = 0;
+// from basic/source/inc/runtime.hxx
+#define Sb_ATTR_NORMAL 0x0000
+#define Sb_ATTR_HIDDEN 0x0002
+#define Sb_ATTR_SYSTEM 0x0004
+#define Sb_ATTR_VOLUME 0x0008
+#define Sb_ATTR_DIRECTORY 0x0010
+#define Sb_ATTR_ARCHIVE 0x0020
+ // copied from Basic and adapted basic/source/runtime/methods.cxx Revision 1.54
+ if ( (nParams & PARAM_STR_1) )
+ {
+ delete pDir;
+ pDir = NULL; // wg. Sonderbehandlung Sb_ATTR_VOLUME
+ DirEntry aEntry( aString1 );
+ FileStat aStat( aEntry );
+ if(!aStat.GetError() && (aStat.GetKind() & FSYS_KIND_FILE))
+ {
+ // OK, only a filename
+ // cut off path (VB4)
+ aPath = aEntry.GetName();
+ }
+ else
+ {
+ sal_uInt16 nFlags = 0;
+ if ( (nParams & PARAM_USHORT_1) )
+ nDirFlags = nFlags = nNr1;
+ else
+ nDirFlags = nFlags = Sb_ATTR_HIDDEN | Sb_ATTR_SYSTEM | Sb_ATTR_DIRECTORY;
+
+ // Nur diese Bitmaske ist unter Windows erlaubt
+ // Sb_ATTR_VOLUME wird getrennt gehandelt
+ if( nDirFlags & Sb_ATTR_VOLUME )
+ aPath = aEntry.GetVolume();
+ else
+ {
+ // Die richtige Auswahl treffen
+ sal_uInt16 nMode = FSYS_KIND_FILE;
+ if( nFlags & Sb_ATTR_DIRECTORY )
+ nMode |= FSYS_KIND_DIR;
+ if( nFlags == Sb_ATTR_DIRECTORY )
+ nMode = FSYS_KIND_DIR;
+ pDir = new Dir( aEntry, (DirEntryKind) nMode );
+ nErrorcode = pDir->GetError();
+ nDirPos = 0;
+ }
+ }
+ }
+
+ if( pDir )
+ {
+ for( ;; )
+ {
+ if( nDirPos >= pDir->Count() )
+ {
+ delete pDir;
+ pDir = NULL;
+ aPath.Erase();
+ break;
+ }
+ DirEntry aNextEntry=(*(pDir))[nDirPos++];
+ aPath = aNextEntry.GetName(); //Full();
+ break;
+ }
+ }
+ if ( !nErrorcode )
+ {
+ pRet->GenReturn ( RET_Value, nMethodId, aPath );
+ }
+
+
+
+/* keep old Implementation for now
+ // neues Verzeichnis einlesen
+ if ( (nParams & PARAM_STR_1) )
+ {
+ if ( pDir )
+ {
+ delete pDir;
+ pDir = NULL;
+ }
+ DirEntryKind aDirEntryKind = FSYS_KIND_FILE | FSYS_KIND_DIR;
+ if ( (nParams & PARAM_USHORT_1) && nNr1 )
+ {
+ if ( nNr1 & 16 )
+ aDirEntryKind = FSYS_KIND_DIR;
+ else
+ ReportError( GEN_RES_STR0( S_SELECTION_BY_ATTRIBUTE_ONLY_DIRECTORIES ) );
+ }
+
+ DirEntry aEntry( aString1 );
+ nErrorcode = aEntry.GetError();
+ if ( !nErrorcode )
+ {
+ nDirPos = 0;
+ FileStat aFS( aEntry );
+ if ( !aFS.IsKind( FSYS_KIND_WILD ) && !aFS.IsKind( FSYS_KIND_DIR ) && aEntry.Exists() )
+ { // Sonderbehandlung für genau einen Eintrag
+ if ( !aFS.IsKind( FSYS_KIND_DIR ) && ( aDirEntryKind == FSYS_KIND_DIR ) )
+ pRet->GenReturn ( RET_Value, nMethodId, String() );
+ else
+ pRet->GenReturn ( RET_Value, nMethodId, (String)(aEntry.GetName()) );
+
+ break;
+ }
+ else
+ {
+ pDir = new Dir( aEntry, aDirEntryKind );
+ nErrorcode = pDir->GetError();
+ }
+ }
+ }
+
+ if ( !pDir )
+ pDir = new Dir;
+
+ if ( !nErrorcode && ValueOK( nMethodId, GEN_RES_STR0( S_NO_MORE_FILES ), nDirPos+1, pDir->Count()+1 ) )
+ {
+ if ( nDirPos == pDir->Count() )
+ pRet->GenReturn ( RET_Value, nMethodId, String() );
+ else
+ pRet->GenReturn ( RET_Value, nMethodId, (String)((*pDir)[ nDirPos ].GetName()) );
+ nDirPos++;
+ }*/
+ }
+ break;
+ case RC_FileLen:
+ {
+ DirEntry aFile( aString1 );
+ nErrorcode = aFile.GetError();
+ if ( FSYS_ERR_OK == nErrorcode )
+ {
+ FileStat aFS( aFile );
+ pRet->GenReturn ( RET_Value, nMethodId, static_cast<comm_ULONG>(aFS.GetSize()) ); //GetSize() sal_uLong != comm_ULONG on 64bit
+ nErrorcode = aFS.GetError();
+ }
+ }
+ break;
+ case RC_FileDateTime:
+ {
+ DirEntry aFile( aString1 );
+ nErrorcode = aFile.GetError();
+ if ( FSYS_ERR_OK == nErrorcode )
+ {
+ FileStat aStat( aFile );
+ Time aTime( aStat.TimeModified() );
+ Date aDate( aStat.DateModified() );
+ nErrorcode = aStat.GetError();
+
+ double fSerial = (double)( aDate - Date(30,12,1899) );
+ long nSeconds = aTime.GetHour();
+ nSeconds *= 3600;
+ nSeconds += aTime.GetMin() * 60;
+ nSeconds += aTime.GetSec();
+ double nDays = ((double)nSeconds) / (double)(24.0*3600.0);
+ fSerial += nDays;
+
+ SbxValueRef xValue = new SbxValue( SbxDATE );
+ xValue->PutDate( fSerial );
+
+ pRet->GenReturn ( RET_Value, nMethodId, *xValue );
+ }
+ }
+ break;
+ }
+ switch ( nErrorcode )
+ {
+ case FSYS_ERR_OK:
+ break;
+ case FSYS_ERR_MISPLACEDCHAR:
+ {
+ ReportError( CUniString("MISPLACEDCHAR") );
+ }
+ break;
+ case FSYS_ERR_INVALIDCHAR:
+ {
+ ReportError( CUniString("INVALIDCHAR") );
+ }
+ break;
+ case FSYS_ERR_NOTEXISTS:
+ {
+ ReportError( CUniString("NOTEXISTS") );
+ }
+ break;
+ case FSYS_ERR_ALREADYEXISTS:
+ {
+ ReportError( CUniString("ALREADYEXISTS") );
+ }
+ break;
+ case FSYS_ERR_NOTADIRECTORY:
+ {
+ ReportError( CUniString("NOTADIRECTORY") );
+ }
+ break;
+ case FSYS_ERR_NOTAFILE:
+ {
+ ReportError( CUniString("NOTAFILE") );
+ }
+ break;
+ case FSYS_ERR_INVALIDDEVICE:
+ {
+ ReportError( CUniString("INVALIDDEVICE") );
+ }
+ break;
+ case FSYS_ERR_ACCESSDENIED:
+ {
+ ReportError( CUniString("ACCESSDENIED") );
+ }
+ break;
+ case FSYS_ERR_LOCKVIOLATION:
+ {
+ ReportError( CUniString("LOCKVIOLATION") );
+ }
+ break;
+ case FSYS_ERR_VOLUMEFULL:
+ {
+ ReportError( CUniString("VOLUMEFULL") );
+ }
+ break;
+ case FSYS_ERR_ISWILDCARD:
+ {
+ ReportError( CUniString("ISWILDCARD") );
+ }
+ break;
+ case FSYS_ERR_NOTSUPPORTED:
+ {
+ ReportError( CUniString("NOTSUPPORTED") );
+ }
+ break;
+ case FSYS_ERR_UNKNOWN:
+ {
+ ReportError( CUniString("UNKNOWN") );
+ }
+ break;
+ default:
+ {
+ ReportError( CUniString("Not an FSYS Error") );
+ }
+ }
+
+ }
+ break;
+ case RC_TypeKeysDelay:
+ {
+ if( (nParams & PARAM_BOOL_1) )
+ {
+ bDoTypeKeysDelay = bBool1;
+ }
+ else if( nParams & PARAM_USHORT_1 )
+ {
+ nMinTypeKeysDelay = nNr1;
+ if( nParams & PARAM_USHORT_2 )
+ nMaxTypeKeysDelay = nNr2;
+ else
+ nMaxTypeKeysDelay = nMinTypeKeysDelay;
+ }
+ else
+ ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) );
+ }
+ break;
+ case RC_GetMouseStyle:
+ {
+ Pointer aPointer;
+// if ( DragManager::GetDragManager() )
+// aPointer = DragManager::GetDragManager()->GetDragPointer();
+// else
+ {
+ Window *pActualWin = GetMouseWin();
+ if ( pActualWin )
+ aPointer = pActualWin->GetPointer();
+ else
+ {
+ ReportError( GEN_RES_STR1( S_POINTER_OUTSIDE_APPWIN, RcString( nMethodId ) ) );
+ aPointer = Pointer( POINTER_NULL );
+ }
+ }
+ pRet->GenReturn ( RET_Value, nMethodId, (comm_ULONG)aPointer.GetStyle() );
+ }
+ break;
+ case RC_UnpackStorage:
+ {
+ if( (nParams & PARAM_STR_1) )
+ {
+ String aFileName( aString1 );
+ DirEntry aDestPath;
+ if( (nParams & PARAM_STR_2) )
+ aDestPath = DirEntry( aString2 );
+ else
+ {
+ aDestPath = DirEntry( aFileName );
+ aDestPath.SetExtension( CUniString( "plaintext" ) );
+ }
+
+#if OSL_DEBUG_LEVEL > 1
+ sal_uInt16 nEntries = Dir( aDestPath, FSYS_KIND_FILE | FSYS_KIND_DIR ).Count();
+ (void) nEntries; /* avoid warning about unused parameter */
+#endif
+ // The Count is only larger than 2 is the path is a directory which is not empty
+ // the Count of 2 results from the "." and ".." directory
+ if ( Dir( aDestPath, FSYS_KIND_FILE | FSYS_KIND_DIR ).Count() > 2 )
+ DirectLog( S_QAError, GEN_RES_STR1( S_DIRECTORY_NOT_EMPTY, aDestPath.GetFull() ) );
+
+ SotStorageRef xStorage = new SotStorage( aFileName, STREAM_STD_READ );
+ if ( xStorage->GetError() )
+ ReportError( GEN_RES_STR2(S_UNPACKING_STORAGE_FAILED, aFileName, aDestPath.GetFull()) );
+ else
+ UnpackStorage( xStorage, aDestPath );
+ }
+ else
+ ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) );
+ }
+ break;
+ case RC_CloseSysDialog:
+ case RC_ExistsSysDialog:
+ {
+ if( (nParams & PARAM_USHORT_1) )
+ {
+ Reference < ::com::sun::star::util::XCancellable > xPicker;
+ switch( nNr1 )
+ {
+ case CONST_FilePicker:
+ {
+ xPicker.set( Reference < ::com::sun::star::util::XCancellable >( svt::GetTopMostFilePicker(), UNO_QUERY ) );
+ }
+ break;
+ case CONST_FolderPicker:
+ {
+ xPicker.set( Reference < ::com::sun::star::util::XCancellable >( svt::GetTopMostFolderPicker(), UNO_QUERY ) );
+ }
+ break;
+ default:
+ ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) );
+ }
+ switch( nMethodId )
+ {
+ case RC_CloseSysDialog:
+ {
+ if ( xPicker.is() )
+ xPicker->cancel();
+ else
+ ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) );
+ }
+ break;
+ case RC_ExistsSysDialog:
+ {
+ pRet->GenReturn ( RET_Value, nMethodId, (comm_BOOL)xPicker.is() );
+ }
+ break;
+ default:
+ ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) );
+ }
+ }
+ else
+ ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) );
+ }
+ break;
+ case RC_SAXCheckWellformed:
+ case RC_SAXReadFile:
+
+ case RC_SAXGetNodeType:
+ case RC_SAXGetAttributeCount:
+ case RC_SAXGetAttributeName:
+ case RC_SAXGetAttributeValue:
+ case RC_SAXGetChildCount:
+ case RC_SAXGetElementName:
+ case RC_SAXGetChars:
+
+ case RC_SAXSeekElement:
+ case RC_SAXHasElement:
+ case RC_SAXGetElementPath:
+
+ case RC_SAXRelease:
+ {
+ HandleSAXParser();
+ }
+ break;
+ case RC_RecordMacro:
+ {
+ if ( ! (nParams & PARAM_BOOL_1) )
+ bBool1 = sal_True;
+
+ MacroRecorder::GetMacroRecorder()->SetActionRecord( bBool1 );
+ }
+ break;
+ case RC_GetDocumentCount :
+ {
+ pRet->GenReturn ( RET_Value, nMethodId, (comm_USHORT)GetDocWinCount() );
+ }
+ break;
+ case RC_ActivateDocument :
+ {
+ if( nParams & PARAM_USHORT_1 )
+ {
+ if ( ValueOK( rtl::OString(), RcString( nMethodId ), nNr1, GetDocWinCount() ) )
+ {
+ Window* pWin = GetDocWin( nNr1-1 );
+ if ( pWin )
+ {
+ pWin->ToTop();
+ pWin->GrabFocus();
+ }
+ }
+ }
+ else
+ ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) );
+ }
+ break;
+ case RC_GetSystemLanguage :
+ {
+ pRet->GenReturn ( RET_Value, nMethodId, (comm_USHORT)Application::GetSettings().GetLanguage() );
+ }
+ break;
+ case RC_CatchGPF :
+ {
+ if( (nParams & PARAM_BOOL_1) )
+ bCatchGPF = bBool1;
+ else
+ bCatchGPF = sal_True;
+ }
+ break;
+ case RC_IsProduct :
+ {
+ sal_Bool bIsProduct;
+ #ifdef DBG_UTIL
+ bIsProduct = sal_False;
+ #else
+ bIsProduct = sal_True;
+ #endif
+ pRet->GenReturn ( RET_Value, nMethodId, (sal_Bool)bIsProduct );
+ }
+ break;
+ case RC_UsePostEvents :
+ {
+ if( (nParams & PARAM_BOOL_1) )
+ bUsePostEvents = bBool1;
+ else
+ bUsePostEvents = sal_True;
+ }
+ break;
+ default:
+ ReportError( GEN_RES_STR1( S_UNKNOWN_COMMAND, RcString( nMethodId ) ) );
+ }
+ SendProfile( RcString(nMethodId) );
+ delete this;
+ return sal_True;
+}
+
+
+sal_Bool StatementCommand::UnpackStorage( SotStorageRef xStorage, DirEntry &aBaseDir )
+{
+ SvStorageInfoList aList;
+ xStorage->FillInfoList( &aList );
+
+ for( sal_uInt16 i = 0; i < aList.Count(); i++ )
+ {
+ SvStorageInfo& rInfo = aList.GetObject( i );
+ String aName = rInfo.GetName();
+ DirEntry aPath ( aBaseDir );
+ aPath += DirEntry( aName );
+ sal_Bool bIsStorage = xStorage->IsStorage( aName );
+ if ( bIsStorage )
+ {
+ SotStorageRef xSubStorage = xStorage->OpenSotStorage( aName, STREAM_STD_READ );
+ if ( xSubStorage->GetError() )
+ {
+ ReportError( GEN_RES_STR2(S_UNPACKING_STORAGE_FAILED, aName, aPath.GetFull()) );
+ return sal_False;
+ }
+ UnpackStorage( xSubStorage, aPath );
+ }
+ else
+ {
+ if ( !aPath.MakeDir( sal_True ) )
+ {
+ ReportError( GEN_RES_STR1(S_CANNOT_CREATE_DIRECTORY, aPath.GetFull()) );
+ return sal_False;
+ }
+ SotStorageStreamRef xStream = xStorage->OpenSotStream( aName, STREAM_STD_READ );
+ SvFileStream aDestination( aPath.GetFull(), STREAM_STD_READWRITE | STREAM_TRUNC );
+ (*xStream) >> aDestination;
+ if ( aDestination.GetError() != ERRCODE_NONE )
+ {
+ ReportError( GEN_RES_STR2(S_UNPACKING_STORAGE_FAILED, aName, aPath.GetFull()) );
+ return sal_False;
+ }
+ aDestination.Close();
+ }
+ }
+ return sal_True;
+}
+
+
+// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+StatementControl::StatementControl( SCmdStream *pCmdIn, sal_uInt16 nControlIdType )
+: StatementList()
+, nNr1( 0 )
+, nNr2( 0 )
+, nNr3( 0 )
+, nNr4( 0 )
+, nLNr1( 0 )
+, aString1()
+, aString2()
+, bBool1(sal_False)
+, bBool2(sal_False)
+{
+ QueStatement( NULL );
+ //HELPID BACKWARD (SIControl is no longer needed)
+ if ( nControlIdType == SIControl )
+ {
+ comm_ULONG nId;
+ pCmdIn->Read( nId );
+ aUId = rtl::OString( nId );
+ if ( nId == 0 )
+ aUId = UID_ACTIVE;
+ else
+ ReportError( aUId, GEN_RES_STR1c( S_INTERNAL_ERROR, "using numeric HelpID from old Testtool" ) );
+ }
+ else if ( nControlIdType == SIStringControl )
+ {
+ String aId;
+ pCmdIn->Read( aId );
+ aUId = Str2Id( aId );
+ }
+ else
+ {
+ DBG_ERROR( "Wrong ControlType" );
+ }
+
+ pCmdIn->Read( nMethodId );
+ pCmdIn->Read( nParams );
+
+ if( nParams & PARAM_USHORT_1 ) pCmdIn->Read( nNr1 );
+ if( nParams & PARAM_USHORT_2 ) pCmdIn->Read( nNr2 );
+ if( nParams & PARAM_USHORT_3 ) pCmdIn->Read( nNr3 );
+ if( nParams & PARAM_USHORT_4 ) pCmdIn->Read( nNr4 );
+ if( nParams & PARAM_ULONG_1 ) pCmdIn->Read( nLNr1 );
+ if( nParams & PARAM_STR_1 ) pCmdIn->Read( aString1 );
+ if( nParams & PARAM_STR_2 ) pCmdIn->Read( aString2 );
+ if( nParams & PARAM_BOOL_1 ) pCmdIn->Read( bBool1 );
+ if( nParams & PARAM_BOOL_2 ) pCmdIn->Read( bBool2 );
+
+#if OSL_DEBUG_LEVEL > 1
+ m_pDbgWin->AddText( "Reading Control: UId: " );
+ m_pDbgWin->AddText( Id2Str( aUId ) );
+ m_pDbgWin->AddText( " Methode: " );
+ m_pDbgWin->AddText( String::CreateFromInt32( nMethodId ) );
+ m_pDbgWin->AddText( " Params:" );
+ if( nParams & PARAM_USHORT_1 ) {m_pDbgWin->AddText( " n1:" );m_pDbgWin->AddText( String::CreateFromInt32( nNr1 ) );}
+ if( nParams & PARAM_USHORT_2 ) {m_pDbgWin->AddText( " n2:" );m_pDbgWin->AddText( String::CreateFromInt32( nNr2 ) );}
+ if( nParams & PARAM_USHORT_3 ) {m_pDbgWin->AddText( " n3:" );m_pDbgWin->AddText( String::CreateFromInt32( nNr3 ) );}
+ if( nParams & PARAM_USHORT_4 ) {m_pDbgWin->AddText( " n4:" );m_pDbgWin->AddText( String::CreateFromInt32( nNr4 ) );}
+ if( nParams & PARAM_ULONG_1 ) {m_pDbgWin->AddText( " nl1:" );m_pDbgWin->AddText( String::CreateFromInt64( nLNr1 ) );}
+ if( nParams & PARAM_STR_1 ) {m_pDbgWin->AddText( " s1:" );m_pDbgWin->AddText( aString1 );}
+ if( nParams & PARAM_STR_2 ) {m_pDbgWin->AddText( " s2:" );m_pDbgWin->AddText( aString2 );}
+/* if( nParams & PARAM_BOOL_1 ) pCmdIn->Read( bBool1 );
+ if( nParams & PARAM_BOOL_2 ) pCmdIn->Read( bBool2 );*/
+ m_pDbgWin->AddText( "\n" );
+#endif
+}
+
+sal_Bool IsDialog(Window *pWin)
+{ // Alles was von SystemWindow abgeleitet ist
+ if ( !pWin )
+ return sal_False;
+
+ switch (pWin->GetType())
+ {
+ case WINDOW_FLOATINGWINDOW:
+ case WINDOW_DOCKINGWINDOW:
+ case WINDOW_MODELESSDIALOG:
+ case WINDOW_DIALOG:
+ case WINDOW_MODALDIALOG:
+ case WINDOW_WORKWINDOW:
+ case WINDOW_TABDIALOG:
+
+ case WINDOW_MESSBOX:
+ case WINDOW_INFOBOX:
+ case WINDOW_WARNINGBOX:
+ case WINDOW_ERRORBOX:
+ case WINDOW_QUERYBOX:
+ case WINDOW_BUTTONDIALOG:
+ case WINDOW_FILEDIALOG:
+ case WINDOW_PRINTDIALOG:
+ case WINDOW_PRINTERSETUPDIALOG:
+
+// ab hier nicht ansprechbar (da nicht implementiert)
+ case WINDOW_SYSWINDOW:
+ case WINDOW_SYSTEMDIALOG:
+ case WINDOW_COLORDIALOG:
+ case WINDOW_FONTDIALOG:
+ case WINDOW_PATHDIALOG:
+
+
+ return sal_True;
+// break;
+ default:
+ return sal_False;
+// break;
+ }
+}
+
+
+sal_Bool IsAccessable(Window *pWin)
+{
+ if ( pWin == NULL )
+ return sal_False;
+
+ return pWin->IsEnabled() && pWin->IsInputEnabled();
+}
+
+
+
+// neue Hilfsfunktion
+static Window*ImpGetButton( Window *pBase, WinBits nMask, WinBits nWinBits )
+{
+ sal_uInt16 n = pBase->GetChildCount();
+ for( sal_uInt16 i = 0 ; i < n; i++ ) {
+ Window *pChild = pBase->GetChild(i);
+ if( pChild->GetType() == WINDOW_OKBUTTON
+ || pChild->GetType() == WINDOW_CANCELBUTTON
+ || pChild->GetType() == WINDOW_HELPBUTTON
+ || pChild->GetType() == WINDOW_PUSHBUTTON )
+ if( !nMask || ( pChild->GetStyle() & nMask ) == nWinBits )
+ return pChild;
+ }
+ return NULL;
+}
+
+sal_Bool StatementControl::ControlOK( Window *pControl, const sal_Char* cBezeichnung )
+{
+ if ( pControl && ( ( ( IsAccessable(pControl) || (nMethodId & M_WITH_RETURN) ) &&
+ pControl->IsVisible() ) ||
+ aUId.equals( UID_ACTIVE ) ) )
+ return sal_True;
+ else
+ {
+ UniString aBezeichnung( cBezeichnung, RTL_TEXTENCODING_ASCII_US );
+ if ( aBezeichnung.Len() > 0 )
+ {
+ if (!pControl)
+ ReportError( aUId, GEN_RES_STR1( S_WIN_NOT_FOUND, aBezeichnung ) );
+ else if ( !pControl->IsVisible() )
+ ReportError( aUId, GEN_RES_STR1( S_WIN_INVISIBLE, aBezeichnung ) );
+ else
+ ReportError( aUId, GEN_RES_STR1( S_WIN_DISABLED, aBezeichnung ) );
+ }
+ #if OSL_DEBUG_LEVEL > 1
+ m_pDbgWin->AddText( aBezeichnung.AppendAscii(" NotFound or Disabled or Invisible") );
+ #endif
+
+ return sal_False;
+ }
+}
+
+
+sal_Bool StatementList::ValueOK( rtl::OString aId, String aBezeichnung, sal_uLong nValue, sal_uLong nMax )
+{
+
+ if ( nMax < nValue )
+ {
+ if ( aBezeichnung.Len() > 0 )
+ ReportError( aId, GEN_RES_STR3( S_NUMBER_TOO_BIG, aBezeichnung, UniString::CreateFromInt32( nValue ), UniString::CreateFromInt32( nMax ) ) );
+ return sal_False;
+ }
+ if ( nValue < 1 )
+ {
+ if ( aBezeichnung.Len() > 0 )
+ ReportError( aId, GEN_RES_STR3c3( S_NUMBER_TOO_SMALL, aBezeichnung, UniString::CreateFromInt32( nValue ), "1" ) );
+ return sal_False;
+ }
+ return sal_True;
+}
+
+sal_uInt16 StatementList::GetCurrentMenues( PopupMenu *&pPopup, MenuBar *&pMenuBar, Menu *&pMenu )
+{
+ if ( WinPtrValid( pMenuWindow ) )
+ pMenuBar = pMenuWindow->GetMenuBar();
+
+ if ( pMenuBar ) // use MenuBar as base
+ pMenu = pMenuBar;
+ else // use contextmenu as base
+ {
+ pMenu = PopupMenu::GetActivePopupMenu();
+ pPopup = PopupMenu::GetActivePopupMenu();
+ }
+
+ if ( !pMenu )
+ return 1;
+
+ if ( aSubMenuId1 )
+ {
+ pPopup = pMenu->GetPopupMenu( aSubMenuId1 );
+ pMenu = pPopup;
+ }
+
+ if ( pMenu && aSubMenuId2 )
+ {
+ pPopup = pMenu->GetPopupMenu( aSubMenuId2 );
+ pMenu = pPopup;
+ }
+
+ if ( pMenu && aSubMenuId3 )
+ {
+ pPopup = pMenu->GetPopupMenu( aSubMenuId3 );
+ pMenu = pPopup;
+ }
+
+ return 0;
+}
+
+void StatementControl::AnimateMouse( Window *pControl, TTHotSpots aWohin )
+{
+ Point aZiel;
+
+ switch (aWohin)
+ {
+ case MitteLinks:
+ {
+ long nHeight = pControl->GetSizePixel().Height();
+ aZiel.X() += 5;
+ aZiel.Y() += nHeight / 2;
+ }
+ break;
+ case Mitte:
+ {
+ Size aSize = pControl->GetOutputSizePixel();
+ aZiel.Move( aSize.Width() / 2, aSize.Height() / 2 );
+ }
+ break;
+ case MitteOben:
+ {
+ long nWidth = pControl->GetSizePixel().Width();
+ aZiel.X() += nWidth / 2;
+ aZiel.Y() += 5;
+ }
+ break;
+ }
+ AnimateMouse( pControl, aZiel );
+}
+
+
+void StatementControl::AnimateMouse( Window *pControl, Point aWohin )
+{
+ Point aAkt = pControl->GetPointerPosPixel();
+ Point aZiel = aWohin;
+
+ long nSteps;
+ Point aDiff = aAkt - aZiel;
+
+ if ( Abs(aDiff.X()) < Abs(aDiff.Y()) )
+ nSteps = Abs(aDiff.Y()) / 5;
+ else
+ nSteps = Abs(aDiff.X()) / 5;
+ if ( nSteps == 0 )
+ return;
+
+ aDiff *= 1000;
+ aDiff /= nSteps;
+
+ StatementList::bExecuting = sal_True; // Bah ist das ein ekliger Hack
+ // Das verhindert, daß schon der nächste Befehl ausgeführt wird.
+
+ for ( ; nSteps ; nSteps-- )
+ {
+ if ( Abs((aAkt - pControl->GetPointerPosPixel()).X()) > 5 ||
+ Abs((aAkt - pControl->GetPointerPosPixel()).Y()) > 5 )
+ nSteps = 1;
+ aAkt = aZiel + aDiff * nSteps / 1000;
+ pControl->SetPointerPosPixel(aAkt);
+ SafeReschedule();
+ }
+ pControl->SetPointerPosPixel(aZiel);
+ StatementList::bExecuting = sal_False; // Bah ist das ein ekliger Hack
+}
+
+
+sal_Bool StatementControl::MaybeDoTypeKeysDelay( Window *pTestWindow )
+{
+ if ( bDoTypeKeysDelay )
+ {
+ sal_uLong nTimeWait = nMinTypeKeysDelay;
+ if ( nMaxTypeKeysDelay != nMinTypeKeysDelay )
+ nTimeWait += Time::GetSystemTicks() % ( nMaxTypeKeysDelay - nMinTypeKeysDelay );
+ Timer aTimer;
+ aTimer.SetTimeout( nTimeWait );
+ aTimer.Start();
+ StatementList::bExecuting = sal_True; // Bah ist das ein ekliger Hack
+ // Das verhindert, daß schon der nächste Befehl ausgeführt wird.
+ while ( aTimer.IsActive() )
+ {
+ SafeReschedule( sal_True );
+ }
+ StatementList::bExecuting = sal_False; // Bah ist das ein ekliger Hack
+ if ( !WinPtrValid(pTestWindow ) )
+ {
+ ReportError( aUId, GEN_RES_STR1( S_WINDOW_DISAPPEARED, MethodString( nMethodId ) ) );
+ return sal_False;
+ }
+ }
+ return sal_True;
+}
+
+sal_Bool StatementControl::HandleVisibleControls( Window *pControl )
+{
+ if( pControl ) // Also auch bei Disabled nicht jedoch bei Invisible
+ {
+ switch( nMethodId )
+ {
+ case M_IsEnabled:
+ pRet->GenReturn ( RET_Value, aUId, IsAccessable(pControl) );
+ break;
+ case M_IsVisible:
+ pRet->GenReturn ( RET_Value, aUId, pControl->IsVisible() );
+ break;
+ case M_GetPosX:
+ if ( pControl->GetType() == WINDOW_DOCKINGWINDOW && pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_FLOATINGWINDOW )
+ pControl = pControl->GET_REAL_PARENT(); // Sonderbehandlung für FloatingWindows
+ if ( pControl->GetType() == WINDOW_TABCONTROL && pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_TABDIALOG )
+ pControl = pControl->GET_REAL_PARENT(); // Sonderbehandlung für TabDialoge
+ if ( pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_BORDERWINDOW )
+ pControl = pControl->GET_REAL_PARENT(); // Sonderbehandlung für Border
+ if ( (nParams & PARAM_BOOL_1) && bBool1 )
+ pControl = pControl->GetWindow( WINDOW_OVERLAP );
+
+ if ( pControl->GetType() == WINDOW_DOCKINGWINDOW && pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_SPLITWINDOW )
+ {
+ Point aPos = pControl->GetPosPixel();
+ aPos = pControl->GET_REAL_PARENT()->OutputToScreenPixel( aPos );
+ pRet->GenReturn ( RET_Value, aUId, (comm_ULONG)aPos.X() );
+ }
+ else
+ pRet->GenReturn ( RET_Value, aUId, (comm_ULONG)pControl->GetPosPixel().X() );
+ break;
+ case M_GetPosY:
+ if ( pControl->GetType() == WINDOW_DOCKINGWINDOW && pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_FLOATINGWINDOW )
+ pControl = pControl->GET_REAL_PARENT(); // Sonderbehandlung für FloatingWindows
+ if ( pControl->GetType() == WINDOW_TABCONTROL && pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_TABDIALOG )
+ pControl = pControl->GET_REAL_PARENT(); // Sonderbehandlung für TabDialoge
+ if ( pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_BORDERWINDOW )
+ pControl = pControl->GET_REAL_PARENT(); // Sonderbehandlung für Border
+ if ( (nParams & PARAM_BOOL_1) && bBool1 )
+ pControl = pControl->GetWindow( WINDOW_OVERLAP );
+
+ if ( pControl->GetType() == WINDOW_DOCKINGWINDOW && pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_SPLITWINDOW )
+ {
+ Point aPos = pControl->GetPosPixel();
+ aPos = pControl->GET_REAL_PARENT()->OutputToScreenPixel( aPos );
+ pRet->GenReturn ( RET_Value, aUId, (comm_ULONG)aPos.Y() );
+ }
+ else
+ pRet->GenReturn ( RET_Value, aUId, (comm_ULONG)pControl->GetPosPixel().Y() );
+ break;
+ case M_GetSizeX:
+ if ( pControl->GetType() == WINDOW_DOCKINGWINDOW && pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_FLOATINGWINDOW )
+ pControl = pControl->GET_REAL_PARENT(); // Sonderbehandlung für FloatingWindows
+ if ( pControl->GetType() == WINDOW_TABCONTROL && pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_TABDIALOG )
+ pControl = pControl->GET_REAL_PARENT(); // Sonderbehandlung für TabDialoge
+ if ( pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_BORDERWINDOW )
+ pControl = pControl->GET_REAL_PARENT(); // Sonderbehandlung für Border
+ if ( (nParams & PARAM_BOOL_1) && bBool1 )
+ pControl = pControl->GetWindow( WINDOW_OVERLAP );
+
+ pRet->GenReturn ( RET_Value, aUId, (comm_ULONG)pControl->GetSizePixel().Width() );
+ break;
+ case M_GetSizeY:
+ if ( pControl->GetType() == WINDOW_DOCKINGWINDOW && pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_FLOATINGWINDOW )
+ pControl = pControl->GET_REAL_PARENT(); // Sonderbehandlung für FloatingWindows
+ if ( pControl->GetType() == WINDOW_TABCONTROL && pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_TABDIALOG )
+ pControl = pControl->GET_REAL_PARENT(); // Sonderbehandlung für TabDialoge
+ if ( pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_BORDERWINDOW )
+ pControl = pControl->GET_REAL_PARENT(); // Sonderbehandlung für Border
+ if ( (nParams & PARAM_BOOL_1) && bBool1 )
+ pControl = pControl->GetWindow( WINDOW_OVERLAP );
+
+ pRet->GenReturn ( RET_Value, aUId, (comm_ULONG)pControl->GetSizePixel().Height() );
+ break;
+ case M_SnapShot:
+ {
+ if ( pControl->GetType() == WINDOW_DOCKINGWINDOW && pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_FLOATINGWINDOW )
+ pControl = pControl->GET_REAL_PARENT(); // Sonderbehandlung für FloatingWindows
+ if ( pControl->GetType() == WINDOW_TABCONTROL && pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_TABDIALOG )
+ pControl = pControl->GET_REAL_PARENT(); // Sonderbehandlung für TabDialoge
+ if ( pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_BORDERWINDOW )
+ pControl = pControl->GET_REAL_PARENT(); // Sonderbehandlung für Border
+ if ( (nParams & PARAM_BOOL_1) && bBool1 )
+ pControl = pControl->GetWindow( WINDOW_OVERLAP );
+
+ Bitmap aBmp = pControl->SnapShot();
+ if ( pControl->GetType() == WINDOW_WORKWINDOW )
+ {
+ Point aStart = pControl->GetPosPixel();
+ if ( !(nParams & PARAM_USHORT_4) )
+ {
+ nParams |= PARAM_USHORT_1;
+ nParams |= PARAM_USHORT_2;
+ nParams |= PARAM_USHORT_3;
+ nParams |= PARAM_USHORT_4;
+ nNr1 = (sal_uInt16)-aStart.X();
+ nNr2 = (sal_uInt16)-aStart.Y();
+ nNr3 = (sal_uInt16)pControl->GetSizePixel().Width() + 2*(sal_uInt16)aStart.X();
+ nNr4 = (sal_uInt16)pControl->GetSizePixel().Height() + 2*(sal_uInt16)aStart.Y();
+ }
+ nNr1 = std::max((sal_uInt16)-aStart.X(),nNr1);
+ nNr2 = std::max((sal_uInt16)-aStart.Y(),nNr2);
+ nNr3 = std::min((sal_uInt16)(pControl->GetSizePixel().Width() + 2*(sal_uInt16)aStart.X()),nNr3);
+ nNr4 = std::min((sal_uInt16)(pControl->GetSizePixel().Height() + 2*(sal_uInt16)aStart.Y()),nNr4);
+ }
+ if( nParams & PARAM_USHORT_4 )
+ { // Zuschneiden
+ Point aPt(-nNr1,-nNr2);
+ Size aSz(nNr3,nNr4);
+ VirtualDevice aVDev( *pControl );
+
+ aVDev.SetOutputSizePixel( aSz );
+ aVDev.DrawBitmap( aPt, aBmp );
+ aBmp = aVDev.GetBitmap( Point(), aSz );
+ }
+
+ SvFileStream fOut;
+ fOut.Open(aString1,STREAM_STD_WRITE);
+ aBmp.Write(fOut);
+ if ( fOut.GetError() )
+ ReportError( aUId, GEN_RES_STR1( S_ERROR_SAVING_IMAGE, UniString::CreateFromInt32( fOut.GetError() ) ) );
+ fOut.Close();
+ }
+ break;
+ case M_GetFixedTextCount:
+ {
+ pRet->GenReturn ( RET_Value, aUId, CountWinByRT( pControl, WINDOW_FIXEDTEXT, sal_True ) );
+ }
+ break;
+ case M_GetFixedText:
+ {
+ if( ( nParams & PARAM_USHORT_1 ) == 0 )
+ nNr1 = 1;
+
+ FixedText* pFixedText = (FixedText*)GetWinByRT( pControl, WINDOW_FIXEDTEXT, sal_True, nNr1-1 );
+ if ( pFixedText )
+ pRet->GenReturn ( RET_Value, aUId, pFixedText->GetText() );
+ else
+ ValueOK(aUId, MethodString( nMethodId ),nNr1,CountWinByRT( pControl, WINDOW_FIXEDTEXT, sal_True ) );
+ }
+ break;
+ default:
+ return sal_False;
+ }
+ SendProfile( UIdString( aUId ).Append('.').Append( MethodString( nMethodId ) ) );
+ return sal_True;
+ }
+ return sal_False;
+}
+
+sal_Bool StatementControl::HandleCommonMethods( Window *pControl )
+{
+ switch( nMethodId ) // Diese können an jedem Window ausgeführt werden
+ {
+ case M_Exists: // Oben schon Behandelt. Unterdrückt hier nur Fehler
+ case M_NotExists:
+ case M_IsEnabled:
+ case M_IsVisible:
+ case M_SnapShot:
+ break;
+ case M_Caption :
+ {
+ if ( pControl->GetText().Len() == 0 && IsDocFrame( pControl->GetWindow( WINDOW_FRAME ) ) )
+ pRet->GenReturn ( RET_Value, aUId, pControl->GetWindow( WINDOW_FRAME )->GetText());
+ else
+ pRet->GenReturn ( RET_Value, aUId, pControl->GetText());
+ }
+ break;
+ case M_GetRT:
+ {
+ pRet->GenReturn ( RET_Value, aUId, (comm_ULONG)pControl->GetType() );
+ }
+ break;
+ case M_TypeKeys:
+ {
+ if( !(nParams & PARAM_USHORT_1) ) // Anzahl wiederholungen
+ nNr1 = 1;
+ if( !(nParams & PARAM_BOOL_1) ) // Follow Focus
+ bBool1 = sal_False; // so bleibt das bisherige Verhalten
+
+ if ( !bBool1 ) // Altes Verhalten
+ pControl->GrabFocus();
+ else // If focus is not inside given control we grab it once.
+ {
+ Window *pFocus = GetpApp()->GetFocusWindow();
+ if ( !pFocus || !pControl->IsWindowOrChild( pFocus, sal_True ) )
+ pControl->GrabFocus();
+ }
+
+
+ // maybe this can get removed since we are using GetPreferredKeyInputWindow()
+ if ( pControl->GetType() == WINDOW_COMBOBOX )
+ { // Bei COMBOBOX an das Edit direkt liefern
+ Window *pTemp = NULL;
+ for ( sal_uInt16 i = 0 ; i < pControl->GetChildCount() && !pTemp ; i++ )
+ if ( pControl->GetChild( i )->GetType() == WINDOW_EDIT )
+ pTemp = pControl->GetChild( i );
+ if ( pTemp )
+ pControl = pTemp;
+ }
+
+ Window *pDeliverHere = pControl;
+ for (int j = 0; j < nNr1; j++)
+ for (xub_StrLen i = 0; i < aString1.Len(); i++)
+ {
+ if ( StatementList::bUsePostEvents )
+ { // grab focus every time
+ Window *pFocus = GetpApp()->GetFocusWindow();
+ if ( !pFocus || !pControl->IsWindowOrChild( pFocus, sal_True ) )
+ pControl->GrabFocus();
+ }
+ if ( bBool1 ) // Jedesmal das FocusWindow finden
+ {
+ Window *pFocus = GetpApp()->GetFocusWindow();
+ if ( pFocus && pControl->IsWindowOrChild( pFocus, sal_True ) )
+ pDeliverHere = pFocus;
+ else // sonst fallback auf das Basisfenster
+ pDeliverHere = pControl;
+ }
+ pDeliverHere = pDeliverHere->GetPreferredKeyInputWindow();
+ KeyEvent aEvent;
+ if ( ((sal_uInt16)aString1.GetChar(i)) <= 7 )
+ {
+ sal_uInt16 nVal = 0;
+ switch (aString1.GetChar(i))
+ {
+ case 1: nVal = aString1.GetChar(i+1) + (aString1.GetChar(i+2) << 8);
+ i += 2;
+ break;
+ case 3: nVal = (aString1.GetChar(i+1) << 8);
+ i++;
+ break;
+ case 5: nVal = aString1.GetChar(i+1);
+ i++;
+ break;
+ case 7: nVal = 0;
+ break;
+ }
+ // #105672#
+ // find out the keycode
+ sal_uInt16 nKeygroup = nVal & KEYGROUP_TYPE;
+ sal_uInt16 nKeyCode = nVal & KEY_CODE;
+ sal_Unicode aCh;
+ switch (nKeygroup)
+ {
+ case KEYGROUP_NUM:
+ aCh = nKeyCode - KEY_0 + '0';
+ break;
+ case KEYGROUP_ALPHA:
+ aCh = nKeyCode - KEY_A;
+ if ( nVal & KEY_MOD1 )
+ {}
+ else if ( nVal & KEY_SHIFT )
+ aCh += 'A';
+ else
+ aCh += 'a';
+ break;
+ case KEYGROUP_MISC:
+ { // CR ESC TAB BACK
+ ByteString aPrintableMisc("\x0d\x1b\x09\x08 **+-*/.,<>=",16);
+ if ( nKeyCode-KEY_RETURN < aPrintableMisc.Len()
+ && nKeyCode != KEY_INSERT && nKeyCode != KEY_DELETE )
+ aCh = aPrintableMisc.GetChar( nKeyCode-KEY_RETURN );
+ else
+ aCh = 0;
+ }
+ break;
+ case KEYGROUP_CURSOR:
+ case KEYGROUP_FKEYS:
+ default:
+ aCh = 0;
+ }
+ aEvent = KeyEvent(aCh,KeyCode(nVal & 0xFFF,nVal & 0xF000));
+ }
+ else
+ {
+ // CR ESC TAB BACK
+ String aPrintableMisc = CUniString("\x0d\x1b\x09\x08 xx+-*/.,<>=");
+ sal_Unicode aCh = aString1.GetChar(i);
+ if ( aCh >= 'a' && aCh <= 'z' )
+ aEvent = KeyEvent(aCh, KeyCode(KEYGROUP_ALPHA + aCh-'a', 0));
+ else if ( aCh >= 'A' && aCh <= 'Z' )
+ aEvent = KeyEvent(aCh, KeyCode(KEYGROUP_ALPHA + aCh-'a', KEY_SHIFT));
+ else if ( aCh >= '0' && aCh <= '9' )
+ aEvent = KeyEvent(aCh, KeyCode(KEYGROUP_NUM + aCh-'0', 0));
+ else if ( aPrintableMisc.Search(aCh) != STRING_NOTFOUND )
+ aEvent = KeyEvent(aCh, KeyCode(KEYGROUP_MISC + (sal_uInt16)aPrintableMisc.Search(aCh), 0));
+ else // Sollte eigentlich nicht auftreten
+ aEvent = KeyEvent(aCh, KeyCode());
+ }
+ ImplKeyInput( pDeliverHere, aEvent );
+ if ( !MaybeDoTypeKeysDelay( pControl ) )
+ break;
+ else
+ SafeReschedule();SafeReschedule();SafeReschedule();
+ }
+ }
+ break;
+
+#define CalcMouseButton\
+ sal_uInt16 nButton = MOUSE_LEFT;\
+ if ( (nParams & PARAM_USHORT_3) )\
+ {\
+ switch ( nNr3 )\
+ {\
+ case 1: nButton = MOUSE_LEFT; break;\
+ case 2: nButton = MOUSE_MIDDLE; break;\
+ case 3: nButton = MOUSE_RIGHT; break;\
+ }\
+ }\
+
+ case M_MouseDown:
+ {
+ CalcMouseButton;
+ Size aS = pControl->GetOutputSizePixel();
+ Point aPos = Point(aS.Width() * nNr1 / 100,aS.Height() * nNr2 / 100);
+ Window *pActualWin = pControl->FindWindow( aPos );
+// AnimateMouse( pControl, aPos );
+
+ if ( pActualWin )
+ aPos = pActualWin->AbsoluteScreenToOutputPixel( pControl->OutputToAbsoluteScreenPixel ( aPos ) );
+// aPos = pActualWin->ScreenToOutputPixel( pControl->OutputToScreenPixel ( aPos ) );
+ else
+ pActualWin = pControl;
+
+ AnimateMouse( pActualWin, aPos );
+ pActualWin->GrabFocus();
+ MouseEvent aMEvnt(aPos,1,MOUSE_SIMPLECLICK|MOUSE_SELECT,nButton);
+ ImplMouseButtonDown( pActualWin, aMEvnt );
+ }
+ break;
+ case M_MouseUp:
+ {
+ CalcMouseButton;
+ Size aS = pControl->GetOutputSizePixel();
+ Point aPos = Point(aS.Width() * nNr1 / 100,aS.Height() * nNr2 / 100);
+ Window *pActualWin = pControl->FindWindow( aPos );
+
+ if ( pActualWin )
+ aPos = pActualWin->AbsoluteScreenToOutputPixel( pControl->OutputToAbsoluteScreenPixel ( aPos ) );
+// aPos = pActualWin->ScreenToOutputPixel( pControl->OutputToScreenPixel ( aPos ) );
+ else
+ pActualWin = pControl;
+
+ AnimateMouse( pActualWin, aPos );
+// pActualWin->GrabFocus();
+ MouseEvent aMEvt( aPos, 1, MOUSE_SIMPLECLICK|MOUSE_SELECT, nButton );
+ ImplMouseButtonUp( pActualWin, aMEvt );
+ }
+ break;
+ case M_MouseMove:
+ {
+ CalcMouseButton;
+ Size aS = pControl->GetOutputSizePixel();
+ Point aPos = Point(aS.Width() * nNr1 / 100,aS.Height() * nNr2 / 100);
+ Window *pActualWin = pControl->FindWindow( aPos );
+
+ if ( pActualWin )
+ {
+ aPos = pActualWin->AbsoluteScreenToOutputPixel( pControl->OutputToAbsoluteScreenPixel ( aPos ) );
+// aPos = pActualWin->ScreenToOutputPixel( pControl->OutputToScreenPixel ( aPos ) );
+ }
+ else
+ pActualWin = pControl;
+
+ AnimateMouse( pActualWin, aPos );
+// pActualWin->GrabFocus();
+ MouseEvent aMEvt( aPos, 0, MOUSE_SIMPLEMOVE|MOUSE_DRAGMOVE, nButton );
+ ImplMouseMove( pActualWin, aMEvt );
+ }
+ break;
+ case M_MouseDoubleClick:
+ {
+ CalcMouseButton;
+ Size aS = pControl->GetOutputSizePixel();
+ Point aPos = Point(aS.Width() * nNr1 / 100,aS.Height() * nNr2 / 100);
+ Window *pActualWin = pControl->FindWindow( aPos );
+
+ if ( pActualWin )
+ {
+ aPos = pActualWin->AbsoluteScreenToOutputPixel( pControl->OutputToAbsoluteScreenPixel ( aPos ) );
+// aPos = pActualWin->ScreenToOutputPixel( pControl->OutputToScreenPixel ( aPos ) );
+ }
+ else
+ pActualWin = pControl;
+
+ AnimateMouse( pActualWin, aPos );
+ pActualWin->GrabFocus();
+ MouseEvent aMEvnt;
+ aMEvnt = MouseEvent(aPos,1,MOUSE_SIMPLECLICK|MOUSE_SELECT,nButton);
+ ImplMouseButtonDown( pActualWin, aMEvnt );
+ ImplMouseButtonUp ( pActualWin, aMEvnt );
+ aMEvnt = MouseEvent(aPos,2,MOUSE_SIMPLECLICK|MOUSE_SELECT,nButton);
+ ImplMouseButtonDown( pActualWin, aMEvnt );
+ ImplMouseButtonUp ( pActualWin, aMEvnt );
+ }
+ break;
+ case M_DisplayPercent:
+ {
+ ModelessDialog *pDlg = new ModelessDialog(NULL);
+ pDlg->SetOutputSizePixel(Size(100,30));
+
+ Edit *pMyEd = new Edit(pDlg,WB_CENTER | WB_BORDER );
+ pMyEd->SetSizePixel(Size(100,30));
+ pDlg->SetText(UniString("Schließen", RTL_TEXTENCODING_ISO_8859_1));
+ pDlg->Show();
+ pMyEd->Show();
+ sal_uLong nTime = Time().GetTime();
+
+ while (pDlg->IsVisible())
+ {
+ pDlg->ToTop();
+ for (int i = 1 ; i<10 ; i++)
+ SafeReschedule();
+ Point Pos = pControl->GetPointerPosPixel();
+ Size Siz=pControl->GetOutputSizePixel();
+ if ( Time().GetTime() - nTime > 10 )
+ {
+ nTime = Time().GetTime();
+ pMyEd->SetText(UniString::CreateFromInt32(Pos.X()*100/Siz.Width()).AppendAscii("%x").Append( UniString::CreateFromInt32(Pos.Y()*100/Siz.Height()) ).Append('%'));
+ }
+ }
+
+ delete pMyEd;
+ delete pDlg;
+ }
+ break;
+ case M_OpenContextMenu:
+ {
+ aSubMenuId1 = 0;
+ aSubMenuId2 = 0;
+ aSubMenuId3 = 0;
+ pMenuWindow = NULL;
+ Point aPos;
+ ToolBox* pTB = (ToolBox*)pControl;
+ if ( (pControl->GetType() == WINDOW_TOOLBOX) && pTB->IsMenuEnabled() )
+ {
+ pTB->ExecuteCustomMenu();
+/* Rectangle aRect = pTB->GetMenubuttonRect();
+ AnimateMouse( pControl, aRect.Center() );
+ MouseEvent aMEvnt(aRect.Center(),1,MOUSE_SIMPLECLICK,MOUSE_LEFT);
+ ImplMouseButtonDown( pTB, aMEvnt );*/
+ }
+ else
+ {
+ sal_Bool bAtMousePos = ( nParams & PARAM_BOOL_1 ) && bBool1;
+ if ( bAtMousePos )
+ {
+ aPos = pControl->GetPointerPosPixel();
+ Window *pActualWin = pControl->FindWindow( aPos );
+
+ if ( pActualWin )
+ {
+ aPos = pActualWin->AbsoluteScreenToOutputPixel( pControl->OutputToAbsoluteScreenPixel ( aPos ) );
+ // aPos = pActualWin->ScreenToOutputPixel( pControl->OutputToScreenPixel ( aPos ) );
+ pControl = pActualWin;
+ }
+ }
+ CommandEvent aEvent( aPos, COMMAND_CONTEXTMENU, bAtMousePos );
+ ImplCommand( pControl, aEvent );
+ }
+ }
+ break;
+ case M_UseMenu:
+ {
+ aSubMenuId1 = 0;
+ aSubMenuId2 = 0;
+ aSubMenuId3 = 0;
+ pMenuWindow = NULL;
+
+ while ( pControl && !( ( pControl->GetType() == WINDOW_SYSWINDOW || pControl->GetType() == WINDOW_WORKWINDOW ) && ControlOK( pControl, "" ) ) )
+ pControl = pControl->GET_REAL_PARENT();
+
+ if ( pControl && ((SystemWindow*)pControl)->GetMenuBar() )
+ pMenuWindow = ((SystemWindow*)pControl);
+ else
+ ReportError( GEN_RES_STR1( S_NO_MENU, MethodString( nMethodId ) ) );
+ }
+ break;
+ case M_FadeIn:
+ case M_FadeOut:
+ case M_Pin:
+ case M_IsFadeIn:
+ case M_IsPin:
+ {
+ WindowAlign aWindowAlign = WINDOWALIGN_LEFT;
+ if ( (nParams & PARAM_USHORT_1) )
+ {
+ switch ( nNr1 )
+ {
+ case CONST_ALIGN_LEFT:
+ aWindowAlign = WINDOWALIGN_LEFT;
+ break;
+ case CONST_ALIGN_TOP:
+ aWindowAlign = WINDOWALIGN_TOP;
+ break;
+ case CONST_ALIGN_RIGHT:
+ aWindowAlign = WINDOWALIGN_RIGHT;
+ break;
+ case CONST_ALIGN_BOTTOM:
+ aWindowAlign = WINDOWALIGN_BOTTOM;
+ break;
+ default:
+ ReportError( aUId, GEN_RES_STR1( S_INVALID_POSITION, MethodString( nMethodId ) ) );
+ }
+ }
+
+ Window* pTemp = NULL;
+ while ( !pTemp && pControl )
+ {
+ pTemp = GetFadeSplitWin( pControl, aWindowAlign );
+ pControl = pControl->GET_REAL_PARENT();
+ }
+
+ if ( !pTemp )
+ {
+ ReportError( aUId, GEN_RES_STR1( S_SPLITWIN_NOT_FOUND, MethodString( nMethodId ) ) );
+ break;
+ }
+
+ pControl = pTemp; // So daß wir unten ohne Fehler durchkommen
+ SplitWindow *pSW = (SplitWindow*) pTemp;
+
+// Rectangle GetAutoHideRect() const;
+// Rectangle GetFadeInRect() const;
+// Rectangle GetFadeOutRect() const;
+
+ switch( nMethodId )
+ {
+ case M_FadeIn:
+ if ( pSW->IsFadeInButtonVisible() )
+ pSW->FadeIn();
+ break;
+ case M_FadeOut:
+ if ( pSW->IsFadeOutButtonVisible() )
+ pSW->FadeOut();
+ break;
+ case M_Pin:
+ if ( ( pSW->GetAutoHideState() && bBool1 )
+ || ( !pSW->GetAutoHideState() && !bBool1 ) )
+ {
+ MouseEvent aMEvnt;
+ Point aPt( pSW->GetAutoHideRect().Center() );
+ aMEvnt = MouseEvent( aPt,1,MOUSE_SIMPLECLICK,MOUSE_LEFT );
+ ImplMouseButtonDown( pControl, aMEvnt, FORCE_DIRECT_CALL );
+ ImplMouseButtonUp ( pControl, aMEvnt, FORCE_DIRECT_CALL );
+ }
+// pSW->AutoHide();
+ break;
+ case M_IsFadeIn:
+ pRet->GenReturn ( RET_Value, aUId, pSW->IsFadeOutButtonVisible() );
+ break;
+ case M_IsPin:
+ pRet->GenReturn ( RET_Value, aUId, (comm_BOOL)!pSW->GetAutoHideState() );
+ break;
+ default:
+ ReportError( aUId, GEN_RES_STR1( S_INTERNAL_ERROR, MethodString( nMethodId ) ) );
+ }
+ SendProfile( UIdString( aUId ).Append('.').Append( MethodString( nMethodId ) ) );
+ }
+ break;
+ case M_StatusGetText:
+ case M_StatusIsProgress:
+ case M_StatusGetItemCount:
+ case M_StatusGetItemId:
+ {
+ StatusBar *pStatus = NULL;
+ while ( !pStatus && pControl )
+ {
+ pStatus = (StatusBar*)GetWinByRT( pControl, WINDOW_STATUSBAR, sal_True );
+ pControl = pControl->GET_REAL_PARENT();
+ }
+
+ if ( !pStatus )
+ {
+ ReportError( aUId, GEN_RES_STR1( S_NO_STATUSBAR, MethodString( nMethodId ) ) );
+ break;
+ }
+
+ switch ( nMethodId )
+ {
+ case M_StatusGetText:
+ {
+ if ( (nParams & PARAM_USHORT_1) )
+ {
+ if ( pStatus->AreItemsVisible() )
+ pRet->GenReturn ( RET_Value, aUId, String(pStatus->GetItemText(nNr1)));
+ else
+ ReportError( aUId, GEN_RES_STR1( S_ITEMS_INVISIBLE, MethodString( nMethodId ) ) );
+ }
+ else
+ {
+ if ( pStatus->AreItemsVisible() )
+ {
+ if ( pStatus->GetItemCount() == 1 )
+ {
+ pRet->GenReturn ( RET_Value, aUId, pStatus->GetItemText( pStatus->GetItemId(0) ));
+ }
+ else
+ {
+ pRet->GenReturn ( RET_Value, aUId, String() );
+ }
+ }
+ else
+ pRet->GenReturn ( RET_Value, aUId, (String)pStatus->GetText() );
+ }
+ }
+ break;
+ case M_StatusIsProgress:
+ {
+ pRet->GenReturn ( RET_Value, aUId, (comm_BOOL)pStatus->IsProgressMode() );
+ }
+ break;
+ case M_StatusGetItemCount:
+ if ( pStatus->AreItemsVisible() )
+ pRet->GenReturn ( RET_Value, aUId, comm_ULONG(pStatus->GetItemCount()));
+ else
+ pRet->GenReturn ( RET_Value, aUId, comm_ULONG(0));
+ break;
+ case M_StatusGetItemId:
+ if ( ValueOK(aUId, MethodString( nMethodId ),nNr1,pStatus->GetItemCount()) )
+ pRet->GenReturn ( RET_Value, aUId, comm_ULONG(pStatus->GetItemId(nNr1-1)));
+ break;
+ }
+ }
+ break;
+ case M_HasScrollBar:
+ case M_IsScrollBarEnabled:
+ {
+ if ( (nParams | PARAM_USHORT_1) != PARAM_USHORT_1 ) // so there are other params
+ {
+ ReportError( aUId, GEN_RES_STR0( S_INVALID_PARAMETERS ) );
+ break;
+ }
+
+ if( !(nParams & PARAM_USHORT_1) )
+ nNr1 = CONST_ALIGN_RIGHT; // default is right Scrollbar(vertical)
+
+ if ( (nNr1 != CONST_ALIGN_RIGHT) && (nNr1 != CONST_ALIGN_BOTTOM) )
+ {
+ ReportError( aUId, GEN_RES_STR1( S_INVALID_POSITION, MethodString( nMethodId ) ) );
+ break;
+ }
+
+ ScrollBar *pScroll = NULL;
+
+ sal_uInt16 nSteps = 2;
+ while ( !pScroll && pControl && nSteps-- )
+ {
+ pScroll = GetScrollBar( pControl, nNr1, sal_True );
+ pControl = pControl->GET_REAL_PARENT();
+ }
+
+ switch ( nMethodId )
+ {
+ case M_HasScrollBar:
+ {
+ if ( pScroll )
+ pRet->GenReturn ( RET_Value, aUId, (comm_BOOL)sal_True );
+ else
+ pRet->GenReturn ( RET_Value, aUId, (comm_BOOL)sal_False );
+ }
+ break;
+ case M_IsScrollBarEnabled:
+ {
+ if ( !pScroll )
+ {
+ ReportError( aUId, GEN_RES_STR1( S_NO_SCROLLBAR, MethodString( nMethodId ) ) );
+ break;
+ }
+ pRet->GenReturn ( RET_Value, aUId, pScroll->IsEnabled() );
+ }
+ break;
+ }
+ }
+ break;
+ default:
+ return sal_False;
+ }
+ return sal_True;
+}
+
+
+sal_Bool StatementControl::Execute()
+{
+ Window *pControl;
+ sal_Bool bStatementDone = sal_True;
+
+
+ if ( IsError )
+ {
+ #if OSL_DEBUG_LEVEL > 1
+ m_pDbgWin->AddText( "Skipping Window: " );
+ m_pDbgWin->AddText( Id2Str( aUId ) );
+ m_pDbgWin->AddText( " Method: " );
+ m_pDbgWin->AddText( String::CreateFromInt32( nMethodId ) );
+ m_pDbgWin->AddText( "\n" );
+ #endif
+ Advance();
+ delete this;
+ return sal_True;
+ }
+
+ InitProfile();
+#if OSL_DEBUG_LEVEL > 1
+ m_pDbgWin->AddText( "Executing Window: " );
+ m_pDbgWin->AddText( Id2Str( aUId ) );
+ m_pDbgWin->AddText( " Method: " );
+ m_pDbgWin->AddText( String::CreateFromInt32( nMethodId ) );
+ m_pDbgWin->AddText( "\n" );
+#endif
+
+
+ if ( aUId.equals( UID_ACTIVE ) )
+ pControl = GetAnyActive();
+ else
+ {
+ sal_Bool bSearchButtonOnToolbox = (nParams == PARAM_NONE) && ((M_Click == nMethodId) || (M_TearOff == nMethodId) || (M_IsEnabled == nMethodId) || (M_OpenMenu == nMethodId));
+ bSearchButtonOnToolbox |= (nParams == PARAM_USHORT_1) && (M_GetState == nMethodId);
+ if ( nMethodId == M_TypeKeys || nMethodId == M_MouseDown
+ || nMethodId == M_MouseUp || nMethodId == M_MouseMove
+ || nMethodId == M_SnapShot )
+ {
+ pControl = NULL;
+ if ( /*(nMethodId == M_SnapShot || nMethodId == M_TypeKeys) &&*/ !pControl )
+ pControl = SearchTree( aUId ,bSearchButtonOnToolbox );
+ }
+ else
+ pControl = SearchTree( aUId ,bSearchButtonOnToolbox );
+ }
+
+
+ if ( pControl && pControl->GetType() == WINDOW_TOOLBOX )
+ {
+ if ( !aUId.equals( pControl->GetUniqueOrHelpId() ) )
+ { // Also wenn wir irgendwas auf einer Toolbox gefunden haben
+ switch ( nMethodId )
+ {
+ case M_Click:
+ case M_TearOff:
+ case M_OpenMenu:
+ case M_GetState:
+ break;
+ case M_IsEnabled:
+ nMethodId = _M_IsEnabled; // Umlabeln, da die Behandlung essentiell anders ist!
+ break;
+ default:
+ pControl = NULL;
+ }
+ }
+ }
+
+
+ switch ( nMethodId )
+ {
+ case M_Exists:
+ case M_NotExists:
+ Time aT;
+ sal_uInt16 aSeconds = aT.GetMin()*60+aT.GetSec();
+ if ( !bBool2 ) // wurde im Konstruktor auf sal_False gesetzt
+ {
+ bBool2 = sal_True;
+ nNr2 = aSeconds;
+ if( !(nParams & PARAM_USHORT_1) )
+ nNr1 = 0; // defaultmäßig sofort zurück
+ }
+ if ( aSeconds < nNr2 ) // Falls die Stunde umgesprungen ist
+ aSeconds += 60*60;
+
+ if ( /* !IsAccessable(pControl)#87019# */ !pControl || !pControl->IsVisible() )
+ pControl = NULL;
+ if ( ((nMethodId == M_Exists) && pControl) ||
+ ((nMethodId == M_NotExists) && !pControl) )
+ { // Wenn Bedingung erfüllt
+ pRet->GenReturn ( RET_Value, aUId, (comm_BOOL)sal_True );
+ }
+ else
+ if ( aSeconds <= nNr2 + nNr1 ) // Zeit ist noch nicht abgelaufen
+ return sal_False;
+ else
+ pRet->GenReturn ( RET_Value, aUId, (comm_BOOL)sal_False );
+
+ Advance();
+ delete this;
+ return sal_True;
+// break;
+ }
+
+
+ short nRT = 0;
+
+ if( pControl ) // Das Fenster Existiert irgendwo, kann aber auch hidden sein!
+ {
+ nRT = ImpGetRType( pControl );
+#if OSL_DEBUG_LEVEL > 1
+ m_pDbgWin->AddText( "Type is: " );
+ m_pDbgWin->AddText( String::CreateFromInt32( nRT ) );
+ m_pDbgWin->AddText( "\n" );
+#endif
+ }
+
+ if ( nRT == C_Window && // Search for WorkWindow to satisfy these commands
+ ( nMethodId == M_Close
+// || nMethodId == M_Size
+// || nMethodId == M_Move
+ || nMethodId == M_IsMax
+ || nMethodId == M_IsMin
+ || nMethodId == M_IsRestore
+ || nMethodId == M_Minimize
+ || nMethodId == M_Maximize
+ || nMethodId == M_Restore ) )
+ {
+ Window* pNewControl = pControl;
+ while ( pNewControl && pNewControl->GetType() != WINDOW_WORKWINDOW )
+ pNewControl = pNewControl->GET_REAL_PARENT();
+
+ if ( pNewControl )
+ {
+ pControl = pNewControl;
+ nRT = C_WorkWin;
+ }
+ }
+
+
+ if ( (!ControlOK( pControl, "" )) && ( nMethodId != M_SnapShot ) && (nRetryCount--))
+ {
+#if OSL_DEBUG_LEVEL > 1
+ m_pDbgWin->AddText( CUniString("Reschedule command (").Append( UniString::CreateFromInt32(nRetryCount) ).AppendAscii(")\n") );
+#endif
+ return sal_False;
+ }
+
+ if( ControlOK( pControl, "" ) )
+ {
+ if ( nMethodId == M_OpenContextMenu && !bBool2 )
+ {
+ pControl->GrabFocus(); // to get asyncron focus on unix
+ bBool2 = sal_True;
+ return sal_False;
+ }
+ // TODO: handle GetFocus for all Methods and Windows like this (remove part below)
+ // See for impact of changed focus for HandleVisibleControls() (taking Snapshots might be different, possible exclude those methods)
+ if (( (nRT == C_TreeListBox) && !bBool2 )
+ && nMethodId != M_TypeKeys // TypeKeys macht das selbst, falls eigenes Focushandling gewünscht
+ && nMethodId != M_MouseDown
+ && nMethodId != M_MouseUp
+ && nMethodId != M_MouseMove
+ /*&& nMethodId != M_MouseDoubleClick*/ )
+ {
+ if ( !pControl->HasFocus() )
+ {
+ pControl->GrabFocus();
+ int i = 10;
+ while ( i-- && !pControl->HasFocus() ) // reschedule a bit
+ {
+ SafeReschedule();
+ if ( !WinPtrValid( pControl ) )
+ return sal_False;
+ }
+ if ( !pControl->HasFocus() ) // to get asyncronous focus
+ {
+ bBool2 = sal_True;
+ return sal_False;
+ }
+ }
+ }
+ }
+
+ Advance();
+
+ if ( HandleVisibleControls( pControl ) )
+ {
+ delete this;
+ return sal_True;
+ }
+ if( ControlOK( pControl, "Window/Control" ) )
+ {
+ if (((( nRT < C_TabPage && nRT > C_TabControl )
+ || nRT == C_PatternBox
+ || nRT == C_ToolBox
+ || nRT == C_ValueSet
+ || nRT == C_Control
+ || nRT == C_TreeListBox
+ )
+ || nMethodId == M_OpenContextMenu )
+ && nMethodId != M_TypeKeys // TypeKeys macht das selbst, falls eigenes Focushandling gewünscht
+ && nMethodId != M_MouseDown
+ && nMethodId != M_MouseUp
+ && nMethodId != M_MouseMove
+ /*&& nMethodId != M_MouseDoubleClick*/ )
+ pControl->GrabFocus();
+
+/* leads to problems because settext sets the text whereas typekeys adds to the text.
+ if ( bDoTypeKeysDelay && nMethodId == M_SetText && ( nParams & PARAM_STR_1 ) )
+ { // Hier wird das Statement auf ein TypeKeys umgebogen
+ nMethodId = M_TypeKeys;
+ nParams = PARAM_BOOL_1 | PARAM_STR_1;
+ bBool1 = sal_True;
+ pControl->GrabFocus();
+ }
+*/
+ if ( !HandleCommonMethods( pControl ) )
+ {
+ switch( nRT )
+ {
+ case C_TabControl:
+ switch( nMethodId )
+ {
+ case M_GetPageId:
+ if ( (nParams & PARAM_USHORT_1) )
+ {
+ if ( ValueOK(aUId, MethodString( nMethodId ),nNr1,((TabControl*)pControl)->GetPageCount() ) )
+ pRet->GenReturn ( RET_Value, aUId, (comm_ULONG)((TabControl*)pControl)->GetPageId(nNr1-1));
+ }
+ else
+ pRet->GenReturn ( RET_Value, aUId, (comm_ULONG)((TabControl*)pControl)->GetCurPageId());
+ break;
+ case M_GetPageCount:
+ pRet->GenReturn ( RET_Value, aUId, (comm_ULONG)((TabControl*)pControl)->GetPageCount());
+ break;
+ case M_SetPageId:
+ if (((TabControl*)pControl)->GetCurPageId())
+ ((TabControl*)pControl)->DeactivatePage();
+ ((TabControl*)pControl)->SetCurPageId( nNr1 );
+ ((TabControl*)pControl)->ActivatePage();
+ break;
+ case M_SetPageNr:
+ if ( ValueOK(aUId, MethodString( nMethodId ),nNr1,((TabControl*)pControl)->GetPageCount() ) )
+ {
+ if (((TabControl*)pControl)->GetCurPageId())
+ ((TabControl*)pControl)->DeactivatePage();
+ ((TabControl*)pControl)->SetCurPageId( ((TabControl*)pControl)->GetPageId( nNr1-1 ) );
+ ((TabControl*)pControl)->ActivatePage();
+ }
+ break;
+ case M_GetPage:
+ pRet->GenReturn ( RET_Value, aUId, Id2Str( ((TabControl*)pControl)->GetTabPage(((TabControl*)pControl)->GetCurPageId())->GetUniqueOrHelpId() ) );
+ break;
+ case M_SetPage :
+ { // Wegen lokaler Variablen
+ TabControl *pTControl = ((TabControl*)pControl);
+ sal_uInt16 nActive = pTControl->GetCurPageId();
+ sal_uInt16 i,anz;
+ rtl::OString aID;
+ rtl::OString aWantedID;
+ //HELPID BACKWARD (No numbers please (remove PARAM_ULONG_1 part)
+ if ( (nParams & PARAM_ULONG_1) )
+ {
+ //aWantedID = rtl::OString( nLNr1 );
+ ReportError( aUId, GEN_RES_STR1c( S_INTERNAL_ERROR, "using numeric HelpID from old Testtool" ) );
+ }
+ else if ( (nParams & PARAM_STR_1) )
+ {
+ aWantedID = Str2Id( aString1 );
+ }
+ else
+ ReportError( aUId, GEN_RES_STR1( S_INTERNAL_ERROR, MethodString( nMethodId ) ) );
+
+ i = pTControl->GetPagePos( pTControl->GetCurPageId() );
+ for ( anz=0 ; anz < pTControl->GetPageCount() && !aID.equals( aWantedID ) ; anz++ )
+ {
+ pTControl->SelectTabPage( pTControl->GetPageId(i) );
+ /*if (pTControl->GetCurPageId())
+ pTControl->DeactivatePage();
+ pTControl->SetCurPageId( pTControl->GetPageId(i) );
+ pTControl->ActivatePage();*/
+ aID = pTControl->GetTabPage(pTControl->GetCurPageId())->GetUniqueOrHelpId();
+ i++;
+ if ( i >= pTControl->GetPageCount() )
+ i = 0;
+ if ( !MaybeDoTypeKeysDelay( pTControl ) || !MaybeDoTypeKeysDelay( pTControl ) || !MaybeDoTypeKeysDelay( pTControl ) ) // 3 Mal aufrufen
+ break;
+ }
+ if ( !aID.equals( aWantedID ) )
+ {
+ pTControl->SelectTabPage( nActive );
+ /*if (pTControl->GetCurPageId())
+ pTControl->DeactivatePage();
+ pTControl->SetCurPageId( nActive );
+ pTControl->ActivatePage();*/
+ ReportError( aWantedID, GEN_RES_STR1( S_TABPAGE_NOT_FOUND, MethodString( nMethodId ) ) );
+ }
+ }
+ break;
+ default:
+ ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "TabControl" ) );
+ break;
+ }
+ break;
+ case C_RadioButton:
+ case C_ImageRadioButton:
+ switch( nMethodId )
+ {
+ case M_AnimateMouse :
+ AnimateMouse( pControl, MitteLinks);
+ break;
+ case M_IsChecked :
+ pRet->GenReturn ( RET_Value, aUId, ((RadioButton*)pControl)->IsChecked());
+ break;
+ case M_Check :
+ ((RadioButton*)pControl)->Check();
+ ((RadioButton*)pControl)->Click();
+ break;
+ default:
+ ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "RadioButton" ) );
+ break;
+ }
+ break;
+ case C_CheckBox:
+ case C_TriStateBox:
+ switch( nMethodId )
+ {
+ case M_AnimateMouse :
+ AnimateMouse( pControl, MitteLinks);
+ break;
+ case M_IsChecked :
+ pRet->GenReturn ( RET_Value, aUId, comm_BOOL( ((TriStateBox*)pControl)->GetState() == STATE_CHECK) );
+ break;
+ case M_IsTristate :
+ pRet->GenReturn ( RET_Value, aUId, comm_BOOL( ((TriStateBox*)pControl)->GetState() == STATE_DONTKNOW) );
+ break;
+ case M_GetState :
+ pRet->GenReturn ( RET_Value, aUId, comm_ULONG(((TriStateBox*)pControl)->GetState()));
+ break;
+ case M_Check :
+ ((TriStateBox*)pControl)->SetState( STATE_CHECK );
+ ((TriStateBox*)pControl)->Click();
+ break;
+ case M_UnCheck :
+ ((TriStateBox*)pControl)->SetState( STATE_NOCHECK );
+ ((TriStateBox*)pControl)->Click();
+ break;
+ case M_TriState :
+ if ( ((TriStateBox*)pControl)->IsTriStateEnabled() )
+ {
+ ((TriStateBox*)pControl)->SetState( STATE_DONTKNOW );
+ ((TriStateBox*)pControl)->Click();
+ }
+ else
+ {
+ ReportError( aUId, GEN_RES_STR0( S_TRISTATE_NOT_ALLOWED ) );
+ }
+ break;
+ case M_Click :
+ {
+ TriStateBox *pTB = ((TriStateBox*)pControl);
+ if ( pTB->GetState() == STATE_NOCHECK )
+ pTB->SetState( STATE_CHECK );
+ else if ( pTB->GetState() == STATE_CHECK )
+ {
+ if ( pTB->IsTriStateEnabled() )
+ pTB->SetState( STATE_DONTKNOW );
+ else
+ pTB->SetState( STATE_NOCHECK );
+ }
+ else
+ pTB->SetState( STATE_NOCHECK );
+ pTB->Click();
+ }
+ break;
+ default:
+ ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "TriStateBox" ) );
+ break;
+ }
+ break;
+ case C_Edit:
+ case C_MultiLineEdit:
+ switch( nMethodId )
+ {
+ case M_AnimateMouse :
+ AnimateMouse( pControl, Mitte);
+ break;
+ case M_GetText :
+ pRet->GenReturn ( RET_Value, aUId, ((Edit*)pControl)->GetText());
+ break;
+ case M_IsWritable:
+ pRet->GenReturn ( RET_Value, aUId, (comm_BOOL) !((Edit*)pControl)->IsReadOnly() );
+ break;
+ default:
+ if ( ! ((Edit*)pControl)->IsReadOnly() )
+ {
+ switch( nMethodId )
+ {
+ case M_SetText :
+ ((Edit*)pControl)->SetText( aString1 );
+ if ( nRT == C_MultiLineEdit ) // since SetModifyFlag is not virtual we have to do this
+ ((MultiLineEdit*)pControl)->SetModifyFlag();
+ else
+ ((Edit*)pControl)->SetModifyFlag();
+ ((Edit*)pControl)->Modify();
+ if ( ((Edit*)pControl)->GetText().CompareTo(aString1) != COMPARE_EQUAL )
+ ReportError( aUId, GEN_RES_STR1( S_ERROR_IN_SET_TEXT, MethodString( nMethodId ) ) );
+ break;
+ default:
+ ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "(MultiLine)Edit" ) );
+ break;
+ }
+ }
+ else
+ ReportError( aUId, GEN_RES_STR1c( S_ATTEMPT_TO_WRITE_READONLY, "(MultiLine)Edit" ) );
+ }
+ break;
+ case C_MultiListBox:
+ case C_ListBox:
+ switch( nMethodId )
+ {
+ case M_AnimateMouse :
+ AnimateMouse( pControl, MitteOben);
+ break;
+ case M_GetSelCount :
+ pRet->GenReturn ( RET_Value, aUId, comm_ULONG(((ListBox*)pControl)->GetSelectEntryCount()));
+ break;
+ case M_GetSelIndex :
+ if ( ! (nParams & PARAM_USHORT_1) )
+ {
+ if ( ((ListBox*)pControl)->GetSelectEntryCount() == 0 )
+ {
+ pRet->GenReturn ( RET_Value, aUId, comm_ULONG(0));
+ break;
+ }
+ nNr1 = 1;
+ }
+ ValueOK(aUId, MethodString( nMethodId ),nNr1,((ListBox*)pControl)->GetSelectEntryCount());
+ pRet->GenReturn ( RET_Value, aUId, comm_ULONG(((ListBox*)pControl)->GetSelectEntryPos(nNr1-1)) +1);
+ break;
+ case M_GetSelText :
+ if ( ! (nParams & PARAM_USHORT_1) )
+ nNr1 = 1;
+ pRet->GenReturn ( RET_Value, aUId, ((ListBox*)pControl)->GetSelectEntry(nNr1-1));
+ break;
+ case M_GetItemCount :
+ pRet->GenReturn ( RET_Value, aUId, comm_ULONG(((ListBox*)pControl)->GetEntryCount()));
+ break;
+ case M_GetItemText :
+ pRet->GenReturn ( RET_Value, aUId, ((ListBox*)pControl)->GetEntry(nNr1-1));
+ break;
+ case M_Select:
+ case M_MultiSelect:
+ {
+ sal_Bool bUnselectBeforeSelect = ( nMethodId == M_Select );
+ sal_Bool bFehler = sal_False;
+ if ( ! (nParams & PARAM_BOOL_1) )
+ bBool1 = sal_True;
+
+ if ( nMethodId == M_MultiSelect && nRT == C_ListBox )
+ {
+ ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "ListBox" ) );
+ bFehler = sal_True;
+ }
+
+ if ( !bBool1 && nMethodId == M_Select )
+ {
+ ReportError( aUId, GEN_RES_STR1( S_NO_SELECT_FALSE, MethodString( nMethodId ) ) );
+ bFehler = sal_True;
+ }
+
+ if ( !bFehler )
+ {
+ if( nParams & PARAM_STR_1 )
+ {
+ ListBox *pLB = ((ListBox*)pControl);
+ sal_uInt16 nPos;
+ if ( (nPos = pLB->GetEntryPos( aString1 )) == LISTBOX_ENTRY_NOTFOUND )
+ ReportError( aUId, GEN_RES_STR2( S_ENTRY_NOT_FOUND, MethodString( nMethodId ), aString1 ) );
+ else
+ {
+ if ( bUnselectBeforeSelect )
+ pLB->SetNoSelection();
+ pLB->SelectEntryPos( nPos, bBool1 );
+ if ( pLB->IsEntryPosSelected( nPos ) ? !bBool1 : bBool1 ) // XOR rein mit BOOL
+ ReportError( aUId, GEN_RES_STR2( S_METHOD_FAILED, MethodString( nMethodId ), aString1 ) );
+ }
+ }
+ else
+ {
+ ListBox *pLB = ((ListBox*)pControl);
+ pLB = static_cast<ListBox*>(pControl);
+ if ( ValueOK(aUId, MethodString( nMethodId ),nNr1,pLB->GetEntryCount()) )
+ {
+ if ( bUnselectBeforeSelect )
+ pLB->SetNoSelection();
+ pLB->SelectEntryPos( nNr1-1, bBool1 );
+ if ( pLB->IsEntryPosSelected( nNr1-1 ) ? !bBool1 : bBool1 ) // XOR rein mit BOOL
+ ReportError( aUId, GEN_RES_STR2( S_METHOD_FAILED, MethodString( nMethodId ), UniString::CreateFromInt32( nNr1 ) ) );
+ }
+ }
+ ((ListBox*)pControl)->Select();
+ }
+ }
+ break;
+ case M_SetNoSelection :
+ ((ListBox*)pControl)->SetNoSelection();
+ ((ListBox*)pControl)->Select();
+ break;
+ default:
+ ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "(Multi)ListBox" ) );
+ break;
+ }
+ break;
+ case C_ComboBox:
+ case C_PatternBox:
+ case C_NumericBox:
+ case C_MetricBox:
+ case C_CurrencyBox:
+ case C_DateBox:
+ case C_TimeBox:
+ switch( nMethodId )
+ {
+ case M_AnimateMouse :
+ AnimateMouse( pControl, MitteOben);
+ break;
+ case M_GetSelText :
+ pRet->GenReturn ( RET_Value, aUId, ((ComboBox*)pControl)->GetText());
+ break;
+ case M_GetSelIndex :
+ {
+ sal_uInt16 nPos = ((ComboBox*)pControl)->GetEntryPos(((ComboBox*)pControl)->GetText());
+ if ( nPos == COMBOBOX_ENTRY_NOTFOUND )
+ nPos = 0;
+ else
+ nPos++;
+ pRet->GenReturn ( RET_Value, aUId, (comm_ULONG) nPos);
+ }
+ break;
+ case M_GetItemCount :
+ pRet->GenReturn ( RET_Value, aUId, comm_ULONG(((ComboBox*)pControl)->GetEntryCount()));
+ break;
+ case M_GetItemText :
+ pRet->GenReturn ( RET_Value, aUId, ((ComboBox*)pControl)->GetEntry(nNr1-1));
+ break;
+ case M_IsWritable:
+ pRet->GenReturn ( RET_Value, aUId, (comm_BOOL) !((ComboBox*)pControl)->IsReadOnly() );
+ break;
+ case M_Select :
+ if( nParams & PARAM_USHORT_1 )
+ {
+ if ( !ValueOK(aUId, MethodString( nMethodId ),nNr1,((ComboBox*)pControl)->GetEntryCount()) )
+ break;
+ aString1 = ((ComboBox*)pControl)->GetEntry(nNr1-1);
+ }
+ else
+ {
+ if ( ((ComboBox*)pControl)->GetEntryPos( aString1 ) == COMBOBOX_ENTRY_NOTFOUND )
+ {
+ ReportError( aUId, GEN_RES_STR2( S_ENTRY_NOT_FOUND, MethodString( nMethodId ), aString1 ) );
+ break;
+ }
+ }
+
+
+ ((ComboBox*)pControl)->SetText( aString1 );
+ ((ComboBox*)pControl)->SetModifyFlag();
+ ((ComboBox*)pControl)->Modify();
+ break;
+ case M_SetText :
+ if ( ! ((ComboBox*)pControl)->IsReadOnly() )
+ {
+ if ( ! (nParams & PARAM_STR_1) )
+ aString1 = String();
+ ((ComboBox*)pControl)->SetText( aString1 );
+ ((ComboBox*)pControl)->SetModifyFlag();
+ ((ComboBox*)pControl)->Modify();
+ }
+ else
+ ReportError( aUId, GEN_RES_STR1c( S_ATTEMPT_TO_WRITE_READONLY, "ComboBox" ) );
+ break;
+ default:
+ ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "ComboBox" ) );
+ break;
+ }
+ break;
+ case C_PushButton:
+ case C_OkButton:
+ case C_CancelButton:
+ case C_ImageButton:
+ switch( nMethodId )
+ {
+ case M_AnimateMouse :
+ AnimateMouse( pControl, Mitte);
+ break;
+ case M_Click :
+ ((PushButton*)pControl)->Click();
+ break;
+ default:
+ ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "PushButton" ) );
+ break;
+ }
+ break;
+ case C_MoreButton:
+ switch( nMethodId )
+ {
+ case M_AnimateMouse :
+ AnimateMouse( pControl, Mitte);
+ break;
+ case M_IsOpen :
+ pRet->GenReturn ( RET_Value, aUId, ((MoreButton*)pControl)->GetState());
+ break;
+ case M_Click :
+ ((MoreButton*)pControl)->Click();
+ break;
+ case M_Open :
+ ((MoreButton*)pControl)->SetState(sal_True);
+ break;
+ case M_Close :
+ ((MoreButton*)pControl)->SetState(sal_False);
+ break;
+ default:
+ ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "MoreButton" ) );
+ break;
+ }
+ break;
+ case C_SpinField:
+ case C_PatternField:
+ case C_NumericField:
+ case C_MetricField:
+ case C_CurrencyField:
+ case C_DateField:
+ case C_TimeField:
+ switch( nMethodId )
+ {
+ case M_AnimateMouse :
+ AnimateMouse( pControl, Mitte);
+ break;
+ case M_GetText :
+ pRet->GenReturn ( RET_Value, aUId, ((SpinField*)pControl)->GetText());
+ break;
+ case M_IsWritable:
+ pRet->GenReturn ( RET_Value, aUId, (comm_BOOL) !((SpinField*)pControl)->IsReadOnly() );
+ break;
+ case M_SetText :
+ if ( ! ((SpinField*)pControl)->IsReadOnly() )
+ {
+ ((SpinField*)pControl)->SetText( aString1 );
+ ((SpinField*)pControl)->SetModifyFlag();
+ ((SpinField*)pControl)->Modify();
+ }
+ else
+ ReportError( aUId, GEN_RES_STR1c( S_ATTEMPT_TO_WRITE_READONLY, "SpinField" ) );
+ break;
+ case M_More :
+ {
+ if ( !(nParams & PARAM_USHORT_1) )
+ nNr1 = 1;
+ for (int i = 1; i<= nNr1; i++)
+ {
+ ((SpinField*)pControl)->Up();
+ ((SpinField*)pControl)->SetModifyFlag();
+ ((SpinField*)pControl)->Modify();
+ }
+ }
+ break;
+ case M_Less :
+ {
+ if ( !(nParams & PARAM_USHORT_1) )
+ nNr1 = 1;
+ for (int i = 1; i<= nNr1; i++)
+ {
+ ((SpinField*)pControl)->Down();
+ ((SpinField*)pControl)->SetModifyFlag();
+ ((SpinField*)pControl)->Modify();
+ }
+ }
+ break;
+ case M_ToMin :
+ ((SpinField*)pControl)->First();
+ ((SpinField*)pControl)->SetModifyFlag();
+ ((SpinField*)pControl)->Modify();
+ break;
+ case M_ToMax :
+ ((SpinField*)pControl)->Last();
+ ((SpinField*)pControl)->SetModifyFlag();
+ ((SpinField*)pControl)->Modify();
+ break;
+ default:
+ ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "SpinField" ) );
+ break;
+ }
+ break;
+
+ case C_MenuButton:
+ switch( nMethodId )
+ {
+ case M_AnimateMouse :
+ AnimateMouse( pControl, Mitte);
+ break;
+ case M_Click :
+ {
+ MouseEvent aMEvnt;
+ Point aPt( pControl->GetSizePixel().Width() / 2, pControl->GetSizePixel().Height() / 2 );
+ aMEvnt = MouseEvent( aPt,1,MOUSE_SIMPLECLICK,MOUSE_LEFT );
+ ImplMouseButtonDown( pControl, aMEvnt, FORCE_DIRECT_CALL );
+ ImplMouseButtonUp ( pControl, aMEvnt, FORCE_DIRECT_CALL );
+ }
+ break;
+ case M_Open :
+ case M_OpenMenu :
+ {
+ MouseEvent aMEvnt;
+ Point aPt( pControl->GetSizePixel().Width() / 2, pControl->GetSizePixel().Height() / 2 );
+ aMEvnt = MouseEvent( aPt,1,MOUSE_SIMPLECLICK,MOUSE_LEFT );
+ ImplMouseButtonDown( pControl, aMEvnt, FORCE_DIRECT_CALL );
+
+ sal_uLong nStart = Time::GetSystemTicks();
+ sal_uLong nDelay = pControl->GetSettings().GetMouseSettings().GetActionDelay();
+ while ( ( Time::GetSystemTicks() - nStart ) < nDelay + 100 )
+ SafeReschedule();
+
+ ImplMouseButtonUp ( pControl, aMEvnt, FORCE_DIRECT_CALL );
+
+ aSubMenuId1 = 0;
+ aSubMenuId2 = 0;
+ aSubMenuId3 = 0;
+ pMenuWindow = NULL;
+ }
+ break;
+ default:
+ ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "MenuButton" ) );
+ break;
+ }
+ break;
+ case C_ToolBox:
+ {
+ ToolBox *pTB = ((ToolBox*)pControl);
+ if ( !aUId.equals( pTB->GetUniqueOrHelpId() ) ) // So we found a Button on the ToolBox
+ {
+ if ( (nParams == PARAM_NONE) || (nParams == PARAM_USHORT_1) )
+ { // Wir fälschen einen Parameter
+ nParams |= PARAM_STR_1;
+ aString1 = Id2Str( aUId );
+ }
+ else
+ ReportError( aUId, GEN_RES_STR1( S_INTERNAL_ERROR, MethodString( nMethodId ) ) );
+ }
+
+#define FIND_ITEM\
+ sal_uInt16 nItemPos = 0;\
+ sal_Bool bItemFound = sal_False;\
+ {\
+ rtl::OString aButtonId;\
+ if( nParams & PARAM_STR_1 )\
+ aButtonId = Str2Id( aString1 );\
+ else\
+ ReportError( aUId, GEN_RES_STR1( S_INTERNAL_ERROR, MethodString( nMethodId ) ) );\
+ for ( nItemPos = 0; nItemPos < pTB->GetItemCount() && !aButtonId.equals(Str2Id( pTB->GetItemCommand(pTB->GetItemId(nItemPos)) )) &&\
+ !aButtonId.equals(pTB->GetHelpId(pTB->GetItemId(nItemPos))) ; nItemPos++ ) {}\
+ bItemFound = aButtonId.equals(Str2Id( pTB->GetItemCommand(pTB->GetItemId(nItemPos)) )) || aButtonId.equals(pTB->GetHelpId(pTB->GetItemId(nItemPos)));\
+ if ( !bItemFound )\
+ ReportError( aUId, GEN_RES_STR1( S_HELPID_ON_TOOLBOX_NOT_FOUND, MethodString( nMethodId ) ) );\
+ else\
+ {\
+ if ( !pTB->IsItemEnabled( pTB->GetItemId(nItemPos) ) && nMethodId != _M_IsEnabled && nMethodId != M_GetState )\
+ {\
+ ReportError( aUId, GEN_RES_STR1( S_BUTTON_DISABLED_ON_TOOLBOX, MethodString( nMethodId ) ) );\
+ bItemFound = sal_False;\
+ }\
+ else if ( !pTB->IsItemVisible( pTB->GetItemId(nItemPos) ) && nMethodId != M_GetState )\
+ {\
+ ReportError( aUId, GEN_RES_STR1( S_BUTTON_HIDDEN_ON_TOOLBOX, MethodString( nMethodId ) ) );\
+ bItemFound = sal_False;\
+ }\
+ else\
+ {\
+ if ( pTB->IsMenuEnabled() )\
+ { /* button is in Menu */\
+ }\
+ else\
+ { /* Try the multi line way */\
+ if ( pTB->GetItemRect(pTB->GetItemId(nItemPos)).IsEmpty() )\
+ {\
+ sal_uInt16 nLine = pTB->GetCurLine();\
+ do\
+ {\
+ pTB->ShowLine( sal_False );\
+ for ( int i = 1 ; i < 30 ; i++ )\
+ SafeReschedule();\
+ }\
+ while ( pTB->GetCurLine() != nLine && pTB->GetItemRect(pTB->GetItemId(nItemPos)).IsEmpty() );\
+ pTB->Invalidate( pTB->GetScrollRect() );\
+ }\
+ if ( pTB->GetItemRect(pTB->GetItemId(nItemPos)).IsEmpty() )\
+ {\
+ ReportError( aUId, GEN_RES_STR1( S_CANNOT_MAKE_BUTTON_VISIBLE_IN_TOOLBOX, MethodString( nMethodId ) ) );\
+ bItemFound = sal_False;\
+ }\
+ }\
+ }\
+ }\
+ }
+
+ switch( nMethodId )
+ {
+ case M_AnimateMouse :
+ AnimateMouse( pControl, MitteLinks);
+ break;
+ case M_Click :
+ {
+ FIND_ITEM;
+ if ( bItemFound ) // FIND_ITEM Erfolgreich
+ {
+ Rectangle aRect = pTB->GetItemRect(pTB->GetItemId(nItemPos));
+ if ( aRect.IsEmpty() )
+ {
+ pTB->ExecuteCustomMenu();
+/* aRect = pTB->GetMenubuttonRect();
+ MouseEvent aMEvnt(aRect.Center(),1,MOUSE_SIMPLECLICK,MOUSE_LEFT);
+ ImplMouseButtonDown( pTB, aMEvnt );*/
+
+ aSubMenuId1 = 0;
+ aSubMenuId2 = 0;
+ aSubMenuId3 = 0;
+ pMenuWindow = NULL;
+
+ new StatementCommand( this, RC_MenuSelect, PARAM_USHORT_1, pTB->GetItemId(nItemPos) + TOOLBOX_MENUITEM_START );
+ }
+ else
+ {
+ aRect = pTB->GetItemRect(pTB->GetItemId(nItemPos));
+ MouseEvent aMEvnt;
+ aMEvnt = MouseEvent(aRect.Center(),1,MOUSE_SIMPLECLICK,MOUSE_LEFT);
+ ImplMouseButtonDown( pTB, aMEvnt, FORCE_DIRECT_CALL );
+ ImplMouseButtonUp ( pTB, aMEvnt, FORCE_DIRECT_CALL );
+ }
+ }
+ }
+ break;
+ case M_TearOff :
+ {
+ FIND_ITEM;
+ if ( bItemFound ) // FIND_ITEM Erfolgreich
+ {
+ Rectangle aRect = pTB->GetItemPosDropDownRect( nItemPos );
+ AnimateMouse( pControl, aRect.Center() );
+ MouseEvent aMEvnt(aRect.Center(),1,MOUSE_SIMPLECLICK,MOUSE_LEFT);
+ ImplMouseButtonDown( pTB, aMEvnt, FORCE_DIRECT_CALL );
+
+ Window *pWin = NULL;
+ // Wait for the window to open.
+ StatementList::bExecuting = sal_True; // Bah ist das ein ekliger Hack
+ { // Das verhindert, daß schon der nächste Befehl ausgeführt wird.
+ Time aDelay;
+ while ( !pWin && ( (pWin = GetPopupFloatingWin()) == NULL ) && ( Time() - aDelay ).GetSec() < 15 )
+ SafeReschedule();
+ }
+ StatementList::bExecuting = sal_False; // Bah ist das ein ekliger Hack
+
+ if ( pWin && pWin->GetType() == WINDOW_FLOATINGWINDOW )
+ {
+ aMEvnt = MouseEvent(aRect.Center(),1,MOUSE_SIMPLECLICK,MOUSE_LEFT);
+ ImplMouseButtonUp( pTB, aMEvnt, FORCE_DIRECT_CALL );
+ ((FloatingWindow*)pWin)->EndPopupMode( FLOATWIN_POPUPMODEEND_TEAROFF );
+ }
+ else
+ {
+ aMEvnt = MouseEvent(Point(1,-10), 1, MOUSE_SIMPLECLICK,MOUSE_LEFT);
+ ImplMouseButtonUp( pTB, aMEvnt, FORCE_DIRECT_CALL );
+ ReportError( aUId, GEN_RES_STR1( S_TEAROFF_FAILED, MethodString( nMethodId ) ) );
+ }
+ }
+ }
+ break;
+ case M_OpenMenu :
+ {
+ FIND_ITEM;
+ if ( bItemFound ) // FIND_ITEM Erfolgreich
+ {
+ Rectangle aRect = pTB->GetItemPosDropDownRect( nItemPos );
+ AnimateMouse( pControl, aRect.Center() );
+ MouseEvent aMEvnt(aRect.Center(),1,MOUSE_SIMPLECLICK,MOUSE_LEFT);
+ ImplMouseButtonDown( pTB, aMEvnt);
+ ImplMouseButtonUp( pTB, aMEvnt);
+
+ // Das Fenster ist offen.
+ aSubMenuId1 = 0;
+ aSubMenuId2 = 0;
+ aSubMenuId3 = 0;
+ pMenuWindow = NULL;
+ }
+ }
+ break;
+ case _M_IsEnabled:
+ {
+ FIND_ITEM;
+ if ( bItemFound ) // FIND_ITEM Erfolgreich
+ {
+ pRet->GenReturn ( RET_Value, aUId, pTB->IsItemEnabled( pTB->GetItemId(nItemPos) ) );
+ }
+ }
+ break;
+ case M_GetState :
+ {
+ FIND_ITEM;
+ if ( bItemFound ) // FIND_ITEM Erfolgreich
+ {
+ if ( ValueOK( aUId, CUniString("GetState"), nNr1, 4 ) )
+ switch (nNr1)
+ {
+ case 0:
+ pRet->GenReturn ( RET_Value, aUId, Id2Str( pTB->GetHelpId(pTB->GetItemId(nItemPos)) ) );
+ break;
+ case 1:
+ pRet->GenReturn ( RET_Value, aUId, (comm_ULONG)pTB->GetItemType(nItemPos));
+ break;
+ case 2:
+ pRet->GenReturn ( RET_Value, aUId, (comm_ULONG)pTB->GetItemState(pTB->GetItemId(nItemPos)));
+ break;
+ case 3:
+ pRet->GenReturn ( RET_Value, aUId, (comm_ULONG)pTB->GetItemId(nItemPos));
+ break;
+ default:
+ ReportError( aUId, GEN_RES_STR1( S_INTERNAL_ERROR, MethodString( nMethodId ) ) );
+ pRet->GenReturn ( RET_Value, aUId, comm_ULONG(0));
+ break;
+ }
+ }
+ }
+ break;
+ case M_GetItemText :
+ pRet->GenReturn ( RET_Value, aUId, (String)pTB->GetItemText(nNr1));
+ break;
+ case M_GetText :
+ pRet->GenReturn ( RET_Value, aUId, (String)pTB->GetText());
+ break;
+ case M_GetItemCount :
+ pRet->GenReturn ( RET_Value, aUId, (comm_ULONG)pTB->GetItemCount());
+ break;
+ case M_SetNextToolBox :
+ if ( (nParams & PARAM_STR_1) )
+ pTB->SetNextToolBox( aString1 );
+ else
+ pTB->SetNextToolBox( pTB->GetNextToolBox() );
+ pTB->NextToolBox();
+ break;
+ case M_GetNextToolBox :
+ pRet->GenReturn ( RET_Value, aUId, (String)pTB->GetNextToolBox());
+ break;
+ case M_Dock :
+ case M_Undock :
+ case M_IsDocked :
+ case M_Close:
+ case M_Size:
+ case M_Move:
+ case M_IsMax:
+ case M_Minimize:
+ case M_Maximize:
+ case M_Help: // Alles was unten weiterbehandelt werden soll
+ goto DockingWin;
+ default:
+ ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "ToolBox" ) );
+ break;
+ }
+ }
+ break;
+
+ case C_TreeListBox:
+ switch( nMethodId )
+ {
+
+
+
+#define GET_NTH_ENTRY_LBOX( First, Next, Anzahl) \
+ SvLBoxEntry *pThisEntry = ((SvTreeListBox*)pControl)->First(); \
+ { \
+ int niTemp = Anzahl; \
+ while ( niTemp-- ) \
+ { \
+ pThisEntry = ((SvTreeListBox*)pControl)->Next( pThisEntry ); \
+ } \
+ }
+
+ case M_GetText : // Get the first text of the given (default=1) line
+ { // should get removed some time
+ SvTreeListBox *pTree = (SvTreeListBox*)pControl;
+ SvLBoxEntry *pThisEntry = pTree->GetCurEntry();
+ if ( ! (nParams & PARAM_USHORT_1) )
+ nNr1 = 1;
+ if ( pThisEntry )
+ {
+ SvLBoxString* pItem = NULL;
+ sal_uInt16 nValidTextItemCount = 0;
+ {
+ sal_uInt16 nIndex = 0;
+ SvLBoxItem *pMyItem;
+ while ( ( nValidTextItemCount < nNr1 ) && nIndex < pThisEntry->ItemCount() )
+ {
+ pMyItem = pThisEntry->GetItem( nIndex );
+ if ( pMyItem->IsA() == SV_ITEM_ID_LBOXSTRING )
+ {
+ pItem = (SvLBoxString*)pMyItem;
+ nValidTextItemCount++;
+ }
+ nIndex++;
+ }
+ }
+ if ( ValueOK( aUId, CUniString("GetText"), nNr1, nValidTextItemCount ) )
+ pRet->GenReturn ( RET_Value, aUId, pItem->GetText() );
+ }
+ else
+ ReportError( aUId, GEN_RES_STR2c2( S_NO_SELECTED_ENTRY, MethodString( nMethodId ), "TreeListBox" ) );
+ }
+ break;
+ case M_GetSelCount :
+ pRet->GenReturn ( RET_Value, aUId, comm_ULONG(((SvLBox*)pControl)->GetSelectionCount()));
+ break;
+ case M_GetItemCount :
+ pRet->GenReturn ( RET_Value, aUId, comm_ULONG(((SvLBox*)pControl)->GetVisibleCount()) );
+ break;
+ case M_GetSelIndex :
+ if ( ! (nParams & PARAM_USHORT_1) )
+ nNr1 = 1;
+ if ( ValueOK(aUId, CUniString("GetSelIndex"),nNr1,((SvLBox*)pControl)->GetSelectionCount()) )
+ {
+ nNr1--;
+ GET_NTH_ENTRY_LBOX( FirstSelected, NextSelected, nNr1);
+ pRet->GenReturn ( RET_Value, aUId, comm_ULONG( ((SvTreeListBox*)pControl)->GetVisiblePos( pThisEntry )) +1 );
+ }
+ break;
+ case M_Select :
+ if ( ! (nParams & PARAM_BOOL_1) )
+ bBool1 = sal_True;
+ if( nParams & PARAM_STR_1 )
+ {
+/* ListBox *pLB = ((ListBox*)pControl);
+ if ( pLB->GetEntryPos( aString1 ) == LISTBOX_ENTRY_NOTFOUND )
+ ReportError( aUId, GEN_RES_STR2( S_ENTRY_NOT_FOUND, MethodString( nMethodId ), aString1 ) );
+ else
+ {
+ pLB->SelectEntry( aString1, bBool1 );
+ if ( pLB->IsEntrySelected( aString1 ) ? !bBool1 : bBool1 ) // XOR rein mit BOOL
+ ReportError( aUId, GEN_RES_STR2( S_METHOD_FAILED, MethodString( nMethodId ), aString1 ) );
+ }
+*/ ReportError( aUId, GEN_RES_STR1( S_SELECT_DESELECT_VIA_STRING_NOT_IMPLEMENTED, MethodString( nMethodId ) ) );
+ }
+ else
+ {
+ if ( ValueOK(aUId, MethodString( nMethodId ),nNr1,((SvLBox*)pControl)->GetVisibleCount()) )
+ {
+ SvLBoxEntry *pEntry = (SvLBoxEntry*)((SvTreeListBox*)pControl)->GetEntryAtVisPos( nNr1-1 );
+ ((SvTreeListBox*)pControl)->Select ( pEntry, bBool1 );
+ }
+ }
+ break;
+ case M_GetSelText :
+ if ( ! (nParams & PARAM_USHORT_1) )
+ nNr1 = 1;
+ if ( ! (nParams & PARAM_USHORT_2) )
+ nNr2 = 1;
+ if ( ValueOK(aUId, CUniString("GetSelText"),nNr1,((SvLBox*)pControl)->GetSelectionCount()) )
+ {
+ nNr1--;
+ GET_NTH_ENTRY_LBOX( FirstSelected, NextSelected, nNr1);
+ if ( ValueOK( aUId, MethodString( nMethodId ),nNr2,pThisEntry->ItemCount() ) )
+ {
+ SvLBoxString* pItem = NULL;
+ if ( ! (nParams & PARAM_USHORT_2) )
+ pItem = (SvLBoxString*)pThisEntry->GetFirstItem( SV_ITEM_ID_LBOXSTRING );
+ else
+ {
+ SvLBoxItem *pMyItem = pThisEntry->GetItem( nNr2-1 );
+ if ( pMyItem->IsA() == SV_ITEM_ID_LBOXSTRING )
+ pItem = (SvLBoxString*)pMyItem;
+ }
+
+ if ( pItem )
+ pRet->GenReturn ( RET_Value, aUId, pItem->GetText() );
+ else
+ ReportError( aUId, GEN_RES_STR1( S_NO_LIST_BOX_STRING, MethodString( nMethodId ) ) );
+ }
+ }
+ break;
+ case M_GetItemText :
+ if ( ValueOK(aUId, MethodString( nMethodId ),nNr1,((SvLBox*)pControl)->GetVisibleCount()) )
+ {
+ SvLBoxEntry *pThisEntry = (SvLBoxEntry*)((SvTreeListBox*)pControl)->GetEntryAtVisPos( nNr1-1 );
+ if ( ! (nParams & PARAM_USHORT_2) )
+ nNr2 = 1;
+ if ( ValueOK( aUId, MethodString( nMethodId ),nNr2,pThisEntry->ItemCount() ) )
+ {
+ SvLBoxString* pItem = NULL;
+ if ( ! (nParams & PARAM_USHORT_2) )
+ pItem = (SvLBoxString*)pThisEntry->GetFirstItem( SV_ITEM_ID_LBOXSTRING );
+ else
+ {
+ SvLBoxItem *pMyItem = pThisEntry->GetItem( nNr2-1 );
+ if ( pMyItem->IsA() == SV_ITEM_ID_LBOXSTRING )
+ pItem = (SvLBoxString*)pMyItem;
+ }
+
+ if ( pItem )
+ pRet->GenReturn ( RET_Value, aUId, pItem->GetText() );
+ else
+ ReportError( aUId, GEN_RES_STR1( S_NO_LIST_BOX_STRING, MethodString( nMethodId ) ) );
+ }
+ }
+ break;
+ case M_IsChecked :
+ case M_IsTristate :
+ case M_GetState :
+ case M_Check :
+ case M_UnCheck :
+ case M_TriState :
+ {
+ SvTreeListBox *pTree = (SvTreeListBox*)pControl;
+ SvLBoxEntry *pThisEntry = NULL;
+
+ if ( ! (nParams & PARAM_USHORT_1) )
+ {
+ pThisEntry = pTree->GetCurEntry();
+ if ( !pThisEntry )
+ ReportError( aUId, GEN_RES_STR2c2( S_NO_SELECTED_ENTRY, MethodString( nMethodId ), "TreeListBox" ) );
+ }
+ else
+ {
+ if ( ValueOK(aUId, MethodString( nMethodId ),nNr1,((SvLBox*)pControl)->GetVisibleCount()) )
+ {
+ pThisEntry = (SvLBoxEntry*)pTree->GetEntryAtVisPos( nNr1-1 );
+ }
+ }
+
+ if ( ! (nParams & PARAM_USHORT_2) )
+ nNr2 = 1;
+
+ if ( pThisEntry )
+ {
+ if ( ValueOK( aUId, MethodString( nMethodId ),nNr2,pThisEntry->ItemCount() ) )
+ {
+ SvLBoxButton* pItem = NULL;
+ if ( ! (nParams & PARAM_USHORT_2) )
+ pItem = (SvLBoxButton*)pThisEntry->GetFirstItem( SV_ITEM_ID_LBOXBUTTON );
+ else
+ {
+ SvLBoxItem *pMyItem = pThisEntry->GetItem( nNr2-1 );
+ if ( pMyItem->IsA() == SV_ITEM_ID_LBOXBUTTON )
+ pItem = (SvLBoxButton*)pMyItem;
+ }
+
+ if ( pItem )
+ {
+ switch( nMethodId )
+ {
+ case M_IsChecked :
+ pRet->GenReturn ( RET_Value, aUId, comm_BOOL( pItem->IsStateChecked() ) );
+ break;
+ case M_IsTristate :
+ pRet->GenReturn ( RET_Value, aUId, comm_BOOL( pItem->IsStateTristate() ) );
+ break;
+ case M_GetState :
+ pRet->GenReturn ( RET_Value, aUId, comm_ULONG( pItem->GetButtonFlags() & ~SV_STATE_MASK ));
+ break;
+ case M_Check :
+ if ( !pItem->IsStateChecked() )
+ {
+ pItem->SetStateChecked();
+ pTree->CheckButtonHdl();
+ pTree->InvalidateEntry( pThisEntry );
+ }
+ break;
+ case M_UnCheck :
+ if ( pItem->IsStateChecked() || pItem->IsStateTristate() )
+ {
+ pItem->SetStateUnchecked();
+ pTree->CheckButtonHdl();
+ pTree->InvalidateEntry( pThisEntry );
+ }
+ break;
+ case M_TriState :
+ if ( !pItem->IsStateTristate() )
+ {
+ pItem->SetStateTristate();
+ pTree->CheckButtonHdl();
+ pTree->InvalidateEntry( pThisEntry );
+ }
+ break;
+ default:
+ ReportError( aUId, GEN_RES_STR1( S_INTERNAL_ERROR, MethodString( nMethodId ) ) );
+ break;
+ }
+ }
+ else
+ ReportError( aUId, GEN_RES_STR1( S_NO_LIST_BOX_BUTTON, MethodString( nMethodId ) ) );
+ }
+ }
+ }
+ break;
+ case M_GetItemType :
+ {
+ SvTreeListBox *pTree = (SvTreeListBox*)pControl;
+ SvLBoxEntry *pThisEntry = NULL;
+
+ if ( ! (nParams & PARAM_USHORT_1) )
+ {
+ pThisEntry = pTree->GetCurEntry();
+ if ( !pThisEntry )
+ ReportError( aUId, GEN_RES_STR2c2( S_NO_SELECTED_ENTRY, MethodString( nMethodId ), "TreeListBox" ) );
+ }
+ else
+ {
+ if ( ValueOK(aUId, MethodString( nMethodId ),nNr1,((SvLBox*)pControl)->GetVisibleCount()) )
+ {
+ pThisEntry = (SvLBoxEntry*)pTree->GetEntryAtVisPos( nNr1-1 );
+ }
+ }
+
+ if ( pThisEntry )
+ {
+ if ( ! (nParams & PARAM_USHORT_2) )
+ nNr2 = 1;
+ if ( ValueOK( aUId, MethodString( nMethodId ),nNr2,pThisEntry->ItemCount() ) )
+ {
+ SvLBoxItem *pMyItem = pThisEntry->GetItem( nNr2-1 );
+ comm_USHORT nType;
+ switch ( pMyItem->IsA() )
+ {
+ case SV_ITEM_ID_LBOXSTRING: nType = CONST_ItemTypeText ; break;
+ case SV_ITEM_ID_LBOXBMP: nType = CONST_ItemTypeBMP ; break;
+ case SV_ITEM_ID_LBOXBUTTON: nType = CONST_ItemTypeCheckbox ; break;
+ case SV_ITEM_ID_LBOXCONTEXTBMP: nType = CONST_ItemTypeContextBMP ; break;
+ default: nType = CONST_ItemTypeUnknown;
+ }
+ pRet->GenReturn ( RET_Value, aUId, nType );
+ }
+ }
+ }
+ break;
+ default:
+ ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "TreeListBox" ) );
+ break;
+ }
+ break;
+ case C_Control:
+ {
+ sal_uInt16 nRealControlType = 0;
+ if ( dynamic_cast< EditBrowseBox* >(pControl) )
+ nRealControlType = CONST_CTBrowseBox;
+ else if ( dynamic_cast< ValueSet* >(pControl) )
+ nRealControlType = CONST_CTValueSet;
+ else if ( dynamic_cast< ORoadmap* >(pControl) )
+ nRealControlType = CONST_CTORoadmap;
+ else if ( dynamic_cast< IExtensionListBox* >(pControl) )
+ nRealControlType = CONST_CTIExtensionListBox;
+ else if ( dynamic_cast< ::svt::table::TableControl* >(pControl) )
+ nRealControlType = CONST_CTTableControl;
+ else
+ nRealControlType = CONST_CTUnknown;
+
+ switch( nMethodId )
+ {
+ case M_AnimateMouse :
+ AnimateMouse( pControl, MitteOben);
+ break;
+ default:
+ switch( nRealControlType )
+ {
+ case CONST_CTBrowseBox:
+ {
+ EditBrowseBox* pEBBox = dynamic_cast< EditBrowseBox* >(pControl);
+ switch( nMethodId )
+ {
+
+
+ /*
+
+
+ sal_Bool MakeFieldVisible( long nRow, sal_uInt16 nColId, sal_Bool bComplete = sal_False );
+ // access to dynamic values of cursor row
+ String GetColumnTitle( sal_uInt16 nColumnId ) const;
+ sal_uInt16 GetColumnId( sal_uInt16 nPos ) const;
+ sal_uInt16 GetColumnPos( sal_uInt16 nColumnId ) const;
+ // access and movement of cursor
+ long GetCurRow() const { return nCurRow; }
+ sal_uInt16 GetCurColumnId() const { return nCurColId; }
+ sal_Bool GoToRow( long nRow );
+ sal_Bool GoToRowAndDoNotModifySelection( long nRow );
+ sal_Bool GoToColumnId( sal_uInt16 nColId );
+ sal_Bool GoToRowColumnId( long nRow, sal_uInt16 nColId );
+ // selections
+ void SetNoSelection();
+ void SelectAll();
+ void SelectRow( long nRow, sal_Bool bSelect = sal_True, sal_Bool bExpand = sal_True );
+ void SelectColumnPos( sal_uInt16 nCol, sal_Bool bSelect = sal_True )
+ { SelectColumnPos( nCol, bSelect, sal_True); }
+ void SelectColumnId( sal_uInt16 nColId, sal_Bool bSelect = sal_True )
+ { SelectColumnPos( GetColumnPos(nColId), bSelect, sal_True); }
+ long GetSelectRowCount() const;
+ sal_uInt16 GetSelectColumnCount() const;
+ sal_Bool IsRowSelected( long nRow ) const;
+ sal_Bool IsColumnSelected( sal_uInt16 nColumnId ) const;
+ long FirstSelectedRow( sal_Bool bInverse = sal_False );
+ long LastSelectedRow( sal_Bool bInverse = sal_False );
+ long PrevSelectedRow();
+ long NextSelectedRow();
+ const MultiSelection* GetSelection() const
+ { return bMultiSelection ? uRow.pSel : 0; }
+ void SetSelection( const MultiSelection &rSelection );
+
+ virtual String GetCellText(long _nRow, sal_uInt16 _nColId) const;
+ sal_uInt16 GetColumnCount() const { return ColCount(); }
+protected:
+ virtual long GetRowCount() const;
+
+
+ EditBrowseBox
+
+ sal_Bool IsEditing() const {return aController.Is();}
+ void InvalidateStatusCell(long nRow) {RowModified(nRow, 0);}
+ void InvalidateHandleColumn();
+
+ CellControllerRef Controller() const { return aController; }
+ sal_Int32 GetBrowserFlags() const { return m_nBrowserFlags; }
+
+ virtual void ActivateCell(long nRow, sal_uInt16 nCol, sal_Bool bSetCellFocus = sal_True);
+ virtual void DeactivateCell(sal_Bool bUpdate = sal_True);
+
+
+
+ */
+ case M_GetSelText :
+ {
+ pRet->GenReturn ( RET_Value, aUId, pEBBox->GetCellText( pEBBox->GetCurrRow(), pEBBox->GetColumnId( pEBBox->GetCurrColumn() )));
+ }
+ break;
+ case M_GetColumnCount :
+ {
+ sal_uInt16 nColCount = pEBBox->GetColumnCount();
+ comm_USHORT nUnfrozenColCount = 0;
+ sal_uInt16 i;
+ for ( i=0 ; i < nColCount ; i++ )
+ {
+ if ( !pEBBox->IsFrozen( pEBBox->GetColumnId( i ) ) )
+ nUnfrozenColCount++;
+ }
+ pRet->GenReturn ( RET_Value, aUId, nUnfrozenColCount );
+ }
+ break;
+ case M_GetRowCount :
+ {
+ pRet->GenReturn ( RET_Value, aUId, (comm_ULONG)pEBBox->GetRowCount() );
+ }
+ break;
+ case M_IsEditing :
+ {
+ CellControllerRef aControler;
+ aControler = pEBBox->Controller();
+ pRet->GenReturn ( RET_Value, aUId, (comm_BOOL)aControler.Is() );
+ }
+ break;
+ case M_Select :
+ {
+ if ( ValueOK(aUId, MethodString( nMethodId ),nNr1,pEBBox->GetRowCount() ) )
+ {
+ sal_uInt16 nColCount = pEBBox->GetColumnCount();
+ comm_USHORT nUnfrozenColCount = 0;
+ sal_uInt16 i;
+ for ( i=0 ; i < nColCount ; i++ )
+ {
+ if ( !pEBBox->IsFrozen( pEBBox->GetColumnId( i ) ) )
+ nUnfrozenColCount++;
+ }
+ if ( ValueOK(aUId, MethodString( nMethodId ),nNr2,nUnfrozenColCount ) )
+ pEBBox->GoToRowColumnId( nNr1-1, pEBBox->GetColumnId( nNr2 ) );
+ }
+ }
+ break;
+
+
+
+ /*
+ case M_GetSelCount :
+ pRet->GenReturn ( RET_Value, aUId, comm_ULONG(((SvLBox*)pControl)->GetSelectionCount()));
+ break;
+ case M_GetSelIndex :
+ if ( ! (nParams & PARAM_USHORT_1) )
+ nNr1 = 1;
+ if ( ValueOK(aUId, CUniString("GetSelIndex"),nNr1,((SvLBox*)pControl)->GetSelectionCount()) )
+ {
+ nNr1--;
+ COUNT_LBOX( FirstSelected, NextSelected, nNr1);
+ pRet->GenReturn ( RET_Value, aUId, comm_ULONG( ((SvTreeListBox*)pControl)->GetVisiblePos( pThisEntry )) +1 );
+ }
+ break;
+ case M_GetSelText :
+ if ( ! (nParams & PARAM_USHORT_1) )
+ nNr1 = 1;
+ if ( ValueOK(aUId, CUniString("GetSelText"),nNr1,((SvLBox*)pControl)->GetSelectionCount()) )
+ {
+ nNr1--;
+ COUNT_LBOX( FirstSelected, NextSelected, nNr1);
+ GetFirstValidTextItem( pThisEntry );
+ pRet->GenReturn ( RET_Value, aUId, pItem->GetText() );
+ }
+ break;
+ case M_GetItemCount :
+ pRet->GenReturn ( RET_Value, aUId, comm_ULONG(((SvLBox*)pControl)->GetVisibleCount()) );
+ break;
+ case M_GetItemText :
+ if ( ValueOK(aUId, MethodString( nMethodId ),nNr1,((SvLBox*)pControl)->GetVisibleCount()) )
+ {
+ SvLBoxEntry *pEntry = (SvLBoxEntry*)((SvTreeListBox*)pControl)->GetEntryAtVisPos( nNr1-1 );
+ GetFirstValidTextItem( pEntry );
+ pRet->GenReturn ( RET_Value, aUId, pItem->GetText() );
+ }
+ break;
+ case M_Select :
+ if ( ! (nParams & PARAM_BOOL_1) )
+ bBool1 = sal_True;
+ if( nParams & PARAM_STR_1 )
+ {
+ / * ListBox *pLB = ((ListBox*)pControl);
+ if ( pLB->GetEntryPos( aString1 ) == LISTBOX_ENTRY_NOTFOUND )
+ ReportError( aUId, GEN_RES_STR2( S_ENTRY_NOT_FOUND, MethodString( nMethodId ), aString1 ) );
+ else
+ {
+ pLB->SelectEntry( aString1, bBool1 );
+ if ( pLB->IsEntrySelected( aString1 ) ? !bBool1 : bBool1 ) // XOR rein mit BOOL
+ ReportError( aUId, GEN_RES_STR2( S_METHOD_FAILED, MethodString( nMethodId ), aString1 ) );
+ }
+ * / ReportError( aUId, GEN_RES_STR1( S_SELECT_DESELECT_VIA_STRING_NOT_IMPLEMENTED, MethodString( nMethodId ) ) );
+ }
+ else
+ {
+ if ( ValueOK(aUId, MethodString( nMethodId ),nNr1,((SvLBox*)pControl)->GetVisibleCount()) )
+ {
+ SvLBoxEntry *pEntry = (SvLBoxEntry*)((SvTreeListBox*)pControl)->GetEntryAtVisPos( nNr1-1 );
+ ((SvTreeListBox*)pControl)->Select ( pEntry, bBool1 );
+ }
+ }
+ break;*/
+ default:
+ ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "EditBrowseBox" ) );
+ break;
+ }
+ }
+ break;
+ case CONST_CTValueSet:
+ {
+ ValueSet *pVS = dynamic_cast< ValueSet* >(pControl);
+ switch ( nMethodId )
+ {
+ case M_GetItemCount:
+ pRet->GenReturn ( RET_Value, aUId, comm_ULONG( pVS->GetItemCount()));
+ break;
+ case M_GetItemText:
+ if ( ValueOK( aUId, MethodString( nMethodId ), nNr1, pVS->GetItemCount() ))
+ pRet->GenReturn ( RET_Value, aUId, pVS->GetItemText( pVS->GetItemId( nNr1-1 ) ) );
+ break;
+ case M_Select:
+ if ( ValueOK( aUId, MethodString( nMethodId ), nNr1, pVS->GetItemCount() ))
+ pVS->SelectItem( pVS->GetItemId( nNr1-1 ) );
+ break;
+ case M_GetSelIndex :
+ if ( pVS->IsNoSelection() )
+ pRet->GenReturn ( RET_Value, aUId, comm_ULONG(0));
+ else
+ pRet->GenReturn ( RET_Value, aUId, comm_ULONG( pVS->GetItemPos( pVS->GetSelectItemId() ) +1));
+ break;
+ case M_GetSelText :
+ if ( pVS->IsNoSelection() )
+ pRet->GenReturn ( RET_Value, aUId, String() );
+ else
+ pRet->GenReturn ( RET_Value, aUId, pVS->GetItemText( pVS->GetSelectItemId() ) );
+ break;
+ case M_SetNoSelection :
+ pVS->SetNoSelection();
+ break;
+ default:
+ ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "ValueSet" ) );
+ break;
+ }
+ }
+ break;
+ case CONST_CTORoadmap:
+ {
+ ORoadmap *pRM = dynamic_cast< ORoadmap* >(pControl);
+ switch ( nMethodId )
+ {
+ case M_GetItemCount:
+ pRet->GenReturn ( RET_Value, aUId, comm_ULONG( pRM->GetItemCount()));
+ break;
+ case M_GetItemText:
+ if ( ValueOK( aUId, MethodString( nMethodId ), nNr1, pRM->GetItemCount() ))
+ pRet->GenReturn ( RET_Value, aUId, pRM->GetRoadmapItemLabel( pRM->GetItemID( nNr1-1 ) ) );
+ break;
+ case M_Select:
+ if ( ValueOK( aUId, MethodString( nMethodId ), nNr1, pRM->GetItemCount() ))
+ {
+ if ( pRM->IsRoadmapItemEnabled( pRM->GetItemID( nNr1-1 ) ) )
+ pRM->SelectRoadmapItemByID( pRM->GetItemID( nNr1-1 ) );
+ else
+ ReportError( aUId, GEN_RES_STR1c( S_WIN_DISABLED, "RoadmapItem" ) );
+ }
+ break;
+ case M_GetSelIndex :
+ pRet->GenReturn ( RET_Value, aUId, comm_ULONG( pRM->GetItemIndex( pRM->GetCurrentRoadmapItemID() ) +1));
+ break;
+ case M_GetSelText :
+ pRet->GenReturn ( RET_Value, aUId, pRM->GetRoadmapItemLabel( pRM->GetCurrentRoadmapItemID() ) );
+ break;
+ case M_IsItemEnabled :
+ if ( ValueOK( aUId, MethodString( nMethodId ), nNr1, pRM->GetItemCount() ))
+ pRet->GenReturn ( RET_Value, aUId, (comm_BOOL)pRM->IsRoadmapItemEnabled( pRM->GetItemID( nNr1-1 ) ) );
+ break;
+ default:
+ ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "RoadMap" ) );
+ break;
+ }
+ }
+ break;
+ case CONST_CTIExtensionListBox:
+ {
+ IExtensionListBox *pELB = dynamic_cast< IExtensionListBox* >(pControl);
+ switch ( nMethodId )
+ {
+ case M_GetItemCount:
+ pRet->GenReturn ( RET_Value, aUId, comm_ULONG( pELB->getItemCount()));
+ break;
+ case M_GetItemText:
+ if ( ValueOK( aUId, MethodString( nMethodId ), nNr1, pELB->getItemCount() ))
+ switch ( nNr2 )
+ {
+ case 1:
+ pRet->GenReturn ( RET_Value, aUId, pELB->getItemName( nNr1 -1 ) );
+ break;
+ case 2:
+ pRet->GenReturn ( RET_Value, aUId, pELB->getItemVersion( nNr1 -1 ) );
+ break;
+ case 3:
+ pRet->GenReturn ( RET_Value, aUId, pELB->getItemDescription( nNr1 -1 ) );
+ break;
+ case 4:
+ pRet->GenReturn ( RET_Value, aUId, pELB->getItemPublisher( nNr1 -1 ) );
+ break;
+ case 5:
+ pRet->GenReturn ( RET_Value, aUId, pELB->getItemPublisherLink( nNr1 -1 ) );
+ break;
+ default:
+ ValueOK( aUId, MethodString( nMethodId ).AppendAscii(" String Number"), nNr2, 5 );
+ }
+ break;
+ case M_Select:
+ if ( (nParams & PARAM_USHORT_1) )
+ {
+ if ( ValueOK( aUId, MethodString( nMethodId ), nNr1, pELB->getItemCount() ))
+ {
+ pELB->select( nNr1-1 );
+ }
+ }
+ else if ( (nParams & PARAM_STR_1) )
+ {
+ pELB->select( aString1 );
+ sal_Bool bSuccess = sal_True;
+ if ( pELB->getSelIndex() == EXTENSION_LISTBOX_ENTRY_NOTFOUND )
+ bSuccess = sal_False;
+ else
+ {
+ if ( !aString1.Equals( String( pELB->getItemName( pELB->getSelIndex() ) ) ) )
+ bSuccess = sal_False;
+ }
+ if ( !bSuccess )
+ ReportError( aUId, GEN_RES_STR2( S_ENTRY_NOT_FOUND, MethodString( nMethodId ), aString1 ) );
+ }
+ break;
+ case M_GetSelCount :
+ if ( pELB->getSelIndex() == EXTENSION_LISTBOX_ENTRY_NOTFOUND )
+ pRet->GenReturn ( RET_Value, aUId, comm_ULONG( 0 ));
+ else
+ pRet->GenReturn ( RET_Value, aUId, comm_ULONG( 1 ));
+ break;
+ case M_GetSelIndex :
+ if ( pELB->getSelIndex() == EXTENSION_LISTBOX_ENTRY_NOTFOUND )
+ pRet->GenReturn ( RET_Value, aUId, comm_ULONG( 0 ));
+ else
+ pRet->GenReturn ( RET_Value, aUId, comm_ULONG( pELB->getSelIndex() +1));
+ break;
+/* xxxcase M_SetNoSelection :
+ ((ListBox*)pControl)->SetNoSelection();
+ ((ListBox*)pControl)->Select();
+ break; */
+ default:
+ ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "RoadMap" ) );
+ break;
+ }
+ }
+ break;
+
+ case CONST_CTTableControl:
+ {
+ ::svt::table::TableControl *pTC = dynamic_cast< ::svt::table::TableControl* >(pControl);
+ switch ( nMethodId )
+ {
+ case M_GetItemType :
+ {
+ if ( ValueOK( aUId, MethodString( nMethodId ), nNr1, pTC->GetColumnCount() ) &&
+ ValueOK( aUId, MethodString( nMethodId ), nNr2, pTC->GetRowCount() ))
+ {
+ ::svt::table::PTableModel pModel = pTC->GetModel();
+ Any aCell;
+ pModel->getCellContent( nNr1-1, nNr2-1, aCell );
+ pRet->GenReturn ( RET_Value, aUId, String( aCell.getValueTypeName() ));
+ }
+ }
+ break;
+ case M_GetItemText :
+ {
+ if ( ValueOK( aUId, MethodString( nMethodId ), nNr1, pTC->GetColumnCount() ) &&
+ ValueOK( aUId, MethodString( nMethodId ), nNr2, pTC->GetRowCount() ))
+ {
+ ::svt::table::PTableModel pModel = pTC->GetModel();
+ Any aCell;
+ pModel->getCellContent( nNr1-1, nNr2-1, aCell );
+ /* doesn't work ATM since it gets casted to SbxDATE in VCLTestTool unfortunately
+ SbxVariableRef xRes = new SbxVariable( SbxVARIANT );
+ unoToSbxValue( xRes, aCell );
+ pRet->GenReturn ( RET_Value, aUId, *xRes );*/
+
+ Type aType = aCell.getValueType();
+ TypeClass eTypeClass = aType.getTypeClass();
+ switch( eTypeClass )
+ {
+ /*case TypeClass_ENUM:
+ {
+ sal_Int32 nEnum = 0;
+ enum2int( nEnum, aValue );
+ pRet->GenReturn ( RET_Value, aUId, (comm_ULONG)nEnum );
+ }
+ break;*/
+ case TypeClass_BOOLEAN:
+ pRet->GenReturn ( RET_Value, aUId, *(sal_Bool*)aCell.getValue() );
+ break;
+ case TypeClass_CHAR:
+ {
+ ::rtl::OUString aContent( *(sal_Unicode*)aCell.getValue() );
+ pRet->GenReturn ( RET_Value, aUId, aContent );
+ }
+ break;
+ case TypeClass_STRING:
+ {
+ ::rtl::OUString aContent;
+ aCell >>= aContent;
+ pRet->GenReturn ( RET_Value, aUId, aContent );
+ }
+ break;
+ //case TypeClass_FLOAT: break;
+ //case TypeClass_DOUBLE: break;
+ //case TypeClass_OCTET: break;
+ case TypeClass_BYTE:
+ case TypeClass_SHORT:
+ case TypeClass_LONG:
+ case TypeClass_HYPER:
+ case TypeClass_UNSIGNED_LONG:
+ case TypeClass_UNSIGNED_HYPER:
+ {
+ comm_ULONG val = 0;
+ aCell >>= val;
+ pRet->GenReturn ( RET_Value, aUId, val );
+ }
+ break;
+ //case TypeClass_UNSIGNED_OCTET:break;
+ case TypeClass_UNSIGNED_SHORT:
+ {
+ comm_USHORT val = 0;
+ aCell >>= val;
+ pRet->GenReturn ( RET_Value, aUId, val );
+ }
+ break;
+ default:
+ pRet->GenReturn ( RET_Value, aUId, comm_USHORT(0) );
+ break;
+ }
+ }
+ }
+ break;
+ case M_GetColumnCount :
+ {
+ pRet->GenReturn ( RET_Value, aUId, (comm_ULONG)pTC->GetColumnCount() );
+ }
+ break;
+ case M_GetRowCount :
+ {
+ pRet->GenReturn ( RET_Value, aUId, (comm_ULONG)pTC->GetRowCount() );
+ }
+ break;
+ case M_Select :
+ {
+ if ( ValueOK( aUId, MethodString( nMethodId ), nNr1, pTC->GetRowCount() ))
+ {
+ if ( pTC->GoToRow( ::svt::table::RowPos( nNr1-1 ) ) )
+ {
+ Size aSize( pTC->GetSizePixel() );
+// DirectLog( S_QAError, UniString::CreateFromInt32( aSize.Width() ).Append( UniString::CreateFromInt32( aSize.Height() ) ) );
+ Point aPos( aSize.Width() / 2, aSize.Height() / 2 );
+ long nStep = aSize.Height() / 4;
+ ::svt::table::RowPos nLastPos;
+ while ( ( nLastPos = pTC->getTableControlInterface().hitTest( aPos ).nRow ) != nNr1-1 && nStep > 0 )
+ {
+ if ( nLastPos > nNr1-1 || nLastPos == ROW_INVALID )
+ aPos.Y() -= nStep;
+ else
+ aPos.Y() += nStep;
+ nStep /= 2;
+ }
+ if ( pTC->getTableControlInterface().hitTest( aPos ).nRow == nNr1-1 )
+ {
+ MouseEvent aMEvnt(aPos,1,MOUSE_SIMPLECLICK|MOUSE_SELECT,MOUSE_LEFT,KEY_MOD1);
+ pTC->getSelEngine()->SelMouseButtonDown( aMEvnt );
+ pTC->getSelEngine()->SelMouseButtonUp( aMEvnt );
+ if ( pTC->IsRowSelected( nNr1-1 ) )
+ pTC->Select();
+ }
+ else
+ ReportError( aUId, GEN_RES_STR2c2( S_METHOD_FAILED, MethodString( nMethodId ), "find pos" ) );
+ }
+ else
+ ReportError( aUId, GEN_RES_STR2c2( S_METHOD_FAILED, MethodString( nMethodId ), "GoTo" ) );
+ }
+ }
+ break;
+ case M_GetSelCount :
+ pRet->GenReturn ( RET_Value, aUId, comm_USHORT( pTC->GetSelectedRowCount() ));
+ break;
+ case M_GetSelIndex :
+ if ( ! (nParams & PARAM_USHORT_1) )
+ nNr1 = 1;
+ if ( ValueOK( aUId, CUniString("GetSelIndex"), nNr1, pTC->GetSelectedRowCount() ) )
+ pRet->GenReturn ( RET_Value, aUId, comm_USHORT( pTC->GetSelectedRowIndex( nNr1-1 ) +1 ) );
+ break;
+/* case M_GetSelText :
+ if ( ! (nParams & PARAM_USHORT_1) )
+ nNr1 = 1;
+ if ( ValueOK(aUId, CUniString("GetSelText"),nNr1,((SvLBox*)pControl)->GetSelectionCount()) )
+ {
+ nNr1--;
+ COUNT_LBOX( FirstSelected, NextSelected, nNr1);
+ GetFirstValidTextItem( pThisEntry );
+ pRet->GenReturn ( RET_Value, aUId, pItem->GetText() );
+ }
+ break;
+ */
+ default:
+ ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "TableControl" ) );
+ break;
+ }
+ }
+ break;
+
+ case CONST_CTUnknown:
+ ReportError( aUId, GEN_RES_STR2( S_UNKNOWN_TYPE, UniString::CreateFromInt32( nRT ), MethodString(nMethodId) ) );
+ break;
+ default:
+ ReportError( aUId, GEN_RES_STR1( S_INTERNAL_ERROR, MethodString( nMethodId ) ) );
+ break;
+ }
+ }
+ break;
+ }
+ case C_Window:
+ switch( nMethodId )
+ {
+ case M_AnimateMouse :
+ AnimateMouse( pControl, MitteOben);
+ break;
+ default:
+ ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "Window" ) );
+ break;
+ }
+ break;
+
+ case C_DockingWin:
+ DockingWin:
+ switch( nMethodId )
+ {
+ case M_AnimateMouse :
+ AnimateMouse( pControl, MitteOben);
+ break;
+ case M_Dock :
+ if ( ((DockingWindow*)pControl)->IsFloatingMode() )
+ ((DockingWindow*)pControl)->SetFloatingMode(sal_False);
+ else
+ ReportError( aUId, GEN_RES_STR1( S_ALLOWED_ONLY_IN_FLOATING_MODE, MethodString( nMethodId ) ) );
+ break;
+ case M_Undock :
+ if ( !((DockingWindow*)pControl)->IsFloatingMode() )
+ ((DockingWindow*)pControl)->SetFloatingMode(sal_True);
+ else
+ ReportError( aUId, GEN_RES_STR1( S_ALLOWED_ONLY_IN_FLOATING_MODE, MethodString( nMethodId ) ) );
+ break;
+ case M_IsDocked :
+ pRet->GenReturn ( RET_Value, aUId, (comm_BOOL) !((DockingWindow*)pControl)->IsFloatingMode());
+ break;
+ case M_Close:
+ //aWindowWaitUId = aUId;
+ DBG_ASSERT( aUId.equals( pControl->GetUniqueOrHelpId() ), "aUID != UniqueOrHelpId");
+ SET_WINP_CLOSING(pControl);
+ ((DockingWindow*)pControl)->Close();
+ break;
+ case M_Size:
+ case M_Move:
+ case M_IsMax:
+ case M_Minimize:
+ case M_Maximize:
+ if ( ((DockingWindow*)pControl)->IsFloatingMode() )
+ {
+ Window* pFloat = ((DockingWindow*)pControl)->GetFloatingWindow();
+ if ( !pFloat && ((DockingWindow*)pControl)->IsFloatingMode() )
+ {
+ if ( pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_FLOATINGWINDOW )
+ pFloat = pControl->GET_REAL_PARENT();
+ else
+ {
+ DBG_ERROR("FloatingMode set but Parent is no FloatingWindow");
+ }
+ }
+ if ( pFloat && pFloat->GetType() == WINDOW_FLOATINGWINDOW )
+ {
+ pControl = pFloat;
+ goto FloatWin;
+ }
+ else
+ ReportError( aUId, GEN_RES_STR1( S_CANNOT_FIND_FLOATING_WIN, MethodString( nMethodId ) ) );
+ }
+ else
+ ReportError( aUId, GEN_RES_STR1( S_ALLOWED_ONLY_IN_DOCKING_MODE, MethodString( nMethodId ) ) );
+ break;
+ case M_Help: // Alles was unten weiterbehandelt werden soll
+ goto MoreDialog;
+
+ default:
+ ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "DockingWindow" ) );
+ break;
+ }
+ break;
+ case C_FloatWin:
+ FloatWin:
+ switch( nMethodId )
+ {
+ case M_AnimateMouse :
+ AnimateMouse( pControl, MitteOben);
+ break;
+ case M_IsMax :
+ pRet->GenReturn ( RET_Value, aUId, (comm_BOOL)!((FloatingWindow*)pControl)->IsRollUp());
+ break;
+ case M_Minimize :
+ ((FloatingWindow*)pControl)->RollUp();
+ break;
+ case M_Maximize :
+ ((FloatingWindow*)pControl)->RollDown();
+ break;
+ case M_Size:
+ {
+ if ( pControl->GetStyle() & WB_SIZEABLE )
+ {
+ Size aMin = ((FloatingWindow*)pControl)->GetMinOutputSizePixel();
+ if ( aMin.Width() <= nNr1 && aMin.Height() <= nNr2 )
+ {
+ pControl->SetSizePixel(Size(nNr1,nNr2));
+ pControl->Resize();
+ }
+ else
+ {
+ ReportError( aUId, GEN_RES_STR2( S_SIZE_BELOW_MINIMUM, String::CreateFromInt32( aMin.Width() ), String::CreateFromInt32( aMin.Height() ) ) );
+ }
+ }
+ else
+ ReportError( aUId, GEN_RES_STR1( S_SIZE_NOT_CHANGEABLE, MethodString( nMethodId ) ) );
+ break;
+ }
+ case M_Close:
+ DBG_ASSERT( aUId.equals( pControl->GetUniqueOrHelpId() ), "aUID != UniqueOrHelpId");
+ SET_WINP_CLOSING(pControl);
+ ((FloatingWindow*)pControl)->Close();
+ break;
+ case M_Help: // Alles was unten weiterbehandelt werden soll
+ case M_Move:
+ goto MoreDialog;
+ default:
+ ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "FloatingWin" ) );
+ break;
+ }
+ break;
+ case C_ModelessDlg:
+ case C_ModalDlg:
+ case C_Dialog:
+ case C_TabDlg:
+ MoreDialog:
+ switch( nMethodId )
+ {
+ case M_AnimateMouse :
+ AnimateMouse( pControl, MitteOben);
+ break;
+ case M_Close:
+ DBG_ASSERT( aUId.equals( pControl->GetUniqueOrHelpId() ), "aUID != UniqueOrHelpId");
+ SET_WINP_CLOSING(pControl);
+ ((SystemWindow*)pControl)->Close();
+ break;
+ case M_OK:
+ {
+ Window *pChild = GetWinByRT( pControl, WINDOW_OKBUTTON );
+ if( ControlOK( pChild, "OK Button" ) )
+ {
+ DBG_ASSERT( aUId.equals( pControl->GetUniqueOrHelpId() ), "aUID != UniqueOrHelpId");
+ SET_WINP_CLOSING(pControl);
+ ((Button*)pChild)->Click();
+ }
+ break;
+ }
+ case M_Cancel:
+ {
+ Window *pChild = GetWinByRT( pControl, WINDOW_CANCELBUTTON );
+ if( ControlOK( pChild, "Cancel Button" ) )
+ {
+ DBG_ASSERT( aUId.equals( pControl->GetUniqueOrHelpId() ), "aUID != UniqueOrHelpId");
+ SET_WINP_CLOSING(pControl);
+ ((Button*)pChild)->Click();
+ }
+ break;
+ }
+ case M_Help:
+ {
+ Window *pChild = GetWinByRT( pControl, WINDOW_HELPBUTTON );
+ if( ControlOK( pChild, "Help Button" ) )
+ ((Button*)pChild)->Click();
+ break;
+ }
+ case M_Default:
+ {
+ Window *pChild = ImpGetButton( pControl, WB_DEFBUTTON, WB_DEFBUTTON );
+ if( ControlOK( pChild, "Default Button" ) )
+ ((Button*)pChild)->Click();
+ break;
+ }
+ case M_Move:
+ {
+ pControl->SetPosPixel(Point(nNr1,nNr2));
+ break;
+ }
+ default:
+ ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "Dialog" ) );
+ break;
+ }
+ break;
+ case C_WorkWin:
+ switch( nMethodId )
+ {
+ case M_AnimateMouse :
+ AnimateMouse( pControl, MitteOben);
+ break;
+ case M_Close:
+ DBG_ASSERT( aUId.equals( pControl->GetUniqueOrHelpId() ), "aUID != UniqueOrHelpId");
+ SET_WINP_CLOSING(pControl);
+ ((WorkWindow*)pControl)->Close();
+ break;
+ case M_Size:
+ case M_Move:
+ goto FloatWin;
+// break;
+ case M_IsMax :
+ pRet->GenReturn ( RET_Value, aUId, ((WorkWindow*)pControl)->IsMaximized() );
+ break;
+ case M_IsMin :
+ pRet->GenReturn ( RET_Value, aUId, ((WorkWindow*)pControl)->IsMinimized() );
+ break;
+ case M_IsRestore :
+ pRet->GenReturn ( RET_Value, aUId, comm_BOOL (!((WorkWindow*)pControl)->IsMaximized() && !((WorkWindow*)pControl)->IsMinimized()) );
+ break;
+ case M_Minimize :
+ ((WorkWindow*)pControl)->Maximize( sal_False );
+ ((WorkWindow*)pControl)->Minimize();
+ break;
+ case M_Maximize :
+ ((WorkWindow*)pControl)->Maximize();
+ break;
+ case M_Restore :
+ ((WorkWindow*)pControl)->Maximize( sal_False );
+ ((WorkWindow*)pControl)->Restore();
+ break;
+ case M_Help: // Alles was unten weiterbehandelt werden soll
+ goto MoreDialog;
+ default:
+ ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "WorkWindow" ) );
+ break;
+ }
+ break;
+ case C_TabPage:
+ ReportError( aUId, GEN_RES_STR1( S_INTERNAL_ERROR, MethodString( nMethodId ) ) );
+ break;
+ case C_MessBox:
+ case C_InfoBox:
+ case C_WarningBox:
+ case C_ErrorBox:
+ case C_QueryBox:
+ {
+ sal_Bool bDone = sal_True;
+ MessBox* pMB = (MessBox*)pControl;
+ switch( nMethodId )
+ {
+ case M_GetCheckBoxText:
+ pRet->GenReturn ( RET_Value, aUId, pMB->GetCheckBoxText() );
+ break;
+ case M_IsChecked :
+ pRet->GenReturn ( RET_Value, aUId, comm_BOOL( pMB->GetCheckBoxState() == STATE_CHECK) );
+ break;
+ case M_Check :
+ pMB->SetCheckBoxState( sal_True );
+ break;
+ case M_UnCheck :
+ pMB->SetCheckBoxState( sal_False );
+ break;
+ case M_GetText :
+ pRet->GenReturn ( RET_Value, aUId, pMB->GetMessText());
+ break;
+
+ default:
+ bDone = sal_False;
+ break;
+ }
+ if ( bDone )
+ break; // break the case here else continue at C_ButtonDialog
+ }
+ case C_ButtonDialog:
+ {
+ ButtonDialog* pBD = (ButtonDialog*)pControl;
+#if OSL_DEBUG_LEVEL > 1
+ m_pDbgWin->AddText( "Working MessBox: " );
+ if (pControl->IsVisible())
+ m_pDbgWin->AddText("*(Visible)\n");
+ else
+ m_pDbgWin->AddText("*(nicht Visible)\n");
+#endif
+ switch( nMethodId )
+ {
+ case M_AnimateMouse :
+ AnimateMouse( pControl, Mitte);
+ break;
+ case M_OK:
+ if ( pBD->GetPushButton( BUTTONID_OK ) )
+ {
+ SET_WINP_CLOSING(pControl);
+ pBD->EndDialog(RET_OK);
+ }
+ else
+ ReportError( aUId, GEN_RES_STR1( S_NO_OK_BUTTON, MethodString( nMethodId ) ) );
+ break;
+ case M_Cancel:
+ if ( pBD->GetPushButton( BUTTONID_CANCEL ) )
+ {
+ SET_WINP_CLOSING(pControl);
+ pBD->EndDialog(RET_CANCEL);
+ }
+ else
+ ReportError( aUId, GEN_RES_STR1( S_NO_CANCEL_BUTTON, MethodString( nMethodId ) ) );
+ break;
+ case M_Yes:
+ if ( pBD->GetPushButton( BUTTONID_YES ) )
+ {
+ SET_WINP_CLOSING(pControl);
+ pBD->EndDialog(RET_YES);
+ }
+ else
+ ReportError( aUId, GEN_RES_STR1( S_NO_YES_BUTTON, MethodString( nMethodId ) ) );
+ break;
+ case M_No:
+ if ( pBD->GetPushButton( BUTTONID_NO ) )
+ {
+ SET_WINP_CLOSING(pControl);
+ pBD->EndDialog(RET_NO);
+ }
+ else
+ ReportError( aUId, GEN_RES_STR1( S_NO_NO_BUTTON, MethodString( nMethodId ) ) );
+ break;
+ case M_Repeat:
+ if ( pBD->GetPushButton( BUTTONID_RETRY ) )
+ {
+ SET_WINP_CLOSING(pControl);
+ pBD->EndDialog(RET_RETRY);
+ }
+ else
+ ReportError( aUId, GEN_RES_STR1( S_NO_RETRY_BUTTON, MethodString( nMethodId ) ) );
+ break;
+ case M_Help:
+ if ( pBD->GetPushButton( BUTTONID_HELP ) )
+ {
+ SET_WINP_CLOSING(pControl);
+ pBD->EndDialog(BUTTONID_HELP);
+ }
+ else
+ ReportError( aUId, GEN_RES_STR1( S_NO_HELP_BUTTON, MethodString( nMethodId ) ) );
+ break;
+ case M_Default:
+ {
+ WinBits Style = pControl->GetStyle();
+ if ( Style & WB_DEF_OK )
+ {
+ SET_WINP_CLOSING(pControl);
+ pBD->EndDialog(RET_OK);
+ }
+ else if ( Style & WB_DEF_CANCEL )
+ {
+ SET_WINP_CLOSING(pControl);
+ pBD->EndDialog(RET_CANCEL);
+ }
+ else if ( Style & WB_DEF_YES )
+ {
+ SET_WINP_CLOSING(pControl);
+ pBD->EndDialog(RET_YES);
+ }
+ else if ( Style & WB_DEF_NO )
+ {
+ SET_WINP_CLOSING(pControl);
+ pBD->EndDialog(RET_NO);
+ }
+ else if ( Style & WB_DEF_RETRY )
+ {
+ SET_WINP_CLOSING(pControl);
+ pBD->EndDialog(RET_RETRY);
+ }
+ else
+ ReportError( aUId, GEN_RES_STR1( S_NO_DEFAULT_BUTTON, MethodString( nMethodId ) ) );
+ }
+ break;
+ case M_GetText :
+ pRet->GenReturn ( RET_Value, aUId, pControl->GetText());
+ break;
+ case M_Click:
+ if ( nParams & PARAM_USHORT_1 )
+ {
+ if ( pBD->GetPushButton( nNr1 ) )
+ {
+ if ( nNr1 != BUTTONID_HELP )
+ {
+ SET_WINP_CLOSING(pControl);
+ }
+ pBD->GetPushButton( nNr1 )->Click();
+ }
+ else
+ ReportError( aUId, GEN_RES_STR2( S_NO_DEFAULT_BUTTON, UniString::CreateFromInt32( nNr1 ), MethodString( nMethodId ) ) );
+ }
+ else
+ ReportError( aUId, GEN_RES_STR1( S_BUTTONID_REQUIRED, MethodString( nMethodId ) ) );
+ break;
+ case M_GetButtonCount :
+ pRet->GenReturn ( RET_Value, aUId, comm_ULONG(pBD->GetButtonCount()));
+ break;
+ case M_GetButtonId :
+ if ( ValueOK(aUId, MethodString( nMethodId ),nNr1,pBD->GetButtonCount()) )
+ pRet->GenReturn ( RET_Value, aUId, comm_ULONG(pBD->GetButtonId(nNr1-1)));
+ break;
+ default:
+ ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "MessageBox" ) );
+ break;
+ }
+ break;
+ }
+ default:
+ DBG_ERROR( "Unknown Objekttype from UId or Method not suported" );
+ ReportError( aUId, GEN_RES_STR2( S_UNKNOWN_TYPE, UniString::CreateFromInt32( nRT ), MethodString(nMethodId) ) );
+#if OSL_DEBUG_LEVEL > 1
+ m_pDbgWin->AddText( " Unknown Objekttype from UId or Method not suported" );
+#endif
+ break;
+ }
+ }
+ for( int i = 0; i < 32; i++ )
+ SafeReschedule();
+ }
+#if OSL_DEBUG_LEVEL > 1
+ m_pDbgWin->AddText( "\n" );
+#endif
+ if ( bStatementDone )
+ {
+ SendProfile( UIdString( aUId ).Append('.').Append( MethodString( nMethodId ) ) );
+ delete this;
+ }
+ else
+ {
+ if ( nRetryCount-- )
+ {
+#if OSL_DEBUG_LEVEL > 1
+ m_pDbgWin->AddText( CUniString("Reschedule command (requed) (").Append( UniString::CreateFromInt32(nRetryCount) ).AppendAscii(")\n") );
+#endif
+ QueStatement( this ); // will que at the start of the list
+ }
+ else
+ {
+ bStatementDone=sal_True;
+ }
+ }
+ return bStatementDone;
+
+#define FINISH_NEXT
+#define FINISH_SAME
+
+}
diff --git a/automation/source/server/statemnt.hxx b/automation/source/server/statemnt.hxx
new file mode 100644
index 000000000000..42f8dbf05d1a
--- /dev/null
+++ b/automation/source/server/statemnt.hxx
@@ -0,0 +1,498 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+/***************************************************************************
+**
+** Von StatementList werden alle Statements abgeleitet.
+** Es gibt immer nur eine Statementliste, die verpointert ist.
+** jederzeit kann das der Anfang der Kette abgefragt werden.
+**
+**
+**
+**
+**
+**
+**
+***************************************************************************/
+#ifndef _STATEMNT_HXX
+#define _STATEMNT_HXX
+
+#include <tools/wintypes.hxx>
+#include <tools/string.hxx>
+#include <tools/debug.hxx>
+#include <tools/time.hxx>
+#ifndef _SV_DRAG_HXX //autogen
+//#include <vcl/drag.hxx>
+#endif
+#include <vcl/menu.hxx>
+#include <vcl/svapp.hxx>
+#include <tools/fsys.hxx>
+#include <sot/storage.hxx>
+#include <basic/sbstar.hxx>
+#include <vcl/event.hxx>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <automation/commtypes.hxx>
+
+class Window;
+class SystemWindow;
+class Point;
+class SfxPoolItem;
+
+class ScrollBar;
+
+class SCmdStream;
+class RetStream;
+class ImplRemoteControl;
+
+class TTProfiler;
+class TTProperties;
+
+class Dir;
+
+class CommunicationLink;
+
+#if OSL_DEBUG_LEVEL > 1
+class EditWindow;
+#endif
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+ void SAL_CALL osl_TestToolDebugPrint( const sal_Char *pString );
+#ifdef __cplusplus
+}
+#endif
+
+
+#define IsVisible IsReallyVisible
+#define GET_REAL_PARENT() GetWindow( WINDOW_REALPARENT )
+
+// switch behaviour of ImplMouse* and ImplKeyInput
+#define FORCE_DIRECT_CALL sal_True
+
+typedef sal_uInt16 SearchFlags;
+#define SEARCH_NOOVERLAP ((SearchFlags) 0x0001)
+#define SEARCH_NO_TOPLEVEL_WIN ((SearchFlags) 0x0002)
+#define SEARCH_FOCUS_FIRST ((SearchFlags) 0x0004)
+#define SEARCH_FIND_DISABLED ((SearchFlags) 0x0008)
+
+class Search
+{
+ SearchFlags nmSearchFlags;
+public:
+ Search( SearchFlags nSearchFlags = 0): nmSearchFlags(nSearchFlags) {}
+ virtual ~Search() {}
+
+ virtual sal_Bool IsWinOK( Window *pWin ) = 0;
+ SearchFlags GetSearchFlags() { return nmSearchFlags; }
+ void AddSearchFlags( SearchFlags aNewFlags ) { nmSearchFlags |= aNewFlags; }
+ void RemoveSearchFlags( SearchFlags aRemoveFlags ) { nmSearchFlags &= ( ~aRemoveFlags ); }
+ sal_Bool HasSearchFlag( SearchFlags aQueryFlag ) { return (nmSearchFlags & aQueryFlag) == aQueryFlag; }
+};
+
+sal_Bool IsDialog(Window *pWin); // Ist *pWin von SystemWindow abgeleitet (Kann es Active sein)
+sal_Bool IsAccessable(Window *pWin); // Ist *pWin Zugreifbar (über IsEnabled und Parents geprüft)
+
+
+//class SafePointer : CriticalSection
+class SafePointer
+{
+ SafePointer *pSelf;
+public:
+ SafePointer() { pSelf = this; }
+ virtual ~SafePointer() { DBG_ASSERT(pSelf==this,"Destructor von Nicht existierendem Objekt aufgerufen");
+ pSelf = NULL; }
+// static sal_Bool IsValid( SafePointer *pThis ) { return pThis == pThis->pSelf; }
+// virtual operator -> (); { DBG_ASSERT(pMyself == this,"-> von Nicht existierendem Objekt aufgerufen"); }
+};
+
+
+class DisplayHidWin;
+class StatementCommand;
+class TranslateWin;
+
+struct TTSettings
+{
+ // DisplayHID
+ StatementCommand *pDisplayInstance;
+ DisplayHidWin *pDisplayHidWin;
+ Window *Old;
+ Window *Act;
+ String aOriginalCaption;
+
+ // Translate
+ TranslateWin *pTranslateWin;
+ sal_Bool bToTop;
+};
+
+
+TTSettings* GetTTSettings();
+
+
+#define MAX_RETRIES 9
+class StatementList : public SafePointer
+{
+private:
+ StatementList(const StatementList&);
+ StatementList & operator=(const StatementList&);
+
+protected:
+ StatementList();
+ sal_uInt16 nRetryCount;
+ void QueStatement(StatementList *pAfterThis);
+ sal_Bool bStatementInQue;
+ static sal_uInt16 nUseBindings;
+
+ static TTProfiler *pProfiler;
+ void InitProfile();
+ void SendProfile( String aText );
+ static StatementList *pCurrentProfileStatement;
+
+ static sal_Bool bIsInReschedule;
+ static sal_uInt16 nModalCount;
+ static Window *pLastFocusWindow; // Wenn dieses sich ändert wird Safe Reschedule abgebrochen
+ static sal_Bool bWasDragManager; // Wenn dieses sich ändert wird Safe Reschedule abgebrochen
+ static sal_Bool bWasPopupMenu; // Wenn dieses sich ändert wird Safe Reschedule abgebrochen
+ static sal_Bool bBasicWasRunning;
+
+ static sal_uInt16 nMinTypeKeysDelay; /// Verzögerung der einzelnen Anschläge für TypeKeys
+ static sal_uInt16 nMaxTypeKeysDelay;
+ static sal_Bool bDoTypeKeysDelay;
+
+ static Window* pFirstDocFrame;
+
+ static sal_Bool bIsSlotInExecute;
+
+public:
+ static sal_Bool IsInReschedule() { return bIsInReschedule; }
+ void SafeReschedule( sal_Bool bYield = sal_False ) // Setzt Flag, so daß nicht schon der nächste Befehl ausgeführt wird
+ {
+ nModalCount = Application::GetModalModeCount();
+ bIsInReschedule = sal_True;
+ pLastFocusWindow = GetpApp()->GetFocusWindow();
+ bWasDragManager = false /*!= DragManager::GetDragManager()*/;
+ bWasPopupMenu = NULL != PopupMenu::GetActivePopupMenu();
+ bBasicWasRunning = StarBASIC::IsRunning();
+ bWasExecuting = bExecuting;
+ if ( bYield )
+ GetpApp()->Yield();
+ else
+ GetpApp()->Reschedule();
+ bExecuting = bWasExecuting;
+ bBasicWasRunning = sal_False;
+ bWasPopupMenu = sal_False;
+ bWasDragManager = sal_False;
+ pLastFocusWindow = NULL;
+ bIsInReschedule = sal_False;
+ nModalCount = 0;
+ }
+ static sal_Bool MaybeResetSafeReschedule()
+ { // Implementierung muß hier zwar nicht sein, ist aber übersichtlicher so
+ if ( !bIsInReschedule )
+ return sal_False;
+
+ if ( pLastFocusWindow != GetpApp()->GetFocusWindow()
+ || ( Application::GetModalModeCount() > nModalCount )
+// || ( DragManager::GetDragManager() && !bWasDragManager )
+ || ( PopupMenu::GetActivePopupMenu() && !bWasPopupMenu )
+ || ( StarBASIC::IsRunning() && !bBasicWasRunning ) )
+ {
+ bIsInReschedule = sal_False;
+ pLastFocusWindow = NULL;
+ return sal_True;
+ }
+ else
+ return sal_False;
+ }
+ static void NormalReschedule() // Setzt das flag nicht
+ {
+ GetpApp()->Reschedule();
+ }
+#define Reschedule RescheduleNichtBenutzen_StattdessenSafeRescheduleAnStatementList
+
+ static Window* GetMouseWin();
+ static sal_Bool WinPtrValid(Window *pTest);
+ static Window* SearchAllWin( Window *pBase, Search &aSearch, sal_Bool MaybeBase = sal_True );
+protected:
+ static Window* SearchClientWin( Window *pBase, Search &aSearch, sal_Bool MaybeBase = sal_True );
+
+ Window* SearchTree( rtl::OString aUId, sal_Bool bSearchButtonOnToolbox = sal_False );
+ Window* GetActive( WindowType nRT, sal_Bool MaybeBase = sal_True );
+ Window* GetFocus( WindowType nRT, sal_Bool MaybeBase = sal_True );
+ Window* GetAnyActive( sal_Bool MaybeBase = sal_True );
+ ScrollBar* GetScrollBar( Window *pBase, sal_uInt16 nDirection, sal_Bool MaybeBase = sal_True );
+ Window* GetPopupFloatingWin( sal_Bool MaybeBase = sal_True );
+ Menu* GetMatchingMenu( Window* pWin, Menu* pBaseMenu = NULL );
+ Window* GetWinByRT( Window *pBase, WindowType nRT, sal_Bool MaybeBase = sal_True, sal_uInt16 nSkip = 0, sal_Bool bSearchAll = sal_False );
+ sal_uInt16 CountWinByRT( Window *pBase, WindowType nRT, sal_Bool MaybeBase = sal_True );
+ Window* GetDocWin( sal_uInt16 nNr );
+ sal_uInt16 GetDocWinCount();
+ Window* GetFadeSplitWin( Window *pBase, WindowAlign nAlign, sal_Bool MaybeBase = sal_True );
+ sal_Bool ValueOK(rtl::OString nId, String aBezeichnung, sal_uLong nValue, sal_uLong nMax);
+
+ sal_uInt16 GetCurrentMenues( PopupMenu *&pPopup, MenuBar *&pMenuBar, Menu *&pMenu );
+
+public:
+// void AddStatement( StatementList *pNewStatement );
+
+ virtual ~StatementList();
+ void Advance();
+ virtual sal_Bool Execute() = 0;
+/***************************************************************************
+** Bestimmt erst den nächsten Befehl, setzt Current
+** und führt dann aus.
+** Returnwert gibt an, ob Befehl nochmal ausgeführt
+** werden soll. Dann muß auch der UserEvent verlassen werden, um der Applikation
+** normales Arbeiten zu ermöglichen (Dialog schliessen)
+** sal_True bedeutet, dass alles klar gegangen ist
+** sal_False bedeutet nochmal Bitte
+***************************************************************************/
+
+ void ReportError(String aMessage);
+ void ReportError(rtl::OString aUId, String aMessage);
+ void ReportError(String aMessage, sal_uLong nWhatever);
+
+ static void DirectLog( sal_uLong nType, String aString );
+
+ String Tree(Window *pBase, int Indent);
+ String ClientTree(Window *pBase, int Indent);
+
+ StatementList *pNext;
+ static StatementList /**pCurrent,*/ *pFirst;
+ static sal_Bool bReadingCommands;
+ static rtl::OString aWindowWaitUId;
+ static Window *pWindowWaitPointer;
+ static rtl::OString aWindowWaitOldHelpId;
+ static rtl::OString aWindowWaitOldUniqueId;
+ static RetStream *pRet;
+ static sal_Bool IsError;
+ static sal_Bool bDying;
+ static sal_Bool bExecuting; // Gesetzt, wenn ein Befehl rescheduled ohne einen neuen Befehl zu erlauben
+ sal_Bool bWasExecuting; // Wurde bei einem MaybeResetSafeReschedule resettet, so wird der Zustand danach wiederhergestellt
+ static sal_uInt16 aSubMenuId1; // Untermenüs bei PopupMenus
+ static sal_uInt16 aSubMenuId2; // erstmal 2-Stufig
+ static sal_uInt16 aSubMenuId3; // and now even 3 levels #i31512#
+ static SystemWindow *pMenuWindow; // when using MenuBar as base for MenuCommands
+ static TTProperties *pTTProperties; // Hier stehen die SlotIDs aus dem SFX drin
+
+ sal_Bool CheckWindowWait(); //True heisst, dass Window noch existiert
+ //False -> Window weg;
+ static void SetFirstDocFrame( Window* pWin );
+ static Window* GetFirstDocFrame();
+ static sal_Bool IsFirstDocFrame( Window* pWin );
+ static sal_Bool IsDocWin( Window* pWin );
+ static sal_Bool IsIMEWin( Window* pWin ); // Input Window for CJK under Solaris
+ static sal_Bool IsDocFrame( Window* pWin );
+ static MenuBar* GetDocFrameMenuBar( Window* pWin );
+ static sal_uInt16 GetDocFrameCount();
+
+ static sal_Bool bCatchGPF;
+
+ static sal_Bool bUsePostEvents; // use Application::Post*Event or own impl to handle key and mouseevents
+
+#if OSL_DEBUG_LEVEL > 1
+ static EditWindow *m_pDbgWin;
+#endif
+};
+
+class StatementSlot : public StatementList //Slots aufrufen
+{
+protected:
+ sal_uInt16 nAnzahl;
+ SfxPoolItem **pItemArr;
+ ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue> aArgs;
+ sal_uInt16 nFunctionId; // can get removed when the old (numeric) slothandling is removed
+ String aUnoUrl;
+ sal_Bool bMenuClosed;
+
+ StatementSlot();
+ void AddReferer();
+public:
+ StatementSlot( SCmdStream *pIn );
+ StatementSlot( sal_uLong nSlot, SfxPoolItem* pItem = NULL );
+ virtual ~StatementSlot();
+ virtual sal_Bool Execute();
+};
+
+class StatementUnoSlot : public StatementSlot //Uno Slots aufrufen
+{
+public:
+ StatementUnoSlot(SCmdStream *pIn);
+};
+
+class StatementCommand : public StatementList // Befehl ausführen (wintree, resetaplication ...)
+{
+ friend class ImplRemoteControl;
+protected:
+ sal_uInt16 nMethodId;
+ sal_uInt16 nParams;
+ comm_USHORT nNr1,nNr2,nNr3,nNr4;
+ comm_ULONG nLNr1;
+ String aString1,aString2;
+ sal_Bool bBool1,bBool2;
+
+ Window* GetNextOverlap( Window* pBase );
+ Window* GetNextRecoverWin();
+
+ static sal_uInt16 nDirPos;
+ static Dir *pDir;
+ static pfunc_osl_printDebugMessage pOriginal_osl_DebugMessageFunc;
+
+
+ sal_Bool UnpackStorage( SotStorageRef xStorage, DirEntry &aBaseDir );
+
+ void HandleSAXParser();
+
+public:
+ StatementCommand( SCmdStream *pIn );
+ StatementCommand( StatementList *pAfterThis, sal_uInt16 MethodId, sal_uInt16 Params, sal_uInt16 Nr1 );
+ virtual sal_Bool Execute();
+ sal_Bool DisplayHID();
+ void Translate();
+ void WriteControlData( Window *pBase, sal_uLong nConf, sal_Bool bFirst = sal_True );
+
+};
+
+
+enum TTHotSpots { MitteLinks, Mitte, MitteOben };
+
+class StatementControl : public StatementList
+{
+protected:
+ rtl::OString aUId;
+ sal_uInt16 nMethodId;
+ sal_uInt16 nParams;
+ comm_USHORT nNr1,nNr2,nNr3,nNr4;
+ comm_ULONG nLNr1;
+ String aString1,aString2;
+ sal_Bool bBool1,bBool2;
+ sal_Bool ControlOK( Window *pControl, const sal_Char* aBezeichnung );
+ void AnimateMouse( Window *pControl, TTHotSpots aWohin );
+ void AnimateMouse( Window *pControl, Point aWohin );
+
+ sal_Bool MaybeDoTypeKeysDelay( Window *pTestWindow );
+
+ sal_Bool HandleVisibleControls( Window *pControl );
+ sal_Bool HandleCommonMethods( Window *pControl );
+
+public:
+ StatementControl( SCmdStream *pIn, sal_uInt16 nControlType );
+ virtual sal_Bool Execute();
+
+};
+
+class StatementFlow : public StatementList // Kommunikation mit Sequence
+{
+ sal_uInt16 nArt;
+
+ sal_uInt16 nParams;
+ comm_USHORT nSNr1;
+ comm_ULONG nLNr1;
+ String aString1;
+ sal_Bool bBool1;
+
+
+public:
+ StatementFlow (sal_uLong nServiceId, SCmdStream *pIn, ImplRemoteControl *pRC );
+ StatementFlow( StatementList *pAfterThis, sal_uInt16 nArtP );
+ virtual sal_Bool Execute();
+ static CommunicationLink *pCommLink;
+ static sal_Bool bSending;
+
+ static sal_Bool bUseIPC; // Soll zur rückmeldung IPC verwendet werden?
+ static ImplRemoteControl *pRemoteControl; // Static für 2. Constructor
+
+private:
+ void SendViaSocket();
+};
+
+class SearchUID : public Search
+{
+ Window *pMaybeResult;
+ Window *pAlternateResult;
+ rtl::OString aUId;
+ sal_Bool bSearchButtonOnToolbox;
+public:
+ SearchUID( rtl::OString aUIdP, sal_Bool bSearchButtonOnToolboxP ): Search( SEARCH_FOCUS_FIRST ), pMaybeResult(NULL), pAlternateResult(NULL), aUId(aUIdP), bSearchButtonOnToolbox(bSearchButtonOnToolboxP) {}
+ virtual sal_Bool IsWinOK( Window *pWin );
+ Window* GetMaybeWin() { return pMaybeResult; }
+ Window* GetAlternateResultWin() { return pAlternateResult; }
+};
+class SearchActive : public Search
+{
+ WindowType nRT;
+public:
+ SearchActive( WindowType nRTP ): nRT(nRTP) {}
+ virtual sal_Bool IsWinOK( Window *pWin );
+};
+class SearchPopupFloatingWin : public Search
+{
+public:
+ SearchPopupFloatingWin(): Search( SEARCH_FOCUS_FIRST ) {}
+ virtual sal_Bool IsWinOK( Window *pWin );
+};
+class SearchRT : public Search
+{
+ WindowType mnRT;
+ sal_uInt16 mnSkip;
+ sal_uInt16 mnCount;
+public:
+ SearchRT( WindowType nRTP, SearchFlags nSearchFlags, sal_uInt16 nSkip = 0 ): Search(nSearchFlags), mnRT(nRTP), mnSkip( nSkip ), mnCount( 0 ) {}
+ virtual sal_Bool IsWinOK( Window *pWin );
+ sal_uInt16 GetCount(){ return mnCount; }
+};
+class SearchScroll : public SearchRT
+{
+ sal_uInt16 nDirection;
+public:
+ SearchScroll( sal_uInt16 nDir, SearchFlags nSearchFlags ): SearchRT(WINDOW_SCROLLBAR, nSearchFlags), nDirection(nDir) {}
+ virtual sal_Bool IsWinOK( Window *pWin );
+};
+class SearchWinPtr : public Search
+{
+ Window *pTest;
+public:
+ SearchWinPtr( Window *pTestP ): pTest(pTestP) {}
+ virtual sal_Bool IsWinOK( Window *pWin );
+};
+class SearchFadeSplitWin : public Search
+{
+ WindowAlign nAlign;
+public:
+ SearchFadeSplitWin( WindowAlign nAlignP ): nAlign(nAlignP) {}
+ virtual sal_Bool IsWinOK( Window *pWin );
+};
+
+
+void ImplKeyInput( Window* pWin, KeyEvent &aKEvnt, sal_Bool bForceDirect=sal_False );
+void ImplMouseMove( Window* pWin, MouseEvent &aMEvnt, sal_Bool bForceDirect=sal_False );
+void ImplMouseButtonDown( Window* pWin, MouseEvent &aMEvnt, sal_Bool bForceDirect=sal_False );
+void ImplMouseButtonUp( Window* pWin, MouseEvent &aMEvnt, sal_Bool bForceDirect=sal_False );
+void ImplCommand( Window* pWin, CommandEvent &aCmdEvnt );
+void ImplEventWait( sal_uLong nID );
+
+#endif
diff --git a/automation/source/server/svcommstream.cxx b/automation/source/server/svcommstream.cxx
new file mode 100644
index 000000000000..7ff77b30d242
--- /dev/null
+++ b/automation/source/server/svcommstream.cxx
@@ -0,0 +1,48 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_automation.hxx"
+
+#include "svcommstream.hxx"
+
+SvCommStream::SvCommStream( SvStream* pIO ) { pStream = pIO; }
+SvCommStream::~SvCommStream() {}
+
+ICommStream& SvCommStream::operator>>( comm_USHORT& rUShort ) { *pStream >> rUShort; return *this; }
+ICommStream& SvCommStream::operator>>( comm_ULONG& rULong ) { *pStream >> rULong; return *this; }
+ICommStream& SvCommStream::operator>>( comm_BOOL& rChar ) { *pStream >> rChar; return *this; }
+
+ICommStream& SvCommStream::operator<<( comm_USHORT nUShort ) { *pStream << nUShort; return *this; }
+ICommStream& SvCommStream::operator<<( comm_ULONG nULong ) { *pStream << nULong; return *this; }
+ICommStream& SvCommStream::operator<<( comm_BOOL nChar ) { *pStream << nChar; return *this; }
+
+comm_ULONG SvCommStream::Read( void* pData, comm_ULONG nSize ) { return pStream->Read( pData, nSize ); }
+comm_ULONG SvCommStream::Write( const void* pData, comm_ULONG nSize ) { return pStream->Write( pData, nSize ); }
+
+comm_BOOL SvCommStream::IsEof() const { return pStream->IsEof(); }
+comm_ULONG SvCommStream::SeekRel( long nPos ) { return pStream->SeekRel( nPos ); }
diff --git a/automation/source/server/testtool.hrc b/automation/source/server/testtool.hrc
new file mode 100644
index 000000000000..d6a234b74236
--- /dev/null
+++ b/automation/source/server/testtool.hrc
@@ -0,0 +1,55 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#define TTSTART 12345
+
+#define DisplayHidToolBox ( TTSTART + 0 )
+#define TT_SHOW 1
+#define TT_SHOW2 ( TTSTART + 1 )
+#define TT_OUTPUT 3
+#define TT_SEND_DATA 4
+#define TT_ALLWIN 5
+#define TT_KURZNAME 6
+#define TT_LANGNAME 7
+#define TT_ALTERNATE_CAPTION ( TTSTART + 2 )
+
+#define TT_INLINE_TRANSLATION ( TTSTART + 3)
+#define TT_GB_TRANSLATION 1
+#define TT_E_NEW 2
+#define TT_FT_OLD 3
+#define TT_GB_COMMENT 4
+#define TT_E_COMMENT 5
+
+#define TT_PB_SELECT 6
+#define TT_PB_RESTORE 7
+#define TT_PB_ACCEPT 8
+#define TT_PB_NEXT 9
+
+#define TT_DISCARD_CHANGED_DATA ( TTSTART + 4 )
+#define TT_NO_CONTROL ( TTSTART + 5 )
+
+
+#define TT_GPF ( TTSTART + 6 )
diff --git a/automation/source/simplecm/communiio.hxx b/automation/source/simplecm/communiio.hxx
new file mode 100644
index 000000000000..5431c9d49621
--- /dev/null
+++ b/automation/source/simplecm/communiio.hxx
@@ -0,0 +1,65 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+/*************************************************************************
+ *
+ * ATTENTION
+ * This file is intended to work inside and outside the StarOffice environment.
+ * Only adaption of file commtypes.hxx should be necessary. Else it is a bug!
+ *
+ ************************************************************************/
+
+#include <automation/commtypes.hxx>
+
+#define C_ERROR_NONE 0x0001
+#define C_ERROR_PERMANENT 0x0002
+#define C_ERROR_RETRY 0x0003
+#define C_ERROR_TIMEOUT 0x0004
+
+class ITransmiter
+{
+protected:
+ comm_ULONG nLastSent;
+public:
+ ITransmiter() :nLastSent( 0 ){}
+ virtual ~ITransmiter() {}
+ virtual comm_USHORT TransferBytes( const void* pBuffer, comm_UINT32 nLen ) = 0;
+
+ comm_ULONG GetLastSent() { return nLastSent; }
+};
+
+class IReceiver
+{
+protected:
+ comm_ULONG nLastReceived;
+public:
+ IReceiver() :nLastReceived( 0 ){}
+ virtual ~IReceiver() {;}
+ virtual comm_USHORT ReceiveBytes( void* pBuffer, comm_UINT32 nLen ) = 0;
+
+ comm_ULONG GetLastReceived() { return nLastReceived; }
+};
diff --git a/automation/source/simplecm/makefile.mk b/automation/source/simplecm/makefile.mk
new file mode 100644
index 000000000000..b6318ab4fd46
--- /dev/null
+++ b/automation/source/simplecm/makefile.mk
@@ -0,0 +1,46 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..
+
+PRJNAME=automation
+TARGET=simplecm
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files --------------------------------------------------------
+
+SLOFILES= \
+ $(SLO)$/tcpio.obj \
+ $(SLO)$/packethandler.obj \
+ $(SLO)$/simplecm.obj \
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/automation/source/simplecm/packethandler.cxx b/automation/source/simplecm/packethandler.cxx
new file mode 100644
index 000000000000..bafd277ca422
--- /dev/null
+++ b/automation/source/simplecm/packethandler.cxx
@@ -0,0 +1,334 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_automation.hxx"
+
+/*************************************************************************
+ *
+ * ATTENTION
+ * This file is intended to work inside and outside the StarOffice environment.
+ * Only adaption of file commtypes.hxx should be necessary. Else it is a bug!
+ *
+ ************************************************************************/
+
+#include "packethandler.hxx"
+#include <automation/commtypes.hxx>
+#include <automation/commdefines.hxx>
+#include "communiio.hxx"
+
+/**
+Forces switch to multichannel headers even for old communication Method
+**/
+#define FORCE_MULTI_CHANNEL_HEADERS
+
+
+PacketHandler::PacketHandler( ITransmiter* pTransmitter_, IReceiver* pReceiver_, comm_BOOL bMC )
+: pTransmitter( pTransmitter_ )
+, pReceiver( pReceiver_ )
+, bMultiChannel( bMC )
+{
+}
+
+unsigned char PacketHandler::CalcCheckByte( comm_UINT32 nBytes )
+{
+ comm_UINT16 nRes = 0;
+ nRes += HIBYTE( HIWORD( nBytes ) ) ^ 0xf0;
+ nRes += LOBYTE( HIWORD( nBytes ) ) ^ 0x0f;
+ nRes += HIBYTE( LOWORD( nBytes ) ) ^ 0xf0;
+ nRes += LOBYTE( LOWORD( nBytes ) ) ^ 0x0f;
+
+ nRes ^= HIBYTE( nRes );
+
+ return LOBYTE( nRes );
+}
+
+
+#define READ_SOCKET( pBuffer, nLength )\
+ if ( !bWasError )\
+ {\
+ bWasError |= pReceiver->ReceiveBytes( pBuffer, nLength ) != C_ERROR_NONE;\
+ }
+
+#define READ_SOCKET_LEN( pBuffer, nLength, nTotal )\
+ READ_SOCKET( pBuffer, nLength );\
+ if ( !bWasError )\
+ {nTotal += nLength;}
+
+comm_BOOL PacketHandler::ReceiveData( void* &pData, comm_UINT32 &nLen )
+{
+ DBG_ASSERT( !pData, "pData should be NULL -> memory leak" );
+
+ nLen = 0;
+ pData = NULL;
+ comm_BOOL bWasError = sal_False;
+ comm_BOOL bForceMultiChannelThisPacket = sal_False;
+ if ( pReceiver )
+ {
+ comm_UINT32 nBytes = 0;
+ nReceiveProtocol = CM_PROTOCOL_OLDSTYLE;
+ nReceiveHeaderType = CH_NoHeader;
+
+ READ_SOCKET( &nBytes, sizeof(nBytes) )
+ if ( bWasError )
+ return sal_False;
+
+ if ( 0xFFFFFFFF == nBytes ) // Expliziter Request für dieses Datenpaket auf MultiChannel umzuschalten
+ {
+ READ_SOCKET( &nBytes, sizeof(nBytes) )
+ if ( bWasError )
+ return sal_False;
+ bForceMultiChannelThisPacket = sal_True;
+ }
+
+ nBytes = NETDWORD( nBytes );
+
+ if ( bMultiChannel || bForceMultiChannelThisPacket )
+ {
+ comm_ULONG nReadSoFar = 0;
+ comm_ULONG nHeaderReadSoFar = 0;
+
+ // Prüfbyte für Längenangabe
+ unsigned char nLenCheck = 0;
+ READ_SOCKET_LEN( &nLenCheck, 1, nReadSoFar );
+ // Stimmt das Prüfbyte?
+ bWasError |= nLenCheck != CalcCheckByte( nBytes );
+
+
+ comm_UINT16 nHeaderBytes;
+ READ_SOCKET_LEN( &nHeaderBytes, 2, nReadSoFar );
+ nHeaderBytes = NETWORD( nHeaderBytes );
+ // reicht der Header über das Ende hinaus?
+ bWasError |= !(nBytes >= nReadSoFar + nHeaderBytes);
+
+ READ_SOCKET_LEN( &nReceiveHeaderType, 2, nHeaderReadSoFar );
+ nReceiveHeaderType = NETWORD( nReceiveHeaderType );
+
+ switch ( nReceiveHeaderType )
+ {
+ case CH_SimpleMultiChannel:
+ {
+ READ_SOCKET_LEN( &nReceiveProtocol, 2, nHeaderReadSoFar );
+ nReceiveProtocol = NETWORD( nReceiveProtocol );
+ }
+ break;
+ case CH_Handshake:
+ {
+ }
+ break;
+ default:
+ {
+ DBG_ERROR("Unbekannter Headertyp in der Kommunikation");
+ bWasError = sal_True;
+ }
+
+ }
+
+ if ( bWasError )
+ return sal_False;
+
+ /// Längen anpassen und ggf restheader überlesen.
+ while ( nHeaderBytes > nHeaderReadSoFar )
+ {
+ unsigned char nDummy;
+ READ_SOCKET_LEN( &nDummy, 1, nHeaderReadSoFar );
+ }
+
+ nReadSoFar += nHeaderReadSoFar;
+ nBytes -= nReadSoFar;
+
+ }
+
+ /* @@@ Notes @@@
+ *
+ * 1) a 'void*' allocated via 'new char[]' is always deallocated
+ * via plain 'delete()', not via array 'delete[]()'; it's just
+ * raw memory.
+ *
+ * 2) as the caller of this routine later-on changes ownership
+ * of 'pData' via 'SvMemoryStream::SetBuffer()' (in 'simplecm.cxx',
+ * 'SimpleCommunicationLinkViaSocket::DoReceiveDataStream()'),
+ * the allocator used here for 'void* pData' must match the
+ * deallocator used in 'SvMemoryStream::FreeMemory()', i.e.
+ * '::operator delete()'.
+ */
+ pData = ::operator new(nBytes);
+ READ_SOCKET( pData, nBytes )
+ if ( bWasError )
+ {
+ ::operator delete(pData), pData = 0;
+ return sal_False;
+ }
+ nLen = nBytes;
+ }
+ else
+ bWasError = sal_True;
+
+ return !bWasError;
+}
+
+/*#define WRITE_SOCKET( pBuffer, nLength )\
+ if ( !bWasError )\
+ bWasError |= !pStreamSocket || (pStreamSocket->write( pBuffer, nLength ) != nLength)*/
+
+#define WRITE_SOCKET( pBuffer, nLength )\
+ if ( !bWasError )\
+ {bWasError |= pTransmitter->TransferBytes( pBuffer, nLength ) != C_ERROR_NONE;}
+
+
+
+comm_BOOL PacketHandler::TransferData( const void* pData, comm_UINT32 nLen, CMProtocol nProtocol )
+{
+ comm_UINT32 nBuffer = nLen;
+ comm_BOOL bWasError = sal_False;
+
+#ifndef FORCE_MULTI_CHANNEL_HEADERS
+ if ( bMultiChannel )
+#endif
+ nBuffer += 1+2+2+2; // für einen CH_SimpleMultiChannel
+
+#ifdef FORCE_MULTI_CHANNEL_HEADERS
+ if ( !bMultiChannel )
+ {
+ comm_UINT32 n32;
+ n32 = 0xffffffff; // Umschalten auf MultiChannel
+ n32 = NETDWORD( n32 );
+ WRITE_SOCKET( &n32, 4 );
+ }
+#endif
+
+
+ comm_UINT32 nNetworkBuffer = NETDWORD( nBuffer );
+ WRITE_SOCKET( &nNetworkBuffer, sizeof(nNetworkBuffer) );
+
+
+#ifndef FORCE_MULTI_CHANNEL_HEADERS
+ if ( bMultiChannel )
+#endif
+ {
+ comm_UINT16 n16;
+ unsigned char c;
+
+ c = CalcCheckByte( nBuffer );
+ WRITE_SOCKET( &c, 1 );
+
+ n16 = 4; // Länge des Headers für einen CH_SimpleMultiChannel
+ n16 = NETWORD( n16 );
+ WRITE_SOCKET( &n16, 2 );
+
+ n16 = CH_SimpleMultiChannel; // Typ des Headers
+ n16 = NETWORD( n16 );
+ WRITE_SOCKET( &n16, 2 );
+
+ nProtocol = NETWORD( nProtocol );
+ WRITE_SOCKET( &nProtocol, 2 );
+ }
+
+ WRITE_SOCKET( pData, nLen );
+ return !bWasError;
+}
+
+comm_BOOL PacketHandler::SendHandshake( HandshakeType aHandshakeType, const void* pData, comm_UINT32 nLen )
+{
+ comm_BOOL bWasError = sal_False;
+
+ comm_UINT32 nBuffer = 0;
+
+// if ( pMyManager->IsMultiChannel() ) Wir senden immer FFFFFFFF vorweg -> immer MultiChannel (Oder GPF bei älteren)
+ nBuffer += 1+2+2; // für einen CH_Handshake
+
+ nBuffer += 2; // für den Typ des Handshakes
+
+ switch ( aHandshakeType )
+ {
+ case CH_REQUEST_HandshakeAlive:
+ nBuffer += 0; // Keine extra Daten
+ break;
+ case CH_RESPONSE_HandshakeAlive:
+ nBuffer += 0; // Keine extra Daten
+ break;
+ case CH_REQUEST_ShutdownLink:
+ nBuffer += 0; // Keine extra Daten
+ break;
+ case CH_ShutdownLink:
+ nBuffer += 0; // Keine extra Daten
+ break;
+ case CH_SUPPORT_OPTIONS:
+ nBuffer += 2 ; // one word extradata for options
+ break;
+ case CH_SetApplication:
+ nBuffer += 0 ; // one word extradata for options
+ break;
+ default:
+ DBG_ERROR("Unknown HandshakeType");
+ }
+
+ if ( pData )
+ nBuffer += nLen; // Extra data in Buffer
+
+ comm_UINT32 n32;
+ n32 = 0xffffffff; // Umschalten auf MultiChannel
+ n32 = NETDWORD( n32 );
+ WRITE_SOCKET( &n32, 4 );
+
+ comm_UINT32 nNetworkBuffer = NETDWORD( nBuffer );
+ WRITE_SOCKET( &nNetworkBuffer, sizeof(nNetworkBuffer) );
+
+
+ comm_UINT16 n16;
+ unsigned char c;
+
+ c = CalcCheckByte( nBuffer );
+ WRITE_SOCKET( &c, 1 );
+
+ n16 = 2; // Länge des Headers für einen CH_Handshake
+ n16 = NETWORD( n16 );
+ WRITE_SOCKET( &n16, 2 );
+
+ n16 = CH_Handshake; // Typ des Headers
+ n16 = NETWORD( n16 );
+ WRITE_SOCKET( &n16, 2 );
+
+ n16 = aHandshakeType; // Typ des Handshakes
+ n16 = NETWORD( n16 );
+ WRITE_SOCKET( &n16, 2 );
+
+
+ switch ( aHandshakeType )
+ {
+ case CH_SUPPORT_OPTIONS:
+ n16 = OPT_USE_SHUTDOWN_PROTOCOL;
+ n16 = NETWORD( n16 );
+ WRITE_SOCKET( &n16, 2 );
+ break;
+ }
+
+ if ( pData )
+ WRITE_SOCKET( pData, nLen );
+
+ return !bWasError;
+}
diff --git a/automation/source/simplecm/packethandler.hxx b/automation/source/simplecm/packethandler.hxx
new file mode 100644
index 000000000000..cb62f07343df
--- /dev/null
+++ b/automation/source/simplecm/packethandler.hxx
@@ -0,0 +1,69 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+/*************************************************************************
+ *
+ * ATTENTION
+ * This file is intended to work inside and outside the StarOffice environment.
+ * Only adaption of file commtypes.hxx should be necessary. Else it is a bug!
+ *
+ ************************************************************************/
+
+#ifndef _TOOLS_PACKETHANDLER_HXX_
+#define _TOOLS_PACKETHANDLER_HXX_
+
+#include <automation/commtypes.hxx>
+#include <automation/commdefines.hxx>
+
+class ITransmiter;
+class IReceiver;
+
+class PacketHandler
+{
+private:
+ unsigned char CalcCheckByte( comm_UINT32 nBytes );
+ ITransmiter* pTransmitter;
+ IReceiver* pReceiver;
+
+ comm_BOOL bMultiChannel;
+
+protected:
+ comm_UINT16 nReceiveProtocol;
+ comm_UINT16 nReceiveHeaderType;
+
+public:
+ PacketHandler( ITransmiter* pTransmitter_, IReceiver* pReceiver_, comm_BOOL bMC = sal_False );
+
+ comm_UINT16 GetReceiveProtocol() { return nReceiveProtocol; }
+ comm_UINT16 GetReceiveHeaderType() { return nReceiveHeaderType; }
+
+ comm_BOOL ReceiveData( void* &pData, comm_UINT32 &nLen ); /// Recieve DataPacket from Socket
+ virtual comm_BOOL SendHandshake( HandshakeType aHandshakeType, const void* pData = NULL, comm_UINT32 nLen = 0 );
+ virtual comm_BOOL TransferData( const void* pData, comm_UINT32 nLen, CMProtocol nProtocol = CM_PROTOCOL_OLDSTYLE );
+};
+
+#endif
diff --git a/automation/source/simplecm/simplecm.cxx b/automation/source/simplecm/simplecm.cxx
new file mode 100644
index 000000000000..74a86f343677
--- /dev/null
+++ b/automation/source/simplecm/simplecm.cxx
@@ -0,0 +1,702 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_automation.hxx"
+
+
+#define ENABLE_BYTESTRING_STREAM_OPERATORS
+#include <tools/solar.h>
+#include <automation/simplecm.hxx>
+
+#include <automation/commdefines.hxx>
+#include "packethandler.hxx"
+#include "tcpio.hxx"
+
+#if OSL_DEBUG_LEVEL > 1
+#include <stdio.h>
+void debug_printf( const char *chars )
+{
+ static BOOL bPrint = (getenv("DEBUG") != NULL);
+ if ( bPrint )
+ {
+ printf( chars );
+ fflush( stdout );
+ }
+}
+#endif
+
+CommunicationLink::CommunicationLink( CommunicationManager *pMan )
+: pMyManager(pMan)
+, pServiceData(NULL)
+, nServiceProtocol( 0 )
+, bIsInsideCallback( sal_False )
+, nTotalBytes( 0 )
+, maApplication("Undefined")
+#if OSL_DEBUG_LEVEL > 1
+, bFlag( sal_False )
+, nSomething( 0 )
+#endif
+{
+}
+
+CommunicationLink::~CommunicationLink()
+{
+#if OSL_DEBUG_LEVEL > 1
+ if ( !bFlag ) // bFlag will be set if deletion is expected else we can set a breakpoint
+ bFlag = sal_False;
+#endif
+ if ( pMyManager )
+ pMyManager->DestroyingLink( this );
+}
+
+void CommunicationLink::CallInfoMsg( InfoString aMsg )
+{
+ if ( pMyManager )
+ pMyManager->InfoMsg( aMsg );
+};
+
+CM_InfoType CommunicationLink::GetInfoType()
+{
+ if ( pMyManager )
+ return pMyManager->GetInfoType();
+ else
+ return CM_NO_TEXT;
+}
+
+IMPL_LINK( CommunicationLink, ConnectionClosed, void*, EMPTYARG )
+{
+ if ( pMyManager )
+ pMyManager->CallConnectionClosed( this );
+ return 1;
+}
+
+IMPL_LINK( CommunicationLink, DataReceived, void*, EMPTYARG )
+{
+ if ( pMyManager )
+ pMyManager->CallDataReceived( this );
+ return 1;
+}
+
+sal_Bool CommunicationLink::DoTransferDataStream( SvStream *pDataStream, CMProtocol nProtocol )
+{
+ INFO_MSG( CByteString("S :").Append( GetCommunicationPartner( CM_FQDN ) ),
+ CByteString("Daten Senden:").Append( GetCommunicationPartner( CM_FQDN ) ),
+ CM_SEND, this );
+ sal_Bool bWasError = sal_False;
+
+ sal_uInt32 nBuffer;
+ nBuffer = pDataStream->SeekRel(0) +1;
+ bWasError = pPacketHandler->TransferData( ((SvMemoryStream*)pDataStream)->GetData(), nBuffer, nProtocol ) != C_ERROR_NONE;
+
+ if ( bWasError )
+ {
+ INFO_MSG( CByteString("Send Failed:").Append( GetCommunicationPartner( CM_FQDN ) ),
+ CByteString( "Socket wird wegen Fehlers beim Senden geschlossen: ").Append( GetCommunicationPartner( CM_FQDN ) ),
+ CM_ERROR, this );
+ ShutdownCommunication();
+ }
+ return !bWasError;
+}
+
+sal_Bool CommunicationLink::TransferDataStream( SvStream *pDataStream, CMProtocol nProtocol )
+{
+ aLastAccess = DateTime();
+ nTotalBytes += pDataStream->Seek( STREAM_SEEK_TO_END );
+ return DoTransferDataStream( pDataStream, nProtocol );
+}
+
+void CommunicationLink::SetApplication( const ByteString& aApp )
+{
+ maApplication = aApp;
+}
+
+
+SimpleCommunicationLinkViaSocket::SimpleCommunicationLinkViaSocket( CommunicationManager *pMan, vos::OStreamSocket *pSocket )
+: CommunicationLink( pMan )
+, aCommunicationPartner()
+, aMyName()
+, pStreamSocket( pSocket )
+, pReceiveStream( NULL )
+, bIsRequestShutdownPending( sal_False )
+{
+ pTCPIO = new TCPIO( pStreamSocket );
+ pPacketHandler = new PacketHandler( (ITransmiter*) pTCPIO, pTCPIO, pMyManager->IsMultiChannel() );
+}
+
+SimpleCommunicationLinkViaSocket::~SimpleCommunicationLinkViaSocket()
+{
+ delete pPacketHandler;
+ pPacketHandler = NULL;
+ delete pTCPIO;
+ pTCPIO = NULL;
+ delete pStreamSocket;
+ pStreamSocket = NULL;
+}
+
+void SimpleCommunicationLinkViaSocket::SetStreamSocket( vos::OStreamSocket* pSocket )
+{
+ if ( pTCPIO )
+ pTCPIO->SetStreamSocket( pSocket );
+ pStreamSocket = pSocket;
+}
+
+sal_Bool SimpleCommunicationLinkViaSocket::StopCommunication()
+{
+ CommunicationLinkRef rHold(this); // avoid deleting this link before the end of the method
+ if ( !IsCommunicationError() ) // Meaning that the Communication is still runnung
+ {
+#if OSL_DEBUG_LEVEL > 1
+ debug_printf("Sending REQUEST_ShutdownLink\n");
+#endif
+ SendHandshake( CH_REQUEST_ShutdownLink );
+ }
+ WaitForShutdown();
+ return sal_True;
+}
+
+void SimpleCommunicationLinkViaSocket::SetFinalRecieveTimeout()
+{
+ if ( !IsCommunicationError() )
+ {
+ TimeValue aTime = {30, 0}; // 30 seconds
+ pStreamSocket->setRecvTimeout( &aTime );
+ }
+}
+
+sal_Bool SimpleCommunicationLinkViaSocket::IsCommunicationError()
+{
+ return !pStreamSocket;
+}
+
+ByteString SimpleCommunicationLinkViaSocket::GetCommunicationPartner( CM_NameType eType )
+{
+ if ( pStreamSocket )
+ {
+ switch ( eType )
+ {
+ case CM_DOTTED:
+ {
+ rtl::OUString aDotted;
+ vos::OSocketAddr *pPeerAdr = new vos::OSocketAddr;
+ pStreamSocket->getPeerAddr( *pPeerAdr );
+ ((vos::OInetSocketAddr*)pPeerAdr)->getDottedAddr( aDotted );
+ delete pPeerAdr;
+ return ByteString( UniString(aDotted), RTL_TEXTENCODING_UTF8 );
+ }
+ //break;
+ case CM_FQDN:
+ {
+ if ( !aCommunicationPartner.Len() )
+ {
+ rtl::OUString aFQDN;
+ pStreamSocket->getPeerHost( aFQDN );
+ aCommunicationPartner = ByteString( UniString(aFQDN), RTL_TEXTENCODING_UTF8 );
+ }
+ return aCommunicationPartner;
+ }
+ //break;
+ }
+ }
+ return CByteString( "Unknown" );
+}
+
+ByteString SimpleCommunicationLinkViaSocket::GetMyName( CM_NameType eType )
+{
+ if ( pStreamSocket )
+ {
+ switch ( eType )
+ {
+ case CM_DOTTED:
+ {
+ rtl::OUString aDotted;
+ vos::OSocketAddr *pPeerAdr = new vos::OSocketAddr;
+ pStreamSocket->getLocalAddr( *pPeerAdr );
+ ((vos::OInetSocketAddr*)pPeerAdr)->getDottedAddr( aDotted );
+ delete pPeerAdr;
+ return ByteString( UniString(aDotted), RTL_TEXTENCODING_UTF8 );
+ }
+ //break;
+ case CM_FQDN:
+ {
+ if ( !aMyName.Len() )
+ {
+ rtl::OUString aFQDN;
+ pStreamSocket->getLocalHost( aFQDN );
+ aMyName = ByteString( UniString(aFQDN), RTL_TEXTENCODING_UTF8 );
+ }
+ return aMyName;
+ }
+ //break;
+ }
+ }
+ return CByteString( "Error" );
+}
+
+SvStream* SimpleCommunicationLinkViaSocket::GetBestCommunicationStream()
+{
+ SvStream* pStream = new SvMemoryStream;
+// pStream->SetNumberFormatInt( NUMBERFORMAT_INT_BIGENDIAN );
+ return pStream;
+}
+
+#define READ_SOCKET( pBuffer, nLength )\
+ if ( !bWasError )\
+ {bWasError |= pTCPIO->ReceiveBytes( pBuffer, nLength ) != C_ERROR_NONE;}
+
+#define READ_SOCKET_LEN( pBuffer, nLength, nTotal )\
+ READ_SOCKET( pBuffer, nLength );\
+ if ( !bWasError )\
+ {nTotal += nLength;}
+
+sal_Bool SimpleCommunicationLinkViaSocket::DoReceiveDataStream()
+{
+ sal_Bool bWasError = sal_False;
+ void* pBuffer = NULL;
+ comm_UINT32 nLen;
+ bWasError = pPacketHandler->ReceiveData( pBuffer, nLen ) != C_ERROR_NONE;
+ if ( !bWasError )
+ {
+ pReceiveStream = GetBestCommunicationStream();
+ DBG_ASSERT( pReceiveStream->IsA() == ID_MEMORYSTREAM, "CommunicationStream is not an SvMemoryStream. Communication has to be reimplemented here!");
+ if ( pReceiveStream->IsA() == ID_MEMORYSTREAM )
+ ((SvMemoryStream*)pReceiveStream)->SetBuffer( pBuffer, nLen, sal_True, nLen );
+ DBG_ASSERT( pReceiveStream, "Datastream is NULL");
+ }
+
+ return !bWasError;
+}
+
+void SimpleCommunicationLinkViaSocket::SetApplication( const ByteString& aApp )
+{
+ CommunicationLink::SetApplication( aApp );
+ SvStream* pData = GetBestCommunicationStream();
+ *pData << aApp;
+ SendHandshake( CH_SetApplication, pData );
+ delete pData;
+}
+
+void SimpleCommunicationLinkViaSocket::SetNewPacketAsCurrent()
+{
+ pServiceData = pReceiveStream;
+ nServiceProtocol = pPacketHandler->GetReceiveProtocol();
+ nServiceHeaderType = pPacketHandler->GetReceiveHeaderType();
+}
+
+sal_Bool SimpleCommunicationLinkViaSocket::SendHandshake( HandshakeType aHandshakeType, SvStream* pData )
+{
+ sal_Bool bWasError;
+
+ if ( pData )
+ {
+ sal_uInt32 nBuffer;
+ nBuffer = pData->Seek( STREAM_SEEK_TO_END );
+ bWasError = !pPacketHandler->SendHandshake( aHandshakeType, ((SvMemoryStream*)pData)->GetData(), nBuffer );
+ }
+ else
+ bWasError = !pPacketHandler->SendHandshake( aHandshakeType );
+
+
+ if ( bWasError )
+ {
+ INFO_MSG( CByteString("Send Failed:").Append( GetCommunicationPartner( CM_FQDN ) ),
+ CByteString( "Socket wird wegen Fehlers beim Senden geschlossen: ").Append( GetCommunicationPartner( CM_FQDN ) ),
+ CM_ERROR, this );
+ ShutdownCommunication();
+ }
+ else
+ { // set new status
+ switch ( aHandshakeType )
+ {
+ case CH_REQUEST_HandshakeAlive:
+ break;
+ case CH_RESPONSE_HandshakeAlive:
+ break;
+ case CH_REQUEST_ShutdownLink:
+ bIsRequestShutdownPending = sal_True;
+ break;
+ case CH_ShutdownLink:
+ break;
+ case CH_SUPPORT_OPTIONS:
+ break;
+ case CH_SetApplication:
+ break;
+ default:
+ DBG_ERROR("Unknown HandshakeType");
+ }
+ }
+ return !bWasError;
+}
+
+SimpleCommunicationLinkViaSocketWithReceiveCallbacks::SimpleCommunicationLinkViaSocketWithReceiveCallbacks( CommunicationManager *pMan, vos::OStreamSocket *pSocket )
+: SimpleCommunicationLinkViaSocket( pMan, pSocket )
+{
+}
+
+SimpleCommunicationLinkViaSocketWithReceiveCallbacks::~SimpleCommunicationLinkViaSocketWithReceiveCallbacks()
+{
+ if ( pMyManager && pMyManager->IsLinkValid( this ) && !bIsRequestShutdownPending )
+ StopCommunication();
+}
+
+void SimpleCommunicationLinkViaSocketWithReceiveCallbacks::WaitForShutdown()
+{
+ CommunicationLinkRef rHold(this); // avoid deleting this link before the end of the method
+ SetFinalRecieveTimeout();
+ while ( pMyManager && !IsCommunicationError() )
+ ReceiveDataStream();
+}
+
+sal_Bool SimpleCommunicationLinkViaSocketWithReceiveCallbacks::ReceiveDataStream()
+{
+ if ( DoReceiveDataStream() )
+ {
+ SetNewPacketAsCurrent();
+ StartCallback();
+ DataReceived();
+ return sal_True;
+ }
+ else
+ {
+ StartCallback();
+ ShutdownCommunication();
+ return sal_False;
+ }
+}
+
+sal_Bool SimpleCommunicationLinkViaSocketWithReceiveCallbacks::ShutdownCommunication()
+{
+ if ( GetStreamSocket() )
+ GetStreamSocket()->shutdown();
+
+ if ( GetStreamSocket() )
+ GetStreamSocket()->close();
+
+ vos::OStreamSocket *pTempSocket = GetStreamSocket();
+ SetStreamSocket( NULL );
+ delete pTempSocket;
+
+ ConnectionClosed();
+
+ return sal_True;
+}
+
+
+
+CommunicationManager::CommunicationManager( sal_Bool bUseMultiChannel )
+: nInfoType( CM_NONE )
+, bIsCommunicationRunning( sal_False )
+, maApplication("Unknown")
+, bIsMultiChannel( bUseMultiChannel )
+{
+}
+
+CommunicationManager::~CommunicationManager()
+{
+ xLastNewLink.Clear();
+}
+
+sal_Bool CommunicationManager::StartCommunication( String aApp, String aParams )
+{
+ (void) aApp; /* avoid warning about unused parameter */
+ (void) aParams; /* avoid warning about unused parameter */
+ return sal_False;
+}
+
+sal_Bool CommunicationManager::StartCommunication( ByteString aHost, sal_uLong nPort )
+{
+ (void) aHost; /* avoid warning about unused parameter */
+ (void) nPort; /* avoid warning about unused parameter */
+ return sal_False;
+}
+
+ByteString CommunicationManager::GetMyName( CM_NameType )
+{
+ rtl::OUString aHostname;
+ vos::OSocketAddr::getLocalHostname( aHostname );
+ return ByteString( UniString(aHostname), RTL_TEXTENCODING_UTF8 );
+}
+
+void CommunicationManager::CallConnectionOpened( CommunicationLink* pCL )
+{
+ pCL->StartCallback(); // Sollte bereits vor dem Aufruf gerufen werden
+ pCL->aStart = DateTime();
+ pCL->aLastAccess = pCL->aStart;
+ bIsCommunicationRunning = sal_True;
+ pCL->SetApplication( GetApplication() );
+
+ xLastNewLink = pCL;
+
+ INFO_MSG( CByteString("C+:").Append( pCL->GetCommunicationPartner( CM_FQDN ) ),
+ CByteString("Verbindung aufgebaut: ").Append( pCL->GetCommunicationPartner( CM_FQDN ) ),
+ CM_OPEN, pCL );
+ ConnectionOpened( pCL );
+ pCL->FinishCallback();
+}
+
+void CommunicationManager::CallConnectionClosed( CommunicationLink* pCL )
+{
+ pCL->StartCallback(); // Sollte bereits vor dem Aufruf gerufen werden
+ pCL->aLastAccess = DateTime();
+
+ INFO_MSG( CByteString("C-:").Append( pCL->GetCommunicationPartner( CM_FQDN ) ),
+ CByteString("Verbindung abgebrochen: ").Append( pCL->GetCommunicationPartner( CM_FQDN ) ),
+ CM_CLOSE, pCL );
+ ConnectionClosed( pCL );
+
+ if ( xLastNewLink == pCL )
+ xLastNewLink.Clear();
+
+ pCL->FinishCallback();
+// delete pCL;
+}
+
+void CommunicationManager::CallDataReceived( CommunicationLink* pCL )
+{
+ pCL->StartCallback(); // Sollte bereits vor dem Aufruf gerufen werden
+ pCL->aLastAccess = DateTime();
+ CommunicationLinkRef rHold(pCL); // Hält den Zeiger bis zum Ende des calls
+
+ // should be impossible but happens for mysterious reasons
+ if ( !pCL->pServiceData )
+ {
+ DBG_ERROR( "Datastream is NULL" );
+ pCL->FinishCallback();
+ return;
+ }
+
+
+ if ( CH_Handshake == pCL->nServiceHeaderType )
+ {
+ SvStream *pData = pCL->GetServiceData();
+ sal_uInt16 nType;
+ pData->SetNumberFormatInt( NUMBERFORMAT_INT_BIGENDIAN ); // Unfortulately it is written this way :((
+ *pData >> nType;
+ pData->SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
+ switch ( nType )
+ {
+ case CH_REQUEST_HandshakeAlive:
+ {
+ pCL->SendHandshake( CH_RESPONSE_HandshakeAlive );
+ }
+ break;
+ case CH_REQUEST_ShutdownLink:
+ {
+#if OSL_DEBUG_LEVEL > 1
+ debug_printf("Sending ShutdownLink\n");
+#endif
+ pCL->SendHandshake( CH_ShutdownLink );
+ }
+ break;
+ case CH_ShutdownLink:
+ {
+#if OSL_DEBUG_LEVEL > 1
+ debug_printf("Executing ShutdownLink\n");
+#endif
+ pCL->ShutdownCommunication();
+ }
+ break;
+ case CH_SetApplication:
+ {
+ ByteString aApplication;
+ *pData >> aApplication;
+ pCL->CommunicationLink::SetApplication( aApplication );
+#if OSL_DEBUG_LEVEL > 1
+ debug_printf( "Setting Application to " );
+ debug_printf( aApplication.GetBuffer() );
+ debug_printf( "\n" );
+#endif
+ }
+ break;
+
+#if OSL_DEBUG_LEVEL > 1
+ default:
+ {
+ debug_printf("Unknown Handshake received\n");
+ }
+#endif
+ }
+ delete pData;
+ }
+ else
+ {
+ if ( pCL->pServiceData )
+ {
+ pCL->nTotalBytes += pCL->pServiceData->Seek( STREAM_SEEK_TO_END );
+ pCL->pServiceData->Seek( STREAM_SEEK_TO_BEGIN );
+ }
+
+ INFO_MSG( CByteString("D :").Append( pCL->GetCommunicationPartner( CM_FQDN ) ),
+ CByteString("Daten Empfangen:").Append( pCL->GetCommunicationPartner( CM_FQDN ) ),
+ CM_RECEIVE, pCL );
+ DataReceived( pCL );
+ }
+ delete pCL->GetServiceData();
+ pCL->FinishCallback();
+}
+
+void CommunicationManager::CallInfoMsg( InfoString aMsg )
+{
+ // Hier wird es wohl kein Housekeeping geben
+ InfoMsg( aMsg );
+}
+
+void CommunicationManager::SetApplication( const ByteString& aApp, sal_Bool bRunningLinks )
+{
+ maApplication = aApp;
+ if ( bRunningLinks )
+ {
+ sal_uInt16 i;
+ for ( i = 0 ; i < GetCommunicationLinkCount() ; i++ )
+ GetCommunicationLink( i )->SetApplication( aApp );
+ }
+}
+
+
+
+SingleCommunicationManager::SingleCommunicationManager( sal_Bool bUseMultiChannel )
+: CommunicationManager( bUseMultiChannel )
+{
+ xActiveLink = NULL;
+ pInactiveLink = NULL;
+}
+
+SingleCommunicationManager::~SingleCommunicationManager()
+{
+ StopCommunication();
+ if ( pInactiveLink )
+ pInactiveLink->InvalidateManager();
+}
+
+sal_Bool SingleCommunicationManager::StopCommunication()
+{
+ if ( xActiveLink.Is() )
+ {
+ sal_Bool bSuccess = xActiveLink->StopCommunication();
+ if ( pInactiveLink )
+ pInactiveLink->InvalidateManager();
+ pInactiveLink = xActiveLink;
+ xActiveLink.Clear();
+ return bSuccess;
+ }
+ return sal_True;
+}
+
+sal_Bool SingleCommunicationManager::IsLinkValid( CommunicationLink* pCL )
+{
+ return &xActiveLink == pCL;
+}
+
+sal_uInt16 SingleCommunicationManager::GetCommunicationLinkCount()
+{
+ return IsCommunicationRunning()?1:0;
+}
+
+CommunicationLinkRef SingleCommunicationManager::GetCommunicationLink( sal_uInt16 )
+{
+ return xActiveLink;
+}
+
+void SingleCommunicationManager::CallConnectionOpened( CommunicationLink* pCL )
+{
+ DBG_ASSERT( !xActiveLink.Is(), "Es ist bereits ein CommunicationLink aktiv");
+ if ( xActiveLink.Is() )
+ {
+ if ( pInactiveLink )
+ pInactiveLink->InvalidateManager();
+ pInactiveLink = xActiveLink;
+ xActiveLink->StopCommunication(); // Den alten Link brutal abwürgen
+ }
+ xActiveLink = pCL;
+ CommunicationManager::CallConnectionOpened( pCL );
+}
+
+void SingleCommunicationManager::CallConnectionClosed( CommunicationLink* pCL )
+{
+ CommunicationManager::CallConnectionClosed( pCL );
+
+ DBG_ASSERT( pCL == xActiveLink, "SingleCommunicationManager::CallConnectionClosed mit fremdem Link");
+ if ( pInactiveLink )
+ pInactiveLink->InvalidateManager();
+ pInactiveLink = xActiveLink;
+ xActiveLink.Clear();
+ bIsCommunicationRunning = sal_False;
+}
+
+void SingleCommunicationManager::DestroyingLink( CommunicationLink *pCL )
+{
+ pInactiveLink = NULL;
+ pCL->InvalidateManager();
+}
+
+
+SingleCommunicationManagerClientViaSocket::SingleCommunicationManagerClientViaSocket( ByteString aHost, sal_uLong nPort, sal_Bool bUseMultiChannel )
+: SingleCommunicationManager( bUseMultiChannel )
+, aHostToTalk( aHost )
+, nPortToTalk( nPort )
+{
+}
+
+
+SingleCommunicationManagerClientViaSocket::SingleCommunicationManagerClientViaSocket( sal_Bool bUseMultiChannel )
+: SingleCommunicationManager( bUseMultiChannel )
+, aHostToTalk()
+, nPortToTalk( 0 )
+{
+}
+
+
+sal_Bool CommonSocketFunctions::DoStartCommunication( CommunicationManager *pCM, ICommunicationManagerClient *pCMC, ByteString aHost, sal_uLong nPort )
+{
+ vos::OInetSocketAddr Addr;
+ vos::OConnectorSocket *pConnSocket;
+
+ Addr.setAddr( rtl::OUString( UniString( aHost, RTL_TEXTENCODING_UTF8 ) ) );
+ Addr.setPort( nPort );
+
+ TimeValue aTV;
+ aTV.Seconds = 10; // Warte 10 Sekunden
+ aTV.Nanosec = 0;
+ do
+ {
+ pConnSocket = new vos::OConnectorSocket();
+ pConnSocket->setTcpNoDelay( 1 );
+ if ( pConnSocket->connect( Addr, &aTV ) == vos::ISocketTypes::TResult_Ok )
+ {
+ pConnSocket->setTcpNoDelay( 1 );
+
+ pCM->CallConnectionOpened( CreateCommunicationLink( pCM, pConnSocket ) );
+ return sal_True;
+ }
+ else
+ delete pConnSocket;
+
+ } while ( pCMC->RetryConnect() );
+
+ return sal_False;
+}
+
diff --git a/automation/source/simplecm/tcpio.cxx b/automation/source/simplecm/tcpio.cxx
new file mode 100644
index 000000000000..7cd090c6bfb8
--- /dev/null
+++ b/automation/source/simplecm/tcpio.cxx
@@ -0,0 +1,71 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_automation.hxx"
+
+#include "tcpio.hxx"
+
+/// implement ITransmiter
+comm_USHORT TCPIO::TransferBytes( const void* pBuffer, comm_UINT32 nLen )
+{
+ vos::OGuard aGuard( aMSocketWriteAccess );
+ if ( !pStreamSocket )
+ {
+ nLastSent = 0;
+ return C_ERROR_PERMANENT;
+ }
+ nLastSent = pStreamSocket->write( pBuffer, nLen );
+ if ( nLastSent == nLen )
+ return C_ERROR_NONE;
+ return C_ERROR_PERMANENT;
+}
+
+
+/// implement IReceiver
+comm_USHORT TCPIO::ReceiveBytes( void* pBuffer, comm_UINT32 nLen )
+{
+ vos::OGuard aGuard( aMSocketReadAccess );
+ if ( !pStreamSocket )
+ {
+ nLastReceived = 0;
+ return C_ERROR_PERMANENT;
+ }
+ nLastReceived = pStreamSocket->read( pBuffer, nLen );
+ if ( nLastReceived == nLen )
+ return C_ERROR_NONE;
+ return C_ERROR_PERMANENT;
+}
+
+
+// helper
+void TCPIO::SetStreamSocket( vos::OStreamSocket *pSocket )
+{
+ vos::OGuard aRGuard( aMSocketReadAccess );
+ vos::OGuard aWGuard( aMSocketWriteAccess );
+ pStreamSocket = pSocket;
+}
diff --git a/automation/source/simplecm/tcpio.hxx b/automation/source/simplecm/tcpio.hxx
new file mode 100644
index 000000000000..5b6a997917e5
--- /dev/null
+++ b/automation/source/simplecm/tcpio.hxx
@@ -0,0 +1,61 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef TCPIO_HXX
+#define TCPIO_HXX
+
+#include <vos/socket.hxx>
+#include <vos/mutex.hxx>
+
+#include "communiio.hxx"
+
+class TCPIO : public ITransmiter, public IReceiver
+{
+private:
+ vos::OStreamSocket *pStreamSocket;
+ vos::OMutex aMSocketReadAccess;
+ vos::OMutex aMSocketWriteAccess;
+
+public:
+
+ ///
+ TCPIO( vos::OStreamSocket *pSocket ):pStreamSocket( pSocket ){}
+ virtual ~TCPIO(){}
+
+
+ /// implement ITransmiter
+ virtual comm_USHORT TransferBytes( const void* pBuffer, comm_UINT32 nLen );
+
+ /// implement IReceiver
+ virtual comm_USHORT ReceiveBytes( void* pBuffer, comm_UINT32 nLen );
+
+ // helper
+ void SetStreamSocket( vos::OStreamSocket *pSocket );
+
+};
+
+#endif
diff --git a/automation/source/testtool/cmdstrm.cxx b/automation/source/testtool/cmdstrm.cxx
new file mode 100644
index 000000000000..17621aec9d53
--- /dev/null
+++ b/automation/source/testtool/cmdstrm.cxx
@@ -0,0 +1,471 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_automation.hxx"
+#ifndef _KEYCOD_HXX //autogen
+#include <vcl/keycod.hxx>
+#endif
+#include <basic/sbx.hxx>
+#include <tools/stream.hxx>
+
+#include "cmdstrm.hxx"
+#include "rcontrol.hxx"
+#include "objtest.hxx"
+#include "sttresid.hxx"
+#include "svcommstream.hxx"
+#include <basic/testtool.hrc>
+
+ControlDefLoad __READONLY_DATA CmdStream::arKeyCodes [] =
+#include <keycodes.hxx>
+CNames *CmdStream::pKeyCodes = NULL;
+
+ResMgr* SttResId::getSttResMgr()
+{
+ static ResMgr* pMgr = NULL;
+ if( ! pMgr )
+ pMgr = CREATEVERSIONRESMGR( stt );
+ return pMgr;
+}
+
+CmdStream::CmdStream()
+{
+ pSammel = new SvMemoryStream();
+ pCommStream = new SvCommStream( pSammel );
+}
+
+CmdStream::~CmdStream()
+{
+ delete pCommStream;
+ delete pSammel;
+}
+
+
+#define PUT_CHAR(ch) \
+ sal_uInt16 nMCode = nModify + ch; \
+ sal_uInt16 _Code = 1; \
+ if ( (nMCode & 0xFF) == 0 ) \
+ _Code |= 2; \
+ if ( (nMCode >> 8) == 0 ) \
+ _Code |= 4; \
+ Result += (char) _Code; \
+ Result += (char) ( nMCode & 0xFF ); \
+ Result += (char) ( nMCode >> 8 )
+
+
+String CmdStream::WandleKeyEventString( String aKeys )
+{
+ if ( !pKeyCodes )
+ ReadFlatArray(arKeyCodes,pKeyCodes);
+ if ( !pKeyCodes )
+ return aKeys;
+
+ xub_StrLen nPos1 = 0;
+ while ( (nPos1 = aKeys.Search('<',nPos1)) != STRING_NOTFOUND)
+ {
+ xub_StrLen nPos2 = aKeys.Search('>',nPos1);
+ if ( nPos2 != STRING_NOTFOUND )
+ {
+ String Work = aKeys.Copy(nPos1+1,nPos2-nPos1+1-2);
+ aKeys.Erase(nPos1,nPos2-nPos1+1); // Inclusive Spitze Klammern weg
+ String Result, Token;
+ sal_uInt16 nModify = 0;
+ while ( Work.Len() > 0 )
+ {
+ Token = Work.GetToken(0,' ');
+ Work.Erase(0,Token.Len()+1);
+ ControlDef WhatName(Token,rtl::OString());
+ sal_uInt16 nElement;
+ if (pKeyCodes->Seek_Entry(&WhatName,&nElement))
+ {
+ // FIXME: HELPID
+ sal_uInt16 nCode = 0;//(sal_uInt16) pKeyCodes->GetObject(nElement)->pData->aUId.GetNum();
+ if ( nCode >= KEY_SHIFT )
+ nModify ^= nCode;
+ else
+ {
+ if ( ( nModify == 0 ) &&
+ (((nCode & 0xFF00) == KEYGROUP_NUM) ||
+ ((nCode & 0xFF00) == KEYGROUP_ALPHA) ||
+ ( nCode == KEY_SPACE) ||
+ ( nCode == KEY_ADD) ||
+ ( nCode == KEY_SUBTRACT) ||
+ ( nCode == KEY_MULTIPLY) ||
+ ( nCode == KEY_DIVIDE) ||
+ ( nCode == KEY_POINT) ||
+ ( nCode == KEY_COMMA) ||
+ ( nCode == KEY_LESS) ||
+ ( nCode == KEY_GREATER) ||
+ ( nCode == KEY_EQUAL) ) )
+ {
+ switch ( nCode )
+ {
+ case KEY_SPACE: Token = ' '; break;
+ case KEY_ADD: Token = '+'; break;
+ case KEY_SUBTRACT: Token = '-'; break;
+ case KEY_MULTIPLY: Token = '*'; break;
+ case KEY_DIVIDE: Token = '/'; break;
+ case KEY_POINT: Token = '.'; break;
+ case KEY_COMMA: Token = ','; break;
+ case KEY_LESS: Token = '<'; break;
+ case KEY_GREATER: Token = '>'; break;
+ case KEY_EQUAL: Token = '='; break;
+ default:
+// if ( nModify == 0 )
+// Token.ToLower();
+// else
+// Token.ToUpper();
+ ;
+ }
+ Result += Token;
+ }
+ else
+ {
+ PUT_CHAR (nCode);
+ }
+ }
+ }
+ else
+ {
+ Result += '<';
+ Result += Token;
+ Result += ' ';
+ Result += String( SttResId( S_INVALID_KEYCODE ) );
+ Result += '>';
+ }
+ }
+ aKeys.Insert(Result,nPos1);
+ nPos1 = nPos1 + Result.Len();
+ }
+ else
+ nPos1 = aKeys.Len() + 1;
+ }
+
+ return aKeys;
+}
+
+
+void CmdStream::WriteSortedParams( SbxArray* rPar, sal_Bool IsKeyString )
+{
+ sal_uInt16 nParams = PARAM_NONE;
+ sal_uInt16 nNr1=0,nNr2=0,nNr3=0,nNr4=0;
+ comm_ULONG nLNr1=0;
+ String aString1,aString2;
+ sal_Bool bBool1=sal_False,bBool2=sal_False;
+
+ if ( rPar )
+ {
+ for ( sal_uInt16 i = 1; i < rPar->Count() ; i++)
+ {
+ switch (rPar->Get( i )->GetType())
+ {
+ case SbxLONG: // alles immer als Short �bertragen
+ case SbxULONG:
+ case SbxLONG64:
+ case SbxULONG64:
+ case SbxDOUBLE:
+ case SbxINTEGER:
+ case SbxBYTE:
+ case SbxUSHORT:
+ case SbxINT:
+ case SbxUINT:
+ case SbxSINGLE:
+ if ( (nParams & PARAM_USHORT_1) == 0 )
+ {
+ nParams |= PARAM_USHORT_1;
+ nNr1 = rPar->Get( i )->GetUShort();
+ }
+ else if ( (nParams & PARAM_USHORT_2) == 0 )
+ {
+ nParams |= PARAM_USHORT_2;
+ nNr2 = rPar->Get( i )->GetUShort();
+ }
+ else if ( (nParams & PARAM_USHORT_3) == 0 )
+ {
+ nParams |= PARAM_USHORT_3;
+ nNr3 = rPar->Get( i )->GetUShort();
+ }
+ else if ( (nParams & PARAM_USHORT_4) == 0 )
+ {
+ nParams |= PARAM_USHORT_4;
+ nNr4 = rPar->Get( i )->GetUShort();
+ }
+ else
+ SbxBase::SetError( SbxERR_WRONG_ARGS );
+ break;
+ case SbxOBJECT: // whenever a control is passed. TabPage, MenuBar
+ {
+ SbxProperty *pMember = NULL;
+ if ( rPar->Get( i )->ISA( SbxObject ) )
+ pMember = ((SbxObject*)rPar->Get( i ))->GetDfltProperty();
+ if ( pMember != NULL )
+ {
+ if ( pMember->GetType() == SbxSTRING )
+ {
+ if ( nParams & PARAM_STR_1 )
+ if ( nParams & PARAM_STR_2 )
+ SbxBase::SetError( SbxERR_WRONG_ARGS );
+ else
+ {
+ nParams |= PARAM_STR_2;
+ aString2 = pMember->GetString();
+ }
+ else
+ {
+ nParams |= PARAM_STR_1;
+ aString1 = pMember->GetString();
+ }
+ break;
+ }
+ else if ( pMember->GetType() == SbxULONG )
+ {
+ if ( nParams & PARAM_ULONG_1 )
+ SbxBase::SetError( SbxERR_WRONG_ARGS );
+ else
+ {
+ nParams |= PARAM_ULONG_1;
+ nLNr1 = pMember->GetULong();
+ }
+ }
+ else
+ SbxBase::SetError( SbxERR_NAMED_NOT_FOUND );
+ }
+ else
+ {
+ SbxBase::SetError( SbxERR_NAMED_NOT_FOUND );
+ }
+ }
+ break;
+ case SbxSTRING:
+ case SbxCHAR:
+ if ( nParams & PARAM_STR_1 )
+ if ( nParams & PARAM_STR_2 )
+ SbxBase::SetError( SbxERR_WRONG_ARGS );
+ else
+ {
+ nParams |= PARAM_STR_2;
+ aString2 = rPar->Get( i )->GetString();
+ }
+ else
+ {
+ nParams |= PARAM_STR_1;
+ aString1 = rPar->Get( i )->GetString();
+ }
+ break;
+ case SbxBOOL:
+ if ( nParams & PARAM_BOOL_1 )
+ if ( nParams & PARAM_BOOL_2 )
+ SbxBase::SetError( SbxERR_WRONG_ARGS );
+ else
+ {
+ nParams |= PARAM_BOOL_2;
+ bBool2 = rPar->Get( i )->GetBool();
+ }
+ else
+ {
+ nParams |= PARAM_BOOL_1;
+ bBool1 = rPar->Get( i )->GetBool();
+ }
+ break;
+ default:
+ SbxBase::SetError( SbxERR_WRONG_ARGS );
+ break;
+ }
+ }
+ }
+ Write (nParams);
+ if( nParams & PARAM_USHORT_1 ) Write( nNr1 );
+ if( nParams & PARAM_USHORT_2 ) Write( nNr2 );
+ if( nParams & PARAM_USHORT_3 ) Write( nNr3 );
+ if( nParams & PARAM_USHORT_4 ) Write( nNr4 );
+ if( nParams & PARAM_ULONG_1 ) Write( nLNr1 );
+ if( nParams & PARAM_STR_1 ) Write( aString1, IsKeyString );
+ if( nParams & PARAM_STR_2 ) Write( aString2, IsKeyString );
+ if( nParams & PARAM_BOOL_1 ) Write( bBool1 );
+ if( nParams & PARAM_BOOL_2 ) Write( bBool2 );
+}
+
+void CmdStream::GenCmdCommand( sal_uInt16 nNr, SbxArray* rPar )
+{
+ Write(sal_uInt16(SICommand));
+ Write(nNr);
+ WriteSortedParams(rPar, (nNr & M_KEY_STRING) != 0 );
+}
+
+void CmdStream::GenCmdSlot( sal_uInt16 nNr, SbxArray* rPar )
+{
+ Write(sal_uInt16(SISlot));
+ Write(nNr);
+ if (rPar)
+ {
+ sal_uInt16 nAnz = (rPar->Count()-1) >> 1; // Geteilt durch 2
+ Write(nAnz);
+ sal_Bool bWriteUnoSlot = rPar->Get( 1 )->GetType() == SbxSTRING;
+
+ for (sal_uInt16 n = 1 ; n <= nAnz ; n++)
+ {
+ /// #59513# nicht mehr ben�tigt
+// sal_uLong nUserData = rPar->Get( 2*n-1 )->GetUserData();
+// rPar->Get( 2*n-1 )->SetUserData(ID_DoNothing); // Verhindert Ausf�hrung der Slots, die als Parameter �bergeben sind.
+
+ if ( bWriteUnoSlot )
+ Write(rPar->Get( 2*n-1 )->GetString());
+ else
+ Write(rPar->Get( 2*n-1 )->GetUShort());
+ switch (rPar->Get( 2*n )->GetType())
+ {
+ case SbxINTEGER:
+ case SbxBYTE:
+ case SbxUSHORT:
+ case SbxINT:
+ case SbxUINT:
+ case SbxSINGLE:
+ if ( !bWriteUnoSlot )
+ Write( (sal_uInt16)BinUSHORT );
+ Write(rPar->Get( 2*n )->GetUShort());
+ break;
+ case SbxLONG:
+ case SbxULONG:
+ case SbxLONG64:
+ case SbxULONG64:
+ case SbxDOUBLE:
+ if ( !bWriteUnoSlot )
+ Write( (sal_uInt16)BinULONG );
+ Write(rPar->Get( 2*n )->GetULong());
+ break;
+ case SbxSTRING:
+ case SbxCHAR:
+ if ( !bWriteUnoSlot )
+ Write( (sal_uInt16)BinString);
+ Write((String)rPar->Get( 2*n )->GetString()); // Cast f�r OS/2
+ break;
+ case SbxBOOL:
+ if ( !bWriteUnoSlot )
+ Write( (sal_uInt16)BinBool);
+ Write(rPar->Get( 2*n )->GetBool());
+ break;
+ default:
+ SbxBase::SetError( SbxERR_WRONG_ARGS );
+ break;
+ }
+
+ /// #59513# nicht mehr ben�tigt ( siehe oben )
+// rPar->Get( 2*n-1 )->SetUserData(nUserData); // Und wieder zur�cksetzen, so da� auch alles sauber ist.
+ }
+ }
+ else
+ Write(sal_uInt16(0));
+}
+
+void CmdStream::GenCmdUNOSlot( const String &aURL )
+{
+ Write( sal_uInt16(SIUnoSlot) );
+/* Write( sal_uInt16(0) ); // Hier wird im Office die SID_OPENURL Eingetragen.
+ // Dies mu� nat�rlich im Office hart verdratet werden und nicht hier,
+ // da sich die ID ja mal �ndern kann.
+
+ // Da auch die ID f�r das PoolItem im Office entnommen werden mu� hier also kein PoolItem
+ // gesendet werden.
+
+ Write( sal_uInt16(0) ); // Anzahl PoolItems
+
+ // Stattdessen wird noch eine extra String gesendet, der dann Officeseitig in ein
+ // SfxStringItem mit entsprechender ID gewandelt wird.
+ Write( aURL ); // String f�r das PoolItem*/
+
+ Write( aURL ); // Die UNO URL eben
+}
+
+void CmdStream::GenCmdControl( comm_ULONG nUId, sal_uInt16 nMethodId, SbxArray* rPar )
+{
+ Write(sal_uInt16(SIControl));
+ Write(nUId);
+ Write(nMethodId);
+ WriteSortedParams(rPar, (nMethodId & M_KEY_STRING) != 0 );
+}
+
+void CmdStream::GenCmdControl( String aUId, sal_uInt16 nMethodId, SbxArray* rPar )
+{
+ Write(sal_uInt16(SIStringControl));
+ Write(aUId);
+ Write(nMethodId);
+ WriteSortedParams(rPar, (nMethodId & M_KEY_STRING) != 0 );
+}
+
+void CmdStream::GenCmdFlow( sal_uInt16 nArt )
+{
+ Write(sal_uInt16(SIFlow));
+ Write(nArt);
+ Write(sal_uInt16(PARAM_NONE)); // Typ der folgenden Parameter
+}
+
+void CmdStream::GenCmdFlow( sal_uInt16 nArt, sal_uInt16 nNr1 )
+{
+ Write(sal_uInt16(SIFlow));
+ Write(nArt);
+ Write(sal_uInt16(PARAM_USHORT_1)); // Typ der folgenden Parameter
+ Write(nNr1);
+}
+
+void CmdStream::GenCmdFlow( sal_uInt16 nArt, comm_ULONG nNr1 )
+{
+ Write(sal_uInt16(SIFlow));
+ Write(nArt);
+ Write(sal_uInt16(PARAM_ULONG_1)); // Typ der folgenden Parameter
+ Write(nNr1);
+}
+
+void CmdStream::GenCmdFlow( sal_uInt16 nArt, String aString1 )
+{
+ Write(sal_uInt16(SIFlow));
+ Write(nArt);
+ Write(sal_uInt16(PARAM_STR_1)); // Typ der folgenden Parameter
+ Write(aString1);
+}
+
+void CmdStream::Write( String aString, sal_Bool IsKeyString )
+{
+ if ( IsKeyString )
+ Write( WandleKeyEventString( aString ), sal_False );
+ else
+ Write( aString.GetBuffer(), aString.Len() );
+}
+
+SvMemoryStream* CmdStream::GetStream()
+{
+ return pSammel;
+}
+
+void CmdStream::Reset( comm_ULONG nSequence )
+{
+ delete pCommStream;
+ delete pSammel;
+ pSammel = new SvMemoryStream();
+ pCommStream = new SvCommStream( pSammel );
+ GenCmdFlow (F_Sequence,nSequence);
+}
+
diff --git a/automation/source/testtool/cmdstrm.hxx b/automation/source/testtool/cmdstrm.hxx
new file mode 100644
index 000000000000..8cdd695c6ca7
--- /dev/null
+++ b/automation/source/testtool/cmdstrm.hxx
@@ -0,0 +1,78 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _CMDSTRM_HXX
+#define _CMDSTRM_HXX
+
+#include <objtest.hxx>
+#include <testapp.hxx>
+#include "cmdbasestream.hxx"
+
+class CmdStream : public CmdBaseStream
+{
+public:
+ CmdStream();
+ ~CmdStream();
+
+ void WriteSortedParams( SbxArray* rPar, sal_Bool IsKeyString = sal_False );
+
+ void GenCmdCommand( sal_uInt16 nNr, SbxArray* rPar );
+
+ void GenCmdSlot( sal_uInt16 nNr, SbxArray* rPar );
+
+ void GenCmdUNOSlot( const String &aURL );
+
+ void GenCmdControl( comm_ULONG nUId, sal_uInt16 nMethodId, SbxArray* rPar );
+ void GenCmdControl( String aUId, sal_uInt16 nMethodId, SbxArray* rPar );
+
+
+ void GenCmdFlow( sal_uInt16 nArt );
+ void GenCmdFlow( sal_uInt16 nArt, sal_uInt16 nNr1 );
+ void GenCmdFlow( sal_uInt16 nArt, comm_ULONG nNr1 );
+ void GenCmdFlow( sal_uInt16 nArt, String aString1 );
+
+ void Reset(comm_ULONG nSequence);
+
+ SvMemoryStream* GetStream();
+
+ static CNames *pKeyCodes; // Namen der Sondertasten MOD1, F1, LEFT ...
+ static ControlDefLoad __READONLY_DATA arKeyCodes [];
+
+private:
+ String WandleKeyEventString( String aKeys ); // Nutzt pKeyCodes. <RETURN> <SHIFT LEFT LEFT>
+
+ using CmdBaseStream::Write;
+ void Write( comm_USHORT nNr ){CmdBaseStream::Write( nNr );}
+ void Write( comm_ULONG nNr ){CmdBaseStream::Write( nNr );}
+ void Write( const comm_UniChar* aString, comm_USHORT nLenInChars ){CmdBaseStream::Write( aString, nLenInChars );}
+ void Write( comm_BOOL bBool ){CmdBaseStream::Write( bBool );}
+// new
+ void Write( String aString, sal_Bool IsKeyString = sal_False );
+
+ SvMemoryStream *pSammel;
+};
+
+#endif
diff --git a/automation/source/testtool/comm_bas.cxx b/automation/source/testtool/comm_bas.cxx
new file mode 100644
index 000000000000..f8dafece2a5b
--- /dev/null
+++ b/automation/source/testtool/comm_bas.cxx
@@ -0,0 +1,442 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_automation.hxx"
+
+#include "comm_bas.hxx"
+#include <tools/errcode.hxx>
+#include <basic/sbxobj.hxx>
+#include <basic/sbx.hxx>
+#ifndef __SBX_SBXVARIABLE_HXX //autogen
+#include <basic/sbxvar.hxx>
+#endif
+#include <vcl/svapp.hxx>
+#include <automation/communi.hxx>
+#ifndef _BASIC_TTRESHLP_HXX
+#include <basic/ttstrhlp.hxx>
+#endif
+
+// Der CommunicationManager hat folgende Elemente:
+// 1) Properties:
+// Keine
+// 2) Methoden:
+// CommunicationLink StartCommunication( Host, Port )
+// StopAllCommunication // Alle Kommunikation wird abgebrochen
+// sal_Bool IsCommunicationRunning // Läuft noch irgendwas
+// String GetMyName Der eigene Name
+// sal_Bool IsLinkValid( CommunicationLink ) // Ist dieser Link noch gültig
+// SetCommunicationEventHandler( String ) // Diese Funktion wird aufgerufen bei jedem Event
+
+// Der CommunicationLink hat folgende Elemente:
+// 1) Properties:
+// Keine
+// 2) Methoden:
+// StopCommunication Die Kommunikation wird abgebrochen
+// String GetMyName Der eigene Name
+// String GetHostName Der Name des Anderen
+// Send(String ) String an den Partner schicken
+// String GetString Ergebnis des letzten Empfangs
+
+
+// Diese Implementation ist ein Beispiel fuer eine tabellengesteuerte
+// Version, die sehr viele Elemente enthalten kann. Die Elemente werden
+// je nach Bedarf aus der Tabelle in das Objekt uebernommen.
+
+// Das nArgs-Feld eines Tabelleneintrags ist wie folgt verschluesselt:
+
+#define _ARGSMASK 0x00FF // Bis zu 255 Argumente
+#define _RWMASK 0x0F00 // Maske fuer R/W-Bits
+#define _TYPEMASK 0xF000 // Maske fuer den Typ des Eintrags
+
+#define _READ 0x0100 // kann gelesen werden
+#define _BWRITE 0x0200 // kann as Lvalue verwendet werden
+#define _LVALUE _BWRITE // kann as Lvalue verwendet werden
+#define _READWRITE 0x0300 // beides
+#define _OPT 0x0400 // TRUE: optionaler Parameter
+#define _METHOD 0x1000 // Masken-Bit fuer eine Methode
+#define _PROPERTY 0x2000 // Masken-Bit fuer eine Property
+#define _COLL 0x4000 // Masken-Bit fuer eine Collection
+ // Kombination von oberen Bits:
+#define _FUNCTION 0x1100 // Maske fuer Function
+#define _LFUNCTION 0x1300 // Maske fuer Function, die auch als Lvalue geht
+#define _ROPROP 0x2100 // Maske Read Only-Property
+#define _WOPROP 0x2200 // Maske Write Only-Property
+#define _RWPROP 0x2300 // Maske Read/Write-Property
+#define _COLLPROP 0x4100 // Maske Read-Collection-Element
+
+#define COLLNAME "Elements" // Name der Collection, hier mal hart verdrahtet
+
+
+
+CommunicationWrapper::Methods CommunicationWrapper::aManagerMethods[] = {
+// Neue Kommunikation aufbauen
+{ "StartCommunication", SbxEMPTY, &CommunicationWrapper::MStartCommunication, 2 | _FUNCTION },
+ // Zwei Named Parameter
+ { "Host", SbxSTRING, NULL, 0 },
+ { "Port", SbxLONG, NULL, 0 },
+// Alle Kommunikation wird abgebrochen
+{ "StopAllCommunication", SbxEMPTY, &CommunicationWrapper::MStopAllCommunication, 0 | _FUNCTION },
+// Läuft noch irgendwas
+{ "IsCommunicationRunning", SbxBOOL, &CommunicationWrapper::MIsCommunicationRunning, 0 | _FUNCTION },
+// Hostname als FQDN erfragen
+{ "GetMyName", SbxSTRING, &CommunicationWrapper::MGetMyName, 0 | _FUNCTION },
+// Abfragen ob der Link überhaupt noch gültig ist
+{ "IsLinkValid", SbxBOOL, &CommunicationWrapper::MIsLinkValid, 1 | _FUNCTION },
+ // Ein Named Parameter
+ { "Link", SbxOBJECT, NULL, 0 },
+// Dieser Handler wird dauernd gerufen
+{ "SetCommunicationEventHandler", SbxEMPTY, &CommunicationWrapper::MSetCommunicationEventHandler, 1 | _FUNCTION },
+ // Ein Named Parameter
+ { "FuncName", SbxSTRING, NULL, 0 },
+
+{ NULL, SbxNULL, NULL, -1 }}; // Tabellenende
+
+
+
+
+
+
+CommunicationWrapper::Methods CommunicationWrapper::aLinkMethods[] = {
+// Die Kommunikation wird abgebrochen
+{ "StopCommunication", SbxEMPTY, &CommunicationWrapper::LStopCommunication, 0 | _FUNCTION },
+// Der eigene Name
+{ "GetMyName", SbxSTRING, &CommunicationWrapper::LGetMyName, 0 | _FUNCTION },
+// Der Name des Anderen
+{ "GetHostName", SbxSTRING, &CommunicationWrapper::LGetHostName, 0 | _FUNCTION },
+// String an den Partner schicken
+{ "Send", SbxEMPTY, &CommunicationWrapper::LSend, 1 | _FUNCTION },
+ // Ein Named Parameter
+ { "SendString", SbxSTRING, NULL, 0 },
+// Ergebnis des letzten Empfangs
+{ "GetString", SbxSTRING, &CommunicationWrapper::LGetString, 0 | _FUNCTION },
+
+{ NULL, SbxNULL, NULL, -1 }}; // Tabellenende
+
+
+
+
+
+// Konstruktor für den Manager
+CommunicationWrapper::CommunicationWrapper( const String& rClass ) : SbxObject( rClass )
+, m_pLink( NULL )
+, m_bIsManager( sal_True )
+, m_bCatchOpen( sal_False )
+, m_pNewLink( NULL )
+{
+// SetName( CUniString("Manager") );
+ m_pMethods = &aManagerMethods[0];
+ m_pManager = new CommunicationManagerClientViaSocket;
+ m_pManager->SetConnectionOpenedHdl( LINK( this, CommunicationWrapper, Open ) );
+ m_pManager->SetConnectionClosedHdl( LINK( this, CommunicationWrapper, Close ) );
+ m_pManager->SetDataReceivedHdl( LINK( this, CommunicationWrapper, Data ) );
+}
+
+// Konstruktor für den Link
+CommunicationWrapper::CommunicationWrapper( CommunicationLink *pThisLink ) : SbxObject( CUniString("Link") )
+, m_pLink( pThisLink )
+, m_bIsManager( sal_False )
+, m_bCatchOpen( sal_False )
+, m_pNewLink( NULL )
+{
+ m_pMethods = &aLinkMethods[0];
+ m_pManager = (CommunicationManagerClientViaSocket*)pThisLink->GetCommunicationManager();
+}
+
+// Destruktor
+CommunicationWrapper::~CommunicationWrapper()
+{
+ if ( m_bIsManager )
+ delete m_pManager;
+}
+
+
+// Suche nach einem Element:
+// Hier wird linear durch die Methodentabelle gegangen, bis eine
+// passende Methode gefunden wurde.
+// Wenn die Methode/Property nicht gefunden wurde, nur NULL ohne
+// Fehlercode zurueckliefern, da so auch eine ganze Chain von
+// Objekten nach der Methode/Property befragt werden kann.
+
+SbxVariable* CommunicationWrapper::Find( const String& rName, SbxClassType t )
+{
+ // Ist das Element bereits vorhanden?
+ SbxVariable* pRes = SbxObject::Find( rName, t );
+ if( !pRes && t != SbxCLASS_OBJECT )
+ {
+ // sonst suchen
+ Methods* p = m_pMethods;
+ short nIndex = 0;
+ sal_Bool bFound = sal_False;
+ while( p->nArgs != -1 )
+ {
+ if( rName.CompareIgnoreCaseToAscii( p->pName ) == COMPARE_EQUAL )
+ {
+ bFound = sal_True; break;
+ }
+ nIndex += ( p->nArgs & _ARGSMASK ) + 1;
+ p = m_pMethods + nIndex;
+ }
+ if( bFound )
+ {
+ // Args-Felder isolieren:
+ short nAccess = ( p->nArgs & _RWMASK ) >> 8;
+ short nType = ( p->nArgs & _TYPEMASK );
+ String aName( p->pName, RTL_TEXTENCODING_ASCII_US );
+ SbxClassType eCT = SbxCLASS_OBJECT;
+ if( nType & _PROPERTY )
+ eCT = SbxCLASS_PROPERTY;
+ else if( nType & _METHOD )
+ eCT = SbxCLASS_METHOD;
+ pRes = Make( aName, eCT, p->eType );
+ // Wir setzen den Array-Index + 1, da ja noch andere
+ // Standard-Properties existieren, die auch aktiviert
+ // werden muessen.
+ pRes->SetUserData( nIndex + 1 );
+ pRes->SetFlags( nAccess );
+ }
+ }
+ return pRes;
+}
+
+// Aktivierung eines Elements oder Anfordern eines Infoblocks
+
+void CommunicationWrapper::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCT,
+ const SfxHint& rHint, const TypeId& rHT )
+{
+ const SbxHint* pHint = PTR_CAST(SbxHint,&rHint);
+ if( pHint )
+ {
+ SbxVariable* pVar = pHint->GetVar();
+ SbxArray* pPar = pVar->GetParameters();
+ sal_uInt16 nIndex = (sal_uInt16) pVar->GetUserData();
+ // kein Index: weiterreichen!
+ if( nIndex )
+ {
+ sal_uLong t = pHint->GetId();
+ if( t == SBX_HINT_INFOWANTED )
+ pVar->SetInfo( GetInfo( (short) pVar->GetUserData() ) );
+ else
+ {
+ sal_Bool bWrite = sal_False;
+ if( t == SBX_HINT_DATACHANGED )
+ bWrite = sal_True;
+ if( t == SBX_HINT_DATAWANTED || bWrite )
+ {
+ // Parameter-Test fuer Methoden:
+ sal_uInt16 nPar = m_pMethods[ --nIndex ].nArgs & 0x00FF;
+ // Element 0 ist der Returnwert
+ if( ( !pPar && nPar )
+ || ( pPar && pPar->Count() != nPar+1 ) )
+ SetError( SbxERR_WRONG_ARGS );
+ // Alles klar, man kann den Call ausfuehren
+ else
+ {
+ (this->*(m_pMethods[ nIndex ].pFunc))( pVar, pPar, bWrite );
+ }
+ }
+ }
+ }
+ SbxObject::SFX_NOTIFY( rBC, rBCT, rHint, rHT );
+ }
+}
+
+// Zusammenbau der Infostruktur fuer einzelne Elemente
+
+SbxInfo* CommunicationWrapper::GetInfo( short nIdx )
+{
+ Methods* p = &m_pMethods[ nIdx ];
+ // Wenn mal eine Hilfedatei zur Verfuegung steht:
+ // SbxInfo* pInfo = new SbxInfo( Hilfedateiname, p->nHelpId );
+ SbxInfo* pRetInfo = new SbxInfo;
+ short nPar = p->nArgs & _ARGSMASK;
+ for( short i = 0; i < nPar; i++ )
+ {
+ p++;
+ String aName( p->pName, RTL_TEXTENCODING_ASCII_US );
+ sal_uInt16 nIFlags = ( p->nArgs >> 8 ) & 0x03;
+ if( p->nArgs & _OPT )
+ nIFlags |= SBX_OPTIONAL;
+ pRetInfo->AddParam( aName, p->eType, nIFlags );
+ }
+ return pRetInfo;
+}
+
+
+////////////////////////////////////////////////////////////////////////////
+
+// Hilfsmethoden für den Manager
+
+IMPL_LINK( CommunicationWrapper, Open, CommunicationLink*, pLink )
+{
+ if ( m_bCatchOpen )
+ m_pNewLink = pLink;
+ else
+ Events( CUniString("Open"), pLink );
+ return 1;
+}
+
+IMPL_LINK( CommunicationWrapper, Close, CommunicationLink*, pLink )
+{
+ Events( CUniString("Close"), pLink );
+ return 1;
+}
+
+IMPL_LINK( CommunicationWrapper, Data, CommunicationLink*, pLink )
+{
+ Events( CUniString("Data"), pLink );
+ return 1;
+}
+
+void CommunicationWrapper::Events( String aType, CommunicationLink* pLink )
+{
+ if ( m_aEventHandlerName.Len() )
+ {
+ SbxArrayRef pPar = new SbxArray( SbxVARIANT );
+ pPar->Put( new SbxVariable( SbxSTRING ), 1 );
+ pPar->Get( 1 )->PutString( aType );
+
+ pPar->Put( new SbxVariable( SbxOBJECT ), 2 );
+ pPar->Get( 2 )->PutObject( new CommunicationWrapper( pLink ) );
+
+ Call( m_aEventHandlerName, pPar );
+ }
+ else
+ delete pLink->GetServiceData(); // Stream wegschmeissen um nicht zu blockieren
+}
+
+
+////////////////////////////////////////////////////////////////////////////
+
+// Properties und Methoden legen beim Get (bPut = sal_False) den Returnwert
+// im Element 0 des Argv ab; beim Put (bPut = sal_True) wird der Wert aus
+// Element 0 gespeichert.
+
+// Die Methoden:
+
+// Manager
+void CommunicationWrapper::MStartCommunication( SbxVariable* pVar, SbxArray* pPar, sal_Bool /*bWrite*/ )
+{ // CommunicationLink StartCommunication( Host, Port )
+ m_bCatchOpen = sal_True;
+ if ( m_pManager->StartCommunication( ByteString( pPar->Get( 1 )->GetString(), RTL_TEXTENCODING_UTF8 ), pPar->Get( 2 )->GetULong() ) )
+ {
+ while ( !m_pNewLink )
+ GetpApp()->Reschedule();
+ m_bCatchOpen = sal_False;
+ CommunicationWrapper *pNewLinkWrapper = new CommunicationWrapper( m_pNewLink );
+ m_pNewLink = NULL;
+ pVar->PutObject( pNewLinkWrapper );
+ }
+
+}
+
+void CommunicationWrapper::MStopAllCommunication( SbxVariable* /*pVar*/, SbxArray* /*pPar*/, sal_Bool /*bWrite*/ )
+{ // StopAllCommunication // Alle Kommunikation wird abgebrochen
+ m_pManager->StopCommunication();
+}
+
+void CommunicationWrapper::MIsCommunicationRunning( SbxVariable* pVar, SbxArray* /*pPar*/, sal_Bool /*bWrite*/ )
+{ // sal_Bool IsCommunicationRunning // Läuft noch irgendwas
+ pVar->PutBool( m_pManager->IsCommunicationRunning() );
+}
+
+void CommunicationWrapper::MGetMyName( SbxVariable* pVar, SbxArray* /*pPar*/, sal_Bool /*bWrite*/ )
+{ // String GetMyName Der eigene Name
+ pVar->PutString( UniString( m_pManager->GetMyName( CM_FQDN ), RTL_TEXTENCODING_UTF8 ) );
+}
+
+void CommunicationWrapper::MIsLinkValid( SbxVariable* pVar, SbxArray* pPar, sal_Bool /*bWrite*/ )
+{ // sal_Bool IsLinkValid( CommunicationLink ) // Ist dieser Link noch gültig
+ CommunicationWrapper *pWrapper = (CommunicationWrapper*)(pPar->Get( 1 )->GetObject());
+ pVar->PutBool( m_pManager->IsLinkValid( pWrapper->GetCommunicationLink() ) );
+}
+
+void CommunicationWrapper::MSetCommunicationEventHandler( SbxVariable* /*pVar*/, SbxArray* pPar, sal_Bool /*bWrite*/ )
+{ // SetCommunicationEventHandler( String ) // Diese Funktion wird aufgerufen bei jedem Event
+ m_aEventHandlerName = pPar->Get( 1 )->GetString();
+}
+
+
+
+
+
+// Link
+void CommunicationWrapper::LStopCommunication( SbxVariable* /*pVar*/, SbxArray* /*pPar*/, sal_Bool /*bWrite*/ )
+{ // StopCommunication Die Kommunikation wird abgebrochen
+ m_pLink->StopCommunication();
+}
+
+void CommunicationWrapper::LGetMyName( SbxVariable* pVar, SbxArray* /*pPar*/, sal_Bool /*bWrite*/ )
+{ // String GetMyName Der eigene Name
+ pVar->PutString( UniString( m_pLink->GetMyName( CM_FQDN ), RTL_TEXTENCODING_UTF8 ) );
+}
+
+void CommunicationWrapper::LGetHostName( SbxVariable* pVar, SbxArray* /*pPar*/, sal_Bool /*bWrite*/ )
+{ // String GetHostName Der Name des Anderen
+ pVar->PutString( UniString( m_pLink->GetCommunicationPartner( CM_FQDN ), RTL_TEXTENCODING_UTF8 ) );
+}
+
+void CommunicationWrapper::LSend( SbxVariable* /*pVar*/, SbxArray* pPar, sal_Bool /*bWrite*/ )
+{ // Send(String ) String an den Partner schicken
+ SvStream *pSendStream = m_pLink->GetBestCommunicationStream();
+ String aSendString = pPar->Get( 1 )->GetString();
+ pSendStream->WriteByteString( aSendString, RTL_TEXTENCODING_UTF8 );
+ m_pLink->TransferDataStream( pSendStream );
+ delete pSendStream;
+}
+
+void CommunicationWrapper::LGetString( SbxVariable* pVar, SbxArray* /*pPar*/, sal_Bool /*bWrite*/ )
+{ // String GetString Ergebnis des letzten Empfangs
+ SvStream *pReceiveStream = m_pLink->GetServiceData();
+ if ( pReceiveStream )
+ {
+ sal_uLong nLength = pReceiveStream->Seek( STREAM_SEEK_TO_END );
+ pReceiveStream->Seek( STREAM_SEEK_TO_BEGIN );
+ char *pBuffer = new char[nLength];
+ pReceiveStream->Read( pBuffer, nLength );
+ String aReceive(
+ pBuffer, sal::static_int_cast< xub_StrLen >( nLength ),
+ RTL_TEXTENCODING_UTF8 );
+ delete [] pBuffer;
+ pVar->PutString( aReceive );
+ delete pReceiveStream;
+ }
+ else
+ pVar->PutString( UniString() );
+}
+
+
+
+// Die Factory legt unser Objekte an.
+
+SbxObject* CommunicationFactory::CreateObject( const String& rClass )
+{
+ if( rClass.CompareIgnoreCaseToAscii( "CommunicationManager" ) == COMPARE_EQUAL )
+ return new CommunicationWrapper( rClass );
+ return NULL;
+}
+
diff --git a/automation/source/testtool/comm_bas.hxx b/automation/source/testtool/comm_bas.hxx
new file mode 100644
index 000000000000..2080354334aa
--- /dev/null
+++ b/automation/source/testtool/comm_bas.hxx
@@ -0,0 +1,120 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _COMM_BAS_HXX
+#define _COMM_BAS_HXX
+
+#include <basic/sbxfac.hxx>
+#ifndef __SBX_SBXVARIABLE_HXX //autogen
+#include <basic/sbxvar.hxx>
+#endif
+#include <basic/sbxobj.hxx>
+
+class CommunicationManagerClientViaSocket;
+class CommunicationLink;
+
+class CommunicationWrapper : public SbxObject // Einer für Manager und Links
+{
+ // Definition eines Tabelleneintrags. Dies wird hier gemacht,
+ // da dadurch die Methoden und Properties als private deklariert
+ // werden koennen.
+#if defined ( ICC ) || defined ( HPUX ) || defined ( C50 ) || defined ( C52 )
+public:
+#endif
+ typedef void( CommunicationWrapper::*pMeth )
+ ( SbxVariable* pThis, SbxArray* pArgs, sal_Bool bWrite );
+#if defined ( ICC ) || defined ( HPUX )
+private:
+#endif
+
+ struct Methods {
+ const char* pName; // Name des Eintrags
+ SbxDataType eType; // Datentyp
+ pMeth pFunc; // Function Pointer
+ short nArgs; // Argumente und Flags
+ };
+ static Methods aManagerMethods[]; // Methodentabelle
+ static Methods aLinkMethods[]; // Methodentabelle
+ Methods *m_pMethods; // Aktuelle Methodentabelle
+
+ // Methoden
+ // Manager
+ void MStartCommunication( SbxVariable* pVar, SbxArray* pPar, sal_Bool bWrite );
+ void MStopAllCommunication( SbxVariable* pVar, SbxArray* pPar, sal_Bool bWrite );
+ void MIsCommunicationRunning( SbxVariable* pVar, SbxArray* pPar, sal_Bool bWrite );
+ void MGetMyName( SbxVariable* pVar, SbxArray* pPar, sal_Bool bWrite );
+ void MIsLinkValid( SbxVariable* pVar, SbxArray* pPar, sal_Bool bWrite );
+ void MSetCommunicationEventHandler( SbxVariable* pVar, SbxArray* pPar, sal_Bool bWrite );
+
+ // Link
+ void LStopCommunication( SbxVariable* pVar, SbxArray* pPar, sal_Bool bWrite );
+ void LGetMyName( SbxVariable* pVar, SbxArray* pPar, sal_Bool bWrite );
+ void LGetHostName( SbxVariable* pVar, SbxArray* pPar, sal_Bool bWrite );
+ void LSend( SbxVariable* pVar, SbxArray* pPar, sal_Bool bWrite );
+ void LGetString( SbxVariable* pVar, SbxArray* pPar, sal_Bool bWrite );
+
+ // Interne Member und Methoden
+ CommunicationManagerClientViaSocket *m_pManager;
+ CommunicationLink *m_pLink;
+ sal_Bool m_bIsManager; // Ist es kein Manager, so ist es ein Link
+
+ // Kram für Manager
+ DECL_LINK( Open, CommunicationLink* );
+ DECL_LINK( Close, CommunicationLink* );
+ DECL_LINK( Data, CommunicationLink* );
+ void Events( String aType, CommunicationLink* pLink );
+ sal_Bool m_bCatchOpen;
+ CommunicationLink *m_pNewLink;
+ String m_aEventHandlerName;
+
+ using SbxVariable::GetInfo;
+ // Infoblock auffuellen
+ SbxInfo* GetInfo( short nIdx );
+
+ // Broadcaster Notification
+ virtual void SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType,
+ const SfxHint& rHint, const TypeId& rHintType );
+public:
+ CommunicationWrapper( const String& );
+ CommunicationWrapper( CommunicationLink *pThisLink );
+ ~CommunicationWrapper();
+ // Suchen eines Elements
+ virtual SbxVariable* Find( const String&, SbxClassType );
+
+ CommunicationLink* GetCommunicationLink() { return m_pLink; }
+};
+
+
+// Die dazugehoerige Factory:
+
+class CommunicationFactory : public SbxFactory
+{
+public:
+ virtual SbxObject* CreateObject( const String& );
+};
+
+#endif
diff --git a/automation/source/testtool/cretstrm.cxx b/automation/source/testtool/cretstrm.cxx
new file mode 100644
index 000000000000..907ce02a4731
--- /dev/null
+++ b/automation/source/testtool/cretstrm.cxx
@@ -0,0 +1,73 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_automation.hxx"
+#ifndef _CRetStream_HXX
+#include "cretstrm.hxx"
+#endif
+#include <tools/debug.hxx>
+#include "rcontrol.hxx"
+#include "svcommstream.hxx"
+
+
+SV_IMPL_REF(SbxBase)
+
+CRetStream::CRetStream(SvStream *pIn)
+{
+ pSammel = pIn;
+ delete pCommStream;
+ pCommStream = new SvCommStream( pSammel );
+}
+
+CRetStream::~CRetStream()
+{
+ delete pCommStream;
+}
+
+void CRetStream::Read ( String &aString )
+{
+ comm_UniChar* pStr;
+ sal_uInt16 nLenInChars;
+ CmdBaseStream::Read( pStr, nLenInChars );
+
+ aString = String( pStr, nLenInChars );
+ delete [] pStr;
+}
+
+void CRetStream::Read( SbxValue &aValue )
+{
+ *pSammel >> nId;
+ if (nId != BinSbxValue)
+ {
+ DBG_ERROR1( "Falscher Typ im Stream: Erwartet SbxValue, gefunden :%hu", nId );
+ }
+ SbxBaseRef xBase = SbxBase::Load( *pSammel );
+ if ( IS_TYPE( SbxValue, xBase ) )
+ aValue = *PTR_CAST( SbxValue, &xBase );
+}
+
diff --git a/automation/source/testtool/cretstrm.hxx b/automation/source/testtool/cretstrm.hxx
new file mode 100644
index 000000000000..7fe1416c681e
--- /dev/null
+++ b/automation/source/testtool/cretstrm.hxx
@@ -0,0 +1,55 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _CRETSTRM_HXX
+#define _CRETSTRM_HXX
+
+#include <tools/stream.hxx>
+#include <basic/sbxvar.hxx>
+
+#include "cmdbasestream.hxx"
+
+class CRetStream : public CmdBaseStream
+{
+ SvStream *pSammel;
+ sal_uInt16 nId;
+
+public:
+ CRetStream( SvStream *pIn );
+ ~CRetStream();
+
+ using CmdBaseStream::Read;
+ void Read ( comm_USHORT &nNr ){CmdBaseStream::Read ( nNr );}
+ void Read ( comm_ULONG &nNr ){CmdBaseStream::Read ( nNr );}
+// void Read ( comm_UniChar* &aString, comm_USHORT &nLenInChars ){CmdBaseStream::Read ( aString, nLenInChars );}
+ virtual void Read ( rtl::OString* &pId ){CmdBaseStream::Read ( pId );}
+ void Read ( comm_BOOL &bBool ){CmdBaseStream::Read ( bBool );}
+// new
+ void Read( String &aString );
+ void Read( SbxValue &aValue );
+};
+
+#endif
diff --git a/automation/source/testtool/filter.pl b/automation/source/testtool/filter.pl
new file mode 100644
index 000000000000..8f45073b0934
--- /dev/null
+++ b/automation/source/testtool/filter.pl
@@ -0,0 +1,125 @@
+#!/usr/bin/perl
+#*************************************************************************
+#*
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#************************************************************************/
+
+$debug = "";
+$ctrue = 1;
+$cfalse = 0;
+# reads a block
+# Parameter: FileHandle
+# list of Regular Expressions which terminate the block.
+# for '#ifdef' block would then be ("^#else\$", "^#endif\$")
+
+sub read_block {
+
+ local($file) = @_;
+ print "reading block '$file' ",scalar(@_),"\n" if $debug;
+ while ( <$file> ) {
+ chop;
+ s/\s*$//; # remove trailing whitespaces
+ s/^\s*//; # remove leading whitespaces
+ print "Input : \"$_\"\n" if $debug;
+ s/\/\/.*//; # Remove line comment
+ s/\/\*.*?\*\///g; # remove comments within one line
+ s/\s+/ /g; # Change all whitespace into a single blank
+ s/ *$//; # Remove whitespace at end
+ s/^# /#/; # Change # <command> to #<command>
+
+
+ @line = split(/ /,$_,3);
+
+ $_ = $line[0];
+ if ( $_ && /^#/ ) { # Line starts with '#' -> preprocessor command
+ print "proccessing line: @line\n" if $debug;
+ if (/#define/)
+ {
+ if ( $line[1] =~ /^$namefilter/ )
+ {
+ $mykey = $line[1];
+ $mykey =~ s/^$namefilter//;
+ $count += 1;
+ print OUT "$mykey ", $line[2], "\n";
+ print OUT2 "\t{ \"$mykey\", ", $line[2] ," },\n";
+ }
+ }
+ }
+ }
+ print "Leaving read_block at the end\n" if $debug;
+}
+
+# Read a file.
+# first parameter ist the filename
+sub read_file {
+
+ local ($filename,$file) = @_;
+ $file++; # String increment
+ local $TempFileName = $basename."/".$filename;
+ print "reading file $TempFileName as $file\n" if $debug;
+ open($file, $TempFileName) || die "error: Could not open file $TempFileName. ";
+
+ &read_block($file); # read data
+ close($file);
+ print "done reading $filename\n" if $debug;
+}
+
+# main starts here
+
+$basename = ".";
+$basename = $ARGV[0] if defined($ARGV[0]);
+
+$filename = "app.hrc";
+$filename = $ARGV[1] if defined($ARGV[1]);
+
+
+$outfilebase = $filename;
+$outfilebase =~ s/\.[^.]+$//; # cut off suffix
+$outfilebase = $ARGV[2] if defined($ARGV[2]);
+
+
+$namefilter = $ARGV[3] if defined($ARGV[3]);
+
+
+print "Generating $outfilebase:\n";
+
+$count = 0;
+
+open(OUT,">$outfilebase");
+open(OUT2,">$outfilebase.hxx");
+print OUT2 "\{\n";
+
+&read_file ($filename,"f00");
+
+print OUT2 "\t{ \"\" ,0 }\n\};\n";
+
+close(OUT);
+close(OUT2);
+
+if ( $count == 0 )
+{
+ die "Error: No Entries Found generating \"$outfilebase.hxx\". Testtool will not work!"
+}
+
diff --git a/automation/source/testtool/httprequest.cxx b/automation/source/testtool/httprequest.cxx
new file mode 100644
index 000000000000..691d803998ae
--- /dev/null
+++ b/automation/source/testtool/httprequest.cxx
@@ -0,0 +1,239 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_automation.hxx"
+
+#include <stdio.h>
+#include "httprequest.hxx"
+#include <vos/socket.hxx>
+#include <tools/debug.hxx>
+
+
+void HttpRequest::Init()
+{
+ nResultId = 0;
+ aHeader.Erase();
+ aContentType.Erase();
+ delete pStream;
+ pStream = NULL;
+}
+
+HttpRequest::HttpRequest()
+: nStatus( HTTP_INIT )
+, nResultId( 0 )
+, pStream( NULL )
+{}
+
+HttpRequest::~HttpRequest()
+{
+ delete pStream;
+ pStream = NULL;
+}
+
+void HttpRequest::SetRequest( ByteString aHost, ByteString aPath, sal_uInt16 nPort )
+{
+ nStatus = HTTP_REQUEST_SET;
+ Init();
+ aRequestHost = aHost;
+ aRequestPath = aPath;
+ nRequestPort = nPort;
+}
+
+void HttpRequest::SetProxy( ByteString aHost, sal_uInt16 nPort )
+{
+ nStatus = HTTP_REQUEST_SET;
+ Init();
+ aProxyHost = aHost;
+ nProxyPort = nPort;
+}
+
+sal_Bool HttpRequest::Execute()
+{
+ nStatus = HTTP_REQUEST_PENDING;
+ Init();
+
+ // Open channel to standard redir host
+ vos::OInetSocketAddr aConnectAddr;
+
+ if ( aProxyHost.Len() )
+ {
+ aConnectAddr.setAddr( rtl::OUString( UniString( aProxyHost, RTL_TEXTENCODING_UTF8 ) ) );
+ aConnectAddr.setPort( nProxyPort );
+ }
+ else
+ {
+ aConnectAddr.setAddr( rtl::OUString( UniString( aRequestHost, RTL_TEXTENCODING_UTF8 ) ) );
+ aConnectAddr.setPort( nRequestPort );
+ }
+
+ TimeValue aTV;
+ aTV.Seconds = 10; // Warte 10 Sekunden
+ aTV.Nanosec = 0;
+
+ pOutSocket = new vos::OConnectorSocket();
+ if ( pOutSocket->connect( aConnectAddr, &aTV ) == vos::ISocketTypes::TResult_Ok )
+ {
+// pOutSocket->setTcpNoDelay( 1 );
+ }
+ else
+ {
+ delete pOutSocket;
+ nStatus = HTTP_REQUEST_ERROR;
+ return sal_False;
+ }
+
+
+ SendString( pOutSocket, "GET " );
+ if ( aProxyHost.Len() )
+ {
+ //GET http://staroffice-doc.germany.sun.com/cgi-bin/htdig/binarycopy.sh?CopyIt=++CopyIt++ HTTP/1.0
+ SendString( pOutSocket, "http://" );
+ SendString( pOutSocket, aRequestHost );
+ SendString( pOutSocket, ":" );
+ SendString( pOutSocket, ByteString::CreateFromInt32( nRequestPort ) );
+ SendString( pOutSocket, aRequestPath );
+ SendString( pOutSocket, " HTTP/1.0\n" );
+
+ SendString( pOutSocket, "Proxy-Connection: Keep-Alive\n" );
+ }
+ else
+ {
+ //GET /cgi-bin/htdig/binarycopy.sh?CopyIt=++CopyIt++ HTTP/1.0
+ SendString( pOutSocket, aRequestPath );
+ SendString( pOutSocket, " HTTP/1.0\n" );
+
+ SendString( pOutSocket, "Connection: Keep-Alive\n" );
+ }
+
+ SendString( pOutSocket, "User-Agent: Mozilla/4.7 [de] (Linux; I)" );
+ SendString( pOutSocket, "Host: " );
+ SendString( pOutSocket, aRequestHost );
+ // Terminate with empty line
+ SendString( pOutSocket, "\n\n" );
+
+
+
+#define BUFFRE_SIZE 0x10000 // 64K Buffer
+ char* pBuffer = new char[ BUFFRE_SIZE ];
+
+ sal_Bool bWasError = ( nStatus != HTTP_REQUEST_PENDING );
+
+ sal_uLong nDataRead;
+ pStream = new SvMemoryStream( 0x10000, 0x10000 );
+ while ( !bWasError )
+ {
+ bWasError |= ( BUFFRE_SIZE != ( nDataRead = pOutSocket->read( pBuffer, BUFFRE_SIZE ) ) );
+
+ pStream->Write( pBuffer, nDataRead );
+ }
+
+ delete [] pBuffer;
+ pOutSocket->shutdown();
+ pOutSocket->close();
+
+ pStream->Seek( 0 );
+
+ ByteString aLine;
+ sal_Bool bInsideHeader = sal_True;
+ while ( bInsideHeader )
+ {
+ pStream->ReadLine( aLine );
+ if ( !aLine.Len() )
+ bInsideHeader = sal_False;
+ else
+ {
+ if ( IsItem( "HTTP/", aLine ) )
+ nResultId = (sal_uInt16)aLine.GetToken( 1, ' ' ).ToInt32();
+ if ( IsItem( "Content-Type:", aLine ) )
+ {
+ aContentType = aLine.Copy( 13 );
+ aContentType.EraseLeadingAndTrailingChars();
+ }
+ aHeader += aLine;
+ aHeader += "\n";
+ }
+ }
+
+ if ( nStatus == HTTP_REQUEST_PENDING )
+ {
+ nStatus = HTTP_REQUEST_DONE;
+ return sal_True;
+ }
+ else
+ {
+ nStatus = HTTP_REQUEST_ERROR;
+ return sal_False;
+ }
+}
+/*
+HTTP/1.1 200 OK
+Date: Tue, 22 Jan 2002 14:16:20 GMT
+Server: Apache/1.3.14 (Unix) (SuSE/Linux) mod_throttle/3.0 mod_layout/1.0 mod_f
+astcgi/2.2.2 mod_jk
+Set-Cookie2: JSESSIONID=ffkpgb7tm1;Version=1;Discard;Path="/bugtracker"
+Set-Cookie: JSESSIONID=ffkpgb7tm1;Path=/bugtracker
+Servlet-Engine: Tomcat Web Server/3.2.1 (JSP 1.1; Servlet 2.2; Java 1.3.0; Linux
+ 2.4.0-4GB i386; java.vendor=Sun Microsystems Inc.)
+Connection: close
+Content-Type: text/xml; charset=ISO-8859-1
+ */
+void HttpRequest::SendString( vos::OStreamSocket* pSocket , ByteString aText )
+{
+ if ( nStatus == HTTP_REQUEST_PENDING )
+ pSocket->write( aText.GetBuffer(), aText.Len() );
+}
+
+sal_Bool HttpRequest::IsItem( ByteString aItem, ByteString aLine )
+{
+ return aItem.Match( aLine ) == STRING_MATCH;
+}
+
+
+void HttpRequest::Abort()
+{
+ if ( pOutSocket )
+ {
+ nStatus = HTTP_REQUEST_ERROR;
+ pOutSocket->shutdown();
+ pOutSocket->close();
+ }
+}
+
+
+
+
+SvMemoryStream* HttpRequest::GetBody()
+{
+ return pStream;
+}
+
+sal_uInt16 HttpRequest::GetStatus()
+{
+ return nStatus;
+}
+
diff --git a/automation/source/testtool/httprequest.hxx b/automation/source/testtool/httprequest.hxx
new file mode 100644
index 000000000000..e9b36a321d82
--- /dev/null
+++ b/automation/source/testtool/httprequest.hxx
@@ -0,0 +1,85 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _HTTPREQUEST_HXX_
+#define _HTTPREQUEST_HXX_
+
+#define HTTP_INIT 0
+#define HTTP_REQUEST_SET 1
+#define HTTP_REQUEST_PENDING 2
+#define HTTP_REQUEST_DONE 3
+#define HTTP_REQUEST_ERROR 4
+
+#include <tools/string.hxx>
+#include <tools/stream.hxx>
+
+namespace vos
+{
+ class OStreamSocket;
+ class OConnectorSocket;
+}
+
+class HttpRequest
+{
+ ByteString aRequestPath;
+ ByteString aRequestHost;
+ sal_uInt16 nRequestPort;
+ ByteString aProxyHost;
+ sal_uInt16 nProxyPort;
+
+ sal_uInt16 nStatus;
+ vos::OConnectorSocket *pOutSocket;
+
+ ByteString aHeader;
+ sal_uInt16 nResultId;
+ ByteString aContentType;
+ SvMemoryStream* pStream;
+
+ void SendString( vos::OStreamSocket* pSocket, ByteString aText );
+ sal_Bool IsItem( ByteString aItem, ByteString aLine );
+ void Init();
+public:
+ HttpRequest();
+ ~HttpRequest();
+
+ void SetRequest( ByteString aHost, ByteString aPath, sal_uInt16 nPort );
+ void SetProxy( ByteString aHost, sal_uInt16 nPort );
+
+ sal_Bool Execute();
+ void Abort();
+
+ ByteString GetHeader() { return aHeader; }
+ SvMemoryStream* GetBody();
+
+ ByteString GetContentType() { return aContentType; }
+ sal_uInt16 GetResultId() { return nResultId; }
+
+ sal_uInt16 GetStatus();
+
+};
+
+#endif
diff --git a/automation/source/testtool/makefile.mk b/automation/source/testtool/makefile.mk
new file mode 100644
index 000000000000..db8464130c1b
--- /dev/null
+++ b/automation/source/testtool/makefile.mk
@@ -0,0 +1,109 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..
+
+PRJNAME=automation
+TARGET=testtool
+
+# --- Settings ------------------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Allgemein ------------------------------------------------------------
+
+OBJFILES = \
+ $(OBJ)$/cmdstrm.obj \
+ $(OBJ)$/cretstrm.obj \
+ $(OBJ)$/objtest.obj \
+ $(OBJ)$/tcommuni.obj \
+ $(OBJ)$/comm_bas.obj \
+ $(OBJ)$/httprequest.obj \
+
+
+EXCEPTIONSFILES= \
+ $(OBJ)$/tcommuni.obj \
+ $(OBJ)$/cmdstrm.obj \
+ $(OBJ)$/objtest.obj
+
+HXXFILES = $(INCCOM)$/keycodes.hxx \
+ $(INCCOM)$/classes.hxx \
+ $(INCCOM)$/r_cmds.hxx \
+ $(INCCOM)$/res_type.hxx
+
+.IF "$(GUI)" == "WNT"
+OBJFILES += $(OBJ)$/sysdir_win.obj
+OBJFILES += $(OBJ)$/registry_win.obj
+.ENDIF
+# --- Targets ------------------------------------------------------------
+
+.INCLUDE : target.mk
+
+
+$(OBJFILES) : $(HXXFILES)
+$(HXXFILES) : $(MISC)$/xfilter.pl
+
+
+$(INCCOM)$/keycodes.hxx : $(SOLARVERSION)$/$(INPATH)$/inc$(UPDMINOREXT)$/vcl$/keycodes.hxx \
+ $(MISC)$/xfilter.pl
+ $(PERL) $(MISC)$/xfilter.pl $(SOLARVERSION)$/$(INPATH)$/inc$(UPDMINOREXT) vcl$/keycodes.hxx $(INCCOM)$/keycodes KEY_
+
+$(INCCOM)$/classes.hxx : ..$/inc$/rcontrol.hxx \
+ $(MISC)$/xfilter.pl
+ $(PERL) $(MISC)$/xfilter.pl ..$/inc rcontrol.hxx $(INCCOM)$/classes M_
+
+$(INCCOM)$/r_cmds.hxx : ..$/inc$/rcontrol.hxx \
+ $(MISC)$/xfilter.pl
+ $(PERL) $(MISC)$/xfilter.pl ..$/inc rcontrol.hxx $(INCCOM)$/r_cmds RC_
+
+$(INCCOM)$/res_type.hxx : $(SOLARVERSION)$/$(INPATH)$/inc$(UPDMINOREXT)$/tools$/wintypes.hxx \
+ $(MISC)$/xfilter.pl
+ $(PERL) $(MISC)$/xfilter.pl $(SOLARVERSION)$/$(INPATH)$/inc$(UPDMINOREXT) tools$/wintypes.hxx $(INCCOM)$/res_type WINDOW_
+
+
+
+$(MISC)$/xfilter.pl : filter.pl
+ tr -d "\015" < filter.pl > $(MISC)$/xfilter.pl
+ chmod 664 $(MISC)$/xfilter.pl
+
+
+
+.IF "$(GUI)"=="UNX"
+INIFILESUFFIX=rc
+BRANDPATH=none
+.ELIF "$(GUI)"=="WNT" || "$(GUI)"=="OS2"
+INIFILESUFFIX=.ini
+BRANDPATH=..
+.END
+
+$(BIN)$/testtool$(INIFILESUFFIX): testtool.ini
+ $(SED) -e s/$(EMQ)!INIFILESUFFIX$(EMQ)!/$(INIFILESUFFIX)/ \
+ -e s/$(EMQ)!BRANDPATH$(EMQ)!/$(BRANDPATH)/ < $< > $@
+
+ALLTAR: \
+ $(BIN)$/testtool$(INIFILESUFFIX)
+
diff --git a/automation/source/testtool/objtest.cxx b/automation/source/testtool/objtest.cxx
new file mode 100644
index 000000000000..43334a915788
--- /dev/null
+++ b/automation/source/testtool/objtest.cxx
@@ -0,0 +1,4366 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_automation.hxx"
+
+/*#include <com/sun/star/devtools/XIServerProxy.hpp>
+#include <com/sun/star/devtools/XInformationClient.hpp>
+using namespace com::sun::star::devtools;
+*/
+#ifdef OS2
+#define INCL_DOS
+//#include <vcl/sysdep.hxx>
+#ifndef _SVPM_H
+#include <svpm.h>
+#endif
+#endif
+
+#include "sysdir_win.hxx"
+#include "registry_win.hxx"
+#include "sttresid.hxx"
+#include <osl/file.hxx>
+#ifndef _MSGBOX_HXX //autogen
+#include <vcl/msgbox.hxx>
+#endif
+#ifndef _SOUND_HXX //autogen
+#include <vcl/sound.hxx>
+#endif
+#include <tools/config.hxx>
+#ifndef _APP_HXX //autogen
+#include <vcl/svapp.hxx>
+#endif
+#include <svtools/stringtransfer.hxx>
+#include <svl/brdcst.hxx>
+//#ifndef _SBXCLASS_HXX //autogen
+#include <basic/sbx.hxx>
+//#endif
+#include <com/sun/star/uno/Any.hxx>
+#ifndef _COM_SUN_STAR_FRAME_XDESKTOP_HXX_
+#include <com/sun/star/frame/XDesktop.hpp>
+#endif
+#include <comphelper/processfactory.hxx>
+#include <com/sun/star/bridge/XBridgeFactory.hpp>
+#include <com/sun/star/connection/XConnector.hpp>
+#include <com/sun/star/connection/XConnection.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/uno/XNamingService.hpp>
+
+#include <cppuhelper/servicefactory.hxx>
+
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::frame;
+using namespace com::sun::star::bridge;
+using namespace com::sun::star::connection;
+using namespace rtl;
+
+
+#include <svtools/svmedit.hxx>
+
+#ifdef UNX
+#include <unistd.h> // readlink
+#include <errno.h>
+#endif
+
+#include <basic/sbuno.hxx>
+
+//#include <basic/basrid.hxx>
+#include <basic/basicrt.hxx>
+#ifndef _BASIC_TTRESHLP_HXX
+#include <basic/ttstrhlp.hxx>
+#endif
+#include "tcommuni.hxx"
+#include "comm_bas.hxx"
+#include <cretstrm.hxx>
+
+#include "objtest.hxx"
+#include "rcontrol.hxx"
+
+#include <basic/testtool.hrc>
+#include <basic/ttmsg.hrc>
+
+#include <basic/mybasic.hxx>
+#include <basic/testtool.hxx>
+#include <basic/sbstar.hxx>
+
+#include <algorithm>
+
+#ifndef SBX_VALUE_DECL_DEFINED
+#define SBX_VALUE_DECL_DEFINED
+SV_DECL_REF(SbxValue)
+#endif
+SV_IMPL_REF(SbxValue)
+
+static CommunicationFactory aComManFac;
+
+#define cMyDelim ' '
+#define P_FEHLERLISTE pFehlerListe
+#define KEEP_SEQUENCES 100 // Keep Names of last 100 Calls
+
+
+ControlDefLoad __READONLY_DATA Controls::arClasses [] =
+#include "classes.hxx"
+CNames *Controls::pClasses = NULL;
+
+ControlDefLoad __READONLY_DATA TestToolObj::arR_Cmds [] =
+#include "r_cmds.hxx"
+CNames *TestToolObj::pRCommands = NULL;
+CErrors *TestToolObj::pFehlerListe = NULL; // Hier werden die Fehler des Testtools gespeichert
+
+
+DBG_NAME( ControlItem )
+DBG_NAME( ControlDef )
+
+ControlItem::ControlItem( const sal_Char *Name, rtl::OString aUIdP )
+{
+DBG_CTOR(ControlItem,0);
+ InitData();
+ pData->Kurzname.AssignAscii( Name );
+ pData->aUId = aUIdP;
+}
+
+ControlItem::ControlItem( const String &Name, rtl::OString aUIdP )
+{
+DBG_CTOR(ControlItem,0);
+ InitData();
+ pData->Kurzname = Name;
+ pData->aUId = aUIdP;
+}
+
+/*ControlItem::ControlItem( const String &Name, const String &URL, const URLType aType )
+{
+DBG_CTOR(ControlItem,0);
+ InitData();
+ pData->Kurzname = Name;
+ pData->aURL = URL;
+ pData->nUId = aType;
+}
+
+ControlItem::ControlItem( const String &Name, const String &URL, const sal_uLong nUId )
+{
+DBG_CTOR(ControlItem,0);
+ InitData();
+ pData->Kurzname = Name;
+ pData->aURL = URL;
+ pData->nUId = nUId;
+}
+
+ControlItem::ControlItem( const char *Name, const String &URL, const sal_uLong nUId )
+{
+DBG_CTOR(ControlItem,0);
+ InitData();
+ pData->Kurzname.AssignAscii( Name );
+ pData->aURL = URL;
+ pData->nUId = nUId;
+} */
+
+
+ControlItem::ControlItem( ControlData *pDataP )
+{
+DBG_CTOR(ControlItem,0);
+ pData = pDataP;
+}
+
+ControlSon::~ControlSon()
+{
+ if (pSons)
+ {
+ delete pSons;
+ pSons = NULL;
+ }
+}
+
+ControlItemSon::ControlItemSon(const String &Name, rtl::OString aUIdP )
+: ControlItem( Name, aUIdP )
+{}
+
+/*ControlItemSon::ControlItemSon(const String &Name, const String &URL, const URLType aType )
+: ControlItem( Name, URL, aType )
+{}
+
+ControlItemSon::ControlItemSon(const String &Name, const String &URL, const sal_uLong nUId )
+: ControlItem( Name, URL, nUId )
+{}
+
+ControlItemSon::ControlItemSon(const char *Name, const String &URL, const sal_uLong nUId )
+: ControlItem( Name, URL, nUId )
+{}*/
+
+
+
+sal_Bool ControlDef::operator < (const ControlItem &rPar)
+{
+ return pData->Kurzname.CompareIgnoreCaseToAscii(rPar.pData->Kurzname) == COMPARE_LESS;
+}
+
+sal_Bool ControlDef::operator == (const ControlItem &rPar)
+{
+ return pData->Kurzname.CompareIgnoreCaseToAscii(rPar.pData->Kurzname) == COMPARE_EQUAL;
+}
+
+void ControlDef::Write( SvStream &aStream )
+{
+ // FIXME: HELPID
+ #if 0
+ if ( pSons )
+ aStream.WriteByteString( String('*').Append( pData->Kurzname ), RTL_TEXTENCODING_UTF8 );
+ else
+ aStream.WriteByteString( pData->Kurzname, RTL_TEXTENCODING_UTF8 );
+ aStream << ((sal_uInt16)pData->aUId.HasNumeric());
+ if ( pData->aUId.HasString() )
+ aStream.WriteByteString( pData->aUId.GetStr(), RTL_TEXTENCODING_UTF8 );
+ else
+ aStream << static_cast<comm_ULONG>(pData->aUId.GetNum()); //GetNum() sal_uLong != comm_ULONG on 64bit
+ if ( pSons )
+ for ( sal_uInt16 i = 0 ; pSons->Count() > i ; i++ )
+ ((ControlDef*)(*pSons)[i])->Write(aStream);
+ #else
+ (void)aStream;
+ #endif
+}
+
+ControlDef::ControlDef(const String &Name, rtl::OString aUIdP )
+: ControlItemSon( Name, aUIdP)
+{
+ DBG_CTOR(ControlDef,0);
+}
+
+/*ControlDef::ControlDef(const String &Name, const String &URL, const URLType aType )
+: ControlItemSon( Name, URL, aType )
+{
+ DBG_CTOR(ControlDef,0);
+} */
+
+ControlDef::ControlDef(const String &aOldName, const String &aNewName, ControlDef *pOriginal, sal_Bool bWithSons )
+: ControlItemSon("", pOriginal->pData->aUId)
+{
+ DBG_CTOR(ControlDef,0);
+ if ( pOriginal->pData->Kurzname == aOldName )
+ pData->Kurzname = aNewName;
+ else
+ pData->Kurzname = pOriginal->pData->Kurzname;
+
+ if ( bWithSons && pOriginal->pSons )
+ {
+ pSons = new CNames();
+ for ( sal_uInt16 i = 0; i < pOriginal->pSons->Count() ; i++)
+ {
+ ControlDef *pNewDef;
+ pNewDef = new ControlDef( aOldName, aNewName, pOriginal->SonGetObject(i) ,sal_True );
+ if (! SonInsert(pNewDef))
+ {
+ DBG_ERROR("Name Doppelt im CopyConstructor. Neuer Name = Controlname!!");
+ delete pNewDef;
+ }
+ }
+
+ }
+ else
+ pSons = NULL;
+}
+
+sal_Bool ControlItemUId::operator < (const ControlItem &rPar)
+{
+ return pData->aUId < rPar.pData->aUId;
+}
+
+sal_Bool ControlItemUId::operator == (const ControlItem &rPar)
+{
+ return pData->aUId == rPar.pData->aUId;
+}
+
+SV_IMPL_OP_PTRARR_SORT( CNames, ControlItem* )
+
+void CRevNames::Insert( String aName, rtl::OString aUId, sal_uLong nSeq )
+{
+ ControlItem *pRN = new ReverseName(aName,aUId,nSeq);
+ sal_uInt16 nPos;
+ if ( Seek_Entry(pRN,&nPos) )
+ DeleteAndDestroy(nPos);
+
+ if ( !CNames::C40_PTR_INSERT( ControlItem, pRN) )
+ {
+ DBG_ERROR("Interner Fehler beim Speichern der Lokalen KurzNamen");
+ delete pRN;
+ }
+
+}
+
+String CRevNames::GetName( rtl::OString aUId )
+{
+ ReverseName *pRN = new ReverseName(UniString(),aUId,0);
+ sal_uInt16 nPos;
+ sal_Bool bSeekOK = Seek_Entry(pRN,&nPos);
+
+ delete pRN;
+ if ( bSeekOK )
+ return GetObject(nPos)->pData->Kurzname;
+ else
+ {
+ // FIXME: HELPID
+ #if 0
+ if ( aUId.Matches( UID_ACTIVE ) )
+ return CUniString("Active");
+ else
+ return GEN_RES_STR1( S_NAME_NOT_THERE, aUId.GetText() );
+ #else
+ return String();
+ #endif
+ }
+}
+
+void CRevNames::Invalidate ( sal_uLong nSeq )
+{
+ sal_uInt16 i;
+ for (i = 0; i < Count() ;)
+ {
+ if (((ReverseName*)GetObject(i))->LastSequence < nSeq)
+ DeleteAndDestroy(i);
+ else
+ i++;
+ }
+}
+
+
+SV_IMPL_PTRARR(CErrors, ErrorEntry*)
+
+
+SbxTransportMethod::SbxTransportMethod( SbxDataType DT )
+: SbxMethod(CUniString("Dummy"),DT)
+{
+ nValue = 0;
+}
+
+
+TestToolObj::TestToolObj( String aName, String aFilePath ) // Interner Aufruf
+: SbxObject( aName )
+, bUseIPC(sal_False)
+, bReturnOK(sal_True)
+, nSequence(KEEP_SEQUENCES)
+, ProgPath()
+, IsBlock(sal_False)
+, SingleCommandBlock(sal_True)
+, m_pControls(NULL)
+, m_pNameKontext(NULL)
+, m_pSIds(NULL)
+, m_pReverseSlots(NULL)
+, m_pReverseControls(NULL)
+, m_pReverseControlsSon(NULL)
+, m_pReverseUIds(NULL)
+, pCommunicationManager(NULL)
+, aDialogHandlerName()
+, nWindowHandlerCallLevel(0)
+, nIdleCount(0)
+{
+ pImpl = new ImplTestToolObj;
+ pImpl->ProgParam = String();
+ pImpl->aFileBase = DirEntry(aFilePath);
+// pImpl->aLogFileBase = DirEntry();
+ pImpl->aHIDDir = DirEntry(aFilePath);
+ pImpl->bIsStart = sal_False;
+ pImpl->pMyBasic = NULL;
+
+ pImpl->aServerTimeout = Time(0,1,00); // 1:00 Minuten fest
+ InitTestToolObj();
+}
+
+TestToolObj::TestToolObj( String aName, MyBasic* pBas ) // Aufruf im Testtool
+: SbxObject( aName )
+, bUseIPC(sal_True)
+, bReturnOK(sal_True)
+, nSequence(KEEP_SEQUENCES)
+, ProgPath()
+, IsBlock(sal_False)
+, SingleCommandBlock(sal_True)
+, m_pControls(NULL)
+, m_pNameKontext(NULL)
+, m_pSIds(NULL)
+, m_pReverseSlots(NULL)
+, m_pReverseControls(NULL)
+, m_pReverseControlsSon(NULL)
+, m_pReverseUIds(NULL)
+, pCommunicationManager(NULL)
+, aDialogHandlerName()
+, nWindowHandlerCallLevel(0)
+, nIdleCount(0)
+{
+ pImpl = new ImplTestToolObj;
+ pImpl->ProgParam = String();
+ pImpl->bIsStart = sal_False;
+ pImpl->pMyBasic = pBas;
+
+ LoadIniFile();
+ InitTestToolObj();
+
+ pCommunicationManager = new CommunicationManagerClientViaSocketTT();
+ pCommunicationManager->SetDataReceivedHdl( LINK( this, TestToolObj, ReturnResultsLink ));
+}
+
+void TestToolObj::LoadIniFile() // Laden der IniEinstellungen, die durch den ConfigDialog ge�ndert werden k�nnen
+{
+#define GETSET(aVar, KeyName, Dafault) \
+ { \
+ ByteString __##aVar##__; \
+ __##aVar##__ = aConf.ReadKey(KeyName); \
+ if ( !__##aVar##__.Len() ) \
+ { \
+ __##aVar##__ = Dafault; \
+ aConf.WriteKey(KeyName, __##aVar##__); \
+ } \
+ aVar = UniString( __##aVar##__, RTL_TEXTENCODING_UTF8 );\
+ }
+
+#define NEWOLD( NewKey, OldKey ) \
+ { \
+ ByteString aValue; \
+ if ( ( (aValue = aConf.ReadKey( OldKey )).Len() ) && !aConf.ReadKey( NewKey ).Len() ) \
+ aConf.WriteKey( NewKey, aValue ); \
+ }
+
+
+ Config aConf(Config::GetConfigName( Config::GetDefDirectory(), CUniString("testtool") ));
+ aConf.SetGroup("Misc");
+ ByteString aCurrentProfile = aConf.ReadKey( "CurrentProfile", "Path" );
+ aConf.SetGroup( aCurrentProfile );
+
+ NEWOLD( "BaseDir", "Basisverzeichnis" )
+ String aFB;
+ GETSET( aFB, "BaseDir", "" );
+ pImpl->aFileBase = DirEntry(aFB);
+
+ // remove old keys
+ if ( aConf.ReadKey("KeyCodes + Classes").Len() != 0 ||
+ aConf.ReadKey("KeyCodes + Classes + Res_Type").Len() != 0 )
+ {
+ aConf.DeleteKey("KeyCodes + Classes + Res_Type");
+ aConf.DeleteKey("KeyCodes + Classes");
+ }
+
+ NEWOLD( "LogBaseDir", "LogBasisverzeichnis" )
+ String aLFB;
+ GETSET( aLFB, "LogBaseDir", ByteString( aFB, RTL_TEXTENCODING_UTF8 ) );
+ pImpl->aLogFileBase = DirEntry(aLFB);
+
+ NEWOLD( "HIDDir", "HIDVerzeichnis" )
+ String aHID;
+ GETSET( aHID, "HIDDir", "" );
+ pImpl->aHIDDir = DirEntry(aHID);
+
+
+ aConf.SetGroup("Misc");
+
+ String aST;
+ GETSET( aST, "ServerTimeout", ByteString::CreateFromInt64(Time(0,0,45).GetTime()) ); // 45 Sekunden Initial
+ pImpl->aServerTimeout = Time(sal_uLong(aST.ToInt64()));
+
+ String aSOSE;
+ aCurrentProfile = aConf.ReadKey( "CurrentProfile", "Misc" );
+ aConf.SetGroup( aCurrentProfile );
+ GETSET( aSOSE, "StopOnSyntaxError", "0" );
+ pImpl->bStopOnSyntaxError = aSOSE.EqualsAscii("1");
+
+
+ aConf.SetGroup("GUI Platform");
+
+ String aGP;
+ ByteString abGP;
+#ifdef WNT
+ abGP.Append( "501" ); // WinXP
+#elif defined SOLARIS && defined SPARC
+ abGP.Append( "01" ); // Solaris SPARC
+#elif defined SCO
+ abGP.Append( "02" ); // SCO UNIX
+#elif defined LINUX && defined INTEL
+ abGP.Append( "03" ); // Linux
+#elif defined AIX
+ abGP.Append( "04" );
+#elif defined SOLARIS && defined INTEL
+ abGP.Append( "05" ); // Solaris x86
+#elif defined HPUX
+ abGP.Append( "07" );
+#elif defined FREEBSD
+ abGP.Append( "08" );
+#elif defined MACOSX
+ abGP.Append( "12" );
+#elif defined LINUX && defined PPC
+ abGP.Append( "13" );
+#elif defined NETBSD
+ abGP.Append( "14" );
+#elif defined LINUX && defined X86_64
+ abGP.Append( "15" ); // Linux x86-64
+#elif defined LINUX && defined SPARC
+ abGP.Append( "16" ); // Linux SPARC
+#elif defined OS2
+ abGP.Append( "17" );
+#elif defined LINUX && defined MIPS
+ abGP.Append( "18" ); // Linux MIPS
+#elif defined LINUX && defined ARM
+ abGP.Append( "19" ); // Linux ARM
+#elif defined LINUX && defined IA64
+ abGP.Append( "20" ); // Linux ia64
+#elif defined LINUX && defined S390
+ abGP.Append( "21" ); // Linux S390
+#elif defined LINUX && defined HPPA
+ abGP.Append( "22" ); // Linux PA-RISC
+#elif defined LINUX && defined AXP
+ abGP.Append( "23" ); // Linux ALPHA
+#else
+#error ("unknown platform. please request an ID for your platform on qa/dev")
+#endif
+ GETSET( aGP, "Current", abGP );
+
+// #i68804# Write default Communication section to testtoolrc/.ini
+// this is not fastest but too keep defaultsettings in one place in the code
+ GetHostConfig();
+ GetTTPortConfig();
+ GetUnoPortConfig();
+}
+
+#define MAKE_TT_KEYWORD( cName, aType, aResultType, nID ) \
+{ \
+ SbxVariableRef pMeth; \
+ pMeth = Make( CUniString(cName), aType, aResultType ); \
+ pMeth->SetUserData( nID ); \
+}
+
+// SetUserData muß irgendwas sein, sonst wird es im Find rausgefiltert!!!
+#define MAKE_USHORT_CONSTANT(cName, nValue) \
+ { \
+ SbxProperty *pVal = new SbxProperty( CUniString( cName) , SbxINTEGER ); \
+ pVal->PutInteger( nValue ) ; \
+ pVal->SetUserData( 32000 ); \
+ Insert( pVal ); \
+ }
+
+#define RTLNAME "@SBRTL" // copied from basic/source/classes/sb.cxx
+
+void TestToolObj::InitTestToolObj()
+{
+ pImpl->nNumBorders = 0; // F�r Profiling mit k�stchen
+
+ pImpl->nMinRemoteCommandDelay = 0;
+ pImpl->nMaxRemoteCommandDelay = 0;
+ pImpl->bDoRemoteCommandDelay = sal_False;
+
+ pImpl->bLnaguageExtensionLoaded= sal_False;
+ pImpl->pTTSfxBroadcaster = NULL;
+
+ pImpl->nErrorCount = 0;
+ pImpl->nWarningCount = 0;
+ pImpl->nQAErrorCount = 0;
+ pImpl->nIncludeFileWarningCount = 0;
+
+ pImpl->xErrorList = new SbxDimArray( SbxSTRING );
+ pImpl->xWarningList = new SbxDimArray( SbxSTRING );
+ pImpl->xQAErrorList = new SbxDimArray( SbxSTRING );
+ pImpl->xIncludeFileWarningList = new SbxDimArray( SbxSTRING );
+
+ pImpl->nTestCaseLineNr = 0;
+
+ pImpl->bEnableQaErrors = sal_True;
+ pImpl->bDebugFindNoErrors = sal_False;
+
+ pImpl->pChildEnv = new Environment;
+
+ if (!pFehlerListe)
+ pFehlerListe = new CErrors; // Vor allem anderen. Wer weiss, wer alles einen Fehler ausl�st.
+
+ In = new CmdStream();
+
+ pShortNames = new CRevNames;
+
+ pImpl->pHttpRequest = NULL;
+
+// overwrite standard "wait" method, cause we can do better than that!!
+// Insert Object into SbiStdObject but change listening.
+ SbxVariable* pRTL = pImpl->pMyBasic->Find( CUniString(RTLNAME), SbxCLASS_DONTCARE );
+ SbxObject* pRTLObject = PTR_CAST( SbxObject, pRTL );
+ if ( pRTLObject )
+ {
+ SbxVariableRef pWait;
+ pWait = pRTLObject->Make( CUniString("Wait"), SbxCLASS_METHOD, SbxNULL );
+ pWait->SetUserData( ID_Wait );
+ // change listener here
+ pRTLObject->EndListening( pWait->GetBroadcaster(), sal_True );
+ StartListening( pWait->GetBroadcaster(), sal_True );
+ }
+ else
+ {
+ DBG_ERROR("Testtool: Could not replace Wait method");
+ }
+
+ MAKE_TT_KEYWORD( "Kontext", SbxCLASS_METHOD, SbxNULL, ID_Kontext );
+ MAKE_TT_KEYWORD( "GetNextError", SbxCLASS_VARIABLE, SbxVARIANT, ID_GetError );
+ MAKE_TT_KEYWORD( "Start", SbxCLASS_METHOD, SbxSTRING, ID_Start );
+// pMeth = Make( "Kill", SbxCLASS_METHOD, SbxNULL );
+// pMeth->SetUserData( ID_Kill );
+ /* pMeth = Make( "TestReset", SbxCLASS_METHOD, SbxNULL );
+ pMeth->SetUserData( ID_Reset );*/
+ MAKE_TT_KEYWORD( "Use", SbxCLASS_METHOD, SbxNULL, ID_Use );
+ MAKE_TT_KEYWORD( "StartUse", SbxCLASS_METHOD, SbxNULL, ID_StartUse );
+ MAKE_TT_KEYWORD( "FinishUse", SbxCLASS_METHOD, SbxNULL, ID_FinishUse );
+
+ MAKE_TT_KEYWORD( "CaseLog", SbxCLASS_METHOD, SbxNULL, ID_CaseLog );
+ MAKE_TT_KEYWORD( "ExceptLog", SbxCLASS_METHOD, SbxNULL, ID_ExceptLog );
+ MAKE_TT_KEYWORD( "PrintLog", SbxCLASS_METHOD, SbxNULL, ID_PrintLog );
+ MAKE_TT_KEYWORD( "WarnLog", SbxCLASS_METHOD, SbxNULL, ID_WarnLog );
+ MAKE_TT_KEYWORD( "ErrorLog", SbxCLASS_METHOD, SbxNULL, ID_ErrorLog );
+ MAKE_TT_KEYWORD( "QAErrorLog", SbxCLASS_METHOD, SbxNULL, ID_QAErrorLog );
+ MAKE_TT_KEYWORD( "EnableQaErrors", SbxCLASS_PROPERTY, SbxBOOL, ID_EnableQaErrors );
+ MAKE_TT_KEYWORD( "MaybeAddErr", SbxCLASS_METHOD, SbxNULL, ID_MaybeAddErr );
+ MAKE_TT_KEYWORD( "ClearError", SbxCLASS_METHOD, SbxNULL, ID_ClearError );
+ MAKE_TT_KEYWORD( "SaveIDs", SbxCLASS_METHOD, SbxBOOL, ID_SaveIDs );
+ MAKE_TT_KEYWORD( "AutoExecute", SbxCLASS_PROPERTY, SbxBOOL, ID_AutoExecute ); // Achtung! PROPERTY Also eine Variable
+ MAKE_TT_KEYWORD( "Execute", SbxCLASS_METHOD, SbxNULL, ID_Execute );
+ MAKE_TT_KEYWORD( "StopOnSyntaxError", SbxCLASS_PROPERTY, SbxBOOL, ID_StopOnSyntaxError );
+
+/* Dialog Handler werden gebraucht, wenn im internen Testtool ein Dialog
+ hochgerissen wird. Nach versenden der Remote-Kommandos wird IdleHandler aktiviert.
+ Er testet, ob das Reschedule zum WaitForAnswer zur�ckkehrt. Bleibt das aus, so
+ wird erst der RemoteHandler zur�ckgesetzt und dann die Handler-Sub im Basic
+ gerufen.(Entkoppelt �ber PostUserEvent.)
+
+ In returndaten_verarbeiten wird flag f�r ausf�hrung des n�chsten remote-befehls
+ r�ckgesetzt. Der Handler wird damit auch entwertet. Er gilt also nur f�r den
+ n�chsten Remotebefehl.
+*/
+ MAKE_TT_KEYWORD( "DialogHandler", SbxCLASS_METHOD, SbxNULL, ID_DialogHandler );
+
+ MAKE_TT_KEYWORD( "GetUnoApp", SbxCLASS_METHOD, SbxOBJECT, ID_GetUnoApp );
+ MAKE_TT_KEYWORD( "GetIServer", SbxCLASS_METHOD, SbxOBJECT, ID_GetIServer );
+
+ MAKE_TT_KEYWORD( "RemoteCommandDelay", SbxCLASS_METHOD, SbxNULL, ID_RemoteCommandDelay );
+
+ MAKE_TT_KEYWORD( "GetApplicationPath", SbxCLASS_METHOD, SbxSTRING, ID_GetApplicationPath );
+ MAKE_TT_KEYWORD( "GetCommonApplicationPath", SbxCLASS_METHOD, SbxSTRING, ID_GetCommonApplicationPath );
+ MAKE_TT_KEYWORD( "MakeIniFileName", SbxCLASS_METHOD, SbxSTRING, ID_MakeIniFileName );
+
+/// active constants returning error and warning count
+ MAKE_TT_KEYWORD( "GetErrorCount", SbxCLASS_METHOD, SbxULONG, ID_GetErrorCount );
+ MAKE_TT_KEYWORD( "GetWarningCount", SbxCLASS_METHOD, SbxULONG, ID_GetWarningCount );
+ MAKE_TT_KEYWORD( "GetQAErrorCount", SbxCLASS_METHOD, SbxULONG, ID_GetQAErrorCount );
+ MAKE_TT_KEYWORD( "GetUseFileWarningCount", SbxCLASS_METHOD, SbxULONG, ID_GetUseFileWarningCount );
+
+ MAKE_TT_KEYWORD( "GetErrorList", SbxCLASS_METHOD, SbxOBJECT, ID_GetErrorList );
+ MAKE_TT_KEYWORD( "GetWarningList", SbxCLASS_METHOD, SbxOBJECT, ID_GetWarningList );
+ MAKE_TT_KEYWORD( "GetQAErrorList", SbxCLASS_METHOD, SbxOBJECT, ID_GetQAErrorList );
+ MAKE_TT_KEYWORD( "GetUseFileWarningList", SbxCLASS_METHOD, SbxOBJECT, ID_GetUseFileWarningList );
+
+ MAKE_TT_KEYWORD( "GetTestCaseName", SbxCLASS_METHOD, SbxSTRING, ID_GetTestCaseName );
+ MAKE_TT_KEYWORD( "GetTestCaseFileName", SbxCLASS_METHOD, SbxSTRING, ID_GetTestCaseFileName );
+ MAKE_TT_KEYWORD( "GetTestCaseLineNr", SbxCLASS_METHOD, SbxUSHORT, ID_GetTestCaseLineNr );
+
+ MAKE_TT_KEYWORD( "SetChildEnv", SbxCLASS_METHOD, SbxNULL, ID_SetChildEnv );
+ MAKE_TT_KEYWORD( "GetChildEnv", SbxCLASS_METHOD, SbxSTRING, ID_GetChildEnv );
+
+ MAKE_TT_KEYWORD( "GetLinkDestination", SbxCLASS_METHOD, SbxSTRING, ID_GetLinkDestination );
+ MAKE_TT_KEYWORD( "GetRegistryValue", SbxCLASS_METHOD, SbxSTRING, ID_GetRegistryValue );
+
+ MAKE_TT_KEYWORD( "KillApp", SbxCLASS_METHOD, SbxNULL, ID_KillApp );
+
+ MAKE_TT_KEYWORD( "HTTPSend", SbxCLASS_METHOD, SbxUSHORT, ID_HTTPSend );
+ MAKE_TT_KEYWORD( "HTTPSetProxy", SbxCLASS_METHOD, SbxNULL, ID_HTTPSetProxy );
+
+ // Load the Remote Commands from list
+ if ( !pRCommands ) // Ist static, wird also nur einmal geladen
+ ReadFlatArray( arR_Cmds, pRCommands );
+ sal_uInt16 i;
+ for ( i = 0 ; i < pRCommands->Count() ; i++ )
+ {
+ SbxTransportMethod *pMeth = new SbxTransportMethod( SbxVARIANT );
+ pMeth->SetName( pRCommands->GetObject( i )->pData->Kurzname );
+ pMeth->SetUserData( ID_RemoteCommand );
+ // FIXME: HELPID
+ #if 0
+ pMeth->nValue = pRCommands->GetObject( i )->pData->aUId.GetNum();
+ #else
+ pMeth->nValue = 0;
+ #endif
+ Insert( pMeth );
+ StartListening( pMeth->GetBroadcaster(), sal_True );
+ }
+
+// Konstanten f�r SetControlType
+ MAKE_USHORT_CONSTANT("CTBrowseBox",CONST_CTBrowseBox);
+ MAKE_USHORT_CONSTANT("CTValueSet",CONST_CTValueSet);
+
+// Konstanten f�r das Alignment des gesuchten Splitters
+ MAKE_USHORT_CONSTANT("AlignLeft",CONST_ALIGN_LEFT);
+ MAKE_USHORT_CONSTANT("AlignTop",CONST_ALIGN_TOP);
+ MAKE_USHORT_CONSTANT("AlignRight",CONST_ALIGN_RIGHT);
+ MAKE_USHORT_CONSTANT("AlignBottom",CONST_ALIGN_BOTTOM);
+
+/// What dialog to use in RC_CloseSysDialog or RC_ExistsSysDialog
+ MAKE_USHORT_CONSTANT("FilePicker",CONST_FilePicker);
+ MAKE_USHORT_CONSTANT("FolderPicker",CONST_FolderPicker);
+
+/// NodeTypes of the SAX Parser
+ MAKE_USHORT_CONSTANT("NodeTypeCharacter",CONST_NodeTypeCharacter);
+ MAKE_USHORT_CONSTANT("NodeTypeElement",CONST_NodeTypeElement);
+ MAKE_USHORT_CONSTANT("NodeTypeComment",CONST_NodeTypeComment);
+
+
+/// ItemTypes for TreeListBox and maybe others
+ MAKE_USHORT_CONSTANT("ItemTypeText",CONST_ItemTypeText);
+ MAKE_USHORT_CONSTANT("ItemTypeBMP",CONST_ItemTypeBMP);
+ MAKE_USHORT_CONSTANT("ItemTypeCheckbox",CONST_ItemTypeCheckbox);
+ MAKE_USHORT_CONSTANT("ItemTypeContextBMP",CONST_ItemTypeContextBMP);
+ MAKE_USHORT_CONSTANT("ItemTypeUnknown",CONST_ItemTypeUnknown);
+
+
+/// Return values for WaitSlot
+ MAKE_USHORT_CONSTANT("WSTimeout",CONST_WSTimeout);
+ MAKE_USHORT_CONSTANT("WSAborted",CONST_WSAborted);
+ MAKE_USHORT_CONSTANT("WSFinished",CONST_WSFinished);
+
+
+ pImpl->pControlsObj = new Controls( CUniString("GetNextCloseWindow") );
+ pImpl->pControlsObj->SetType( SbxVARIANT );
+ Insert( pImpl->pControlsObj );
+ pImpl->pControlsObj->SetUserData( ID_GetNextCloseWindow );
+ pImpl->pControlsObj->ChangeListener( this );
+
+ for ( i=0;i<VAR_POOL_SIZE;i++)
+ {
+/* pMyVar = new SbxObject( "Dummy" );
+ pMyVar->SetType( SbxVARIANT );*/
+
+// pMyVar = new SbxMethod( "Dummy", SbxVARIANT );
+
+ pImpl->pMyVars[i] = new SbxTransportMethod( SbxVARIANT );
+ pImpl->pMyVars[i]->SetName( CUniString("VarDummy").Append(String::CreateFromInt32(i) ) );
+
+ Insert( pImpl->pMyVars[i] );
+// StartListening( pMyVars[i]->GetBroadcaster(), sal_True );
+
+ }
+
+ m_pControls = new CNames();
+ m_pSIds = new CNames();
+ m_pNameKontext = m_pControls;
+
+ nMyVar = 0;
+
+ pImpl->pMyBasic->AddFactory( &aComManFac );
+
+
+// Das ist zum testen des IPC
+
+/* int sent = 0;
+
+ ModelessDialog *pDlg = new ModelessDialog(NULL);
+ pDlg->SetOutputSizePixel(Size(100,30));
+
+ Edit *pMyEd = new Edit(pDlg,WB_CENTER | WB_BORDER);
+ pMyEd->SetSizePixel(Size(100,30));
+ pDlg->Show();
+ pMyEd->Show();
+ Time aTime;
+
+ String VollePackung;
+ VollePackung.Fill(32760,'*');
+
+ BeginBlock(); // zum warm werden
+ EndBlock();
+ ResetError();
+
+ while ( pDlg->IsVisible() && !IsError() )
+ {
+ BeginBlock();
+ In->GenCmdFlow (124,VollePackung);
+ EndBlock();
+ pMyEd->SetText(String("Test Nr. ") + String(++sent));
+ while ( aTime.Get100Sec() / 10 == Time().Get100Sec() / 10 );
+ aTime = Time();
+ }
+
+ delete pMyEd;
+ delete pDlg;
+*/
+// Test ende
+
+
+}
+
+TestToolObj::~TestToolObj()
+{
+ pImpl->pMyBasic->RemoveFactory( &aComManFac );
+ EndListening( ((StarBASIC*)GetParent())->GetBroadcaster() );
+ pImpl->pNextReturn.Clear();
+
+ pImpl->pControlsObj.Clear();
+
+ for ( int i = 0 ; i < VAR_POOL_SIZE ; i++ )
+ {
+ pImpl->pMyVars[i].Clear();
+ }
+
+ if (m_pControls)
+ delete m_pControls;
+ if (m_pReverseSlots)
+ delete m_pReverseSlots;
+ if (m_pReverseControls)
+ delete m_pReverseControls;
+ if (m_pReverseControlsSon)
+ delete m_pReverseControlsSon;
+ if (m_pReverseUIds)
+ delete m_pReverseUIds;
+ if (m_pSIds)
+ delete m_pSIds;
+ if (pFehlerListe)
+ {
+ delete pFehlerListe;
+ pFehlerListe = NULL; // da pFehlerListe static ist!!
+ }
+ if ( pCommunicationManager )
+ {
+ pCommunicationManager->StopCommunication();
+ delete pCommunicationManager;
+ }
+ delete In;
+ if ( pImpl->pTTSfxBroadcaster )
+ delete pImpl->pTTSfxBroadcaster;
+ delete pImpl->pChildEnv;
+
+ pImpl->xErrorList.Clear();
+ pImpl->xWarningList.Clear();
+ pImpl->xQAErrorList.Clear();
+ pImpl->xIncludeFileWarningList.Clear();
+
+ delete pImpl;
+
+ delete pShortNames;
+}
+
+SfxBroadcaster& TestToolObj::GetTTBroadcaster()
+{
+ if ( !pImpl->pTTSfxBroadcaster )
+ pImpl->pTTSfxBroadcaster = new SfxBroadcaster;
+ return *pImpl->pTTSfxBroadcaster;
+}
+
+void TestToolObj::ReadNames( String Filename, CNames *&pNames, CNames *&pUIds, sal_Bool bIsFlat )
+{
+/*******************************************************************************
+**
+** Folgende Dateiendungen sind vorhanden
+**
+** hid.lst Langname UId
+** *.sid Slot Ids Kurzname Langname Datei ist flach
+** *.win Controlname Langname Datei mit *name und +name Notation
+**
+**
+*******************************************************************************/
+
+
+ SvFileStream Stream;
+ String aLine,aShortname,aLongname;
+ rtl::OString aUId;
+ xub_StrLen nLineNr;
+ sal_uInt16 nElement;
+ ControlDef *pNewDef, *pNewDef2;
+ ControlDef *pFatherDef = NULL;
+
+ nLineNr = 0; // Wir sind ja noch vor der Datei
+
+ if (! pUIds)
+ {
+ String aFileName = (pImpl->aHIDDir + DirEntry(CUniString("hid.lst"))).GetFull();
+ {
+ TTExecutionStatusHint aHint( TT_EXECUTION_SHOW_ACTION, String(SttResId(S_READING_LONGNAMES)), aFileName );
+ GetTTBroadcaster().Broadcast( aHint );
+ }
+ ReadFlat( aFileName ,pUIds, sal_True );
+ if ( !pUIds )
+ return;
+ pNewDef = new ControlDef("Active",rtl::OString());
+ const ControlItem *pItem = pNewDef;
+ if (! pUIds->Insert(pItem))
+ {
+ ADD_WARNING_LOG2( GEN_RES_STR1c( S_DOUBLE_NAME, "Active" ), Filename, nLineNr );
+ delete pNewDef;
+ }
+
+ }
+
+ ADD_MESSAGE_LOG( Filename );
+
+ Stream.Open(Filename, STREAM_STD_READ);
+ if (!Stream.IsOpen())
+ {
+ ADD_ERROR(ERR_NO_FILE,GEN_RES_STR1(S_CANNOT_OPEN_FILE, Filename));
+ return;
+ }
+
+ if ( bIsFlat && !pNames )
+ {
+ TTExecutionStatusHint aHint( TT_EXECUTION_SHOW_ACTION, String(SttResId(S_READING_SLOT_IDS)), Filename );
+ GetTTBroadcaster().Broadcast( aHint );
+ }
+ else
+ {
+ TTExecutionStatusHint aHint( TT_EXECUTION_SHOW_ACTION, String(SttResId(S_READING_CONTROLS)), Filename );
+ GetTTBroadcaster().Broadcast( aHint );
+ }
+
+ if ( !pNames )
+ pNames = new CNames();
+
+ {
+ TTExecutionStatusHint aHint( TT_EXECUTION_ENTERWAIT );
+ GetTTBroadcaster().Broadcast( aHint );
+ }
+ while (!Stream.IsEof())
+ {
+ nLineNr++;
+
+ Stream.ReadByteStringLine(aLine, RTL_TEXTENCODING_IBM_850);
+ aLine.EraseLeadingChars();
+ aLine.EraseTrailingChars();
+ while ( aLine.SearchAscii(" ") != STRING_NOTFOUND )
+ aLine.SearchAndReplaceAllAscii(" ",UniString(' '));
+ if (aLine.Len() == 0) continue;
+ if (aLine.Copy(0,4).CompareIgnoreCaseToAscii("Rem ") == COMPARE_EQUAL) continue;
+ if (aLine.Copy(0,1).CompareToAscii("'") == COMPARE_EQUAL) continue;
+
+ if ( (aLine.GetTokenCount(cMyDelim) < 2 || aLine.GetTokenCount(cMyDelim) > 3) && aLine.CompareIgnoreCaseToAscii("*Active") != COMPARE_EQUAL )
+ {
+ ADD_WARNING_LOG2( GEN_RES_STR1( S_INVALID_LINE, aLine ), Filename, nLineNr );
+ continue;
+ }
+
+ aShortname = aLine.GetToken(0,cMyDelim);
+ aLongname = aLine.GetToken(1,cMyDelim);
+
+ String aFirstAllowedExtra, aAllowed;
+ aFirstAllowedExtra.AssignAscii("+*");
+ aAllowed.AssignAscii("_");
+ xub_StrLen nIndex = 0;
+ sal_Bool bOK = sal_True;
+
+ while ( bOK && nIndex < aShortname.Len() )
+ {
+ sal_Unicode aChar = aShortname.GetChar( nIndex );
+ sal_Bool bOKThis = sal_False;
+ bOKThis |= ( aAllowed.Search( aChar ) != STRING_NOTFOUND );
+ if ( !nIndex )
+ bOKThis |= ( aFirstAllowedExtra.Search( aChar ) != STRING_NOTFOUND );
+ bOKThis |= ( aChar >= 'A' && aChar <= 'Z' );
+ bOKThis |= ( aChar >= 'a' && aChar <= 'z' );
+ bOKThis |= ( aChar >= '0' && aChar <= '9' );
+
+ bOK &= bOKThis;
+ nIndex++;
+ }
+ if ( !bOK )
+ {
+ ADD_WARNING_LOG2( CUniString("Zeile \"").Append(aLine).AppendAscii("\" enth�lt ung�ltige Zeichen."), Filename, nLineNr );
+ continue;
+ }
+
+ sal_Bool bUnoName = ( aLongname.Copy( 0, 5 ).EqualsIgnoreCaseAscii( ".uno:" )
+ || aLongname.Copy( 0, 4 ).EqualsIgnoreCaseAscii( "http" )
+ || aLongname.Copy( 0, 15 ).EqualsIgnoreCaseAscii( "private:factory" )
+ || aLongname.Copy( 0, 8 ).EqualsIgnoreCaseAscii( "service:" )
+ || aLongname.Copy( 0, 6 ).EqualsIgnoreCaseAscii( "macro:" )
+ || aLongname.Copy( 0, 8 ).EqualsIgnoreCaseAscii( ".HelpId:" ) );
+ // generic method to mark longnames as symbolic
+ if ( aLongname.Copy( 0, 4 ).EqualsIgnoreCaseAscii( "sym:" ) )
+ {
+ bUnoName = sal_True;
+ aLongname.Erase( 0, 4 );
+ }
+ sal_Bool bMozillaName = ( !bIsFlat && aLongname.Copy( 0, 4 ).EqualsIgnoreCaseAscii( ".moz" ) );
+
+ if ( aShortname.GetChar(0) == '+' ) // Kompletten Eintrag kopieren
+ {
+ aShortname.Erase(0,1);
+ ControlDef WhatName(aLongname,rtl::OString());
+ ControlDef *OldTree;
+ if (pNames->Seek_Entry(&WhatName,&nElement))
+ {
+ OldTree = (ControlDef*)pNames->GetObject(nElement);
+ pNewDef = new ControlDef(aLongname,aShortname,OldTree,sal_True);
+
+ const ControlItem *pItem = pNewDef;
+ if (! pNames->Insert(pItem))
+ {
+ ADD_WARNING_LOG2( GEN_RES_STR1( S_DOUBLE_NAME, aLine ), Filename, nLineNr );
+ delete pNewDef;
+ pFatherDef = NULL;
+ }
+ else
+ {
+ pFatherDef = pNewDef;
+ }
+ }
+ else
+ {
+ ADD_WARNING_LOG2( GEN_RES_STR1( S_SHORTNAME_UNKNOWN, aLine ), Filename, nLineNr );
+ continue;
+ }
+
+ }
+ else
+ {
+
+ // FIXME: HELPID
+ #if 0
+ if (aShortname.CompareIgnoreCaseToAscii("*Active") == COMPARE_EQUAL)
+ aUId = rtl::OString( UID_ACTIVE );
+ else
+ #endif
+ if ( !bUnoName && !bMozillaName )
+ { // Bestimmen der ID aus der Hid.Lst
+ ControlDef WhatName(aLongname,rtl::OString());
+ if (pUIds->Seek_Entry(&WhatName,&nElement))
+ aUId = pUIds->GetObject(nElement)->pData->aUId;
+ else
+ {
+ ADD_WARNING_LOG2( GEN_RES_STR1( S_LONGNAME_UNKNOWN, aLine ), Filename, nLineNr );
+ continue;
+ }
+ }
+ else
+ {
+ // FIXME: HELPID
+ #if 0
+ if ( bUnoName )
+ aUId = rtl::OString( aLongname );
+ else if ( bMozillaName )
+ aUId = rtl::OString( aLongname );
+ else
+ {
+ DBG_ERROR("Unknown URL schema");
+ }
+ #endif
+ }
+
+
+
+ if (aShortname.GetChar(0) == '*' || bIsFlat) // Globaler Kurzname (Dialogname oder SId)
+ {
+ if (!bIsFlat)
+ aShortname.Erase(0,1);
+
+ pNewDef = new ControlDef(aShortname,aUId);
+
+ if (!bIsFlat)
+ {
+ pNewDef->Sons( new CNames() );
+
+ pNewDef2 = new ControlDef(aShortname,aUId);
+ if (!pNewDef->SonInsert( pNewDef2 )) // Dialog in eigenen Namespace eintragen
+ {
+ delete pNewDef2;
+ DBG_ERROR(" !!!! ACHTUNG !!!! Fehler beim einf�gen in leere Liste!");
+ }
+ }
+
+ const ControlItem *pItem = pNewDef;
+ if (! pNames->Insert(pItem))
+ {
+ ADD_WARNING_LOG2( GEN_RES_STR1( S_DOUBLE_NAME, aLine ), Filename, nLineNr );
+ delete pNewDef;
+ pFatherDef = NULL;
+ }
+ else
+ {
+ pFatherDef = pNewDef;
+ }
+ }
+ else
+ {
+ if (!pFatherDef)
+ {
+ ADD_WARNING_LOG2( GEN_RES_STR0( S_FIRST_SHORTNAME_REQ_ASTRX ), Filename, nLineNr );
+ }
+ else
+ {
+ pNewDef = new ControlDef(aShortname,aUId);
+ if (! pFatherDef->SonInsert(pNewDef))
+ {
+ ADD_WARNING_LOG2( GEN_RES_STR1( S_DOUBLE_NAME, aLine ), Filename, nLineNr );
+ delete pNewDef;
+ }
+ }
+ }
+ }
+ GetpApp()->Reschedule();
+ }
+ {
+ TTExecutionStatusHint aHint( TT_EXECUTION_LEAVEWAIT );
+ GetTTBroadcaster().Broadcast( aHint );
+ }
+ {
+ TTExecutionStatusHint aHint( TT_EXECUTION_HIDE_ACTION );
+ GetTTBroadcaster().Broadcast( aHint );
+ }
+
+ Stream.Close();
+}
+
+
+void TestToolObj::AddName(String &aBisher, String &aNeu )
+{
+ String aSl( '/' );
+ if ( UniString(aSl).Append(aBisher).Append(aSl).ToUpperAscii().Search( UniString(aSl).Append(aNeu).Append(aSl).ToUpperAscii() ) == STRING_NOTFOUND )
+ {
+ aBisher += aSl;
+ aBisher += aNeu;
+ }
+}
+
+
+void TestToolObj::ReadFlat( String Filename, CNames *&pNames, sal_Bool bSortByName )
+// Wenn bSortByName == sal_False, dann nach UId Sortieren (ControlItemUId statt ControlDef)
+{
+ SvFileStream Stream;
+ String aLine,aLongname;
+ rtl::OString aUId;
+ xub_StrLen nLineNr;
+ ControlItem *pNewItem;
+ sal_uInt16 nDoubleCount = 0;
+
+ Stream.Open(Filename, STREAM_STD_READ);
+
+ if (!Stream.IsOpen())
+ {
+ ADD_ERROR(ERR_NO_FILE,GEN_RES_STR1(S_CANNOT_OPEN_FILE, Filename));
+ return;
+ }
+
+ nLineNr = 0; // Wir sind ja noch vor der Datei
+
+ if ( !pNames )
+ pNames = new CNames();
+
+ {
+ TTExecutionStatusHint aHint( TT_EXECUTION_ENTERWAIT );
+ GetTTBroadcaster().Broadcast( aHint );
+ }
+ ADD_MESSAGE_LOG( Filename );
+ while (!Stream.IsEof())
+ {
+ nLineNr++;
+
+ Stream.ReadByteStringLine(aLine, RTL_TEXTENCODING_IBM_850);
+ aLine.EraseLeadingChars();
+ aLine.EraseTrailingChars();
+ while ( aLine.SearchAscii(" ") != STRING_NOTFOUND )
+ aLine.SearchAndReplaceAllAscii(" ",UniString(' '));
+ if (aLine.Len() == 0) continue;
+
+ if ( (aLine.GetTokenCount(cMyDelim) < 2 || aLine.GetTokenCount(cMyDelim) > 3) && aLine.CompareIgnoreCaseToAscii("*Active") != COMPARE_EQUAL )
+ {
+ ADD_WARNING_LOG2( GEN_RES_STR1( S_INVALID_LINE, aLine ), Filename, nLineNr );
+ continue;
+ }
+
+ aLongname = aLine.GetToken(0,cMyDelim);
+ // FIXME: HELPID
+ aUId = rtl::OUStringToOString( aLine.GetToken(1,cMyDelim), RTL_TEXTENCODING_UTF8 );
+
+ if ( bSortByName )
+ pNewItem = new ControlDef( aLongname, aUId );
+ else
+ pNewItem = new ControlItemUId( aLongname, aUId );
+ if ( !pNames->C40_PTR_INSERT( ControlItem, pNewItem ) )
+ {
+ if ( bSortByName )
+ {
+ if ( nDoubleCount++ < 10 )
+ {
+ ADD_WARNING_LOG2( GEN_RES_STR1( S_DOUBLE_NAME, aLine ), Filename, nLineNr );
+ }
+ }
+ else
+ {
+ sal_uInt16 nNr;
+ pNames->Seek_Entry( pNewItem, &nNr );
+ AddName( pNames->GetObject(nNr)->pData->Kurzname, pNewItem->pData->Kurzname );
+ }
+ delete pNewItem;
+ }
+ GetpApp()->Reschedule();
+ }
+ {
+ TTExecutionStatusHint aHint( TT_EXECUTION_LEAVEWAIT );
+ GetTTBroadcaster().Broadcast( aHint );
+ }
+
+ Stream.Close();
+#ifdef DBG_UTIL
+// int i;
+// for ( i = 0 ; i < pNames->Count() ; i++ )
+// {
+// DBG_ERROR( pNames->GetObject(i)->pData->Kurzname );
+// }
+#endif
+}
+
+void ReadFlatArray( const ControlDefLoad arWas [], CNames *&pNames )
+{
+ sal_uInt16 nIndex = 0;
+
+ if ( !pNames )
+ pNames = new CNames();
+
+ while ( String::CreateFromAscii(arWas[nIndex].Kurzname).Len() > 0 )
+ {
+ // FIXME: HELPID
+ rtl::OString aUId;// (arWas[nIndex].nUId);
+ const ControlItem *pX = new ControlDef( arWas[nIndex].Kurzname, aUId);
+ pNames->C40_PTR_INSERT(ControlItem, pX);
+ nIndex++;
+ }
+}
+
+void TestToolObj::WaitForAnswer ()
+{
+ if ( bUseIPC )
+ {
+ #ifdef DBG_UTILx
+ sal_uInt16 nSysWinModeMemo = GetpApp()->GetSystemWindowMode();
+ GetpApp()->SetSystemWindowMode( 0 );
+ ModelessDialog aDlg(NULL);
+ aDlg.SetOutputSizePixel(Size(200,0));
+ aDlg.SetText(CUniString("Waiting for Answer"));
+ aDlg.Show( sal_True, SHOW_NOFOCUSCHANGE | SHOW_NOACTIVATE );
+ GetpApp()->SetSystemWindowMode( nSysWinModeMemo );
+ #endif
+ sal_Bool bWasRealWait = !bReturnOK;
+ BasicRuntime aRun( NULL );
+ if ( BasicRuntimeAccess::HasRuntime() )
+ aRun = BasicRuntimeAccess::GetRuntime();
+
+ // this timer to terminate Yield below
+ Timer aTimer;
+ aTimer.SetTimeout( pImpl->aServerTimeout.GetMSFromTime() );
+ aTimer.Start();
+ while ( !bReturnOK && aTimer.IsActive() && pCommunicationManager->IsCommunicationRunning()
+ && aRun.IsValid() && aRun.IsRun() )
+ {
+ #ifdef OS2
+ DosSleep(100);
+ #endif
+ GetpApp()->Yield();
+ if ( BasicRuntimeAccess::HasRuntime() )
+ aRun = BasicRuntimeAccess::GetRuntime();
+ else
+ aRun = BasicRuntime( NULL );
+ }
+ if ( bWasRealWait && aDialogHandlerName.Len() > 0 ) // Damit das ganze auch im Testtool l�uft
+ CallDialogHandler(GetpApp());
+ }
+ else
+ {
+ Time Ende;
+
+ Ende += pImpl->aServerTimeout;
+ SvStream *pTemp = NULL;
+
+ while ( !bReturnOK && Ende > Time() )
+ {
+// pTemp = PlugInApplication::GetPlugInApp()->GetReturnFromExecute();
+ if ( pTemp )
+ {
+ ReturnResults( pTemp );
+ bReturnOK = sal_True;
+ }
+ else
+ {
+ GetpApp()->Reschedule();
+ }
+ nIdleCount = 0;
+ }
+ }
+
+
+ if ( !bReturnOK )
+ {
+ ADD_ERROR(ERR_EXEC_TIMEOUT,GEN_RES_STR1(S_TIMOUT_WAITING, String::CreateFromInt64(nSequence)));
+ bReturnOK = sal_True;
+ nSequence++;
+ }
+}
+
+
+IMPL_LINK( TestToolObj, IdleHdl, Application*, EMPTYARG )
+{
+ if ( !bReturnOK )
+ nIdleCount++;
+ if ( nIdleCount > 10 ) // d.h. Schon 10 mal hier gewesen und noch keinmal im WaitForAnswer
+ {
+ GetpApp()->RemoveIdleHdl( LINK( this, TestToolObj, IdleHdl ) );
+ GetpApp()->PostUserEvent( LINK( this, TestToolObj, CallDialogHandler ) );
+ }
+ return 0;
+}
+
+IMPL_LINK( TestToolObj, CallDialogHandler, Application*, EMPTYARG )
+{
+ nWindowHandlerCallLevel++;
+ String aHandlerName(aDialogHandlerName);
+ aDialogHandlerName.Erase();
+
+ sal_uLong nRememberSequence = nSequence; // Da sich die Sequence im DialogHandler �ndert
+ ((StarBASIC*)GetParent())->Call( aHandlerName );
+ nSequence = nRememberSequence;
+ // Die Sequenznummern werden dann zwar doppelt vergeben, aber wen k�mmerts.
+
+ nWindowHandlerCallLevel--;
+ return 0;
+}
+
+
+void TestToolObj::BeginBlock()
+{
+ WaitForAnswer();
+ if ( IsError() )
+ return;
+
+ DBG_ASSERT(!IsBlock,"BeginBlock innerhalb eines Blockes");
+ In->Reset(nSequence);
+ IsBlock = sal_True;
+}
+
+
+void TestToolObj::SendViaSocket()
+{
+ if ( !pCommunicationManager )
+ {
+ DBG_ERROR("Kein CommunicationManager vorhanden!!");
+ return;
+ }
+
+ if ( !pCommunicationManager->IsCommunicationRunning() )
+ {
+ // first try to run basic sub "startTheOffice" see i86540
+ SbxVariable* pMeth = pImpl->pMyBasic->Find( CUniString( "startTheOffice" ), SbxCLASS_DONTCARE);
+ if( !pImpl->bIsStart && pMeth && pMeth->ISA(SbxMethod) )
+ {
+ pImpl->pMyBasic->Call( CUniString( "startTheOffice" ) );
+ }
+ else
+ {
+ pImpl->pMyBasic->ResetError(); // reset error produced by failed Find above
+ if ( !pCommunicationManager->StartCommunication( ProgPath, pImpl->ProgParam, pImpl->pChildEnv ) )
+ {
+ ADD_ERROR(ERR_RESTART_FAIL,GEN_RES_STR1(S_APPLICATION_START_FAILED, ProgPath));
+ }
+ else
+ {
+ if ( !pImpl->bIsStart )
+ {
+ ADD_ERROR(ERR_RESTART,GEN_RES_STR0(S_APPLICATION_RESTARTED));
+ }
+ }
+ }
+ }
+
+ bReturnOK = sal_False;
+ if ( pCommunicationManager->GetLastNewLink() )
+ {
+ if ( !pCommunicationManager->GetLastNewLink()->TransferDataStream( In->GetStream() ) )
+ {
+ ADD_ERROR(ERR_SEND_TIMEOUT,GEN_RES_STR1(S_TIMOUT_SENDING, String::CreateFromInt64(nSequence)));
+ nSequence++;
+ bReturnOK = sal_True; // Kein Return zu erwarten
+ }
+ }
+ else
+ {
+ ADD_ERROR(ERR_SEND_TIMEOUT,GEN_RES_STR1(S_NO_CONNECTION, String::CreateFromInt64(nSequence)));
+ nSequence++;
+ bReturnOK = sal_True; // Kein Return zu erwarten
+ }
+
+}
+
+void TestToolObj::EndBlock()
+{
+ if (IsBlock)
+ {
+ pImpl->LocalStarttime = Time::GetSystemTicks(); // Setzen der Anfangszeit f�r Performancemessung
+
+ In->GenCmdFlow (F_EndCommandBlock);
+
+ if ( pImpl->bDoRemoteCommandDelay )
+ {
+ sal_uLong nTimeWait = pImpl->nMinRemoteCommandDelay;
+ if ( pImpl->nMaxRemoteCommandDelay != pImpl->nMinRemoteCommandDelay )
+ nTimeWait += Time::GetSystemTicks() % ( pImpl->nMaxRemoteCommandDelay - pImpl->nMinRemoteCommandDelay );
+ Timer aTimer;
+ aTimer.SetTimeout( nTimeWait );
+ aTimer.Start();
+ while ( aTimer.IsActive() && pCommunicationManager->IsCommunicationRunning() )
+ {
+ #ifdef OS2
+ DosSleep(100);
+ #endif
+ GetpApp()->Yield();
+ }
+ }
+
+ if ( bUseIPC )
+ SendViaSocket();
+ else
+ {
+// PlugInApplication::GetPlugInApp()->ExecuteRemoteStatements( In->GetStream() );
+ bReturnOK = sal_False;
+ if ( aDialogHandlerName.Len() > 0 )
+ GetpApp()->InsertIdleHdl( LINK( this, TestToolObj, IdleHdl ), 1 );
+ }
+ IsBlock = sal_False;
+ }
+ else
+ {
+ DBG_ERROR("EndBlock au�erhalb eines Blockes");
+ }
+}
+
+
+sal_Bool TestToolObj::Load( String aFileName, SbModule *pMod )
+{
+ sal_Bool bOk = sal_True;
+ SvFileStream aStrm( aFileName, STREAM_STD_READ );
+ if( aStrm.IsOpen() )
+ {
+ String aText, aLine;
+ sal_Bool bIsFirstLine = sal_True;
+ rtl_TextEncoding aFileEncoding = RTL_TEXTENCODING_IBM_850;
+ while( !aStrm.IsEof() && bOk )
+ {
+ aStrm.ReadByteStringLine( aLine, aFileEncoding );
+ if ( bIsFirstLine && IsTTSignatureForUnicodeTextfile( aLine ) )
+ aFileEncoding = RTL_TEXTENCODING_UTF8;
+ else
+ {
+ if ( !bIsFirstLine )
+ aText += '\n';
+ aText += aLine;
+ bIsFirstLine = sal_False;
+ }
+ if( aStrm.GetError() != SVSTREAM_OK )
+ bOk = sal_False;
+ }
+ aText.ConvertLineEnd();
+ pMod->SetName(CUniString("--").Append(aFileName));
+
+ pMod->SetComment( GetRevision( aText ) );
+
+ SbModule* pOldModule = MyBasic::GetCompileModule();
+ MyBasic::SetCompileModule( pMod );
+
+ pMod->SetSource( PreCompile( aText ) );
+
+ MyBasic::SetCompileModule( pOldModule );
+ if ( WasPrecompilerError() )
+ bOk = sal_False;
+
+ }
+ else
+ bOk = sal_False;
+ return bOk;
+}
+
+
+sal_Bool TestToolObj::ReadNamesBin( String Filename, CNames *&pSIds, CNames *&pControls )
+{
+ SvFileStream aStream;
+ String aName,aURL;
+ rtl::OString aUId;
+ ControlDef *pNewDef, *pNewDef2;
+ ControlDef *pFatherDef = NULL;
+
+
+ aStream.Open(Filename, STREAM_STD_READ);
+ if (!aStream.IsOpen())
+ {
+ ADD_ERROR(ERR_NO_FILE,GEN_RES_STR1(S_CANNOT_OPEN_FILE, Filename));
+ return sal_False;
+ }
+
+ if ( !pSIds )
+ pSIds = new CNames();
+ if ( !pControls )
+ pControls = new CNames();
+
+ {
+ TTExecutionStatusHint aHint( TT_EXECUTION_ENTERWAIT );
+ GetTTBroadcaster().Broadcast( aHint );
+ }
+
+ sal_uInt16 nAnz;
+ aStream >> nAnz;
+ CNames *pNames = pSIds; // first read all the slots
+ sal_Bool bIsFlat = sal_True; // Slots do not have children
+
+ while ( nAnz && !aStream.IsEof() )
+ {
+
+ aStream.ReadByteString( aName, RTL_TEXTENCODING_UTF8 );
+
+ sal_uInt16 nType;
+ aStream >> nType;
+ if ( !nType /* HasNumeric() */)
+ {
+ String aStrId;
+ aStream.ReadByteString( aStrId, RTL_TEXTENCODING_UTF8 );
+ // FIXME: HELPID
+ #if 0
+ aUId = rtl::OString( aStrId );
+ #endif
+ }
+ else
+ {
+ comm_ULONG nUId;
+ aStream >> nUId;
+ aUId = rtl::OString();// nUId;
+ }
+
+ if (aName.GetChar(0) == '*' || bIsFlat ) // Globaler Kurzname (Dialogname oder SId)
+ {
+ if (!bIsFlat)
+ aName.Erase(0,1);
+ pNewDef = new ControlDef(aName,aUId);
+
+ if (!bIsFlat)
+ {
+ pNewDef->Sons(new CNames());
+
+ pNewDef2 = new ControlDef(aName,aUId); // Noch einen machen
+ if (!pNewDef->SonInsert(pNewDef2)) // Dialog in eigenen Namespace eintragen
+ {
+ delete pNewDef2;
+ DBG_ERROR(" !!!! ACHTUNG !!!! Fehler beim einf�gen in leere Liste!");
+ }
+ }
+
+ const ControlItem *pItem = pNewDef;
+ if (! pNames->Insert(pItem))
+ {
+ DBG_ERROR(" !!!! ACHTUNG !!!! Fehler beim einf�gen eines namens!");
+ delete pNewDef;
+ pFatherDef = NULL;
+ }
+ else
+ {
+ pFatherDef = pNewDef;
+ }
+ }
+ else
+ {
+ if (!pFatherDef)
+ {
+ DBG_ERROR( "Internal Error: Erster Kurzname mu� mit * beginnen. �berspringe." );
+ }
+ else
+ {
+ pNewDef = new ControlDef(aName,aUId);
+ if (! pFatherDef->SonInsert(pNewDef))
+ {
+ delete pNewDef;
+ DBG_ERROR(" !!!! ACHTUNG !!!! Fehler beim einf�gen eines namens!");
+ }
+ }
+ }
+
+
+ nAnz--;
+ if ( !nAnz && bIsFlat ) // We have read all slots
+ {
+ aStream >> nAnz;
+ pNames = pControls; // Now read the controls
+ bIsFlat = sal_False; // Controls *do* have children
+ }
+
+
+ GetpApp()->Reschedule();
+ }
+ {
+ TTExecutionStatusHint aHint( TT_EXECUTION_LEAVEWAIT );
+ GetTTBroadcaster().Broadcast( aHint );
+ }
+
+ aStream.Close();
+ return sal_True;
+}
+
+
+sal_Bool TestToolObj::WriteNamesBin( String Filename, CNames *pSIds, CNames *pControls )
+{
+ sal_Bool bOk = sal_True;
+ SvFileStream aStrm( String(Filename).AppendAscii(".bin"), STREAM_STD_WRITE );
+ if( aStrm.IsOpen() )
+ {
+ sal_uInt16 i;
+ if ( pSIds )
+ {
+ aStrm << pSIds->Count();
+ for ( i = 0 ; pSIds->Count() > i && bOk ; i++ )
+ {
+ ((ControlDef*)(*pSIds)[i])->Write(aStrm);
+ if( aStrm.GetError() != SVSTREAM_OK )
+ bOk = sal_False;
+ }
+ }
+ else
+ aStrm << sal_uInt16( 0 );
+
+ if ( pControls )
+ {
+ aStrm << pControls->Count();
+ for ( i = 0 ; pControls->Count() > i && bOk ; i++ )
+ {
+ ((ControlDef*)(*pControls)[i])->Write(aStrm);
+ if( aStrm.GetError() != SVSTREAM_OK )
+ bOk = sal_False;
+ }
+ }
+ else
+ aStrm << sal_uInt16( 0 );
+ }
+ else
+ bOk = sal_False;
+ return bOk;
+}
+
+
+void TestToolObj::SFX_NOTIFY( SfxBroadcaster&, const TypeId&,
+ const SfxHint& rHint, const TypeId& )
+{
+ static CNames *pUIds = NULL; // Halten der hid.lst
+
+ const SbxHint* p = PTR_CAST(SbxHint,&rHint);
+ if( p )
+ {
+ SbxVariable* pVar = p->GetVar();
+ SbxArray* rPar = pVar->GetParameters();
+
+ sal_uLong nHintId = p->GetId();
+ sal_uLong nHintUserData = pVar->GetUserData();
+ if( nHintId == SBX_HINT_DATAWANTED )
+ {
+ nMyVar = 0;
+ switch( nHintUserData )
+ {
+ case ID_Kontext:
+ if ( !rPar )
+ {
+ m_pNameKontext = m_pControls;
+
+ // So da� nicht immer mal wieder was aus einem alten Kontext dazwischenhaut
+ for (sal_uInt16 i=0;i<VAR_POOL_SIZE;i++)
+ {
+ pImpl->pMyVars[i]->SetName( CUniString("VarDummy").Append(UniString::CreateFromInt32(i)) );
+ }
+ }
+ else if ( rPar && rPar->Count() == 2 )
+ {
+ sal_uInt16 nElement;
+ SbxVariableRef pArg = rPar->Get( 1 );
+ String aKontext = pArg->GetString();
+ ControlDef WhatName(aKontext,rtl::OString());
+ if (m_pControls && m_pControls->Seek_Entry(&WhatName,&nElement))
+ {
+ m_pNameKontext = ((ControlDef*)m_pControls->GetObject(nElement))->GetSons();
+
+ // So da� nicht immer mal wieder was aus einem alten Kontext dazwischenhaut
+ for (sal_uInt16 i=0;i<VAR_POOL_SIZE;i++)
+ {
+ pImpl->pMyVars[i]->SetName( CUniString("VarDummy").Append(UniString::CreateFromInt32(i)) );
+ }
+ }
+ }
+ else
+ SetError( SbxERR_WRONG_ARGS );
+ break;
+ case ID_Start:
+ if ( rPar && rPar->Count() >= 2 )
+ {
+ SbxVariableRef pArg = rPar->Get( 1 );
+ ProgPath = pArg->GetString();
+ if ( rPar && rPar->Count() >= 3 )
+ {
+ pArg = rPar->Get( 2 );
+ pImpl->ProgParam = pArg->GetString();
+ }
+ else
+ pImpl->ProgParam.Erase();
+
+ String aTmpStr(ProgPath);
+ aTmpStr += ' ';
+ aTmpStr += pImpl->ProgParam;
+ {
+ TTExecutionStatusHint aHint( TT_EXECUTION_SHOW_ACTION, String(SttResId(S_STARTING_APPLICATION)), aTmpStr );
+ GetTTBroadcaster().Broadcast( aHint );
+ }
+
+ pImpl->bIsStart = sal_True;
+ BeginBlock();
+ EndBlock();
+ pImpl->bIsStart = sal_False;
+ {
+ TTExecutionStatusHint aHint( TT_EXECUTION_HIDE_ACTION );
+ GetTTBroadcaster().Broadcast( aHint );
+ }
+ }
+ break;
+ case ID_KillApp:
+ pCommunicationManager->KillApplication();
+ break;
+ case ID_SaveIDs:
+ if ( rPar && rPar->Count() >= 2 ) // Genau ein Parameter
+ {
+ SbxVariableRef pArg = rPar->Get( 1 );
+ DirEntry FilePath = pImpl->aFileBase + DirEntry(pArg->GetString(),FSYS_STYLE_VFAT);
+ WriteNamesBin( FilePath.GetFull(), m_pSIds, m_pControls );
+ }
+ else
+ SetError( SbxERR_WRONG_ARGS );
+ break;
+ case ID_AutoExecute:
+ if ( !rPar ) // rPar = NULL <=> Kein Parameter
+ {
+ pVar->PutBool(SingleCommandBlock);
+ }
+ else
+ SetError( SbxERR_WRONG_ARGS );
+ break;
+ case ID_Execute:
+ if ( !rPar ) // rPar = NULL <=> Kein Parameter
+ {
+ EndBlock();
+ BeginBlock();
+ }
+ else
+ SetError( SbxERR_WRONG_ARGS );
+ break;
+ case ID_DialogHandler:
+ if ( rPar && rPar->Count() >= 2 ) // Genau ein Parameter
+ {
+ SbxVariableRef pArg = rPar->Get( 1 );
+ aDialogHandlerName = pArg->GetString();
+ }
+ else
+ SetError( SbxERR_WRONG_ARGS );
+ break;
+ case ID_GetError:
+ if ( !rPar ) // rPar = NULL <=> Kein Parameter
+ {
+ WaitForAnswer();
+ if ( IS_ERROR() )
+ {
+// pVar->PutULong( GET_ERROR()->nError );
+ pVar->PutString( GET_ERROR()->aText );
+ POP_ERROR();
+ }
+ else
+ {
+// pVar->PutULong( 0 );
+ pVar->PutString( String() );
+ }
+ }
+ else
+ SetError( SbxERR_WRONG_ARGS );
+ break;
+ case ID_StartUse:
+ if ( !rPar ) // rPar = NULL <=> Kein Parameter
+ {
+ {
+ BasicRuntime aRun = BasicRuntimeAccess::GetRuntime();
+ aLogFileName = DirEntry(aRun.GetModuleName(SbxNAME_NONE)).GetBase().AppendAscii(".res");
+ }
+
+ ADD_RUN_LOG();
+ ADD_CASE_LOG(GEN_RES_STR0(S_READING_FILE));
+
+ pCommunicationManager->StopCommunication();
+ // Wait for asynchronous events to be processed, so communication will be restarted properly
+ while ( pCommunicationManager->IsCommunicationRunning() )
+ Application::Reschedule();
+
+ SingleCommandBlock = sal_True; // Bug 57188
+ IsBlock = sal_False;
+
+// pCommunicationManager->StartCommunication();
+
+ for (sal_uInt16 i=0;i<VAR_POOL_SIZE;i++)
+ {
+ pImpl->pMyVars[i]->SetName( CUniString("VarDummy").Append(UniString::CreateFromInt32(i)) );
+ }
+ nMyVar = 0;
+
+ if (m_pControls)
+ {
+ delete m_pControls;
+ m_pControls = NULL;
+ }
+ if (m_pReverseSlots)
+ {
+ delete m_pReverseSlots;
+ m_pReverseSlots = NULL;
+ }
+ if (m_pReverseControls)
+ {
+ delete m_pReverseControls;
+ m_pReverseControls = NULL;
+ }
+ if (m_pReverseControlsSon)
+ {
+ delete m_pReverseControlsSon;
+ m_pReverseControlsSon = NULL;
+ }
+ if (m_pSIds)
+ {
+ delete m_pSIds;
+ m_pSIds = NULL;
+ }
+ if (pUIds)
+ {
+ delete pUIds;
+ pUIds = NULL;
+ }
+ if (m_pReverseUIds)
+ {
+ delete m_pReverseUIds;
+ m_pReverseUIds = NULL;
+ }
+ m_pNameKontext = m_pControls;
+ pImpl->bLnaguageExtensionLoaded = sal_False;
+ SfxSimpleHint aHint( SBX_HINT_LANGUAGE_EXTENSION_LOADED );
+ GetTTBroadcaster().Broadcast( aHint );
+
+ pImpl->nMinRemoteCommandDelay = 0;
+ pImpl->nMaxRemoteCommandDelay = 0;
+ pImpl->bDoRemoteCommandDelay = sal_False;
+ pImpl->aTestCaseName.Erase();
+ pImpl->aTestCaseFileName.Erase();
+ pImpl->nTestCaseLineNr = 0;
+
+ pImpl->bEnableQaErrors = sal_True;
+ pImpl->bDebugFindNoErrors = sal_False;
+
+ pImpl->pChildEnv->clear();
+
+ String aName( CUniString( "StopOnSyntaxError" ) );
+ SbxVariableRef xStopOnSyntaxError = SbxObject::Find( aName, SbxCLASS_PROPERTY );
+ if ( xStopOnSyntaxError.Is() )
+ xStopOnSyntaxError->PutBool( pImpl->bStopOnSyntaxError );
+ else
+ SetError( SbxERR_BAD_ACTION );
+ }
+ else
+ SetError( SbxERR_WRONG_ARGS );
+ break;
+ case ID_Use:
+ if ( rPar && rPar->Count() >= 2 )
+ {
+ SbxVariableRef pArg = rPar->Get( 1 );
+ DirEntry FilePath(pArg->GetString(),FSYS_STYLE_VFAT);
+ if ( !FilePath.IsAbs() )
+ FilePath = pImpl->aFileBase + FilePath;
+ String Ext = FilePath.GetExtension();
+ if ( Ext.CompareIgnoreCaseToAscii("Win") == COMPARE_EQUAL )
+ {
+ ReadNames( FilePath.GetFull(),m_pControls,pUIds);
+ pImpl->bLnaguageExtensionLoaded = sal_True;
+ SfxSimpleHint aHint( SBX_HINT_LANGUAGE_EXTENSION_LOADED );
+ GetTTBroadcaster().Broadcast( aHint );
+ }
+ else if ( Ext.CompareIgnoreCaseToAscii("Sid") == COMPARE_EQUAL )
+ {
+ ReadNames( FilePath.GetFull(),m_pSIds,pUIds,FLAT);
+ pImpl->bLnaguageExtensionLoaded = sal_True;
+ SfxSimpleHint aHint( SBX_HINT_LANGUAGE_EXTENSION_LOADED );
+ GetTTBroadcaster().Broadcast( aHint );
+ }
+ else if ( Ext.CompareIgnoreCaseToAscii("Bin") == COMPARE_EQUAL )
+ {
+ ReadNamesBin( FilePath.GetFull(), m_pSIds, m_pControls );
+ pImpl->bLnaguageExtensionLoaded = sal_True;
+ SfxSimpleHint aHint( SBX_HINT_LANGUAGE_EXTENSION_LOADED );
+ GetTTBroadcaster().Broadcast( aHint );
+ }
+ else if ( Ext.CompareIgnoreCaseToAscii("Inc") == COMPARE_EQUAL )
+ {
+ {
+ TTExecutionStatusHint aHint( TT_EXECUTION_SHOW_ACTION, String(SttResId(S_READING_BASIC_MODULE)), FilePath.GetFull() );
+ GetTTBroadcaster().Broadcast( aHint );
+ }
+ String aFullPathname = FilePath.GetFull();
+ StarBASIC *pBasic = (StarBASIC*)GetParent();
+ if ( !aModuleWinExistsHdl.Call( &aFullPathname ) &&
+ !pBasic->FindModule( CUniString( "--" ).Append(aFullPathname) ) )
+ {
+ SbModule *pMod;
+ pMod = pBasic->MakeModule( CUniString("--"), String() );
+ pMod->Clear();
+ if ( Load( aFullPathname, pMod ) )
+ {
+ if ( !IS_ERROR() )
+ {
+ pBasic->Compile( pMod );
+ pMod->RunInit();
+ }
+ }
+ else
+ {
+ ADD_ERROR( SbxERR_CANNOT_LOAD, FilePath.GetFull() );
+ }
+ }
+ {
+ TTExecutionStatusHint aHint( TT_EXECUTION_HIDE_ACTION );
+ GetTTBroadcaster().Broadcast( aHint );
+ }
+ }
+ else
+ {
+ ADD_ERROR(SbxERR_CANNOT_LOAD,FilePath.GetFull());
+ }
+ }
+ else
+ SetError( SbxERR_WRONG_ARGS );
+ break;
+ case ID_FinishUse:
+ if ( !rPar ) // rPar = NULL <=> Kein Parameter
+ {
+ ADD_CASE_LOG( String() ); // Case abschliessen
+ if (!m_pControls)
+ m_pControls = new CNames();
+
+ if (!m_pSIds)
+ m_pSIds = new CNames();
+
+ if (pUIds)
+ { // save some memory
+ delete pUIds;
+ pUIds = NULL;
+ }
+
+ m_pNameKontext = m_pControls;
+
+ if ( pImpl->bLnaguageExtensionLoaded )
+ {
+ SfxSimpleHint aHint( SBX_HINT_LANGUAGE_EXTENSION_LOADED );
+ GetTTBroadcaster().Broadcast( aHint );
+ }
+
+ pImpl->nIncludeFileWarningCount = pImpl->nWarningCount;
+ pImpl->nWarningCount = 0;
+
+ *pImpl->xIncludeFileWarningList = *pImpl->xWarningList;
+ pImpl->xWarningList->SbxArray::Clear();
+ }
+ else
+ SetError( SbxERR_WRONG_ARGS );
+ break;
+ case ID_CaseLog:
+ if ( rPar ) // rPar != NULL <=> Es gibt Parameter
+ {
+ sal_uInt16 n;
+ String aX;
+ for ( n = 1; n < rPar->Count(); n++ )
+ {
+ SbxVariableRef pArg = rPar->Get( n );
+ aX += pArg->GetString();
+ }
+ pImpl->aTestCaseName = aX;
+ if ( pImpl->aTestCaseName.Len() && BasicRuntimeAccess::HasRuntime() )
+ {
+ BasicRuntime aRun = BasicRuntimeAccess::GetRuntime();
+ pImpl->aTestCaseFileName = aRun.GetModuleName(SbxNAME_SHORT_TYPES);
+ if ( pImpl->aTestCaseFileName.Copy(0,2).CompareToAscii( "--" ) == COMPARE_EQUAL )
+ pImpl->aTestCaseFileName.Erase(0,2);
+ pImpl->nTestCaseLineNr = aRun.GetLine();
+ }
+ else
+ {
+ pImpl->aTestCaseFileName.Erase();
+ pImpl->nTestCaseLineNr = 0;
+ }
+ ADD_CASE_LOG( aX );
+ }
+ break;
+ case ID_ExceptLog:
+ if ( IS_ERROR() )
+ {
+ BasicRuntime aRun = BasicRuntimeAccess::GetRuntime();
+ sal_Bool bWasNewError = sal_False;
+
+ if ( BasicRuntimeAccess::HasStack() )
+ {
+ for ( sal_uInt16 i = 0 ; i < BasicRuntimeAccess::GetStackEntryCount() -1 ; i++ )
+ {
+ BasicErrorStackEntry aThisEntry = BasicRuntimeAccess::GetStackEntry(i);
+ if ( !bWasNewError )
+ {
+ bWasNewError = sal_True;
+ ADD_ERROR_LOG( GET_ERROR()->aText, aThisEntry.GetModuleName(SbxNAME_SHORT_TYPES),
+ aThisEntry.GetLine(), aThisEntry.GetCol1(), aThisEntry.GetCol2(), aThisEntry.GetSourceRevision() );
+ }
+ ADD_CALL_STACK_LOG( String(aThisEntry.GetModuleName(SbxNAME_SHORT_TYPES))
+ .AppendAscii(": ").Append(aThisEntry.GetMethodName(SbxNAME_SHORT_TYPES)),
+ aThisEntry.GetModuleName(SbxNAME_SHORT_TYPES),
+ aThisEntry.GetLine(), aThisEntry.GetCol1(), aThisEntry.GetCol2() );
+
+ }
+ BasicRuntimeAccess::DeleteStack();
+ }
+
+ sal_Bool bIsFirst = sal_True;
+ while ( aRun.IsValid() )
+ {
+ xub_StrLen nErrLn;
+ xub_StrLen nCol1;
+ xub_StrLen nCol2;
+ if ( bIsFirst )
+ {
+ bIsFirst = sal_False;
+ nErrLn = GET_ERROR()->nLine;
+ nCol1 = GET_ERROR()->nCol1;
+ nCol2 = GET_ERROR()->nCol2;
+ }
+ else
+ {
+ nErrLn = aRun.GetLine();
+ nCol1 = aRun.GetCol1();
+ nCol2 = aRun.GetCol2();
+ }
+
+ if ( !bWasNewError )
+ {
+ bWasNewError = sal_True;
+ ADD_ERROR_LOG( GET_ERROR()->aText, aRun.GetModuleName(SbxNAME_SHORT_TYPES),
+ nErrLn, nCol1, nCol2, aRun.GetSourceRevision() );
+ }
+ ADD_CALL_STACK_LOG( String(aRun.GetModuleName(SbxNAME_SHORT_TYPES))
+ .AppendAscii(": ").Append(aRun.GetMethodName(SbxNAME_SHORT_TYPES)),
+ aRun.GetModuleName(SbxNAME_SHORT_TYPES),
+ nErrLn, nCol1, nCol2 );
+ aRun = aRun.GetNextRuntime();
+ }
+ }
+ break;
+ case ID_ErrorLog:
+ if ( IS_ERROR() )
+ {
+ BasicRuntime aRun = BasicRuntimeAccess::GetRuntime();
+ if ( BasicRuntimeAccess::HasStack() )
+ {
+ BasicErrorStackEntry aThisEntry = BasicRuntimeAccess::GetStackEntry( 0 );
+ ADD_ERROR_LOG( GET_ERROR()->aText, aThisEntry.GetModuleName(SbxNAME_SHORT_TYPES),
+ aThisEntry.GetLine(), aThisEntry.GetCol1(), aThisEntry.GetCol2(), aThisEntry.GetSourceRevision() );
+ BasicRuntimeAccess::DeleteStack();
+ }
+ else
+ {
+ ADD_ERROR_LOG( GET_ERROR()->aText, aRun.GetModuleName(SbxNAME_SHORT_TYPES),
+ StarBASIC::GetErl(), aRun.GetCol1(), aRun.GetCol2(), aRun.GetSourceRevision() );
+ }
+ }
+ break;
+ case ID_QAErrorLog:
+ if ( rPar ) // rPar != NULL <=> Es gibt Parameter
+ {
+ sal_uInt16 n;
+ String aSammel;
+ for ( n = 1; n < rPar->Count(); n++ )
+ {
+ SbxVariableRef pArg = rPar->Get( n );
+ aSammel += pArg->GetString();
+ }
+ ADD_QA_ERROR_LOG( aSammel );
+ }
+ break;
+ case ID_PrintLog:
+ if ( rPar ) // rPar != NULL <=> Es gibt Parameter
+ {
+ sal_uInt16 n;
+ String aSammel;
+ for ( n = 1; n < rPar->Count(); n++ )
+ {
+ SbxVariableRef pArg = rPar->Get( n );
+ aSammel += pArg->GetString();
+ }
+ ADD_MESSAGE_LOG( aSammel );
+ }
+ break;
+ case ID_WarnLog:
+ if ( rPar ) // rPar != NULL <=> Es gibt Parameter
+ {
+ sal_uInt16 n;
+ String aSammel;
+ for ( n = 1; n < rPar->Count(); n++ )
+ {
+ SbxVariableRef pArg = rPar->Get( n );
+ aSammel += pArg->GetString();
+ }
+ ADD_WARNING_LOG( aSammel );
+
+ }
+ break;
+ case ID_ClearError:
+ while ( IS_ERROR() )
+ {
+ POP_ERROR();
+ }
+ break;
+ case ID_MaybeAddErr:
+ if ( ((StarBASIC*)GetParent())->GetErrBasic() && ( !IS_ERROR() ||
+ pFehlerListe->GetObject(pFehlerListe->Count()-1)->nError != ((StarBASIC*)GetParent())->GetErrBasic() ) )
+ {
+ ((StarBASIC*)GetParent())->MakeErrorText(((StarBASIC*)GetParent())->GetErrBasic(),String());
+ ADD_ERROR_QUIET(((StarBASIC*)GetParent())->GetErrBasic() , ((StarBASIC*)GetParent())->GetErrorText())
+ }
+ break;
+ case ID_GetNextCloseWindow:
+ if ( !rPar ) // rPar = NULL <=> Kein Parameter
+ {
+ SetError( SbxERR_NOTIMP );
+ break;
+
+// Das ist total rotten und mu� wohl komplett neu!!
+
+
+/* sal_Bool bWasBlock = IsBlock;
+ if ( !IsBlock ) // Impliziter call bei Aufruf mit Methode
+ if ( SingleCommandBlock )
+ BeginBlock();
+// if ( !IsError() )
+// In->GenCmdSlot (128,rPar);
+// ((Controls*)pVar)->pMethodVar->nValue = 128;
+
+ sal_uLong nOldValue = ((Controls*)pVar)->GetULong();
+ // Setzen, so da� beim Return der Wert stimmt
+ ((Controls*)pVar)->PutULong( 128 );
+ pImpl->pNextReturn = ((Controls*)pVar)->pMethodVar;
+ if ( SingleCommandBlock )
+ EndBlock();
+ WaitForAnswer();
+ if ( bWasBlock )
+ if ( SingleCommandBlock )
+ BeginBlock();
+ ((Controls*)pVar)->PutULong( nOldValue );
+
+ // R�cksetzen, so da� beim n�chsten Aufruf alles klappt
+// ((Controls*)pVar)->SetUserData( 128 );
+
+
+// ((Controls*)pVar)->SetName("xxx");
+ // Setzen und r�cksetzen der ID, so dass der Notify ohne Wirkung bleibt.
+ ((Controls*)pVar)->pMethodVar->SetUserData(ID_ErrorDummy);
+ ((Controls*)pVar)->PutULong( ((Controls*)pVar)->pMethodVar->GetULong() );
+ ((Controls*)pVar)->pMethodVar->SetUserData(ID_Control);
+
+ pShortNames->Insert( CUniString("xxx"), rtl::OString( ((Controls*)pVar)->pMethodVar->nValue ), nSequence );
+
+ nOldValue = ((Controls*)pVar)->GetULong();
+
+ SbxVariable *pMember;
+ if ( ! (pMember = ((Controls*)pVar)->Find(CUniString("ID"),SbxCLASS_DONTCARE)) )
+ {
+ pMember = new SbxProperty(CUniString("ID"),SbxVARIANT);
+ ((Controls*)pVar)->Insert(pMember);
+ }
+ pMember->PutULong(((Controls*)pVar)->pMethodVar->nValue);
+
+ if ( ! (pMember = ((Controls*)pVar)->Find(CUniString("name"),SbxCLASS_DONTCARE)) )
+ {
+ pMember = NULL;
+ }
+ else
+ pMember->PutString(CUniString("xxx"));
+
+ */
+
+ }
+ else
+ SetError( SbxERR_WRONG_ARGS );
+ break;
+ case ID_RemoteCommand:
+ {
+ if ( SingleCommandBlock )
+ BeginBlock();
+ else
+ if ( ((SbxTransportMethod*)pVar)->nValue & M_WITH_RETURN )
+ {
+ SetError( SbxERR_NOTIMP );
+ }
+ if ( !IsError() )
+ In->GenCmdCommand ((sal_uInt16)(((SbxTransportMethod*)pVar)->nValue),rPar);
+ if ( !IsError() && ((SbxTransportMethod*)pVar)->nValue & M_WITH_RETURN )
+ {
+ pImpl->pNextReturn = ((SbxTransportMethod*)pVar);
+ // FIXME: HELPID
+ aNextReturnId = rtl::OString();// ((SbxTransportMethod*)pVar)->nValue );
+ }
+ if ( SingleCommandBlock )
+ EndBlock();
+ if ( !IsError() && (sal_uInt16)((SbxTransportMethod*)pVar)->nValue & M_WITH_RETURN )
+ {
+ WaitForAnswer();
+ }
+ // f�r einige noch etwas Nachbehandlung
+ switch ( ((SbxTransportMethod*)pVar)->nValue )
+ {
+ case RC_WinTree:
+// ::svt::OStringTransfer::CopyString(pVar->GetString(), pSomeWindowIDontHave );
+ break;
+ }
+
+ }
+ break;
+ case ID_Dispatch:
+ if ( !rPar || (rPar->Count() % 2) == 1 ) // rPar = NULL <=> Kein Parameter ansonsten Gerade Anzahl(Ungerade, da immer Anzahl+1
+ {
+ if ( SingleCommandBlock )
+ BeginBlock();
+ if ( !IsError() )
+ In->GenCmdSlot ( (sal_uInt16)((SbxTransportMethod*)pVar)->nValue, rPar );
+ pVar->PutInteger( (sal_uInt16)((SbxTransportMethod*)pVar)->nValue );
+ if ( SingleCommandBlock )
+ EndBlock();
+ }
+ else
+ SetError( SbxERR_WRONG_ARGS );
+ break;
+ case ID_UNODispatch:
+ if ( !rPar ) // rPar = NULL <=> Kein Parameter ansonsten Gerade Anzahl(Ungerade, da immer Anzahl+1
+ {
+ if ( SingleCommandBlock )
+ BeginBlock();
+ if ( !IsError() )
+ In->GenCmdUNOSlot ( ((SbxTransportMethod*)pVar)->aUnoSlot );
+ pVar->PutString( ((SbxTransportMethod*)pVar)->aUnoSlot );
+ if ( SingleCommandBlock )
+ EndBlock();
+ }
+ else
+ SetError( SbxERR_WRONG_ARGS );
+ break;
+ case ID_Control:
+ case ID_StringControl:
+ // if only the object is given in the script we don't have to do anything (object stands for itself)
+ if ( !pVar->ISA( SbxObject ) )
+ {
+ if ( SingleCommandBlock )
+ BeginBlock();
+ else
+ if ( ((SbxTransportMethod*)pVar)->nValue & M_WITH_RETURN )
+ {
+ SetError( SbxERR_NOTIMP );
+ }
+ if ( !IsError() )
+ {
+ SbxVariable *pMember = NULL;
+ if ( pVar->GetParent() )
+ pMember = pVar->GetParent()->Find(CUniString("ID"),SbxCLASS_DONTCARE);
+ if ( pMember == NULL )
+ {
+ SetError( SbxERR_NAMED_NOT_FOUND );
+ }
+ else
+ {
+ if ( nHintUserData == ID_Control )
+ {
+ In->GenCmdControl (pMember->GetULong(),
+ (sal_uInt16)((SbxTransportMethod*)pVar)->nValue, rPar);
+ // FIXME: HELPID
+ aNextReturnId = rtl::OString();// pMember->GetULong() );
+ }
+ else
+ {
+ In->GenCmdControl (pMember->GetString(),
+ (sal_uInt16)((SbxTransportMethod*)pVar)->nValue, rPar);
+ // FIXME: HELPID
+ #if 0
+ aNextReturnId = rtl::OString( pMember->GetString() );
+ #endif
+ }
+ }
+
+ if ( !IsError() && ((SbxTransportMethod*)pVar)->nValue & M_WITH_RETURN )
+ {
+ pImpl->pNextReturn = ((SbxTransportMethod*)pVar);
+ }
+ else
+ {
+ pImpl->pNextReturn = NULL;
+ aNextReturnId = rtl::OString();
+ }
+
+ }
+ if ( SingleCommandBlock )
+ EndBlock();
+ if ( !IsError() && (sal_uInt16)((SbxTransportMethod*)pVar)->nValue & M_WITH_RETURN )
+ {
+ WaitForAnswer();
+ }
+ }
+
+ break;
+ case ID_GetUnoApp:
+ {
+ // Hier wird der Remote UNO Kram gestartet
+ // Eintrag in die Konfiguration unter
+ // org.openoffice.Office.Common/Start/Connection
+ // socket,host=0,port=12345;iiop;XBla
+ // oder
+ // socket,host=0,port=12345;urp;;XBla
+
+ String aString;
+ aString.AppendAscii( "socket,host=" );
+ aString += GetHostConfig();
+ aString.AppendAscii( ",port=" );
+ aString += String::CreateFromInt32( GetUnoPortConfig() );
+
+ Reference< XMultiServiceFactory > smgr_xMultiserviceFactory;
+ try
+ {
+ Reference< XMultiServiceFactory > xSMgr = comphelper::getProcessServiceFactory();
+// is allways there
+/* if ( ! xSMgr.is() )
+ {
+ xSMgr = ::cppu::createRegistryServiceFactory(OUString(RTL_CONSTASCII_USTRINGPARAM("applicat.rdb")), sal_True );
+ if ( xSMgr.is() )
+ comphelper::setProcessServiceFactory( xSMgr );
+ }*/
+
+ OUString aURL( aString );
+ Reference< XConnector > xConnector( xSMgr->createInstance(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.connection.Connector") ) ), UNO_QUERY );
+ Reference< XConnection > xConnection( xConnector->connect( aURL ) );
+
+ Reference< XBridgeFactory > xBridgeFactory( xSMgr->createInstance(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.bridge.BridgeFactory") ) ), UNO_QUERY );
+ Reference< XBridge > xBridge( xBridgeFactory->createBridge(
+ OUString(), OUString( RTL_CONSTASCII_USTRINGPARAM("urp") ),
+ xConnection, Reference< XInstanceProvider >() ) );
+
+ // Reference< XInterface > xRet( xBridge->getInstance( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.Desktop")) ) );
+ Reference< XInterface > xRet( xBridge->getInstance( OUString( RTL_CONSTASCII_USTRINGPARAM("StarOffice.ServiceManager")) ) );
+
+ // Reference< XNamingService > xNamingService(xRet, UNO_QUERY);
+
+ // Reference< XInterface > smgr = xNamingService->getRegisteredObject( OUString( RTL_CONSTASCII_USTRINGPARAM("StarOffice.ServiceManager" ) ) );
+
+ smgr_xMultiserviceFactory = Reference< XMultiServiceFactory >(xRet, UNO_QUERY);
+ //MBA fragen!!
+ }
+ catch( class Exception & rEx)
+ {
+ ADD_ERROR(SbxERR_BAD_ACTION, String( rEx.Message ) );
+ }
+ catch( ... )
+ {
+ ADD_ERROR(SbxERR_BAD_ACTION, CUniString( "Unknown Error" ) );
+ }
+
+ if( smgr_xMultiserviceFactory.is() )
+ {
+ Any aAny;
+// aAny <<= xBridge;
+ aAny <<= smgr_xMultiserviceFactory;
+
+ SbxObjectRef xMySbxObj = GetSbUnoObject( CUniString("RemoteUnoAppFuerTesttool"), aAny );
+ if ( xMySbxObj.Is() )
+ pVar->PutObject( xMySbxObj );
+ }
+ }
+ break;
+ case ID_GetIServer:
+ {
+ // Hier wird der Remote UNO Kram gestartet
+
+ String aString;
+// aString += GetHostConfig();
+// aString.AppendAscii( ":" );
+// aString += String::CreateFromInt32( GetUnoPortConfig() );
+
+ Reference< XMultiServiceFactory > xSMgr /* = comphelper::getProcessServiceFactory()*/;
+// if ( ! xSMgr.is() )
+ {
+ xSMgr = ::cppu::createRegistryServiceFactory(OUString(RTL_CONSTASCII_USTRINGPARAM("g:\\iserverproxy.rdb")), sal_True);
+// comphelper::setProcessServiceFactory( xSMgr );
+ }
+
+ OUString aURL( aString );
+ Reference< XConnector > xConnector( xSMgr->createInstance(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.connection.Connector") ) ), UNO_QUERY );
+ Reference< XConnection > xConnection( xConnector->connect( OUString( RTL_CONSTASCII_USTRINGPARAM("socket,host=grande,port=7453")) ) );
+
+ Reference< XBridgeFactory > xBridgeFactory( xSMgr->createInstance(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.bridge.BridgeFactory") ) ), UNO_QUERY );
+ Reference< XBridge > xBridge( xBridgeFactory->createBridge(
+ OUString(), OUString( RTL_CONSTASCII_USTRINGPARAM("urp") ),
+ xConnection, Reference< XInstanceProvider >() ) );
+
+ Reference< XInterface > xRet( xBridge->getInstance( OUString( RTL_CONSTASCII_USTRINGPARAM("XIServerProxy")) ) );
+
+
+/* Reference< XIServerProxy > xIS( xRet, UNO_QUERY );
+ if ( xIS.is() )
+ {
+ String aHost( xIS->getIServerHost() );
+
+// Reference < XInformationClient > xIC = xIS->createIServerClient( "XInformationClient" );
+ Reference < XInformationClient > xIC = xIS->createInformationClient();
+ xIC->getTree(OUString::createFromAscii("r:\\b_server\\config\\stand.lst"), OUString() );
+
+
+ Reference< XTypeProvider > xTP( xRet, UNO_QUERY );
+ Sequence < com::sun::star::uno::Type > s = xTP->getTypes();
+ }
+ */
+
+ if( xRet.is() )
+ {
+ Any aAny;
+ aAny <<= xRet;
+
+ SbxObjectRef xMySbxObj = GetSbUnoObject( CUniString("IServerProxy"), aAny );
+ if ( xMySbxObj.Is() )
+ pVar->PutObject( xMySbxObj );
+ }
+ // In Basic:
+ // msgbox dbg_SupportedInterfaces
+ // msgbox dbg_Properties
+ // msgbox dbg_Methods
+ }
+ break;
+ case ID_RemoteCommandDelay:
+ if ( rPar && rPar->Count() >= 2 && rPar->Count() <=3 )
+ {
+ switch (rPar->Get( 1 )->GetType())
+ {
+ case SbxLONG: // alles immer als Short �bertragen
+ case SbxULONG:
+ case SbxLONG64:
+ case SbxULONG64:
+ case SbxDOUBLE:
+ case SbxINTEGER:
+ case SbxBYTE:
+ case SbxUSHORT:
+ case SbxINT:
+ case SbxUINT:
+ case SbxSINGLE:
+ pImpl->nMinRemoteCommandDelay = rPar->Get( 1 )->GetULong();
+ if ( rPar->Count() == 3 )
+ pImpl->nMaxRemoteCommandDelay = rPar->Get( 2 )->GetULong();
+ else
+ pImpl->nMaxRemoteCommandDelay = pImpl->nMinRemoteCommandDelay;
+ break;
+ case SbxBOOL:
+ pImpl->bDoRemoteCommandDelay = rPar->Get( 1 )->GetBool();
+ break;
+ default:
+ SbxBase::SetError( SbxERR_WRONG_ARGS );
+ break;
+ }
+ }
+ else
+ SetError( SbxERR_WRONG_ARGS );
+ break;
+ case ID_GetApplicationPath:
+ if ( !rPar )
+ {
+ OUString aUrl = Config::GetDefDirectory();
+ OUString aPath;
+ osl::FileBase::getSystemPathFromFileURL( aUrl, aPath );
+ pVar->PutString( String( aPath ) );
+ }
+ else
+ SetError( SbxERR_WRONG_ARGS );
+ break;
+ case ID_GetCommonApplicationPath:
+ if ( !rPar )
+ {
+#ifdef WNT
+ //////// adapted this from setup2\win\source\system\winos.cxx
+ String aSysPath;
+ aSysPath = _SHGetSpecialFolder_COMMON_APPDATA();
+ if ( aSysPath.Len() )
+ {
+ pVar->PutString( aSysPath );
+ }
+ else // default to ID_GetApplicationPath (same as in setup)
+ {
+ OUString aUrl = Config::GetDefDirectory();
+ OUString aPath;
+ osl::FileBase::getSystemPathFromFileURL( aUrl, aPath );
+ pVar->PutString( String( aPath ) );
+ }
+#elif defined OS2
+ {
+ char* etc = getenv("ETC");
+ if (etc)
+ pVar->PutString( CUniString( etc ) );
+ else
+ pVar->PutString( CUniString( "/etc" ) );
+ }
+#else
+#if UNX
+ pVar->PutString( CUniString( "/etc" ) );
+#else
+#error not implemented
+#endif
+#endif
+ }
+ else
+ SetError( SbxERR_WRONG_ARGS );
+ break;
+ case ID_MakeIniFileName:
+ if ( rPar && rPar->Count() == 2 )
+ {
+ OUString aUrl = Config::GetConfigName( String(), rPar->Get( 1 )->GetString() );
+ OUString aPath;
+ osl::FileBase::getSystemPathFromFileURL( aUrl, aPath );
+ pVar->PutString( String( aPath ) );
+ }
+ else
+ SetError( SbxERR_WRONG_ARGS );
+ break;
+ case ID_Wait:
+ {
+ if( rPar && rPar->Count() == 2 )
+ {
+ long nWait = rPar->Get(1)->GetLong();
+ if( nWait >= 0 )
+ {
+#ifdef DEBUG
+ Time aStart;
+#endif
+ Timer aTimer;
+ aTimer.SetTimeout( nWait );
+ aTimer.Start();
+ while ( aTimer.IsActive() )
+ Application::Yield();
+#ifdef DEBUG
+ Time aEnd;
+ Time aDiff = aEnd - aStart;
+ long aMS = long( aDiff.GetMSFromTime() );
+ if ( Abs( aMS - nWait ) > 100 )
+ {
+ DBG_ERROR1("Wait was off limit by %i", aDiff.GetMSFromTime() - nWait );
+ }
+#endif
+ }
+ }
+ else
+ SetError( SbERR_BAD_NUMBER_OF_ARGS );
+ }
+ break;
+ case ID_GetErrorCount:
+ {
+ pVar->PutULong( pImpl->nErrorCount );
+ }
+ break;
+ case ID_GetWarningCount:
+ {
+ pVar->PutULong( pImpl->nWarningCount );
+ }
+ break;
+ case ID_GetQAErrorCount:
+ {
+ pVar->PutULong( pImpl->nQAErrorCount );
+ }
+ break;
+ case ID_GetUseFileWarningCount:
+ {
+ pVar->PutULong( pImpl->nIncludeFileWarningCount );
+ }
+ break;
+ case ID_GetErrorList:
+ {
+ if ( ! pImpl->xErrorList->GetDims() )
+ pImpl->xErrorList->AddDim( 1, 32000 );
+ pVar->PutObject( pImpl->xErrorList );
+ }
+ break;
+ case ID_GetWarningList:
+ {
+ if ( ! pImpl->xWarningList->GetDims() )
+ pImpl->xWarningList->AddDim( 1, 32000 );
+ pVar->PutObject( pImpl->xWarningList );
+ }
+ break;
+ case ID_GetQAErrorList:
+ {
+ if ( ! pImpl->xQAErrorList->GetDims() )
+ pImpl->xQAErrorList->AddDim( 1, 32000 );
+ pVar->PutObject( pImpl->xQAErrorList );
+ }
+ break;
+ case ID_GetUseFileWarningList:
+ {
+ if ( ! pImpl->xIncludeFileWarningList->GetDims() )
+ pImpl->xIncludeFileWarningList->AddDim( 1, 32000 );
+ pVar->PutObject( pImpl->xIncludeFileWarningList );
+ }
+ break;
+ case ID_GetTestCaseName:
+ {
+ pVar->PutString( pImpl->aTestCaseName );
+ }
+ break;
+ case ID_GetTestCaseFileName:
+ {
+ pVar->PutString( pImpl->aTestCaseFileName );
+ }
+ break;
+ case ID_GetTestCaseLineNr:
+ {
+ pVar->PutUShort( pImpl->nTestCaseLineNr );
+ }
+ break;
+ case ID_SetChildEnv:
+ {
+ if( rPar && rPar->Count() == 3 )
+ {
+ pImpl->pChildEnv->erase( rPar->Get(1)->GetString() );
+ pImpl->pChildEnv->insert( EnvironmentVariable( rPar->Get(1)->GetString(), rPar->Get(2)->GetString() ) );
+ }
+ else
+ SetError( SbERR_BAD_NUMBER_OF_ARGS );
+ }
+ break;
+ case ID_GetChildEnv:
+ {
+ if( rPar && rPar->Count() == 2 )
+ {
+ Environment::const_iterator aIter = pImpl->pChildEnv->find( rPar->Get(1)->GetString() );
+ if ( aIter != pImpl->pChildEnv->end() )
+ pVar->PutString( (*aIter).second );
+ else
+ pVar->PutString( String() );
+ }
+ else
+ SetError( SbERR_BAD_NUMBER_OF_ARGS );
+ }
+ break;
+ case ID_GetLinkDestination:
+ {
+ if( rPar && rPar->Count() == 2 )
+ {
+ String aSource,aDest;
+ aSource = rPar->Get(1)->GetString();
+#ifdef UNX
+ ByteString aByteSource( aSource, osl_getThreadTextEncoding() );
+ char cDest[1024];
+ int nLen = 0;
+ if ( ( nLen = readlink( aByteSource.GetBuffer(), cDest, sizeof(cDest) ) ) >= 0 )
+ {
+ aDest = String( cDest, nLen, osl_getThreadTextEncoding() );
+ }
+ else
+ {
+ int nErr = errno;
+ switch ( nErr )
+ {
+ case EINVAL: aDest = aSource;
+ break;
+ default:
+ SetError( SbERR_ACCESS_ERROR );
+ }
+ }
+#else
+ aDest = aSource;
+#endif
+ pVar->PutString( aDest );
+ }
+ else
+ SetError( SbERR_BAD_NUMBER_OF_ARGS );
+ }
+ break;
+ case ID_GetRegistryValue:
+ {
+ if( rPar && rPar->Count() == 3 )
+ {
+ String aValue;
+#ifdef WNT
+ aValue = ReadRegistry( rPar->Get(1)->GetString(), rPar->Get(2)->GetString() );
+#endif
+ pVar->PutString( aValue );
+ }
+ else
+ SetError( SbERR_BAD_NUMBER_OF_ARGS );
+ }
+ break;
+ case ID_HTTPSend:
+ {
+ if( rPar && ( rPar->Count() == 4 || rPar->Count() == 5 ) )
+ {
+ if ( !pImpl->pHttpRequest )
+ pImpl->pHttpRequest = new HttpRequest;
+ pImpl->pHttpRequest->SetRequest( ByteString( rPar->Get(1)->GetString(), RTL_TEXTENCODING_ASCII_US ), ByteString( rPar->Get(2)->GetString(), RTL_TEXTENCODING_ASCII_US ), rPar->Get(3)->GetUShort() );
+
+ if ( pImpl->pHttpRequest->Execute() )
+ {
+ if ( rPar->Count() == 5 )
+ { // filename is given
+ SvFileStream aDestination( rPar->Get(4)->GetString(), STREAM_STD_READWRITE | STREAM_TRUNC );
+ (*(pImpl->pHttpRequest->GetBody())) >> aDestination;
+ if ( aDestination.GetError() != ERRCODE_NONE )
+ SetError( SbERR_ACCESS_ERROR );
+ aDestination.Close();
+ }
+ pVar->PutUShort( pImpl->pHttpRequest->GetResultId() );
+ }
+ else
+ SetError( SbERR_ACCESS_ERROR );
+ }
+ else
+ SetError( SbERR_BAD_NUMBER_OF_ARGS );
+ }
+ break;
+ case ID_HTTPSetProxy:
+ {
+ if( rPar && rPar->Count() == 3 )
+ {
+ if ( !pImpl->pHttpRequest )
+ pImpl->pHttpRequest = new HttpRequest;
+ pImpl->pHttpRequest->SetProxy( ByteString( rPar->Get(1)->GetString(), RTL_TEXTENCODING_ASCII_US ), rPar->Get(2)->GetUShort() );
+ }
+ else
+ SetError( SbERR_BAD_NUMBER_OF_ARGS );
+ }
+ break;
+ } // switch( nHintUserData )
+ } // if( nHintId == SBX_HINT_DATAWANTED )
+ else if( nHintId == SBX_HINT_DATACHANGED )
+ {
+ switch( nHintUserData )
+ {
+ case ID_AutoExecute:
+ if ( !rPar ) // rPar = NULL <=> Kein Parameter
+ {
+ SingleCommandBlock = pVar->GetBool();
+ if ( SingleCommandBlock )
+ EndBlock();
+ else
+ BeginBlock();
+ }
+ else
+ SetError( SbxERR_WRONG_ARGS );
+ break;
+ case ID_EnableQaErrors:
+ if ( !rPar ) // rPar = NULL <=> Kein Parameter
+ pImpl->bEnableQaErrors = pVar->GetBool();
+ else
+ SetError( SbxERR_WRONG_ARGS );
+ break;
+ }
+ } // if( nHintId == SBX_HINT_DATACHANGED )
+ else if( nHintId == SBX_HINT_BASICSTART )
+ {
+ pImpl->nErrorCount = 0;
+ pImpl->nWarningCount = 0;
+ pImpl->nQAErrorCount = 0;
+ pImpl->nIncludeFileWarningCount = 0;
+
+ pImpl->xErrorList->SbxArray::Clear(); // call SbxArray::Clear because SbxVarArray::Clear only clears dimensions but no content
+ pImpl->xWarningList->SbxArray::Clear(); // call SbxArray::Clear because SbxVarArray::Clear only clears dimensions but no content
+ pImpl->xQAErrorList->SbxArray::Clear(); // call SbxArray::Clear because SbxVarArray::Clear only clears dimensions but no content
+ pImpl->xIncludeFileWarningList->SbxArray::Clear(); // call SbxArray::Clear because SbxVarArray::Clear only clears dimensions but no content
+
+ if (pFehlerListe)
+ delete pFehlerListe;
+ pFehlerListe = new CErrors;
+
+ for (sal_uInt16 i=0;i<VAR_POOL_SIZE;i++)
+ {
+ pImpl->pMyVars[i]->SetName( CUniString("VarDummy").Append(UniString::CreateFromInt32(i)) );
+ }
+ nMyVar = 0;
+
+ } // if( nHintId == SBX_HINT_BASICSTART )
+ else if( nHintId == SBX_HINT_BASICSTOP )
+ {
+ // Log summary to journal
+ ADD_CASE_LOG( String() ); // Case abschliessen
+ ADD_MESSAGE_LOG( CUniString("***************************************************") );
+ if ( pImpl->nErrorCount )
+ {
+ ADD_WARNING_LOG( GEN_RES_STR1( S_ERRORS_DETECTED, String::CreateFromInt32( pImpl->nErrorCount ) ) );
+ pImpl->nWarningCount--; // Anpassen, da diese Warnung nicht in die Statistik soll
+ }
+ else
+ ADD_MESSAGE_LOG( GEN_RES_STR0( S_NO_ERRORS_DETECTED ) );
+
+ if ( pImpl->nWarningCount )
+ ADD_WARNING_LOG( GEN_RES_STR1( S_WARNINGS_DETECTED, String::CreateFromInt32( pImpl->nWarningCount ) ) )
+ else
+ ADD_MESSAGE_LOG( GEN_RES_STR0( S_NO_WARNINGS_DETECTED ) );
+
+ if ( pImpl->nIncludeFileWarningCount )
+ ADD_WARNING_LOG( GEN_RES_STR1( S_INCLUDE_FILE_WARNINGS_DETECTED, String::CreateFromInt32( pImpl->nIncludeFileWarningCount ) ) )
+ else
+ ADD_MESSAGE_LOG( GEN_RES_STR0( S_NO_INCLUDE_FILE_WARNINGS_DETECTED ) );
+ ADD_MESSAGE_LOG( CUniString("***************************************************") );
+
+ pImpl->nErrorCount = 0;
+ pImpl->nWarningCount = 0;
+ pImpl->nQAErrorCount = 0;
+ pImpl->nIncludeFileWarningCount = 0;
+
+ pImpl->xErrorList->SbxArray::Clear(); // call SbxArray::Clear because SbxVarArray::Clear only clears dimensions but no content
+ pImpl->xWarningList->SbxArray::Clear(); // call SbxArray::Clear because SbxVarArray::Clear only clears dimensions but no content
+ pImpl->xQAErrorList->SbxArray::Clear(); // call SbxArray::Clear because SbxVarArray::Clear only clears dimensions but no content
+ pImpl->xIncludeFileWarningList->SbxArray::Clear(); // call SbxArray::Clear because SbxVarArray::Clear only clears dimensions but no content
+ } // if( nHintId == SBX_HINT_BASICSTOP )
+ WaitForAnswer();
+ if ( IsError() && ( !IS_ERROR() || GET_ERROR()->nError != GetError() ) )
+ {
+ ((StarBASIC*)GetParent())->MakeErrorText(GetError(),String());
+ ADD_ERROR_QUIET(GetError(),String(pVar->GetName()).AppendAscii(": ").
+ Append(((StarBASIC*)GetParent())->GetErrorText()));
+ }
+ }
+}
+
+void TestToolObj::DebugFindNoErrors( sal_Bool bDebugFindNoErrors )
+{
+ pImpl->bDebugFindNoErrors = bDebugFindNoErrors;
+}
+
+SbxVariable* TestToolObj::Find( const String& aStr, SbxClassType aType)
+{
+ if ( BasicRuntimeAccess::IsRunInit() ) // wegen Find im "Global" Befehl des Basic
+ return NULL;
+
+ SbxVariableRef Old = SbxObject::Find(aStr, aType );
+ // do not return any objects from pMyVars[]
+ if (Old && Old->GetUserData() != ID_Dispatch
+ && Old->GetUserData() != ID_UNODispatch
+ && Old->GetUserData() != ID_ErrorDummy
+ && Old->GetUserData() != 0 )
+ return Old;
+ else if ( aStr.SearchAscii(":") != STRING_NOTFOUND )
+ { // ignore qualified names e.g. main:FormWizard If this was removed an error would be generated
+ }
+ else
+ {
+
+ sal_uInt16 nElement;
+ ControlDef *pWhatName = new ControlDef(aStr,rtl::OString());
+
+ /// nach Controls suchen
+ if (m_pNameKontext && m_pNameKontext->Seek_Entry(pWhatName,&nElement))
+ {
+ delete pWhatName;
+ pWhatName = ((ControlDef*)m_pNameKontext->GetObject(nElement));
+
+//// new Controls Object every time
+ pImpl->pControlsObj = new Controls( pWhatName->pData->Kurzname );
+ pImpl->pControlsObj->SetType( SbxOBJECT );
+ pImpl->pControlsObj->ChangeListener( this );
+
+
+ // Will be set on method-child further down
+ // FIXME: HELPID
+ #if 0
+ if ( pWhatName->pData->aUId.HasNumeric() )
+ pImpl->pControlsObj->SetUserData( ID_Control );
+ else
+ #endif
+ pImpl->pControlsObj->SetUserData( ID_StringControl );
+
+ pShortNames->Insert(pWhatName->pData->Kurzname,pWhatName->pData->aUId,nSequence);
+
+ SbxVariable *pMember = pImpl->pControlsObj->Find(CUniString("ID"),SbxCLASS_DONTCARE);
+ if ( pMember == NULL )
+ {
+ SbxProperty* pID = new SbxProperty(CUniString("ID"),SbxVARIANT);
+ pImpl->pControlsObj->Insert(pID);
+ pImpl->pControlsObj->SetDfltProperty(pID);
+ pMember = pID;
+ }
+ // FIXME: HELPID
+ #if 0
+ if ( pWhatName->pData->aUId.HasNumeric() )
+ pMember->PutULong(pWhatName->pData->aUId.GetNum());
+ else
+ pMember->PutString(pWhatName->pData->aUId.GetStr());
+ #endif
+
+ pMember = pImpl->pControlsObj->Find(CUniString("name"),SbxCLASS_DONTCARE);
+ if ( pMember != NULL )
+ pMember->PutString(pWhatName->pData->Kurzname);
+
+ return pImpl->pControlsObj;
+ }
+
+ /// Nach slots suchen
+ if (m_pSIds && m_pSIds->Seek_Entry(pWhatName,&nElement))
+ {
+ SbxTransportMethodRef pMyVar;
+ pMyVar = pImpl->pMyVars[nMyVar++];
+ if ( nMyVar >= VAR_POOL_SIZE )
+ nMyVar = 0;
+ delete pWhatName;
+ pWhatName = ( (ControlDef*)m_pSIds->GetObject( nElement ) );
+ pMyVar->SetName( pWhatName->pData->Kurzname );
+
+ // FIXME: HELPID
+ #if 0
+ if ( pWhatName->pData->aUId.HasNumeric() )
+ {
+ pMyVar->SetUserData( ID_Dispatch );
+ pMyVar->nValue = pWhatName->pData->aUId.GetNum();
+ pShortNames->Insert( aStr, pWhatName->pData->aUId, nSequence );
+ }
+ else
+ {
+ pMyVar->SetUserData( ID_UNODispatch );
+ pMyVar->aUnoSlot = pWhatName->pData->aUId.GetStr();
+ }
+ #endif
+ return pMyVar;
+ }
+
+ /// es kann sich noch um eine SlotID handeln, die numerisch abgefragt wird, statt ausgef�hrt zu werden
+ if ( aStr.Copy( aStr.Len()-3, 3 ).CompareIgnoreCaseToAscii("_ID") == COMPARE_EQUAL && m_pSIds )
+ {
+ delete pWhatName;
+ pWhatName = new ControlDef( aStr.Copy( 0, aStr.Len()-3 ), rtl::OString() );
+ if ( m_pSIds->Seek_Entry( pWhatName, &nElement ) )
+ { // Nach slots suchen
+ SbxVariable *pReturn = new SbxVariable;
+ delete pWhatName;
+ pWhatName = ( (ControlDef*)m_pSIds->GetObject( nElement ) );
+ pReturn->SetName( pWhatName->pData->Kurzname );
+
+ // FIXME: HELPID
+ #if 0
+ if ( pWhatName->pData->aUId.HasNumeric() )
+ pReturn->PutULong(pWhatName->pData->aUId.GetNum());
+ else
+ pReturn->PutString(pWhatName->pData->aUId.GetStr());
+ #endif
+ return pReturn;
+ }
+ }
+ if ( !pImpl->bDebugFindNoErrors )
+ {
+ ADD_ERROR(SbxERR_PROC_UNDEFINED,GEN_RES_STR1(S_UNKNOWN_SLOT_CONTROL, aStr) );
+ }
+ }
+ return NULL;
+}
+
+String TestToolObj::GetRevision( String const &aSourceIn )
+{
+ // search $Revision: 1.40 $
+ xub_StrLen nPos;
+ if ( ( nPos = aSourceIn.SearchAscii( "$Revision:" ) ) != STRING_NOTFOUND )
+ return aSourceIn.Copy( nPos+ 10, aSourceIn.SearchAscii( "$", nPos+10 ) -nPos-10);
+ else
+ return String::CreateFromAscii("No Revision found");
+}
+
+sal_Bool TestToolObj::CError( sal_uLong code, const String& rMsg, xub_StrLen l, xub_StrLen c1, xub_StrLen c2 )
+{
+ bWasPrecompilerError = sal_True;
+ if ( aCErrorHdl.IsSet() )
+ {
+ ErrorEntry aErrorEntry( code, rMsg, l, c1, c2 );
+ return (sal_Bool)aCErrorHdl.Call( &aErrorEntry );
+ }
+ else
+ {
+ ADD_ERROR( code, rMsg )
+ return sal_True;
+ }
+}
+
+void TestToolObj::CalcPosition( String const &aSource, xub_StrLen nPos, xub_StrLen &l, xub_StrLen &c )
+{
+ l = 1;
+ xub_StrLen nAkt = 0;
+ xub_StrLen nNext;
+ while ( (nNext = aSource.Search( '\n', nAkt )) != STRING_NOTFOUND && nNext < nPos )
+ {
+ l++;
+ nAkt = nNext+1;
+ }
+ c = nPos - nAkt;
+}
+
+
+#define CATCH_LABEL CUniString( "ctch" )
+#define CATCHRES_LABEL CUniString( "ctchres" )
+#define ENDCATCH_LABEL CUniString( "endctch" )
+
+sal_Bool IsAlphaChar( sal_Unicode cChar )
+{
+ return ( cChar >= 'a' && cChar <= 'z' ) ||
+ ( cChar >= 'A' && cChar <= 'Z' );
+}
+
+sal_Bool IsInsideString( const String& aSource, const xub_StrLen nStart )
+{
+ sal_Bool bInside = sal_False;
+ xub_StrLen nPos = nStart-1;
+
+ while ( nPos && aSource.GetChar(nPos) != _CR && aSource.GetChar(nPos) != _LF )
+ {
+ if ( aSource.GetChar(nPos) == '"' )
+ bInside = !bInside;
+ nPos--;
+ }
+ return bInside;
+}
+
+sal_Bool IsValidHit( const String& aSource, const xub_StrLen nStart, const xub_StrLen nEnd )
+{
+ return !IsAlphaChar( aSource.GetChar(nStart-1) ) && !IsAlphaChar( aSource.GetChar(nEnd+1))
+ && !IsInsideString( aSource, nStart );
+}
+
+
+xub_StrLen TestToolObj::ImplSearch( const String &aSource, const xub_StrLen nStart, const xub_StrLen nEnd, const String &aSearch, const xub_StrLen nSearchStart )
+{
+ xub_StrLen nPos = aSource.Search( aSearch, std::max( nSearchStart, nStart ) );
+ if ( nPos > nEnd - aSearch.Len() || nPos == STRING_NOTFOUND )
+ return STRING_NOTFOUND;
+ else
+ {
+ if ( IsValidHit( aSource, nPos, nPos+aSearch.Len()-1 ) )
+ return nPos;
+ else
+ return ImplSearch( aSource, nStart, nEnd, aSearch, nPos+aSearch.Len() );
+ }
+}
+
+xub_StrLen TestToolObj::PreCompilePart( String &aSource, xub_StrLen nStart, xub_StrLen nEnd, String aFinalErrorLabel, sal_uInt16 &nLabelCount )
+{
+ xub_StrLen nTry,nCatch,nEndcatch;
+ if( (nTry = ImplSearch( aSource, nStart, nEnd, CUniString("try"), nStart )) == STRING_NOTFOUND )
+ return nEnd;
+ if ( (nCatch = ImplSearch( aSource, nStart, nEnd, CUniString("catch"), nTry )) == STRING_NOTFOUND )
+ {
+ xub_StrLen l,c;
+ CalcPosition( aSource, nTry, l, c );
+ CError( SbERR_BAD_BLOCK, CUniString("catch"), l, c, c+2 );
+ return nEnd;
+ }
+ if ( (nEndcatch = ImplSearch( aSource, nStart, nEnd, CUniString("endcatch"), nCatch )) == STRING_NOTFOUND )
+ {
+ xub_StrLen l,c;
+ CalcPosition( aSource, nCatch, l, c );
+ CError( SbERR_BAD_BLOCK, CUniString("endcatch"), l, c, c+4 );
+ return nEnd;
+ }
+
+ nLabelCount++;
+ String aStr = String::CreateFromInt32( nLabelCount );
+ String aCatchLabel(CATCH_LABEL);
+ aCatchLabel += aStr;
+ String aCatchresLabel(CATCHRES_LABEL);
+ aCatchresLabel += aStr;
+ String aEndcatchLabel( ENDCATCH_LABEL);
+ aEndcatchLabel += aStr;
+
+ xub_StrLen nTry2 = 0;
+ while ( !WasPrecompilerError() && (nTry2 = ImplSearch( aSource, nStart, nEnd, CUniString("try"), nTry+1 )) != STRING_NOTFOUND )
+ { // Wir rekursieren erstmal mit dem 2. Try
+ if ( nTry2 < nCatch )
+ nEnd += PreCompilePart( aSource, nTry2, nEndcatch+8, aCatchLabel, nLabelCount ) - nEndcatch-8;
+ else
+ nEnd = PreCompilePart( aSource, nTry2, nEnd, aFinalErrorLabel, nLabelCount );
+
+ if ( (nCatch = ImplSearch( aSource, nStart, nEnd, CUniString("catch"), nTry )) == STRING_NOTFOUND )
+ {
+ xub_StrLen l,c;
+ CalcPosition( aSource, nTry, l, c );
+ CError( SbERR_BAD_BLOCK, CUniString("catch"), l, c, c+2 );
+ return nEnd;
+ }
+ if ( (nEndcatch = ImplSearch( aSource, nStart, nEnd, CUniString("endcatch"), nCatch )) == STRING_NOTFOUND )
+ {
+ xub_StrLen l,c;
+ CalcPosition( aSource, nCatch, l, c );
+ CError( SbERR_BAD_BLOCK, CUniString("endcatch"), l, c, c+4 );
+ return nEnd;
+ }
+ }
+
+ String aReplacement;
+ int nTotalLength = -3 -5 -8; // try, catch und endcatch fallen raus
+
+ aReplacement.AppendAscii( "on error goto " );
+ aReplacement += aCatchLabel;
+ aSource.SearchAndReplaceAscii( "try", aReplacement, nTry );
+ nTotalLength += aReplacement.Len();
+
+
+// on error goto endcse
+// goto endctchXX
+// ctchXX:
+// if err = 35 or err = 18 then : resume : endif :
+// MaybeAddErr
+// on error goto endcse
+// resume ctchresXX
+// ctchresXX:
+ aReplacement.Erase();
+ aReplacement.AppendAscii( "on error goto " );
+ aReplacement += aFinalErrorLabel;
+ aReplacement.AppendAscii( " : goto " );
+ aReplacement += aEndcatchLabel;
+ aReplacement.AppendAscii( " : " );
+ aReplacement += aCatchLabel;
+ aReplacement.AppendAscii( ": if err = 35 or err = 18 then : on error goto 0 : resume : endif" );
+ aReplacement.AppendAscii( " : MaybeAddErr : on error goto " );
+ aReplacement += aFinalErrorLabel;
+ aReplacement.AppendAscii( " : resume " );
+ aReplacement += aCatchresLabel;
+ aReplacement.AppendAscii( " : " );
+ aReplacement += aCatchresLabel;
+ aReplacement.AppendAscii( ": " );
+ aSource.SearchAndReplaceAscii( "catch", aReplacement, nCatch );
+ nTotalLength += aReplacement.Len();
+
+
+ aReplacement.Erase();
+ aReplacement.AppendAscii("ClearError : ");
+ aReplacement += aEndcatchLabel;
+ aReplacement.AppendAscii(": ");
+ aSource.SearchAndReplaceAscii( "endcatch", aReplacement, nEndcatch );
+ nTotalLength += aReplacement.Len();
+
+ if ( aSource.Len() >= STRING_MAXLEN )
+ {
+ xub_StrLen l,c;
+ CalcPosition( aSource, nEndcatch, l, c );
+ CError( SbERR_PROG_TOO_LARGE, CUniString("endcatch"), l, c, c+2 );
+ }
+
+ return xub_StrLen( nEnd + nTotalLength );
+}
+
+
+void TestToolObj::PreCompileDispatchParts( String &aSource, String aStart, String aEnd, String aFinalLable )
+{
+ sal_uInt16 nLabelCount = 0;
+ xub_StrLen nPartPos = 0;
+
+ while ( !WasPrecompilerError() && (nPartPos = ImplSearch( aSource, nPartPos, aSource.Len(), aStart )) != STRING_NOTFOUND )
+ {
+ xub_StrLen nEndPart = ImplSearch( aSource, nPartPos, aSource.Len(), aEnd );
+ if ( nEndPart == STRING_NOTFOUND )
+ return;
+ nPartPos = PreCompilePart( aSource, nPartPos, nEndPart, aFinalLable, nLabelCount );
+ nPartPos = nPartPos + aEnd.Len();
+ }
+}
+
+
+sal_Bool TestToolObj::WasPrecompilerError()
+{
+ return bWasPrecompilerError;
+}
+
+String TestToolObj::PreCompile( String const &aSourceIn )
+{
+ // Im CTOR zu fr�h, und hier grade nicg rechtzeitig. Start und Stop von Programmausf�hrung
+ StartListening( ((StarBASIC*)GetParent())->GetBroadcaster(), sal_True );
+
+ xub_StrLen nTestCase;
+ xub_StrLen nEndCase;
+ xub_StrLen nStartPos = 0;
+ String aSource(aSourceIn);
+ bWasPrecompilerError = sal_False;
+
+HACK("Ich gestehe alles: Ich war zu faul das richtig zu machen.")
+ aSource = String(' ').Append( aSource ); // Da Schl�sselworte an Position 0 sonst nicht gefunden werden
+
+
+// Erstmal alle "'" Kommentare raus
+
+ xub_StrLen nComment;
+ while ( (nComment = aSource.SearchAscii("'",nStartPos)) != STRING_NOTFOUND )
+ {
+ sal_uInt16 nStringEndCount = 0;
+ xub_StrLen nIndex = nComment;
+ while ( nIndex && aSource.GetChar(nIndex) != '\n' )
+ {
+ if ( aSource.GetChar(nIndex) == '"' )
+ nStringEndCount++;
+ nIndex--;
+ }
+ if ( (nStringEndCount & 1) == 0 ) // Wir waren also nicht innerhalb eines Strings
+ {
+ xub_StrLen nComEnd = aSource.SearchAscii("\n",nComment);
+
+ while ( aSource.GetChar(nComEnd) == _CR || aSource.GetChar(nComEnd) == _LF )
+ nComEnd--;
+
+ nComEnd++;
+
+ aSource.Erase(nComment,nComEnd-nComment);
+ }
+ else
+ nComment++;
+ nStartPos = nComment;
+ }
+
+
+ PreCompileDispatchParts( aSource, CUniString("sub"), CUniString("end sub"), CUniString("0") );
+ PreCompileDispatchParts( aSource, CUniString("function"), CUniString("end function"), CUniString("0") );
+ PreCompileDispatchParts( aSource, CUniString("testcase"), CUniString("endcase"), CUniString("endcse") );
+
+
+ xub_StrLen nMainPos = ImplSearch( aSource, 0, aSource.Len(), CUniString("sub main") );
+ aSource.SearchAndReplaceAscii("sub main",CUniString("Sub Main StartUse : LoadIncludeFiles : FinishUse "), nMainPos );
+ if ( aSource.Len() >= STRING_MAXLEN )
+ {
+ xub_StrLen l,c;
+ CalcPosition( aSource, nMainPos, l, c );
+ CError( SbERR_PROG_TOO_LARGE, CUniString("endcatch"), l, c, c+2 );
+ }
+
+ while ( (nTestCase = ImplSearch( aSource, 0, aSource.Len(), CUniString("testcase") ) ) != STRING_NOTFOUND )
+ {
+ xub_StrLen nTcEnd = aSource.SearchAscii("\n",nTestCase);
+
+ while ( aSource.GetChar(nTcEnd) == _CR || aSource.GetChar(nTcEnd) == _LF )
+ nTcEnd--;
+
+ nTcEnd++;
+
+ if ( aSource.SearchAscii(":",nTestCase) < nTcEnd )
+ nTcEnd = aSource.SearchAscii(":",nTestCase) -1;
+ String aSuffix = aSource.Copy(nTestCase+8,nTcEnd-nTestCase-8);
+ sal_uInt16 nOldLen;
+ do
+ {
+ nOldLen = aSuffix.Len();
+ aSuffix.EraseLeadingAndTrailingChars( ' ' );
+ aSuffix.EraseLeadingAndTrailingChars( 0x09 );
+ } while ( nOldLen != aSuffix.Len() );
+ aSource.Erase(nTestCase,nTcEnd-nTestCase);
+ aSource.Insert(CUniString("Sub ").Append(aSuffix).AppendAscii(" CaseLog \"").Append(aSuffix).AppendAscii("\" : on error goto endcse : TestEnter "),nTestCase);
+ }
+
+ /////////////////////////////////////////////////////////////////////////////////////////////////////////
+ // Attention!!! The lable endsub is officially used to exit a sub instead of using 'exit sub' or 'return'
+ /////////////////////////////////////////////////////////////////////////////////////////////////////////
+ while ( (nEndCase = ImplSearch( aSource, 0, aSource.Len(), CUniString("endcase") ) ) != STRING_NOTFOUND )
+ aSource.SearchAndReplaceAscii("endcase",CUniString("goto endsub : endcse: if ( err = 35 and StopOnSyntaxError ) or err = 18 then : on error goto 0 : resume : endif : MaybeAddErr : ExceptLog : resume endcse_res : endcse_res: on error goto 0 : endsub: TestExit : ClearError : CaseLog \"\" : end sub "), nEndCase );
+
+ if ( aSource.Len() >= STRING_MAXLEN )
+ {
+ xub_StrLen l,c;
+ CalcPosition( aSource, 0, l, c );
+ CError( SbERR_PROG_TOO_LARGE, CUniString("endcatch"), l, c, c+2 );
+ }
+ return aSource;
+}
+
+void TestToolObj::AddToListByNr( CNames *&pControls, ControlItemUId *&pNewItem )
+{
+ sal_uInt16 nNr;
+ if ( pControls->Seek_Entry( pNewItem, &nNr ) )
+ {
+ AddName( pControls->GetObject(nNr)->pData->Kurzname, pNewItem->pData->Kurzname );
+ delete pNewItem;
+ pNewItem = (ControlItemUId*)pControls->GetObject(nNr); // f�r einf�gen der S�hne
+ }
+ else
+ {
+ ControlItem* pNI = pNewItem;
+ pControls->C40_PTR_INSERT(ControlItem,pNI);
+ }
+}
+
+IMPL_LINK( TestToolObj, ReturnResultsLink, CommunicationLink*, pCommLink )
+{
+ return ReturnResults( pCommLink->GetServiceData() );
+}
+
+void TestToolObj::ReadHidLstByNumber()
+{
+ // Die Hid.Lst nach Nummern sortiert einlesen
+ if ( !m_pReverseUIds )
+ {
+ String aName = (pImpl->aHIDDir + DirEntry(CUniString("hid.lst"))).GetFull();
+
+ {
+ TTExecutionStatusHint aHint( TT_EXECUTION_SHOW_ACTION, String(SttResId(S_READING_LONGNAMES)), aName );
+ GetTTBroadcaster().Broadcast( aHint );
+ }
+
+ ReadFlat( aName, m_pReverseUIds, sal_False );
+
+ {
+ TTExecutionStatusHint aHint( TT_EXECUTION_HIDE_ACTION );
+ GetTTBroadcaster().Broadcast( aHint );
+ }
+ }
+}
+
+void TestToolObj::SortControlsByNumber( sal_Bool bIncludeActive )
+{
+ // Die Controls einmal hirarchisch und einmal alle flach nach nummer sortiert
+ if ( !m_pReverseControls && !m_pReverseControlsSon && m_pControls )
+ {
+ m_pReverseControls = new CNames;
+ m_pReverseControlsSon = new CNames;
+ sal_uInt16 nWin,nCont;
+ const String aSl('/');
+ for ( nWin = 0 ; nWin < m_pControls->Count() ; nWin++ )
+ {
+ String aFatherName( m_pControls->GetObject(nWin)->pData->Kurzname );
+ ControlItemUId *pNewFather = new ControlItemUIdSon(aFatherName,m_pControls->GetObject(nWin)->pData->aUId);
+ AddToListByNr( m_pReverseControlsSon, pNewFather );
+ if (! ((ControlItemUIdSon*)pNewFather)->GetSons() )
+ ((ControlItemUIdSon*)pNewFather)->Sons( new CNames );
+
+ // Existieren S�hne, diese in beide Listen eintragen
+ CNames *pControlList = ((ControlItemSon*)m_pControls->GetObject(nWin))->GetSons();
+ if ( pControlList )
+ for ( nCont = 0 ; nCont < pControlList->Count() ; nCont++ )
+ {
+ ControlItemUId *pNewItem;
+
+ String aCombinedName( aFatherName );
+ aCombinedName.AppendAscii( ":" );
+ aCombinedName.Append( pControlList->GetObject(nCont)->pData->Kurzname );
+ pNewItem = new ControlItemUId( aCombinedName, pControlList->GetObject(nCont)->pData->aUId );
+ AddToListByNr( m_pReverseControls, pNewItem );
+
+ pNewItem = new ControlItemUId( pControlList->GetObject(nCont)->pData->Kurzname, pControlList->GetObject(nCont)->pData->aUId );
+ AddToListByNr( ((ControlItemUIdSon*)pNewFather)->GetSons(), pNewItem );
+ }
+ }
+ if ( !bIncludeActive )
+ {
+ // FIXME: HELPID
+ ControlItem *pZeroItem = new ControlItemUId( UniString(), rtl::OString() );
+ sal_uInt16 nNr;
+ if ( m_pReverseControls->Seek_Entry( pZeroItem, &nNr ) )
+ {
+ m_pReverseControls->DeleteAndDestroy( nNr );
+// um VorlagenLaden/UntergeordneteIniDatei/SpeichernDlg/OrdnerDlg/OeffnenDlg/MessageBox/LetzteVersion/GrafikEinfuegenDlg/FarbeDlg/ExportierenDlg/DruckerEinrichten/DruckenDlg/DateiEinfuegenDlg/Active zu verhindern
+ }
+/* if ( m_pReverseControlsSon->Seek_Entry( pZeroItem, &nNr ) )
+ {
+ m_pReverseControlsSon->DeleteAndDestroy( nNr );
+// um VorlagenLaden/UntergeordneteIniDatei/SpeichernDlg/OrdnerDlg/OeffnenDlg/MessageBox/LetzteVersion/GrafikEinfuegenDlg/FarbeDlg/ExportierenDlg/DruckerEinrichten/DruckenDlg/DateiEinfuegenDlg/Active zu verhindern
+ }*/
+ delete pZeroItem;
+ }
+ }
+}
+
+
+sal_Bool TestToolObj::ReturnResults( SvStream *pIn )
+{
+
+ sal_uInt16 nId;
+ sal_uLong nClearSequence = 0;
+ sal_Bool bSequenceOK = sal_True;
+ CNames *pReverseControlsKontext = NULL;
+
+ CRetStream *pRetStream = new CRetStream(pIn);
+
+ pRetStream->Read( nId );
+ while( !pIn->IsEof() )
+ {
+ switch( nId )
+ {
+ case SIReturn:
+ {
+ sal_uInt16 nRet,nParams;
+ rtl::OString aUId;
+ pRetStream->Read(nRet);
+ if ( pRetStream->GetNextType() == BinString )
+ {
+ String aUStrId; // UniqueStringID Used for Mozilla Integration
+ pRetStream->Read( aUStrId );
+ // FIXME: HELPID
+ #if 0
+ aUId = rtl::OString( aUStrId );
+ #endif
+ }
+ else
+ {
+ comm_ULONG nUId;
+ pRetStream->Read( nUId ); // bei Sequence einfach die Sequence
+ // FIXME: HELPID
+ #if 0
+ aUId = rtl::OString( nUId );
+ #endif
+ }
+ pRetStream->Read(nParams);
+
+ sal_uInt16 nNr1 = 0;
+ comm_ULONG nLNr1 = 0;
+ String aString1;
+ sal_Bool bBool1 = sal_False;
+ SbxValueRef xValue1 = new SbxValue;
+
+ if( nParams & PARAM_USHORT_1 )
+ pRetStream->Read( nNr1 );
+ if( nParams & PARAM_ULONG_1 )
+ pRetStream->Read( nLNr1 );
+ if( nParams & PARAM_STR_1 )
+ {
+ pRetStream->Read( aString1 );
+ ReplaceNumbers ( aString1 );
+ }
+ else
+ aString1.Erase();
+ if( nParams & PARAM_BOOL_1 )
+ pRetStream->Read( bBool1 );
+ if( nParams & PARAM_SBXVALUE_1 )
+ pRetStream->Read( *xValue1 );
+ switch (nRet)
+ {
+ case RET_Sequence:
+ {
+ // FIXME: HELPID
+ #if 0
+ sal_uLong nUId = aUId.GetNum();
+ if ( nSequence != nUId )
+ {
+ bSequenceOK = sal_False;
+ ADD_ERROR(SbxERR_BAD_ACTION, GEN_RES_STR2(S_RETURN_SEQUENCE_MISSMATCH, String::CreateFromInt64(nUId), String::CreateFromInt64(nSequence)) );
+ }
+ else
+ {
+ nClearSequence = nUId;
+ }
+ #endif
+ }
+ break;
+ case RET_Value:
+ if ( pImpl->pNextReturn )
+ {
+// sal_uLong nHintUserData = pImpl->pNextReturn->GetParent()->GetUserData();
+// pImpl->pNextReturn->GetParent()->SetUserData(0);
+// if ( nUId == pImpl->pNextReturn->GetParent()->GetULong() )
+ if ( aNextReturnId.equals( aUId ) )
+ {
+ if( nParams & PARAM_ULONG_1 ) // FIXME this is to allow negative numbers, hoping that no large numbers are interpreted wrong. should have new PARAM_LONG_1 instead
+ {
+ if ( nLNr1 > 0x7fffffff )
+ pImpl->pNextReturn->PutLong( long(nLNr1 - 0xffffffff) -1 );
+ else
+ pImpl->pNextReturn->PutULong( nLNr1 );
+ }
+ if( nParams & PARAM_USHORT_1 ) pImpl->pNextReturn->PutUShort( nNr1 );
+ if( nParams & PARAM_STR_1 ) pImpl->pNextReturn->PutString( aString1 );
+ if( nParams & PARAM_BOOL_1 ) pImpl->pNextReturn->PutBool( bBool1 );
+ if( nParams & PARAM_SBXVALUE_1 ) // FIXME: allow generic datatype
+ {
+ SbxValues aValues( SbxDATE );
+ xValue1->Get( aValues );
+ pImpl->pNextReturn->Put( aValues );
+ }
+ }
+ else
+ {
+ ADD_ERROR(SbxERR_BAD_ACTION, GEN_RES_STR0(S_RETURNED_VALUE_ID_MISSMATCH) )
+ }
+// pImpl->pNextReturn->GetParent()->SetUserData(nHintUserData);
+ pImpl->pNextReturn = NULL;
+ }
+ else
+ {
+ ADD_ERROR(SbxERR_BAD_ACTION, GEN_RES_STR0(S_RETURNED_VALUE_NO_RECEIVER) )
+ }
+ break;
+ case RET_WinInfo:
+ {
+ if ( !m_pReverseControls && !m_pReverseControlsSon )
+ pReverseControlsKontext = NULL;
+
+ ReadHidLstByNumber();
+ SortControlsByNumber();
+
+ // Alle Slots nach Nummer Sortiert
+ if ( !m_pReverseSlots && m_pSIds )
+ {
+ m_pReverseSlots = new CNames;
+ sal_uInt16 nWin;
+ const String aSl('/');
+ for ( nWin = 0 ; nWin < m_pSIds->Count() ; nWin++ )
+ {
+ ControlItemUId *pNewItem = new ControlItemUId(m_pSIds->GetObject(nWin)->pData->Kurzname,m_pSIds->GetObject(nWin)->pData->aUId);
+ AddToListByNr( m_pReverseSlots, pNewItem );
+ }
+ }
+
+ WinInfoRec *pWinInfo = new WinInfoRec;
+ // FIXME: HELPID
+ #if 0
+ pWinInfo->aUId = aUId.GetText();
+ #endif
+ pWinInfo->nRType = (sal_uInt16)nLNr1; // just sal_uLong for Transport, data is always USHORT
+ pWinInfo->aRName = aString1;
+ pWinInfo->bIsReset = bBool1;
+ pWinInfo->aKurzname.Erase();
+ pWinInfo->aSlotname.Erase();
+
+ // eventuell den Kontext feststellen. Passiert nur beim ersten Eintrag nach reset
+ if ( !pReverseControlsKontext && m_pReverseControlsSon )
+ {
+ sal_uInt16 nNr;
+ ControlItem *pNewItem = new ControlItemUId( String(), aUId );
+ if ( m_pReverseControlsSon->Seek_Entry(pNewItem,&nNr) )
+ {
+ pReverseControlsKontext = ((ControlItemUIdSon*)m_pReverseControlsSon->GetObject(nNr))->GetSons();
+ pWinInfo->aKurzname = CUniString("*");
+ }
+ else
+ pReverseControlsKontext = m_pReverseControls;
+
+ delete pNewItem;
+ }
+
+ // Reset. Mu� nach bestimmen des Kontext stehen, da sonst mit dem reset-record
+ // der Kontext falsch gesetzt wird.
+ if ( pWinInfo->bIsReset )
+ pReverseControlsKontext = NULL; // Reihenfolge wichtig!
+
+
+ // Kurzname feststellen
+ if ( pReverseControlsKontext )
+ {
+ sal_uInt16 nNr;
+ ControlItem *pNewItem = new ControlItemUId( String(), aUId );
+ if ( pReverseControlsKontext->Seek_Entry(pNewItem,&nNr) )
+ {
+// rtl::OString aID = pReverseControlsKontext->GetObject(nNr)->pData->aUId;
+ pWinInfo->aKurzname += pReverseControlsKontext->GetObject(nNr)->pData->Kurzname;
+ }
+ delete pNewItem;
+ }
+
+ // Slotname feststellen
+ if ( m_pReverseSlots )
+ {
+ sal_uInt16 nNr;
+ ControlItem *pNewItem = new ControlItemUId( String(), aUId );
+ if ( m_pReverseSlots->Seek_Entry(pNewItem,&nNr) )
+ pWinInfo->aSlotname = m_pReverseSlots->GetObject(nNr)->pData->Kurzname;
+ delete pNewItem;
+ }
+
+ // Langname feststellen
+ // FIXME: HELPID
+ #if 0
+ if ( aUId.HasString() )
+ { // use the String ID since there is no LongName in hid.lst
+ pWinInfo->aLangname = aUId.GetStr();
+ }
+ else
+ {
+ if ( m_pReverseUIds )
+ {
+ sal_uInt16 nNr;
+ ControlItem *pNewItem = new ControlItemUId( String(), aUId );
+ if ( m_pReverseUIds->Seek_Entry(pNewItem,&nNr) )
+ pWinInfo->aLangname = m_pReverseUIds->GetObject(nNr)->pData->Kurzname;
+ delete pNewItem;
+ }
+ }
+ #endif
+
+ aWinInfoHdl.Call( pWinInfo );
+
+ delete pWinInfo;
+ }
+ break;
+ case RET_ProfileInfo:
+ {
+ // FIXME: HELPID
+ #if 0
+ sal_uLong nUId = aUId.GetNum();
+ if ( nParams & PARAM_STR_1 )
+ {
+ DirEntry FilePath = pImpl->aLogFileBase + DirEntry(DirEntry(aLogFileName).GetBase().AppendAscii(".prf"));
+ SvFileStream aStrm( FilePath.GetFull(), STREAM_STD_WRITE );
+ if( aStrm.IsOpen() )
+ {
+ aString1.ConvertLineEnd(LINEEND_CRLF);
+ aStrm.Seek(STREAM_SEEK_TO_END);
+ aStrm << ByteString( aString1, RTL_TEXTENCODING_UTF8 ).GetBuffer();
+ aStrm.Close();
+ }
+ }
+ if ( nParams & PARAM_ULONG_1 )
+ {
+ switch ( nUId )
+ {
+ case S_ProfileReset: // nLNr1 = Anzahl Borders
+ {
+ pImpl->nNumBorders = (sal_uInt16)nLNr1; // Borders are 0 to 4
+ sal_uInt16 i;
+ for ( i=0 ; i<4 ; i++ )
+ pImpl->naValBorders[i] = 0;
+
+ for ( i=0 ; i<5 ; i++ )
+ {
+ pImpl->naNumEntries[i] = 0;
+ pImpl->naRemoteTime[i] = 0;
+ pImpl->naLocalTime[i] = 0;
+ }
+ break;
+ }
+ case S_ProfileBorder1: // nLNr1 = Border1 in ms
+ case S_ProfileBorder2: // nLNr1 = Border2 in ms
+ case S_ProfileBorder3: // nLNr1 = Border3 in ms
+ case S_ProfileBorder4: // nLNr1 = Border4 in ms
+ {
+ pImpl->naValBorders[ nUId - S_ProfileBorder1 ] = nLNr1;
+ break;
+ }
+ case S_ProfileTime: // nLNr1 = remote Zeit des Befehls
+ {
+ sal_uInt16 i;
+ for ( i=0 ; i<pImpl->nNumBorders &&
+ pImpl->naValBorders[i] <= nLNr1 ; i++ ) {};
+
+ pImpl->naNumEntries[ i ]++;
+ pImpl->naRemoteTime[ i ] += nLNr1;
+ pImpl->naLocalTime[ i ] += Time::GetSystemTicks() - pImpl->LocalStarttime;
+
+ #if OSL_DEBUG_LEVEL > 1
+ if ( nLNr1 > (Time::GetSystemTicks() - pImpl->LocalStarttime) )
+ {
+ String aLine = CUniString("Testtoolzeit(").Append(String::CreateFromInt64(Time::GetSystemTicks() - pImpl->LocalStarttime)).AppendAscii(") kleiner Officezeit(").Append(String::CreateFromInt64(nLNr1)).AppendAscii(")\n");
+ DirEntry FilePath = pImpl->aLogFileBase + DirEntry(DirEntry(aLogFileName).GetBase().AppendAscii(".prf"));
+ SvFileStream aStrm( FilePath.GetFull(), STREAM_STD_WRITE );
+ if( aStrm.IsOpen() )
+ {
+ aLine.ConvertLineEnd(LINEEND_CRLF);
+ aStrm.Seek(STREAM_SEEK_TO_END);
+ aStrm << ByteString( aLine, RTL_TEXTENCODING_UTF8 ).GetBuffer();
+ aStrm.Close();
+ }
+ }
+ #endif
+
+ break;
+ }
+ case S_ProfileDump: // Gibt die daten aus.
+ {
+ if ( pImpl->nNumBorders == 0 ) // Also keine alte R�ckmeldung vom Office
+ break;
+ DirEntry FilePath = pImpl->aLogFileBase + DirEntry(DirEntry(aLogFileName).GetBase().AppendAscii(".prf"));
+ SvFileStream aStrm( FilePath.GetFull(), STREAM_STD_WRITE );
+ if( aStrm.IsOpen() )
+ {
+ String aProfile;
+ sal_uInt16 i;
+
+ aProfile += String().Expand(15);
+ for ( i=0 ; i<pImpl->nNumBorders ; i++ )
+ aProfile += (CUniString("< ").Append(String::CreateFromInt64(pImpl->naValBorders[i]))).Expand(20);
+
+ aProfile += (CUniString(">= ").Append(TTFormat::ms2s(pImpl->naValBorders[pImpl->nNumBorders-1])));
+
+ aProfile += '\n';
+
+ aProfile += CUniString("Ereignisse").Expand(15);
+ for ( i=0 ; i<=pImpl->nNumBorders ; i++ )
+ aProfile += TTFormat::ms2s(pImpl->naNumEntries[i]).Expand(20);
+
+ aProfile += '\n';
+
+ aProfile += CUniString("Server Zeit").Expand(15);
+ for ( i=0 ; i<=pImpl->nNumBorders ; i++ )
+ aProfile += TTFormat::ms2s(pImpl->naRemoteTime[i]).Expand(20);
+
+ aProfile += '\n';
+
+ aProfile += CUniString("Testtool Zeit").Expand(15);
+ for ( i=0 ; i<=pImpl->nNumBorders ; i++ )
+ aProfile += TTFormat::ms2s(pImpl->naLocalTime[i]).Expand(20);
+
+ aProfile += '\n';
+
+ aProfile += CUniString("Overhead p.e.").Expand(15);
+ for ( i=0 ; i<=pImpl->nNumBorders ; i++ )
+ {
+ if ( pImpl->naNumEntries[i] > 0 )
+ aProfile += TTFormat::ms2s((pImpl->naLocalTime[i]-pImpl->naRemoteTime[i])/pImpl->naNumEntries[i]).Expand(20);
+ else
+ aProfile += CUniString( "??" ).Expand(20);
+ }
+
+ aProfile += '\n';
+
+ aProfile.ConvertLineEnd(LINEEND_CRLF);
+ aStrm.Seek(STREAM_SEEK_TO_END);
+ aStrm << ByteString( aProfile, RTL_TEXTENCODING_UTF8 ).GetBuffer();
+ aStrm.Close();
+ }
+ break;
+ }
+ default:
+ DBG_ERROR1("Unbekannter Sub Return Code bei Profile: %hu", nUId );
+ break;
+ }
+ }
+ #endif
+ }
+ break;
+ case RET_DirectLoging:
+ {
+ // FIXME: HELPID
+ #if 0
+ sal_uLong nUId = aUId.GetNum();
+ switch ( nUId )
+ {
+ case S_AssertError:
+ {
+ ADD_ASSERTION_LOG( aString1 );
+// ADD_ERROR_LOG( aString1, aRun.GetModuleName(SbxNAME_SHORT_TYPES),
+// aRun.GetLine(), aRun.GetCol1(), aRun.GetCol2() );
+ }
+ break;
+ case S_QAError:
+ {
+ ADD_QA_ERROR_LOG( aString1 );
+ }
+ break;
+ default:
+ ;
+ }
+ #endif
+ }
+ break;
+ case RET_MacroRecorder:
+ {
+ SortControlsByNumber( sal_True );
+ String aCommand,aControls,aControl,aULongNames,aULongName;
+ sal_Bool bWriteNewKontext = sal_False;
+
+ aControls.Erase();
+ // Kurzname feststellen
+ if ( m_pReverseControls )
+ {
+ sal_uInt16 nNr;
+ ControlItem *pNewItem = new ControlItemUId( String(), aUId );
+ if ( m_pReverseControls->Seek_Entry(pNewItem,&nNr) )
+ aControls = m_pReverseControls->GetObject(nNr)->pData->Kurzname;
+ delete pNewItem;
+ }
+ if ( !aControls.Len() )
+ {
+ aControls = String::CreateFromAscii("UnknownControl:UnknownControl");
+ Sound::Beep( SOUND_WARNING );
+ }
+
+ aULongNames.Erase();
+ if( (nParams & PARAM_ULONG_1) && (nNr1 & M_RET_NUM_CONTROL) )
+ {
+ if ( m_pReverseControls )
+ {
+ sal_uInt16 nNr;
+ // FIXME: HELPID
+ ControlItem *pNewItem = new ControlItemUId( String(), rtl::OString( /*nLNr1*/ ) );
+ if ( m_pReverseControls->Seek_Entry(pNewItem,&nNr) )
+ aULongNames = m_pReverseControls->GetObject(nNr)->pData->Kurzname;
+ delete pNewItem;
+ }
+ if ( !aULongNames.Len() )
+ {
+ aULongNames = String::CreateFromAscii("Unknown:Unknown");
+ Sound::Beep( SOUND_WARNING );
+ }
+
+ // now determin the best common kontext
+ sal_uInt16 i,j;
+ sal_Bool bFoundUlongName = sal_False, bFoundControl = sal_False;
+ // check for current kontext
+ for ( i = 0 ; !bFoundUlongName && i < aULongNames.GetTokenCount('/') ; i++ )
+ bFoundUlongName = aLastRecordedKontext.Equals( aULongNames.GetToken(i,'/').GetToken( 0,':') );
+
+ for ( j = 0 ; !bFoundControl && j < aControls.GetTokenCount('/') ; j++ )
+ bFoundControl = aLastRecordedKontext.Equals( aControls.GetToken(j,'/').GetToken( 0,':') );
+
+ if ( bFoundUlongName && bFoundControl )
+ {
+ aULongName = aULongNames.GetToken(i-1,'/').GetToken( 1,':');
+ aControl = aControls.GetToken(j-1,'/').GetToken( 1,':');
+ }
+ else
+ { // see if we can find common kontext
+ sal_Bool bFound = sal_False;
+
+ String aCurrentKontext;
+ for ( i = 0 ; !bFound && i < aULongNames.GetTokenCount('/') ; i++ )
+ {
+ aCurrentKontext = aULongNames.GetToken(i,'/').GetToken( 0,':');
+
+ for ( j = 0 ; !bFound && j < aControls.GetTokenCount('/') ; j++ )
+ {
+ if ( aCurrentKontext.Equals( aControls.GetToken(j,'/').GetToken( 0,':') ) )
+ {
+ bFound = sal_True;
+ aULongName = aULongNames.GetToken(i,'/').GetToken( 1,':');
+ aControl = aControls.GetToken(j,'/').GetToken( 1,':');
+ aLastRecordedKontext = aCurrentKontext;
+ bWriteNewKontext = sal_True;
+ }
+ }
+ }
+ if ( !bFound )
+ {
+ // check if both contain toplevel
+ bFoundUlongName = sal_False;
+ bFoundControl = sal_False;
+ for ( i = 0 ; !bFoundUlongName && i < aULongNames.GetTokenCount('/') ; i++ )
+ bFoundUlongName = aULongNames.GetToken(i,'/').GetToken( 0,':').Equals( aULongNames.GetToken(i,'/').GetToken( 1,':') );
+
+ for ( j = 0 ; !bFoundControl && j < aControls.GetTokenCount('/') ; j++ )
+ bFoundControl = aControls.GetToken(j,'/').GetToken( 0,':').Equals( aControls.GetToken(j,'/').GetToken( 1,':') );
+
+ if ( bFoundUlongName && bFoundControl )
+ {
+ aULongName = aULongNames.GetToken(i-1,'/').GetToken( 1,':');
+ aControl = aControls.GetToken(j-1,'/').GetToken( 1,':');
+ if ( aLastRecordedKontext.Len() )
+ {
+ aLastRecordedKontext.Erase();
+ bWriteNewKontext = sal_True;
+ }
+ }
+ else
+ {
+ String aComment;
+ aComment = CUniString( "'could not Determin common kontext\n" );
+ Sound::Beep( SOUND_WARNING );
+ aWriteStringHdl.Call( &aComment );
+ aULongName = aULongNames.GetToken(i,'/');
+ aControl = aControls.GetToken(j,'/');
+ }
+ }
+ }
+
+ }
+ else
+ { // we only have a Control
+ sal_uInt16 i;
+ sal_Bool bFoundControl = sal_False;
+ // check for current kontext
+ for ( i = 0 ; !bFoundControl && i < aControls.GetTokenCount('/') ; i++ )
+ bFoundControl = aLastRecordedKontext.Equals( aControls.GetToken(i,'/').GetToken( 0,':') );
+ if ( bFoundControl )
+ aControl = aControls.GetToken(i-1,'/').GetToken( 1,':');
+ else
+ {
+ aLastRecordedKontext = aControls.GetToken(0,'/').GetToken( 0,':');
+ bWriteNewKontext = sal_True;
+ aControl = aControls.GetToken(0,'/').GetToken( 1,':');
+ }
+
+ }
+
+
+ if ( bWriteNewKontext )
+ {
+ String aKontextCommand = CUniString( "Kontext" );
+ if ( aLastRecordedKontext.Len() )
+ {
+ aKontextCommand.AppendAscii ( " \"" );
+ aKontextCommand += aLastRecordedKontext;
+ aKontextCommand.AppendAscii ( "\"" );
+ }
+ aKontextCommand.AppendAscii( "\n" );
+ aWriteStringHdl.Call( &aKontextCommand );
+ }
+
+ aCommand = aControl;
+
+ // Add Method name
+ String aMethod = GetMethodName( nNr1 & ~M_RET_NUM_CONTROL );
+ aCommand += '.';
+ aCommand += aMethod;
+
+ sal_Bool bWasParam = sal_False;
+
+ if( nParams & PARAM_STR_1 )
+ {
+ bWasParam = sal_True;
+ aCommand.AppendAscii( " \"" );
+ if ( nNr1 & M_KEY_STRING )
+ {
+ sal_uInt16 nModify = 0;
+ sal_Bool bIsProsa = sal_False;
+ xub_StrLen i;
+ for ( i = 0; i < aString1.Len(); i++ )
+ {
+ if ( ((sal_uInt16)aString1.GetChar(i)) == 1 ) // we have a spechial char
+ {
+ i++;
+ if ( !bIsProsa )
+ {
+ aCommand.AppendAscii( "<" );
+ bIsProsa = sal_True;
+ }
+ else
+ aCommand.AppendAscii( " " );
+
+ sal_uInt16 nKeyCode = (sal_uInt16)aString1.GetChar(i) & KEY_CODE;
+ sal_uInt16 nNewModify = (sal_uInt16)aString1.GetChar(i) & KEY_MODTYPE;
+ if ( nNewModify != nModify )
+ { // generate modifiers
+ sal_uInt16 nChanged = ( nNewModify ^ nModify );
+ if ( nChanged & KEY_SHIFT )
+ {
+ aCommand += GetKeyName( KEY_SHIFT );
+ aCommand.AppendAscii( " " );
+ }
+ if ( nChanged & KEY_MOD1 )
+ {
+ aCommand += GetKeyName( KEY_MOD1 );
+ aCommand.AppendAscii( " " );
+ }
+ if ( nChanged & KEY_MOD2 )
+ {
+ aCommand += GetKeyName( KEY_MOD2 );
+ aCommand.AppendAscii( " " );
+ }
+ }
+ aCommand += GetKeyName( nKeyCode );
+ nModify = nNewModify;
+ }
+ else
+ {
+ if ( bIsProsa )
+ {
+ aCommand.AppendAscii( ">" );
+ bIsProsa = sal_False;
+ }
+ aCommand += aString1.GetChar(i);
+ nModify = 0;
+ }
+ }
+ if ( bIsProsa )
+ {
+ aCommand.AppendAscii( ">" );
+ bIsProsa = sal_False;
+ }
+ }
+ else
+ {
+ aCommand += aString1;
+ }
+ aCommand.AppendAscii( "\"" );
+ }
+ if( nParams & PARAM_ULONG_1 )
+ {
+ if ( bWasParam )
+ aCommand.AppendAscii( ", " );
+ else
+ aCommand.AppendAscii( " " );
+ bWasParam = sal_True;
+ if ( nNr1 & M_RET_NUM_CONTROL )
+ {
+ aCommand.Append( aULongName );
+ }
+ else
+ {
+ aCommand.Append( String::CreateFromInt64( nLNr1 ) );
+ }
+ }
+ if( nParams & PARAM_BOOL_1 )
+ {
+ if ( bWasParam )
+ aCommand.AppendAscii( ", " );
+ else
+ aCommand.AppendAscii( " " );
+ bWasParam = sal_True;
+ if ( bBool1 )
+ aCommand.AppendAscii( "true" );
+ else
+ aCommand.AppendAscii( "false" );
+ }
+
+ aCommand.AppendAscii( "\n" );
+
+ aWriteStringHdl.Call( &aCommand );
+ }
+ break;
+ default:
+ DBG_ERROR1( "Unbekannter Return Code: %iu", nRet );
+ break;
+ }
+
+ break;
+ }
+ case SIReturnError:
+ {
+ String aString;
+ rtl::OString aUId;
+ if ( pRetStream->GetNextType() == BinString )
+ {
+ String aUStrId; // UniqueStringID Used for Mozilla Integration
+ pRetStream->Read( aUStrId );
+ // FIXME: HELPID
+ #if 0
+ aUId = rtl::OString( aUStrId );
+ #endif
+ }
+ else
+ {
+ comm_ULONG nUId;
+ pRetStream->Read( nUId ); // bei Sequence einfach die Sequence
+ // FIXME: HELPID
+ #if 0
+ aUId = rtl::OString( nUId );
+ #endif
+ }
+ pRetStream->Read( aString );
+ ReplaceNumbers (aString);
+
+ String aShortName;
+ aShortName = pShortNames->GetName(aUId);
+ aShortName.AppendAscii( " : " );
+
+ String aTmpStr(aShortName);
+ aTmpStr += aString;
+ ADD_ERROR(SbxERR_BAD_ACTION, aTmpStr/*, nNr*/);
+ break;
+ }
+ default:
+ DBG_ERROR1( "Unbekannter Request im Return Stream Nr: %iu", nId );
+ break;
+ }
+ if( !pIn->IsEof() )
+ pRetStream->Read( nId );
+ else
+ {
+ DBG_ERROR( "truncated input stream" );
+ }
+
+ }
+
+ delete pRetStream;
+ if ( bSequenceOK )
+ {
+ nSequence++;
+ pShortNames->Invalidate( nClearSequence - KEEP_SEQUENCES );
+ }
+
+ bReturnOK = sal_True;
+
+ return sal_True;
+} // RetService::Request()
+
+String TestToolObj::GetMethodName( sal_uLong nMethodId )
+{
+ sal_uInt16 nElement;
+ if ( !Controls::pClasses ) // Ist static, wird also nur einmal geladen
+ ReadFlatArray( Controls::arClasses, Controls::pClasses );
+ if ( Controls::pClasses )
+ {
+ // FIXME: HELPID
+ #if 0
+ for ( nElement = 0 ; nElement < Controls::pClasses->Count() ; nElement++ )
+ if ( Controls::pClasses->GetObject(nElement)->pData->aUId.Matches( nMethodId ) )
+ return Controls::pClasses->GetObject(nElement)->pData->Kurzname;
+ #else
+ (void)nElement;
+ (void)nMethodId;
+ #endif
+ }
+ return String();
+}
+
+String TestToolObj::GetKeyName( sal_uInt16 nKeyCode )
+{
+ sal_uInt16 nElement;
+ if ( !CmdStream::pKeyCodes ) // Ist static, wird also nur einmal geladen
+ ReadFlatArray( CmdStream::arKeyCodes, CmdStream::pKeyCodes );
+ if ( CmdStream::pKeyCodes )
+ {
+ // FIXME: HELPID
+ #if 0
+ for ( nElement = 0 ; nElement < CmdStream::pKeyCodes->Count() ; nElement++ )
+ if ( CmdStream::pKeyCodes->GetObject(nElement)->pData->aUId.Matches( nKeyCode ) )
+ return CmdStream::pKeyCodes->GetObject(nElement)->pData->Kurzname;
+ #else
+ (void)nElement;
+ (void)nKeyCode;
+ #endif
+ }
+ return CUniString( "UnknownKeyCode" );
+}
+
+void TestToolObj::ReplaceNumbers(String &aText)
+{
+static ControlDefLoad __READONLY_DATA arRes_Type [] =
+#include "res_type.hxx"
+
+ static CNames *pRTypes = NULL;
+ xub_StrLen nStart = STRING_NOTFOUND;
+ xub_StrLen nGleich = STRING_NOTFOUND;
+ xub_StrLen nEnd = STRING_NOTFOUND;
+ xub_StrLen nStartPos = 0;
+ sal_uLong nNumber;
+ String aType;
+ String aResult;
+ sal_Bool bFound;
+
+ while ( (nStart = aText.Search(StartKenn,nStartPos)) != STRING_NOTFOUND &&
+ (nGleich = aText.SearchAscii("=",nStart+StartKenn.Len())) != STRING_NOTFOUND &&
+ (nEnd = aText.Search(EndKenn,nGleich+1)) != STRING_NOTFOUND)
+ {
+ aType = aText.Copy(nStart,nGleich-nStart);
+ nNumber = (sal_uLong)aText.Copy(nGleich+1,nEnd-nGleich-1).ToInt64();
+ bFound = sal_False;
+ if ( aType.CompareTo(UIdKenn) == COMPARE_EQUAL )
+ {
+ // FIXME: HELPID
+ aResult = pShortNames->GetName(rtl::OString(/*nNumber*/));
+ bFound = sal_True;
+ }
+ if ( aType.CompareTo(MethodKenn ) == COMPARE_EQUAL )
+ {
+ bFound = sal_True;
+ aResult = GetMethodName( nNumber );
+ }
+ if ( aType.CompareTo(RcKenn ) == COMPARE_EQUAL )
+ {
+ bFound = sal_True;
+ if ( !pRCommands ) // Ist static, wird also nur einmal geladen
+ ReadFlatArray( arR_Cmds, pRCommands );
+
+ sal_uInt16 nElement;
+ if ( pRCommands )
+ {
+ // FIXME: HELPID
+ #if 0
+ for ( nElement = 0 ; nElement < pRCommands->Count() ; nElement++ )
+ if ( pRCommands->GetObject(nElement)->pData->aUId.Matches( nNumber ) )
+ {
+ aResult = pRCommands->GetObject(nElement)->pData->Kurzname;
+ nElement = pRCommands->Count();
+ }
+ #else
+ (void)nElement;
+ #endif
+ }
+ }
+ if ( aType.CompareTo(TypeKenn ) == COMPARE_EQUAL )
+ {
+ bFound = sal_True;
+ if ( !pRTypes ) // Ist static, wird also nur einmal geladen
+ ReadFlatArray( arRes_Type, pRTypes );
+
+ sal_uInt16 nElement;
+ if ( pRTypes )
+ {
+ // FIXME: HELPID
+ #if 0
+ for ( nElement = 0 ; nElement < pRTypes->Count() ; nElement++ )
+ if ( pRTypes->GetObject(nElement)->pData->aUId.Matches( nNumber ) )
+ {
+ aResult = pRTypes->GetObject(nElement)->pData->Kurzname;
+ nElement = pRTypes->Count();
+ }
+ #else
+ (void)nElement;
+ #endif
+ }
+ }
+ if ( aType.CompareTo(SlotKenn ) == COMPARE_EQUAL )
+ {
+ // FIXME: HELPID
+ aResult = pShortNames->GetName(rtl::OString(/*nNumber*/));
+ bFound = sal_True;
+ }
+ if ( aType.CompareTo(TabKenn ) == COMPARE_EQUAL )
+ {
+ if ( nNumber > nStart )
+ aResult.Fill( (sal_uInt16)nNumber - nStart +1 );
+ else
+ aResult = CUniString(" ");
+ bFound = sal_True;
+ }
+
+ nStartPos = nStart;
+ if ( bFound )
+ {
+ aText.Erase(nStart,nEnd+EndKenn.Len()-nStart);
+ aText.Insert(aResult,nStart);
+ nStartPos = nStartPos + aResult.Len();
+ }
+ else
+ nStartPos = nStartPos + StartKenn.Len();
+ }
+}
+
+
+SbTextType TestToolObj::GetSymbolType( const String &rSymbol, sal_Bool bWasControl )
+{
+ if ( rSymbol.CompareToAscii( "try" ) == COMPARE_EQUAL
+ || rSymbol.CompareToAscii( "catch" ) == COMPARE_EQUAL
+ || rSymbol.CompareToAscii( "endcatch" ) == COMPARE_EQUAL
+ || rSymbol.CompareToAscii( "testcase" ) == COMPARE_EQUAL
+ || rSymbol.CompareToAscii( "endcase" ) == COMPARE_EQUAL )
+ {
+ return TT_KEYWORD;
+ }
+
+
+ ControlDef WhatName( rSymbol, rtl::OString() );
+
+ if ( bWasControl )
+ {
+ if ( !Controls::pClasses ) // Ist static, wird also nur einmal geladen
+ ReadFlatArray( Controls::arClasses, Controls::pClasses );
+
+ if ( (Controls::pClasses && Controls::pClasses->Seek_Entry( &WhatName ))
+ || rSymbol.EqualsIgnoreCaseAscii( "ID" )
+ || rSymbol.EqualsIgnoreCaseAscii( "Name" ) )
+ return TT_METHOD;
+ else
+ return TT_NOMETHOD;
+ }
+
+ // Die Controls durchsuchen
+ if ( m_pControls )
+ {
+ sal_uInt16 nWin;
+
+ for ( nWin = 0 ; nWin < m_pControls->Count() ; nWin++ )
+ {
+ if ( ((ControlDef*)m_pControls->GetObject( nWin ))->SonSeek_Entry( &WhatName ) )
+ return TT_CONTROL;
+ }
+ }
+
+ // Die Slots durchsuchen
+ if ( m_pSIds && m_pSIds->Seek_Entry( &WhatName ) )
+ return TT_SLOT;
+
+ // Ist es ein RemoteCommand
+ if ( !pRCommands ) // Ist static, wird also nur einmal geladen
+ ReadFlatArray( arR_Cmds, pRCommands );
+ if ( pRCommands && pRCommands->Seek_Entry( &WhatName ) )
+ return TT_REMOTECMD;
+
+ // Wenns sonst nix war, dann vielleicht ein Lokales Kommando
+ SbxVariable *pVar = SbxObject::Find( rSymbol, SbxCLASS_DONTCARE );
+ if ( pVar && ( pVar->ISA(SbxMethod) || pVar->ISA(SbxProperty) ) )
+ {
+ return TT_LOCALCMD;
+ }
+
+ return SB_SYMBOL; // Alles was hier landet ist vom Typ SB_SYMBOL und bleibt es auch
+}
+
+
+#undef P_FEHLERLISTE
+#define P_FEHLERLISTE TestToolObj::pFehlerListe
+
+Controls::Controls( String aCName )
+: SbxObject( aCName)
+{
+ pMethodVar = new SbxTransportMethod( SbxVARIANT );
+ pMethodVar->SetName( CUniString("Dummy") );
+ Insert( pMethodVar );
+// pMethodVar = Make( CUniString("Dummy"), SbxCLASS_PROPERTY, SbxULONG );
+}
+
+
+Controls::~Controls()
+{}
+
+
+void Controls::ChangeListener( SbxObject* parent )
+{
+ EndListening( pMethodVar->GetBroadcaster(), sal_True );
+ parent->StartListening( pMethodVar->GetBroadcaster(), sal_True );
+}
+
+void Controls::SFX_NOTIFY( SfxBroadcaster&, const TypeId&,
+ const SfxHint&, const TypeId& )
+{}
+
+
+
+SbxVariable* Controls::Find( const String& aStr, SbxClassType aType)
+{
+ if ( !pClasses ) // Ist static, wird also nur einmal geladen
+ ReadFlatArray( arClasses, pClasses );
+
+ if ( GetUserData() == ID_ErrorDummy )
+ {
+ pMethodVar->SetName(UniString(GetName()).AppendAscii(".").Append(aStr));
+ pMethodVar->SetUserData( ID_ErrorDummy );
+ return pMethodVar;
+ }
+
+
+ sal_uInt16 nElement;
+ ControlDef WhatName(aStr,rtl::OString());
+ if (pClasses && pClasses->Seek_Entry(&WhatName,&nElement))
+ {
+ pMethodVar->SetName(aStr);
+ // FIXME: HELPID
+ sal_uLong nUId = 0;//pClasses->GetObject(nElement)->pData->aUId.GetNum();
+ pMethodVar->nValue = nUId;
+
+ pMethodVar->SetUserData( GetUserData() );
+ return pMethodVar;
+ }
+ else
+ { // mainly for ID and name
+ SbxVariableRef Old = SbxObject::Find(aStr, aType );
+ if (Old)
+ return Old;
+ else if ( aStr.EqualsIgnoreCaseAscii("ID") )
+ return NULL; // suppress generation of error in this case
+ }
+ ADD_ERROR(SbxERR_BAD_METHOD,GEN_RES_STR2(S_UNKNOWN_METHOD, GetName(), aStr));
+ return NULL;
+}
+
+
+String TTFormat::ms2s( sal_uLong nMilliSeconds )
+{
+ if ( nMilliSeconds < 100000 ) // 100 Sekunden
+ return String::CreateFromInt64( nMilliSeconds );
+ if ( nMilliSeconds < 100000*60 ) // 100 Minuten
+ return String::CreateFromInt32( nMilliSeconds / 1000 ).AppendAscii("Sec");
+ return String::CreateFromInt32( nMilliSeconds / 1000 / 60 ).AppendAscii("Min");
+}
+
+
diff --git a/automation/source/testtool/objtest.hxx b/automation/source/testtool/objtest.hxx
new file mode 100644
index 000000000000..c0dfd1c12ac6
--- /dev/null
+++ b/automation/source/testtool/objtest.hxx
@@ -0,0 +1,402 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _OBJTEST_HXX
+#define _OBJTEST_HXX
+
+#include <tools/fsys.hxx>
+
+
+#include <testapp.hxx>
+#include <testtool.hxx>
+#include "cmdstrm.hxx"
+#include <basic/basicrt.hxx>
+#include "httprequest.hxx"
+
+#include <map>
+
+// #define ID_BeginBlock 1
+// #define ID_EndBlock 2
+#define ID_Kontext 3
+#define ID_GetError 4
+#define ID_ErrorDummy 5 // Intern zum Behandlen von Fehlenden Controls und Methoden
+#define ID_RecordError 6
+#define ID_Start 7
+//#define ID_Kill 8
+//#define ID_Reset 9
+// #define ID_AppAbort 10
+#define ID_Dispatch 11
+#define ID_UNODispatch 12
+#define ID_Control 13
+#define ID_StartUse 14
+#define ID_Use 15
+#define ID_FinishUse 16
+#define ID_CaseLog 17
+#define ID_ExceptLog 18
+#define ID_PrintLog 19
+#define ID_WarnLog 20
+#define ID_ErrorLog 21
+#define ID_EnableQaErrors 22
+#define ID_QAErrorLog 23
+#define ID_MaybeAddErr 24
+#define ID_ClearError 25
+#define ID_GetNextCloseWindow 26
+#define ID_RemoteCommand 27
+#define ID_SaveIDs 28
+#define ID_AutoExecute 29
+#define ID_Execute 30
+#define ID_DialogHandler 31
+#define ID_GetUnoApp 32
+#define ID_GetIServer 33
+#define ID_RemoteCommandDelay 34
+#define ID_GetApplicationPath 35
+#define ID_GetCommonApplicationPath 36
+#define ID_MakeIniFileName 37
+#define ID_StringControl 38
+#define ID_Wait 39
+#define ID_GetErrorCount 40
+#define ID_GetWarningCount 41
+#define ID_GetQAErrorCount 42
+#define ID_GetUseFileWarningCount 43
+#define ID_GetErrorList 44
+#define ID_GetWarningList 45
+#define ID_GetQAErrorList 46
+#define ID_GetUseFileWarningList 47
+#define ID_GetTestCaseName 48
+#define ID_GetTestCaseFileName 49
+#define ID_GetTestCaseLineNr 50
+#define ID_StopOnSyntaxError 51
+#define ID_SetChildEnv 52
+#define ID_GetChildEnv 53
+#define ID_GetLinkDestination 54
+#define ID_GetRegistryValue 55
+#define ID_KillApp 56
+#define ID_HTTPSend 57
+#define ID_HTTPSetProxy 58
+#define ID_DoNothing 99
+
+void ReadFlatArray( const ControlDefLoad arWas [], CNames *&pNames );
+
+class ControlData
+{
+public:
+ String Kurzname;
+ rtl::OString aUId;
+};
+
+DBG_NAMEEX( ControlItem )
+DBG_NAMEEX( ControlDef )
+class ControlItem
+{
+private:
+ void InitData() { pData = new ControlData; }
+public:
+ ControlData *pData;
+
+ ControlItem( const char *Name, rtl::OString aUIdP );
+ ControlItem( const String &Name, rtl::OString aUIdP );
+// ControlItem( const String &Name, const String &URL, const URLType aType );
+// ControlItem( const String &Name, const String &URL, const sal_uLong nUId );
+// ControlItem( const char *Name, const String &URL, const sal_uLong nUId );
+ ControlItem( ControlData *pDataP );
+ virtual ~ControlItem() {
+DBG_DTOR(ControlItem,0);
+ delete pData;
+ }
+ virtual sal_Bool operator < (const ControlItem &rPar)=0;
+ virtual sal_Bool operator == (const ControlItem &rPar)=0;
+// void Write( SvStream &aStream );
+};
+
+SV_DECL_PTRARR_SORT_DEL(CNames, ControlItem*, 50, 10)
+
+#define MK_SON_ACCESS( ClassName )\
+ sal_Bool SonInsert( const ClassName *pNewEntry ) { const ControlItem *pItem = pNewEntry; return pSons->Insert( pItem ); }\
+ sal_Bool SonSeek_Entry( const ClassName *pSearchEntry, sal_uInt16 *nRes = NULL) { return pSons->Seek_Entry( pSearchEntry, nRes ); }\
+ ClassName* SonGetObject( sal_uInt16 nNr ) { return (ClassName*)pSons->GetObject( nNr ); }
+
+class ControlSon
+{
+protected:
+ CNames *pSons; // um sicherzustelle, daß nur Söhne des richtien Type reinkommen
+
+public:
+ ControlSon() : pSons( NULL ) {};
+ ~ControlSon();
+// void Write( SvStream &aStream );
+
+ sal_uInt16 Son_Count() { return pSons->Count(); }
+ void Sons( CNames *pNewSons ) { pSons = pNewSons; }
+ CNames*& GetSons() { return pSons; }
+};
+
+class ControlItemSon : public ControlItem, public ControlSon
+{
+public:
+ ControlItemSon(const char *Name, rtl::OString aUIdP )
+ : ControlItem( Name, aUIdP ) {}
+ ControlItemSon(const String &Name, rtl::OString aUIdP );
+// ControlItemSon(const String &Name, const String &URL, const URLType aType );
+// ControlItemSon(const String &Name, const String &URL, const sal_uLong nUId );
+// ControlItemSon(const char *Name, const String &URL, const sal_uLong nUId );
+// void Write( SvStream &aStream );
+};
+
+class ControlDef : public ControlItemSon
+{
+public:
+ ControlDef(const char *Name, rtl::OString aUIdP )
+ : ControlItemSon( Name, aUIdP ) {DBG_CTOR(ControlDef,0);}
+ ControlDef(const String &Name, rtl::OString aUIdP );
+// ControlDef(const String &Name, const String &URL, const URLType aType );
+ ControlDef(const String &aOldName, const String &aNewName, ControlDef *pOriginal, sal_Bool bWithSons = sal_False );
+ ~ControlDef() {DBG_DTOR(ControlDef,0);}
+ virtual sal_Bool operator < (const ControlItem &rPar);
+ virtual sal_Bool operator == (const ControlItem &rPar);
+ void Write( SvStream &aStream );
+ MK_SON_ACCESS( ControlDef )
+};
+
+class ControlItemUId : public ControlItem
+{
+public:
+ ControlItemUId(String Name, rtl::OString aUIdP)
+ : ControlItem( Name, aUIdP){}
+ virtual sal_Bool operator < (const ControlItem &rPar);
+ virtual sal_Bool operator == (const ControlItem &rPar);
+};
+
+class ControlItemUIdSon : public ControlItemUId, public ControlSon
+{
+public:
+ ControlItemUIdSon(String Name, rtl::OString aUIdP) : ControlItemUId( Name, aUIdP) {}
+ MK_SON_ACCESS( ControlItemUId )
+};
+
+class ReverseName : public ControlItemUId
+{
+public:
+ sal_uLong LastSequence;
+
+ ReverseName(String Name, rtl::OString aUIdP, sal_uLong nSeq) : ControlItemUId( Name, aUIdP), LastSequence(nSeq) {}
+};
+
+class CRevNames: public CNames
+{
+public:
+ void Insert( String aName, rtl::OString aUId, sal_uLong nSeq );
+ String GetName( rtl::OString aUId );
+ void Invalidate ( sal_uLong nSeq );
+};
+
+
+class SbxTransportMethod: public SbxMethod
+{
+public:
+ SbxTransportMethod( SbxDataType );
+ sal_uLong nValue;
+ String aUnoSlot;
+};
+SV_DECL_IMPL_REF(SbxTransportMethod);
+
+class Controls: public SbxObject
+{
+public:
+ Controls( String aCName );
+ ~Controls();
+ void ChangeListener( SbxObject* pParent );
+
+ void SFX_NOTIFY( SfxBroadcaster&, const TypeId&, const SfxHint& rHint, const TypeId& );
+ virtual SbxVariable* Find( const String&, SbxClassType );
+ SbxTransportMethodRef pMethodVar; // zum Transport von Find nach Notify
+ static CNames *pClasses;
+ static ControlDefLoad __READONLY_DATA arClasses [];
+};
+SV_DECL_IMPL_REF(Controls);
+
+typedef std::map< String, String > Environment;
+
+class ImplTestToolObj
+{
+public:
+// ImplTestToolObj()
+// ~ImplTestToolObj()
+
+ String ProgParam; // Parameter der zu Testenden APP; Gesetzt über Start
+
+ DirEntry aFileBase; // Grundpfad für die *.sid und *.win Dateien (Aus Configdatei)
+ DirEntry aLogFileBase; // Grundpfad für die *.res Dateien (Aus Configdatei)
+ DirEntry aHIDDir; // Verzeichnis, in dem die hid.lst gesucht wird
+
+ SbxTransportMethodRef pNextReturn; // Verweis auf die Var, die den Returnwert aufnimmt.
+
+ ControlsRef pControlsObj; // Jeweiliges Objekt, an dem Methoden aufgerufen weden.
+
+#define VAR_POOL_SIZE 8
+ SbxTransportMethodRef pMyVars[VAR_POOL_SIZE]; // Falls in Ausdrücken mehrere verwendet werden
+
+ Time aServerTimeout;
+
+
+// Profiling Datenfelder
+ sal_uLong LocalStarttime;
+ sal_uInt16 nNumBorders;
+ sal_uLong naValBorders[4];
+ sal_uLong naNumEntries[5];
+ sal_uLong naRemoteTime[5];
+ sal_uLong naLocalTime[5];
+
+ sal_uLong nMinRemoteCommandDelay;
+ sal_uLong nMaxRemoteCommandDelay;
+ sal_Bool bDoRemoteCommandDelay;
+
+ sal_Bool bLnaguageExtensionLoaded; // Wurde über 'use' was geladen? Für syntax highlighting
+ SfxBroadcaster *pTTSfxBroadcaster;
+
+ sal_uLong nErrorCount;
+ sal_uLong nWarningCount;
+ sal_uLong nQAErrorCount;
+ sal_uLong nIncludeFileWarningCount;
+
+ SbxDimArrayRef xErrorList;
+ SbxDimArrayRef xWarningList;
+ SbxDimArrayRef xQAErrorList;
+ SbxDimArrayRef xIncludeFileWarningList;
+
+ sal_Bool bIsStart; // set tu sal_True while command Start is initiating the communication
+
+ MyBasic* pMyBasic;
+
+ String aTestCaseName; // holds name of current TestCase
+ String aTestCaseFileName; // holds FileName of current TestCase
+ sal_uInt16 nTestCaseLineNr; // holds Line of current TestCase
+
+ sal_Bool bEnableQaErrors; // include QA errors in report
+ sal_Bool bDebugFindNoErrors; // suppress generating errors when find of variables is called for variable viewing purposes
+
+ sal_Bool bStopOnSyntaxError; // catch syntax errors in testcases or not
+
+ Environment *pChildEnv; // Environment Variables for child Process
+
+ HttpRequest *pHttpRequest; // used for sending HTTP requests
+};
+
+
+class TTFormat
+{
+public:
+ static String ms2s( sal_uLong nMilliSeconds );
+};
+
+
+#define ADD_TO_LOG( aLogTypep, aMsgp, aFilenamep, nLinep, nCol1p, nCol2p, aRevisionp, pLogList )\
+{ \
+ TTLogMsg *pLogMsg = new TTLogMsg(); \
+ pLogMsg->aDebugData.aMsg = aMsgp; \
+ pLogMsg->aLogFileName = (pImpl->aLogFileBase + DirEntry(aLogFileName)).GetFull(); \
+ pLogMsg->aDebugData.aFilename = aFilenamep; \
+ pLogMsg->aDebugData.nLine = nLinep; \
+ pLogMsg->aDebugData.nCol1 = nCol1p; \
+ pLogMsg->aDebugData.nCol2 = nCol2p; \
+ pLogMsg->aDebugData.aLogType = aLogTypep; \
+ aLogHdl.Call( pLogMsg ); \
+ void* pDummyForWarningAboutNULL = pLogList; \
+ if( pDummyForWarningAboutNULL ) \
+ { \
+ SbxDimArray* pLogArray = (SbxDimArray*)pLogList; \
+ SbxVariable* pLogLine = new SbxVariable( SbxSTRING ); \
+ String aCollect; \
+ aCollect.Append( pLogMsg->aDebugData.aFilename ); \
+ aCollect.AppendAscii( ";" ); \
+ aCollect.Append( String::CreateFromInt32( nLinep ) ); \
+ aCollect.AppendAscii( ";" ); \
+ aCollect.Append( aRevisionp ); \
+ aCollect.AppendAscii( ";" ); \
+ aCollect.Append( pLogMsg->aDebugData.aMsg ); \
+ pLogLine->PutString( aCollect ); \
+ pLogArray->Insert( pLogLine, pLogArray->Count() ); \
+ } \
+ delete pLogMsg; \
+} \
+
+
+#define ADD_RUN_LOG() \
+ ADD_TO_LOG(LOG_RUN, String(), String(), 0, 0, 0, String(), NULL) \
+
+#define ADD_ERROR_LOG(aMsg, aFilename, nLine, nCol1, nCol2, aRevision) \
+{ \
+ ADD_TO_LOG(LOG_ERROR, aMsg, aFilename, nLine, nCol1, nCol2, aRevision, &pImpl->xErrorList) \
+ pImpl->nErrorCount++; \
+}
+
+#define ADD_CALL_STACK_LOG(aMsg, aFilename, nLine, nCol1, nCol2) \
+ ADD_TO_LOG(LOG_CALL_STACK, aMsg, aFilename, nLine, nCol1, nCol2, String(), NULL) \
+
+
+#define ADD_AUTO_LOG(aLogType, aMsg, pLogList) \
+{ \
+ if ( BasicRuntimeAccess::HasRuntime() ) \
+ { \
+ BasicRuntime aRun = BasicRuntimeAccess::GetRuntime(); \
+ ADD_TO_LOG(aLogType, aMsg, aRun.GetModuleName(SbxNAME_SHORT_TYPES), \
+ aRun.GetLine(), aRun.GetCol1(), aRun.GetCol2(), aRun.GetSourceRevision(), pLogList) \
+ } \
+ else \
+ { \
+ ADD_TO_LOG(aLogType, aMsg, UniString(), 0, 0, STRING_LEN, String(), pLogList) \
+ } \
+} \
+
+#define ADD_CASE_LOG(aMsg) \
+ ADD_AUTO_LOG(LOG_TEST_CASE, aMsg, NULL) \
+
+#define ADD_MESSAGE_LOG(aMsg) \
+ ADD_AUTO_LOG(LOG_MESSAGE, aMsg, NULL) \
+
+#define ADD_WARNING_LOG(aMsg) \
+{ \
+ ADD_AUTO_LOG(LOG_WARNING, aMsg, &pImpl->xWarningList) \
+ pImpl->nWarningCount++; \
+}
+
+#define ADD_WARNING_LOG2(aMsg, aFilename, nLine ) \
+{ \
+ ADD_TO_LOG(LOG_WARNING, aMsg, aFilename, nLine, 0, STRING_LEN, String(), &pImpl->xWarningList) \
+ pImpl->nWarningCount++; \
+}
+
+#define ADD_ASSERTION_LOG(aMsg) \
+ ADD_AUTO_LOG(LOG_ASSERTION, aMsg, NULL) \
+
+#define ADD_QA_ERROR_LOG(aMsg) \
+ if ( pImpl->bEnableQaErrors ) \
+ { \
+ ADD_AUTO_LOG(LOG_QA_ERROR, aMsg, &pImpl->xQAErrorList) \
+ pImpl->nQAErrorCount++; \
+ }
+
+#endif
diff --git a/automation/source/testtool/registry_win.cxx b/automation/source/testtool/registry_win.cxx
new file mode 100644
index 000000000000..d0b1c0a0aa1b
--- /dev/null
+++ b/automation/source/testtool/registry_win.cxx
@@ -0,0 +1,89 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_automation.hxx"
+
+////////////////////////////////////////////////////////////////////////////
+////
+//// Windows ONLY
+////
+////////////////////////////////////////////////////////////////////////////
+
+
+#include <tools/prewin.h>
+#include "winreg.h"
+#include <tools/postwin.h>
+// as we define it ourselves further down the line we remove it here
+#ifdef IS_ERROR
+// #undef IS_ERROR
+#endif
+
+//#include <tchar.h>
+#include "registry_win.hxx"
+#include <osl/thread.h>
+
+
+String ReadRegistry( String aKey, String aValueName )
+{
+ String aRet;
+ HKEY hBaseKey;
+ if ( aKey.GetToken( 0, '\\' ).EqualsIgnoreCaseAscii( "HKEY_CURRENT_USER" ) )
+ hBaseKey = HKEY_CURRENT_USER;
+ else if ( aKey.GetToken( 0, '\\' ).EqualsIgnoreCaseAscii( "HKEY_LOCAL_MACHINE" ) )
+ hBaseKey = HKEY_LOCAL_MACHINE;
+ else
+ {
+ return aRet;
+ }
+
+ aKey.Erase( 0, aKey.Search( '\\' )+1 );
+
+ HKEY hRegKey;
+
+ if ( RegOpenKeyW( hBaseKey,
+ reinterpret_cast<LPCWSTR>(aKey.GetBuffer()),
+ &hRegKey ) == ERROR_SUCCESS )
+ {
+ LONG lRet;
+ sal_Unicode PathW[_MAX_PATH];
+ DWORD lSize = sizeof(PathW) / sizeof( sal_Unicode );
+ DWORD Type = REG_SZ;
+
+ lRet = RegQueryValueExW(hRegKey, reinterpret_cast<LPCWSTR>(aValueName.GetBuffer()), NULL, &Type, (LPBYTE)PathW, &lSize);
+
+ if ((lRet == ERROR_SUCCESS) && (Type == REG_SZ))
+ {
+ aRet = String( PathW );
+ }
+
+ RegCloseKey(hRegKey);
+ }
+ return aRet;
+}
+
+
diff --git a/automation/source/testtool/registry_win.hxx b/automation/source/testtool/registry_win.hxx
new file mode 100644
index 000000000000..7099f39a3874
--- /dev/null
+++ b/automation/source/testtool/registry_win.hxx
@@ -0,0 +1,31 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#include <tools/string.hxx>
+
+String ReadRegistry( String aKey, String aValueName );
diff --git a/automation/source/testtool/sysdir_win.cxx b/automation/source/testtool/sysdir_win.cxx
new file mode 100644
index 000000000000..ec87c65cfb4a
--- /dev/null
+++ b/automation/source/testtool/sysdir_win.cxx
@@ -0,0 +1,105 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_automation.hxx"
+
+////////////////////////////////////////////////////////////////////////////
+////
+//// Windows ONLY
+////
+////////////////////////////////////////////////////////////////////////////
+
+
+#include <tools/prewin.h>
+#ifndef _SHOBJ_H
+#if defined _MSC_VER
+#pragma warning(push, 1)
+#pragma warning(disable: 4917)
+#endif
+#include <shlobj.h>
+#if defined _MSC_VER
+#pragma warning(pop)
+#endif
+#endif
+#include <tools/postwin.h>
+// as we define it ourselves further down the line we remove it here
+#ifdef IS_ERROR
+ #undef IS_ERROR
+#endif
+
+#include <tchar.h>
+#include "sysdir_win.hxx"
+
+
+//////// copied this from setup2\win\source\system\winos.cxx
+
+void _SHFree( void *pv )
+{
+ IMalloc *pMalloc;
+ if( NOERROR == SHGetMalloc(&pMalloc) )
+ {
+ pMalloc->Free( pv );
+ pMalloc->Release();
+ }
+}
+
+#define ALLOC(type, n) ((type *) HeapAlloc(GetProcessHeap(), 0, sizeof(type) * n ))
+#define FREE(p) HeapFree(GetProcessHeap(), 0, p)
+
+UniString _SHGetSpecialFolder( int nFolderID )
+{
+
+ LPITEMIDLIST pidl;
+ HRESULT hHdl = SHGetSpecialFolderLocation( NULL, nFolderID, &pidl );
+ UniString aFolder;
+
+ if( hHdl == NOERROR )
+ {
+ WCHAR *lpFolderW;
+ lpFolderW = ALLOC( WCHAR, 16000 );
+
+ SHGetPathFromIDListW( pidl, lpFolderW );
+ aFolder = UniString( reinterpret_cast<const sal_Unicode*>(lpFolderW) );
+
+ FREE( lpFolderW );
+ _SHFree( pidl );
+ }
+ return aFolder;
+}
+
+
+/////////////// end of copy
+
+
+
+String _SHGetSpecialFolder_COMMON_APPDATA()
+{
+ return _SHGetSpecialFolder( CSIDL_COMMON_APPDATA );
+}
+
+
diff --git a/automation/source/testtool/sysdir_win.hxx b/automation/source/testtool/sysdir_win.hxx
new file mode 100644
index 000000000000..f406f69572db
--- /dev/null
+++ b/automation/source/testtool/sysdir_win.hxx
@@ -0,0 +1,31 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#include <tools/string.hxx>
+
+String _SHGetSpecialFolder_COMMON_APPDATA();
diff --git a/automation/source/testtool/tcommuni.cxx b/automation/source/testtool/tcommuni.cxx
new file mode 100644
index 000000000000..f3c338362529
--- /dev/null
+++ b/automation/source/testtool/tcommuni.cxx
@@ -0,0 +1,200 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_automation.hxx"
+
+
+#include <tools/config.hxx>
+#include <vcl/svapp.hxx>
+#include <tools/time.hxx>
+#include <tools/debug.hxx>
+#include <vcl/timer.hxx>
+
+#ifndef _BASIC_TTRESHLP_HXX
+#include <basic/ttstrhlp.hxx>
+#endif
+
+#include "rcontrol.hxx"
+#include "tcommuni.hxx"
+#include <basic/testtool.hxx>
+
+CommunicationManagerClientViaSocketTT::CommunicationManagerClientViaSocketTT()
+: CommunicationManagerClientViaSocket( sal_True )
+, aAppPath()
+, aAppParams()
+, pProcess( NULL )
+{
+}
+
+
+sal_Bool CommunicationManagerClientViaSocketTT::StartCommunication()
+{
+ bApplicationStarted = sal_False;
+ return CommunicationManagerClientViaSocket::StartCommunication( ByteString( GetHostConfig(), RTL_TEXTENCODING_UTF8 ), GetTTPortConfig() );
+}
+
+
+sal_Bool CommunicationManagerClientViaSocketTT::StartCommunication( String aApp, String aParams, Environment *pChildEnv )
+{
+ aAppPath = aApp;
+ aAppParams = aParams;
+ aAppEnv = (*pChildEnv);
+ return StartCommunication();
+}
+
+
+sal_Bool CommunicationManagerClientViaSocketTT::RetryConnect()
+{
+ if ( !bApplicationStarted )
+ {
+ // Die App ist wohl nicht da. Starten wir sie mal.
+ if ( aAppPath.Len() )
+ {
+ delete pProcess;
+
+ pProcess = new Process();
+ pProcess->SetImage( aAppPath, aAppParams, &aAppEnv );
+
+ sal_Bool bSucc = pProcess->Start();
+ bApplicationStarted = sal_True;
+
+ if ( bSucc )
+ {
+ aFirstRetryCall = Time() + Time( 0, 1 ); // Max eine Minute Zeit
+ for ( int i = 10 ; i-- ; )
+ GetpApp()->Reschedule();
+ }
+ return bSucc;
+ }
+ return sal_False;
+ }
+ else
+ {
+ if ( aFirstRetryCall > Time() )
+ {
+ Timer aWait;
+ aWait.SetTimeout( 500 ); // Max 500 mSec
+ aWait.Start();
+ while ( aWait.IsActive() )
+ GetpApp()->Yield();
+ return sal_True;
+ }
+ else
+ return sal_False;
+ }
+}
+
+sal_Bool CommunicationManagerClientViaSocketTT::KillApplication()
+{
+ if ( pProcess )
+ return pProcess->Terminate();
+ return sal_True;
+}
+
+#define GETSET(aVar, KeyName, Dafault) \
+ aVar = aConf.ReadKey(KeyName,"No Entry"); \
+ if ( aVar.CompareTo("No Entry") == COMPARE_EQUAL ) \
+ { \
+ aVar = ByteString(Dafault); \
+ aConf.WriteKey(KeyName, aVar); \
+ }
+
+
+String GetHostConfig()
+{
+ String aHostToTalk;
+
+ for ( sal_uInt16 i = 0 ; i < Application::GetCommandLineParamCount() ; i++ )
+ {
+ if ( Application::GetCommandLineParam( i ).Copy(0,6).CompareIgnoreCaseToAscii("-host=") == COMPARE_EQUAL
+#ifndef UNX
+ || Application::GetCommandLineParam( i ).Copy(0,6).CompareIgnoreCaseToAscii("/host=") == COMPARE_EQUAL
+#endif
+ )
+ return Application::GetCommandLineParam( i ).Copy(6);
+ }
+
+ ByteString abHostToTalk;
+ Config aConf(Config::GetConfigName( Config::GetDefDirectory(), CUniString("testtool") ));
+ aConf.SetGroup("Communication");
+
+ GETSET( abHostToTalk, "Host", DEFAULT_HOST );
+ return UniString( abHostToTalk, RTL_TEXTENCODING_UTF8 );
+}
+
+
+sal_uLong GetTTPortConfig()
+{
+ String aPortToTalk;
+
+ for ( sal_uInt16 i = 0 ; i < Application::GetCommandLineParamCount() ; i++ )
+ {
+ if ( Application::GetCommandLineParam( i ).Copy(0,6).CompareIgnoreCaseToAscii("-port=") == COMPARE_EQUAL
+#ifndef UNX
+ || Application::GetCommandLineParam( i ).Copy(0,6).CompareIgnoreCaseToAscii("/port=") == COMPARE_EQUAL
+#endif
+ )
+ {
+ aPortToTalk = Application::GetCommandLineParam( i ).Copy(6);
+ return (sal_uLong)aPortToTalk.ToInt64();
+ }
+ }
+
+ ByteString abPortToTalk;
+ Config aConf(Config::GetConfigName( Config::GetDefDirectory(), CUniString("testtool") ));
+ aConf.SetGroup("Communication");
+
+ GETSET( abPortToTalk, "TTPort", ByteString::CreateFromInt32( TESTTOOL_DEFAULT_PORT ) );
+ return (sal_uLong)abPortToTalk.ToInt64();
+}
+
+
+sal_uLong GetUnoPortConfig()
+{
+ String aPortToTalk;
+
+ for ( sal_uInt16 i = 0 ; i < Application::GetCommandLineParamCount() ; i++ )
+ {
+ if ( Application::GetCommandLineParam( i ).Copy(0,9).CompareIgnoreCaseToAscii("-unoport=") == COMPARE_EQUAL
+#ifndef UNX
+ || Application::GetCommandLineParam( i ).Copy(0,9).CompareIgnoreCaseToAscii("/unoport=") == COMPARE_EQUAL
+#endif
+ )
+ {
+ aPortToTalk = Application::GetCommandLineParam( i ).Copy(6);
+ return (sal_uLong)aPortToTalk.ToInt64();
+ }
+ }
+
+ ByteString abPortToTalk;
+ Config aConf(Config::GetConfigName( Config::GetDefDirectory(), CUniString("testtool") ));
+ aConf.SetGroup("Communication");
+
+ GETSET( abPortToTalk, "UnoPort", ByteString::CreateFromInt32( UNO_DEFAULT_PORT ) );
+ return (sal_uLong)abPortToTalk.ToInt64();
+}
diff --git a/automation/source/testtool/tcommuni.hxx b/automation/source/testtool/tcommuni.hxx
new file mode 100644
index 000000000000..c3fec2f7b04d
--- /dev/null
+++ b/automation/source/testtool/tcommuni.hxx
@@ -0,0 +1,67 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include <automation/communi.hxx>
+#include <tools/link.hxx>
+#include <svl/svarray.hxx>
+
+#include <vos/thread.hxx>
+
+#ifndef _STRING_LIST
+DECLARE_LIST( StringList, String * )
+#define _STRING_LIST
+#endif
+#include <basic/process.hxx>
+
+class Process;
+
+class CommunicationManagerClientViaSocketTT : public CommunicationManagerClientViaSocket
+{
+public:
+ CommunicationManagerClientViaSocketTT();
+
+ using CommunicationManagerClientViaSocket::StartCommunication;
+ virtual sal_Bool StartCommunication();
+ virtual sal_Bool StartCommunication( String aApp, String aParams, Environment *pChildEnv );
+
+ sal_Bool KillApplication();
+
+protected:
+ virtual sal_Bool RetryConnect();
+ sal_Bool bApplicationStarted;
+ Time aFirstRetryCall;
+ String aAppPath;
+ String aAppParams;
+ Environment aAppEnv;
+ Process *pProcess;
+};
+
+
+String GetHostConfig();
+sal_uLong GetTTPortConfig();
+sal_uLong GetUnoPortConfig();
+
diff --git a/automation/source/testtool/testtool.ini b/automation/source/testtool/testtool.ini
new file mode 100644
index 000000000000..ff2e43f5c0f6
--- /dev/null
+++ b/automation/source/testtool/testtool.ini
@@ -0,0 +1,19 @@
+[Bootstrap]
+URE_BOOTSTRAP=${ORIGIN}/fundamentalbasis!INIFILESUFFIX!
+OOO_BASE_DIR=${ORIGIN}/..
+BRAND_BASE_DIR=${OOO_BASE_DIR}/!BRANDPATH!
+UserInstallation=${SYSUSERCONFIG}/.oootesttool
+
+[Misc]
+CurrentProfile=_profile_Default
+
+[OOoProgramDir]
+Type=Path
+Current=.
+
+[Crashreporter]
+UseProxy=false
+ProxyServer=none
+ProxyPort=8080
+AllowContact=false
+ReturnAddress=
diff --git a/automation/util/makefile.mk b/automation/util/makefile.mk
new file mode 100644
index 000000000000..756a3d6a62e4
--- /dev/null
+++ b/automation/util/makefile.mk
@@ -0,0 +1,288 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..
+
+PRJNAME=automation
+TARGET=automation
+TARGETTYPE=GUI
+
+# --- Settings ---------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Allgemein ---------------------------------------------------
+
+LIB1TARGET=$(SLB)$/$(TARGET).lib
+LIB1FILES= \
+ $(SLB)$/server.lib \
+ $(SLB)$/simplecm.lib \
+ $(SLB)$/communi.lib
+
+# --- sts library ---------------------------------------------------
+
+SHL1TARGET= sts$(DLLPOSTFIX)
+SHL1IMPLIB= ists
+
+SHL1STDLIBS= \
+ $(TOOLSLIB) \
+ $(UNOTOOLSLIB) \
+ $(SVTOOLLIB) \
+ $(SVLLIB) \
+ $(VCLLIB) \
+ $(BASICLIB) \
+ $(VOSLIB) \
+ $(SALLIB) \
+ $(CPPUHELPERLIB) \
+ $(CPPULIB) \
+ $(COMPHELPERLIB) \
+ $(SOTLIB)
+
+
+.IF "$(GUI)"=="WNT"
+SHL1STDLIBS+= \
+ $(ADVAPI32LIB) \
+ $(GDI32LIB)
+.ENDIF
+
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+SHL1LIBS= $(SLB)$/$(TARGET).lib
+
+DEF1NAME =$(SHL1TARGET)
+DEF1DEPN = \
+ $(MISC)$/$(SHL1TARGET).flt
+
+DEFLIB1NAME =$(TARGET)
+DEF1DES =TestToolServer
+
+# --- simple communication library (no vcl) ---------------------------------------------------
+
+SHL2TARGET= simplecm$(DLLPOSTFIX)
+SHL2IMPLIB= isimplecm
+
+SHL2STDLIBS= \
+ $(TOOLSLIB) \
+ $(VOSLIB) \
+ $(SALLIB)
+
+
+SHL2DEF= $(MISC)$/$(SHL2TARGET).def
+SHL2LIBS= $(SLB)$/simplecm.lib
+
+DEF2NAME =$(SHL2TARGET)
+DEF2DEPN = \
+ $(MISC)$/$(SHL2TARGET).flt
+
+DEFLIB2NAME =simplecm
+DEF2DES =SimpleCommunication
+
+# --- communication library ---------------------------------------------------
+
+SHL3TARGET= communi$(DLLPOSTFIX)
+SHL3IMPLIB= icommuni
+
+SHL3STDLIBS= \
+ $(TOOLSLIB) \
+ $(SVLLIB) \
+ $(VCLLIB) \
+ $(VOSLIB) \
+ $(SALLIB) \
+ $(VOSLIB) \
+ $(SIMPLECMLIB)
+
+
+.IF "$(GUI)"=="WNT"
+SHL3STDLIBS+= \
+ $(ADVAPI32LIB) \
+ $(GDI32LIB)
+.ENDIF
+
+SHL3DEF= $(MISC)$/$(SHL3TARGET).def
+SHL3LIBS= $(SLB)$/communi.lib
+SHL3DEPN=$(SHL2TARGETN)
+
+DEF3NAME =$(SHL3TARGET)
+DEF3DEPN = \
+ $(MISC)$/$(SHL3TARGET).flt
+
+DEFLIB3NAME =communi
+DEF3DES =Communication
+
+# --- TESTTOOL IDE ------------------------------------------------------
+
+APP1TARGET=testtool
+
+.IF "$(GUI)"=="UNX" || ("$(COM)"=="GCC" && "$(GUI)"=="WNT")
+APP1DEPN+=$(SHL2TARGETN) $(SHL3TARGETN)
+.ELSE
+APP1DEPN+=$(SHL2IMPLIBN) $(SHL3IMPLIBN)
+.ENDIF
+APP1STDLIBS= \
+ $(APP3RDLIB) \
+ $(SAMPLE3RDLIB)
+
+APP1STDLIBS+= \
+ $(CPPUHELPERLIB) \
+ $(TOOLSLIB) \
+ $(UNOTOOLSLIB) \
+ $(SVTOOLLIB) \
+ $(SVLLIB) \
+ $(VCLLIB) \
+ $(SALLIB) \
+ $(VOSLIB) \
+ $(UCBHELPERLIB) \
+ $(COMPHELPERLIB) \
+ $(BASICLIB) \
+ $(SIMPLECMLIB) \
+ $(COMMUNILIB)
+
+.IF "$(GUI)"=="UNX"
+APP1STDLIBS+= \
+ $(VOSLIB) $(SALLIB) $(BASICLIB)
+APP1STDLIBS+=$(CPPULIB)
+.ENDIF
+.IF "$(GUI)"=="WNT" || "$(COM)"=="GCC"
+APP1STDLIBS+=$(CPPULIB)
+.ENDIF
+
+.IF "$(GUI)"=="WNT"
+APP1STDLIBS += \
+ $(SHELL32LIB) \
+ $(ADVAPI32LIB)
+.ENDIF # "$(GUI)"=="WNT"
+
+
+
+.IF "$(OS)" == "SOLARIS"
+APP1STDLIBS+= -lXm
+.ENDIF
+
+.IF "$(GUI)" == "UNX"
+.IF "$(OS)" == "LINUX"
+APP1STDLIBS+= -lXext -lX11 -lSM -lICE
+.ENDIF
+.IF "$(OS)"=="MACOSX"
+APP1STDLIBS+= -lapp -lsample
+.ENDIF
+.ENDIF
+
+
+
+APP1LIBS=\
+ $(LB)$/testtool.lib
+
+APP1OBJS= $(OBJ)$/testbasi.obj \
+ $(OBJ)$/cmdbasestream.obj \
+ $(OBJ)$/svcommstream.obj
+
+# --- TESTTOOL MINIAPP ------------------------------------------------------
+# ressources are linked here
+
+RESLIB1NAME=tma
+RESLIB1SRSFILES= \
+ $(SRS)$/miniapp.srs
+
+APP3TARGET=miniapp
+APP3STDLIBS= \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(UCBHELPERLIB) \
+ $(COMPHELPERLIB) \
+ $(AUTOMATIONLIB) \
+ $(SALLIB) \
+ $(TOOLSLIB) \
+ $(SVTOOLLIB) \
+ $(VCLLIB)
+
+.IF "$(GUI)"=="UNX"
+.IF "$(OS)"=="MACOSX"
+APP3STDLIBS+= \
+ $(VOSLIB) $(SALLIB) $(LIBSTLPORT)
+.ELSE
+APP3STDLIBS+= \
+ $(VOSLIB) $(SALLIB)
+.ENDIF
+.ENDIF
+# $(AUTOMATIONLIB) is build in SHL1TARGET
+.IF "$(GUI)"=="UNX" || ("$(COM)"=="GCC" && "$(GUI)"=="WNT")
+APP3DEPN=$(SHL1TARGETN)
+.ELSE
+APP3DEPN=$(SHL1IMPLIBN)
+.ENDIF
+
+APP3LIBS= \
+ $(LB)$/miniapp.lib
+
+.IF "$(GUI)" != "UNX"
+.IF "$(COM)" != "GCC"
+# win16 braucht ein appobj
+APP3OBJS= $(OBJ)$/testapp.obj
+.ENDIF
+.ENDIF
+
+# --- Targets -----------------------------------------------------------
+
+.INCLUDE : target.mk
+
+# --- Basic-Filter-Datei ---
+
+$(MISC)$/$(SHL1TARGET).flt: makefile.mk
+ @echo ------------------------------
+ @echo Making: $@
+ @echo WEP > $@
+ @echo LIBMAIN >> $@
+ @echo LibMain >> $@
+ @echo Sbi >> $@
+ @echo exception >> $@
+ @echo bad_alloc >> $@
+ @echo __CT >> $@
+
+$(MISC)$/$(SHL2TARGET).flt: makefile.mk
+ @echo ------------------------------
+ @echo Making: $@
+ @echo WEP > $@
+ @echo LIBMAIN >> $@
+ @echo LibMain >> $@
+ @echo Sbi >> $@
+ @echo exception >> $@
+ @echo bad_alloc >> $@
+ @echo __CT >> $@
+
+$(MISC)$/$(SHL3TARGET).flt: makefile.mk
+ @echo ------------------------------
+ @echo Making: $@
+ @echo WEP > $@
+ @echo LIBMAIN >> $@
+ @echo LibMain >> $@
+ @echo Sbi >> $@
+ @echo exception >> $@
+ @echo bad_alloc >> $@
+ @echo __CT >> $@
+
+
+# ------------------------------------------------------------------------
+
diff --git a/automation/util/manually_added_ids.hid b/automation/util/manually_added_ids.hid
new file mode 100644
index 000000000000..7372dc0d9879
--- /dev/null
+++ b/automation/util/manually_added_ids.hid
@@ -0,0 +1,8 @@
+
+MSC_Super_ID 123456
+MSC_Super_ID2 1234567
+MSC_Super_ID3 12345678
+
+FontWork1TBO 40026
+FontWork2TBO 40027
+