diff options
Diffstat (limited to 'automation/source')
77 files changed, 25318 insertions, 0 deletions
diff --git a/automation/source/app/makefile.mk b/automation/source/app/makefile.mk new file mode 100644 index 000000000000..ab1de73cbe24 --- /dev/null +++ b/automation/source/app/makefile.mk @@ -0,0 +1,56 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2008 by Sun Microsystems, Inc. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.6 $ +# +# 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..a7454dc549bd --- /dev/null +++ b/automation/source/app/testbasi.cxx @@ -0,0 +1,164 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: testbasi.cxx,v $ + * $Revision: 1.9.14.1 $ + * + * 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( UINT16 nSbxId, UINT32 = SBXCR_SBX ); +}; + +static SampleObjectFac aFac1; +static MyFactory aFac2; +static CommunicationFactory aComManFac; +static ProcessFactory aProcessFac; +static short nInst = 0; + +SbxBase* MyFactory::Create( UINT16 nSbxId, 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, 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 ); +} + +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 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( 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..ad23306162ef --- /dev/null +++ b/automation/source/app/testbasi.hxx @@ -0,0 +1,67 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: testbasi.hxx,v $ + * $Revision: 1.7 $ + * + * 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(); + 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, BOOL bWasTTControl ); // Besimmt den erweiterten Symboltyp für das Syntaxhighlighting + virtual const String GetSpechialErrorText(); + virtual void ReportRuntimeError( AppBasEd *pEditWin ); + virtual void DebugFindNoErrors( 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..6f79551ecd72 --- /dev/null +++ b/automation/source/communi/communi.cxx @@ -0,0 +1,599 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: communi.cxx,v $ + * $Revision: 1.9 $ + * + * 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( USHORT nP, USHORT nL ) { \ + if( nL ) {\ + DBG_ASSERT( nP < nA && nP + nL <= nA, "ERR_VAR_DEL" );\ + for( USHORT 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* ); + +NAMESPACE_VOS(OMutex) *pMPostUserEvent=NULL; // Notwendig, da nicht threadfest + +CommunicationLinkViaSocket::CommunicationLinkViaSocket( CommunicationManager *pMan, NAMESPACE_VOS(OStreamSocket) *pSocket ) +: SimpleCommunicationLinkViaSocket( pMan, pSocket ) +, nConnectionClosedEventId( 0 ) +, nDataReceivedEventId( 0 ) +, bShutdownStarted( FALSE ) +, bDestroying( FALSE ) +{ + SetPutDataReceivedHdl(LINK( this, CommunicationLinkViaSocket, PutDataReceivedHdl )); + if ( !pMPostUserEvent ) + pMPostUserEvent = new NAMESPACE_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 = TRUE; + StopCommunication(); + while ( nConnectionClosedEventId || nDataReceivedEventId ) + GetpApp()->Yield(); + { + NAMESPACE_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 ); + } + } + { + NAMESPACE_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 ); + } + } +} + +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(); + + NAMESPACE_VOS(OStreamSocket) *pTempSocket = GetStreamSocket(); + SetStreamSocket( NULL ); + delete pTempSocket; + +// ConnectionClosed(); Wird am Ende des Thread gerufen + + } + else + { + join(); + } + + return TRUE; +} + +BOOL CommunicationLinkViaSocket::StopCommunication() +{ + if ( !bShutdownStarted ) + { + return SimpleCommunicationLinkViaSocket::StopCommunication(); + } + else + { + WaitForShutdown(); + return 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 = TRUE; + } + if ( bDestroying ) + { + while ( pMyManager && aShutdownTimer.IsActive() ) + { + if ( IsCommunicationError() ) + return; + GetpApp()->Yield(); + } + ShutdownCommunication(); + } +} + +BOOL CommunicationLinkViaSocket::IsCommunicationError() +{ + return !isRunning() || SimpleCommunicationLinkViaSocket::IsCommunicationError(); +} + +void CommunicationLinkViaSocket::run() +{ + BOOL bWasError = 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(); + { + NAMESPACE_VOS(OGuard) aGuard( aMDataReceived ); + NAMESPACE_VOS(OGuard) aGuard2( *pMPostUserEvent ); + mlPutDataReceived.Call(this); + } + } + TimeValue sNochEins = {0, 1000000}; + while ( schedule() && bIsInsideCallback ) // solange der letzte Callback nicht beendet ist + sleep( sNochEins ); + + StartCallback(); + { + NAMESPACE_VOS(OGuard) aGuard( aMConnectionClosed ); + NAMESPACE_VOS(OGuard) aGuard2( *pMPostUserEvent ); + nConnectionClosedEventId = GetpApp()->PostUserEvent( LINK( this, CommunicationLinkViaSocket, ConnectionClosed ) ); + } +} + +BOOL CommunicationLinkViaSocket::DoTransferDataStream( SvStream *pDataStream, CMProtocol nProtocol ) +{ + if ( !isRunning() ) + return FALSE; + + return SimpleCommunicationLinkViaSocket::DoTransferDataStream( pDataStream, nProtocol ); +} + +/// Dies ist ein virtueller Link!!! +long CommunicationLinkViaSocket::ConnectionClosed( void* EMPTYARG ) +{ + { + NAMESPACE_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 ) +{ + { + NAMESPACE_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( BOOL bUseMultiChannel ) +: CommunicationManager( bUseMultiChannel ) +, bGracefullShutdown( 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(); + USHORT nLinkCount = 0; + USHORT 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 + USHORT 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; +} + +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. + USHORT 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; +} + +BOOL MultiCommunicationManager::IsLinkValid( CommunicationLink* pCL ) +{ + if ( ActiveLinks->Seek_Entry( pCL ) ) + return TRUE; + else + return FALSE; +} + +USHORT MultiCommunicationManager::GetCommunicationLinkCount() +{ + return ActiveLinks->Count(); +} + +CommunicationLinkRef MultiCommunicationManager::GetCommunicationLink( USHORT 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 ); + + USHORT 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 = TRUE; +#endif +} + +void MultiCommunicationManager::DestroyingLink( CommunicationLink *pCL ) +{ + USHORT nPos; + if ( InactiveLinks->Seek_Entry( pCL, &nPos ) ) + InactiveLinks->Remove( nPos ); + pCL->InvalidateManager(); +} + + + +CommunicationManagerClient::CommunicationManagerClient( BOOL bUseMultiChannel ) +: MultiCommunicationManager( bUseMultiChannel ) +{ + ByteString aApplication("Something inside "); + aApplication.Append( ByteString( DirEntry( Application::GetAppFileName() ).GetName(), gsl_getSystemTextEncoding() ) ); + SetApplication( aApplication ); +} + + + +CommunicationManagerServerViaSocket::CommunicationManagerServerViaSocket( ULONG nPort, USHORT nMaxCon, BOOL bUseMultiChannel ) +: CommunicationManagerServer( bUseMultiChannel ) +, nPortToListen( nPort ) +, nMaxConnections( nMaxCon ) +, pAcceptThread( NULL ) +{ +} + +CommunicationManagerServerViaSocket::~CommunicationManagerServerViaSocket() +{ + StopCommunication(); +} + +BOOL CommunicationManagerServerViaSocket::StartCommunication() +{ + if ( !pAcceptThread ) + pAcceptThread = new CommunicationManagerServerAcceptThread( this, nPortToListen, nMaxConnections ); + return TRUE; +} + + +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, ULONG nPort, USHORT nMaxCon ) +: pMyServer( pServer ) +, pAcceptorSocket( NULL ) +, nPortToListen( nPort ) +, nMaxConnections( nMaxCon ) +, nAddConnectionEventId( 0 ) +, xmNewConnection( NULL ) +{ + if ( !pMPostUserEvent ) + pMPostUserEvent = new NAMESPACE_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 + { + NAMESPACE_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 NAMESPACE_VOS(OAcceptorSocket)(); + NAMESPACE_VOS(OInetSocketAddr) Addr; + Addr.setPort( nPortToListen ); + pAcceptorSocket->setReuseAddr( 1 ); + if ( !pAcceptorSocket->bind( Addr ) ) + { + return; + } + if ( !pAcceptorSocket->listen( nMaxConnections ) ) + { + return; + } + + + NAMESPACE_VOS(OStreamSocket) *pStreamSocket = NULL; + + while ( schedule() ) + { + pStreamSocket = new NAMESPACE_VOS(OStreamSocket); + switch ( pAcceptorSocket->acceptConnection( *pStreamSocket ) ) + { + case NAMESPACE_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(); + { + NAMESPACE_VOS(OGuard) aGuard( aMAddConnection ); + NAMESPACE_VOS(OGuard) aGuard2( *pMPostUserEvent ); + nAddConnectionEventId = GetpApp()->PostUserEvent( LINK( this, CommunicationManagerServerAcceptThread, AddConnection ) ); + } + } + break; + case NAMESPACE_VOS(ISocketTypes::TResult_TimedOut): + delete pStreamSocket; + pStreamSocket = NULL; + break; + case NAMESPACE_VOS(ISocketTypes::TResult_Error): + delete pStreamSocket; + pStreamSocket = NULL; + break; + + case NAMESPACE_VOS(ISocketTypes::TResult_Interrupted): + case NAMESPACE_VOS(ISocketTypes::TResult_InProgress): + break; // -Wall not handled... + } + } +} + + +IMPL_LINK( CommunicationManagerServerAcceptThread, AddConnection, void*, EMPTYARG ) +{ + { + NAMESPACE_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, ULONG nPort, BOOL bUseMultiChannel ) +: CommunicationManagerClient( bUseMultiChannel ) +, aHostToTalk( aHost ) +, nPortToTalk( nPort ) +{ +} + +CommunicationManagerClientViaSocket::CommunicationManagerClientViaSocket( 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..6c3a576c2e21 --- /dev/null +++ b/automation/source/communi/makefile.mk @@ -0,0 +1,48 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2008 by Sun Microsystems, Inc. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.7 $ +# +# 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..9af701f4fc25 --- /dev/null +++ b/automation/source/inc/cmdbasestream.hxx @@ -0,0 +1,88 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: cmdbasestream.hxx,v $ + * $Revision: 1.6 $ + * + * 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( SmartId *pUId, comm_String *pString ); + + void GenReturn( comm_USHORT nRet, comm_ULONG nNr ); + void GenReturn( comm_USHORT nRet, SmartId *pUId, comm_ULONG nNr ); + void GenReturn( comm_USHORT nRet, SmartId *pUId, comm_String *pString ); + void GenReturn( comm_USHORT nRet, SmartId *pUId, comm_BOOL bBool ); + void GenReturn( comm_USHORT nRet, SmartId *pUId, comm_ULONG nNr, comm_String *pString, comm_BOOL bBool ); + +// MacroRecorder + void GenReturn( comm_USHORT nRet, SmartId *pUId, comm_USHORT nMethod ); + void GenReturn( comm_USHORT nRet, SmartId *pUId, comm_USHORT nMethod, comm_String *pString ); + void GenReturn( comm_USHORT nRet, SmartId *pUId, comm_USHORT nMethod, comm_String *pString, comm_BOOL bBool ); + void GenReturn( comm_USHORT nRet, SmartId *pUId, comm_USHORT nMethod, comm_BOOL bBool ); + void GenReturn( comm_USHORT nRet, SmartId *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 ( SmartId* &pId ); + + virtual void Write( comm_String *pString ); + virtual void Write( SmartId* pId ); +}; + +#endif diff --git a/automation/source/inc/icommstream.hxx b/automation/source/inc/icommstream.hxx new file mode 100644 index 000000000000..9e0c0a44df47 --- /dev/null +++ b/automation/source/inc/icommstream.hxx @@ -0,0 +1,67 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: icommstream.hxx,v $ + * $Revision: 1.4 $ + * + * 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..8a5750284578 --- /dev/null +++ b/automation/source/inc/rcontrol.hxx @@ -0,0 +1,499 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: rcontrol.hxx,v $ + * $Revision: 1.10 $ + * + * 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 0 + + +#define SI_IPCCommandBlock 1 +#define SI_SocketCommandBlock SI_IPCCommandBlock // Zumindest erstmal +#define SI_DirectCommandBlock 2 +#define SIControl 3 +#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 ) +// 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 + + + +// Konstanten die im Basic zur Verfügung stehen sollen + +// Verschiedene Typen von Controls für den Befehl SetControlType +// !!!!!!!!!!! Müssen alle bei SetControlType eingetragen werden !!!!!!!!!!!! +#define CONST_CTBrowseBox 100 +#define CONST_CTValueSet 103 +#define CONST_CTORoadmap 104 +#define CONST_CTIExtensionListBox 105 +#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..cd84e72ae9a1 --- /dev/null +++ b/automation/source/inc/sttresid.hxx @@ -0,0 +1,45 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: sttresid.hxx,v $ + * $Revision: 1.3 $ + * + * 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..9474009824fd --- /dev/null +++ b/automation/source/inc/svcommstream.hxx @@ -0,0 +1,59 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: svcommstream.hxx,v $ + * $Revision: 1.5 $ + * + * 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..cf76571a81de --- /dev/null +++ b/automation/source/inc/testapp.hxx @@ -0,0 +1,198 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: testapp.hxx,v $ + * $Revision: 1.12.24.1 $ + * + * 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> +#include <vcl/smartid.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(ULONG nNr, String aStr = String()) : nError(nNr),aText(aStr),nLine(0),nCol1(0),nCol2(0) {} + ErrorEntry(ULONG nNr, String aStr, xub_StrLen l, xub_StrLen c1, xub_StrLen c2 ) + : nError(nNr),aText(aStr),nLine(l),nCol1(c1),nCol2(c2) {} + 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; + 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( BOOL bDebugFindNoErrors ); + +private: + BOOL bWasPrecompilerError; // True wenn beim letzten Precompile ein Fehler auftrat + BOOL CError( 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, USHORT &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 .. + 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* ); + 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; } + 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) + BOOL bReturnOK; // Bricht WaitForAnswer ab + CRevNames *pShortNames; // Aktuell verwendete Controls, zur gewinnung des Namens aus Fehlermeldung + ULONG nSequence; // Sequence um Antwort und Anfrage zu syncronisieren + SmartId 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 TRUE + String ProgPath; // Dateiname der zu Testenden APP; Gesetzt über Start + String aLogFileName; // Momentaner Logfilename (Wie Programmdatei aber mit .res) + BOOL IsBlock; // Innerhalb Begin/EndBlock + 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 + + + USHORT nMyVar; // Wievielte Var aus Pool ist dran + + void InitTestToolObj(); + CommunicationManagerClientViaSocketTT *pCommunicationManager; + void SendViaSocket(); + + BOOL Load( String aFileName, SbModule *pMod ); + + void ReadNames( String Filename, CNames *&pNames, CNames *&pUIds, BOOL bIsFlat = FALSE ); + void ReadFlat( String Filename, CNames *&pNames, BOOL bSortByName ); + BOOL ReadNamesBin( String Filename, CNames *&pSIds, CNames *&pControls ); + BOOL WriteNamesBin( String Filename, CNames *pSIds, CNames *pControls ); + void ReadHidLstByNumber(); + void SortControlsByNumber( BOOL bIncludeActive = FALSE ); + + String GetMethodName( ULONG nMethodId ); + String GetKeyName( USHORT nKeyCode ); + + void WaitForAnswer (); + DECL_LINK( IdleHdl, Application* ); + DECL_LINK( CallDialogHandler, Application* ); + String aDialogHandlerName; + USHORT nWindowHandlerCallLevel; + + USHORT 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, 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..3acf66b05d9d --- /dev/null +++ b/automation/source/inc/testtool.hxx @@ -0,0 +1,75 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: testtool.hxx,v $ + * $Revision: 1.6 $ + * + * 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; + + BOOL m_bIdleInserted; + AutoTimer m_aIdleTimer; + BOOL m_bInsideExecutionLoop; +#if OSL_DEBUG_LEVEL > 1 + EditWindow *m_pDbgWin; +#endif + +public: + ImplRemoteControl(); + ~ImplRemoteControl(); + BOOL QueCommands( 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..6f141178cb12 --- /dev/null +++ b/automation/source/miniapp/editwin.cxx @@ -0,0 +1,130 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: editwin.cxx,v $ + * $Revision: 1.5 $ + * + * 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 + + +BOOL GHEditWindow::Close() +{ + if (aInhalt.IsModified()) + { + } + delete(this); + return 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, 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,FALSE); + +} + +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..8c480afd792b --- /dev/null +++ b/automation/source/miniapp/editwin.hxx @@ -0,0 +1,73 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: editwin.hxx,v $ + * $Revision: 1.3 $ + * + * 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 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, BOOL bMoveToEnd = TRUE); +}; + + + +class EditFileWindow : public GHEditWindow +{ + + String aFileName; + virtual 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..4ab23d923cda --- /dev/null +++ b/automation/source/miniapp/makefile.mk @@ -0,0 +1,58 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2008 by Sun Microsystems, Inc. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.6 $ +# +# 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..fa0551c738fd --- /dev/null +++ b/automation/source/miniapp/servres.cxx @@ -0,0 +1,63 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: servres.cxx,v $ + * $Revision: 1.5 $ + * + * 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, 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, 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..21e7911a966d --- /dev/null +++ b/automation/source/miniapp/servres.hrc @@ -0,0 +1,43 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: servres.hrc,v $ + * $Revision: 1.3 $ + * + * 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 4 +#define IDM_FILE_OPEN_TEST_HELP 1 +#define IDM_FILE_HELP 3 +#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..fb85c0868444 --- /dev/null +++ b/automation/source/miniapp/servres.hxx @@ -0,0 +1,84 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: servres.hxx,v $ + * $Revision: 1.3 $ + * + * 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, BOOL bFreeRes = TRUE ); +}; + +class MenuMENU_CLIENT : public MenuBar +{ +protected: +public: + MenuMENU_CLIENT( const ResId & rResId, BOOL bFreeRes = TRUE ); +}; + diff --git a/automation/source/miniapp/servres.src b/automation/source/miniapp/servres.src new file mode 100644 index 000000000000..c9fb27ac5b7f --- /dev/null +++ b/automation/source/miniapp/servres.src @@ -0,0 +1,236 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: servres.src,v $ + * $Revision: 1.3 $ + * + * 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 = 1 ; + 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..1bc874b84335 --- /dev/null +++ b/automation/source/miniapp/servuid.hxx @@ -0,0 +1,40 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: servuid.hxx,v $ + * $Revision: 1.3 $ + * + * 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 101 +#define UID_CheckBox 202 +#define UID_TriStateBox 303 +#define UID_OKButton 404 +#define UID_TimeField 505 +#define UID_MultiLineEdit 606 +#define UID_RadioButton1 707 +#define UID_RadioButton2 708 +#define UID_MultiListBox 809 +#define UID_ComboBox 910 +#define UID_DateBox 1011 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..babe0e428440 --- /dev/null +++ b/automation/source/miniapp/testapp.cxx @@ -0,0 +1,353 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: testapp.cxx,v $ + * $Revision: 1.9.24.1 $ + * + * 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) + { + } +} + + +BOOL MainWindow::Close() +{ + WorkWindow::Close(); + FileExit(); + return TRUE; +} + +void MainWindow::FileExit() +{ +/* WriteSTBProfile();*/ + +// if (pApp->CloseAll()) + pApp->Quit(); +} + + +void MainWindow::Tree(GHEditWindow *aEditWin, Window *pBase, USHORT 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")); + aEditWin->AddText(String(sIndent).AppendAscii("Help: ").Append(String::CreateFromInt64(pBase->GetHelpId())).AppendAscii(":").Append(pBase->GetQuickHelpText()).AppendAscii(":").Append(pBase->GetHelpText()).AppendAscii("\n")); + + USHORT 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; + } +} + + +USHORT MyDispatcher::ExecuteFunction( USHORT nSID, SfxPoolItem** ppArgs, USHORT 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..0ab2b48d3579 --- /dev/null +++ b/automation/source/miniapp/testapp.hxx @@ -0,0 +1,128 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: testapp.hxx,v $ + * $Revision: 1.4 $ + * + * 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 <svtools/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 BOOL Close(); // derived + + void FileExit(); + void FileOpen(); + void TestGross(); + void Tree(GHEditWindow *aEditWin, Window *pBase, USHORT 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 USHORT ExecuteFunction( USHORT nSID, SfxPoolItem** ppArgs = 0, USHORT nMode = 0); + virtual void SetExecuteMode( USHORT 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..761f09d15c33 --- /dev/null +++ b/automation/source/mozillaserver/makefile.mk @@ -0,0 +1,157 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2008 by Sun Microsystems, Inc. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.7 $ +# +# 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..ac756be62095 --- /dev/null +++ b/automation/source/mozillaserver/mozillatesttoolserver.idl @@ -0,0 +1,55 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: mozillatesttoolserver.idl,v $ + * $Revision: 1.3 $ + * + * 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..c266a6df1d80 --- /dev/null +++ b/automation/source/mozillaserver/xmozillatesttoolserver.idl @@ -0,0 +1,160 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: xmozillatesttoolserver.idl,v $ + * $Revision: 1.3 $ + * + * 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..d9ef14461a1f --- /dev/null +++ b/automation/source/server/XMLParser.cxx @@ -0,0 +1,698 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: XMLParser.cxx,v $ + * $Revision: 1.10 $ + * + * 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) +{ + ULONG nCurrent = pStream->Tell(); + ULONG nSize = pStream->Seek( STREAM_SEEK_TO_END ); + 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 ); + ULONG GetChildCount(){ return aDocumentNodeList.Count(); } + NodeRef GetChild( USHORT 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; + 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; } + ULONG GetTimestamp(){ return nTimestamp; } + void Touch(){ nTimestamp = Time::GetSystemTicks(); } + + // Methods SAXParser + 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(); +} + +BOOL SAXParser::Parse( ParseAction aAct ) +{ + aAction = aAct; + Touch(); + SvStream* pStream = new SvFileStream( aFilename, STREAM_STD_READ ); + if ( pStream->GetError() ) + return 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 FALSE; + return 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 + BOOL bAllWhitespace = 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 = 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, aSmartMethodId, 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, aSmartMethodId, pSAXParser->GetErrors() ); + } + } + else + ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) ); + } + break; + case RC_SAXGetNodeType: + { + pRet->GenReturn ( RET_Value, aSmartMethodId, (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, aSmartMethodId, pElementNode->GetNodeName() ); + break; + case RC_SAXGetChildCount: + pRet->GenReturn ( RET_Value, aSmartMethodId, (comm_ULONG)pElementNode->GetChildCount() ); + break; + case RC_SAXGetAttributeCount: + if ( xAttributeList.is() ) + pRet->GenReturn ( RET_Value, aSmartMethodId, (comm_ULONG)xAttributeList->getLength() ); + else + pRet->GenReturn ( RET_Value, aSmartMethodId, (comm_ULONG)0 ); + break; + case RC_SAXGetAttributeName: + { + if( (nParams & PARAM_USHORT_1) && ValueOK( aSmartMethodId, RcString( nMethodId ), nNr1, xAttributeList.is()?xAttributeList->getLength():0 ) ) + { + String aRet( xAttributeList->getNameByIndex( nNr1-1 ) ); + pRet->GenReturn ( RET_Value, aSmartMethodId, aRet ); + } + else + ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) ); + } + break; + case RC_SAXGetAttributeValue: + // Number or String + { + if( (nParams & PARAM_USHORT_1) && ValueOK( aSmartMethodId, RcString( nMethodId ), nNr1, xAttributeList.is()?xAttributeList->getLength():0 ) ) + { + String aRet( xAttributeList->getValueByIndex( nNr1-1 ) ); + pRet->GenReturn ( RET_Value, aSmartMethodId, aRet ); + } + else if( (nParams & PARAM_STR_1) && xAttributeList.is() ) + { + String aRet( xAttributeList->getValueByName( aString1 ) ); + pRet->GenReturn ( RET_Value, aSmartMethodId, 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, aSmartMethodId, aCharacterNode->GetCharacters() ); + } + else + ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) ); + } + break; + + case RC_SAXSeekElement: + case RC_SAXHasElement: + // Number or String + { + BOOL bCheckOnly = nMethodId == RC_SAXHasElement; + + if( (nParams & PARAM_USHORT_1) && !(nParams & PARAM_STR_1) ) + { + if ( nNr1 == 0 ) + { + if ( bCheckOnly ) + pRet->GenReturn ( RET_Value, aSmartMethodId, 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, aSmartMethodId, ValueOK( aSmartMethodId, String(), nNr1, pElementNode->GetChildCount() ) ); + else if ( ValueOK( aSmartMethodId, 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, aSmartMethodId, (comm_BOOL)TRUE ); + else + pSAXParser->SetCurrentNode( pSAXParser->GetRootNode() ); + } + else if ( aString1.Copy(0,2).EqualsAscii( "*:" ) ) + { + ULONG nTimestamp = (ULONG)aString1.GetToken( 1, ':' ).ToInt64(); + ULONG nPointer = (ULONG)aString1.GetToken( 2, ':' ).ToInt64(); + if ( bCheckOnly ) + pRet->GenReturn ( RET_Value, aSmartMethodId, (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 ) + { + USHORT nNthOccurance; + if( (nParams & PARAM_USHORT_1) ) + nNthOccurance = nNr1; + else + nNthOccurance = 1; + + USHORT 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, aSmartMethodId, xNew.Is() ); + else + if ( xNew.Is() ) + pSAXParser->SetCurrentNode( xNew ); + else + ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) ); + } + else + if ( bCheckOnly ) + pRet->GenReturn ( RET_Value, aSmartMethodId, (comm_BOOL)FALSE ); + else + ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) ); + } + else + ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) ); + } + break; + case RC_SAXGetElementPath: + { + DBG_ASSERT( sizeof( ULONG ) == sizeof ( void* ), "Pointertype has different size than ULONG"); + String aPath; + aPath.AppendAscii( "*:" ); + aPath.Append( String::CreateFromInt64( pSAXParser->GetTimestamp() ) ); + aPath.AppendAscii( ":" ); + NodeRef xNode=pSAXParser->GetCurrentNode(); + Node* pNode = (Node*)(&xNode); + aPath.Append( String::CreateFromInt64( (ULONG)pNode ) ); + pRet->GenReturn ( RET_Value, aSmartMethodId, 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..48a982d78d31 --- /dev/null +++ b/automation/source/server/cmdbasestream.cxx @@ -0,0 +1,304 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: cmdbasestream.cxx,v $ + * $Revision: 1.7 $ + * + * 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 (SmartId *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, SmartId *pUId, comm_ULONG nNr ) +{ + Write(comm_USHORT(SIReturn)); + Write(nRet); + Write(pUId); + Write(comm_USHORT(PARAM_ULONG_1)); // Typ der folgenden Parameter + Write(nNr); +} + +void CmdBaseStream::GenReturn (comm_USHORT nRet, SmartId *pUId, comm_String *pString ) +{ + Write(comm_USHORT(SIReturn)); + Write(nRet); + Write(pUId); + Write(comm_USHORT(PARAM_STR_1)); // Typ der folgenden Parameter + Write(pString); +} + +void CmdBaseStream::GenReturn (comm_USHORT nRet, SmartId *pUId, comm_BOOL bBool ) +{ + Write(comm_USHORT(SIReturn)); + Write(nRet); + Write(pUId); + Write(comm_USHORT(PARAM_BOOL_1)); // Typ der folgenden Parameter + Write(bBool); +} + +void CmdBaseStream::GenReturn (comm_USHORT nRet, SmartId *pUId, comm_ULONG nNr, comm_String *pString, comm_BOOL bBool ) +{ + Write(comm_USHORT(SIReturn)); + Write(nRet); + Write(pUId); + Write(comm_USHORT(PARAM_ULONG_1|PARAM_STR_1|PARAM_BOOL_1)); // Typ der folgenden Parameter + Write(nNr); + Write(pString); + Write(bBool); +} + +// MacroRecorder +void CmdBaseStream::GenReturn( comm_USHORT nRet, SmartId *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, SmartId *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, SmartId *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, SmartId *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, SmartId *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 ( SmartId* &pId ) +{ + (void) pId; /* avoid warning about unused parameter */ + DBG_ERROR("Read ( SmartId* &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( SmartId* pId ) +{ + (void) pId; /* avoid warning about unused parameter */ + DBG_ERROR("Write( SmartId* pId ) Not Implemented"); +} + diff --git a/automation/source/server/editwin.cxx b/automation/source/server/editwin.cxx new file mode 100644 index 000000000000..137fc850a0a9 --- /dev/null +++ b/automation/source/server/editwin.cxx @@ -0,0 +1,167 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: editwin.cxx,v $ + * $Revision: 1.7 $ + * + * 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() ); +} + +BOOL EditWindow::Close() +{ + if ( pImpWorkWindow ) + { + delete pImpWorkWindow; + pImpWorkWindow = NULL; + } + return TRUE; +} + +void EditWindow::Show() +{ + if ( Check() ) + pImpWorkWindow->Show(); + else + bShowWin = TRUE; +} + +void EditWindow::Hide() +{ + if ( Check() ) + pImpWorkWindow->Hide(); + else + bShowWin = FALSE; +} + +EditWindow::EditWindow( WorkWindow *pParent, const String &rName, WinBits iWstyle ) +: pImpWorkWindow(NULL) +, pMemParent(pParent) +, aMemName(rName) +, iMemWstyle(iWstyle) +, nTextLen(0) +, bQuiet(FALSE) +{ +} + +EditWindow::~EditWindow() +{ + Close(); +} + +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 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..04da97fb8444 --- /dev/null +++ b/automation/source/server/editwin.hxx @@ -0,0 +1,77 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: editwin.hxx,v $ + * $Revision: 1.5 $ + * + * 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; + BOOL check(); + + WorkWindow *pMemParent; + String aMemName; + WinBits iMemWstyle; + + String aMemPreWinText; + 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 BOOL Close(); // derived + BOOL bQuiet; + BOOL Check(); +}; + +#endif +#endif + diff --git a/automation/source/server/makefile.mk b/automation/source/server/makefile.mk new file mode 100644 index 000000000000..5f0ada293432 --- /dev/null +++ b/automation/source/server/makefile.mk @@ -0,0 +1,75 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2008 by Sun Microsystems, Inc. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.7 $ +# +# 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..a437c42dc9b5 --- /dev/null +++ b/automation/source/server/prof_nul.cxx @@ -0,0 +1,99 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: prof_nul.cxx,v $ + * $Revision: 1.5 $ + * + * 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 *, USHORT ) +{}; + + +// 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..f2d8d9c47c38 --- /dev/null +++ b/automation/source/server/prof_usl.cxx @@ -0,0 +1,139 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: prof_usl.cxx,v $ + * $Revision: 1.7 $ + * + * 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, USHORT ) +{ + 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 ); + + + ULONG d_utime = DIFF_MS( pStart, pStop, mpstatus.pr_utime ) + DIFF_MS( pStart, pStop, mpstatus.pr_cutime ); + 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..5da7c55057d7 --- /dev/null +++ b/automation/source/server/profiler.cxx @@ -0,0 +1,267 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: profiler.cxx,v $ + * $Revision: 1.6 $ + * + * 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( FALSE ) +, bIsProfilingPerCommand( FALSE ) +, bIsPartitioning( FALSE ) +, bIsAutoProfiling( 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( BOOL bReadAnyway ) +{ + if ( !bIsProfileIntervalStarted || bReadAnyway ) + { + GetProfileSnapshot( mpStart ); + GetSysdepProfileSnapshot( mpStart->pSysdepProfileSnapshot, PROFILE_START ); + bIsProfileIntervalStarted = TRUE; + } +} + +String TTProfiler::GetProfileLine( ProfileSnapshot *pStart, ProfileSnapshot *pEnd ) +{ + String aProfileString; + + aProfileString += Pad(GetpApp()->GetAppLocaleDataWrapper().getDuration( DIFF( pStart, pEnd, aTime) , TRUE, TRUE ), 12); + + ULONG nProcessTicks = DIFF( pStart, pEnd, nProcessTicks ); + 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 = FALSE; +} + + +void TTProfiler::GetProfileSnapshot( ProfileSnapshot *pProfileSnapshot ) +{ + pProfileSnapshot->aTime = Time(); + pProfileSnapshot->nProcessTicks = Time::GetProcessTicks(); + pProfileSnapshot->nSystemTicks = Time::GetSystemTicks(); +} + + +void TTProfiler::StartProfilingPerCommand() // Jeden Befehl mitschneiden +{ + bIsProfilingPerCommand = TRUE; +} + +void TTProfiler::StopProfilingPerCommand() +{ + bIsProfilingPerCommand = FALSE; +} + +void TTProfiler::StartPartitioning() +{ + bIsPartitioning = TRUE; +} + +void TTProfiler::StopPartitioning() +{ + bIsPartitioning = TRUE; +} + +ULONG TTProfiler::GetPartitioningTime() +{ + return DIFF( mpStart, mpEnd, nSystemTicks ); +} + + + +void TTProfiler::StartAutoProfiling( 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 = 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 = FALSE; + } +} + + + +//String TTProfiler::Hex( ULONG nNr ) +String TTProfiler::Dec( 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..1a17c601e406 --- /dev/null +++ b/automation/source/server/profiler.hxx @@ -0,0 +1,140 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: profiler.hxx,v $ + * $Revision: 1.4 $ + * + * 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; + ULONG nProcessTicks; + ULONG nSystemTicks; +}; + + +class TTProfiler : private Timer +{ +public: + TTProfiler(); + ~TTProfiler(); + + String GetProfileHeader(); // Titelzeile für Logdatei + void StartProfileInterval( BOOL bReadAnyway = FALSE ); // Zustand merken + void EndProfileInterval(); // Informationszeile zusammenbauen + String GetProfileLine( String &aPrefix ); + + + void StartProfilingPerCommand(); // Jeden Befehl mitschneiden + void StopProfilingPerCommand(); + BOOL IsProfilingPerCommand() { return bIsProfilingPerCommand; } + + void StartPartitioning(); + void StopPartitioning(); + BOOL IsPartitioning() { return bIsPartitioning; } + ULONG GetPartitioningTime(); + + void StartAutoProfiling( ULONG nMSec ); // Automatisch alle nMSec Milisekunden sampeln + String GetAutoProfiling(); // Aktuelle `Sammlung` abholen + void StopAutoProfiling(); // Sampeln beenden + BOOL IsAutoProfiling() { return bIsAutoProfiling; } + +private: + + void GetProfileSnapshot( ProfileSnapshot *pProfileSnapshot ); + + // Informationszeile zusammenbauen + String GetProfileLine( ProfileSnapshot *pStart, ProfileSnapshot *pStop ); + + + ProfileSnapshot *mpStart; + ProfileSnapshot *mpEnd; + BOOL bIsProfileIntervalStarted; + + + +// + BOOL bIsProfilingPerCommand; + BOOL bIsPartitioning; + + +// Für das Automatische Profiling in festen Intervallen + + ProfileSnapshot *pAutoStart; + ProfileSnapshot *pAutoEnd; + BOOL bIsAutoProfiling; + String aAutoProfileBuffer; + + virtual void Timeout(); + + +// Einige Hilfsfunktionen + +// String Hex( ULONG nNr ); + String Dec( 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, USHORT 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..49f6f7608ef0 --- /dev/null +++ b/automation/source/server/recorder.cxx @@ -0,0 +1,1098 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: recorder.cxx,v $ + * $Revision: 1.13 $ + * + * 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( FALSE ) +, m_bRecord( FALSE ) +, m_bLog( 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( SmartId aParentID, USHORT nVCLWindowType, SmartId aID, String aMethod, USHORT nParam ) +{ + ::comphelper::UiEventsLogger::logVcl( aParentID.GetText(), nVCLWindowType, aID.GetText(), aMethod, nParam ); +} + +void MacroRecorder::LogVCL( SmartId aParentID, USHORT nVCLWindowType, SmartId aID, String aMethod ) +{ + ::comphelper::UiEventsLogger::logVcl( aParentID.GetText(), nVCLWindowType, aID.GetText(), aMethod ); +} + +Window* MacroRecorder::GetParentWithID( Window* pThis ) +{ + Window *pOverlap = pThis->GetWindow( WINDOW_OVERLAP ); + while ( pOverlap != pThis && !pThis->GetSmartUniqueOrHelpId().HasAny() && pThis->GET_REAL_PARENT() ) + pThis = pThis->GET_REAL_PARENT(); + return pThis; +} + +SmartId MacroRecorder::GetParentID( Window* pThis ) +{ + if ( pThis->GetParent() ) + return pThis->GetParent()->GetSmartUniqueOrHelpId(); + else + return SmartId(); +} + +IMPL_LINK( MacroRecorder, EventListener, VclSimpleEvent*, pEvent ) +{ + BOOL bSendData = FALSE; + + if ( pEvent->ISA( VclWindowEvent ) ) + { + VclWindowEvent* pWinEvent = ( VclWindowEvent* ) pEvent; + Window* pWin = pWinEvent->GetWindow(); + 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, (USHORT)M_TypeKeys, aKeyString, bKeyFollowFocus ); + else + StatementList::pRet->GenReturn( RET_MacroRecorder, aKeyUniqueID, (USHORT)M_TypeKeys, aKeyString ); +#if OSL_DEBUG_LEVEL > 1 + StatementList::pRet->GenReturn( RET_MacroRecorder, aKeyUniqueID, (USHORT)M_TypeKeys, String::CreateFromInt32( nEventID ) ); +#endif + bSendData = TRUE; + } + if ( m_bLog ) + { +// HACK Too many KeyEvents generated LogVCL( SmartId(), 0, aKeyUniqueID, CUniString("TypeKeys"), aKeyString.Len() ); + } + // cleanup + aKeyString.Erase(); + pKeyWin = NULL; + bKeyFollowFocus = FALSE; + } + + switch ( pWin->GetType() ) + { + case WINDOW_TABPAGE: + switch( nEventID ) + { + case VCLEVENT_WINDOW_ACTIVATE: + if ( m_bRecord ) + { + StatementList::pRet->GenReturn( RET_MacroRecorder, SmartId(), (comm_USHORT)(M_SetPage|M_RET_NUM_CONTROL), static_cast<comm_ULONG>(pWin->GetSmartUniqueOrHelpId().GetNum()) ); //GetNum() ULONG != comm_ULONG on 64bit + bSendData = TRUE; + } + if ( m_bLog ) + { + LogVCL( SmartId(), pWin->GetType(), pWin->GetSmartUniqueOrHelpId(), 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->GetSmartUniqueOrHelpId(), (comm_USHORT)M_Check ); + bSendData = TRUE; + } + if ( m_bLog ) + { + LogVCL( GetParentID( pWin ), pWin->GetType(), pWin->GetSmartUniqueOrHelpId(), 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->GetSmartUniqueOrHelpId(), nMethod ); + bSendData = TRUE; + } + if ( m_bLog ) + { + LogVCL( GetParentID( pWin ), pWin->GetType(), pWin->GetSmartUniqueOrHelpId(), 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->GetSmartUniqueOrHelpId(), (comm_USHORT)M_Select, comm_ULONG( ((ListBox*)pWin)->GetSelectEntryPos() +1 ) ); + bSendData = TRUE; + } + if ( m_bLog ) + { + LogVCL( GetParentID( pWin ), pWin->GetType(), pWin->GetSmartUniqueOrHelpId(), 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(); + + USHORT nPos = ((ComboBox*)pWin)->GetEntryPos(((ComboBox*)pWin)->GetText()); + if ( m_bRecord ) + { + if ( nPos == COMBOBOX_ENTRY_NOTFOUND ) + Sound::Beep(); + else + { + StatementList::pRet->GenReturn( RET_MacroRecorder, pWin->GetSmartUniqueOrHelpId(), (comm_USHORT)M_Select, (comm_ULONG) nPos+1 ); + bSendData = TRUE; + } + } + if ( m_bLog ) + { + LogVCL( GetParentID( pWin ), pWin->GetType(), pWin->GetSmartUniqueOrHelpId(), 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(); + BOOL bDone = FALSE; + if ( pParent->IsDialog() && !pWin->GetSmartUniqueOrHelpId().HasAny() ) + { + 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 :-( + USHORT nCurrentButtonId = 0xffff; // Some wild value to wak up people + USHORT 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, SmartId( 0 ), nMethod ); + else + StatementList::pRet->GenReturn( RET_MacroRecorder, SmartId( 0 ), nMethod, (comm_ULONG)nCurrentButtonId ); + bSendData = TRUE; + } + if ( m_bLog ) + { + if ( nMethod != M_Click ) + LogVCL( SmartId(), pWin->GetType(), pWin->GetSmartUniqueOrHelpId(), aMethod ); + else + LogVCL( SmartId(), pWin->GetType(), pWin->GetSmartUniqueOrHelpId(), aMethod, nCurrentButtonId ); + bDone = 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->GetSmartUniqueOrHelpId(), nMethod ); + bSendData = TRUE; + } + if ( m_bLog ) + { + LogVCL( GetParentID( pWin ), pWin->GetType(), pWin->GetSmartUniqueOrHelpId(), aMethod ); + bDone = TRUE; + } + } + break; + } + } + if ( m_bRecord ) + { + if ( !bSendData && pWin->GetSmartUniqueOrHelpId().HasAny() ) + { + StatementList::pRet->GenReturn( RET_MacroRecorder, pWin->GetSmartUniqueOrHelpId(), (comm_USHORT)M_Click ); + bSendData = TRUE; + } + } + if ( m_bLog ) + { + if ( !bDone ) + LogVCL( GetParentID( pWin ), pWin->GetType(), pWin->GetSmartUniqueOrHelpId(), 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(TRUE); + break; + case M_Close : + ((MoreButton*)pControl)->SetState(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->GetSmartUniqueOrHelpId(), nMethod ); + bSendData = TRUE; + } + if ( m_bLog ) + { + LogVCL( GetParentID( pWin ), pWin->GetType(), pWin->GetSmartUniqueOrHelpId(), 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->GetSmartUniqueOrHelpId(), (comm_USHORT)M_Click ); + bSendData = TRUE; + } + if ( m_bLog ) + { + LogVCL( GetParentID( pWin ), pWin->GetType(), pWin->GetSmartUniqueOrHelpId(), 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 ); + + ULONG nStart = Time::GetSystemTicks(); + 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->GetSmartUniqueOrHelpId().HasAny() || pWin->GetSmartUniqueOrHelpId().Matches( 1 ) ) + // generate direct Button access + StatementList::pRet->GenReturn( RET_MacroRecorder, SmartId( pTB->GetItemCommand( pTB->GetCurItemId() ) ), (comm_USHORT)(M_Click) ); + else + // access via Toolbox + StatementList::pRet->GenReturn( RET_MacroRecorder, pTB->GetSmartUniqueOrHelpId(), (comm_USHORT)(M_Click|M_RET_NUM_CONTROL), static_cast<comm_ULONG>(pTB->GetHelpId( pTB->GetCurItemId() )) ); // GetHelpId() ULONG != comm_ULONG on 64bit + bSendData = 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, SmartId( 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() ULONG != comm_ULONG on 64bit +// bSendData = TRUE; +// } +// if ( m_bLog ) +// { +// LogVCL( pActionParent->GetSmartUniqueOrHelpId(), pWin->GetType(), SmartId( 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 = FALSE;\ + }\ + else if ( !pTB->IsItemVisible( pTB->GetItemId(nNr1) ) )\ + {\ + ReportError( nUId, GEN_RES_STR1( S_BUTTON_HIDDEN_ON_TOOLBOX, MethodString( nMethodId ) ) );\ + bBool1 = FALSE;\ + }\ + else\ + {\ + if ( pTB->GetItemRect(pTB->GetItemId(nNr1)).IsEmpty() )\ + {\ + USHORT nLine = pTB->GetCurLine();\ + do\ + {\ + pTB->ShowLine( 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 = 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 = TRUE; + aKeyUniqueID = pIdWin->GetSmartUniqueOrHelpId(); + if ( m_bLog ) + { +// HACK Too many KeyEvents generated if ( aKeyString.Len() == 0 ) +// HACK Too many KeyEvents generated LogVCL( SmartId(), 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 ); +// BOOL bx = ((DockingWindow*)pWin)->IsFloatingMode(); +// break; +/* case M_Dock : + if ( ((DockingWindow*)pControl)->IsFloatingMode() ) + ((DockingWindow*)pControl)->SetFloatingMode(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(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 = 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: + { + BOOL bDone = 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 = 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->GetSmartUniqueOrHelpId(), M_SetText, aEditModifyString ); + bSendData = TRUE; + } + if ( m_bLog ) + { + LogVCL( GetParentID( pWin ), pWin->GetType(), pWin->GetSmartUniqueOrHelpId(), 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; +} + +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..13e78f46d480 --- /dev/null +++ b/automation/source/server/recorder.hxx @@ -0,0 +1,87 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: recorder.hxx,v $ + * $Revision: 1.2 $ + * + * 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/smartid.hxx> +#include <vcl/timer.hxx> + +class ToolBox; +class Window; +class VclSimpleEvent; + +class MacroRecorder +{ +private: + Window* GetParentWithID( Window* pThis ); + SmartId 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; + SmartId aKeyUniqueID; // has to be remembered seperately since Window might be gone when needed + Window* pKeyWin; + BOOL bKeyFollowFocus; + + AutoTimer aHookRefresh; + void AddEventHooks(); + void RemoveEventHooks(); + DECL_LINK( HookRefreshHdl, void* ); + + void LogVCL( SmartId aParentID, USHORT nVCLWindowType, SmartId aID, String aMethod, USHORT aParam ); + void LogVCL( SmartId aParentID, USHORT nVCLWindowType, SmartId aID, String aMethod ); + + static MacroRecorder *pMacroRecorder; + + MacroRecorder(); + ~MacroRecorder(); + void CheckDelete(); + + // Actions to perform + BOOL m_bRecord; + BOOL m_bLog; + +public: + + void SetActionRecord( BOOL bRecord = TRUE ) { m_bRecord = bRecord; CheckDelete(); }; + void SetActionLog( BOOL bLog = TRUE ) { m_bLog = bLog; CheckDelete(); }; + + static MacroRecorder* GetMacroRecorder(); + static BOOL HasMacroRecorder(); +}; + diff --git a/automation/source/server/retstrm.cxx b/automation/source/server/retstrm.cxx new file mode 100644 index 000000000000..04b73ac9ebb6 --- /dev/null +++ b/automation/source/server/retstrm.cxx @@ -0,0 +1,125 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: retstrm.cxx,v $ + * $Revision: 1.7 $ + * + * 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 "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 ( SmartId aUId, String aString ) +{ + CmdBaseStream::GenError ( &aUId, &aString ); +} + +void RetStream::GenReturn ( USHORT nRet, SmartId aUId, String aString ) +{ + CmdBaseStream::GenReturn ( nRet, &aUId, &aString ); +} + +void RetStream::GenReturn ( USHORT nRet, SmartId aUId, SbxValue &aValue ) +{ + Write(USHORT(SIReturn)); + Write(nRet); + Write(&aUId); + Write(USHORT(PARAM_SBXVALUE_1)); // Typ der folgenden Parameter + Write(aValue); +} + +void RetStream::GenReturn ( USHORT nRet, SmartId aUId, comm_ULONG nNr, String aString, BOOL bBool ) +{ + CmdBaseStream::GenReturn ( nRet, &aUId, nNr, &aString, bBool ); +} + +void RetStream::GenReturn( USHORT nRet, SmartId aUId, comm_USHORT nMethod, String aString ) +{ + CmdBaseStream::GenReturn ( nRet, &aUId, nMethod, &aString ); +} + +void RetStream::GenReturn( USHORT nRet, SmartId aUId, comm_USHORT nMethod, String aString, BOOL bBool ) +{ + CmdBaseStream::GenReturn ( nRet, &aUId, nMethod, &aString, bBool ); +} + + +void RetStream::Write( String *pString ) +{ + CmdBaseStream::Write( pString->GetBuffer(), pString->Len() ); +} + +void RetStream::Write( SbxValue &aValue ) +{ + *pSammel << USHORT( BinSbxValue ); + aValue.Store( *pSammel ); +} + +void RetStream::Write( SmartId* pId ) +{ + DBG_ASSERT( !pId->HasString() || !pId->HasNumeric(), "SmartId contains Number and String. using String only." ); + if ( pId->HasString() ) + { + String aTmp( pId->GetStr() ); + Write( &aTmp ); + } + else + Write( static_cast<comm_ULONG>(pId->GetNum()) ); ////GetNum() ULONG != comm_ULONG on 64bit +} + + +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..537aa3db216c --- /dev/null +++ b/automation/source/server/retstrm.hxx @@ -0,0 +1,87 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: retstrm.hxx,v $ + * $Revision: 1.8 $ + * + * 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 <vcl/smartid.hxx> +#include "cmdbasestream.hxx" + +class SvStream; + +class RetStream: public CmdBaseStream +{ + +public: + RetStream(); + ~RetStream(); + + using CmdBaseStream::GenError; +// void GenError( comm_ULONG nError, const comm_UniChar* aString, comm_USHORT nLenInChars ){CmdBaseStream::GenError( nError, aString, nLenInChars );} +// new + void GenError( SmartId aUId, String aString ); + + using CmdBaseStream::GenReturn; + void GenReturn( comm_USHORT nRet, comm_ULONG nNr ){CmdBaseStream::GenReturn( nRet, nNr );} + void GenReturn( comm_USHORT nRet, SmartId aUId, comm_ULONG nNr ){CmdBaseStream::GenReturn( nRet, &aUId, nNr );} + void GenReturn( comm_USHORT nRet, SmartId aUId, comm_BOOL bBool ){CmdBaseStream::GenReturn( nRet, &aUId, bBool );} +// MacroRecorder + void GenReturn( comm_USHORT nRet, SmartId aUId, comm_USHORT nMethod ){CmdBaseStream::GenReturn( nRet, &aUId, nMethod );} + void GenReturn( comm_USHORT nRet, SmartId aUId, comm_USHORT nMethod, comm_BOOL bBool ){CmdBaseStream::GenReturn( nRet, &aUId, nMethod, bBool );} + void GenReturn( comm_USHORT nRet, SmartId aUId, comm_USHORT nMethod, comm_ULONG nNr ){CmdBaseStream::GenReturn( nRet, &aUId, nMethod, nNr );} + +// new + void GenReturn( USHORT nRet, SmartId aUId, String aString ); + void GenReturn( USHORT nRet, SmartId aUId, SbxValue &aValue ); + void GenReturn( USHORT nRet, SmartId aUId, comm_ULONG nNr, String aString, BOOL bBool ); +// MacroRecorder + void GenReturn( USHORT nRet, SmartId aUId, comm_USHORT nMethod, String aString ); + void GenReturn( USHORT nRet, SmartId aUId, comm_USHORT nMethod, String aString, 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( SmartId* 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..8888a007918c --- /dev/null +++ b/automation/source/server/scmdstrm.cxx @@ -0,0 +1,218 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: scmdstrm.cxx,v $ + * $Revision: 1.7 $ + * + * 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/intitem.hxx> +#include <svtools/stritem.hxx> +#include <svtools/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; + USHORT nLenInChars; + CmdBaseStream::Read( pStr, nLenInChars ); + + *pString = String( pStr, nLenInChars ); + delete [] pStr; +} + +void SCmdStream::Read (String &aString) +{ + comm_UniChar* pStr; + USHORT nLenInChars; + CmdBaseStream::Read( pStr, nLenInChars ); + + aString = String( pStr, nLenInChars ); + delete [] pStr; +} + +void SCmdStream::Read ( SfxPoolItem *&pItem ) +{ + USHORT nType; + USHORT 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 ) +{ + USHORT 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..874e9f41bbb6 --- /dev/null +++ b/automation/source/server/scmdstrm.hxx @@ -0,0 +1,64 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: scmdstrm.hxx,v $ + * $Revision: 1.5 $ + * + * 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..988f4055a2eb --- /dev/null +++ b/automation/source/server/server.cxx @@ -0,0 +1,981 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: server.cxx,v $ + * $Revision: 1.26 $ + * + * 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 <svtools/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 + + +ULONG RemoteControlCommunicationManager::nPortIs = TT_PORT_NOT_INITIALIZED; +USHORT RemoteControlCommunicationManager::nComm = 0; +BOOL RemoteControlCommunicationManager::bQuiet = FALSE; + +#if OSL_DEBUG_LEVEL > 1 +RemoteControlCommunicationManager::RemoteControlCommunicationManager( EditWindow * pDbgWin ) +#else +RemoteControlCommunicationManager::RemoteControlCommunicationManager() +#endif +: CommunicationManagerServerViaSocket( GetPort(), 1, 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 +} + +ULONG RemoteControlCommunicationManager::GetPort() +{ + if ( TT_PORT_NOT_INITIALIZED == nPortIs ) + { // Read Config + + USHORT i; + // are we to be automated at all? + BOOL bAutomate = FALSE; + for ( i = 0 ; i < Application::GetCommandLineParamCount() ; i++ ) + { + if ( Application::GetCommandLineParam( i ).EqualsIgnoreCaseAscii("/enableautomation") + || Application::GetCommandLineParam( i ).EqualsIgnoreCaseAscii("-enableautomation")) + { + bAutomate = 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 = (USHORT)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(); + + USHORT 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 + ULONG nLastInputInterval = Application::GetLastInputInterval(); + 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((USHORT)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 ( USHORT 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() ); + } + +/*********************************************************************** +// USHORT 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 = 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 = 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 = 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 = FALSE; + } + + StatementList::aWindowWaitUId = SmartId(); // 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; +} + +BOOL ImplRemoteControl::QueCommands( ULONG nServiceId, SvStream *pIn ) +{ +// return TRUE; + USHORT 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 = TRUE; + } + + + StatementList::bReadingCommands = 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 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 = 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 = TRUE; +#endif + return TRUE; +} // BOOL ImplRemoteControl::QueCommands( ULONG nServiceId, SvStream *pIn ) + + +SvStream* ImplRemoteControl::GetReturnStream() +{ + SvStream* pTemp = pRetStream; + pRetStream = NULL; + return pTemp; +} + +ImplRemoteControl::ImplRemoteControl() +: m_bIdleInserted( FALSE ) +, m_bInsideExecutionLoop( 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 = TRUE; + m_pDbgWin->Hide(); + 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( FALSE ); // Will delete MacroRecorder if necessary + + + StatementList::bDying = TRUE; +#if OSL_DEBUG_LEVEL > 1 + if ( m_pDbgWin ) + m_pDbgWin->bQuiet = 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 = 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( 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..f3674c79af16 --- /dev/null +++ b/automation/source/server/server.hxx @@ -0,0 +1,84 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: server.hxx,v $ + * $Revision: 1.6 $ + * + * 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 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; + BOOL bIsPortValid; + DECL_LINK( SetWinCaption, Timer* = NULL); + Timer* pTimer; + virtual void InfoMsg( InfoString aMsg ); + static ULONG nPortIs; + static 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 ULONG GetPort(); + static USHORT 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..6f114ae57f5b --- /dev/null +++ b/automation/source/server/sta_list.cxx @@ -0,0 +1,1226 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: sta_list.cxx,v $ + * $Revision: 1.30 $ + * + * 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> + +#define WINDOW_ANYTYPE WINDOW_BASE + + +TTProfiler *StatementList::pProfiler = NULL; +StatementList *StatementList::pFirst = NULL; +BOOL StatementList::bReadingCommands = FALSE; +BOOL StatementList::bIsInReschedule = FALSE; +USHORT StatementList::nModalCount = 0; +Window *StatementList::pLastFocusWindow = NULL; +BOOL StatementList::bWasDragManager = FALSE; +BOOL StatementList::bWasPopupMenu = FALSE; +BOOL StatementList::bBasicWasRunning = FALSE; +RetStream *StatementList::pRet = NULL; +BOOL StatementList::IsError = FALSE; +BOOL StatementList::bDying = FALSE; +BOOL StatementList::bExecuting = FALSE; +StatementList *StatementList::pCurrentProfileStatement = NULL; +BOOL StatementList::bUsePostEvents = TRUE; +#if OSL_DEBUG_LEVEL > 1 +EditWindow *StatementList::m_pDbgWin; +#endif + + +SmartId StatementList::aWindowWaitUId = SmartId(); +Window *StatementList::pWindowWaitPointer = NULL; +SmartId StatementList::aWindowWaitOldHelpId = SmartId(); +SmartId StatementList::aWindowWaitOldUniqueId = SmartId(); +USHORT StatementList::nUseBindings = 0; + +SmartId StatementList::aSubMenuId1 = SmartId(); // Untermenüs bei PopupMenus +SmartId StatementList::aSubMenuId2 = SmartId(); // erstmal 2-Stufig +SmartId StatementList::aSubMenuId3 = SmartId(); // and now even 3 levels #i31512# +SystemWindow *StatementList::pMenuWindow = NULL; +TTProperties *StatementList::pTTProperties = NULL; + +USHORT StatementList::nMinTypeKeysDelay = 0; // Verzögerung der einzelnen Anschläge für TypeKeys +USHORT StatementList::nMaxTypeKeysDelay = 0; +BOOL StatementList::bDoTypeKeysDelay = FALSE; + +Window* StatementList::pFirstDocFrame = NULL; + +BOOL StatementList::bIsSlotInExecute = FALSE; + +BOOL StatementList::bCatchGPF = 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 = TRUE; + } + + return pTTSettings; +} + + + + +#define IS_WINP_CLOSING(pWin) (pWin->GetSmartHelpId().Matches( 4321 ) && pWin->GetSmartUniqueId().Matches( 1234 )) + +/* +UniString GEN_RES_STR0( ULONG nResId ) { return ResString( nResId ); } +UniString GEN_RES_STR1( ULONG nResId, const UniString &Text1 ) { return GEN_RES_STR0( nResId ).Append( ArgString( 1, Text1 ) ); } +UniString GEN_RES_STR2( ULONG nResId, const UniString &Text1, const UniString &Text2 ) { return GEN_RES_STR1( nResId, Text1 ).Append( ArgString( 2, Text2 ) ); } +UniString GEN_RES_STR3( 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(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, SmartId(), 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, SmartId(), pProfiler->GetProfileLine( aText ) ); + + if ( pProfiler->IsPartitioning() ) + pRet->GenReturn( RET_ProfileInfo, SmartId( S_ProfileTime ), static_cast<comm_ULONG>(pProfiler->GetPartitioningTime()) ); // GetPartitioningTime() ULONG != comm_ULONG on 64bit + } + + if ( pProfiler->IsAutoProfiling() ) + pRet->GenReturn( RET_ProfileInfo, SmartId(), pProfiler->GetAutoProfiling() ); + +#if OSL_DEBUG_LEVEL > 1 + if ( pCurrentProfileStatement == NULL ) + pRet->GenReturn( RET_ProfileInfo, SmartId(), 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 = 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 = 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( USHORT nNr ) +{ + Window* pBase = Application::GetFirstTopLevelWindow(); + + while ( pBase ) + { + if ( IsDocWin( pBase ) ) + { + if ( !nNr ) + return pBase; + nNr--; + } + pBase = Application::GetNextTopLevelWindow( pBase ); + } + return NULL; +} + +USHORT StatementList::GetDocFrameCount() +{ + Window* pBase = Application::GetFirstTopLevelWindow(); + USHORT nCount = 0; + + while ( pBase ) + { + if ( IsDocFrame( pBase ) ) + nCount++; + pBase = Application::GetNextTopLevelWindow( pBase ); + } + return nCount; +} + +USHORT StatementList::GetDocWinCount() +{ + Window* pBase = Application::GetFirstTopLevelWindow(); + USHORT nCount = 0; + + while ( pBase ) + { + if ( IsDocWin( pBase ) ) + nCount++; + pBase = Application::GetNextTopLevelWindow( pBase ); + } + return nCount; +} + +Window* StatementList::SearchAllWin( Window *pBase, Search &aSearch, BOOL MaybeBase ) +{ + + if ( !pBase && !aSearch.HasSearchFlag( SEARCH_NO_TOPLEVEL_WIN ) ) + { + 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, BOOL MaybeBase ) +{ + if ( !pBase ) + return NULL; + + if ( MaybeBase && aSearch.IsWinOK( pBase ) ) + return pBase; + + Window *pResult = NULL; + + USHORT i; + for( i = 0 ; i < pBase->GetChildCount() && !pResult; i++ ) + pResult = SearchClientWin( pBase->GetChild(i), aSearch ); + + return pResult; +} + + +BOOL SearchUID::IsWinOK( Window *pWin ) +{ + if ( aUId.Matches( pWin->GetSmartUniqueOrHelpId() ) ) + { + if ( ( pWin->IsEnabled() || HasSearchFlag( SEARCH_FIND_DISABLED ) ) && pWin->IsVisible() ) + return TRUE; + else + { + if ( !pMaybeResult ) + pMaybeResult = pWin; + return FALSE; + } + } + else if ( pWin->GetType() == WINDOW_TOOLBOX ) // Buttons and Controls on ToolBox. + { + ToolBox *pTB = ((ToolBox*)pWin); + USHORT i; + for ( i = 0; i < pTB->GetItemCount() ; i++ ) + { + if ( aUId.Matches( pTB->GetItemCommand(pTB->GetItemId( i )) ) || aUId.Matches( 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 TRUE; // We got a Button. + else + { // better a disabled Button on a valid ToolBox than an invalid ToolBox as below + pMaybeResult = pTB; + return FALSE; + } + } + else if ( !pMaybeResult ) + { // invalid ToolBox + pMaybeResult = pTB; + return 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 FALSE; // continue searching to prefer a window with the right ID #i32292 + } + else if ( !pMaybeResult ) + { + pMaybeResult = pItemWin; + return FALSE; + } + } + } + } + return FALSE; + } + else + return FALSE; +} + +Window* StatementList::SearchTree( SmartId aUId ,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(); +} + + +BOOL SearchWinPtr::IsWinOK( Window *pWin ) +{ + return pWin == pTest; +} + +BOOL StatementList::WinPtrValid(Window *pTest) +{ + SearchWinPtr aSearch( pTest ); + return SearchAllWin( NULL, aSearch ) != NULL; +} + + +BOOL SearchRT::IsWinOK( Window *pWin ) +{ + if ( pWin->IsVisible() && pWin->GetType() == mnRT ) + { + mnCount++; + if ( mnSkip ) + { + mnSkip--; + return FALSE; + } + else + return TRUE; + } + return FALSE; +} + +Window* StatementList::GetWinByRT( Window *pBase, WindowType nRT, BOOL MaybeBase, USHORT nSkip, 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 ); +} + +USHORT StatementList::CountWinByRT( Window *pBase, WindowType nRT, BOOL MaybeBase ) +{ + SearchRT aSearch( nRT, SEARCH_NOOVERLAP | SEARCH_NO_TOPLEVEL_WIN, 0xFFFF ); + + SearchAllWin( pBase, aSearch, MaybeBase ); + return aSearch.GetCount(); +} + +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 FALSE; +} + +ScrollBar* StatementList::GetScrollBar( Window *pBase, USHORT nDirection, BOOL MaybeBase ) +{ + SearchScroll aSearch( nDirection, SEARCH_NOOVERLAP | SEARCH_NO_TOPLEVEL_WIN ); + + return (ScrollBar*)SearchAllWin( pBase, aSearch, MaybeBase ); +} + + +BOOL SearchPopupFloatingWin::IsWinOK( Window *pWin ) +{ + return pWin->IsVisible() && pWin->GetType() == WINDOW_FLOATINGWINDOW && ((FloatingWindow*)pWin)->IsInPopupMode(); +} + +Window* StatementList::GetPopupFloatingWin( BOOL MaybeBase ) +{ + SearchPopupFloatingWin aSearch; + + return SearchAllWin( NULL, aSearch, MaybeBase ); +} + + +Menu* StatementList::GetMatchingMenu( Window* pWin, Menu* pBaseMenu ) +{ + if ( pBaseMenu ) + { + if ( pBaseMenu->GetWindow() == pWin ) + return pBaseMenu; + + USHORT 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; + } + + USHORT nSkip = 0; + Window* pMenuBarWin = NULL; + while ( (pMenuBarWin = GetWinByRT( NULL, WINDOW_MENUBARWINDOW, TRUE, nSkip++, TRUE )) != NULL ) + { + Window* pParent = pMenuBarWin->GET_REAL_PARENT(); + if ( pParent && pParent->GetType() == WINDOW_BORDERWINDOW && pParent->IsVisible() ) + { + Menu* pMenu = NULL; + // find Menu of MenuBarWindow + USHORT 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; +} + + +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, BOOL MaybeBase ) +{ + SearchActive aSearch( nRT ); + + return SearchAllWin( NULL, aSearch, MaybeBase ); +} + +BOOL SearchFadeSplitWin::IsWinOK( Window *pWin ) +{ +#if OSL_DEBUG_LEVEL > 1 + if ( pWin->GetType() == WINDOW_SPLITWINDOW ) + { + 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, 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, BOOL MaybeBase ) +{ + + if ( nRT == WINDOW_TABCONTROL ) + { + Window *pResult = GetActive( WINDOW_TABDIALOG, MaybeBase); + for( USHORT i = 0 ; pResult && i < pResult->GetChildCount(); i++ ) + if ( pResult->GetChild(i)->GetType() == nRT ) + return pResult->GetChild(i); + } + + return NULL; +} + +Window* StatementList::GetAnyActive( 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; +} + +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 ) + { + USHORT 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 +BOOL StatementList::IsDocFrame( Window* pWin ) +{ + if ( pWin && pWin->IsVisible() && pWin->GetType() == WINDOW_BORDERWINDOW ) + { + USHORT nCount; + BOOL bHasWorkWindow = FALSE; + BOOL bHasMenuBar = 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 = TRUE; + if ( pWin->GetChild( nCount )->GetType() == WINDOW_MENUBARWINDOW ) + bHasMenuBar = TRUE; + } + return bHasWorkWindow && bHasMenuBar; + } + return FALSE; +} + +// a Doc Win is a real document (not the Backing Window) +BOOL StatementList::IsDocWin( Window* pWin ) +{ + if ( pWin && IsDocFrame( pWin ) ) + { + if ( GetDocFrameCount() != 1 ) + return 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 FALSE; +} + +BOOL StatementList::IsIMEWin( Window* pWin ) // Input Window for CJK under Solaris +{ + if ( pWin && pWin->IsVisible() && pWin->GetType() == WINDOW_BORDERWINDOW ) + { + USHORT nCount; + BOOL bHasWorkWindow = FALSE; + BOOL bHasWindow = 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 = TRUE; + for ( nCount = 0 ; nCount < pWin->GetChildCount() ; nCount++ ) + if ( pWin->GetChild( nCount )->GetType() == WINDOW_WINDOW ) + bHasWindow = TRUE; + return bHasWorkWindow && !bHasWindow; + } + return 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(UIdString(pBase->GetSmartUniqueOrHelpId())); + 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 + WRITEc("/Unknown") + } + WRITEc("\n"); + + aReturn.ConvertLineEnd(); + USHORT i; + for (i = 0 ; i < pBase->GetChildCount() ; i++) + { + aReturn += ClientTree(pBase->GetChild(i),Indent+1); + } + return aReturn; +} + + +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( aWindowWaitUId.GetText().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->SetSmartHelpId(aWindowWaitOldHelpId, SMART_SET_ALL); + pWindowWaitPointer->SetSmartUniqueId(aWindowWaitOldUniqueId, SMART_SET_ALL); + + aWindowWaitUId = SmartId(); + pWindowWaitPointer = NULL; + StartTime = Time(0L); + return TRUE; + } + + return FALSE; + } + pWindowWaitPointer = NULL; + aWindowWaitUId = SmartId(); +#if OSL_DEBUG_LEVEL > 1 + m_pDbgWin->AddText( "Closed, Going on.\n" ); +#endif + } + StartTime = Time(0L); + return TRUE; +} + +void StatementList::ReportError(String aMessage) +{ + ReportError ( SmartId(), aMessage ); +} + +void StatementList::ReportError(SmartId aUId, String aMessage) +{ + pRet->GenError ( aUId, aMessage ); + IsError = TRUE; +} + +void StatementList::ReportError(String aMessage, ULONG nWhatever) +{ + ReportError ( aMessage.AppendAscii(" ").Append(UniString::CreateFromInt32(nWhatever))); +} + +void StatementList::DirectLog( ULONG nType, String aMessage ) +{ + if ( pRet ) + pRet->GenReturn( RET_DirectLoging, SmartId(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, BOOL bForceDirect ) +{ + + if ( StatementList::bUsePostEvents && !bForceDirect ) + { + if ( StatementList::WinPtrValid( pWin ) ) + { + ULONG nID1; + 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, FALSE ); + ImplCommand( pWin, aEvent ); + } + } + } + + CALL_EVENT_WITH_NOTIFY( EVENT_KEYUP, aKEvnt, pWin, KeyUp ) + } +}; + +void ImplMouseMove( Window* pWin, MouseEvent &aMEvnt, BOOL bForceDirect ) +{ + if ( StatementList::bUsePostEvents && !bForceDirect ) + { + if ( StatementList::WinPtrValid( pWin ) ) + { + 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, BOOL bForceDirect ) +{ + if ( StatementList::bUsePostEvents && !bForceDirect ) + { + if ( StatementList::WinPtrValid( pWin ) ) + { + 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, BOOL bForceDirect ) +{ + if ( StatementList::bUsePostEvents && !bForceDirect ) + { + if ( StatementList::WinPtrValid( pWin ) ) + { + 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( 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..65be45907b90 --- /dev/null +++ b/automation/source/server/statemnt.cxx @@ -0,0 +1,6600 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: statemnt.cxx,v $ + * $Revision: 1.40 $ + * + * 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 <vcl/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 <vcl/wintypes.hxx> +#include <svtools/valueset.hxx> +#include <svtools/roadmap.hxx> +#include <svtools/poolitem.hxx> +#include <svtools/extensionlistbox.hxx> +// Hat keinen Includeschutz +#include <svtools/svtdata.hxx> +#include <tools/time.hxx> +#include <svtools/stringtransfer.hxx> +#ifndef _PRINT_HXX //autogen +#include <vcl/print.hxx> +#endif +#ifndef _PRNDLG_HXX //autogen +#include <vcl/prndlg.hxx> +#endif +#include <tools/stream.hxx> +#ifndef _SV_DRAG_HXX //autogen +//#include <vcl/drag.hxx> +#endif +#include <tools/fsys.hxx> +#include <svtools/stritem.hxx> +#include <svtools/ttprops.hxx> +#ifndef _BASIC_TTRESHLP_HXX +#include <basic/ttstrhlp.hxx> +#endif +#include <basic/dispdefs.hxx> +#include <vos/socket.hxx> +#include <svtools/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; +using namespace com::sun::star::beans; +using namespace svt; + + +#ifndef SBX_VALUE_DECL_DEFINED +#define SBX_VALUE_DECL_DEFINED +SV_DECL_REF(SbxValue) +#endif +SV_IMPL_REF(SbxValue) + +CommunicationLink *StatementFlow::pCommLink = NULL; +BOOL StatementFlow::bUseIPC = TRUE; +BOOL StatementFlow::bSending = FALSE; +ImplRemoteControl *StatementFlow::pRemoteControl = NULL; + +USHORT 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->GetSmartUniqueOrHelpId(); \ + aWindowWaitOldHelpId = pWin->GetSmartHelpId(); \ + aWindowWaitOldUniqueId = pWin->GetSmartUniqueId(); \ + pWin->SetSmartHelpId( SmartId(4321) ); \ + pWin->SetSmartUniqueId( SmartId(1234) ); + +// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + +StatementFlow::StatementFlow( StatementList *pAfterThis, USHORT nArtP ) +: nArt(nArtP) +, nParams(0) +, nSNr1(0) +, nLNr1(0) +, aString1() +, bBool1(FALSE) +{ + QueStatement( pAfterThis ); +} + +StatementFlow::StatementFlow( ULONG nServiceId, SCmdStream *pCmdIn, ImplRemoteControl *pRC ) +: nArt(0) +, nParams(0) +, nSNr1(0) +, nLNr1(0) +, aString1() +, bBool1(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 = 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 = FALSE; + IsError = FALSE; +} + +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 FALSE initialisiert + if ( !bBool1 ) // also erster Durchlauf + { + pRemoteControl->pRetStream = pRet->GetStream(); + bBool1 = TRUE; // wurde im CTOR auf FALSE initialisiert + nRetryCount = nRetryCount * 4; + } + if ( pRemoteControl->pRetStream && (nRetryCount--) ) // also solange nicht abgeholt + { + return FALSE; // Bitte einmal vom Callstack runter + } + } + + } + break; + } + + Advance(); + switch ( nArt ) + { + case F_EndCommandBlock: + if ( !bUseIPC ) + { // wird oben abgehandelt + pRet->Reset(); + IsError = 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 TRUE; +} + +// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + +// neue Hilfsfunktion, die stetig erweitert werden muss +static short ImpGetRType( Window *pWin, SmartId aUId ) +{ + ULONG nUId = aUId.GetNum(); // GetNum() is always zero if no num is defined + // GGGg gggg::gggg gggg::ggLL LLLl::llll llll + DBG_ASSERT( pWin, "missing Parameter" ); + short nRT; + if( (nUId & 0xE0000000) == 0 ) // keine auto ID + nRT = C_NoType; + else { +// if( (nUId & 0x1F) == 0 ) // globale Resource + if( (nUId & 0x1FF) == 0 ) // globale Resource GH: soweit ich das verstanden habe 1FF + nRT = (short)(C_TabPage - 1 + (nUId >> 29)); + else + nRT = (short)((nUId & 0x00003E00) >> 9); + if ( nRT == C_TabPage ) // wegen TabDialog.UId = TabPage.UId + nRT = C_NoType; + else + { +#ifndef DBG_UTIL + return nRT; +#endif + } + } + +#ifdef DBG_UTIL + short n = nRT; +#endif + 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; + } +#ifdef DBG_UTIL + // Die Werte n sind bei den WindowTypen nicht mehr vergeben, werden aber in der AutoID noch verwendet + // Sie werden jetzt durch den Typ nRT implementiert. + DBG_ASSERT( n == C_NoType || n == nRT + || ( n == C_ImageButton && nRT == C_PushButton ) + || ( n == C_TriStateBox && nRT == C_CheckBox ) + || ( n == C_ImageRadioButton && nRT == C_RadioButton ) + , "error in algorithm" ); +#endif + 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 (USHORT 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 (USHORT i = 0 ; i < nAnzahl ; i++) + pCmdIn->Read( pArg[i] ); + } + break; + } + } +} + +// Constructor for UnoSlot +StatementSlot::StatementSlot() +: nAnzahl( 0 ) +, pItemArr(NULL) +, nFunctionId( 0 ) +, bMenuClosed(FALSE) +{} + +StatementSlot::StatementSlot( ULONG nSlot, SfxPoolItem* pItem ) +: pItemArr(NULL) +, bMenuClosed(FALSE) +{ + QueStatement( NULL ); + nFunctionId = USHORT(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 (USHORT 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( 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 + BOOL bDisposed; + 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( FALSE ) +, bEnabled( 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 = TRUE; +} + +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 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 = SmartId(); + aSubMenuId2 = SmartId(); + aSubMenuId3 = SmartId(); + pMenuWindow = NULL; + bMenuClosed = TRUE; +#if OSL_DEBUG_LEVEL > 1 + m_pDbgWin->AddText( "Closed contextmenu\n" ); +#endif + return FALSE; + } + else if ( nRetryCount-- ) + { +#if OSL_DEBUG_LEVEL > 1 + m_pDbgWin->AddText( "Waiting for contextmenu to close\n" ); +#endif + return 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 ) ); + 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 < 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 = TRUE; + xDisp->dispatch( aTargetURL, aArgs ); + bIsSlotInExecute = 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( SmartId(nFunctionId), GEN_RES_STR0( S_SID_EXECUTE_FAILED_NO_DISPATCHER ) ); + } + break; + case TT_PR_ERR_NOEXECUTE: + { + ReportError(SmartId(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 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, USHORT MethodId, USHORT Params, USHORT Nr1 ) +: nMethodId( MethodId ) +, aSmartMethodId() +, nParams(Params) +, nNr1(Nr1) +, nNr2(0) +, nNr3(0) +, nNr4(0) +, nLNr1(0) +, aString1() +, aString2() +, bBool1(FALSE) +, bBool2(FALSE) +{ + QueStatement( pAfterThis ); + aSmartMethodId = SmartId( nMethodId ); + +#if OSL_DEBUG_LEVEL > 1 + m_pDbgWin->AddText( "Directly adding Conmmand:" ); + m_pDbgWin->AddText( " Methode: " ); + m_pDbgWin->AddText( aSmartMethodId.GetText() ); + 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) +, aSmartMethodId() +, nParams(0) +, nNr1(0) +, nNr2(0) +, nNr3(0) +, nNr4(0) +, nLNr1(0) +, aString1() +, aString2() +, bBool1(FALSE) +, bBool2(FALSE) +{ + QueStatement( NULL ); + pCmdIn->Read( nMethodId ); + aSmartMethodId = SmartId( 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( aSmartMethodId.GetText() ); + 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 = FALSE; + while ( StatementList::pFirst != this ) // Alles Löschen außer mich selbst + { + StatementList *pDeQue = StatementList::pFirst; + pDeQue->Advance(); + delete pDeQue; + } + bReadingCommands = TRUE; + #if OSL_DEBUG_LEVEL > 1 + m_pDbgWin->AddText( "*Done deleting all Commands:\n" ); + #endif + } + +} + +void StatementCommand::WriteControlData( Window *pBase, ULONG nConf, BOOL bFirst ) +{ + + if ( IsDialog(pBase) && !bFirst ) + return; + + if ( bFirst ) + pRet->GenReturn ( RET_WinInfo, SmartId(), (comm_ULONG)nConf | DH_MODE_DATA_VALID, UniString(), TRUE ); + + { // Klammerung, so daß der String nicht während der Rekursion bestehen bleibt + String aName; + BOOL bSkip = 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->GetSmartUniqueOrHelpId().Equals( SmartId() ) && !( nConf & DH_MODE_ALLWIN ) ) + bSkip = TRUE; + } + + 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 + aTypeSuffix.AppendAscii( "/Unknown", 8 ); + } + + SmartId aId = pBase->GetSmartUniqueOrHelpId(); + if ( aId.HasString() || ( nConf & DH_MODE_ALLWIN ) ) + pRet->GenReturn ( RET_WinInfo, SmartId( aId.GetStr() ), (comm_ULONG)pBase->GetType(), + TypeString(pBase->GetType()).Append(aTypeSuffix).AppendAscii(": ").Append(aName), FALSE ); + if ( !aId.HasString() || ( nConf & DH_MODE_ALLWIN ) ) + pRet->GenReturn ( RET_WinInfo, SmartId( aId.GetNum() ), (comm_ULONG)pBase->GetType(), + TypeString(pBase->GetType()).Append(aTypeSuffix).AppendAscii(": ").Append(aName), FALSE ); + + + if ( pBase->GetType() == WINDOW_TOOLBOX ) // Buttons und Controls auf Toolboxen. + { + ToolBox *pTB = ((ToolBox*)pBase); + USHORT 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, SmartId( pTB->GetItemCommand(pTB->GetItemId( i )) ), (comm_ULONG)WINDOW_BUTTON, + TypeString(WINDOW_BUTTON).AppendAscii(": ").Append(aName), FALSE ); + if ( !pTB->GetItemCommand(pTB->GetItemId( i )).Len() || ( nConf & DH_MODE_ALLWIN ) ) + pRet->GenReturn ( RET_WinInfo, SmartId( pTB->GetHelpId(pTB->GetItemId( i )) ), (comm_ULONG)WINDOW_BUTTON, + TypeString(WINDOW_BUTTON).AppendAscii(": ").Append(aName), FALSE ); + } + else + { + if ( pItemWin ) + { + if ( pTB->GetItemCommand(pTB->GetItemId( i )).Len() || ( nConf & DH_MODE_ALLWIN ) ) + pRet->GenReturn ( RET_WinInfo, SmartId( pTB->GetItemCommand(pTB->GetItemId( i )) ), (comm_ULONG)pItemWin->GetType(), + TypeString(pItemWin->GetType()).AppendAscii(": ").Append(aName), FALSE ); + if ( !pTB->GetItemCommand(pTB->GetItemId( i )).Len() || ( nConf & DH_MODE_ALLWIN ) ) + pRet->GenReturn ( RET_WinInfo, SmartId( pTB->GetHelpId(pTB->GetItemId( i )) ), (comm_ULONG)pItemWin->GetType(), + TypeString(pItemWin->GetType()).AppendAscii(": ").Append(aName), FALSE ); + USHORT ii; + for( ii = 0 ; ii < pItemWin->GetChildCount(); ii++ ) + WriteControlData( pItemWin->GetChild(ii), nConf, 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, SmartId( pTB->GetItemCommand(pTB->GetItemId( i )) ), (comm_ULONG)WINDOW_BASE, + aToolBoxItemType.AppendAscii(": ").Append(aName), FALSE ); + if ( !pTB->GetItemCommand(pTB->GetItemId( i )).Len() || ( nConf & DH_MODE_ALLWIN ) ) + pRet->GenReturn ( RET_WinInfo, SmartId( pTB->GetHelpId(pTB->GetItemId( i )) ), (comm_ULONG)WINDOW_BASE, + aToolBoxItemType.AppendAscii(": ").Append(aName), 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); + USHORT i; + for ( i = 0; i < pBD->GetButtonCount() ; i++ ) + { + aName = String(); + if ( aName.Len() == 0 ) + aName = pBD->GetPushButton( pBD->GetButtonId(i) )->GetText(); + String aID; + switch ( pBD->GetButtonId(i) ) + { + case BUTTONID_OK: + aID.AssignAscii("Ok"); + break; + case BUTTONID_CANCEL: + aID.AssignAscii("Cancel"); + break; + case BUTTONID_YES: + aID.AssignAscii("Yes"); + break; + case BUTTONID_NO: + aID.AssignAscii("No"); + break; + case BUTTONID_RETRY: + aID.AssignAscii("Retry"); + break; + case BUTTONID_HELP: + aID.AssignAscii("Help"); + break; + default: + aID = UniString::CreateFromInt32( pBD->GetButtonId(i) ); + break; + } + + pRet->GenReturn ( RET_WinInfo, SmartId( 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 = ").Append(aID), FALSE ); + } + + return; // ButtonDialog ist hier schon komplett abgehandelt. + } + + + Menu* pMenu = GetMatchingMenu( pBase ); + + if ( pMenu ) // Menus + { + USHORT i; + for ( i = 0; i < pMenu->GetItemCount() ; i++ ) + { + USHORT 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, SmartId( pMenu->GetItemCommand(nID) ), (comm_ULONG)0, + aMenuItemType.AppendAscii(": ").Append(aName), FALSE ); + if ( !pMenu->GetItemCommand(nID).Len() || ( nConf & DH_MODE_ALLWIN ) ) + pRet->GenReturn ( RET_WinInfo, SmartId( nID ), (comm_ULONG)0, + aMenuItemType.AppendAscii(": ").Append(aName), FALSE ); + } + } + + return; // Menu ist hier schon komplett abgehandelt. + } + } + } + + for( USHORT i = 0 ; i < pBase->GetChildCount(); i++ ) + WriteControlData( pBase->GetChild(i), nConf, 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( 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; + USHORT i; + BOOL bHasValue = FALSE; + ULONG nBestValue = 0; + 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 = TRUE; + } + } + rSize = aBestSize; +} + + +class DisplayHidWin : public ToolBox +{ + Edit *pEdit; + Size aMinEditSize; + USHORT nLastItemID; + BOOL bIsDraging; + BOOL bIsPermanentDraging; + void SetDraging( BOOL bNewDraging ); + Image *pShow, *pShow2; + BOOL bConfigChanged; + void EnableButtons( ULONG nConf ); + + 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 + BOOL bOldShift; + Time aLatest; + USHORT 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(); } + BOOL IsDisplayTextModified() const { return pEdit->IsModified(); } + void ClearDisplayTextModified() const { pEdit->ClearModifyFlag(); } + + void SetConfig( ULONG nConf ); + ULONG GetConfig(); + + BOOL IsConfigChanged() { return bConfigChanged; } + void ConfigSent() { bConfigChanged = FALSE; } + + BOOL IsSendData() { return GetItemState( TT_SEND_DATA ) == STATE_CHECK; } +// BOOL IsAllWin() { return GetItemState( TT_ALLWIN ) == STATE_CHECK; } + + BOOL IsDraging() { return bIsDraging; } + + Window* LastMouseMoveWin() { return pLastMouseMoveWin; } +}; + +DisplayHidWin::DisplayHidWin() +: ToolBox( StatementList::GetFirstDocFrame(), TTProperties::GetSvtResId(DisplayHidToolBox) ) +, bIsDraging( FALSE ) +, bIsPermanentDraging( 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( 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( ULONG nConf ) +{ + BOOL bSend = 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( 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( TRUE ); + } + ToolBox::Click(); +} + +void DisplayHidWin::Select() +{ + if ( GetItemState( GetCurItemId() ) == STATE_NOCHECK ) + { + SetItemState( GetCurItemId(), STATE_CHECK ); + if ( GetCurItemId() == TT_SHOW ) + { + bIsPermanentDraging = TRUE; + SetDraging( TRUE ); + } + } + else + { + SetItemState( GetCurItemId(), STATE_NOCHECK ); + if ( GetCurItemId() == TT_SHOW ) + { + bIsPermanentDraging = FALSE; + SetDraging( FALSE ); + } + } + if ( GetCurItemId() == TT_SEND_DATA ) + { + EnableButtons( GetConfig() ); + } +} + +void DisplayHidWin::SetConfig( 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 ); +} + +ULONG DisplayHidWin::GetConfig() +{ + 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 = FALSE; + SetDraging( 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( FALSE ); + return 0; +} + + +BOOL StatementCommand::DisplayHID() +{ + // Return TRUE -> reexecute command + + if ( !bBool2 ) // Wird auf FALSE initialisiert + { + bBool2 = 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 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( TRUE, TRUE ); + GetTTSettings()->pDisplayHidWin->GetWindow( WINDOW_OVERLAP )->EnableInput( TRUE, 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() );\ + ULONG nMaxCornerRadius = WinPtr->PixelToLogic( Point( 80, 0 ) ).X();\ + ULONG iCorner = std::max ((ULONG) 8, (ULONG) std::min( nMaxCornerRadius, (ULONG) std::min((ULONG) (aSz.Width() / 6), (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(GetTTSettings()->Act->GetSmartUniqueOrHelpId().GetText().AppendAscii(" WinType: ") + .Append(UniString::CreateFromInt64(GetTTSettings()->Act->GetType())).AppendAscii(" ").Append(GetTTSettings()->Act->GetText())); + if ( GetTTSettings()->Act && !GetTTSettings()->Act->GetSmartUniqueId().Equals( GetTTSettings()->Act->GetSmartHelpId() ) ) + GetTTSettings()->pDisplayHidWin->SetText(UniString( TTProperties::GetSvtResId( TT_ALTERNATE_CAPTION ) ).Append(GetTTSettings()->Act->GetSmartHelpId().GetText())); + else + GetTTSettings()->pDisplayHidWin->SetText( GetTTSettings()->aOriginalCaption ); + } + else + GetTTSettings()->pDisplayHidWin->SetDisplayText(CUniString("Kein Window/Control gefunden")); + } + else if ( GetTTSettings()->Act ) + { +// SET_WIN(GetTTSettings()->Act); + if ( GetTTSettings()->pDisplayHidWin->IsDisplayTextModified() && GetTTSettings()->pDisplayHidWin->GetDisplayText().Len() > 0 ) + { + GetTTSettings()->Act->SetSmartUniqueId( SmartId( GetTTSettings()->pDisplayHidWin->GetDisplayText().ToInt32() ) ); + 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; + BOOL bSelecting; + + BOOL bAvailable; + BOOL bNext; + + BOOL TestChangedDataSaved(); + + + 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, BOOL bMark ); + + BOOL IsTranslationAvailable(){ return bAvailable; } + BOOL IsNextDialog(){ return bNext; } + void ResetNextDialog(){ bNext = 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( FALSE ) +, bAvailable( FALSE ) +, bNext( 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 ); +} + +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 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 = 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 = TRUE; + } + return 0; +} + +IMPL_LINK( TranslateWin, DoSelect, PushButton*, EMPTYARG ) +{ + if ( bSelecting ) + { +// ReleaseMouse(); + bSelecting = FALSE; + } + else + { + if ( TestChangedDataSaved() ) + { + PushButtonTT_PB_RESTORE.Disable(); +// CaptureMouse(); + bSelecting = 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 ), 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 ), 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; + USHORT 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 ), 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 = 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; + USHORT nAction; +public: + FindShortcutErrors(); + virtual BOOL IsWinOK( Window *pWin ); + void SetAction( USHORT 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( USHORT nA ) +{ + nAction = nA; + if ( FDS_ACTION_COLLECT == nAction ) + { + aShortcuts = UniString(); + aDoubleShortcuts = UniString(); + } +} + +BOOL FindShortcutErrors::IsWinOK( Window *pWin ) +{ + if ( pWin->IsReallyVisible() ) + { + String aText = pWin->GetText(); + xub_StrLen nPos = aText.Search('~'); + String aShortcut; + BOOL bHasAccel = 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: + { + BOOL bMissing = 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 = 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 = 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 FALSE; +} + +String TranslateWin::MarkShortcutErrors( Window* pBase, BOOL bMark ) +{ + if ( pBase ) + { + FindShortcutErrors aFinder; + if ( bMark ) + { + StatementList::SearchAllWin( pBase, aFinder, TRUE ); // collect Shortcuts first + aFinder.SetAction( FDS_ACTION_MARK ); + } + else + aFinder.SetAction( FDS_ACTION_UNMARK ); + StatementList::SearchAllWin( pBase, aFinder, TRUE ); + return aFinder.GetDoubleShortcuts(); + } + return UniString(); +} + +void TranslateWin::EnableTranslation() +{ + PushButtonTT_PB_SELECT.Enable(); + PushButtonTT_PB_NEXT.Enable(); + bAvailable = FALSE; + bNext = FALSE; +} + +void StatementCommand::Translate() +{ + // Es wurde eine initale UniqueId mitgegeben. Dann nur die dopelten Shortcuts liefern + if( (nParams & PARAM_ULONG_1) && nLNr1 ) + { + String aDouble; + Window *pWin = SearchTree( SmartId( nLNr1 ) ,FALSE ); + if ( pWin ) + { + pWin = pWin->GetWindow( WINDOW_OVERLAP ); + aDouble = TranslateWin::MarkShortcutErrors( pWin, TRUE ); + } + pRet->GenReturn ( RET_Value, aSmartMethodId, aDouble ); + return; + } + + if ( !GetTTSettings()->pTranslateWin ) + { + GetTTSettings()->pTranslateWin = new TranslateWin; + GetTTSettings()->bToTop = TRUE; + } + + GetTTSettings()->pTranslateWin->Show(); + if ( GetTTSettings()->bToTop ) + { + GetTTSettings()->pTranslateWin->ToTop(); + GetTTSettings()->bToTop = FALSE; + } + +// GetTTSettings()->pTranslateWin->GetWindow( WINDOW_OVERLAP )->Enable( TRUE, TRUE ); + GetTTSettings()->pTranslateWin->GetWindow( WINDOW_OVERLAP )->EnableInput( TRUE, 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->GetSmartUniqueOrHelpId().HasAny() && pNew->GetChildCount() == 1 ) + pNew = pNew->GetChild( 0 ); + pTranslationWindow = pNew; + } + + aTranslation = CUniString("0;"); + + aTranslation += pTranslationWindow->GetSmartUniqueOrHelpId().GetText(); + aTranslation += ';'; + + aTranslation += TypeString( pTranslationWindow->GetType() ); + aTranslation += ';'; + + Window* pParentDialog = pTranslationWindow; + while ( pParentDialog && !IsDialog( pParentDialog ) ) + { + pParentDialog = pParentDialog->GET_REAL_PARENT(); + } + + if ( pParentDialog ) + { + aTranslation += pParentDialog->GetSmartUniqueOrHelpId().GetText(); + 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, aSmartMethodId, aTranslation ); + GetTTSettings()->pTranslateWin->EnableTranslation(); + GetTTSettings()->bToTop = TRUE; + } + else + { + pRet->GenReturn ( RET_Value, aSmartMethodId, String() ); + GetTTSettings()->pTranslateWin->EnableTranslation(); + ErrorBox err( GetTTSettings()->pTranslateWin, TTProperties::GetSvtResId( TT_NO_CONTROL )); + err.Execute(); + GetTTSettings()->bToTop = TRUE; + } + + } + else if ( GetTTSettings()->pTranslateWin->IsNextDialog() ) + { + pRet->GenReturn ( RET_Value, aSmartMethodId, CUniString("1") ); + GetTTSettings()->pTranslateWin->ResetNextDialog(); + GetTTSettings()->pTranslateWin->LoseFocus(); + GetTTSettings()->bToTop = TRUE; + } + else + { + GetTTSettings()->pTranslateWin->EnableTranslation(); + pRet->GenReturn ( RET_Value, aSmartMethodId, 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; +} + +BOOL StatementCommand::Execute() +{ + if ( IsError ) + { +#if OSL_DEBUG_LEVEL > 1 + m_pDbgWin->AddText( "Skipping Command: " ); + m_pDbgWin->AddText( aSmartMethodId.GetText() ); + m_pDbgWin->AddText( "\n" ); + #endif + + Advance(); + delete this; + return TRUE; + } + + InitProfile(); +#if OSL_DEBUG_LEVEL > 1 + m_pDbgWin->AddText( "Executing Command: " ); + m_pDbgWin->AddText( aSmartMethodId.GetText() ); + 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->GetSmartUniqueOrHelpId()) ) ); +#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->GetSmartUniqueOrHelpId()); + + + switch ( nMethodId ) + { + case RC_AppDelay: + if ( !bBool1 ) + { + nLNr1 = Time().GetTime() + nNr1/10; + bBool1 = TRUE; + } + if ( Time().GetTime() < long(nLNr1) ) // Aktuelle Zeit kleiner Endzeit + return FALSE; + break; + case RC_DisplayHid: + if ( DisplayHID() ) + return FALSE; + break; + case RC_ResetApplication: + { + if ( !bBool1 ) + { + nRetryCount = 150; // das sollte reichen. + bBool1 = 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 = TRUE; + bUsePostEvents = TRUE; + + aSubMenuId1 = SmartId(); + aSubMenuId2 = SmartId(); + aSubMenuId3 = SmartId(); + pMenuWindow = NULL; + } + if ( !nRetryCount ) + ReportError( GEN_RES_STR0( S_RESETAPPLICATION_FAILED_COMPLEX ) ); + + Window *pControl = GetNextRecoverWin(); + + if ( pControl ) + { + bBool2 = 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, pControl->GetSmartUniqueOrHelpId() ); + + 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, pControl->GetSmartUniqueOrHelpId() ); + } + + 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: + { + USHORT 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 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 = (ULONG)pControl; + + return 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 = (ULONG)pControl; + + return 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 = (ULONG)pControl; + + return 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 = TRUE; + } + if ( Time().GetTime() < long(nLNr1) ) // Aktuelle Zeit kleiner Endzeit + return FALSE; + else + pRet->GenReturn ( RET_Value, aSmartMethodId, 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 = TRUE; + } + + if ( !bIsSlotInExecute ) + pRet->GenReturn ( RET_Value, aSmartMethodId, comm_USHORT(CONST_WSFinished) ); + else + { + if ( Time().GetTime() < long(nLNr1) ) // Aktuelle Zeit kleiner Endzeit + return FALSE; + pRet->GenReturn ( RET_Value, aSmartMethodId, 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: + { + BOOL bWait = FALSE; + ReportError( GEN_RES_STR0( S_NO_ACTIVE_WINDOW ) ); +// if ( Application::GetAppWindow() ) +// bWait = Application::GetAppWindow()->IsWait(); + pRet->GenReturn ( RET_Value, aSmartMethodId, bWait ); + break; + } + case RC_GetClipboard: + { + ::rtl::OUString aTemp; + ::svt::OStringTransfer::PasteString( aTemp, GetFirstDocFrame() ); + pRet->GenReturn ( RET_Value, aSmartMethodId, String( aTemp ) ); + } + break; + case RC_SetClipboard: + ::svt::OStringTransfer::CopyString(aString1,GetFirstDocFrame()); + break; + case RC_WinTree: + pRet->GenReturn ( RET_Value, aSmartMethodId, Tree( NULL, 0)); + break; + #if OSL_DEBUG_LEVEL > 1 + case RC_NoDebug: + m_pDbgWin->bQuiet = TRUE; + m_pDbgWin->Hide(); + m_pDbgWin->Clear(); + break; + case RC_Debug: + m_pDbgWin->bQuiet = 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, aSmartMethodId, static_cast<comm_ULONG>(pWin->GetSmartUniqueOrHelpId().GetNum())); //GetNum() ULONG != comm_ULONG on 64bit + } + 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, SmartId(), 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, SmartId( S_ProfileReset ), nAnzahl ); + + // Und die einzelnen Grenzen + if ( nParams & PARAM_USHORT_1 ) { pRet->GenReturn( RET_ProfileInfo, SmartId( S_ProfileBorder1 ), (comm_ULONG)nNr1 ); }; + if ( nParams & PARAM_USHORT_2 ) { pRet->GenReturn( RET_ProfileInfo, SmartId( S_ProfileBorder2 ), (comm_ULONG)nNr2 ); }; + if ( nParams & PARAM_USHORT_3 ) { pRet->GenReturn( RET_ProfileInfo, SmartId( S_ProfileBorder3 ), (comm_ULONG)nNr3 ); }; + if ( nParams & PARAM_USHORT_4 ) { pRet->GenReturn( RET_ProfileInfo, SmartId( 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, SmartId(), aString1 ); + } + else + { // Normales Profiling je Kommando: profile + if ( pProfiler->IsAutoProfiling() ) + { + pRet->GenReturn( RET_ProfileInfo, SmartId(), pProfiler->GetAutoProfiling() ); + pProfiler->StopAutoProfiling(); + } + pProfiler->StartProfilingPerCommand(); + + // Der Header ist abhängig vom Modus + pRet->GenReturn( RET_ProfileInfo, SmartId(), pProfiler->GetProfileHeader() ); + } + } + else // Profiling wieder ausschalten: Profile false + if ( pProfiler ) + { + if ( pProfiler->IsProfilingPerCommand() ) + pProfiler->StopProfilingPerCommand(); + + if ( pProfiler->IsAutoProfiling() ) + { + pRet->GenReturn( RET_ProfileInfo, SmartId(), pProfiler->GetAutoProfiling() ); + pProfiler->StopAutoProfiling(); + } + + if ( pProfiler->IsPartitioning() ) + { + pRet->GenReturn( RET_ProfileInfo, SmartId( 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; + + USHORT 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; + } + + USHORT 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 + BOOL bLastWasSeperator = TRUE; // TRUE for Separator at the top + for ( USHORT 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) + USHORT 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 + BOOL bLastWasSeperator = TRUE; // TRUE for Separator at the top + USHORT nVisibleCount = 0; + for ( USHORT 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, aSmartMethodId, (comm_ULONG)nItemCount ); + } + break; + case RC_MenuGetItemId: + { + if ( ValueOK(aSmartMethodId, RcString( nMethodId ),nNr1,nItemCount) ) + pRet->GenReturn ( RET_Value, aSmartMethodId, (comm_ULONG)pMenu->GetItemId(nPhysicalIndex-1) ); + } + break; + case RC_MenuGetItemPos: + { + USHORT 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 + { + BOOL bLastWasSeperator = FALSE; + for ( int i = nLogicalPos ; i >= 0 ; i-- ) + { + if ( !pMenu->IsItemEnabled( pMenu->GetItemId( sal::static_int_cast< USHORT >(i) ) ) || + ( pMenu->GetItemType( sal::static_int_cast< USHORT >(i) ) == MENUITEM_SEPARATOR && bLastWasSeperator ) ) + nLogicalPos--; + bLastWasSeperator = pMenu->GetItemType( sal::static_int_cast< USHORT >(i) ) == MENUITEM_SEPARATOR; + } + } + } + pRet->GenReturn ( RET_Value, aSmartMethodId, (comm_ULONG)(nLogicalPos+1) ); + } + break; + case RC_MenuIsSeperator: + { + if ( ValueOK(aSmartMethodId, RcString( nMethodId ),nNr1,nItemCount) ) + pRet->GenReturn ( RET_Value, aSmartMethodId, (comm_BOOL)(pMenu->GetItemType(nPhysicalIndex-1) == MENUITEM_SEPARATOR) ); + } + break; + case RC_MenuIsItemChecked: + { + pRet->GenReturn ( RET_Value, aSmartMethodId, (comm_BOOL)pMenu->IsItemChecked(nNr1) ); + } + break; + case RC_MenuIsItemEnabled: + { + pRet->GenReturn ( RET_Value, aSmartMethodId, (comm_BOOL)pMenu->IsItemEnabled(nNr1) ); + } + break; + case RC_MenuGetItemText: + { + pRet->GenReturn ( RET_Value, aSmartMethodId, (String)pMenu->GetItemText(nNr1) ); + } + break; + case RC_MenuGetItemCommand: + { + pRet->GenReturn ( RET_Value, aSmartMethodId, (String)pMenu->GetItemCommand(nNr1) ); + } + break; + case RC_MenuHasSubMenu: + { + pRet->GenReturn ( RET_Value, aSmartMethodId, (BOOL)(pMenu->GetPopupMenu(nNr1) != NULL) ); + } + break; + case RC_MenuSelect: + { + if ( pMenu->GetPopupMenu(nNr1) ) + { + if ( !aSubMenuId1.GetNum() ) + aSubMenuId1 = SmartId(nNr1); + else if ( !aSubMenuId2.GetNum() ) + aSubMenuId2 = SmartId(nNr1); + else if ( !aSubMenuId3.GetNum() ) + aSubMenuId3 = SmartId(nNr1); + + if ( pPopup ) + pPopup->SelectEntry(nNr1); + else + pMenuBar->SelectEntry(nNr1); + } + else + { + if ( pPopup ) + { + pPopup->EndExecute(nNr1); + aSubMenuId1 = SmartId(); + aSubMenuId2 = SmartId(); + aSubMenuId3 = SmartId(); + pMenuWindow = NULL; + } + else + { + pMenuBar->SelectEntry(nNr1); + aSubMenuId1 = SmartId(); + aSubMenuId2 = SmartId(); + aSubMenuId3 = SmartId(); + 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; + USHORT 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 + { + USHORT 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 + #ifdef WIN + if( nFlags & ~0x1E ) + { + nDirFlags = 0; + StarBASIC::Error( SbERR_BAD_ARGUMENT ); + } + #endif + // Sb_ATTR_VOLUME wird getrennt gehandelt + if( nDirFlags & Sb_ATTR_VOLUME ) + aPath = aEntry.GetVolume(); + else + { + // Die richtige Auswahl treffen + USHORT 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(); + #ifdef WIN + aNextEntry.ToAbs(); + String sFull(aNextEntry.GetFull()); + unsigned nFlags; + + if (_dos_getfileattr( sFull.GetStr(), &nFlags )) + nErrorcode = FSYS_ERR_NOTEXISTS; + else + { + INT16 nCurFlags = nDirFlags; + if( (nCurFlags == Sb_ATTR_NORMAL) + && !(nFlags & ( _A_HIDDEN | _A_SYSTEM | _A_VOLID | _A_SUBDIR ) ) ) + break; + else if( (nCurFlags & Sb_ATTR_HIDDEN) && (nFlags & _A_HIDDEN) ) + break; + else if( (nCurFlags & Sb_ATTR_SYSTEM) && (nFlags & _A_SYSTEM) ) + break; + else if( (nCurFlags & Sb_ATTR_VOLUME) && (nFlags & _A_VOLID) ) + break; + else if( (nCurFlags & Sb_ATTR_DIRECTORY) && (nFlags & _A_SUBDIR) ) + break; + } + #else + break; + #endif + } + } + if ( !nErrorcode ) + { + pRet->GenReturn ( RET_Value, aSmartMethodId, 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, aSmartMethodId, String() ); + else + pRet->GenReturn ( RET_Value, aSmartMethodId, (String)(aEntry.GetName()) ); + + break; + } + else + { + pDir = new Dir( aEntry, aDirEntryKind ); + nErrorcode = pDir->GetError(); + } + } + } + + if ( !pDir ) + pDir = new Dir; + + if ( !nErrorcode && ValueOK( aSmartMethodId, GEN_RES_STR0( S_NO_MORE_FILES ), nDirPos+1, pDir->Count()+1 ) ) + { + if ( nDirPos == pDir->Count() ) + pRet->GenReturn ( RET_Value, aSmartMethodId, String() ); + else + pRet->GenReturn ( RET_Value, aSmartMethodId, (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, aSmartMethodId, static_cast<comm_ULONG>(aFS.GetSize()) ); //GetSize() 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, aSmartMethodId, *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, aSmartMethodId, (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 + USHORT 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 < XCancellable > xPicker; + switch( nNr1 ) + { + case CONST_FilePicker: + { + xPicker.set( Reference < XCancellable >( svt::GetTopMostFilePicker(), UNO_QUERY ) ); + } + break; + case CONST_FolderPicker: + { + xPicker.set( Reference < 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, aSmartMethodId, (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 = TRUE; + + MacroRecorder::GetMacroRecorder()->SetActionRecord( bBool1 ); + } + break; + case RC_GetDocumentCount : + { + pRet->GenReturn ( RET_Value, aSmartMethodId, (comm_USHORT)GetDocWinCount() ); + } + break; + case RC_ActivateDocument : + { + if( nParams & PARAM_USHORT_1 ) + { + if ( ValueOK(aSmartMethodId, 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, aSmartMethodId, (comm_USHORT)Application::GetSettings().GetLanguage() ); + } + break; + case RC_CatchGPF : + { + if( (nParams & PARAM_BOOL_1) ) + bCatchGPF = bBool1; + else + bCatchGPF = TRUE; + } + break; + case RC_IsProduct : + { + BOOL bIsProduct; + #ifdef DBG_UTIL + bIsProduct = FALSE; + #else + bIsProduct = TRUE; + #endif + pRet->GenReturn ( RET_Value, aSmartMethodId, (BOOL)bIsProduct ); + } + break; + case RC_UsePostEvents : + { + if( (nParams & PARAM_BOOL_1) ) + bUsePostEvents = bBool1; + else + bUsePostEvents = TRUE; + } + break; + default: + ReportError( GEN_RES_STR1( S_UNKNOWN_COMMAND, RcString( nMethodId ) ) ); + } + SendProfile( RcString(nMethodId) ); + delete this; + return TRUE; +} + + +BOOL StatementCommand::UnpackStorage( SotStorageRef xStorage, DirEntry &aBaseDir ) +{ + SvStorageInfoList aList; + xStorage->FillInfoList( &aList ); + + for( USHORT i = 0; i < aList.Count(); i++ ) + { + SvStorageInfo& rInfo = aList.GetObject( i ); + String aName = rInfo.GetName(); + DirEntry aPath ( aBaseDir ); + aPath += DirEntry( aName ); + 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 FALSE; + } + UnpackStorage( xSubStorage, aPath ); + } + else + { + if ( !aPath.MakeDir( TRUE ) ) + { + ReportError( GEN_RES_STR1(S_CANNOT_CREATE_DIRECTORY, aPath.GetFull()) ); + return 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 FALSE; + } + aDestination.Close(); + } + } + return TRUE; +} + + +// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + +StatementControl::StatementControl( SCmdStream *pCmdIn, USHORT nControlIdType ) +: StatementList() +, nNr1( 0 ) +, nNr2( 0 ) +, nNr3( 0 ) +, nNr4( 0 ) +, nLNr1( 0 ) +, aString1() +, aString2() +, bBool1(FALSE) +, bBool2(FALSE) +{ + QueStatement( NULL ); + if ( nControlIdType == SIControl ) + { + comm_ULONG nId; + pCmdIn->Read( nId ); + aUId = SmartId( nId ); + } + else if ( nControlIdType == SIStringControl ) + { + String aId; + pCmdIn->Read( aId ); + aUId = SmartId( 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( aUId.GetText() ); + 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 +} + +BOOL IsDialog(Window *pWin) +{ // Alles was von SystemWindow abgeleitet ist + if ( !pWin ) + return 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 TRUE; +// break; + default: + return FALSE; +// break; + } +} + + +BOOL IsAccessable(Window *pWin) +{ + if ( pWin == NULL ) + return FALSE; + + return pWin->IsEnabled() && pWin->IsInputEnabled(); +} + + + +// neue Hilfsfunktion +static Window*ImpGetButton( Window *pBase, WinBits nMask, WinBits nWinBits ) +{ + USHORT n = pBase->GetChildCount(); + for( USHORT 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; +} + +BOOL StatementControl::ControlOK( Window *pControl, const sal_Char* cBezeichnung ) +{ + if ( pControl && ( ( ( IsAccessable(pControl) || (nMethodId & M_WITH_RETURN) ) && + pControl->IsVisible() ) || + aUId.Matches( UID_ACTIVE ) ) ) + return 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 FALSE; + } +} + + +BOOL StatementList::ValueOK( SmartId aId, String aBezeichnung, ULONG nValue, 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 FALSE; + } + if ( nValue < 1 ) + { + if ( aBezeichnung.Len() > 0 ) + ReportError( aId, GEN_RES_STR3c3( S_NUMBER_TOO_SMALL, aBezeichnung, UniString::CreateFromInt32( nValue ), "1" ) ); + return FALSE; + } + return TRUE; +} + +USHORT 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.GetNum() ) + { + pPopup = pMenu->GetPopupMenu( + sal::static_int_cast< USHORT >(aSubMenuId1.GetNum())); + pMenu = pPopup; + } + + if ( pMenu && aSubMenuId2.GetNum() ) + { + pPopup = pMenu->GetPopupMenu( + sal::static_int_cast< USHORT >(aSubMenuId2.GetNum())); + pMenu = pPopup; + } + + if ( pMenu && aSubMenuId3.GetNum() ) + { + pPopup = pMenu->GetPopupMenu( + sal::static_int_cast< USHORT >(aSubMenuId3.GetNum())); + 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 = 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 = FALSE; // Bah ist das ein ekliger Hack +} + + +BOOL StatementControl::MaybeDoTypeKeysDelay( Window *pTestWindow ) +{ + if ( bDoTypeKeysDelay ) + { + ULONG nTimeWait = nMinTypeKeysDelay; + if ( nMaxTypeKeysDelay != nMinTypeKeysDelay ) + nTimeWait += Time::GetSystemTicks() % ( nMaxTypeKeysDelay - nMinTypeKeysDelay ); + Timer aTimer; + aTimer.SetTimeout( nTimeWait ); + aTimer.Start(); + StatementList::bExecuting = TRUE; // Bah ist das ein ekliger Hack + // Das verhindert, daß schon der nächste Befehl ausgeführt wird. + while ( aTimer.IsActive() ) + { + SafeReschedule( TRUE ); + } + StatementList::bExecuting = FALSE; // Bah ist das ein ekliger Hack + if ( !WinPtrValid(pTestWindow ) ) + { + ReportError( aUId, GEN_RES_STR1( S_WINDOW_DISAPPEARED, MethodString( nMethodId ) ) ); + return FALSE; + } + } + return TRUE; +} + +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 = (USHORT)-aStart.X(); + nNr2 = (USHORT)-aStart.Y(); + nNr3 = (USHORT)pControl->GetSizePixel().Width() + 2*(USHORT)aStart.X(); + nNr4 = (USHORT)pControl->GetSizePixel().Height() + 2*(USHORT)aStart.Y(); + } + nNr1 = std::max((USHORT)-aStart.X(),nNr1); + nNr2 = std::max((USHORT)-aStart.Y(),nNr2); + nNr3 = std::min((USHORT)(pControl->GetSizePixel().Width() + 2*(USHORT)aStart.X()),nNr3); + nNr4 = std::min((USHORT)(pControl->GetSizePixel().Height() + 2*(USHORT)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, TRUE ) ); + } + break; + case M_GetFixedText: + { + if( ( nParams & PARAM_USHORT_1 ) == 0 ) + nNr1 = 1; + + FixedText* pFixedText = (FixedText*)GetWinByRT( pControl, WINDOW_FIXEDTEXT, TRUE, nNr1-1 ); + if ( pFixedText ) + pRet->GenReturn ( RET_Value, aUId, pFixedText->GetText() ); + else + ValueOK(aUId, MethodString( nMethodId ),nNr1,CountWinByRT( pControl, WINDOW_FIXEDTEXT, TRUE ) ); + } + break; + default: + return FALSE; + } + SendProfile( UIdString( aUId ).Append('.').Append( MethodString( nMethodId ) ) ); + return TRUE; + } + return FALSE; +} + +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 = 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, 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 ( USHORT 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, TRUE ) ) + pControl->GrabFocus(); + } + if ( bBool1 ) // Jedesmal das FocusWindow finden + { + Window *pFocus = GetpApp()->GetFocusWindow(); + if ( pFocus && pControl->IsWindowOrChild( pFocus, TRUE ) ) + pDeliverHere = pFocus; + else // sonst fallback auf das Basisfenster + pDeliverHere = pControl; + } + pDeliverHere = pDeliverHere->GetPreferredKeyInputWindow(); + KeyEvent aEvent; + if ( ((USHORT)aString1.GetChar(i)) <= 7 ) + { + USHORT 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 + USHORT nKeygroup = nVal & KEYGROUP_TYPE; + USHORT 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 + (USHORT)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\ + USHORT 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(); + 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 = SmartId(); + aSubMenuId2 = SmartId(); + aSubMenuId3 = SmartId(); + 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 + { + 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 = SmartId(); + aSubMenuId2 = SmartId(); + aSubMenuId3 = SmartId(); + 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, 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; + + USHORT nSteps = 2; + while ( !pScroll && pControl && nSteps-- ) + { + pScroll = GetScrollBar( pControl, nNr1, TRUE ); + pControl = pControl->GET_REAL_PARENT(); + } + + switch ( nMethodId ) + { + case M_HasScrollBar: + { + if ( pScroll ) + pRet->GenReturn ( RET_Value, aUId, (comm_BOOL)TRUE ); + else + pRet->GenReturn ( RET_Value, aUId, (comm_BOOL)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 FALSE; + } + return TRUE; +} + + +BOOL StatementControl::Execute() +{ + Window *pControl; + BOOL bStatementDone = TRUE; + + + if ( IsError ) + { + #if OSL_DEBUG_LEVEL > 1 + m_pDbgWin->AddText( "Skipping Window: " ); + m_pDbgWin->AddText( aUId.GetText() ); + m_pDbgWin->AddText( " Method: " ); + m_pDbgWin->AddText( String::CreateFromInt32( nMethodId ) ); + m_pDbgWin->AddText( "\n" ); + #endif + Advance(); + delete this; + return TRUE; + } + + InitProfile(); +#if OSL_DEBUG_LEVEL > 1 + m_pDbgWin->AddText( "Executing Window: " ); + m_pDbgWin->AddText( aUId.GetText() ); + m_pDbgWin->AddText( " Method: " ); + m_pDbgWin->AddText( String::CreateFromInt32( nMethodId ) ); + m_pDbgWin->AddText( "\n" ); +#endif + + + if ( aUId.Matches( UID_ACTIVE ) ) + pControl = GetAnyActive(); + else + { + 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.Matches( pControl->GetSmartUniqueOrHelpId() ) ) + { // 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; + USHORT aSeconds = aT.GetMin()*60+aT.GetSec(); + if ( !bBool2 ) // wurde im Konstruktor auf FALSE gesetzt + { + bBool2 = 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)TRUE ); + } + else + if ( aSeconds <= nNr2 + nNr1 ) // Zeit ist noch nicht abgelaufen + return FALSE; + else + pRet->GenReturn ( RET_Value, aUId, (comm_BOOL)FALSE ); + + Advance(); + delete this; + return TRUE; +// break; + } + + + short nRT = 0; + + if( pControl ) // Das Fenster Existiert irgendwo, kann aber auch hidden sein! + { + nRT = ImpGetRType( pControl, aUId ); // If not Numeric pControl is used +#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 FALSE; + } + + if( ControlOK( pControl, "" ) ) + { + if ( nMethodId == M_OpenContextMenu && !bBool2 ) + { + pControl->GrabFocus(); // to get asyncron focus on unix + bBool2 = TRUE; + return 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 FALSE; + } + if ( !pControl->HasFocus() ) // to get asyncronous focus + { + bBool2 = TRUE; + return FALSE; + } + } + } + } + + Advance(); + + if ( HandleVisibleControls( pControl ) ) + { + delete this; + return 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 = 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, static_cast<comm_ULONG>(((TabControl*)pControl)->GetTabPage(((TabControl*)pControl)->GetCurPageId())->GetSmartUniqueOrHelpId().GetNum())); //GetNum() ULONG != comm_ULONG on 64bit + break; + case M_SetPage : + { // Wegen lokaler Variablen + TabControl *pTControl = ((TabControl*)pControl); + USHORT nActive = pTControl->GetCurPageId(); + USHORT i,anz; + ULONG nID = 0; + i = pTControl->GetPagePos( pTControl->GetCurPageId() ); + for ( anz=0 ; anz < pTControl->GetPageCount() && nID != nLNr1 ; anz++ ) + { + pTControl->SelectTabPage( pTControl->GetPageId(i) ); + /*if (pTControl->GetCurPageId()) + pTControl->DeactivatePage(); + pTControl->SetCurPageId( pTControl->GetPageId(i) ); + pTControl->ActivatePage();*/ + nID = pTControl->GetTabPage(pTControl->GetCurPageId())->GetSmartUniqueOrHelpId().GetNum(); + i++; + if ( i >= pTControl->GetPageCount() ) + i = 0; + if ( !MaybeDoTypeKeysDelay( pTControl ) || !MaybeDoTypeKeysDelay( pTControl ) || !MaybeDoTypeKeysDelay( pTControl ) ) // 3 Mal aufrufen + break; + } + if ( nID != nLNr1 ) + { + pTControl->SelectTabPage( nActive ); + /*if (pTControl->GetCurPageId()) + pTControl->DeactivatePage(); + pTControl->SetCurPageId( nActive ); + pTControl->ActivatePage();*/ + ReportError( SmartId( nLNr1 ), 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: + { + BOOL bUnselectBeforeSelect = ( nMethodId == M_Select ); + BOOL bFehler = FALSE; + if ( ! (nParams & PARAM_BOOL_1) ) + bBool1 = TRUE; + + if ( nMethodId == M_MultiSelect && nRT == C_ListBox ) + { + ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "ListBox" ) ); + bFehler = TRUE; + } + + if ( !bBool1 && nMethodId == M_Select ) + { + ReportError( aUId, GEN_RES_STR1( S_NO_SELECT_FALSE, MethodString( nMethodId ) ) ); + bFehler = TRUE; + } + + if ( !bFehler ) + { + if( nParams & PARAM_STR_1 ) + { + ListBox *pLB = ((ListBox*)pControl); + USHORT 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 : + { + USHORT 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(TRUE); + break; + case M_Close : + ((MoreButton*)pControl)->SetState(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 ); + + ULONG nStart = Time::GetSystemTicks(); + ULONG nDelay = pControl->GetSettings().GetMouseSettings().GetActionDelay(); + while ( ( Time::GetSystemTicks() - nStart ) < nDelay + 100 ) + SafeReschedule(); + + ImplMouseButtonUp ( pControl, aMEvnt, FORCE_DIRECT_CALL ); + + aSubMenuId1 = SmartId(); + aSubMenuId2 = SmartId(); + aSubMenuId3 = SmartId(); + 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.Matches( pTB->GetSmartUniqueOrHelpId() ) ) // Also Button auf der ToolBox gefunden + { + if ( (nParams == PARAM_NONE) || (nParams == PARAM_USHORT_1) ) + { // Wir fälschen einen Parameter + if ( aUId.HasNumeric() ) + { + nParams = PARAM_ULONG_1; + nLNr1 = USHORT( aUId.GetNum() ); + DBG_ASSERT( nLNr1 <= 0xFFFF, "ID on ToolBox > 0xFFFF" ); + } + else + { + nParams = PARAM_STR_1; + aString1 = aUId.GetStr(); + } + } + else + ReportError( aUId, GEN_RES_STR1( S_INTERNAL_ERROR, MethodString( nMethodId ) ) ); + } + +#define FIND_ITEM\ + USHORT nItemPos = 0;\ + BOOL bItemFound = FALSE;\ + {\ + SmartId aButtonId;\ + if( nParams == PARAM_STR_1 )\ + aButtonId = SmartId( aString1 );\ + if( nParams == PARAM_ULONG_1 )\ + aButtonId = SmartId( nLNr1 );\ + for ( nItemPos = 0; nItemPos < pTB->GetItemCount() && !aButtonId.Matches(pTB->GetItemCommand(pTB->GetItemId(nItemPos))) &&\ + !aButtonId.Matches(pTB->GetHelpId(pTB->GetItemId(nItemPos))) ; nItemPos++ ) {}\ + bItemFound = aButtonId.Matches(pTB->GetItemCommand(pTB->GetItemId(nItemPos))) || aButtonId.Matches(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 )\ + {\ + ReportError( aUId, GEN_RES_STR1( S_BUTTON_DISABLED_ON_TOOLBOX, MethodString( nMethodId ) ) );\ + bItemFound = FALSE;\ + }\ + else if ( !pTB->IsItemVisible( pTB->GetItemId(nItemPos) ) )\ + {\ + ReportError( aUId, GEN_RES_STR1( S_BUTTON_HIDDEN_ON_TOOLBOX, MethodString( nMethodId ) ) );\ + bItemFound = FALSE;\ + }\ + else\ + {\ + if ( pTB->IsMenuEnabled() )\ + { /* button is in Menu */\ + }\ + else\ + { /* Try the multi line way */\ + if ( pTB->GetItemRect(pTB->GetItemId(nItemPos)).IsEmpty() )\ + {\ + USHORT nLine = pTB->GetCurLine();\ + do\ + {\ + pTB->ShowLine( 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 = 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 = SmartId(); + aSubMenuId2 = SmartId(); + aSubMenuId3 = SmartId(); + 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 = 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 = 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 = SmartId(); + aSubMenuId2 = SmartId(); + aSubMenuId3 = SmartId(); + 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 + { + switch (nNr1) + { + case 0: + pRet->GenReturn ( RET_Value, aUId, (comm_ULONG)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: + 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; + USHORT nValidTextItemCount = 0; + { + USHORT 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 = 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 : + pItem->SetStateChecked(); + pTree->CheckButtonHdl(); + pTree->InvalidateEntry( pThisEntry ); + break; + case M_UnCheck : + pItem->SetStateUnchecked(); + pTree->CheckButtonHdl(); + pTree->InvalidateEntry( pThisEntry ); + break; + case M_TriState : + 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: + { + USHORT 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 + 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 ) + { + + + /* + + + BOOL MakeFieldVisible( long nRow, USHORT nColId, BOOL bComplete = FALSE ); + // access to dynamic values of cursor row + String GetColumnTitle( USHORT nColumnId ) const; + USHORT GetColumnId( USHORT nPos ) const; + USHORT GetColumnPos( USHORT nColumnId ) const; + // access and movement of cursor + long GetCurRow() const { return nCurRow; } + USHORT GetCurColumnId() const { return nCurColId; } + BOOL GoToRow( long nRow ); + BOOL GoToRowAndDoNotModifySelection( long nRow ); + BOOL GoToColumnId( USHORT nColId ); + BOOL GoToRowColumnId( long nRow, USHORT nColId ); + // selections + void SetNoSelection(); + void SelectAll(); + void SelectRow( long nRow, BOOL bSelect = TRUE, BOOL bExpand = TRUE ); + void SelectColumnPos( USHORT nCol, BOOL bSelect = TRUE ) + { SelectColumnPos( nCol, bSelect, TRUE); } + void SelectColumnId( USHORT nColId, BOOL bSelect = TRUE ) + { SelectColumnPos( GetColumnPos(nColId), bSelect, TRUE); } + long GetSelectRowCount() const; + USHORT GetSelectColumnCount() const; + BOOL IsRowSelected( long nRow ) const; + BOOL IsColumnSelected( USHORT nColumnId ) const; + long FirstSelectedRow( BOOL bInverse = FALSE ); + long LastSelectedRow( BOOL bInverse = FALSE ); + long PrevSelectedRow(); + long NextSelectedRow(); + const MultiSelection* GetSelection() const + { return bMultiSelection ? uRow.pSel : 0; } + void SetSelection( const MultiSelection &rSelection ); + + virtual String GetCellText(long _nRow, USHORT _nColId) const; + USHORT 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 : + { + USHORT nColCount = pEBBox->GetColumnCount(); + comm_USHORT nUnfrozenColCount = 0; + USHORT 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() ) ) + { + USHORT nColCount = pEBBox->GetColumnCount(); + comm_USHORT nUnfrozenColCount = 0; + USHORT 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 = 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 ); + BOOL bSuccess = TRUE; + if ( pELB->getSelIndex() == EXTENSION_LISTBOX_ENTRY_NOTFOUND ) + bSuccess = FALSE; + else + { + if ( !aString1.Equals( String( pELB->getItemName( pELB->getSelIndex() ) ) ) ) + bSuccess = 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_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(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(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.Matches( pControl->GetSmartUniqueOrHelpId() ), "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.Matches( pControl->GetSmartUniqueOrHelpId() ), "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.Matches( pControl->GetSmartUniqueOrHelpId() ), "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.Matches( pControl->GetSmartUniqueOrHelpId() ), "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.Matches( pControl->GetSmartUniqueOrHelpId() ), "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.Matches( pControl->GetSmartUniqueOrHelpId() ), "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( FALSE ); + ((WorkWindow*)pControl)->Minimize(); + break; + case M_Maximize : + ((WorkWindow*)pControl)->Maximize(); + break; + case M_Restore : + ((WorkWindow*)pControl)->Maximize( 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: + { + BOOL bDone = 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( TRUE ); + break; + case M_UnCheck : + pMB->SetCheckBoxState( FALSE ); + break; + case M_GetText : + pRet->GenReturn ( RET_Value, aUId, pMB->GetMessText()); + break; + + default: + bDone = 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 ( BUTTONID_OK != RET_OK ) +#error BUTTONID_OK != RET_OK +#endif + 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=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..2d287bcafa85 --- /dev/null +++ b/automation/source/server/statemnt.hxx @@ -0,0 +1,503 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: statemnt.hxx,v $ + * $Revision: 1.23 $ + * + * 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 <vcl/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 <vcl/smartid.hxx> +#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 TRUE + +typedef USHORT 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 BOOL IsWinOK( Window *pWin ) = 0; + SearchFlags GetSearchFlags() { return nmSearchFlags; } + void AddSearchFlags( SearchFlags aNewFlags ) { nmSearchFlags |= aNewFlags; } + void RemoveSearchFlags( SearchFlags aRemoveFlags ) { nmSearchFlags &= ( ~aRemoveFlags ); } + BOOL HasSearchFlag( SearchFlags aQueryFlag ) { return (nmSearchFlags & aQueryFlag) == aQueryFlag; } +}; + +BOOL IsDialog(Window *pWin); // Ist *pWin von SystemWindow abgeleitet (Kann es Active sein) +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 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; + BOOL bToTop; +}; + + +TTSettings* GetTTSettings(); + + +#define MAX_RETRIES 9 +class StatementList : public SafePointer +{ +private: + StatementList(const StatementList&); + StatementList & operator=(const StatementList&); + +protected: + StatementList(); + USHORT nRetryCount; + void QueStatement(StatementList *pAfterThis); + BOOL bStatementInQue; + static USHORT nUseBindings; + + static TTProfiler *pProfiler; + void InitProfile(); + void SendProfile( String aText ); + static StatementList *pCurrentProfileStatement; + + static BOOL bIsInReschedule; + static USHORT nModalCount; + static Window *pLastFocusWindow; // Wenn dieses sich ändert wird Safe Reschedule abgebrochen + static BOOL bWasDragManager; // Wenn dieses sich ändert wird Safe Reschedule abgebrochen + static BOOL bWasPopupMenu; // Wenn dieses sich ändert wird Safe Reschedule abgebrochen + static BOOL bBasicWasRunning; + + static USHORT nMinTypeKeysDelay; /// Verzögerung der einzelnen Anschläge für TypeKeys + static USHORT nMaxTypeKeysDelay; + static BOOL bDoTypeKeysDelay; + + static Window* pFirstDocFrame; + + static BOOL bIsSlotInExecute; + +public: + static BOOL IsInReschedule() { return bIsInReschedule; } + void SafeReschedule( BOOL bYield = FALSE ) // Setzt Flag, so daß nicht schon der nächste Befehl ausgeführt wird + { + nModalCount = Application::GetModalModeCount(); + bIsInReschedule = 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 = FALSE; + bWasPopupMenu = FALSE; + bWasDragManager = FALSE; + pLastFocusWindow = NULL; + bIsInReschedule = FALSE; + nModalCount = 0; + } + static BOOL MaybeResetSafeReschedule() + { // Implementierung muß hier zwar nicht sein, ist aber übersichtlicher so + if ( !bIsInReschedule ) + return FALSE; + + if ( pLastFocusWindow != GetpApp()->GetFocusWindow() + || ( Application::GetModalModeCount() > nModalCount ) +// || ( DragManager::GetDragManager() && !bWasDragManager ) + || ( PopupMenu::GetActivePopupMenu() && !bWasPopupMenu ) + || ( StarBASIC::IsRunning() && !bBasicWasRunning ) ) + { + bIsInReschedule = FALSE; + pLastFocusWindow = NULL; + return TRUE; + } + else + return FALSE; + } + static void NormalReschedule() // Setzt das flag nicht + { + GetpApp()->Reschedule(); + } +#define Reschedule RescheduleNichtBenutzen_StattdessenSafeRescheduleAnStatementList + + static Window* GetMouseWin(); + static BOOL WinPtrValid(Window *pTest); + static Window* SearchAllWin( Window *pBase, Search &aSearch, BOOL MaybeBase = TRUE ); +protected: + static Window* SearchClientWin( Window *pBase, Search &aSearch, BOOL MaybeBase = TRUE ); + + Window* SearchTree( SmartId aUId, BOOL bSearchButtonOnToolbox = FALSE ); + Window* GetActive( WindowType nRT, BOOL MaybeBase = TRUE ); + Window* GetFocus( WindowType nRT, BOOL MaybeBase = TRUE ); + Window* GetAnyActive( BOOL MaybeBase = TRUE ); + ScrollBar* GetScrollBar( Window *pBase, USHORT nDirection, BOOL MaybeBase = TRUE ); + Window* GetPopupFloatingWin( BOOL MaybeBase = TRUE ); + Menu* GetMatchingMenu( Window* pWin, Menu* pBaseMenu = NULL ); + Window* GetWinByRT( Window *pBase, WindowType nRT, BOOL MaybeBase = TRUE, USHORT nSkip = 0, BOOL bSearchAll = FALSE ); + USHORT CountWinByRT( Window *pBase, WindowType nRT, BOOL MaybeBase = TRUE ); + Window* GetDocWin( USHORT nNr ); + USHORT GetDocWinCount(); + Window* GetFadeSplitWin( Window *pBase, WindowAlign nAlign, BOOL MaybeBase = TRUE ); + BOOL ValueOK(SmartId nId, String aBezeichnung, ULONG nValue, ULONG nMax); + + USHORT GetCurrentMenues( PopupMenu *&pPopup, MenuBar *&pMenuBar, Menu *&pMenu ); + +public: +// void AddStatement( StatementList *pNewStatement ); + + virtual ~StatementList(); + void Advance(); + virtual 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) +** TRUE bedeutet, dass alles klar gegangen ist +** FALSE bedeutet nochmal Bitte +***************************************************************************/ + + void ReportError(String aMessage); + void ReportError(SmartId aUId, String aMessage); + void ReportError(String aMessage, ULONG nWhatever); + + static void DirectLog( ULONG nType, String aString ); + + String Tree(Window *pBase, int Indent); + String ClientTree(Window *pBase, int Indent); + + StatementList *pNext; + static StatementList /**pCurrent,*/ *pFirst; + static BOOL bReadingCommands; + static SmartId aWindowWaitUId; + static Window *pWindowWaitPointer; + static SmartId aWindowWaitOldHelpId; + static SmartId aWindowWaitOldUniqueId; + static RetStream *pRet; + static BOOL IsError; + static BOOL bDying; + static BOOL bExecuting; // Gesetzt, wenn ein Befehl rescheduled ohne einen neuen Befehl zu erlauben + BOOL bWasExecuting; // Wurde bei einem MaybeResetSafeReschedule resettet, so wird der Zustand danach wiederhergestellt + static SmartId aSubMenuId1; // Untermenüs bei PopupMenus + static SmartId aSubMenuId2; // erstmal 2-Stufig + static SmartId 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 + + BOOL CheckWindowWait(); //True heisst, dass Window noch existiert + //False -> Window weg; + static void SetFirstDocFrame( Window* pWin ); + static Window* GetFirstDocFrame(); + static BOOL IsFirstDocFrame( Window* pWin ); + static BOOL IsDocWin( Window* pWin ); + static BOOL IsIMEWin( Window* pWin ); // Input Window for CJK under Solaris + static BOOL IsDocFrame( Window* pWin ); + static MenuBar* GetDocFrameMenuBar( Window* pWin ); + static USHORT GetDocFrameCount(); + + static BOOL bCatchGPF; + + static 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: + USHORT nAnzahl; + SfxPoolItem **pItemArr; + ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue> aArgs; + USHORT nFunctionId; // can get removed when the old (numeric) slothandling is removed + String aUnoUrl; + BOOL bMenuClosed; + + StatementSlot(); + void AddReferer(); +public: + StatementSlot( SCmdStream *pIn ); + StatementSlot( ULONG nSlot, SfxPoolItem* pItem = NULL ); + virtual ~StatementSlot(); + virtual 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: + USHORT nMethodId; + SmartId aSmartMethodId; + USHORT nParams; + comm_USHORT nNr1,nNr2,nNr3,nNr4; + comm_ULONG nLNr1; + String aString1,aString2; + BOOL bBool1,bBool2; + + Window* GetNextOverlap( Window* pBase ); + Window* GetNextRecoverWin(); + + static USHORT nDirPos; + static Dir *pDir; + static pfunc_osl_printDebugMessage pOriginal_osl_DebugMessageFunc; + + + BOOL UnpackStorage( SotStorageRef xStorage, DirEntry &aBaseDir ); + + void HandleSAXParser(); + +public: + StatementCommand( SCmdStream *pIn ); + StatementCommand( StatementList *pAfterThis, USHORT MethodId, USHORT Params, USHORT Nr1 ); + virtual BOOL Execute(); + BOOL DisplayHID(); + void Translate(); + void WriteControlData( Window *pBase, ULONG nConf, BOOL bFirst = TRUE ); + +}; + + +enum TTHotSpots { MitteLinks, Mitte, MitteOben }; + +class StatementControl : public StatementList +{ +protected: + SmartId aUId; + USHORT nMethodId; + USHORT nParams; + comm_USHORT nNr1,nNr2,nNr3,nNr4; + comm_ULONG nLNr1; + String aString1,aString2; + BOOL bBool1,bBool2; + BOOL ControlOK( Window *pControl, const sal_Char* aBezeichnung ); + void AnimateMouse( Window *pControl, TTHotSpots aWohin ); + void AnimateMouse( Window *pControl, Point aWohin ); + + BOOL MaybeDoTypeKeysDelay( Window *pTestWindow ); + + BOOL HandleVisibleControls( Window *pControl ); + BOOL HandleCommonMethods( Window *pControl ); + +public: + StatementControl( SCmdStream *pIn, USHORT nControlType ); + virtual BOOL Execute(); + +}; + +class StatementFlow : public StatementList // Kommunikation mit Sequence +{ + USHORT nArt; + + USHORT nParams; + comm_USHORT nSNr1; + comm_ULONG nLNr1; + String aString1; + BOOL bBool1; + + +public: + StatementFlow (ULONG nServiceId, SCmdStream *pIn, ImplRemoteControl *pRC ); + StatementFlow( StatementList *pAfterThis, USHORT nArtP ); + virtual BOOL Execute(); + static CommunicationLink *pCommLink; + static BOOL bSending; + + static 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; + SmartId aUId; + BOOL bSearchButtonOnToolbox; +public: + SearchUID( SmartId aUIdP, BOOL bSearchButtonOnToolboxP ): Search( SEARCH_FOCUS_FIRST ), pMaybeResult(NULL), pAlternateResult(NULL), aUId(aUIdP), bSearchButtonOnToolbox(bSearchButtonOnToolboxP) {} + virtual 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 BOOL IsWinOK( Window *pWin ); +}; +class SearchPopupFloatingWin : public Search +{ +public: + SearchPopupFloatingWin(): Search( SEARCH_FOCUS_FIRST ) {} + virtual BOOL IsWinOK( Window *pWin ); +}; +class SearchRT : public Search +{ + WindowType mnRT; + USHORT mnSkip; + USHORT mnCount; +public: + SearchRT( WindowType nRTP, SearchFlags nSearchFlags, USHORT nSkip = 0 ): Search(nSearchFlags), mnRT(nRTP), mnSkip( nSkip ), mnCount( 0 ) {} + virtual BOOL IsWinOK( Window *pWin ); + USHORT GetCount(){ return mnCount; } +}; +class SearchScroll : public SearchRT +{ + USHORT nDirection; +public: + SearchScroll( USHORT nDir, SearchFlags nSearchFlags ): SearchRT(WINDOW_SCROLLBAR, nSearchFlags), nDirection(nDir) {} + virtual BOOL IsWinOK( Window *pWin ); +}; +class SearchWinPtr : public Search +{ + Window *pTest; +public: + SearchWinPtr( Window *pTestP ): pTest(pTestP) {} + virtual BOOL IsWinOK( Window *pWin ); +}; +class SearchFadeSplitWin : public Search +{ + WindowAlign nAlign; +public: + SearchFadeSplitWin( WindowAlign nAlignP ): nAlign(nAlignP) {} + virtual BOOL IsWinOK( Window *pWin ); +}; + + +void ImplKeyInput( Window* pWin, KeyEvent &aKEvnt, BOOL bForceDirect=FALSE ); +void ImplMouseMove( Window* pWin, MouseEvent &aMEvnt, BOOL bForceDirect=FALSE ); +void ImplMouseButtonDown( Window* pWin, MouseEvent &aMEvnt, BOOL bForceDirect=FALSE ); +void ImplMouseButtonUp( Window* pWin, MouseEvent &aMEvnt, BOOL bForceDirect=FALSE ); +void ImplCommand( Window* pWin, CommandEvent &aCmdEvnt ); +void ImplEventWait( ULONG nID ); + +#endif diff --git a/automation/source/server/svcommstream.cxx b/automation/source/server/svcommstream.cxx new file mode 100644 index 000000000000..8b78facd7276 --- /dev/null +++ b/automation/source/server/svcommstream.cxx @@ -0,0 +1,51 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: svcommstream.cxx,v $ + * $Revision: 1.5 $ + * + * 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..a1f539c64bd6 --- /dev/null +++ b/automation/source/server/testtool.hrc @@ -0,0 +1,58 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: testtool.hrc,v $ + * $Revision: 1.3 $ + * + * 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..45c6a4880767 --- /dev/null +++ b/automation/source/simplecm/communiio.hxx @@ -0,0 +1,68 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: communiio.hxx,v $ + * $Revision: 1.5 $ + * + * 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..ab2e70ee2713 --- /dev/null +++ b/automation/source/simplecm/makefile.mk @@ -0,0 +1,50 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2008 by Sun Microsystems, Inc. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.6 $ +# +# 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..e323fffec45d --- /dev/null +++ b/automation/source/simplecm/packethandler.cxx @@ -0,0 +1,337 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: packethandler.cxx,v $ + * $Revision: 1.7 $ + * + * 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 = FALSE; + comm_BOOL bForceMultiChannelThisPacket = FALSE; + if ( pReceiver ) + { + comm_UINT32 nBytes = 0; + nReceiveProtocol = CM_PROTOCOL_OLDSTYLE; + nReceiveHeaderType = CH_NoHeader; + + READ_SOCKET( &nBytes, sizeof(nBytes) ) + if ( bWasError ) + return FALSE; + + if ( 0xFFFFFFFF == nBytes ) // Expliziter Request für dieses Datenpaket auf MultiChannel umzuschalten + { + READ_SOCKET( &nBytes, sizeof(nBytes) ) + if ( bWasError ) + return FALSE; + bForceMultiChannelThisPacket = 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 = TRUE; + } + + } + + if ( bWasError ) + return 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 FALSE; + } + nLen = nBytes; + } + else + bWasError = 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 = 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 = 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..a44bae8e74c3 --- /dev/null +++ b/automation/source/simplecm/packethandler.hxx @@ -0,0 +1,72 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: packethandler.hxx,v $ + * $Revision: 1.5 $ + * + * 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 = 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..6813b4c9b2c7 --- /dev/null +++ b/automation/source/simplecm/simplecm.cxx @@ -0,0 +1,705 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: simplecm.cxx,v $ + * $Revision: 1.8 $ + * + * 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( FALSE ) +, nTotalBytes( 0 ) +, maApplication("Undefined") +#if OSL_DEBUG_LEVEL > 1 +, bFlag( 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 = 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; +} + +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 ); + BOOL bWasError = FALSE; + + 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; +} + +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, NAMESPACE_VOS(OStreamSocket) *pSocket ) +: CommunicationLink( pMan ) +, aCommunicationPartner() +, aMyName() +, pStreamSocket( pSocket ) +, pReceiveStream( NULL ) +, bIsRequestShutdownPending( 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( NAMESPACE_VOS(OStreamSocket)* pSocket ) +{ + if ( pTCPIO ) + pTCPIO->SetStreamSocket( pSocket ); + pStreamSocket = pSocket; +} + +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 TRUE; +} + +void SimpleCommunicationLinkViaSocket::SetFinalRecieveTimeout() +{ + if ( !IsCommunicationError() ) + { + TimeValue aTime = {30, 0}; // 30 seconds + pStreamSocket->setRecvTimeout( &aTime ); + } +} + +BOOL SimpleCommunicationLinkViaSocket::IsCommunicationError() +{ + return !pStreamSocket; +} + +ByteString SimpleCommunicationLinkViaSocket::GetCommunicationPartner( CM_NameType eType ) +{ + if ( pStreamSocket ) + { + switch ( eType ) + { + case CM_DOTTED: + { + rtl::OUString aDotted; + NAMESPACE_VOS(OSocketAddr) *pPeerAdr = new NAMESPACE_VOS(OSocketAddr); + pStreamSocket->getPeerAddr( *pPeerAdr ); + ((NAMESPACE_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; + NAMESPACE_VOS(OSocketAddr) *pPeerAdr = new NAMESPACE_VOS(OSocketAddr); + pStreamSocket->getLocalAddr( *pPeerAdr ); + ((NAMESPACE_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;} + +BOOL SimpleCommunicationLinkViaSocket::DoReceiveDataStream() +{ + BOOL bWasError = FALSE; + char* pBuffer = NULL; + comm_UINT32 nLen; + bWasError = pPacketHandler->ReceiveData( (void* &)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, 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(); +} + +BOOL SimpleCommunicationLinkViaSocket::SendHandshake( HandshakeType aHandshakeType, SvStream* pData ) +{ + BOOL bWasError; + + if ( pData ) + { + 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 = 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, NAMESPACE_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(); +} + +BOOL SimpleCommunicationLinkViaSocketWithReceiveCallbacks::ReceiveDataStream() +{ + if ( DoReceiveDataStream() ) + { + SetNewPacketAsCurrent(); + StartCallback(); + DataReceived(); + return TRUE; + } + else + { + StartCallback(); + ShutdownCommunication(); + return FALSE; + } +} + +BOOL SimpleCommunicationLinkViaSocketWithReceiveCallbacks::ShutdownCommunication() +{ + if ( GetStreamSocket() ) + GetStreamSocket()->shutdown(); + + if ( GetStreamSocket() ) + GetStreamSocket()->close(); + + NAMESPACE_VOS(OStreamSocket) *pTempSocket = GetStreamSocket(); + SetStreamSocket( NULL ); + delete pTempSocket; + + ConnectionClosed(); + + return TRUE; +} + + + +CommunicationManager::CommunicationManager( BOOL bUseMultiChannel ) +: nInfoType( CM_NONE ) +, bIsCommunicationRunning( FALSE ) +, maApplication("Unknown") +, bIsMultiChannel( bUseMultiChannel ) +{ +} + +CommunicationManager::~CommunicationManager() +{ + xLastNewLink.Clear(); +} + +BOOL CommunicationManager::StartCommunication( String aApp, String aParams ) +{ + (void) aApp; /* avoid warning about unused parameter */ + (void) aParams; /* avoid warning about unused parameter */ + return FALSE; +} + +BOOL CommunicationManager::StartCommunication( ByteString aHost, ULONG nPort ) +{ + (void) aHost; /* avoid warning about unused parameter */ + (void) nPort; /* avoid warning about unused parameter */ + return FALSE; +} + +ByteString CommunicationManager::GetMyName( CM_NameType ) +{ + rtl::OUString aHostname; + NAMESPACE_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 = 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(); + USHORT 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, BOOL bRunningLinks ) +{ + maApplication = aApp; + if ( bRunningLinks ) + { + USHORT i; + for ( i = 0 ; i < GetCommunicationLinkCount() ; i++ ) + GetCommunicationLink( i )->SetApplication( aApp ); + } +} + + + +SingleCommunicationManager::SingleCommunicationManager( BOOL bUseMultiChannel ) +: CommunicationManager( bUseMultiChannel ) +{ + xActiveLink = NULL; + pInactiveLink = NULL; +} + +SingleCommunicationManager::~SingleCommunicationManager() +{ + StopCommunication(); + if ( pInactiveLink ) + pInactiveLink->InvalidateManager(); +} + +BOOL SingleCommunicationManager::StopCommunication() +{ + if ( xActiveLink.Is() ) + { + BOOL bSuccess = xActiveLink->StopCommunication(); + if ( pInactiveLink ) + pInactiveLink->InvalidateManager(); + pInactiveLink = xActiveLink; + xActiveLink.Clear(); + return bSuccess; + } + return TRUE; +} + +BOOL SingleCommunicationManager::IsLinkValid( CommunicationLink* pCL ) +{ + return &xActiveLink == pCL; +} + +USHORT SingleCommunicationManager::GetCommunicationLinkCount() +{ + return IsCommunicationRunning()?1:0; +} + +CommunicationLinkRef SingleCommunicationManager::GetCommunicationLink( USHORT ) +{ + 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 = FALSE; +} + +void SingleCommunicationManager::DestroyingLink( CommunicationLink *pCL ) +{ + pInactiveLink = NULL; + pCL->InvalidateManager(); +} + + +SingleCommunicationManagerClientViaSocket::SingleCommunicationManagerClientViaSocket( ByteString aHost, ULONG nPort, BOOL bUseMultiChannel ) +: SingleCommunicationManager( bUseMultiChannel ) +, aHostToTalk( aHost ) +, nPortToTalk( nPort ) +{ +} + + +SingleCommunicationManagerClientViaSocket::SingleCommunicationManagerClientViaSocket( BOOL bUseMultiChannel ) +: SingleCommunicationManager( bUseMultiChannel ) +, aHostToTalk() +, nPortToTalk( 0 ) +{ +} + + +BOOL CommonSocketFunctions::DoStartCommunication( CommunicationManager *pCM, ICommunicationManagerClient *pCMC, ByteString aHost, ULONG nPort ) +{ + NAMESPACE_VOS(OInetSocketAddr) Addr; + NAMESPACE_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 NAMESPACE_VOS(OConnectorSocket)(); + pConnSocket->setTcpNoDelay( 1 ); + if ( pConnSocket->connect( Addr, &aTV ) == NAMESPACE_VOS(ISocketTypes::TResult_Ok) ) + { + pConnSocket->setTcpNoDelay( 1 ); + + pCM->CallConnectionOpened( CreateCommunicationLink( pCM, pConnSocket ) ); + return TRUE; + } + else + delete pConnSocket; + + } while ( pCMC->RetryConnect() ); + + return FALSE; +} + diff --git a/automation/source/simplecm/tcpio.cxx b/automation/source/simplecm/tcpio.cxx new file mode 100644 index 000000000000..9d96c0a167c0 --- /dev/null +++ b/automation/source/simplecm/tcpio.cxx @@ -0,0 +1,74 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tcpio.cxx,v $ + * $Revision: 1.5 $ + * + * 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( NAMESPACE_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..26a7458b8e22 --- /dev/null +++ b/automation/source/simplecm/tcpio.hxx @@ -0,0 +1,64 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tcpio.hxx,v $ + * $Revision: 1.4 $ + * + * 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: + NAMESPACE_VOS(OStreamSocket) *pStreamSocket; + vos::OMutex aMSocketReadAccess; + vos::OMutex aMSocketWriteAccess; + +public: + + /// + TCPIO( NAMESPACE_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( NAMESPACE_VOS(OStreamSocket) *pSocket ); + +}; + +#endif diff --git a/automation/source/testtool/cmdstrm.cxx b/automation/source/testtool/cmdstrm.cxx new file mode 100644 index 000000000000..162ab4ed950c --- /dev/null +++ b/automation/source/testtool/cmdstrm.cxx @@ -0,0 +1,473 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: cmdstrm.cxx,v $ + * $Revision: 1.12 $ + * + * 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) \ + USHORT nMCode = nModify + ch; \ + USHORT _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; + USHORT nModify = 0; + while ( Work.Len() > 0 ) + { + Token = Work.GetToken(0,' '); + Work.Erase(0,Token.Len()+1); + ControlDef WhatName(Token,SmartId()); + USHORT nElement; + if (pKeyCodes->Seek_Entry(&WhatName,&nElement)) + { + USHORT nCode = (USHORT) 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, BOOL IsKeyString ) +{ + USHORT nParams = PARAM_NONE; + USHORT nNr1=0,nNr2=0,nNr3=0,nNr4=0; + comm_ULONG nLNr1=0; + String aString1,aString2; + BOOL bBool1=FALSE,bBool2=FALSE; + + if ( rPar ) + { + for ( USHORT 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( USHORT nNr, SbxArray* rPar ) +{ + Write(USHORT(SICommand)); + Write(nNr); + WriteSortedParams(rPar, (nNr & M_KEY_STRING) != 0 ); +} + +void CmdStream::GenCmdSlot( USHORT nNr, SbxArray* rPar ) +{ + Write(USHORT(SISlot)); + Write(nNr); + if (rPar) + { + USHORT nAnz = (rPar->Count()-1) >> 1; // Geteilt durch 2 + Write(nAnz); + BOOL bWriteUnoSlot = rPar->Get( 1 )->GetType() == SbxSTRING; + + for (USHORT n = 1 ; n <= nAnz ; n++) + { + /// #59513# nicht mehr ben�tigt +// 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( (USHORT)BinUSHORT ); + Write(rPar->Get( 2*n )->GetUShort()); + break; + case SbxLONG: + case SbxULONG: + case SbxLONG64: + case SbxULONG64: + case SbxDOUBLE: + if ( !bWriteUnoSlot ) + Write( (USHORT)BinULONG ); + Write(rPar->Get( 2*n )->GetULong()); + break; + case SbxSTRING: + case SbxCHAR: + if ( !bWriteUnoSlot ) + Write( (USHORT)BinString); + Write((String)rPar->Get( 2*n )->GetString()); // Cast f�r OS/2 + break; + case SbxBOOL: + if ( !bWriteUnoSlot ) + Write( (USHORT)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(USHORT(0)); +} + +void CmdStream::GenCmdUNOSlot( const String &aURL ) +{ + Write( USHORT(SIUnoSlot) ); +/* Write( USHORT(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( USHORT(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, USHORT nMethodId, SbxArray* rPar ) +{ + Write(USHORT(SIControl)); + Write(nUId); + Write(nMethodId); + WriteSortedParams(rPar, (nMethodId & M_KEY_STRING) != 0 ); +} + +void CmdStream::GenCmdControl( String aUId, USHORT nMethodId, SbxArray* rPar ) +{ + Write(USHORT(SIStringControl)); + Write(aUId); + Write(nMethodId); + WriteSortedParams(rPar, (nMethodId & M_KEY_STRING) != 0 ); +} + +void CmdStream::GenCmdFlow( USHORT nArt ) +{ + Write(USHORT(SIFlow)); + Write(nArt); + Write(USHORT(PARAM_NONE)); // Typ der folgenden Parameter +} + +void CmdStream::GenCmdFlow( USHORT nArt, USHORT nNr1 ) +{ + Write(USHORT(SIFlow)); + Write(nArt); + Write(USHORT(PARAM_USHORT_1)); // Typ der folgenden Parameter + Write(nNr1); +} + +void CmdStream::GenCmdFlow( USHORT nArt, comm_ULONG nNr1 ) +{ + Write(USHORT(SIFlow)); + Write(nArt); + Write(USHORT(PARAM_ULONG_1)); // Typ der folgenden Parameter + Write(nNr1); +} + +void CmdStream::GenCmdFlow( USHORT nArt, String aString1 ) +{ + Write(USHORT(SIFlow)); + Write(nArt); + Write(USHORT(PARAM_STR_1)); // Typ der folgenden Parameter + Write(aString1); +} + +void CmdStream::Write( String aString, BOOL IsKeyString ) +{ + if ( IsKeyString ) + Write( WandleKeyEventString( aString ), 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..1f14aa48b803 --- /dev/null +++ b/automation/source/testtool/cmdstrm.hxx @@ -0,0 +1,81 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: cmdstrm.hxx,v $ + * $Revision: 1.5 $ + * + * 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, BOOL IsKeyString = FALSE ); + + void GenCmdCommand( USHORT nNr, SbxArray* rPar ); + + void GenCmdSlot( USHORT nNr, SbxArray* rPar ); + + void GenCmdUNOSlot( const String &aURL ); + + void GenCmdControl( comm_ULONG nUId, USHORT nMethodId, SbxArray* rPar ); + void GenCmdControl( String aUId, USHORT nMethodId, SbxArray* rPar ); + + + void GenCmdFlow( USHORT nArt ); + void GenCmdFlow( USHORT nArt, USHORT nNr1 ); + void GenCmdFlow( USHORT nArt, comm_ULONG nNr1 ); + void GenCmdFlow( USHORT 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, BOOL IsKeyString = 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..31a170945964 --- /dev/null +++ b/automation/source/testtool/comm_bas.cxx @@ -0,0 +1,445 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: comm_bas.cxx,v $ + * $Revision: 1.9 $ + * + * 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 +// BOOL IsCommunicationRunning // Läuft noch irgendwas +// String GetMyName Der eigene Name +// 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( TRUE ) +, m_bCatchOpen( 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( FALSE ) +, m_bCatchOpen( 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; + BOOL bFound = FALSE; + while( p->nArgs != -1 ) + { + if( rName.CompareIgnoreCaseToAscii( p->pName ) == COMPARE_EQUAL ) + { + bFound = 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(); + USHORT nIndex = (USHORT) pVar->GetUserData(); + // kein Index: weiterreichen! + if( nIndex ) + { + ULONG t = pHint->GetId(); + if( t == SBX_HINT_INFOWANTED ) + pVar->SetInfo( GetInfo( (short) pVar->GetUserData() ) ); + else + { + BOOL bWrite = FALSE; + if( t == SBX_HINT_DATACHANGED ) + bWrite = TRUE; + if( t == SBX_HINT_DATAWANTED || bWrite ) + { + // Parameter-Test fuer Methoden: + USHORT 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 ); + USHORT 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 = FALSE) den Returnwert +// im Element 0 des Argv ab; beim Put (bPut = TRUE) wird der Wert aus +// Element 0 gespeichert. + +// Die Methoden: + +// Manager +void CommunicationWrapper::MStartCommunication( SbxVariable* pVar, SbxArray* pPar, BOOL /*bWrite*/ ) +{ // CommunicationLink StartCommunication( Host, Port ) + m_bCatchOpen = TRUE; + if ( m_pManager->StartCommunication( ByteString( pPar->Get( 1 )->GetString(), RTL_TEXTENCODING_UTF8 ), pPar->Get( 2 )->GetULong() ) ) + { + while ( !m_pNewLink ) + GetpApp()->Reschedule(); + m_bCatchOpen = FALSE; + CommunicationWrapper *pNewLinkWrapper = new CommunicationWrapper( m_pNewLink ); + m_pNewLink = NULL; + pVar->PutObject( pNewLinkWrapper ); + } + +} + +void CommunicationWrapper::MStopAllCommunication( SbxVariable* /*pVar*/, SbxArray* /*pPar*/, BOOL /*bWrite*/ ) +{ // StopAllCommunication // Alle Kommunikation wird abgebrochen + m_pManager->StopCommunication(); +} + +void CommunicationWrapper::MIsCommunicationRunning( SbxVariable* pVar, SbxArray* /*pPar*/, BOOL /*bWrite*/ ) +{ // BOOL IsCommunicationRunning // Läuft noch irgendwas + pVar->PutBool( m_pManager->IsCommunicationRunning() ); +} + +void CommunicationWrapper::MGetMyName( SbxVariable* pVar, SbxArray* /*pPar*/, 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, BOOL /*bWrite*/ ) +{ // 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, 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*/, BOOL /*bWrite*/ ) +{ // StopCommunication Die Kommunikation wird abgebrochen + m_pLink->StopCommunication(); +} + +void CommunicationWrapper::LGetMyName( SbxVariable* pVar, SbxArray* /*pPar*/, 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*/, 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, 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*/, BOOL /*bWrite*/ ) +{ // String GetString Ergebnis des letzten Empfangs + SvStream *pReceiveStream = m_pLink->GetServiceData(); + if ( pReceiveStream ) + { + 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..aa3e884372e9 --- /dev/null +++ b/automation/source/testtool/comm_bas.hxx @@ -0,0 +1,123 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: comm_bas.hxx,v $ + * $Revision: 1.6 $ + * + * 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, 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, BOOL bWrite ); + void MStopAllCommunication( SbxVariable* pVar, SbxArray* pPar, BOOL bWrite ); + void MIsCommunicationRunning( SbxVariable* pVar, SbxArray* pPar, BOOL bWrite ); + void MGetMyName( SbxVariable* pVar, SbxArray* pPar, BOOL bWrite ); + void MIsLinkValid( SbxVariable* pVar, SbxArray* pPar, BOOL bWrite ); + void MSetCommunicationEventHandler( SbxVariable* pVar, SbxArray* pPar, BOOL bWrite ); + + // Link + void LStopCommunication( SbxVariable* pVar, SbxArray* pPar, BOOL bWrite ); + void LGetMyName( SbxVariable* pVar, SbxArray* pPar, BOOL bWrite ); + void LGetHostName( SbxVariable* pVar, SbxArray* pPar, BOOL bWrite ); + void LSend( SbxVariable* pVar, SbxArray* pPar, BOOL bWrite ); + void LGetString( SbxVariable* pVar, SbxArray* pPar, BOOL bWrite ); + + // Interne Member und Methoden + CommunicationManagerClientViaSocket *m_pManager; + CommunicationLink *m_pLink; + 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 ); + 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..1c911568278a --- /dev/null +++ b/automation/source/testtool/cretstrm.cxx @@ -0,0 +1,76 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: cretstrm.cxx,v $ + * $Revision: 1.6 $ + * + * 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; + USHORT 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..bd0626d15ff5 --- /dev/null +++ b/automation/source/testtool/cretstrm.hxx @@ -0,0 +1,58 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: cretstrm.hxx,v $ + * $Revision: 1.6 $ + * + * 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; + USHORT 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 ( SmartId* &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..e23d3a0f44e1 --- /dev/null +++ b/automation/source/testtool/filter.pl @@ -0,0 +1,147 @@ +#!/usr/bin/perl +#************************************************************************* +#* +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2008 by Sun Microsystems, Inc. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# $RCSfile: filter.pl,v $ +# +# $Revision: 1.5 $ +# +# 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; +} + +sub convert_path { + + $_ = $_[0]; + $GUI = $ENV {"GUI"}; + $use_shell = $ENV {"USE_SHELL"}; + if ( $GUI eq "WNT" ) + { + if ( defined( $use_shell ) && "$use_shell" eq "4nt" ) + { + s/\//\\/g; + } + } + $_; +} + +# Read a file. +# first parameter ist the filename +sub read_file { + + local ($filename,$file) = @_; + $file++; # String increment + local $TempFileName = &convert_path( $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 + +print &convert_path ("/\n\n\n") if ( $debug ); + + +$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..55aef16ff338 --- /dev/null +++ b/automation/source/testtool/httprequest.cxx @@ -0,0 +1,242 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: httprequest.cxx,v $ + * $Revision: 1.3 $ + * + * 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, USHORT nPort ) +{ + nStatus = HTTP_REQUEST_SET; + Init(); + aRequestHost = aHost; + aRequestPath = aPath; + nRequestPort = nPort; +} + +void HttpRequest::SetProxy( ByteString aHost, USHORT nPort ) +{ + nStatus = HTTP_REQUEST_SET; + Init(); + aProxyHost = aHost; + nProxyPort = nPort; +} + +BOOL HttpRequest::Execute() +{ + nStatus = HTTP_REQUEST_PENDING; + Init(); + + // Open channel to standard redir host + NAMESPACE_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 NAMESPACE_VOS(OConnectorSocket)(); + if ( pOutSocket->connect( aConnectAddr, &aTV ) == NAMESPACE_VOS(ISocketTypes::TResult_Ok) ) + { +// pOutSocket->setTcpNoDelay( 1 ); + } + else + { + delete pOutSocket; + nStatus = HTTP_REQUEST_ERROR; + return 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 ]; + + BOOL bWasError = ( nStatus != HTTP_REQUEST_PENDING ); + + 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; + BOOL bInsideHeader = TRUE; + while ( bInsideHeader ) + { + pStream->ReadLine( aLine ); + if ( !aLine.Len() ) + bInsideHeader = FALSE; + else + { + if ( IsItem( "HTTP/", aLine ) ) + nResultId = (USHORT)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 TRUE; + } + else + { + nStatus = HTTP_REQUEST_ERROR; + return 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() ); +} + +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; +} + +USHORT HttpRequest::GetStatus() +{ + return nStatus; +} + diff --git a/automation/source/testtool/httprequest.hxx b/automation/source/testtool/httprequest.hxx new file mode 100644 index 000000000000..3db9a4516505 --- /dev/null +++ b/automation/source/testtool/httprequest.hxx @@ -0,0 +1,88 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: httprequest.hxx,v $ + * $Revision: 1.3 $ + * + * 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; + USHORT nRequestPort; + ByteString aProxyHost; + USHORT nProxyPort; + + USHORT nStatus; + vos::OConnectorSocket *pOutSocket; + + ByteString aHeader; + USHORT nResultId; + ByteString aContentType; + SvMemoryStream* pStream; + + void SendString( vos::OStreamSocket* pSocket, ByteString aText ); + BOOL IsItem( ByteString aItem, ByteString aLine ); + void Init(); +public: + HttpRequest(); + ~HttpRequest(); + + void SetRequest( ByteString aHost, ByteString aPath, USHORT nPort ); + void SetProxy( ByteString aHost, USHORT nPort ); + + BOOL Execute(); + void Abort(); + + ByteString GetHeader() { return aHeader; } + SvMemoryStream* GetBody(); + + ByteString GetContentType() { return aContentType; } + USHORT GetResultId() { return nResultId; } + + USHORT GetStatus(); + +}; + +#endif diff --git a/automation/source/testtool/makefile.mk b/automation/source/testtool/makefile.mk new file mode 100644 index 000000000000..79a811fdaee7 --- /dev/null +++ b/automation/source/testtool/makefile.mk @@ -0,0 +1,118 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2008 by Sun Microsystems, Inc. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.13 $ +# +# 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)$/vcl$/wintypes.hxx \ + $(MISC)$/xfilter.pl + $(PERL) $(MISC)$/xfilter.pl $(SOLARVERSION)$/$(INPATH)$/inc$(UPDMINOREXT) vcl$/wintypes.hxx $(INCCOM)$/res_type WINDOW_ + + + +$(MISC)$/xfilter.pl : filter.pl +.IF "$(GUI)" == "UNX" || "$(USE_SHELL)"!="4nt" + tr -d "\015" < filter.pl > $(MISC)$/xfilter.pl + chmod 664 $(MISC)$/xfilter.pl +.ELSE + $(COPY) filter.pl $(MISC)$/xfilter.pl + attrib -r $(MISC)$/xfilter.pl +.ENDIF + + + +.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..d3937963c155 --- /dev/null +++ b/automation/source/testtool/objtest.cxx @@ -0,0 +1,4267 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: objtest.cxx,v $ + * $Revision: 1.40 $ + * + * 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 <svtools/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, SmartId aUIdP ) +{ +DBG_CTOR(ControlItem,0); + InitData(); + pData->Kurzname.AssignAscii( Name ); + pData->aUId = aUIdP; +} + +ControlItem::ControlItem( const String &Name, SmartId 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 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 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, SmartId 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 ULONG nUId ) +: ControlItem( Name, URL, nUId ) +{} + +ControlItemSon::ControlItemSon(const char *Name, const String &URL, const ULONG nUId ) +: ControlItem( Name, URL, nUId ) +{}*/ + + + +BOOL ControlDef::operator < (const ControlItem &rPar) +{ + return pData->Kurzname.CompareIgnoreCaseToAscii(rPar.pData->Kurzname) == COMPARE_LESS; +} + +BOOL ControlDef::operator == (const ControlItem &rPar) +{ + return pData->Kurzname.CompareIgnoreCaseToAscii(rPar.pData->Kurzname) == COMPARE_EQUAL; +} + +void ControlDef::Write( SvStream &aStream ) +{ + if ( pSons ) + aStream.WriteByteString( String('*').Append( pData->Kurzname ), RTL_TEXTENCODING_UTF8 ); + else + aStream.WriteByteString( pData->Kurzname, RTL_TEXTENCODING_UTF8 ); + aStream << ((USHORT)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() ULONG != comm_ULONG on 64bit + if ( pSons ) + for ( USHORT i = 0 ; pSons->Count() > i ; i++ ) + ((ControlDef*)(*pSons)[i])->Write(aStream); +} + +ControlDef::ControlDef(const String &Name, SmartId 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, 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 ( USHORT i = 0; i < pOriginal->pSons->Count() ; i++) + { + ControlDef *pNewDef; + pNewDef = new ControlDef( aOldName, aNewName, pOriginal->SonGetObject(i) ,TRUE ); + if (! SonInsert(pNewDef)) + { + DBG_ERROR("Name Doppelt im CopyConstructor. Neuer Name = Controlname!!"); + delete pNewDef; + } + } + + } + else + pSons = NULL; +} + +BOOL ControlItemUId::operator < (const ControlItem &rPar) +{ + return pData->aUId < rPar.pData->aUId; +} + +BOOL ControlItemUId::operator == (const ControlItem &rPar) +{ + return pData->aUId == rPar.pData->aUId; +} + +SV_IMPL_OP_PTRARR_SORT( CNames, ControlItem* ) + +void CRevNames::Insert( String aName, SmartId aUId, ULONG nSeq ) +{ + ControlItem *pRN = new ReverseName(aName,aUId,nSeq); + USHORT 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( SmartId aUId ) +{ + ReverseName *pRN = new ReverseName(UniString(),aUId,0); + USHORT nPos; + BOOL bSeekOK = Seek_Entry(pRN,&nPos); + + delete pRN; + if ( bSeekOK ) + return GetObject(nPos)->pData->Kurzname; + else + { + if ( aUId.Matches( UID_ACTIVE ) ) + return CUniString("Active"); + else + return GEN_RES_STR1( S_NAME_NOT_THERE, aUId.GetText() ); + } +} + +void CRevNames::Invalidate ( ULONG nSeq ) +{ + USHORT 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(FALSE) +, bReturnOK(TRUE) +, nSequence(KEEP_SEQUENCES) +, ProgPath() +, IsBlock(FALSE) +, SingleCommandBlock(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 = 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(TRUE) +, bReturnOK(TRUE) +, nSequence(KEEP_SEQUENCES) +, ProgPath() +, IsBlock(FALSE) +, SingleCommandBlock(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 = 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(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 IRIX + abGP.Append( "06" ); +#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 +#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 = FALSE; + + pImpl->bLnaguageExtensionLoaded= 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 = TRUE; + pImpl->bDebugFindNoErrors = 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(), TRUE ); + StartListening( pWait->GetBroadcaster(), 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 ); + USHORT i; + for ( i = 0 ; i < pRCommands->Count() ; i++ ) + { + SbxTransportMethod *pMeth = new SbxTransportMethod( SbxVARIANT ); + pMeth->SetName( pRCommands->GetObject( i )->pData->Kurzname ); + pMeth->SetUserData( ID_RemoteCommand ); + pMeth->nValue = pRCommands->GetObject( i )->pData->aUId.GetNum(); + Insert( pMeth ); + StartListening( pMeth->GetBroadcaster(), 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(), 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, 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; + SmartId aUId; + xub_StrLen nLineNr; + USHORT 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, TRUE ); + if ( !pUIds ) + return; + pNewDef = new ControlDef("Active",SmartId(0)); + if (! pUIds->C40_PTR_INSERT(ControlItem, (ControlItem*&)pNewDef)) + { + 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; + BOOL bOK = TRUE; + + while ( bOK && nIndex < aShortname.Len() ) + { + sal_Unicode aChar = aShortname.GetChar( nIndex ); + BOOL bOKThis = 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; + } + + 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 = TRUE; + aLongname.Erase( 0, 4 ); + } + BOOL bMozillaName = ( !bIsFlat && aLongname.Copy( 0, 4 ).EqualsIgnoreCaseAscii( ".moz" ) ); + + if ( aShortname.GetChar(0) == '+' ) // Kompletten Eintrag kopieren + { + aShortname.Erase(0,1); + ControlDef WhatName(aLongname,SmartId()); + ControlDef *OldTree; + if (pNames->Seek_Entry(&WhatName,&nElement)) + { + OldTree = (ControlDef*)pNames->GetObject(nElement); + pNewDef = new ControlDef(aLongname,aShortname,OldTree,TRUE); + + if (! pNames->C40_PTR_INSERT(ControlItem, (ControlItem*&)pNewDef)) + { + 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 + { + + if (aShortname.CompareIgnoreCaseToAscii("*Active") == COMPARE_EQUAL) + aUId = SmartId( UID_ACTIVE ); + else if ( !bUnoName && !bMozillaName ) + { // Bestimmen der ID aus der Hid.Lst + ControlDef WhatName(aLongname,SmartId()); + 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 + { + if ( bUnoName ) + aUId = SmartId( aLongname ); + else if ( bMozillaName ) + aUId = SmartId( aLongname ); + else + { + DBG_ERROR("Unknown URL schema"); + } + } + + + + 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!"); + } + } + + if (! pNames->C40_PTR_INSERT(ControlItem, (ControlItem*&)pNewDef)) + { + 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, BOOL bSortByName ) +// Wenn bSortByName == FALSE, dann nach UId Sortieren (ControlItemUId statt ControlDef) +{ + SvFileStream Stream; + String aLine,aLongname; + SmartId aUId; + xub_StrLen nLineNr; + ControlItem *pNewItem; + USHORT 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); + aUId = SmartId( (ULONG)aLine.GetToken(1,cMyDelim).ToInt64() ); + + 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 + { + USHORT 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 ) +{ + USHORT nIndex = 0; + + if ( !pNames ) + pNames = new CNames(); + + while ( String::CreateFromAscii(arWas[nIndex].Kurzname).Len() > 0 ) + { + SmartId 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 + USHORT nSysWinModeMemo = GetpApp()->GetSystemWindowMode(); + GetpApp()->SetSystemWindowMode( 0 ); + ModelessDialog aDlg(NULL); + aDlg.SetOutputSizePixel(Size(200,0)); + aDlg.SetText(CUniString("Waiting for Answer")); + aDlg.Show( TRUE, SHOW_NOFOCUSCHANGE | SHOW_NOACTIVATE ); + GetpApp()->SetSystemWindowMode( nSysWinModeMemo ); + #endif + 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 = TRUE; + } + else + { + GetpApp()->Reschedule(); + } + nIdleCount = 0; + } + } + + + if ( !bReturnOK ) + { + ADD_ERROR(ERR_EXEC_TIMEOUT,GEN_RES_STR1(S_TIMOUT_WAITING, String::CreateFromInt64(nSequence))); + bReturnOK = 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(); + + 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 = 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 = 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 = TRUE; // Kein Return zu erwarten + } + } + else + { + ADD_ERROR(ERR_SEND_TIMEOUT,GEN_RES_STR1(S_NO_CONNECTION, String::CreateFromInt64(nSequence))); + nSequence++; + bReturnOK = 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 ) + { + 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 = FALSE; + if ( aDialogHandlerName.Len() > 0 ) + GetpApp()->InsertIdleHdl( LINK( this, TestToolObj, IdleHdl ), 1 ); + } + IsBlock = FALSE; + } + else + { + DBG_ERROR("EndBlock au�erhalb eines Blockes"); + } +} + + +BOOL TestToolObj::Load( String aFileName, SbModule *pMod ) +{ + BOOL bOk = TRUE; + SvFileStream aStrm( aFileName, STREAM_STD_READ ); + if( aStrm.IsOpen() ) + { + String aText, aLine; + BOOL bIsFirstLine = 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 = FALSE; + } + if( aStrm.GetError() != SVSTREAM_OK ) + bOk = 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 = FALSE; + + } + else + bOk = FALSE; + return bOk; +} + + +BOOL TestToolObj::ReadNamesBin( String Filename, CNames *&pSIds, CNames *&pControls ) +{ + SvFileStream aStream; + String aName,aURL; + SmartId 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 FALSE; + } + + if ( !pSIds ) + pSIds = new CNames(); + if ( !pControls ) + pControls = new CNames(); + + { + TTExecutionStatusHint aHint( TT_EXECUTION_ENTERWAIT ); + GetTTBroadcaster().Broadcast( aHint ); + } + + USHORT nAnz; + aStream >> nAnz; + CNames *pNames = pSIds; // first read all the slots + BOOL bIsFlat = TRUE; // Slots do not have children + + while ( nAnz && !aStream.IsEof() ) + { + + aStream.ReadByteString( aName, RTL_TEXTENCODING_UTF8 ); + + USHORT nType; + aStream >> nType; + if ( !nType /* HasNumeric() */) + { + String aStrId; + aStream.ReadByteString( aStrId, RTL_TEXTENCODING_UTF8 ); + aUId = SmartId( aStrId ); + } + else + { + comm_ULONG nUId; + aStream >> nUId; + aUId = SmartId( 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!"); + } + } + + if (! pNames->C40_PTR_INSERT(ControlItem, (ControlItem*&)pNewDef)) + { + 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 = FALSE; // Controls *do* have children + } + + + GetpApp()->Reschedule(); + } + { + TTExecutionStatusHint aHint( TT_EXECUTION_LEAVEWAIT ); + GetTTBroadcaster().Broadcast( aHint ); + } + + aStream.Close(); + return TRUE; +} + + +BOOL TestToolObj::WriteNamesBin( String Filename, CNames *pSIds, CNames *pControls ) +{ + BOOL bOk = TRUE; + SvFileStream aStrm( String(Filename).AppendAscii(".bin"), STREAM_STD_WRITE ); + if( aStrm.IsOpen() ) + { + USHORT 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 = FALSE; + } + } + else + aStrm << USHORT( 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 = FALSE; + } + } + else + aStrm << USHORT( 0 ); + } + else + bOk = 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(); + + ULONG nHintId = p->GetId(); + 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 (USHORT i=0;i<VAR_POOL_SIZE;i++) + { + pImpl->pMyVars[i]->SetName( CUniString("VarDummy").Append(UniString::CreateFromInt32(i)) ); + } + } + else if ( rPar && rPar->Count() == 2 ) + { + USHORT nElement; + SbxVariableRef pArg = rPar->Get( 1 ); + String aKontext = pArg->GetString(); + ControlDef WhatName(aKontext,SmartId()); + 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 (USHORT 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 = TRUE; + BeginBlock(); + EndBlock(); + pImpl->bIsStart = 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 = TRUE; // Bug 57188 + IsBlock = FALSE; + +// pCommunicationManager->StartCommunication(); + + for (USHORT 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 = FALSE; + SfxSimpleHint aHint( SBX_HINT_LANGUAGE_EXTENSION_LOADED ); + GetTTBroadcaster().Broadcast( aHint ); + + pImpl->nMinRemoteCommandDelay = 0; + pImpl->nMaxRemoteCommandDelay = 0; + pImpl->bDoRemoteCommandDelay = FALSE; + pImpl->aTestCaseName.Erase(); + pImpl->aTestCaseFileName.Erase(); + pImpl->nTestCaseLineNr = 0; + + pImpl->bEnableQaErrors = TRUE; + pImpl->bDebugFindNoErrors = 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 = 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 = 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 = 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 + { + USHORT 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(); + BOOL bWasNewError = FALSE; + + if ( BasicRuntimeAccess::HasStack() ) + { + for ( USHORT i = 0 ; i < BasicRuntimeAccess::GetStackEntryCount() -1 ; i++ ) + { + BasicErrorStackEntry aThisEntry = BasicRuntimeAccess::GetStackEntry(i); + if ( !bWasNewError ) + { + bWasNewError = 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(); + } + + BOOL bIsFirst = TRUE; + while ( aRun.IsValid() ) + { + xub_StrLen nErrLn; + xub_StrLen nCol1; + xub_StrLen nCol2; + if ( bIsFirst ) + { + bIsFirst = 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 = 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 + { + USHORT 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 + { + USHORT 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 + { + USHORT 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!! + + +/* 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; + + 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"), SmartId( ((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 ((USHORT)(((SbxTransportMethod*)pVar)->nValue),rPar); + if ( !IsError() && ((SbxTransportMethod*)pVar)->nValue & M_WITH_RETURN ) + { + pImpl->pNextReturn = ((SbxTransportMethod*)pVar); + aNextReturnId = SmartId( ((SbxTransportMethod*)pVar)->nValue ); + } + if ( SingleCommandBlock ) + EndBlock(); + if ( !IsError() && (USHORT)((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 ( (USHORT)((SbxTransportMethod*)pVar)->nValue, rPar ); + pVar->PutInteger( (USHORT)((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(), + (USHORT)((SbxTransportMethod*)pVar)->nValue, rPar); + aNextReturnId = SmartId( pMember->GetULong() ); + } + else + { + In->GenCmdControl (pMember->GetString(), + (USHORT)((SbxTransportMethod*)pVar)->nValue, rPar); + aNextReturnId = SmartId( pMember->GetString() ); + } + } + + if ( !IsError() && ((SbxTransportMethod*)pVar)->nValue & M_WITH_RETURN ) + { + pImpl->pNextReturn = ((SbxTransportMethod*)pVar); + } + else + { + pImpl->pNextReturn = NULL; + aNextReturnId = SmartId(); + } + + } + if ( SingleCommandBlock ) + EndBlock(); + if ( !IsError() && (USHORT)((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 (USHORT 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( 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 + { + + USHORT nElement; + ControlDef *pWhatName = new ControlDef(aStr,SmartId()); + + /// 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 + if ( pWhatName->pData->aUId.HasNumeric() ) + pImpl->pControlsObj->SetUserData( ID_Control ); + else + 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; + } + if ( pWhatName->pData->aUId.HasNumeric() ) + pMember->PutULong(pWhatName->pData->aUId.GetNum()); + else + pMember->PutString(pWhatName->pData->aUId.GetStr()); + + 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 ); + + 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(); + } + 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 ), SmartId() ); + 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 ); + + if ( pWhatName->pData->aUId.HasNumeric() ) + pReturn->PutULong(pWhatName->pData->aUId.GetNum()); + else + pReturn->PutString(pWhatName->pData->aUId.GetStr()); + 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"); +} + +BOOL TestToolObj::CError( ULONG code, const String& rMsg, xub_StrLen l, xub_StrLen c1, xub_StrLen c2 ) +{ + bWasPrecompilerError = TRUE; + if ( aCErrorHdl.IsSet() ) + { + ErrorEntry aErrorEntry( code, rMsg, l, c1, c2 ); + return (BOOL)aCErrorHdl.Call( &aErrorEntry ); + } + else + { + ADD_ERROR( code, rMsg ) + return 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" ) + +BOOL IsAlphaChar( sal_Unicode cChar ) +{ + return ( cChar >= 'a' && cChar <= 'z' ) || + ( cChar >= 'A' && cChar <= 'Z' ); +} + +BOOL IsInsideString( const String& aSource, const xub_StrLen nStart ) +{ + BOOL bInside = 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; +} + +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, USHORT &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 ) +{ + USHORT 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(); + } +} + + +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(), TRUE ); + + xub_StrLen nTestCase; + xub_StrLen nEndCase; + xub_StrLen nStartPos = 0; + String aSource(aSourceIn); + bWasPrecompilerError = 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 ) + { + USHORT 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); + USHORT 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 ) +{ + USHORT 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, FALSE ); + + { + TTExecutionStatusHint aHint( TT_EXECUTION_HIDE_ACTION ); + GetTTBroadcaster().Broadcast( aHint ); + } + } +} + +void TestToolObj::SortControlsByNumber( 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; + USHORT 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 ) + { + ControlItem *pZeroItem = new ControlItemUId( UniString(), SmartId(0) ); + USHORT 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; + } + } +} + + +BOOL TestToolObj::ReturnResults( SvStream *pIn ) +{ + + USHORT nId; + ULONG nClearSequence = 0; + BOOL bSequenceOK = TRUE; + CNames *pReverseControlsKontext = NULL; + + CRetStream *pRetStream = new CRetStream(pIn); + + pRetStream->Read( nId ); + while( !pIn->IsEof() ) + { + switch( nId ) + { + case SIReturn: + { + USHORT nRet,nParams; + SmartId aUId; + pRetStream->Read(nRet); + if ( pRetStream->GetNextType() == BinString ) + { + String aUStrId; // UniqueStringID Used for Mozilla Integration + pRetStream->Read( aUStrId ); + aUId = SmartId( aUStrId ); + } + else + { + comm_ULONG nUId; + pRetStream->Read( nUId ); // bei Sequence einfach die Sequence + aUId = SmartId( nUId ); + } + pRetStream->Read(nParams); + + USHORT nNr1 = 0; + comm_ULONG nLNr1 = 0; + String aString1; + BOOL bBool1 = 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: + { + ULONG nUId = aUId.GetNum(); + if ( nSequence != nUId ) + { + bSequenceOK = FALSE; + ADD_ERROR(SbxERR_BAD_ACTION, GEN_RES_STR2(S_RETURN_SEQUENCE_MISSMATCH, String::CreateFromInt64(nUId), String::CreateFromInt64(nSequence)) ); + } + else + { + nClearSequence = nUId; + } + } + break; + case RET_Value: + if ( pImpl->pNextReturn ) + { +// ULONG nHintUserData = pImpl->pNextReturn->GetParent()->GetUserData(); +// pImpl->pNextReturn->GetParent()->SetUserData(0); +// if ( nUId == pImpl->pNextReturn->GetParent()->GetULong() ) + if ( aNextReturnId.Matches( aUId ) ) + { + if( nParams & PARAM_ULONG_1 ) + { + 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 ) + { + 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; + USHORT 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; + pWinInfo->aUId = aUId.GetText(); + pWinInfo->nRType = (USHORT)nLNr1; // just 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 ) + { + USHORT 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 ) + { + USHORT nNr; + ControlItem *pNewItem = new ControlItemUId( String(), aUId ); + if ( pReverseControlsKontext->Seek_Entry(pNewItem,&nNr) ) + { +// SmartId aID = pReverseControlsKontext->GetObject(nNr)->pData->aUId; + pWinInfo->aKurzname += pReverseControlsKontext->GetObject(nNr)->pData->Kurzname; + } + delete pNewItem; + } + + // Slotname feststellen + if ( m_pReverseSlots ) + { + USHORT 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 + if ( aUId.HasString() ) + { // use the String ID since there is no LongName in hid.lst + pWinInfo->aLangname = aUId.GetStr(); + } + else + { + if ( m_pReverseUIds ) + { + USHORT nNr; + ControlItem *pNewItem = new ControlItemUId( String(), aUId ); + if ( m_pReverseUIds->Seek_Entry(pNewItem,&nNr) ) + pWinInfo->aLangname = m_pReverseUIds->GetObject(nNr)->pData->Kurzname; + delete pNewItem; + } + } + + aWinInfoHdl.Call( pWinInfo ); + + delete pWinInfo; + } + break; + case RET_ProfileInfo: + { + 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 = (USHORT)nLNr1; // Borders are 0 to 4 + USHORT 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 + { + USHORT 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; + USHORT 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; + } + } + } + break; + case RET_DirectLoging: + { + 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: + ; + } + } + break; + case RET_MacroRecorder: + { + SortControlsByNumber( TRUE ); + String aCommand,aControls,aControl,aULongNames,aULongName; + BOOL bWriteNewKontext = FALSE; + + aControls.Erase(); + // Kurzname feststellen + if ( m_pReverseControls ) + { + USHORT 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 ) + { + USHORT nNr; + ControlItem *pNewItem = new ControlItemUId( String(), SmartId( 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 + USHORT i,j; + BOOL bFoundUlongName = FALSE, bFoundControl = 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 + BOOL bFound = 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 = TRUE; + aULongName = aULongNames.GetToken(i,'/').GetToken( 1,':'); + aControl = aControls.GetToken(j,'/').GetToken( 1,':'); + aLastRecordedKontext = aCurrentKontext; + bWriteNewKontext = TRUE; + } + } + } + if ( !bFound ) + { + // check if both contain toplevel + bFoundUlongName = FALSE; + bFoundControl = 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 = 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 + USHORT i; + BOOL bFoundControl = 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 = 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; + + BOOL bWasParam = FALSE; + + if( nParams & PARAM_STR_1 ) + { + bWasParam = TRUE; + aCommand.AppendAscii( " \"" ); + if ( nNr1 & M_KEY_STRING ) + { + USHORT nModify = 0; + BOOL bIsProsa = FALSE; + xub_StrLen i; + for ( i = 0; i < aString1.Len(); i++ ) + { + if ( ((USHORT)aString1.GetChar(i)) == 1 ) // we have a spechial char + { + i++; + if ( !bIsProsa ) + { + aCommand.AppendAscii( "<" ); + bIsProsa = TRUE; + } + else + aCommand.AppendAscii( " " ); + + USHORT nKeyCode = (USHORT)aString1.GetChar(i) & KEY_CODE; + USHORT nNewModify = (USHORT)aString1.GetChar(i) & KEY_MODTYPE; + if ( nNewModify != nModify ) + { // generate modifiers + USHORT 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 = FALSE; + } + aCommand += aString1.GetChar(i); + nModify = 0; + } + } + if ( bIsProsa ) + { + aCommand.AppendAscii( ">" ); + bIsProsa = FALSE; + } + } + else + { + aCommand += aString1; + } + aCommand.AppendAscii( "\"" ); + } + if( nParams & PARAM_ULONG_1 ) + { + if ( bWasParam ) + aCommand.AppendAscii( ", " ); + else + aCommand.AppendAscii( " " ); + bWasParam = 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 = 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; + SmartId aUId; + if ( pRetStream->GetNextType() == BinString ) + { + String aUStrId; // UniqueStringID Used for Mozilla Integration + pRetStream->Read( aUStrId ); + aUId = SmartId( aUStrId ); + } + else + { + comm_ULONG nUId; + pRetStream->Read( nUId ); // bei Sequence einfach die Sequence + aUId = SmartId( nUId ); + } + 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 = TRUE; + + return TRUE; +} // RetService::Request() + +String TestToolObj::GetMethodName( ULONG nMethodId ) +{ + USHORT nElement; + if ( !Controls::pClasses ) // Ist static, wird also nur einmal geladen + ReadFlatArray( Controls::arClasses, Controls::pClasses ); + if ( Controls::pClasses ) + { + for ( nElement = 0 ; nElement < Controls::pClasses->Count() ; nElement++ ) + if ( Controls::pClasses->GetObject(nElement)->pData->aUId.Matches( nMethodId ) ) + return Controls::pClasses->GetObject(nElement)->pData->Kurzname; + } + return String(); +} + +String TestToolObj::GetKeyName( USHORT nKeyCode ) +{ + USHORT nElement; + if ( !CmdStream::pKeyCodes ) // Ist static, wird also nur einmal geladen + ReadFlatArray( CmdStream::arKeyCodes, CmdStream::pKeyCodes ); + if ( CmdStream::pKeyCodes ) + { + for ( nElement = 0 ; nElement < CmdStream::pKeyCodes->Count() ; nElement++ ) + if ( CmdStream::pKeyCodes->GetObject(nElement)->pData->aUId.Matches( nKeyCode ) ) + return CmdStream::pKeyCodes->GetObject(nElement)->pData->Kurzname; + } + 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; + ULONG nNumber; + String aType; + String aResult; + 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 = (ULONG)aText.Copy(nGleich+1,nEnd-nGleich-1).ToInt64(); + bFound = FALSE; + if ( aType.CompareTo(UIdKenn) == COMPARE_EQUAL ) + { + aResult = pShortNames->GetName(SmartId(nNumber)); + bFound = TRUE; + } + if ( aType.CompareTo(MethodKenn ) == COMPARE_EQUAL ) + { + bFound = TRUE; + aResult = GetMethodName( nNumber ); + } + if ( aType.CompareTo(RcKenn ) == COMPARE_EQUAL ) + { + bFound = TRUE; + if ( !pRCommands ) // Ist static, wird also nur einmal geladen + ReadFlatArray( arR_Cmds, pRCommands ); + + USHORT nElement; + if ( pRCommands ) + { + for ( nElement = 0 ; nElement < pRCommands->Count() ; nElement++ ) + if ( pRCommands->GetObject(nElement)->pData->aUId.Matches( nNumber ) ) + { + aResult = pRCommands->GetObject(nElement)->pData->Kurzname; + nElement = pRCommands->Count(); + } + } + } + if ( aType.CompareTo(TypeKenn ) == COMPARE_EQUAL ) + { + bFound = TRUE; + if ( !pRTypes ) // Ist static, wird also nur einmal geladen + ReadFlatArray( arRes_Type, pRTypes ); + + USHORT nElement; + if ( pRTypes ) + { + for ( nElement = 0 ; nElement < pRTypes->Count() ; nElement++ ) + if ( pRTypes->GetObject(nElement)->pData->aUId.Matches( nNumber ) ) + { + aResult = pRTypes->GetObject(nElement)->pData->Kurzname; + nElement = pRTypes->Count(); + } + } + } + if ( aType.CompareTo(SlotKenn ) == COMPARE_EQUAL ) + { + aResult = pShortNames->GetName(SmartId(nNumber)); + bFound = TRUE; + } + if ( aType.CompareTo(TabKenn ) == COMPARE_EQUAL ) + { + if ( nNumber > nStart ) + aResult.Fill( (USHORT)nNumber - nStart +1 ); + else + aResult = CUniString(" "); + bFound = 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, 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, SmartId() ); + + 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 ) + { + USHORT 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(), TRUE ); + parent->StartListening( pMethodVar->GetBroadcaster(), 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; + } + + + USHORT nElement; + ControlDef WhatName(aStr,SmartId()); + if (pClasses && pClasses->Seek_Entry(&WhatName,&nElement)) + { + pMethodVar->SetName(aStr); + ULONG nUId = 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( 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..260d54c0cef0 --- /dev/null +++ b/automation/source/testtool/objtest.hxx @@ -0,0 +1,406 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: objtest.hxx,v $ + * $Revision: 1.16 $ + * + * 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 <vcl/smartid.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; + SmartId aUId; +}; + +DBG_NAMEEX( ControlItem ) +DBG_NAMEEX( ControlDef ) +class ControlItem +{ +private: + void InitData() { pData = new ControlData; } +public: + ControlData *pData; + + ControlItem( const char *Name, SmartId aUIdP ); + ControlItem( const String &Name, SmartId aUIdP ); +// ControlItem( const String &Name, const String &URL, const URLType aType ); +// ControlItem( const String &Name, const String &URL, const ULONG nUId ); +// ControlItem( const char *Name, const String &URL, const ULONG nUId ); + ControlItem( ControlData *pDataP ); + virtual ~ControlItem() { +DBG_DTOR(ControlItem,0); + delete pData; + } + virtual BOOL operator < (const ControlItem &rPar)=0; + virtual BOOL operator == (const ControlItem &rPar)=0; +// void Write( SvStream &aStream ); +}; + +SV_DECL_PTRARR_SORT_DEL(CNames, ControlItem*, 50, 10) + +#define MK_SON_ACCESS( ClassName )\ + BOOL SonInsert( const ClassName *pNewEntry ) { return pSons->C40_PTR_INSERT( ControlItem, (ControlItem*&)pNewEntry ); }\ + BOOL SonSeek_Entry( const ClassName *pSearchEntry, USHORT *nRes = NULL) { return pSons->Seek_Entry( pSearchEntry, nRes ); }\ + ClassName* SonGetObject( USHORT 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 ); + + USHORT 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, SmartId aUIdP ) + : ControlItem( Name, aUIdP ) {} + ControlItemSon(const String &Name, SmartId aUIdP ); +// ControlItemSon(const String &Name, const String &URL, const URLType aType ); +// ControlItemSon(const String &Name, const String &URL, const ULONG nUId ); +// ControlItemSon(const char *Name, const String &URL, const ULONG nUId ); +// void Write( SvStream &aStream ); +}; + +class ControlDef : public ControlItemSon +{ +public: + ControlDef(const char *Name, SmartId aUIdP ) + : ControlItemSon( Name, aUIdP ) {DBG_CTOR(ControlDef,0);} + ControlDef(const String &Name, SmartId aUIdP ); +// ControlDef(const String &Name, const String &URL, const URLType aType ); + ControlDef(const String &aOldName, const String &aNewName, ControlDef *pOriginal, BOOL bWithSons = FALSE ); + ~ControlDef() {DBG_DTOR(ControlDef,0);} + virtual BOOL operator < (const ControlItem &rPar); + virtual BOOL operator == (const ControlItem &rPar); + void Write( SvStream &aStream ); + MK_SON_ACCESS( ControlDef ) +}; + +class ControlItemUId : public ControlItem +{ +public: + ControlItemUId(String Name, SmartId aUIdP) + : ControlItem( Name, aUIdP){} + virtual BOOL operator < (const ControlItem &rPar); + virtual BOOL operator == (const ControlItem &rPar); +}; + +class ControlItemUIdSon : public ControlItemUId, public ControlSon +{ +public: + ControlItemUIdSon(String Name, SmartId aUIdP) : ControlItemUId( Name, aUIdP) {} + MK_SON_ACCESS( ControlItemUId ) +}; + +class ReverseName : public ControlItemUId +{ +public: + ULONG LastSequence; + + ReverseName(String Name, SmartId aUIdP, ULONG nSeq) : ControlItemUId( Name, aUIdP), LastSequence(nSeq) {} +}; + +class CRevNames: public CNames +{ +public: + void Insert( String aName, SmartId aUId, ULONG nSeq ); + String GetName( SmartId aUId ); + void Invalidate ( ULONG nSeq ); +}; + + +class SbxTransportMethod: public SbxMethod +{ +public: + SbxTransportMethod( SbxDataType ); + 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 + ULONG LocalStarttime; + USHORT nNumBorders; + ULONG naValBorders[4]; + ULONG naNumEntries[5]; + ULONG naRemoteTime[5]; + ULONG naLocalTime[5]; + + ULONG nMinRemoteCommandDelay; + ULONG nMaxRemoteCommandDelay; + BOOL bDoRemoteCommandDelay; + + BOOL bLnaguageExtensionLoaded; // Wurde über 'use' was geladen? Für syntax highlighting + SfxBroadcaster *pTTSfxBroadcaster; + + ULONG nErrorCount; + ULONG nWarningCount; + ULONG nQAErrorCount; + ULONG nIncludeFileWarningCount; + + SbxDimArrayRef xErrorList; + SbxDimArrayRef xWarningList; + SbxDimArrayRef xQAErrorList; + SbxDimArrayRef xIncludeFileWarningList; + + BOOL bIsStart; // set tu TRUE while command Start is initiating the communication + + MyBasic* pMyBasic; + + String aTestCaseName; // holds name of current TestCase + String aTestCaseFileName; // holds FileName of current TestCase + USHORT nTestCaseLineNr; // holds Line of current TestCase + + BOOL bEnableQaErrors; // include QA errors in report + BOOL bDebugFindNoErrors; // suppress generating errors when find of variables is called for variable viewing purposes + + 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( 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..742013154b97 --- /dev/null +++ b/automation/source/testtool/registry_win.cxx @@ -0,0 +1,92 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: registry_win.cxx,v $ + * $Revision: 1.6 $ + * + * 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..c10d96c78260 --- /dev/null +++ b/automation/source/testtool/registry_win.hxx @@ -0,0 +1,34 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: registry_win.hxx,v $ + * $Revision: 1.4 $ + * + * 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..f5e4ff124fcd --- /dev/null +++ b/automation/source/testtool/sysdir_win.cxx @@ -0,0 +1,108 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: sysdir_win.cxx,v $ + * $Revision: 1.8 $ + * + * 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..df84a14800d9 --- /dev/null +++ b/automation/source/testtool/sysdir_win.hxx @@ -0,0 +1,34 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: sysdir_win.hxx,v $ + * $Revision: 1.4 $ + * + * 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..3ac135829f6d --- /dev/null +++ b/automation/source/testtool/tcommuni.cxx @@ -0,0 +1,203 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tcommuni.cxx,v $ + * $Revision: 1.11 $ + * + * 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( TRUE ) +, aAppPath() +, aAppParams() +, pProcess( NULL ) +{ +} + + +BOOL CommunicationManagerClientViaSocketTT::StartCommunication() +{ + bApplicationStarted = FALSE; + return CommunicationManagerClientViaSocket::StartCommunication( ByteString( GetHostConfig(), RTL_TEXTENCODING_UTF8 ), GetTTPortConfig() ); +} + + +BOOL CommunicationManagerClientViaSocketTT::StartCommunication( String aApp, String aParams, Environment *pChildEnv ) +{ + aAppPath = aApp; + aAppParams = aParams; + aAppEnv = (*pChildEnv); + return StartCommunication(); +} + + +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 ); + + BOOL bSucc = pProcess->Start(); + bApplicationStarted = TRUE; + + if ( bSucc ) + { + aFirstRetryCall = Time() + Time( 0, 1 ); // Max eine Minute Zeit + for ( int i = 10 ; i-- ; ) + GetpApp()->Reschedule(); + } + return bSucc; + } + return FALSE; + } + else + { + if ( aFirstRetryCall > Time() ) + { + Timer aWait; + aWait.SetTimeout( 500 ); // Max 500 mSec + aWait.Start(); + while ( aWait.IsActive() ) + GetpApp()->Yield(); + return TRUE; + } + else + return FALSE; + } +} + +BOOL CommunicationManagerClientViaSocketTT::KillApplication() +{ + if ( pProcess ) + return pProcess->Terminate(); + return 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 ( USHORT 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 ); +} + + +ULONG GetTTPortConfig() +{ + String aPortToTalk; + + for ( USHORT 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 (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 (ULONG)abPortToTalk.ToInt64(); +} + + +ULONG GetUnoPortConfig() +{ + String aPortToTalk; + + for ( USHORT 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 (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 (ULONG)abPortToTalk.ToInt64(); +} diff --git a/automation/source/testtool/tcommuni.hxx b/automation/source/testtool/tcommuni.hxx new file mode 100644 index 000000000000..4863f1fd428c --- /dev/null +++ b/automation/source/testtool/tcommuni.hxx @@ -0,0 +1,70 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tcommuni.hxx,v $ + * $Revision: 1.10 $ + * + * 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 <svtools/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 BOOL StartCommunication(); + virtual BOOL StartCommunication( String aApp, String aParams, Environment *pChildEnv ); + + BOOL KillApplication(); + +protected: + virtual BOOL RetryConnect(); + BOOL bApplicationStarted; + Time aFirstRetryCall; + String aAppPath; + String aAppParams; + Environment aAppEnv; + Process *pProcess; +}; + + +String GetHostConfig(); +ULONG GetTTPortConfig(); +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= |