2002-11-18 14:54:26 +00:00
/*************************************************************************
*
2008-04-11 09:12:26 +00:00
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER .
2002-11-18 14:54:26 +00:00
*
2008-04-11 09:12:26 +00:00
* Copyright 2008 by Sun Microsystems , Inc .
2002-11-18 14:54:26 +00:00
*
2008-04-11 09:12:26 +00:00
* OpenOffice . org - a multi - platform office productivity suite
2002-11-18 14:54:26 +00:00
*
2008-04-11 09:12:26 +00:00
* $ RCSfile : objtest . cxx , v $
2008-08-19 11:46:53 +00:00
* $ Revision : 1.40 $
2002-11-18 14:54:26 +00:00
*
2008-04-11 09:12:26 +00:00
* This file is part of OpenOffice . org .
2002-11-18 14:54:26 +00:00
*
2008-04-11 09:12:26 +00:00
* 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 .
2002-11-18 14:54:26 +00:00
*
2008-04-11 09:12:26 +00:00
* 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 ) .
2002-11-18 14:54:26 +00:00
*
2008-04-11 09:12:26 +00:00
* 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 .
2002-11-18 14:54:26 +00:00
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2006-09-16 23:38:58 +00:00
// MARKER(update_precomp.py): autogen include statement, do not remove
# include "precompiled_automation.hxx"
2002-11-18 14:54:26 +00:00
/*#include <com/sun/star/devtools/XIServerProxy.hpp>
# include <com/sun/star/devtools/XInformationClient.hpp>
using namespace com : : sun : : star : : devtools ;
*/
2007-09-20 13:45:22 +00:00
# ifdef OS2
# define INCL_DOS
//#include <vcl/sysdep.hxx>
# ifndef _SVPM_H
# include <svpm.h>
# endif
# endif
2002-11-18 14:54:26 +00:00
2004-01-20 15:54:38 +00:00
# include "sysdir_win.hxx"
2004-06-17 10:41:09 +00:00
# include "registry_win.hxx"
2007-04-26 08:40:15 +00:00
# include "sttresid.hxx"
2002-11-18 14:54:26 +00:00
# include <osl/file.hxx>
# ifndef _MSGBOX_HXX //autogen
# include <vcl/msgbox.hxx>
# endif
# ifndef _SOUND_HXX //autogen
# include <vcl/sound.hxx>
# endif
2004-01-06 16:08:52 +00:00
# include <tools/config.hxx>
2002-11-18 14:54:26 +00:00
# ifndef _APP_HXX //autogen
# include <vcl/svapp.hxx>
# endif
# include <svtools/stringtransfer.hxx>
# include <svtools/brdcst.hxx>
2004-01-19 16:52:32 +00:00
//#ifndef _SBXCLASS_HXX //autogen
2005-04-13 08:55:12 +00:00
# include <basic/sbx.hxx>
2004-01-19 16:52:32 +00:00
//#endif
2002-11-18 14:54:26 +00:00
# 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>
2004-06-17 10:41:09 +00:00
# ifdef UNX
# include <unistd.h> // readlink
# include <errno.h>
# endif
2002-11-18 14:54:26 +00:00
# include <basic/sbuno.hxx>
//#include <basic/basrid.hxx>
# include <basic/basicrt.hxx>
# ifndef _BASIC_TTRESHLP_HXX
# include <basic/ttstrhlp.hxx>
# endif
# include "tcommuni.hxx"
2005-06-21 18:08:21 +00:00
# include "comm_bas.hxx"
2002-11-18 14:54:26 +00:00
# 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 )
2005-06-21 18:08:21 +00:00
static CommunicationFactory aComManFac ;
2002-11-18 14:54:26 +00:00
# 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 ;
2007-06-19 13:37:13 +00:00
CErrors * TestToolObj : : pFehlerListe = NULL ; // Hier werden die Fehler des Testtools gespeichert
2002-11-18 14:54:26 +00:00
DBG_NAME ( ControlItem )
DBG_NAME ( ControlDef )
2004-07-06 11:08:11 +00:00
ControlItem : : ControlItem ( const sal_Char * Name , SmartId aUIdP )
2002-11-18 14:54:26 +00:00
{
DBG_CTOR ( ControlItem , 0 ) ;
InitData ( ) ;
pData - > Kurzname . AssignAscii ( Name ) ;
pData - > aUId = aUIdP ;
}
2004-07-06 11:08:11 +00:00
ControlItem : : ControlItem ( const String & Name , SmartId aUIdP )
2002-11-18 14:54:26 +00:00
{
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 ;
}
}
2004-07-06 11:08:11 +00:00
ControlItemSon : : ControlItemSon ( const String & Name , SmartId aUIdP )
2002-11-18 14:54:26 +00:00
: 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 ) ;
2004-09-09 16:24:31 +00:00
aStream < < ( ( USHORT ) pData - > aUId . HasNumeric ( ) ) ;
if ( pData - > aUId . HasString ( ) )
2004-07-06 11:08:11 +00:00
aStream . WriteByteString ( pData - > aUId . GetStr ( ) , RTL_TEXTENCODING_UTF8 ) ;
2002-11-18 14:54:26 +00:00
else
2006-04-19 13:00:00 +00:00
aStream < < static_cast < comm_ULONG > ( pData - > aUId . GetNum ( ) ) ; //GetNum() ULONG != comm_ULONG on 64bit
2002-11-18 14:54:26 +00:00
if ( pSons )
2006-06-19 23:27:12 +00:00
for ( USHORT i = 0 ; pSons - > Count ( ) > i ; i + + )
2002-11-18 14:54:26 +00:00
( ( ControlDef * ) ( * pSons ) [ i ] ) - > Write ( aStream ) ;
}
2004-07-06 11:08:11 +00:00
ControlDef : : ControlDef ( const String & Name , SmartId aUIdP )
2002-11-18 14:54:26 +00:00
: 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 * )
2004-07-06 11:08:11 +00:00
void CRevNames : : Insert ( String aName , SmartId aUId , ULONG nSeq )
2002-11-18 14:54:26 +00:00
{
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 ;
}
}
2004-07-06 11:08:11 +00:00
String CRevNames : : GetName ( SmartId aUId )
2002-11-18 14:54:26 +00:00
{
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
{
2004-09-09 16:24:31 +00:00
if ( aUId . Matches ( UID_ACTIVE ) )
2002-11-18 14:54:26 +00:00
return CUniString ( " Active " ) ;
else
2004-08-02 14:49:26 +00:00
return GEN_RES_STR1 ( S_NAME_NOT_THERE , aUId . GetText ( ) ) ;
2002-11-18 14:54:26 +00:00
}
}
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 )
2006-06-19 23:27:12 +00:00
, bUseIPC ( FALSE )
2002-11-18 14:54:26 +00:00
, bReturnOK ( TRUE )
, nSequence ( KEEP_SEQUENCES )
, ProgPath ( )
2006-06-19 23:27:12 +00:00
, 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 )
2002-11-18 14:54:26 +00:00
, aDialogHandlerName ( )
2006-06-19 23:27:12 +00:00
, nWindowHandlerCallLevel ( 0 )
, nIdleCount ( 0 )
2002-11-18 14:54:26 +00:00
{
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 )
2006-06-19 23:27:12 +00:00
, bUseIPC ( TRUE )
2002-11-18 14:54:26 +00:00
, bReturnOK ( TRUE )
, nSequence ( KEEP_SEQUENCES )
, ProgPath ( )
2006-06-19 23:27:12 +00:00
, 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 )
2002-11-18 14:54:26 +00:00
, aDialogHandlerName ( )
2006-06-19 23:27:12 +00:00
, nWindowHandlerCallLevel ( 0 )
, nIdleCount ( 0 )
2002-11-18 14:54:26 +00:00
{
pImpl = new ImplTestToolObj ;
pImpl - > ProgParam = String ( ) ;
pImpl - > bIsStart = FALSE ;
pImpl - > pMyBasic = pBas ;
LoadIniFile ( ) ;
InitTestToolObj ( ) ;
pCommunicationManager = new CommunicationManagerClientViaSocketTT ( ) ;
pCommunicationManager - > SetDataReceivedHdl ( LINK ( this , TestToolObj , ReturnResultsLink ) ) ;
}
2007-04-26 08:40:15 +00:00
void TestToolObj : : LoadIniFile ( ) // Laden der IniEinstellungen, die durch den ConfigDialog ge<67> ndert werden k<> nnen
2002-11-18 14:54:26 +00:00
{
# define GETSET(aVar, KeyName, Dafault) \
{ \
ByteString __ # # aVar # # __ ; \
2003-03-18 15:03:50 +00:00
__ # # aVar # # __ = aConf . ReadKey ( KeyName ) ; \
if ( ! __ # # aVar # # __ . Len ( ) ) \
2002-11-18 14:54:26 +00:00
{ \
__ # # aVar # # __ = Dafault ; \
aConf . WriteKey ( KeyName , __ # # aVar # # __ ) ; \
} \
aVar = UniString ( __ # # aVar # # __ , RTL_TEXTENCODING_UTF8 ) ; \
}
2003-03-18 15:03:50 +00:00
# define NEWOLD( NewKey, OldKey ) \
{ \
ByteString aValue ; \
if ( ( ( aValue = aConf . ReadKey ( OldKey ) ) . Len ( ) ) & & ! aConf . ReadKey ( NewKey ) . Len ( ) ) \
aConf . WriteKey ( NewKey , aValue ) ; \
}
2002-11-18 14:54:26 +00:00
Config aConf ( Config : : GetConfigName ( Config : : GetDefDirectory ( ) , CUniString ( " testtool " ) ) ) ;
2003-03-18 15:03:50 +00:00
aConf . SetGroup ( " Misc " ) ;
ByteString aCurrentProfile = aConf . ReadKey ( " CurrentProfile " , " Path " ) ;
aConf . SetGroup ( aCurrentProfile ) ;
2002-11-18 14:54:26 +00:00
2003-03-18 15:03:50 +00:00
NEWOLD ( " BaseDir " , " Basisverzeichnis " )
2002-11-18 14:54:26 +00:00
String aFB ;
2004-06-17 10:41:09 +00:00
GETSET ( aFB , " BaseDir " , " " ) ;
2002-11-18 14:54:26 +00:00
pImpl - > aFileBase = DirEntry ( aFB ) ;
2003-03-18 15:03:50 +00:00
// remove old keys
2002-11-18 14:54:26 +00:00
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 " ) ;
}
2003-03-18 15:03:50 +00:00
NEWOLD ( " LogBaseDir " , " LogBasisverzeichnis " )
2002-11-18 14:54:26 +00:00
String aLFB ;
2003-03-18 15:03:50 +00:00
GETSET ( aLFB , " LogBaseDir " , ByteString ( aFB , RTL_TEXTENCODING_UTF8 ) ) ;
2002-11-18 14:54:26 +00:00
pImpl - > aLogFileBase = DirEntry ( aLFB ) ;
2003-03-18 15:03:50 +00:00
NEWOLD ( " HIDDir " , " HIDVerzeichnis " )
2002-11-18 14:54:26 +00:00
String aHID ;
2004-06-17 10:41:09 +00:00
GETSET ( aHID , " HIDDir " , " " ) ;
2002-11-18 14:54:26 +00:00
pImpl - > aHIDDir = DirEntry ( aHID ) ;
aConf . SetGroup ( " Misc " ) ;
String aST ;
GETSET ( aST , " ServerTimeout " , ByteString : : CreateFromInt64 ( Time ( 0 , 0 , 45 ) . GetTime ( ) ) ) ; // 45 Sekunden Initial
2004-01-20 15:54:38 +00:00
pImpl - > aServerTimeout = Time ( ULONG ( aST . ToInt64 ( ) ) ) ;
2002-11-18 14:54:26 +00:00
2003-03-18 15:03:50 +00:00
String aSOSE ;
aCurrentProfile = aConf . ReadKey ( " CurrentProfile " , " Misc " ) ;
aConf . SetGroup ( aCurrentProfile ) ;
2004-06-17 10:41:09 +00:00
GETSET ( aSOSE , " StopOnSyntaxError " , " 0 " ) ;
2003-03-18 15:03:50 +00:00
pImpl - > bStopOnSyntaxError = aSOSE . EqualsAscii ( " 1 " ) ;
2004-06-17 10:41:09 +00:00
aConf . SetGroup ( " GUI Platform " ) ;
String aGP ;
ByteString abGP ;
# ifdef WNT
abGP . Append ( " 501 " ) ; // WinXP
# elif defined SOLARIS && defined SPARC
abGP . Append ( " 01 " ) ; // Solaris SPARC
2006-05-05 07:10:46 +00:00
# elif defined SCO
abGP . Append ( " 02 " ) ; // SCO UNIX
# elif defined LINUX && defined INTEL
abGP . Append ( " 03 " ) ; // Linux
# elif defined AIX
abGP . Append ( " 04 " ) ;
2004-06-17 10:41:09 +00:00
# elif defined SOLARIS && defined INTEL
abGP . Append ( " 05 " ) ; // Solaris x86
2006-05-05 07:10:46 +00:00
# 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 " ) ;
2006-05-15 08:02:21 +00:00
# elif defined LINUX && defined X86_64
abGP . Append ( " 15 " ) ; // Linux x86-64
2006-11-06 13:46:02 +00:00
# elif defined LINUX && defined SPARC
abGP . Append ( " 16 " ) ; // Linux SPARC
2007-05-11 10:32:42 +00:00
# elif defined OS2
abGP . Append ( " 17 " ) ;
2007-11-02 14:19:12 +00:00
# elif defined LINUX && defined MIPS
abGP . Append ( " 18 " ) ; // Linux MIPS
2007-11-26 16:59:36 +00:00
# elif defined LINUX && defined ARM
abGP . Append ( " 19 " ) ; // Linux ARM
2008-02-27 08:44:28 +00:00
# elif defined LINUX && defined IA64
abGP . Append ( " 20 " ) ; // Linux ia64
2008-03-18 15:04:19 +00:00
# elif defined LINUX && defined S390
abGP . Append ( " 21 " ) ; // Linux S390
2006-05-05 07:10:46 +00:00
# else
# error ("unknown platform. please request an ID for your platform on qa / dev")
2004-06-17 10:41:09 +00:00
# endif
GETSET ( aGP , " Current " , abGP ) ;
2002-11-18 14:54:26 +00:00
2007-05-11 10:32:42 +00:00
// #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 ( ) ;
2002-11-18 14:54:26 +00:00
}
2007-05-11 10:32:42 +00:00
# define MAKE_TT_KEYWORD( cName, aType, aResultType, nID ) \
{ \
SbxVariableRef pMeth ; \
pMeth = Make ( CUniString ( cName ) , aType , aResultType ) ; \
pMeth - > SetUserData ( nID ) ; \
}
2002-11-18 14:54:26 +00:00
2007-05-11 10:32:42 +00:00
// SetUserData mu<6D> 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 ) ; \
2002-11-18 14:54:26 +00:00
}
# define RTLNAME "@SBRTL" // copied from basic/source/classes/sb.cxx
void TestToolObj : : InitTestToolObj ( )
{
2007-04-26 08:40:15 +00:00
pImpl - > nNumBorders = 0 ; // F<> r Profiling mit k<> stchen
2002-11-18 14:54:26 +00:00
pImpl - > nMinRemoteCommandDelay = 0 ;
pImpl - > nMaxRemoteCommandDelay = 0 ;
pImpl - > bDoRemoteCommandDelay = FALSE ;
pImpl - > bLnaguageExtensionLoaded = FALSE ;
pImpl - > pTTSfxBroadcaster = NULL ;
pImpl - > nErrorCount = 0 ;
pImpl - > nWarningCount = 0 ;
2004-08-02 14:49:26 +00:00
pImpl - > nQAErrorCount = 0 ;
2002-11-18 14:54:26 +00:00
pImpl - > nIncludeFileWarningCount = 0 ;
2004-01-19 16:52:32 +00:00
pImpl - > xErrorList = new SbxDimArray ( SbxSTRING ) ;
pImpl - > xWarningList = new SbxDimArray ( SbxSTRING ) ;
2004-08-02 14:49:26 +00:00
pImpl - > xQAErrorList = new SbxDimArray ( SbxSTRING ) ;
2004-01-19 16:52:32 +00:00
pImpl - > xIncludeFileWarningList = new SbxDimArray ( SbxSTRING ) ;
2002-11-18 14:54:26 +00:00
pImpl - > nTestCaseLineNr = 0 ;
2003-03-18 15:03:50 +00:00
pImpl - > bEnableQaErrors = TRUE ;
pImpl - > bDebugFindNoErrors = FALSE ;
2004-06-17 10:41:09 +00:00
pImpl - > pChildEnv = new Environment ;
2007-06-19 13:37:13 +00:00
if ( ! pFehlerListe )
pFehlerListe = new CErrors ; // Vor allem anderen. Wer weiss, wer alles einen Fehler ausl<73> st.
2002-11-18 14:54:26 +00:00
In = new CmdStream ( ) ;
pShortNames = new CRevNames ;
2007-05-11 10:32:42 +00:00
pImpl - > pHttpRequest = NULL ;
2002-11-18 14:54:26 +00:00
// 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
{
2008-11-10 15:06:12 +00:00
DBG_ERROR ( " Testtool: Could not replace Wait method " ) ;
2002-11-18 14:54:26 +00:00
}
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 ) ;
2003-03-18 15:03:50 +00:00
MAKE_TT_KEYWORD ( " QAErrorLog " , SbxCLASS_METHOD , SbxNULL , ID_QAErrorLog ) ;
MAKE_TT_KEYWORD ( " EnableQaErrors " , SbxCLASS_PROPERTY , SbxBOOL , ID_EnableQaErrors ) ;
2002-11-18 14:54:26 +00:00
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 ) ;
2003-03-18 15:03:50 +00:00
MAKE_TT_KEYWORD ( " StopOnSyntaxError " , SbxCLASS_PROPERTY , SbxBOOL , ID_StopOnSyntaxError ) ;
2002-11-18 14:54:26 +00:00
/* Dialog Handler werden gebraucht, wenn im internen Testtool ein Dialog
hochgerissen wird . Nach versenden der Remote - Kommandos wird IdleHandler aktiviert .
2007-04-26 08:40:15 +00:00
Er testet , ob das Reschedule zum WaitForAnswer zur <EFBFBD> ckkehrt . Bleibt das aus , so
wird erst der RemoteHandler zur <EFBFBD> ckgesetzt und dann die Handler - Sub im Basic
gerufen . ( Entkoppelt <EFBFBD> ber PostUserEvent . )
2002-11-18 14:54:26 +00:00
2007-04-26 08:40:15 +00:00
In returndaten_verarbeiten wird flag f <EFBFBD> r ausf <EFBFBD> hrung des n <EFBFBD> chsten remote - befehls
r <EFBFBD> ckgesetzt . Der Handler wird damit auch entwertet . Er gilt also nur f <EFBFBD> r den
n <EFBFBD> chsten Remotebefehl .
2002-11-18 14:54:26 +00:00
*/
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 ) ;
2004-01-20 15:54:38 +00:00
MAKE_TT_KEYWORD ( " GetCommonApplicationPath " , SbxCLASS_METHOD , SbxSTRING , ID_GetCommonApplicationPath ) ;
2002-11-18 14:54:26 +00:00
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 ) ;
2004-08-02 14:49:26 +00:00
MAKE_TT_KEYWORD ( " GetQAErrorCount " , SbxCLASS_METHOD , SbxULONG , ID_GetQAErrorCount ) ;
2002-11-18 14:54:26 +00:00
MAKE_TT_KEYWORD ( " GetUseFileWarningCount " , SbxCLASS_METHOD , SbxULONG , ID_GetUseFileWarningCount ) ;
2004-01-19 16:52:32 +00:00
MAKE_TT_KEYWORD ( " GetErrorList " , SbxCLASS_METHOD , SbxOBJECT , ID_GetErrorList ) ;
MAKE_TT_KEYWORD ( " GetWarningList " , SbxCLASS_METHOD , SbxOBJECT , ID_GetWarningList ) ;
2004-08-02 14:49:26 +00:00
MAKE_TT_KEYWORD ( " GetQAErrorList " , SbxCLASS_METHOD , SbxOBJECT , ID_GetQAErrorList ) ;
2004-01-19 16:52:32 +00:00
MAKE_TT_KEYWORD ( " GetUseFileWarningList " , SbxCLASS_METHOD , SbxOBJECT , ID_GetUseFileWarningList ) ;
2002-11-18 14:54:26 +00:00
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 ) ;
2004-06-17 10:41:09 +00:00
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 ) ;
2004-09-20 11:25:43 +00:00
MAKE_TT_KEYWORD ( " KillApp " , SbxCLASS_METHOD , SbxNULL , ID_KillApp ) ;
2007-05-11 10:32:42 +00:00
MAKE_TT_KEYWORD ( " HTTPSend " , SbxCLASS_METHOD , SbxUSHORT , ID_HTTPSend ) ;
MAKE_TT_KEYWORD ( " HTTPSetProxy " , SbxCLASS_METHOD , SbxNULL , ID_HTTPSetProxy ) ;
2002-11-18 14:54:26 +00:00
// 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 + + )
2007-05-11 10:32:42 +00:00
{
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 ) ;
}
2002-11-18 14:54:26 +00:00
2007-04-26 08:40:15 +00:00
// Konstanten f<> r SetControlType
2002-11-18 14:54:26 +00:00
MAKE_USHORT_CONSTANT ( " CTBrowseBox " , CONST_CTBrowseBox ) ;
2004-06-17 10:41:09 +00:00
MAKE_USHORT_CONSTANT ( " CTValueSet " , CONST_CTValueSet ) ;
2002-11-18 14:54:26 +00:00
2007-04-26 08:40:15 +00:00
// Konstanten f<> r das Alignment des gesuchten Splitters
2002-11-18 14:54:26 +00:00
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 ) ;
2007-05-11 10:32:42 +00:00
/// 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 ) ;
2002-11-18 14:54:26 +00:00
pImpl - > pControlsObj = new Controls ( CUniString ( " GetNextCloseWindow " ) ) ;
2006-04-19 13:15:58 +00:00
pImpl - > pControlsObj - > SetType ( SbxVARIANT ) ;
2007-06-19 13:37:13 +00:00
Insert ( pImpl - > pControlsObj ) ;
2002-11-18 14:54:26 +00:00
pImpl - > pControlsObj - > SetUserData ( ID_GetNextCloseWindow ) ;
2006-04-19 13:15:58 +00:00
pImpl - > pControlsObj - > ChangeListener ( this ) ;
2002-11-18 14:54:26 +00:00
for ( i = 0 ; i < VAR_POOL_SIZE ; i + + )
{
/* pMyVar = new SbxObject( "Dummy" );
2006-04-19 13:15:58 +00:00
pMyVar - > SetType ( SbxVARIANT ) ; */
2002-11-18 14:54:26 +00:00
// pMyVar = new SbxMethod( "Dummy", SbxVARIANT );
pImpl - > pMyVars [ i ] = new SbxTransportMethod ( SbxVARIANT ) ;
2006-04-19 13:15:58 +00:00
pImpl - > pMyVars [ i ] - > SetName ( CUniString ( " VarDummy " ) . Append ( String : : CreateFromInt32 ( i ) ) ) ;
2002-11-18 14:54:26 +00:00
Insert ( pImpl - > pMyVars [ i ] ) ;
// StartListening( pMyVars[i]->GetBroadcaster(), TRUE );
}
2006-06-19 23:27:12 +00:00
m_pControls = new CNames ( ) ;
m_pSIds = new CNames ( ) ;
m_pNameKontext = m_pControls ;
2002-11-18 14:54:26 +00:00
nMyVar = 0 ;
2005-06-21 18:08:21 +00:00
pImpl - > pMyBasic - > AddFactory ( & aComManFac ) ;
2002-11-18 14:54:26 +00:00
// 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 ( )
{
2005-06-21 18:08:21 +00:00
pImpl - > pMyBasic - > RemoveFactory ( & aComManFac ) ;
2002-11-18 14:54:26 +00:00
EndListening ( ( ( StarBASIC * ) GetParent ( ) ) - > GetBroadcaster ( ) ) ;
pImpl - > pNextReturn . Clear ( ) ;
pImpl - > pControlsObj . Clear ( ) ;
for ( int i = 0 ; i < VAR_POOL_SIZE ; i + + )
{
pImpl - > pMyVars [ i ] . Clear ( ) ;
}
2006-06-19 23:27:12 +00:00
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 ;
2002-11-18 14:54:26 +00:00
if ( pFehlerListe )
{
delete pFehlerListe ;
pFehlerListe = NULL ; // da pFehlerListe static ist!!
}
if ( pCommunicationManager )
{
pCommunicationManager - > StopCommunication ( ) ;
delete pCommunicationManager ;
}
delete In ;
if ( pImpl - > pTTSfxBroadcaster )
delete pImpl - > pTTSfxBroadcaster ;
2007-05-11 10:32:42 +00:00
delete pImpl - > pChildEnv ;
pImpl - > xErrorList . Clear ( ) ;
pImpl - > xWarningList . Clear ( ) ;
pImpl - > xQAErrorList . Clear ( ) ;
pImpl - > xIncludeFileWarningList . Clear ( ) ;
2002-11-18 14:54:26 +00:00
delete pImpl ;
2004-06-17 10:41:09 +00:00
2007-05-11 10:32:42 +00:00
delete pShortNames ;
2002-11-18 14:54:26 +00:00
}
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 ;
2006-06-19 23:27:12 +00:00
String aLine , aShortname , aLongname ;
2004-07-06 11:08:11 +00:00
SmartId aUId ;
2002-11-18 14:54:26 +00:00
xub_StrLen nLineNr ;
USHORT nElement ;
ControlDef * pNewDef , * pNewDef2 ;
ControlDef * pFatherDef = NULL ;
nLineNr = 0 ; // Wir sind ja noch vor der Datei
if ( ! pUIds )
{
2006-06-19 23:27:12 +00:00
String aFileName = ( pImpl - > aHIDDir + DirEntry ( CUniString ( " hid.lst " ) ) ) . GetFull ( ) ;
2002-11-18 14:54:26 +00:00
{
2007-04-26 08:40:15 +00:00
TTExecutionStatusHint aHint ( TT_EXECUTION_SHOW_ACTION , String ( SttResId ( S_READING_LONGNAMES ) ) , aFileName ) ;
2002-11-18 14:54:26 +00:00
GetTTBroadcaster ( ) . Broadcast ( aHint ) ;
}
2006-06-19 23:27:12 +00:00
ReadFlat ( aFileName , pUIds , TRUE ) ;
2002-11-18 14:54:26 +00:00
if ( ! pUIds )
return ;
2004-07-06 11:08:11 +00:00
pNewDef = new ControlDef ( " Active " , SmartId ( 0 ) ) ;
2002-11-18 14:54:26 +00:00
if ( ! pUIds - > C40_PTR_INSERT ( ControlItem , ( ControlItem * & ) pNewDef ) )
{
2004-01-19 16:52:32 +00:00
ADD_WARNING_LOG2 ( GEN_RES_STR1c ( S_DOUBLE_NAME , " Active " ) , Filename , nLineNr ) ;
2002-11-18 14:54:26 +00:00
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 )
{
2007-04-26 08:40:15 +00:00
TTExecutionStatusHint aHint ( TT_EXECUTION_SHOW_ACTION , String ( SttResId ( S_READING_SLOT_IDS ) ) , Filename ) ;
2002-11-18 14:54:26 +00:00
GetTTBroadcaster ( ) . Broadcast ( aHint ) ;
}
else
{
2007-04-26 08:40:15 +00:00
TTExecutionStatusHint aHint ( TT_EXECUTION_SHOW_ACTION , String ( SttResId ( S_READING_CONTROLS ) ) , Filename ) ;
2002-11-18 14:54:26 +00:00
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 ;
}
2006-06-19 23:27:12 +00:00
aShortname = aLine . GetToken ( 0 , cMyDelim ) ;
2002-11-18 14:54:26 +00:00
aLongname = aLine . GetToken ( 1 , cMyDelim ) ;
String aFirstAllowedExtra , aAllowed ;
aFirstAllowedExtra . AssignAscii ( " +* " ) ;
aAllowed . AssignAscii ( " _ " ) ;
xub_StrLen nIndex = 0 ;
BOOL bOK = TRUE ;
2006-06-19 23:27:12 +00:00
while ( bOK & & nIndex < aShortname . Len ( ) )
2002-11-18 14:54:26 +00:00
{
2006-06-19 23:27:12 +00:00
sal_Unicode aChar = aShortname . GetChar ( nIndex ) ;
2002-11-18 14:54:26 +00:00
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 )
{
2007-04-26 08:40:15 +00:00
ADD_WARNING_LOG2 ( CUniString ( " Zeile \" " ) . Append ( aLine ) . AppendAscii ( " \" enth<74> lt ung<6E> ltige Zeichen. " ) , Filename , nLineNr ) ;
2002-11-18 14:54:26 +00:00
continue ;
}
2004-07-06 11:08:11 +00:00
BOOL bUnoName = ( aLongname . Copy ( 0 , 5 ) . EqualsIgnoreCaseAscii ( " .uno: " )
| | aLongname . Copy ( 0 , 4 ) . EqualsIgnoreCaseAscii ( " http " )
2004-08-02 14:49:26 +00:00
| | aLongname . Copy ( 0 , 15 ) . EqualsIgnoreCaseAscii ( " private:factory " )
| | aLongname . Copy ( 0 , 8 ) . EqualsIgnoreCaseAscii ( " service: " )
| | aLongname . Copy ( 0 , 6 ) . EqualsIgnoreCaseAscii ( " macro: " )
2004-07-06 11:08:11 +00:00
| | aLongname . Copy ( 0 , 8 ) . EqualsIgnoreCaseAscii ( " .HelpId: " ) ) ;
2006-10-11 08:54:12 +00:00
// generic method to mark longnames as symbolic
if ( aLongname . Copy ( 0 , 4 ) . EqualsIgnoreCaseAscii ( " sym: " ) )
{
bUnoName = TRUE ;
aLongname . Erase ( 0 , 4 ) ;
}
2004-07-06 11:08:11 +00:00
BOOL bMozillaName = ( ! bIsFlat & & aLongname . Copy ( 0 , 4 ) . EqualsIgnoreCaseAscii ( " .moz " ) ) ;
2002-11-18 14:54:26 +00:00
2006-06-19 23:27:12 +00:00
if ( aShortname . GetChar ( 0 ) = = ' + ' ) // Kompletten Eintrag kopieren
2002-11-18 14:54:26 +00:00
{
2006-06-19 23:27:12 +00:00
aShortname . Erase ( 0 , 1 ) ;
2004-07-06 11:08:11 +00:00
ControlDef WhatName ( aLongname , SmartId ( ) ) ;
2002-11-18 14:54:26 +00:00
ControlDef * OldTree ;
if ( pNames - > Seek_Entry ( & WhatName , & nElement ) )
{
OldTree = ( ControlDef * ) pNames - > GetObject ( nElement ) ;
2006-06-19 23:27:12 +00:00
pNewDef = new ControlDef ( aLongname , aShortname , OldTree , TRUE ) ;
2002-11-18 14:54:26 +00:00
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
{
2006-06-19 23:27:12 +00:00
if ( aShortname . CompareIgnoreCaseToAscii ( " *Active " ) = = COMPARE_EQUAL )
2004-07-06 11:08:11 +00:00
aUId = SmartId ( UID_ACTIVE ) ;
else if ( ! bUnoName & & ! bMozillaName )
2002-11-18 14:54:26 +00:00
{ // Bestimmen der ID aus der Hid.Lst
2004-07-06 11:08:11 +00:00
ControlDef WhatName ( aLongname , SmartId ( ) ) ;
2002-11-18 14:54:26 +00:00
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
{
2004-07-06 11:08:11 +00:00
if ( bUnoName )
aUId = SmartId ( aLongname ) ;
2002-11-18 14:54:26 +00:00
else if ( bMozillaName )
2004-07-06 11:08:11 +00:00
aUId = SmartId ( aLongname ) ;
2002-11-18 14:54:26 +00:00
else
{
2008-11-10 15:06:12 +00:00
DBG_ERROR ( " Unknown URL schema " ) ;
2002-11-18 14:54:26 +00:00
}
}
2006-06-19 23:27:12 +00:00
if ( aShortname . GetChar ( 0 ) = = ' * ' | | bIsFlat ) // Globaler Kurzname (Dialogname oder SId)
2002-11-18 14:54:26 +00:00
{
if ( ! bIsFlat )
2006-06-19 23:27:12 +00:00
aShortname . Erase ( 0 , 1 ) ;
2002-11-18 14:54:26 +00:00
2006-06-19 23:27:12 +00:00
pNewDef = new ControlDef ( aShortname , aUId ) ;
2002-11-18 14:54:26 +00:00
if ( ! bIsFlat )
{
pNewDef - > Sons ( new CNames ( ) ) ;
2006-06-19 23:27:12 +00:00
pNewDef2 = new ControlDef ( aShortname , aUId ) ;
2002-11-18 14:54:26 +00:00
if ( ! pNewDef - > SonInsert ( pNewDef2 ) ) // Dialog in eigenen Namespace eintragen
{
delete pNewDef2 ;
2007-04-26 08:40:15 +00:00
DBG_ERROR ( " !!!! ACHTUNG !!!! Fehler beim einf<6E> gen in leere Liste! " ) ;
2002-11-18 14:54:26 +00:00
}
}
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
{
2006-06-19 23:27:12 +00:00
pNewDef = new ControlDef ( aShortname , aUId ) ;
2002-11-18 14:54:26 +00:00
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 ;
2006-06-19 23:27:12 +00:00
String aLine , aLongname ;
2004-07-06 11:08:11 +00:00
SmartId aUId ;
2002-11-18 14:54:26 +00:00
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 ;
}
2006-06-19 23:27:12 +00:00
aLongname = aLine . GetToken ( 0 , cMyDelim ) ;
2004-07-06 11:08:11 +00:00
aUId = SmartId ( ( ULONG ) aLine . GetToken ( 1 , cMyDelim ) . ToInt64 ( ) ) ;
2002-11-18 14:54:26 +00:00
if ( bSortByName )
2006-06-19 23:27:12 +00:00
pNewItem = new ControlDef ( aLongname , aUId ) ;
2002-11-18 14:54:26 +00:00
else
2006-06-19 23:27:12 +00:00
pNewItem = new ControlItemUId ( aLongname , aUId ) ;
2002-11-18 14:54:26 +00:00
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 )
{
2004-07-06 11:08:11 +00:00
SmartId aUId ( arWas [ nIndex ] . nUId ) ;
2002-11-18 14:54:26 +00:00
const ControlItem * pX = new ControlDef ( arWas [ nIndex ] . Kurzname , aUId ) ;
pNames - > C40_PTR_INSERT ( ControlItem , pX ) ;
nIndex + + ;
}
}
void TestToolObj : : WaitForAnswer ( )
{
if ( bUseIPC )
{
2003-06-10 10:30:10 +00:00
# ifdef DBG_UTILx
2002-11-18 14:54:26 +00:00
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 ) ;
}
2007-04-26 08:40:15 +00:00
if ( bWasRealWait & & aDialogHandlerName . Len ( ) > 0 ) // Damit das ganze auch im Testtool l<> uft
2002-11-18 14:54:26 +00:00
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 + + ;
}
}
2006-06-19 23:27:12 +00:00
IMPL_LINK ( TestToolObj , IdleHdl , Application * , EMPTYARG )
2002-11-18 14:54:26 +00:00
{
if ( ! bReturnOK )
nIdleCount + + ;
if ( nIdleCount > 10 ) // d.h. Schon 10 mal hier gewesen und noch keinmal im WaitForAnswer
{
2004-01-19 16:52:32 +00:00
GetpApp ( ) - > RemoveIdleHdl ( LINK ( this , TestToolObj , IdleHdl ) ) ;
2002-11-18 14:54:26 +00:00
GetpApp ( ) - > PostUserEvent ( LINK ( this , TestToolObj , CallDialogHandler ) ) ;
}
return 0 ;
}
2006-06-19 23:27:12 +00:00
IMPL_LINK ( TestToolObj , CallDialogHandler , Application * , EMPTYARG )
2002-11-18 14:54:26 +00:00
{
nWindowHandlerCallLevel + + ;
2006-06-19 23:27:12 +00:00
String aHandlerName ( aDialogHandlerName ) ;
2002-11-18 14:54:26 +00:00
aDialogHandlerName . Erase ( ) ;
2007-04-26 08:40:15 +00:00
ULONG nRememberSequence = nSequence ; // Da sich die Sequence im DialogHandler <20> ndert
2006-06-19 23:27:12 +00:00
( ( StarBASIC * ) GetParent ( ) ) - > Call ( aHandlerName ) ;
2002-11-18 14:54:26 +00:00
nSequence = nRememberSequence ;
2007-04-26 08:40:15 +00:00
// Die Sequenznummern werden dann zwar doppelt vergeben, aber wen k<> mmerts.
2002-11-18 14:54:26 +00:00
nWindowHandlerCallLevel - - ;
return 0 ;
}
void TestToolObj : : BeginBlock ( )
{
WaitForAnswer ( ) ;
if ( IsError ( ) )
return ;
2008-11-10 15:06:12 +00:00
DBG_ASSERT ( ! IsBlock , " BeginBlock innerhalb eines Blockes " ) ;
2002-11-18 14:54:26 +00:00
In - > Reset ( nSequence ) ;
IsBlock = TRUE ;
}
void TestToolObj : : SendViaSocket ( )
{
if ( ! pCommunicationManager )
{
2008-11-10 15:06:12 +00:00
DBG_ERROR ( " Kein CommunicationManager vorhanden!! " ) ;
2002-11-18 14:54:26 +00:00
return ;
}
if ( ! pCommunicationManager - > IsCommunicationRunning ( ) )
2008-08-19 11:46:53 +00:00
{
// 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 ) )
2002-11-18 14:54:26 +00:00
{
2008-08-19 11:46:53 +00:00
pImpl - > pMyBasic - > Call ( CUniString ( " startTheOffice " ) ) ;
2002-11-18 14:54:26 +00:00
}
else
{
2008-08-19 11:46:53 +00:00
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
2002-11-18 14:54:26 +00:00
{
2008-08-19 11:46:53 +00:00
if ( ! pImpl - > bIsStart )
{
ADD_ERROR ( ERR_RESTART , GEN_RES_STR0 ( S_APPLICATION_RESTARTED ) ) ;
}
2002-11-18 14:54:26 +00:00
}
}
2008-08-19 11:46:53 +00:00
}
2002-11-18 14:54:26 +00:00
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 )
{
2007-04-26 08:40:15 +00:00
pImpl - > LocalStarttime = Time : : GetSystemTicks ( ) ; // Setzen der Anfangszeit f<> r Performancemessung
2002-11-18 14:54:26 +00:00
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
{
2008-11-10 15:06:12 +00:00
DBG_ERROR ( " EndBlock au<61> erhalb eines Blockes " ) ;
2002-11-18 14:54:26 +00:00
}
}
2006-06-19 23:27:12 +00:00
BOOL TestToolObj : : Load ( String aFileName , SbModule * pMod )
2002-11-18 14:54:26 +00:00
{
BOOL bOk = TRUE ;
2006-06-19 23:27:12 +00:00
SvFileStream aStrm ( aFileName , STREAM_STD_READ ) ;
2002-11-18 14:54:26 +00:00
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 ( ) ;
2006-06-19 23:27:12 +00:00
pMod - > SetName ( CUniString ( " -- " ) . Append ( aFileName ) ) ;
2002-11-18 14:54:26 +00:00
2004-01-19 16:52:32 +00:00
pMod - > SetComment ( GetRevision ( aText ) ) ;
2002-11-18 14:54:26 +00:00
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 ;
2004-07-06 11:08:11 +00:00
SmartId aUId ;
2002-11-18 14:54:26 +00:00
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 ;
2004-09-09 16:24:31 +00:00
if ( ! nType /* HasNumeric() */ )
2002-11-18 14:54:26 +00:00
{
String aStrId ;
aStream . ReadByteString ( aStrId , RTL_TEXTENCODING_UTF8 ) ;
2004-07-06 11:08:11 +00:00
aUId = SmartId ( aStrId ) ;
2002-11-18 14:54:26 +00:00
}
else
{
2006-04-19 13:00:00 +00:00
comm_ULONG nUId ;
2002-11-18 14:54:26 +00:00
aStream > > nUId ;
2004-07-06 11:08:11 +00:00
aUId = SmartId ( nUId ) ;
2002-11-18 14:54:26 +00:00
}
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 ;
2007-04-26 08:40:15 +00:00
DBG_ERROR ( " !!!! ACHTUNG !!!! Fehler beim einf<6E> gen in leere Liste! " ) ;
2002-11-18 14:54:26 +00:00
}
}
if ( ! pNames - > C40_PTR_INSERT ( ControlItem , ( ControlItem * & ) pNewDef ) )
{
2007-04-26 08:40:15 +00:00
DBG_ERROR ( " !!!! ACHTUNG !!!! Fehler beim einf<6E> gen eines namens! " ) ;
2002-11-18 14:54:26 +00:00
delete pNewDef ;
pFatherDef = NULL ;
}
else
{
pFatherDef = pNewDef ;
}
}
else
{
if ( ! pFatherDef )
{
2007-04-26 08:40:15 +00:00
DBG_ERROR ( " Internal Error: Erster Kurzname mu<6D> mit * beginnen. <20> berspringe. " ) ;
2002-11-18 14:54:26 +00:00
}
else
{
pNewDef = new ControlDef ( aName , aUId ) ;
if ( ! pFatherDef - > SonInsert ( pNewDef ) )
{
delete pNewDef ;
2007-04-26 08:40:15 +00:00
DBG_ERROR ( " !!!! ACHTUNG !!!! Fehler beim einf<6E> gen eines namens! " ) ;
2002-11-18 14:54:26 +00:00
}
}
}
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 ( ) )
{
2006-06-19 23:27:12 +00:00
USHORT i ;
2002-11-18 14:54:26 +00:00
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 ( ) ;
2006-06-19 23:27:12 +00:00
ULONG nHintUserData = pVar - > GetUserData ( ) ;
2002-11-18 14:54:26 +00:00
if ( nHintId = = SBX_HINT_DATAWANTED )
{
nMyVar = 0 ;
2006-06-19 23:27:12 +00:00
switch ( nHintUserData )
2002-11-18 14:54:26 +00:00
{
case ID_Kontext :
if ( ! rPar )
{
2006-06-19 23:27:12 +00:00
m_pNameKontext = m_pControls ;
2002-11-18 14:54:26 +00:00
2007-04-26 08:40:15 +00:00
// So da<64> nicht immer mal wieder was aus einem alten Kontext dazwischenhaut
2002-11-18 14:54:26 +00:00
for ( USHORT i = 0 ; i < VAR_POOL_SIZE ; i + + )
{
2006-04-19 13:15:58 +00:00
pImpl - > pMyVars [ i ] - > SetName ( CUniString ( " VarDummy " ) . Append ( UniString : : CreateFromInt32 ( i ) ) ) ;
2002-11-18 14:54:26 +00:00
}
}
else if ( rPar & & rPar - > Count ( ) = = 2 )
{
USHORT nElement ;
SbxVariableRef pArg = rPar - > Get ( 1 ) ;
String aKontext = pArg - > GetString ( ) ;
2004-07-06 11:08:11 +00:00
ControlDef WhatName ( aKontext , SmartId ( ) ) ;
2006-06-19 23:27:12 +00:00
if ( m_pControls & & m_pControls - > Seek_Entry ( & WhatName , & nElement ) )
2002-11-18 14:54:26 +00:00
{
2006-06-19 23:27:12 +00:00
m_pNameKontext = ( ( ControlDef * ) m_pControls - > GetObject ( nElement ) ) - > GetSons ( ) ;
2002-11-18 14:54:26 +00:00
2007-04-26 08:40:15 +00:00
// So da<64> nicht immer mal wieder was aus einem alten Kontext dazwischenhaut
2002-11-18 14:54:26 +00:00
for ( USHORT i = 0 ; i < VAR_POOL_SIZE ; i + + )
{
2006-04-19 13:15:58 +00:00
pImpl - > pMyVars [ i ] - > SetName ( CUniString ( " VarDummy " ) . Append ( UniString : : CreateFromInt32 ( i ) ) ) ;
2002-11-18 14:54:26 +00:00
}
}
}
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 ( ) ;
}
2004-08-02 14:49:26 +00:00
else
pImpl - > ProgParam . Erase ( ) ;
2002-11-18 14:54:26 +00:00
String aTmpStr ( ProgPath ) ;
aTmpStr + = ' ' ;
aTmpStr + = pImpl - > ProgParam ;
2006-06-19 23:27:12 +00:00
{
2007-04-26 08:40:15 +00:00
TTExecutionStatusHint aHint ( TT_EXECUTION_SHOW_ACTION , String ( SttResId ( S_STARTING_APPLICATION ) ) , aTmpStr ) ;
2006-06-19 23:27:12 +00:00
GetTTBroadcaster ( ) . Broadcast ( aHint ) ;
}
2002-11-18 14:54:26 +00:00
pImpl - > bIsStart = TRUE ;
BeginBlock ( ) ;
EndBlock ( ) ;
pImpl - > bIsStart = FALSE ;
{
TTExecutionStatusHint aHint ( TT_EXECUTION_HIDE_ACTION ) ;
GetTTBroadcaster ( ) . Broadcast ( aHint ) ;
}
}
break ;
2004-09-20 11:25:43 +00:00
case ID_KillApp :
pCommunicationManager - > KillApplication ( ) ;
break ;
2002-11-18 14:54:26 +00:00
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 ) ;
2006-06-19 23:27:12 +00:00
WriteNamesBin ( FilePath . GetFull ( ) , m_pSIds , m_pControls ) ;
2002-11-18 14:54:26 +00:00
}
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
{
2006-07-06 13:33:04 +00:00
{
BasicRuntime aRun = BasicRuntimeAccess : : GetRuntime ( ) ;
aLogFileName = DirEntry ( aRun . GetModuleName ( SbxNAME_NONE ) ) . GetBase ( ) . AppendAscii ( " .res " ) ;
}
2002-11-18 14:54:26 +00:00
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 + + )
{
2006-04-19 13:15:58 +00:00
pImpl - > pMyVars [ i ] - > SetName ( CUniString ( " VarDummy " ) . Append ( UniString : : CreateFromInt32 ( i ) ) ) ;
2002-11-18 14:54:26 +00:00
}
nMyVar = 0 ;
2006-06-19 23:27:12 +00:00
if ( m_pControls )
2002-11-18 14:54:26 +00:00
{
2006-06-19 23:27:12 +00:00
delete m_pControls ;
m_pControls = NULL ;
2002-11-18 14:54:26 +00:00
}
2006-06-19 23:27:12 +00:00
if ( m_pReverseSlots )
2002-11-18 14:54:26 +00:00
{
2006-06-19 23:27:12 +00:00
delete m_pReverseSlots ;
m_pReverseSlots = NULL ;
2002-11-18 14:54:26 +00:00
}
2006-06-19 23:27:12 +00:00
if ( m_pReverseControls )
2002-11-18 14:54:26 +00:00
{
2006-06-19 23:27:12 +00:00
delete m_pReverseControls ;
m_pReverseControls = NULL ;
2002-11-18 14:54:26 +00:00
}
2006-06-19 23:27:12 +00:00
if ( m_pReverseControlsSon )
2002-11-18 14:54:26 +00:00
{
2006-06-19 23:27:12 +00:00
delete m_pReverseControlsSon ;
m_pReverseControlsSon = NULL ;
2002-11-18 14:54:26 +00:00
}
2006-06-19 23:27:12 +00:00
if ( m_pSIds )
2002-11-18 14:54:26 +00:00
{
2006-06-19 23:27:12 +00:00
delete m_pSIds ;
m_pSIds = NULL ;
2002-11-18 14:54:26 +00:00
}
if ( pUIds )
{
delete pUIds ;
pUIds = NULL ;
}
2006-06-19 23:27:12 +00:00
if ( m_pReverseUIds )
2002-11-18 14:54:26 +00:00
{
2006-06-19 23:27:12 +00:00
delete m_pReverseUIds ;
m_pReverseUIds = NULL ;
2002-11-18 14:54:26 +00:00
}
2006-06-19 23:27:12 +00:00
m_pNameKontext = m_pControls ;
2002-11-18 14:54:26 +00:00
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 ;
2003-03-18 15:03:50 +00:00
pImpl - > bEnableQaErrors = TRUE ;
pImpl - > bDebugFindNoErrors = FALSE ;
2004-06-17 10:41:09 +00:00
pImpl - > pChildEnv - > clear ( ) ;
2003-03-18 15:03:50 +00:00
String aName ( CUniString ( " StopOnSyntaxError " ) ) ;
SbxVariableRef xStopOnSyntaxError = SbxObject : : Find ( aName , SbxCLASS_PROPERTY ) ;
if ( xStopOnSyntaxError . Is ( ) )
xStopOnSyntaxError - > PutBool ( pImpl - > bStopOnSyntaxError ) ;
else
SetError ( SbxERR_BAD_ACTION ) ;
2002-11-18 14:54:26 +00:00
}
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 )
{
2006-06-19 23:27:12 +00:00
ReadNames ( FilePath . GetFull ( ) , m_pControls , pUIds ) ;
2002-11-18 14:54:26 +00:00
pImpl - > bLnaguageExtensionLoaded = TRUE ;
SfxSimpleHint aHint ( SBX_HINT_LANGUAGE_EXTENSION_LOADED ) ;
GetTTBroadcaster ( ) . Broadcast ( aHint ) ;
}
else if ( Ext . CompareIgnoreCaseToAscii ( " Sid " ) = = COMPARE_EQUAL )
{
2006-06-19 23:27:12 +00:00
ReadNames ( FilePath . GetFull ( ) , m_pSIds , pUIds , FLAT ) ;
2002-11-18 14:54:26 +00:00
pImpl - > bLnaguageExtensionLoaded = TRUE ;
SfxSimpleHint aHint ( SBX_HINT_LANGUAGE_EXTENSION_LOADED ) ;
GetTTBroadcaster ( ) . Broadcast ( aHint ) ;
}
else if ( Ext . CompareIgnoreCaseToAscii ( " Bin " ) = = COMPARE_EQUAL )
{
2006-06-19 23:27:12 +00:00
ReadNamesBin ( FilePath . GetFull ( ) , m_pSIds , m_pControls ) ;
2002-11-18 14:54:26 +00:00
pImpl - > bLnaguageExtensionLoaded = TRUE ;
SfxSimpleHint aHint ( SBX_HINT_LANGUAGE_EXTENSION_LOADED ) ;
GetTTBroadcaster ( ) . Broadcast ( aHint ) ;
}
else if ( Ext . CompareIgnoreCaseToAscii ( " Inc " ) = = COMPARE_EQUAL )
{
{
2007-04-26 08:40:15 +00:00
TTExecutionStatusHint aHint ( TT_EXECUTION_SHOW_ACTION , String ( SttResId ( S_READING_BASIC_MODULE ) ) , FilePath . GetFull ( ) ) ;
2002-11-18 14:54:26 +00:00
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
2006-06-19 23:27:12 +00:00
if ( ! m_pControls )
m_pControls = new CNames ( ) ;
2002-11-18 14:54:26 +00:00
2006-06-19 23:27:12 +00:00
if ( ! m_pSIds )
m_pSIds = new CNames ( ) ;
2002-11-18 14:54:26 +00:00
if ( pUIds )
{ // save some memory
delete pUIds ;
pUIds = NULL ;
}
2006-06-19 23:27:12 +00:00
m_pNameKontext = m_pControls ;
2002-11-18 14:54:26 +00:00
if ( pImpl - > bLnaguageExtensionLoaded )
{
SfxSimpleHint aHint ( SBX_HINT_LANGUAGE_EXTENSION_LOADED ) ;
GetTTBroadcaster ( ) . Broadcast ( aHint ) ;
}
pImpl - > nIncludeFileWarningCount = pImpl - > nWarningCount ;
pImpl - > nWarningCount = 0 ;
2004-01-19 16:52:32 +00:00
* pImpl - > xIncludeFileWarningList = * pImpl - > xWarningList ;
pImpl - > xWarningList - > SbxArray : : Clear ( ) ;
2002-11-18 14:54:26 +00:00
}
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 ) ,
2004-01-19 16:52:32 +00:00
aThisEntry . GetLine ( ) , aThisEntry . GetCol1 ( ) , aThisEntry . GetCol2 ( ) , aThisEntry . GetSourceRevision ( ) ) ;
2002-11-18 14:54:26 +00:00
}
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 ) ,
2004-01-19 16:52:32 +00:00
nErrLn , nCol1 , nCol2 , aRun . GetSourceRevision ( ) ) ;
2002-11-18 14:54:26 +00:00
}
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 ) ,
2004-01-19 16:52:32 +00:00
aThisEntry . GetLine ( ) , aThisEntry . GetCol1 ( ) , aThisEntry . GetCol2 ( ) , aThisEntry . GetSourceRevision ( ) ) ;
2002-11-18 14:54:26 +00:00
BasicRuntimeAccess : : DeleteStack ( ) ;
}
else
{
ADD_ERROR_LOG ( GET_ERROR ( ) - > aText , aRun . GetModuleName ( SbxNAME_SHORT_TYPES ) ,
2004-01-19 16:52:32 +00:00
StarBASIC : : GetErl ( ) , aRun . GetCol1 ( ) , aRun . GetCol2 ( ) , aRun . GetSourceRevision ( ) ) ;
2002-11-18 14:54:26 +00:00
}
}
break ;
2003-03-18 15:03:50 +00:00
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 ;
2002-11-18 14:54:26 +00:00
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 :
2006-07-06 13:33:04 +00:00
if ( ( ( StarBASIC * ) GetParent ( ) ) - > GetErrBasic ( ) & & ( ! IS_ERROR ( ) | |
pFehlerListe - > GetObject ( pFehlerListe - > Count ( ) - 1 ) - > nError ! = ( ( StarBASIC * ) GetParent ( ) ) - > GetErrBasic ( ) ) )
2002-11-18 14:54:26 +00:00
{
2006-07-06 13:33:04 +00:00
( ( StarBASIC * ) GetParent ( ) ) - > MakeErrorText ( ( ( StarBASIC * ) GetParent ( ) ) - > GetErrBasic ( ) , String ( ) ) ;
ADD_ERROR_QUIET ( ( ( StarBASIC * ) GetParent ( ) ) - > GetErrBasic ( ) , ( ( StarBASIC * ) GetParent ( ) ) - > GetErrorText ( ) )
2002-11-18 14:54:26 +00:00
}
break ;
case ID_GetNextCloseWindow :
if ( ! rPar ) // rPar = NULL <=> Kein Parameter
{
SetError ( SbxERR_NOTIMP ) ;
break ;
2006-06-19 23:27:12 +00:00
2007-04-26 08:40:15 +00:00
// Das ist total rotten und mu<6D> wohl komplett neu!!
2002-11-18 14:54:26 +00:00
2006-06-19 23:27:12 +00:00
/* BOOL bWasBlock = IsBlock;
2002-11-18 14:54:26 +00:00
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 ( ) ;
2007-04-26 08:40:15 +00:00
// Setzen, so da<64> beim Return der Wert stimmt
2002-11-18 14:54:26 +00:00
( ( Controls * ) pVar ) - > PutULong ( 128 ) ;
pImpl - > pNextReturn = ( ( Controls * ) pVar ) - > pMethodVar ;
if ( SingleCommandBlock )
EndBlock ( ) ;
WaitForAnswer ( ) ;
if ( bWasBlock )
if ( SingleCommandBlock )
BeginBlock ( ) ;
( ( Controls * ) pVar ) - > PutULong ( nOldValue ) ;
2007-04-26 08:40:15 +00:00
// R<> cksetzen, so da<64> beim n<> chsten Aufruf alles klappt
2002-11-18 14:54:26 +00:00
// ((Controls*)pVar)->SetUserData( 128 );
// ((Controls*)pVar)->SetName("xxx");
2007-04-26 08:40:15 +00:00
// Setzen und r<> cksetzen der ID, so dass der Notify ohne Wirkung bleibt.
2002-11-18 14:54:26 +00:00
( ( Controls * ) pVar ) - > pMethodVar - > SetUserData ( ID_ErrorDummy ) ;
( ( Controls * ) pVar ) - > PutULong ( ( ( Controls * ) pVar ) - > pMethodVar - > GetULong ( ) ) ;
( ( Controls * ) pVar ) - > pMethodVar - > SetUserData ( ID_Control ) ;
2004-07-06 11:08:11 +00:00
pShortNames - > Insert ( CUniString ( " xxx " ) , SmartId ( ( ( Controls * ) pVar ) - > pMethodVar - > nValue ) , nSequence ) ;
2002-11-18 14:54:26 +00:00
nOldValue = ( ( Controls * ) pVar ) - > GetULong ( ) ;
SbxVariable * pMember ;
if ( ! ( pMember = ( ( Controls * ) pVar ) - > Find ( CUniString ( " ID " ) , SbxCLASS_DONTCARE ) ) )
{
2004-12-10 16:14:13 +00:00
pMember = new SbxProperty ( CUniString ( " ID " ) , SbxVARIANT ) ;
2002-11-18 14:54:26 +00:00
( ( 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 " ) ) ;
2006-06-19 23:27:12 +00:00
*/
2002-11-18 14:54:26 +00:00
}
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 ) ;
2004-07-06 11:08:11 +00:00
aNextReturnId = SmartId ( ( ( SbxTransportMethod * ) pVar ) - > nValue ) ;
2002-11-18 14:54:26 +00:00
}
if ( SingleCommandBlock )
EndBlock ( ) ;
if ( ! IsError ( ) & & ( USHORT ) ( ( SbxTransportMethod * ) pVar ) - > nValue & M_WITH_RETURN )
{
WaitForAnswer ( ) ;
}
2007-04-26 08:40:15 +00:00
// f<> r einige noch etwas Nachbehandlung
2002-11-18 14:54:26 +00:00
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 ) ;
2004-01-20 15:54:38 +00:00
pVar - > PutInteger ( ( USHORT ) ( ( SbxTransportMethod * ) pVar ) - > nValue ) ;
2002-11-18 14:54:26 +00:00
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 :
2006-04-19 13:15:58 +00:00
// if only the object is given in the script we don't have to do anything (object stands for itself)
if ( ! pVar - > ISA ( SbxObject ) )
2002-11-18 14:54:26 +00:00
{
2006-04-19 13:15:58 +00:00
if ( SingleCommandBlock )
BeginBlock ( ) ;
2002-11-18 14:54:26 +00:00
else
2006-04-19 13:15:58 +00:00
if ( ( ( SbxTransportMethod * ) pVar ) - > nValue & M_WITH_RETURN )
{
SetError ( SbxERR_NOTIMP ) ;
}
if ( ! IsError ( ) )
2002-11-18 14:54:26 +00:00
{
2006-04-19 13:15:58 +00:00
SbxVariable * pMember = NULL ;
2006-10-12 10:19:00 +00:00
if ( pVar - > GetParent ( ) )
pMember = pVar - > GetParent ( ) - > Find ( CUniString ( " ID " ) , SbxCLASS_DONTCARE ) ;
if ( pMember = = NULL )
2004-12-10 16:14:13 +00:00
{
2006-04-19 13:15:58 +00:00
SetError ( SbxERR_NAMED_NOT_FOUND ) ;
2004-12-10 16:14:13 +00:00
}
else
{
2006-06-19 23:27:12 +00:00
if ( nHintUserData = = ID_Control )
2006-04-19 13:15:58 +00:00
{
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 ( ) ;
2004-12-10 16:14:13 +00:00
}
2002-11-18 14:54:26 +00:00
}
2006-04-19 13:15:58 +00:00
if ( SingleCommandBlock )
EndBlock ( ) ;
if ( ! IsError ( ) & & ( USHORT ) ( ( SbxTransportMethod * ) pVar ) - > nValue & M_WITH_RETURN )
2002-11-18 14:54:26 +00:00
{
2006-04-19 13:15:58 +00:00
WaitForAnswer ( ) ;
2002-11-18 14:54:26 +00:00
}
}
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 ( ) )
{
2007-04-26 08:40:15 +00:00
case SbxLONG : // alles immer als Short <20> bertragen
2002-11-18 14:54:26 +00:00
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 ;
2004-01-20 15:54:38 +00:00
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 ) ) ;
}
2007-09-20 13:45:22 +00:00
# elif defined OS2
{
char * etc = getenv ( " ETC " ) ;
if ( etc )
pVar - > PutString ( CUniString ( etc ) ) ;
else
pVar - > PutString ( CUniString ( " /etc " ) ) ;
}
2004-01-20 15:54:38 +00:00
# else
# if UNX
pVar - > PutString ( CUniString ( " /etc " ) ) ;
# else
# error not implemented
# endif
# endif
}
else
SetError ( SbxERR_WRONG_ARGS ) ;
break ;
2002-11-18 14:54:26 +00:00
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 )
{
2003-03-26 11:07:27 +00:00
# ifdef DEBUG
Time aStart ;
# endif
2002-11-18 14:54:26 +00:00
Timer aTimer ;
aTimer . SetTimeout ( nWait ) ;
aTimer . Start ( ) ;
while ( aTimer . IsActive ( ) )
Application : : Yield ( ) ;
2003-03-26 11:07:27 +00:00
# ifdef DEBUG
Time aEnd ;
Time aDiff = aEnd - aStart ;
2006-06-19 23:27:12 +00:00
long aMS = long ( aDiff . GetMSFromTime ( ) ) ;
if ( Abs ( aMS - nWait ) > 100 )
2003-03-26 11:07:27 +00:00
{
DBG_ERROR1 ( " Wait was off limit by %i " , aDiff . GetMSFromTime ( ) - nWait )
}
# endif
2002-11-18 14:54:26 +00:00
}
}
else
2007-05-11 10:32:42 +00:00
SetError ( SbERR_BAD_NUMBER_OF_ARGS ) ;
2002-11-18 14:54:26 +00:00
}
break ;
case ID_GetErrorCount :
{
pVar - > PutULong ( pImpl - > nErrorCount ) ;
}
break ;
case ID_GetWarningCount :
{
pVar - > PutULong ( pImpl - > nWarningCount ) ;
}
break ;
2004-08-02 14:49:26 +00:00
case ID_GetQAErrorCount :
{
pVar - > PutULong ( pImpl - > nQAErrorCount ) ;
}
break ;
2002-11-18 14:54:26 +00:00
case ID_GetUseFileWarningCount :
{
pVar - > PutULong ( pImpl - > nIncludeFileWarningCount ) ;
}
break ;
2004-01-19 16:52:32 +00:00
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 ;
2004-08-02 14:49:26 +00:00
case ID_GetQAErrorList :
{
if ( ! pImpl - > xQAErrorList - > GetDims ( ) )
pImpl - > xQAErrorList - > AddDim ( 1 , 32000 ) ;
pVar - > PutObject ( pImpl - > xQAErrorList ) ;
}
break ;
2004-01-19 16:52:32 +00:00
case ID_GetUseFileWarningList :
{
if ( ! pImpl - > xIncludeFileWarningList - > GetDims ( ) )
pImpl - > xIncludeFileWarningList - > AddDim ( 1 , 32000 ) ;
pVar - > PutObject ( pImpl - > xIncludeFileWarningList ) ;
}
break ;
2002-11-18 14:54:26 +00:00
case ID_GetTestCaseName :
{
pVar - > PutString ( pImpl - > aTestCaseName ) ;
}
break ;
case ID_GetTestCaseFileName :
{
pVar - > PutString ( pImpl - > aTestCaseFileName ) ;
}
break ;
case ID_GetTestCaseLineNr :
{
pVar - > PutUShort ( pImpl - > nTestCaseLineNr ) ;
}
break ;
2004-06-17 10:41:09 +00:00
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
2007-05-11 10:32:42 +00:00
SetError ( SbERR_BAD_NUMBER_OF_ARGS ) ;
2004-06-17 10:41:09 +00:00
}
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
2007-05-11 10:32:42 +00:00
SetError ( SbERR_BAD_NUMBER_OF_ARGS ) ;
2004-06-17 10:41:09 +00:00
}
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
2007-05-11 10:32:42 +00:00
SetError ( SbERR_BAD_NUMBER_OF_ARGS ) ;
2004-06-17 10:41:09 +00:00
}
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
2007-05-11 10:32:42 +00:00
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 ) ;
2004-06-17 10:41:09 +00:00
}
break ;
2006-06-19 23:27:12 +00:00
} // switch( nHintUserData )
2002-11-18 14:54:26 +00:00
} // if( nHintId == SBX_HINT_DATAWANTED )
else if ( nHintId = = SBX_HINT_DATACHANGED )
{
2006-06-19 23:27:12 +00:00
switch ( nHintUserData )
2002-11-18 14:54:26 +00:00
{
case ID_AutoExecute :
if ( ! rPar ) // rPar = NULL <=> Kein Parameter
{
SingleCommandBlock = pVar - > GetBool ( ) ;
if ( SingleCommandBlock )
EndBlock ( ) ;
else
BeginBlock ( ) ;
}
else
SetError ( SbxERR_WRONG_ARGS ) ;
break ;
2003-03-18 15:03:50 +00:00
case ID_EnableQaErrors :
if ( ! rPar ) // rPar = NULL <=> Kein Parameter
pImpl - > bEnableQaErrors = pVar - > GetBool ( ) ;
else
SetError ( SbxERR_WRONG_ARGS ) ;
break ;
2002-11-18 14:54:26 +00:00
}
} // if( nHintId == SBX_HINT_DATACHANGED )
else if ( nHintId = = SBX_HINT_BASICSTART )
{
pImpl - > nErrorCount = 0 ;
pImpl - > nWarningCount = 0 ;
2004-08-02 14:49:26 +00:00
pImpl - > nQAErrorCount = 0 ;
2002-11-18 14:54:26 +00:00
pImpl - > nIncludeFileWarningCount = 0 ;
2004-01-19 16:52:32 +00:00
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
2004-08-02 14:49:26 +00:00
pImpl - > xQAErrorList - > SbxArray : : Clear ( ) ; // call SbxArray::Clear because SbxVarArray::Clear only clears dimensions but no content
2004-01-19 16:52:32 +00:00
pImpl - > xIncludeFileWarningList - > SbxArray : : Clear ( ) ; // call SbxArray::Clear because SbxVarArray::Clear only clears dimensions but no content
2002-11-18 14:54:26 +00:00
if ( pFehlerListe )
delete pFehlerListe ;
pFehlerListe = new CErrors ;
2006-04-19 13:15:58 +00:00
for ( USHORT i = 0 ; i < VAR_POOL_SIZE ; i + + )
{
pImpl - > pMyVars [ i ] - > SetName ( CUniString ( " VarDummy " ) . Append ( UniString : : CreateFromInt32 ( i ) ) ) ;
}
nMyVar = 0 ;
2002-11-18 14:54:26 +00:00
} // 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 ;
2004-08-02 14:49:26 +00:00
pImpl - > nQAErrorCount = 0 ;
2002-11-18 14:54:26 +00:00
pImpl - > nIncludeFileWarningCount = 0 ;
2004-01-19 16:52:32 +00:00
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
2004-08-02 14:49:26 +00:00
pImpl - > xQAErrorList - > SbxArray : : Clear ( ) ; // call SbxArray::Clear because SbxVarArray::Clear only clears dimensions but no content
2004-01-19 16:52:32 +00:00
pImpl - > xIncludeFileWarningList - > SbxArray : : Clear ( ) ; // call SbxArray::Clear because SbxVarArray::Clear only clears dimensions but no content
2002-11-18 14:54:26 +00:00
} // 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 ( ) ) ) ;
}
}
}
2003-03-18 15:03:50 +00:00
void TestToolObj : : DebugFindNoErrors ( BOOL bDebugFindNoErrors )
{
pImpl - > bDebugFindNoErrors = bDebugFindNoErrors ;
}
2002-11-18 14:54:26 +00:00
2006-06-19 23:27:12 +00:00
SbxVariable * TestToolObj : : Find ( const String & aStr , SbxClassType aType )
2002-11-18 14:54:26 +00:00
{
if ( BasicRuntimeAccess : : IsRunInit ( ) ) // wegen Find im "Global" Befehl des Basic
return NULL ;
2006-06-19 23:27:12 +00:00
SbxVariableRef Old = SbxObject : : Find ( aStr , aType ) ;
2006-04-19 13:15:58 +00:00
// do not return any objects from pMyVars[]
2005-10-06 11:37:43 +00:00
if ( Old & & Old - > GetUserData ( ) ! = ID_Dispatch
& & Old - > GetUserData ( ) ! = ID_UNODispatch
& & Old - > GetUserData ( ) ! = ID_ErrorDummy
& & Old - > GetUserData ( ) ! = 0 )
2002-11-18 14:54:26 +00:00
return Old ;
2006-06-19 23:27:12 +00:00
else if ( aStr . SearchAscii ( " : " ) ! = STRING_NOTFOUND )
2006-04-19 13:15:58 +00:00
{ // ignore qualified names e.g. main:FormWizard If this was removed an error would be generated
}
2002-11-18 14:54:26 +00:00
else
{
2006-04-19 13:15:58 +00:00
2002-11-18 14:54:26 +00:00
USHORT nElement ;
2006-06-19 23:27:12 +00:00
ControlDef * pWhatName = new ControlDef ( aStr , SmartId ( ) ) ;
2002-11-18 14:54:26 +00:00
/// nach Controls suchen
2006-06-19 23:27:12 +00:00
if ( m_pNameKontext & & m_pNameKontext - > Seek_Entry ( pWhatName , & nElement ) )
2002-11-18 14:54:26 +00:00
{
delete pWhatName ;
2006-06-19 23:27:12 +00:00
pWhatName = ( ( ControlDef * ) m_pNameKontext - > GetObject ( nElement ) ) ;
2006-04-19 13:15:58 +00:00
//// new Controls Object every time
pImpl - > pControlsObj = new Controls ( pWhatName - > pData - > Kurzname ) ;
pImpl - > pControlsObj - > SetType ( SbxOBJECT ) ;
pImpl - > pControlsObj - > ChangeListener ( this ) ;
2002-11-18 14:54:26 +00:00
2004-12-10 16:14:13 +00:00
// Will be set on method-child further down
2004-09-09 16:24:31 +00:00
if ( pWhatName - > pData - > aUId . HasNumeric ( ) )
2004-12-10 16:14:13 +00:00
pImpl - > pControlsObj - > SetUserData ( ID_Control ) ;
2002-11-18 14:54:26 +00:00
else
2004-12-10 16:14:13 +00:00
pImpl - > pControlsObj - > SetUserData ( ID_StringControl ) ;
2002-11-18 14:54:26 +00:00
pShortNames - > Insert ( pWhatName - > pData - > Kurzname , pWhatName - > pData - > aUId , nSequence ) ;
2006-10-12 10:19:00 +00:00
SbxVariable * pMember = pImpl - > pControlsObj - > Find ( CUniString ( " ID " ) , SbxCLASS_DONTCARE ) ;
if ( pMember = = NULL )
2002-11-18 14:54:26 +00:00
{
2004-12-10 16:14:13 +00:00
SbxProperty * pID = new SbxProperty ( CUniString ( " ID " ) , SbxVARIANT ) ;
pImpl - > pControlsObj - > Insert ( pID ) ;
pImpl - > pControlsObj - > SetDfltProperty ( pID ) ;
pMember = pID ;
2002-11-18 14:54:26 +00:00
}
2004-09-09 16:24:31 +00:00
if ( pWhatName - > pData - > aUId . HasNumeric ( ) )
2004-07-06 11:08:11 +00:00
pMember - > PutULong ( pWhatName - > pData - > aUId . GetNum ( ) ) ;
2002-11-18 14:54:26 +00:00
else
2004-07-06 11:08:11 +00:00
pMember - > PutString ( pWhatName - > pData - > aUId . GetStr ( ) ) ;
2002-11-18 14:54:26 +00:00
2006-10-12 10:19:00 +00:00
pMember = pImpl - > pControlsObj - > Find ( CUniString ( " name " ) , SbxCLASS_DONTCARE ) ;
if ( pMember ! = NULL )
2002-11-18 14:54:26 +00:00
pMember - > PutString ( pWhatName - > pData - > Kurzname ) ;
return pImpl - > pControlsObj ;
}
/// Nach slots suchen
2006-06-19 23:27:12 +00:00
if ( m_pSIds & & m_pSIds - > Seek_Entry ( pWhatName , & nElement ) )
2002-11-18 14:54:26 +00:00
{
SbxTransportMethodRef pMyVar ;
pMyVar = pImpl - > pMyVars [ nMyVar + + ] ;
if ( nMyVar > = VAR_POOL_SIZE )
nMyVar = 0 ;
delete pWhatName ;
2006-06-19 23:27:12 +00:00
pWhatName = ( ( ControlDef * ) m_pSIds - > GetObject ( nElement ) ) ;
2002-11-18 14:54:26 +00:00
pMyVar - > SetName ( pWhatName - > pData - > Kurzname ) ;
2004-09-09 16:24:31 +00:00
if ( pWhatName - > pData - > aUId . HasNumeric ( ) )
2002-11-18 14:54:26 +00:00
{
2004-07-06 11:08:11 +00:00
pMyVar - > SetUserData ( ID_Dispatch ) ;
pMyVar - > nValue = pWhatName - > pData - > aUId . GetNum ( ) ;
2006-06-19 23:27:12 +00:00
pShortNames - > Insert ( aStr , pWhatName - > pData - > aUId , nSequence ) ;
2002-11-18 14:54:26 +00:00
}
else
{
2004-07-06 11:08:11 +00:00
pMyVar - > SetUserData ( ID_UNODispatch ) ;
pMyVar - > aUnoSlot = pWhatName - > pData - > aUId . GetStr ( ) ;
2002-11-18 14:54:26 +00:00
}
return pMyVar ;
}
2007-04-26 08:40:15 +00:00
/// es kann sich noch um eine SlotID handeln, die numerisch abgefragt wird, statt ausgef<65> hrt zu werden
2006-06-19 23:27:12 +00:00
if ( aStr . Copy ( aStr . Len ( ) - 3 , 3 ) . CompareIgnoreCaseToAscii ( " _ID " ) = = COMPARE_EQUAL & & m_pSIds )
2002-11-18 14:54:26 +00:00
{
delete pWhatName ;
2006-06-19 23:27:12 +00:00
pWhatName = new ControlDef ( aStr . Copy ( 0 , aStr . Len ( ) - 3 ) , SmartId ( ) ) ;
if ( m_pSIds - > Seek_Entry ( pWhatName , & nElement ) )
2002-11-18 14:54:26 +00:00
{ // Nach slots suchen
SbxVariable * pReturn = new SbxVariable ;
delete pWhatName ;
2006-06-19 23:27:12 +00:00
pWhatName = ( ( ControlDef * ) m_pSIds - > GetObject ( nElement ) ) ;
2002-11-18 14:54:26 +00:00
pReturn - > SetName ( pWhatName - > pData - > Kurzname ) ;
2004-09-09 16:24:31 +00:00
if ( pWhatName - > pData - > aUId . HasNumeric ( ) )
2004-07-06 11:08:11 +00:00
pReturn - > PutULong ( pWhatName - > pData - > aUId . GetNum ( ) ) ;
2002-11-18 14:54:26 +00:00
else
2004-07-06 11:08:11 +00:00
pReturn - > PutString ( pWhatName - > pData - > aUId . GetStr ( ) ) ;
2002-11-18 14:54:26 +00:00
return pReturn ;
}
}
2003-03-18 15:03:50 +00:00
if ( ! pImpl - > bDebugFindNoErrors )
{
2006-06-19 23:27:12 +00:00
ADD_ERROR ( SbxERR_PROC_UNDEFINED , GEN_RES_STR1 ( S_UNKNOWN_SLOT_CONTROL , aStr ) ) ;
2002-11-18 14:54:26 +00:00
}
}
return NULL ;
}
2004-01-19 16:52:32 +00:00
String TestToolObj : : GetRevision ( String const & aSourceIn )
{
2008-08-19 11:46:53 +00:00
// search $Revision: 1.40 $
2004-01-19 16:52:32 +00:00
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 " ) ;
}
2002-11-18 14:54:26 +00:00
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 ;
2007-05-11 10:32:42 +00:00
xub_StrLen nTry2 = 0 ;
while ( ! WasPrecompilerError ( ) & & ( nTry2 = ImplSearch ( aSource , nStart , nEnd , CUniString ( " try " ) , nTry + 1 ) ) ! = STRING_NOTFOUND )
2002-11-18 14:54:26 +00:00
{ // 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 ) ;
}
2006-06-19 23:27:12 +00:00
return xub_StrLen ( nEnd + nTotalLength ) ;
2002-11-18 14:54:26 +00:00
}
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 ) ;
2006-10-12 10:19:00 +00:00
nPartPos = nPartPos + aEnd . Len ( ) ;
2002-11-18 14:54:26 +00:00
}
}
BOOL TestToolObj : : WasPrecompilerError ( )
{
return bWasPrecompilerError ;
}
String TestToolObj : : PreCompile ( String const & aSourceIn )
{
2007-04-26 08:40:15 +00:00
// Im CTOR zu fr<66> h, und hier grade nicg rechtzeitig. Start und Stop von Programmausf<73> hrung
2002-11-18 14:54:26 +00:00
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. " )
2007-04-26 08:40:15 +00:00
aSource = String ( ' ' ) . Append ( aSource ) ; // Da Schl<68> sselworte an Position 0 sonst nicht gefunden werden
2002-11-18 14:54:26 +00:00
// 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 ) ;
}
2003-03-18 15:03:50 +00:00
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// Attention!!! The lable endsub is officially used to exit a sub instead of using 'exit sub' or 'return'
/////////////////////////////////////////////////////////////////////////////////////////////////////////
2002-11-18 14:54:26 +00:00
while ( ( nEndCase = ImplSearch ( aSource , 0 , aSource . Len ( ) , CUniString ( " endcase " ) ) ) ! = STRING_NOTFOUND )
2003-03-18 15:03:50 +00:00
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 ) ;
2002-11-18 14:54:26 +00:00
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 ;
2007-04-26 08:40:15 +00:00
pNewItem = ( ControlItemUId * ) pControls - > GetObject ( nNr ) ; // f<> r einf<6E> gen der S<> hne
2002-11-18 14:54:26 +00:00
}
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
2006-06-19 23:27:12 +00:00
if ( ! m_pReverseUIds )
2002-11-18 14:54:26 +00:00
{
String aName = ( pImpl - > aHIDDir + DirEntry ( CUniString ( " hid.lst " ) ) ) . GetFull ( ) ;
2006-06-19 23:27:12 +00:00
{
2007-04-26 08:40:15 +00:00
TTExecutionStatusHint aHint ( TT_EXECUTION_SHOW_ACTION , String ( SttResId ( S_READING_LONGNAMES ) ) , aName ) ;
2006-06-19 23:27:12 +00:00
GetTTBroadcaster ( ) . Broadcast ( aHint ) ;
}
ReadFlat ( aName , m_pReverseUIds , FALSE ) ;
2002-11-18 14:54:26 +00:00
{
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
2006-06-19 23:27:12 +00:00
if ( ! m_pReverseControls & & ! m_pReverseControlsSon & & m_pControls )
2002-11-18 14:54:26 +00:00
{
2006-06-19 23:27:12 +00:00
m_pReverseControls = new CNames ;
m_pReverseControlsSon = new CNames ;
2002-11-18 14:54:26 +00:00
USHORT nWin , nCont ;
const String aSl ( ' / ' ) ;
2006-06-19 23:27:12 +00:00
for ( nWin = 0 ; nWin < m_pControls - > Count ( ) ; nWin + + )
2002-11-18 14:54:26 +00:00
{
2006-06-19 23:27:12 +00:00
String aFatherName ( m_pControls - > GetObject ( nWin ) - > pData - > Kurzname ) ;
ControlItemUId * pNewFather = new ControlItemUIdSon ( aFatherName , m_pControls - > GetObject ( nWin ) - > pData - > aUId ) ;
AddToListByNr ( m_pReverseControlsSon , pNewFather ) ;
2002-11-18 14:54:26 +00:00
if ( ! ( ( ControlItemUIdSon * ) pNewFather ) - > GetSons ( ) )
( ( ControlItemUIdSon * ) pNewFather ) - > Sons ( new CNames ) ;
2007-04-26 08:40:15 +00:00
// Existieren S<> hne, diese in beide Listen eintragen
2006-06-19 23:27:12 +00:00
CNames * pControlList = ( ( ControlItemSon * ) m_pControls - > GetObject ( nWin ) ) - > GetSons ( ) ;
2002-11-18 14:54:26 +00:00
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 ) ;
2006-06-19 23:27:12 +00:00
AddToListByNr ( m_pReverseControls , pNewItem ) ;
2002-11-18 14:54:26 +00:00
pNewItem = new ControlItemUId ( pControlList - > GetObject ( nCont ) - > pData - > Kurzname , pControlList - > GetObject ( nCont ) - > pData - > aUId ) ;
AddToListByNr ( ( ( ControlItemUIdSon * ) pNewFather ) - > GetSons ( ) , pNewItem ) ;
}
}
if ( ! bIncludeActive )
{
2004-07-06 11:08:11 +00:00
ControlItem * pZeroItem = new ControlItemUId ( UniString ( ) , SmartId ( 0 ) ) ;
2002-11-18 14:54:26 +00:00
USHORT nNr ;
2006-06-19 23:27:12 +00:00
if ( m_pReverseControls - > Seek_Entry ( pZeroItem , & nNr ) )
2002-11-18 14:54:26 +00:00
{
2006-06-19 23:27:12 +00:00
m_pReverseControls - > DeleteAndDestroy ( nNr ) ;
2002-11-18 14:54:26 +00:00
// um VorlagenLaden/UntergeordneteIniDatei/SpeichernDlg/OrdnerDlg/OeffnenDlg/MessageBox/LetzteVersion/GrafikEinfuegenDlg/FarbeDlg/ExportierenDlg/DruckerEinrichten/DruckenDlg/DateiEinfuegenDlg/Active zu verhindern
}
2006-06-19 23:27:12 +00:00
/* if ( m_pReverseControlsSon->Seek_Entry( pZeroItem, &nNr ) )
2002-11-18 14:54:26 +00:00
{
2006-06-19 23:27:12 +00:00
m_pReverseControlsSon - > DeleteAndDestroy ( nNr ) ;
2002-11-18 14:54:26 +00:00
// 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 ;
2004-07-06 11:08:11 +00:00
SmartId aUId ;
2002-11-18 14:54:26 +00:00
pRetStream - > Read ( nRet ) ;
if ( pRetStream - > GetNextType ( ) = = BinString )
{
String aUStrId ; // UniqueStringID Used for Mozilla Integration
pRetStream - > Read ( aUStrId ) ;
2004-07-06 11:08:11 +00:00
aUId = SmartId ( aUStrId ) ;
2002-11-18 14:54:26 +00:00
}
else
{
2006-04-19 13:00:00 +00:00
comm_ULONG nUId ;
2002-11-18 14:54:26 +00:00
pRetStream - > Read ( nUId ) ; // bei Sequence einfach die Sequence
2004-07-06 11:08:11 +00:00
aUId = SmartId ( nUId ) ;
2002-11-18 14:54:26 +00:00
}
pRetStream - > Read ( nParams ) ;
USHORT nNr1 = 0 ;
2006-04-19 13:00:00 +00:00
comm_ULONG nLNr1 = 0 ;
2002-11-18 14:54:26 +00:00
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 :
{
2004-07-06 11:08:11 +00:00
ULONG nUId = aUId . GetNum ( ) ;
2002-11-18 14:54:26 +00:00
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 )
{
2006-06-19 23:27:12 +00:00
// ULONG nHintUserData = pImpl->pNextReturn->GetParent()->GetUserData();
2002-11-18 14:54:26 +00:00
// pImpl->pNextReturn->GetParent()->SetUserData(0);
// if ( nUId == pImpl->pNextReturn->GetParent()->GetULong() )
2004-09-09 16:24:31 +00:00
if ( aNextReturnId . Matches ( aUId ) )
2002-11-18 14:54:26 +00:00
{
2006-04-19 13:15:58 +00:00
if ( nParams & PARAM_ULONG_1 )
{
if ( nLNr1 > 0x7fffffff )
pImpl - > pNextReturn - > PutLong ( long ( nLNr1 - 0xffffffff ) - 1 ) ;
else
pImpl - > pNextReturn - > PutULong ( nLNr1 ) ;
}
2002-11-18 14:54:26 +00:00
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 ) )
}
2006-06-19 23:27:12 +00:00
// pImpl->pNextReturn->GetParent()->SetUserData(nHintUserData);
2002-11-18 14:54:26 +00:00
pImpl - > pNextReturn = NULL ;
}
else
{
ADD_ERROR ( SbxERR_BAD_ACTION , GEN_RES_STR0 ( S_RETURNED_VALUE_NO_RECEIVER ) )
}
break ;
case RET_WinInfo :
{
2006-06-19 23:27:12 +00:00
if ( ! m_pReverseControls & & ! m_pReverseControlsSon )
2002-11-18 14:54:26 +00:00
pReverseControlsKontext = NULL ;
ReadHidLstByNumber ( ) ;
SortControlsByNumber ( ) ;
// Alle Slots nach Nummer Sortiert
2006-06-19 23:27:12 +00:00
if ( ! m_pReverseSlots & & m_pSIds )
2002-11-18 14:54:26 +00:00
{
2006-06-19 23:27:12 +00:00
m_pReverseSlots = new CNames ;
2002-11-18 14:54:26 +00:00
USHORT nWin ;
const String aSl ( ' / ' ) ;
2006-06-19 23:27:12 +00:00
for ( nWin = 0 ; nWin < m_pSIds - > Count ( ) ; nWin + + )
2002-11-18 14:54:26 +00:00
{
2006-06-19 23:27:12 +00:00
ControlItemUId * pNewItem = new ControlItemUId ( m_pSIds - > GetObject ( nWin ) - > pData - > Kurzname , m_pSIds - > GetObject ( nWin ) - > pData - > aUId ) ;
AddToListByNr ( m_pReverseSlots , pNewItem ) ;
2002-11-18 14:54:26 +00:00
}
}
WinInfoRec * pWinInfo = new WinInfoRec ;
2004-07-06 11:08:11 +00:00
pWinInfo - > aUId = aUId . GetText ( ) ;
2004-01-19 16:52:32 +00:00
pWinInfo - > nRType = ( USHORT ) nLNr1 ; // just ULONG for Transport, data is always USHORT
2002-11-18 14:54:26 +00:00
pWinInfo - > aRName = aString1 ;
pWinInfo - > bIsReset = bBool1 ;
pWinInfo - > aKurzname . Erase ( ) ;
pWinInfo - > aSlotname . Erase ( ) ;
// eventuell den Kontext feststellen. Passiert nur beim ersten Eintrag nach reset
2006-06-19 23:27:12 +00:00
if ( ! pReverseControlsKontext & & m_pReverseControlsSon )
2002-11-18 14:54:26 +00:00
{
USHORT nNr ;
ControlItem * pNewItem = new ControlItemUId ( String ( ) , aUId ) ;
2006-06-19 23:27:12 +00:00
if ( m_pReverseControlsSon - > Seek_Entry ( pNewItem , & nNr ) )
2002-11-18 14:54:26 +00:00
{
2006-06-19 23:27:12 +00:00
pReverseControlsKontext = ( ( ControlItemUIdSon * ) m_pReverseControlsSon - > GetObject ( nNr ) ) - > GetSons ( ) ;
2002-11-18 14:54:26 +00:00
pWinInfo - > aKurzname = CUniString ( " * " ) ;
}
else
2006-06-19 23:27:12 +00:00
pReverseControlsKontext = m_pReverseControls ;
2002-11-18 14:54:26 +00:00
delete pNewItem ;
}
2007-04-26 08:40:15 +00:00
// Reset. Mu<4D> nach bestimmen des Kontext stehen, da sonst mit dem reset-record
2002-11-18 14:54:26 +00:00
// 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 ) )
2004-07-06 11:08:11 +00:00
{
// SmartId aID = pReverseControlsKontext->GetObject(nNr)->pData->aUId;
2002-11-18 14:54:26 +00:00
pWinInfo - > aKurzname + = pReverseControlsKontext - > GetObject ( nNr ) - > pData - > Kurzname ;
2004-07-06 11:08:11 +00:00
}
2002-11-18 14:54:26 +00:00
delete pNewItem ;
}
// Slotname feststellen
2006-06-19 23:27:12 +00:00
if ( m_pReverseSlots )
2002-11-18 14:54:26 +00:00
{
USHORT nNr ;
ControlItem * pNewItem = new ControlItemUId ( String ( ) , aUId ) ;
2006-06-19 23:27:12 +00:00
if ( m_pReverseSlots - > Seek_Entry ( pNewItem , & nNr ) )
pWinInfo - > aSlotname = m_pReverseSlots - > GetObject ( nNr ) - > pData - > Kurzname ;
2002-11-18 14:54:26 +00:00
delete pNewItem ;
}
// Langname feststellen
2004-09-09 16:24:31 +00:00
if ( aUId . HasString ( ) )
{ // use the String ID since there is no LongName in hid.lst
pWinInfo - > aLangname = aUId . GetStr ( ) ;
}
else
2002-11-18 14:54:26 +00:00
{
2006-06-19 23:27:12 +00:00
if ( m_pReverseUIds )
2004-07-06 11:08:11 +00:00
{
USHORT nNr ;
ControlItem * pNewItem = new ControlItemUId ( String ( ) , aUId ) ;
2006-06-19 23:27:12 +00:00
if ( m_pReverseUIds - > Seek_Entry ( pNewItem , & nNr ) )
pWinInfo - > aLangname = m_pReverseUIds - > GetObject ( nNr ) - > pData - > Kurzname ;
2004-07-06 11:08:11 +00:00
delete pNewItem ;
}
}
2002-11-18 14:54:26 +00:00
aWinInfoHdl . Call ( pWinInfo ) ;
delete pWinInfo ;
}
break ;
case RET_ProfileInfo :
{
2004-07-06 11:08:11 +00:00
ULONG nUId = aUId . GetNum ( ) ;
2002-11-18 14:54:26 +00:00
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
{
2004-01-19 16:52:32 +00:00
pImpl - > nNumBorders = ( USHORT ) nLNr1 ; // Borders are 0 to 4
2002-11-18 14:54:26 +00:00
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 ;
2003-04-15 14:54:42 +00:00
# if OSL_DEBUG_LEVEL > 1
2002-11-18 14:54:26 +00:00
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.
{
2007-04-26 08:40:15 +00:00
if ( pImpl - > nNumBorders = = 0 ) // Also keine alte R<> ckmeldung vom Office
2002-11-18 14:54:26 +00:00
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 :
{
2004-07-06 11:08:11 +00:00
ULONG nUId = aUId . GetNum ( ) ;
2002-11-18 14:54:26 +00:00
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 ;
2003-03-18 15:03:50 +00:00
case S_QAError :
{
ADD_QA_ERROR_LOG ( aString1 ) ;
}
break ;
2002-11-18 14:54:26 +00:00
default :
;
}
}
break ;
case RET_MacroRecorder :
{
SortControlsByNumber ( TRUE ) ;
String aCommand , aControls , aControl , aULongNames , aULongName ;
BOOL bWriteNewKontext = FALSE ;
aControls . Erase ( ) ;
// Kurzname feststellen
2006-06-19 23:27:12 +00:00
if ( m_pReverseControls )
2002-11-18 14:54:26 +00:00
{
USHORT nNr ;
ControlItem * pNewItem = new ControlItemUId ( String ( ) , aUId ) ;
2006-06-19 23:27:12 +00:00
if ( m_pReverseControls - > Seek_Entry ( pNewItem , & nNr ) )
aControls = m_pReverseControls - > GetObject ( nNr ) - > pData - > Kurzname ;
2002-11-18 14:54:26 +00:00
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 ) )
{
2006-06-19 23:27:12 +00:00
if ( m_pReverseControls )
2002-11-18 14:54:26 +00:00
{
USHORT nNr ;
2004-07-06 11:08:11 +00:00
ControlItem * pNewItem = new ControlItemUId ( String ( ) , SmartId ( nLNr1 ) ) ;
2006-06-19 23:27:12 +00:00
if ( m_pReverseControls - > Seek_Entry ( pNewItem , & nNr ) )
aULongNames = m_pReverseControls - > GetObject ( nNr ) - > pData - > Kurzname ;
2002-11-18 14:54:26 +00:00
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
2004-01-19 16:52:32 +00:00
USHORT i ;
2002-11-18 14:54:26 +00:00
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 )
{
2006-06-19 23:27:12 +00:00
String aKontextCommand = CUniString ( " Kontext " ) ;
2002-11-18 14:54:26 +00:00
if ( aLastRecordedKontext . Len ( ) )
{
2006-06-19 23:27:12 +00:00
aKontextCommand . AppendAscii ( " \" " ) ;
aKontextCommand + = aLastRecordedKontext ;
aKontextCommand . AppendAscii ( " \" " ) ;
2002-11-18 14:54:26 +00:00
}
2006-06-19 23:27:12 +00:00
aKontextCommand . AppendAscii ( " \n " ) ;
aWriteStringHdl . Call ( & aKontextCommand ) ;
2002-11-18 14:54:26 +00:00
}
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 ;
2004-07-06 11:08:11 +00:00
SmartId aUId ;
if ( pRetStream - > GetNextType ( ) = = BinString )
{
String aUStrId ; // UniqueStringID Used for Mozilla Integration
pRetStream - > Read ( aUStrId ) ;
aUId = SmartId ( aUStrId ) ;
}
else
{
2006-04-19 13:00:00 +00:00
comm_ULONG nUId ;
2004-07-06 11:08:11 +00:00
pRetStream - > Read ( nUId ) ; // bei Sequence einfach die Sequence
aUId = SmartId ( nUId ) ;
}
2002-11-18 14:54:26 +00:00
pRetStream - > Read ( aString ) ;
ReplaceNumbers ( aString ) ;
String aShortName ;
2004-07-06 11:08:11 +00:00
aShortName = pShortNames - > GetName ( aUId ) ;
2002-11-18 14:54:26 +00:00
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 + + )
2004-09-09 16:24:31 +00:00
if ( Controls : : pClasses - > GetObject ( nElement ) - > pData - > aUId . Matches ( nMethodId ) )
2002-11-18 14:54:26 +00:00
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 + + )
2004-09-09 16:24:31 +00:00
if ( CmdStream : : pKeyCodes - > GetObject ( nElement ) - > pData - > aUId . Matches ( nKeyCode ) )
2002-11-18 14:54:26 +00:00
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 ;
2006-06-19 23:27:12 +00:00
xub_StrLen nStart = STRING_NOTFOUND ;
xub_StrLen nGleich = STRING_NOTFOUND ;
xub_StrLen nEnd = STRING_NOTFOUND ;
2003-12-01 17:18:38 +00:00
xub_StrLen nStartPos = 0 ;
2002-11-18 14:54:26 +00:00
ULONG nNumber ;
2003-12-01 17:18:38 +00:00
String aType ;
String aResult ;
2002-11-18 14:54:26 +00:00
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 ) ;
2004-01-19 16:52:32 +00:00
nNumber = ( ULONG ) aText . Copy ( nGleich + 1 , nEnd - nGleich - 1 ) . ToInt64 ( ) ;
2002-11-18 14:54:26 +00:00
bFound = FALSE ;
if ( aType . CompareTo ( UIdKenn ) = = COMPARE_EQUAL )
{
2004-07-06 11:08:11 +00:00
aResult = pShortNames - > GetName ( SmartId ( nNumber ) ) ;
2002-11-18 14:54:26 +00:00
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 + + )
2004-09-09 16:24:31 +00:00
if ( pRCommands - > GetObject ( nElement ) - > pData - > aUId . Matches ( nNumber ) )
2002-11-18 14:54:26 +00:00
{
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 + + )
2004-09-09 16:24:31 +00:00
if ( pRTypes - > GetObject ( nElement ) - > pData - > aUId . Matches ( nNumber ) )
2002-11-18 14:54:26 +00:00
{
aResult = pRTypes - > GetObject ( nElement ) - > pData - > Kurzname ;
nElement = pRTypes - > Count ( ) ;
}
}
}
if ( aType . CompareTo ( SlotKenn ) = = COMPARE_EQUAL )
{
2004-07-06 11:08:11 +00:00
aResult = pShortNames - > GetName ( SmartId ( nNumber ) ) ;
2002-11-18 14:54:26 +00:00
bFound = TRUE ;
}
if ( aType . CompareTo ( TabKenn ) = = COMPARE_EQUAL )
{
if ( nNumber > nStart )
2004-01-19 16:52:32 +00:00
aResult . Fill ( ( USHORT ) nNumber - nStart + 1 ) ;
2002-11-18 14:54:26 +00:00
else
aResult = CUniString ( " " ) ;
bFound = TRUE ;
}
nStartPos = nStart ;
if ( bFound )
{
aText . Erase ( nStart , nEnd + EndKenn . Len ( ) - nStart ) ;
aText . Insert ( aResult , nStart ) ;
2006-10-12 10:19:00 +00:00
nStartPos = nStartPos + aResult . Len ( ) ;
2002-11-18 14:54:26 +00:00
}
else
2006-10-12 10:19:00 +00:00
nStartPos = nStartPos + StartKenn . Len ( ) ;
2002-11-18 14:54:26 +00:00
}
}
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 ;
}
2004-07-06 11:08:11 +00:00
ControlDef WhatName ( rSymbol , SmartId ( ) ) ;
2002-11-18 14:54:26 +00:00
if ( bWasControl )
{
if ( ! Controls : : pClasses ) // Ist static, wird also nur einmal geladen
ReadFlatArray ( Controls : : arClasses , Controls : : pClasses ) ;
2004-12-10 16:14:13 +00:00
if ( Controls : : pClasses & & Controls : : pClasses - > Seek_Entry ( & WhatName )
| | rSymbol . EqualsIgnoreCaseAscii ( " ID " )
| | rSymbol . EqualsIgnoreCaseAscii ( " Name " ) )
2002-11-18 14:54:26 +00:00
return TT_METHOD ;
else
return TT_NOMETHOD ;
}
// Die Controls durchsuchen
2006-06-19 23:27:12 +00:00
if ( m_pControls )
2002-11-18 14:54:26 +00:00
{
USHORT nWin ;
2006-06-19 23:27:12 +00:00
for ( nWin = 0 ; nWin < m_pControls - > Count ( ) ; nWin + + )
2002-11-18 14:54:26 +00:00
{
2006-06-19 23:27:12 +00:00
if ( ( ( ControlDef * ) m_pControls - > GetObject ( nWin ) ) - > SonSeek_Entry ( & WhatName ) )
2002-11-18 14:54:26 +00:00
return TT_CONTROL ;
}
}
// Die Slots durchsuchen
2006-06-19 23:27:12 +00:00
if ( m_pSIds & & m_pSIds - > Seek_Entry ( & WhatName ) )
2002-11-18 14:54:26 +00:00
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
2007-06-19 13:37:13 +00:00
# define P_FEHLERLISTE TestToolObj::pFehlerListe
2002-11-18 14:54:26 +00:00
2006-06-19 23:27:12 +00:00
Controls : : Controls ( String aCName )
: SbxObject ( aCName )
2002-11-18 14:54:26 +00:00
{
pMethodVar = new SbxTransportMethod ( SbxVARIANT ) ;
2006-04-19 13:15:58 +00:00
pMethodVar - > SetName ( CUniString ( " Dummy " ) ) ;
2002-11-18 14:54:26 +00:00
Insert ( pMethodVar ) ;
// pMethodVar = Make( CUniString("Dummy"), SbxCLASS_PROPERTY, SbxULONG );
}
Controls : : ~ Controls ( )
{ }
2006-06-19 23:27:12 +00:00
void Controls : : ChangeListener ( SbxObject * parent )
2002-11-18 14:54:26 +00:00
{
EndListening ( pMethodVar - > GetBroadcaster ( ) , TRUE ) ;
2006-06-19 23:27:12 +00:00
parent - > StartListening ( pMethodVar - > GetBroadcaster ( ) , TRUE ) ;
2002-11-18 14:54:26 +00:00
}
void Controls : : SFX_NOTIFY ( SfxBroadcaster & , const TypeId & ,
2006-06-19 23:27:12 +00:00
const SfxHint & , const TypeId & )
2002-11-18 14:54:26 +00:00
{ }
2006-06-19 23:27:12 +00:00
SbxVariable * Controls : : Find ( const String & aStr , SbxClassType aType )
2002-11-18 14:54:26 +00:00
{
if ( ! pClasses ) // Ist static, wird also nur einmal geladen
ReadFlatArray ( arClasses , pClasses ) ;
if ( GetUserData ( ) = = ID_ErrorDummy )
{
2006-06-19 23:27:12 +00:00
pMethodVar - > SetName ( UniString ( GetName ( ) ) . AppendAscii ( " . " ) . Append ( aStr ) ) ;
2002-11-18 14:54:26 +00:00
pMethodVar - > SetUserData ( ID_ErrorDummy ) ;
return pMethodVar ;
}
USHORT nElement ;
2006-06-19 23:27:12 +00:00
ControlDef WhatName ( aStr , SmartId ( ) ) ;
2002-11-18 14:54:26 +00:00
if ( pClasses & & pClasses - > Seek_Entry ( & WhatName , & nElement ) )
{
2006-06-19 23:27:12 +00:00
pMethodVar - > SetName ( aStr ) ;
2004-07-06 11:08:11 +00:00
ULONG nUId = pClasses - > GetObject ( nElement ) - > pData - > aUId . GetNum ( ) ;
2002-11-18 14:54:26 +00:00
pMethodVar - > nValue = nUId ;
2004-12-10 16:14:13 +00:00
pMethodVar - > SetUserData ( GetUserData ( ) ) ;
2002-11-18 14:54:26 +00:00
return pMethodVar ;
}
else
{ // mainly for ID and name
2006-06-19 23:27:12 +00:00
SbxVariableRef Old = SbxObject : : Find ( aStr , aType ) ;
2002-11-18 14:54:26 +00:00
if ( Old )
return Old ;
2006-06-19 23:27:12 +00:00
else if ( aStr . EqualsIgnoreCaseAscii ( " ID " ) )
2002-11-18 14:54:26 +00:00
return NULL ; // suppress generation of error in this case
}
2006-06-19 23:27:12 +00:00
ADD_ERROR ( SbxERR_BAD_METHOD , GEN_RES_STR2 ( S_UNKNOWN_METHOD , GetName ( ) , aStr ) ) ;
2002-11-18 14:54:26 +00:00
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 " ) ;
}