summaryrefslogtreecommitdiff
path: root/automation
diff options
context:
space:
mode:
authorMartin Hollmichel <mh@openoffice.org>2002-11-18 14:54:26 +0000
committerMartin Hollmichel <mh@openoffice.org>2002-11-18 14:54:26 +0000
commitf3621897d465fa7e4ae01dda93c074e1896ecc61 (patch)
tree3ec6c642877704644ffa8816222165ad21e24c29 /automation
parent4c7c7dc4716363014dc2dcad679df44dfabe24b4 (diff)
add: testtool, #104916#
Diffstat (limited to 'automation')
-rw-r--r--automation/source/testtool/cmdstrm.cxx463
-rw-r--r--automation/source/testtool/cmdstrm.hxx121
-rw-r--r--automation/source/testtool/cretstrm.cxx103
-rw-r--r--automation/source/testtool/cretstrm.hxx92
-rw-r--r--automation/source/testtool/filter.pl317
-rw-r--r--automation/source/testtool/makefile.mk124
-rw-r--r--automation/source/testtool/objtest.cxx3881
-rw-r--r--automation/source/testtool/objtest.hxx394
-rw-r--r--automation/source/testtool/tcommuni.cxx231
-rw-r--r--automation/source/testtool/tcommuni.hxx100
10 files changed, 5826 insertions, 0 deletions
diff --git a/automation/source/testtool/cmdstrm.cxx b/automation/source/testtool/cmdstrm.cxx
new file mode 100644
index 000000000000..79f8b19ca7f3
--- /dev/null
+++ b/automation/source/testtool/cmdstrm.cxx
@@ -0,0 +1,463 @@
+/*************************************************************************
+ *
+ * $RCSfile: cmdstrm.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: mh $ $Date: 2002-11-18 15:53:31 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2002
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2002 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2002 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _KEYCOD_HXX //autogen
+#include <vcl/keycod.hxx>
+#endif
+#ifndef _SBXCLASS_HXX //autogen
+#include <svtools/sbx.hxx>
+#endif
+#ifndef _STREAM_HXX //autogen
+#include <tools/stream.hxx>
+#endif
+
+#include "cmdstrm.hxx"
+#include "rcontrol.hxx"
+#include "objtest.hxx"
+#include "svcommstream.hxx"
+#include <basic/testtool.hrc>
+
+
+ControlDefLoad __READONLY_DATA CmdStream::arKeyCodes [] =
+#include <keycodes.hxx>
+CNames *CmdStream::pKeyCodes = NULL;
+
+CmdStream::CmdStream()
+{
+ pSammel = new SvMemoryStream();
+ pCommStream = new SvCommStream( pSammel );
+}
+
+CmdStream::~CmdStream()
+{
+ delete pCommStream;
+ delete pSammel;
+}
+
+
+#define PUT_CHAR(ch) \
+ USHORT nMCode = nModify + ch; \
+ USHORT _Code = 1; \
+ if ( (nMCode & 0xFF) == 0 ) \
+ _Code |= 2; \
+ if ( (nMCode >> 8) == 0 ) \
+ _Code |= 4; \
+ Result += (char) _Code; \
+ Result += (char) ( nMCode & 0xFF ); \
+ Result += (char) ( nMCode >> 8 )
+
+
+String CmdStream::WandleKeyEventString( String aKeys )
+{
+ if ( !pKeyCodes )
+ ReadFlatArray(arKeyCodes,pKeyCodes);
+ if ( !pKeyCodes )
+ return aKeys;
+
+ xub_StrLen nPos1 = 0;
+ while ( (nPos1 = aKeys.Search('<',nPos1)) != STRING_NOTFOUND)
+ {
+ xub_StrLen nPos2 = aKeys.Search('>',nPos1);
+ if ( nPos2 != STRING_NOTFOUND )
+ {
+ String Work = aKeys.Copy(nPos1+1,nPos2-nPos1+1-2);
+ aKeys.Erase(nPos1,nPos2-nPos1+1); // Inclusive Spitze Klammern weg
+ String Result, Token;
+ USHORT nModify = 0;
+ while ( Work.Len() > 0 )
+ {
+ Token = Work.GetToken(0,' ');
+ Work.Erase(0,Token.Len()+1);
+ ControlDef WhatName(Token,0);
+ USHORT nElement;
+ if (pKeyCodes->Seek_Entry(&WhatName,&nElement))
+ {
+ USHORT nCode = (USHORT) pKeyCodes->GetObject(nElement)->pData->aUId.GetULONG();
+ if ( nCode >= KEY_SHIFT )
+ nModify ^= nCode;
+ else
+ {
+ if ( ( nModify == KEY_SHIFT || nModify == 0 ) &&
+ (((nCode & 0xFF00) == KEYGROUP_NUM) ||
+ ((nCode & 0xFF00) == KEYGROUP_ALPHA) ||
+ ( nCode == KEY_SPACE) ||
+ ( nCode == KEY_ADD) ||
+ ( nCode == KEY_SUBTRACT) ||
+ ( nCode == KEY_MULTIPLY) ||
+ ( nCode == KEY_DIVIDE) ||
+ ( nCode == KEY_POINT) ||
+ ( nCode == KEY_COMMA) ||
+ ( nCode == KEY_LESS) ||
+ ( nCode == KEY_GREATER) ||
+ ( nCode == KEY_EQUAL) ) )
+ {
+ switch ( nCode )
+ {
+ case KEY_SPACE: Token = ' '; break;
+ case KEY_ADD: Token = '+'; break;
+ case KEY_SUBTRACT: Token = '-'; break;
+ case KEY_MULTIPLY: Token = '*'; break;
+ case KEY_DIVIDE: Token = '/'; break;
+ case KEY_POINT: Token = '.'; break;
+ case KEY_COMMA: Token = ','; break;
+ case KEY_LESS: Token = '<'; break;
+ case KEY_GREATER: Token = '>'; break;
+ case KEY_EQUAL: Token = '='; break;
+ default:
+// if ( nModify == 0 )
+// Token.ToLower();
+// else
+// Token.ToUpper();
+ ;
+ }
+ Result += Token;
+ }
+ else
+ {
+ PUT_CHAR (nCode);
+ }
+ }
+ }
+ else
+ {
+ Result += '<';
+ Result += Token;
+ Result += ' ';
+ Result += String( ResId( S_INVALID_KEYCODE ) );
+ Result += '>';
+ }
+ }
+ aKeys.Insert(Result,nPos1);
+ nPos1 += Result.Len();
+ }
+ else
+ nPos1 = aKeys.Len() + 1;
+ }
+
+ return aKeys;
+}
+
+
+void CmdStream::WriteSortedParams( SbxArray* rPar, BOOL IsKeyString )
+{
+ USHORT nParams = PARAM_NONE;
+ USHORT nNr1,nNr2,nNr3,nNr4;
+ ULONG nLNr1;
+ String aString1,aString2;
+ BOOL bBool1,bBool2;
+
+ if ( rPar )
+ {
+ for ( USHORT i = 1; i < rPar->Count() ; i++)
+ {
+ switch (rPar->Get( i )->GetType())
+ {
+ case SbxLONG: // alles immer als Short übertragen
+ case SbxULONG:
+ case SbxLONG64:
+ case SbxULONG64:
+ case SbxDOUBLE:
+ case SbxINTEGER:
+ case SbxBYTE:
+ case SbxUSHORT:
+ case SbxINT:
+ case SbxUINT:
+ case SbxSINGLE:
+ if ( (nParams & PARAM_USHORT_1) == 0 )
+ {
+ nParams |= PARAM_USHORT_1;
+ nNr1 = rPar->Get( i )->GetUShort();
+ }
+ else if ( (nParams & PARAM_USHORT_2) == 0 )
+ {
+ nParams |= PARAM_USHORT_2;
+ nNr2 = rPar->Get( i )->GetUShort();
+ }
+ else if ( (nParams & PARAM_USHORT_3) == 0 )
+ {
+ nParams |= PARAM_USHORT_3;
+ nNr3 = rPar->Get( i )->GetUShort();
+ }
+ else if ( (nParams & PARAM_USHORT_4) == 0 )
+ {
+ nParams |= PARAM_USHORT_4;
+ nNr4 = rPar->Get( i )->GetUShort();
+ }
+ else
+ SbxBase::SetError( SbxERR_WRONG_ARGS );
+ break;
+ case SbxOBJECT: // außer bei Umschalten einer TabPage
+ if ( nParams & PARAM_ULONG_1 )
+ SbxBase::SetError( SbxERR_WRONG_ARGS );
+ else
+ {
+ nParams |= PARAM_ULONG_1;
+ nLNr1 = rPar->Get( i )->GetULong();
+ }
+ break;
+ case SbxSTRING:
+ case SbxCHAR:
+ if ( nParams & PARAM_STR_1 )
+ if ( nParams & PARAM_STR_2 )
+ SbxBase::SetError( SbxERR_WRONG_ARGS );
+ else
+ {
+ nParams |= PARAM_STR_2;
+ aString2 = rPar->Get( i )->GetString();
+ }
+ else
+ {
+ nParams |= PARAM_STR_1;
+ aString1 = rPar->Get( i )->GetString();
+ }
+ break;
+ case SbxBOOL:
+ if ( nParams & PARAM_BOOL_1 )
+ if ( nParams & PARAM_BOOL_2 )
+ SbxBase::SetError( SbxERR_WRONG_ARGS );
+ else
+ {
+ nParams |= PARAM_BOOL_2;
+ bBool2 = rPar->Get( i )->GetBool();
+ }
+ else
+ {
+ nParams |= PARAM_BOOL_1;
+ bBool1 = rPar->Get( i )->GetBool();
+ }
+ break;
+ default:
+ SbxBase::SetError( SbxERR_WRONG_ARGS );
+ break;
+ }
+ }
+ }
+ Write (nParams);
+ if( nParams & PARAM_USHORT_1 ) Write( nNr1 );
+ if( nParams & PARAM_USHORT_2 ) Write( nNr2 );
+ if( nParams & PARAM_USHORT_3 ) Write( nNr3 );
+ if( nParams & PARAM_USHORT_4 ) Write( nNr4 );
+ if( nParams & PARAM_ULONG_1 ) Write( nLNr1 );
+ if( nParams & PARAM_STR_1 ) Write( aString1, IsKeyString );
+ if( nParams & PARAM_STR_2 ) Write( aString2, IsKeyString );
+ if( nParams & PARAM_BOOL_1 ) Write( bBool1 );
+ if( nParams & PARAM_BOOL_2 ) Write( bBool2 );
+}
+
+void CmdStream::GenCmdCommand( USHORT nNr, SbxArray* rPar )
+{
+ Write(USHORT(SICommand));
+ Write(nNr);
+ WriteSortedParams(rPar, (nNr & M_KEY_STRING) != 0 );
+}
+
+void CmdStream::GenCmdSlot( USHORT nNr, SbxArray* rPar )
+{
+ Write(USHORT(SISlot));
+ Write(nNr);
+ if (rPar)
+ {
+ USHORT nAnz = (rPar->Count()-1) >> 1; // Geteilt durch 2
+ Write(nAnz);
+ BOOL bWriteUnoSlot = rPar->Get( 1 )->GetType() == SbxSTRING;
+
+ for (USHORT n = 1 ; n <= nAnz ; n++)
+ {
+ /// #59513# nicht mehr benötigt
+// ULONG nUserData = rPar->Get( 2*n-1 )->GetUserData();
+// rPar->Get( 2*n-1 )->SetUserData(ID_DoNothing); // Verhindert Ausführung der Slots, die als Parameter übergeben sind.
+
+ if ( bWriteUnoSlot )
+ Write(rPar->Get( 2*n-1 )->GetString());
+ else
+ Write(rPar->Get( 2*n-1 )->GetUShort());
+ switch (rPar->Get( 2*n )->GetType())
+ {
+ case SbxINTEGER:
+ case SbxBYTE:
+ case SbxUSHORT:
+ case SbxINT:
+ case SbxUINT:
+ case SbxSINGLE:
+ if ( !bWriteUnoSlot )
+ Write( (USHORT)BinUSHORT );
+ Write(rPar->Get( 2*n )->GetUShort());
+ break;
+ case SbxLONG:
+ case SbxULONG:
+ case SbxLONG64:
+ case SbxULONG64:
+ case SbxDOUBLE:
+ if ( !bWriteUnoSlot )
+ Write( (USHORT)BinULONG );
+ Write(rPar->Get( 2*n )->GetULong());
+ break;
+ case SbxSTRING:
+ case SbxCHAR:
+ if ( !bWriteUnoSlot )
+ Write( (USHORT)BinString);
+ Write((String)rPar->Get( 2*n )->GetString()); // Cast für OS/2
+ break;
+ case SbxBOOL:
+ if ( !bWriteUnoSlot )
+ Write( (USHORT)BinBool);
+ Write(rPar->Get( 2*n )->GetBool());
+ break;
+ default:
+ SbxBase::SetError( SbxERR_WRONG_ARGS );
+ break;
+ }
+
+ /// #59513# nicht mehr benötigt ( siehe oben )
+// rPar->Get( 2*n-1 )->SetUserData(nUserData); // Und wieder zurücksetzen, so daß auch alles sauber ist.
+ }
+ }
+ else
+ Write(USHORT(0));
+}
+
+void CmdStream::GenCmdUNOSlot( const String &aURL )
+{
+ Write( USHORT(SIUnoSlot) );
+/* Write( USHORT(0) ); // Hier wird im Office die SID_OPENURL Eingetragen.
+ // Dies muß natürlich im Office hart verdratet werden und nicht hier,
+ // da sich die ID ja mal ändern kann.
+
+ // Da auch die ID für das PoolItem im Office entnommen werden muß hier also kein PoolItem
+ // gesendet werden.
+
+ Write( USHORT(0) ); // Anzahl PoolItems
+
+ // Stattdessen wird noch eine extra String gesendet, der dann Officeseitig in ein
+ // SfxStringItem mit entsprechender ID gewandelt wird.
+ Write( aURL ); // String für das PoolItem*/
+
+ Write( aURL ); // Die UNO URL eben
+}
+
+void CmdStream::GenCmdControl( ULONG nUId, USHORT nMethodId, SbxArray* rPar )
+{
+ Write(USHORT(SIControl));
+ Write(nUId);
+ Write(nMethodId);
+ WriteSortedParams(rPar, (nMethodId & M_KEY_STRING) != 0 );
+}
+
+void CmdStream::GenCmdControl( String aUId, USHORT nMethodId, SbxArray* rPar )
+{
+ Write(USHORT(SIStringControl));
+ Write(aUId);
+ Write(nMethodId);
+ WriteSortedParams(rPar, (nMethodId & M_KEY_STRING) != 0 );
+}
+
+void CmdStream::GenCmdFlow( USHORT nArt )
+{
+ Write(USHORT(SIFlow));
+ Write(nArt);
+ Write(USHORT(PARAM_NONE)); // Typ der folgenden Parameter
+}
+
+void CmdStream::GenCmdFlow( USHORT nArt, USHORT nNr1 )
+{
+ Write(USHORT(SIFlow));
+ Write(nArt);
+ Write(USHORT(PARAM_USHORT_1)); // Typ der folgenden Parameter
+ Write(nNr1);
+}
+
+void CmdStream::GenCmdFlow( USHORT nArt, ULONG nNr1 )
+{
+ Write(USHORT(SIFlow));
+ Write(nArt);
+ Write(USHORT(PARAM_ULONG_1)); // Typ der folgenden Parameter
+ Write(nNr1);
+}
+
+void CmdStream::GenCmdFlow( USHORT nArt, String aString1 )
+{
+ Write(USHORT(SIFlow));
+ Write(nArt);
+ Write(USHORT(PARAM_STR_1)); // Typ der folgenden Parameter
+ Write(aString1);
+}
+
+void CmdStream::Write( String aString, BOOL IsKeyString )
+{
+ if ( IsKeyString )
+ Write( WandleKeyEventString( aString ), FALSE );
+ else
+ Write( aString.GetBuffer(), aString.Len() );
+}
+
+SvMemoryStream* CmdStream::GetStream()
+{
+ return pSammel;
+}
+
+void CmdStream::Reset( ULONG nSequence )
+{
+ delete pCommStream;
+ delete pSammel;
+ pSammel = new SvMemoryStream();
+ pCommStream = new SvCommStream( pSammel );
+ GenCmdFlow (F_Sequence,nSequence);
+}
+
diff --git a/automation/source/testtool/cmdstrm.hxx b/automation/source/testtool/cmdstrm.hxx
new file mode 100644
index 000000000000..7f74bf83023b
--- /dev/null
+++ b/automation/source/testtool/cmdstrm.hxx
@@ -0,0 +1,121 @@
+/*************************************************************************
+ *
+ * $RCSfile: cmdstrm.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: mh $ $Date: 2002-11-18 15:53:37 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2002
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2002 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2002 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _CMDSTRM_HXX
+#define _CMDSTRM_HXX
+
+#include <objtest.hxx>
+#include <testapp.hxx>
+#include "cmdbasestream.hxx"
+
+class CmdStream : public CmdBaseStream
+{
+public:
+ CmdStream();
+ ~CmdStream();
+
+ void WriteSortedParams( SbxArray* rPar, BOOL IsKeyString = FALSE );
+
+ void GenCmdCommand( USHORT nNr, SbxArray* rPar );
+
+ void GenCmdSlot( USHORT nNr, SbxArray* rPar );
+
+ void GenCmdUNOSlot( const String &aURL );
+
+ void GenCmdControl( ULONG nUId, USHORT nMethodId, SbxArray* rPar );
+ void GenCmdControl( String aUId, USHORT nMethodId, SbxArray* rPar );
+
+/* void GenCmdControl (ULONG nUId, USHORT nMethodId = 0);
+ void GenCmdControl (ULONG nUId, USHORT nMethodId, String aString);
+ void GenCmdControl (ULONG nUId, USHORT nMethodId, String aString, USHORT nNr);
+ void GenCmdControl (ULONG nUId, USHORT nMethodId, String aString, BOOL bBool);
+ void GenCmdControl (ULONG nUId, USHORT nMethodId, USHORT nNr);
+ void GenCmdControl (ULONG nUId, USHORT nMethodId, USHORT nNr1, USHORT nNr2);
+ void GenCmdControl (ULONG nUId, USHORT nMethodId, USHORT nNr, BOOL bBool);
+ void GenCmdControl (ULONG nUId, USHORT nMethodId, ULONG nNr);
+ void GenCmdControl (ULONG nUId, USHORT nMethodId, BOOL bBool);*/
+
+ void GenCmdFlow( USHORT nArt );
+ void GenCmdFlow( USHORT nArt, USHORT nNr1 );
+ void GenCmdFlow( USHORT nArt, ULONG nNr1 );
+ void GenCmdFlow( USHORT nArt, String aString1 );
+
+ void Reset(ULONG nSequence);
+
+ SvMemoryStream* GetStream();
+
+ static CNames *pKeyCodes; // Namen der Sondertasten MOD1, F1, LEFT ...
+ static ControlDefLoad __READONLY_DATA arKeyCodes [];
+
+private:
+ String WandleKeyEventString( String aKeys ); // Nutzt pKeyCodes. <RETURN> <SHIFT LEFT LEFT>
+
+// CmdBaseStream::Write;
+ void Write( comm_USHORT nNr ){CmdBaseStream::Write( nNr );}
+ void Write( comm_ULONG nNr ){CmdBaseStream::Write( nNr );}
+ void Write( const comm_UniChar* aString, comm_USHORT nLenInChars ){CmdBaseStream::Write( aString, nLenInChars );}
+ void Write( comm_BOOL bBool ){CmdBaseStream::Write( bBool );}
+// new
+ void Write( String aString, BOOL IsKeyString = FALSE );
+
+ SvMemoryStream *pSammel;
+};
+
+#endif
diff --git a/automation/source/testtool/cretstrm.cxx b/automation/source/testtool/cretstrm.cxx
new file mode 100644
index 000000000000..6941f5bf0a8e
--- /dev/null
+++ b/automation/source/testtool/cretstrm.cxx
@@ -0,0 +1,103 @@
+/*************************************************************************
+ *
+ * $RCSfile: cretstrm.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: mh $ $Date: 2002-11-18 15:53:42 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2002
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2002 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2002 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _CRetStream_HXX
+#include "cretstrm.hxx"
+#endif
+#ifndef _DEBUG_HXX //autogen
+#include <tools/debug.hxx>
+#endif
+#include "rcontrol.hxx"
+#include "svcommstream.hxx"
+
+
+SV_IMPL_REF(SbxBase)
+
+CRetStream::CRetStream(SvStream *pIn)
+{
+ pSammel = pIn;
+ delete pCommStream;
+ pCommStream = new SvCommStream( pSammel );
+}
+
+CRetStream::~CRetStream()
+{
+ delete pCommStream;
+}
+
+void CRetStream::Read ( String &aString )
+{
+ comm_UniChar* pStr;
+ USHORT nLenInChars;
+ Read( pStr, nLenInChars );
+
+ aString = String( pStr, nLenInChars );
+ delete [] pStr;
+}
+
+void CRetStream::Read( SbxValue &aValue )
+{
+ *pSammel >> nId;
+ if (nId != BinSbxValue) DBG_ERROR1( "Falscher Typ im Stream: Erwartet SbxValue, gefunden :%hu", nId );
+ SbxBaseRef xBase = SbxBase::Load( *pSammel );
+ if ( IS_TYPE( SbxValue, xBase ) )
+ aValue = *PTR_CAST( SbxValue, &xBase );
+}
+
diff --git a/automation/source/testtool/cretstrm.hxx b/automation/source/testtool/cretstrm.hxx
new file mode 100644
index 000000000000..0a7e851aa97e
--- /dev/null
+++ b/automation/source/testtool/cretstrm.hxx
@@ -0,0 +1,92 @@
+/*************************************************************************
+ *
+ * $RCSfile: cretstrm.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: mh $ $Date: 2002-11-18 15:53:48 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2002
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2002 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2002 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _CRETSTRM_HXX
+#define _CRETSTRM_HXX
+
+#ifndef _STREAM_HXX //autogen
+#include <tools/stream.hxx>
+#endif
+#ifndef _SBXVAR_HXX //autogen
+#include <svtools/sbxvar.hxx>
+#endif
+
+#include "cmdbasestream.hxx"
+
+class CRetStream : public CmdBaseStream
+{
+ SvStream *pSammel;
+ USHORT nId;
+
+public:
+ CRetStream( SvStream *pIn );
+ ~CRetStream();
+
+// CmdBaseStream::Read;
+ void Read ( comm_USHORT &nNr ){CmdBaseStream::Read ( nNr );}
+ void Read ( comm_ULONG &nNr ){CmdBaseStream::Read ( nNr );}
+ void Read ( comm_UniChar* &aString, comm_USHORT &nLenInChars ){CmdBaseStream::Read ( aString, nLenInChars );}
+ void Read ( comm_BOOL &bBool ){CmdBaseStream::Read ( bBool );}
+// new
+ void Read( String &aString );
+ void Read( SbxValue &aValue );
+};
+
+#endif
diff --git a/automation/source/testtool/filter.pl b/automation/source/testtool/filter.pl
new file mode 100644
index 000000000000..34fc323e9b7d
--- /dev/null
+++ b/automation/source/testtool/filter.pl
@@ -0,0 +1,317 @@
+#!/usr/bin/perl
+#*************************************************************************
+#*
+#* $RCSfile: filter.pl,v $
+#*
+#* $Revision: 1.1 $
+#*
+#* last change: $Author: mh $ $Date: 2002-11-18 15:53:53 $
+#*
+#* The Contents of this file are made available subject to the terms of
+#* either of the following licenses
+#*
+#* - GNU Lesser General Public License Version 2.1
+#* - Sun Industry Standards Source License Version 1.1
+#*
+#* Sun Microsystems Inc., October, 2002
+#*
+#* GNU Lesser General Public License Version 2.1
+#* =============================================
+#* Copyright 2002 by Sun Microsystems, Inc.
+#* 901 San Antonio Road, Palo Alto, CA 94303, USA
+#*
+#* This library is free software; you can redistribute it and/or
+#* modify it under the terms of the GNU Lesser General Public
+#* License version 2.1, as published by the Free Software Foundation.
+#*
+#* This library 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 for more details.
+#*
+#* You should have received a copy of the GNU Lesser General Public
+#* License along with this library; if not, write to the Free Software
+#* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+#* MA 02111-1307 USA
+#*
+#*
+#* Sun Industry Standards Source License Version 1.1
+#* =================================================
+#* The contents of this file are subject to the Sun Industry Standards
+#* Source License Version 1.1 (the "License"); You may not use this file
+#* except in compliance with the License. You may obtain a copy of the
+#* License at http://www.openoffice.org/license.html.
+#*
+#* Software provided under this License is provided on an "AS IS" basis,
+#* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING,
+#* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+#* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+#* See the License for the specific provisions governing your rights and
+#* obligations concerning the Software.
+#*
+#* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#*
+#* Copyright: 2002 by Sun Microsystems, Inc.
+#*
+#* All Rights Reserved.
+#*
+#* Contributor(s): _______________________________________
+#*
+#*
+#************************************************************************/
+
+$debug = "";
+$ctrue = 1;
+$cfalse = 0;
+$cskip = $ctrue;
+$cread = $cfalse;
+
+# keine umlaute
+# Berechnet den Ausdruck der durch den 1. Parameter Uebergeben wird.
+# Falls symbole nicht ersetzt werden koennen findet behandlung als Makro statt
+# Bricht im Fehlerfall das Programm ab
+sub calc_value {
+ $_ = $_[0];
+ s/(\||\+|\-|\*|\/|\(|\)|\<=|\>=|\!=|\>{1,2}|\<{1,2}|\={1,2})/ $1 /g; # Blanks um Operatoren einfuegen
+ s/^ *(.*) *$/$1/; # blanks vorn und hinten weg
+ s/\( *[a-zA-Z]* *\)//; # Casts auf Typen raus
+ @ops = split;
+ print join(",",@ops),"\n" if $debug;
+ @neuop = "";
+ foreach $op (@ops) {
+ if ($op !~ /^(\||\+|\-|\*|\/|\(|\)|\>{1,2}|\<{1,2}|\<=|\>=|\!=|\={1,2}|\d+|0[xX][0-9a-fA-F]+)$/) {
+ print "ersetze $op durch ",$symbol {$op},"\n" if $debug;
+ # Wenn kein Operand oder Zahl oder klammer
+ $op = $symbol {$op}; # zugriff auf assotiatives Array mit {}
+ } # ersetzen des Symbols durch seinen Wert
+ if ( defined ($op) ) {
+ push(@neuop,$op);
+ } else { # Symbol nicht gefunden -> Als Text uebernehmen
+ print "aborting calc_value : \"$_\"\n" if $debug;
+ return $_;
+ }
+ }
+ print @neuop,"\n" if $debug;
+ $_ = join(" ",@neuop);
+ print "$_\n" if $debug;
+ eval "\$value = $_"; # Eigentliche Berechnung des Wertes
+ if ($@) { die "$@ ($_)"; } # Fehlermeldung in $@ auswerten (Abbruch)
+ $value;
+}
+
+# liest einen Block
+# Parameter: FileHandle
+# Flag $skip ob Block .bersprungen werden soll oder Interpretiert
+# Flag $BlindSkip ob if oder else -Zweig (Dann untersuchen weiterer if-then-else)
+# Liste der Regular expressions die das Blockende darstellen.
+# bei #ifdef block waere das dann ("^#else\$","^#endif\$")
+
+sub read_block {
+
+ local($file,$skip,$BlindSkip,@patterns) = @_;
+ print "reading block '$file' $skip $BlindSkip @patterns ",scalar(@_),"\n" if $debug;
+ while (<$file>) {
+ chop;
+ s/\s*$//; # trailing whitespaces entfernen
+ s/\(USHORT\)//; # (USHORT) entfernen
+ print "Input : \"$_\"\n" if $debug;
+ s/\/\/.*//; # Zeilenkommentar entfernen
+# s/\/\*.*?\*\///g; # Kommentare inerhalb einer Zeile entfernen
+# erst ab perl 5
+ s/\s+/ /g; # Allen whitespace in einen blank aendern
+ s/ *$//; # Whitespace am Ende entfernen
+
+# Testen ob letzte Zeile erreicht wurde
+# Liefert auch im falle der ganzen Datei, also ohne RegExp das gewuenschte
+# Ergebnis.
+
+ foreach $patt (@patterns) { # Fuer jede der Expressions testen
+ print "Testing against $patt\n" if $debug;
+ print "Pattern fits: $patt\n" if $debug && /$patt/;
+ return $& if /$patt/; # Ruecksprung wenn die Zeile auf das Muster passt.
+ }
+
+ if ( $skip eq $cread || !$BlindSkip ) {
+
+ if ( /\/\*/ ) { # kommentarbeginn entdecken
+ $_ = $`; # Zeile auf restzeile vor kommantar setzen
+ $comment = $ctrue;
+ print "Kommantar erkannt\n" if $debug;
+ }
+ @line = split(/ /,$_,3); # Zeile Parsen und in @line speichern
+
+ $_ = $line[0]; # Default patternspace setzen
+ if (/^#/) { # Zeile faengt mit '#' an -> Praeprozessorbefehl
+ print "Bearbeite Zeile: @line\n" if $debug;
+ SELECT: { # SELECT ist hier frei gewaehlt
+
+ if (/#if/) { # Alle Ifbefehle (#if,#ifdef und #ifndef)
+ if ($skip) {
+ print "skipping nested if\n" if $debug;
+ $ende = &read_block ($file,$cskip,$cfalse,'^#else$','^#endif$');
+ print "skipping nested else\n" if $debug && $ende eq "#else";
+ &read_block ($file,$cskip,$cfalse,'^#endif$') if $ende eq "#else";
+ last SELECT;
+ }
+ if (/#if$/) {
+ $isif = &calc_value (join(" ",@line[1,2]));
+ } else {
+ $isif = defined ($symbol {$line[1]});
+ if (/#ifndef/) { $isif = ! $isif; }
+ }
+ if ( $isif ) {
+ print "if\n" if $debug;
+ $ende = &read_block ($file,$cread,$cfalse,'^#else$','^#endif$');
+ print "skipping else\n" if $debug && $ende eq "#else";
+ &read_block ($file,$cskip,$cfalse,'^#endif$') if $ende eq "#else";
+ } else {
+ print "skipping if\n" if $debug;
+ $ende = &read_block ($file,$cskip,$cfalse,'^#else$','^#endif$');
+ print "else\n" if $debug && $ende eq "#else";
+ &read_block ($file,$cread,$cfalse,'^#endif$') if $ende eq "#else";
+ }
+ print "endif\n" if $debug;
+ last SELECT;
+ }
+
+ last SELECT if $skip eq $cskip; #Der Rest ist egal (Skip von if und else)
+
+ if (/#define/) {
+# print join(",",%symbol),"\n";
+ if (defined ($symbol {$line[1]}) ) {
+ print "Symbol schon definiert: $line[1]\n";
+ }
+ else {
+ if (defined ($line[2])) {
+ $symbol {$line[1]} = &calc_value ($line[2]);
+ } else {
+ $symbol {$line[1]} = "";
+ }
+ print "setze $line[1] = ",$symbol {$line[1]},"\n" if $debug;
+ if ( $line[1] =~ /^$namefilter/ )
+ {
+ $mykey = $line[1];
+ $mykey =~ s/^$namefilter//;
+ $count += 1;
+ print OUT "$mykey ",$symbol {$line[1]},"\n";
+ print OUT2 "\t{ \"$mykey\", ",$symbol {$line[1]}," },\n";
+ }
+ }
+ last SELECT;
+ }
+
+
+ if (/#include/) {
+ $_ = $line[1];
+ s/<(.*)>/$1/; # < .. > entfernen
+ s/"(.*)"/$1/; # " .. " entfernene
+ &read_file ($_,$file);
+# print "Include abgeklemmt!!!\n" if $debug;
+ last SELECT;
+ }
+
+
+ if (/#pragma/) {
+ print "Pragma Ignoriert!!!\n" if $debug;
+ last SELECT;
+ }
+
+
+ if (/#error/) { die "Error: @line[1,2]\n";}
+
+ # Ansonsten Fehlermeldung
+ print "unbekannter Praeprozessorbefehl : \"$_\"\n";
+ }
+ }
+
+ if ($comment) {
+ &read_block ($file,$cskip,$ctrue,'\*\/');
+ print "After comment $skip\n" if $debug;
+ $comment = $cfalse;
+# redo main; # Schleifenrumpf mit Restzeile neu Durchlaufen
+# kann hier entfallen, da nur Praeprozessorbefehle vorhanden.
+ }
+ }
+ }
+ print "Leaving read_block at the end\n" if $debug;
+}
+
+sub convert_path {
+
+ $_ = $_[0];
+ $GUI = $ENV {"GUI"};
+ $use_shell = $ENV {"USE_SHELL"};
+ if ( $GUI eq "WNT" )
+ {
+ if ( defined( $use_shell ) && "$use_shell" eq "4nt" )
+ {
+ s/\//\\/g;
+ }
+ }
+ $_;
+}
+
+# Einlesen einer Datei.
+# der erste Parameter ist der Dateiname
+# Globale Variable %symbols enthaelt die Symboltabelle
+sub read_file {
+
+ local ($filename,$file) = @_;
+ $comment = $cfalse; # Am Dateianfang immer ausserhalb eines Kommentares
+ $file++; # String increment
+ local $TempFileName = &convert_path ($basename."/".$filename);
+ print "reading file $TempFileName as $file\n" if $debug;
+ if ( ! open($file, $TempFileName ))
+ {
+ print "Warning: Could not open file $TempFileName. ";
+ $TempFileName = &convert_path ($basename."/../".$filename);
+ print "Trying $TempFileName\n";
+ open($file, $TempFileName ) || print "Warning: Could not open file $TempFileName. Ignoring.\n" || return; #( die $basename."/../$filename $!" ) ; # Oeffnen der Datei zum lesen
+ }
+
+ &read_block($file,$cread,$cfalse); # Daten lesen
+ close($file);
+ print "done reading $filename\n" if $debug;
+}
+
+# Hauptprogramm beginnt hier
+
+
+print &convert_path ("//\n\n\n");
+
+
+%symbol = ""; # Assotiatives Array initialisieren
+
+$basename = ".";
+$basename = $ARGV[0] if defined($ARGV[0]);
+
+$filename = "app.hrc";
+$filename = $ARGV[1] if defined($ARGV[1]);
+
+
+$filebase = $filename;
+$filebase =~ s/\.[^.]+$//; # Schneidet den suffix ab
+$filebase = $ARGV[2] if defined($ARGV[2]);
+
+
+$namefilter = $ARGV[3] if defined($ARGV[3]);
+
+print "Generating $filebase:\n";
+
+$count = 0;
+
+open(OUT,">$filebase");
+open(OUT2,">$filebase.hxx");
+print OUT2 "\{\n";
+
+&read_file ($filename,"f00");
+
+print OUT2 "\t{ \"\" ,0 }\n\};\n";
+
+close(OUT);
+close(OUT2);
+
+if ( $count == 0 )
+{
+ die "Error: No Entries Found generating \"$filebase.hxx\". Testtool will not work!"
+}
diff --git a/automation/source/testtool/makefile.mk b/automation/source/testtool/makefile.mk
new file mode 100644
index 000000000000..9b52710d2791
--- /dev/null
+++ b/automation/source/testtool/makefile.mk
@@ -0,0 +1,124 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1 $
+#
+# last change: $Author: mh $ $Date: 2002-11-18 15:53:59 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2002
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2002 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library 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 for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc..
+#
+# Copyright: 2002 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..
+
+PRJNAME=basic
+TARGET=testtool
+
+# --- Settings ------------------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Allgemein ------------------------------------------------------------
+
+OBJFILES = \
+ $(OBJ)$/cmdstrm.obj \
+ $(OBJ)$/cretstrm.obj \
+ $(OBJ)$/objtest.obj \
+ $(OBJ)$/tcommuni.obj
+
+EXCEPTIONSFILES= \
+ $(OBJ)$/cmdstrm.obj \
+ $(OBJ)$/objtest.obj
+
+HXXFILES = $(INCCOM)$/keycodes.hxx \
+ $(INCCOM)$/classes.hxx \
+ $(INCCOM)$/r_cmds.hxx \
+ $(INCCOM)$/res_type.hxx
+
+# --- Targets ------------------------------------------------------------
+
+.INCLUDE : target.mk
+
+
+$(OBJFILES) : $(HXXFILES)
+$(HXXFILES) : $(MISC)$/xfilter.pl
+
+
+$(INCCOM)$/keycodes.hxx : $(SOLARVERSION)$/$(INPATH)$/inc$(UPDMINOREXT)$/vcl$/keycodes.hxx \
+ $(MISC)$/xfilter.pl
+ +$(PERL) $(MISC)$/xfilter.pl $(SOLARVERSION)$/$(INPATH)$/inc$(UPDMINOREXT) vcl$/keycodes.hxx $(INCCOM)$/keycodes KEY_
+
+$(INCCOM)$/classes.hxx : ..$/inc$/rcontrol.hxx \
+ $(MISC)$/xfilter.pl
+ +$(PERL) $(MISC)$/xfilter.pl ..$/inc rcontrol.hxx $(INCCOM)$/classes M_
+
+$(INCCOM)$/r_cmds.hxx : ..$/inc$/rcontrol.hxx \
+ $(MISC)$/xfilter.pl
+ +$(PERL) $(MISC)$/xfilter.pl ..$/inc rcontrol.hxx $(INCCOM)$/r_cmds RC_
+
+$(INCCOM)$/res_type.hxx : $(SOLARVERSION)$/$(INPATH)$/inc$(UPDMINOREXT)$/vcl$/wintypes.hxx \
+ $(MISC)$/xfilter.pl
+ +$(PERL) $(MISC)$/xfilter.pl $(SOLARVERSION)$/$(INPATH)$/inc$(UPDMINOREXT) vcl$/wintypes.hxx $(INCCOM)$/res_type WINDOW_
+
+
+
+$(MISC)$/xfilter.pl : filter.pl
+.IF "$(GUI)" == "UNX" || "$(USE_SHELL)"!="4nt"
+ +tr -d "\015" < filter.pl > $(MISC)$/xfilter.pl
+ chmod 664 $(MISC)$/xfilter.pl
+.ELSE
+ +$(COPY) filter.pl $(MISC)$/xfilter.pl
+ +attrib -r $(MISC)$/xfilter.pl
+.ENDIF
+
diff --git a/automation/source/testtool/objtest.cxx b/automation/source/testtool/objtest.cxx
new file mode 100644
index 000000000000..18639f49deb8
--- /dev/null
+++ b/automation/source/testtool/objtest.cxx
@@ -0,0 +1,3881 @@
+/*************************************************************************
+ *
+ * $RCSfile: objtest.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: mh $ $Date: 2002-11-18 15:54:04 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2002
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2002 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2002 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+/*#include <com/sun/star/devtools/XIServerProxy.hpp>
+#include <com/sun/star/devtools/XInformationClient.hpp>
+using namespace com::sun::star::devtools;
+*/
+
+#ifndef _OSL_FILE_HXX_
+#include <osl/file.hxx>
+#endif
+#ifndef _MSGBOX_HXX //autogen
+#include <vcl/msgbox.hxx>
+#endif
+#ifndef _SOUND_HXX //autogen
+#include <vcl/sound.hxx>
+#endif
+#ifndef _CONFIG_HXX //autogen
+#include <vcl/config.hxx>
+#endif
+#ifndef _APP_HXX //autogen
+#include <vcl/svapp.hxx>
+#endif
+#ifndef _SVTOOLS_STRINGTRANSFER_HXX_
+#include <svtools/stringtransfer.hxx>
+#endif
+#ifndef _SFXBRDCST_HXX
+#include <svtools/brdcst.hxx>
+#endif
+#ifndef _SBXCLASS_HXX //autogen
+#include <svtools/sbx.hxx>
+#endif
+#include <com/sun/star/uno/Any.hxx>
+#ifndef _COM_SUN_STAR_FRAME_XDESKTOP_HXX_
+#include <com/sun/star/frame/XDesktop.hpp>
+#endif
+#ifndef _COMPHELPER_PROCESSFACTORY_HXX_
+#include <comphelper/processfactory.hxx>
+#endif
+#include <com/sun/star/bridge/XBridgeFactory.hpp>
+#include <com/sun/star/connection/XConnector.hpp>
+#include <com/sun/star/connection/XConnection.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/uno/XNamingService.hpp>
+
+#include <cppuhelper/servicefactory.hxx>
+
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::frame;
+using namespace com::sun::star::bridge;
+using namespace com::sun::star::connection;
+using namespace rtl;
+
+
+#include <svtools/svmedit.hxx>
+#ifdef OS2
+#define INCL_DOSPROCESS
+//#include <vcl/sysdep.hxx>
+#ifndef _SVPM_H
+#include <tools/svpm.h>
+#endif
+#endif
+
+
+#include <basic/sbuno.hxx>
+
+//#include <basic/basrid.hxx>
+
+#ifndef _BASICRT_HXX
+#include <basic/basicrt.hxx>
+#endif
+#ifndef _BASIC_TTRESHLP_HXX
+#include <basic/ttstrhlp.hxx>
+#endif
+#include "tcommuni.hxx"
+
+#ifndef _CRETSTRM_HXX
+#include <cretstrm.hxx>
+#endif
+
+#include "objtest.hxx"
+#include "rcontrol.hxx"
+
+#include <basic/testtool.hrc>
+#include <basic/ttmsg.hrc>
+
+#include <basic/mybasic.hxx>
+#include <basic/testtool.hxx>
+
+#ifndef _SB_SBSTAR_HXX
+#include <basic/sbstar.hxx>
+#endif
+
+#include <algorithm>
+
+#ifndef SBX_VALUE_DECL_DEFINED
+#define SBX_VALUE_DECL_DEFINED
+SV_DECL_REF(SbxValue)
+#endif
+SV_IMPL_REF(SbxValue)
+
+
+#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;
+
+DBG_NAME( ControlItem )
+DBG_NAME( ControlDef )
+
+ControlItem::ControlItem( const sal_Char *Name, TTUniqueId aUIdP )
+{
+DBG_CTOR(ControlItem,0);
+ InitData();
+ pData->Kurzname.AssignAscii( Name );
+ pData->aUId = aUIdP;
+}
+
+ControlItem::ControlItem( const String &Name, TTUniqueId aUIdP )
+{
+DBG_CTOR(ControlItem,0);
+ InitData();
+ pData->Kurzname = Name;
+ pData->aUId = aUIdP;
+}
+
+/*ControlItem::ControlItem( const String &Name, const String &URL, const URLType aType )
+{
+DBG_CTOR(ControlItem,0);
+ InitData();
+ pData->Kurzname = Name;
+ pData->aURL = URL;
+ pData->nUId = aType;
+}
+
+ControlItem::ControlItem( const String &Name, const String &URL, const ULONG nUId )
+{
+DBG_CTOR(ControlItem,0);
+ InitData();
+ pData->Kurzname = Name;
+ pData->aURL = URL;
+ pData->nUId = nUId;
+}
+
+ControlItem::ControlItem( const char *Name, const String &URL, const ULONG nUId )
+{
+DBG_CTOR(ControlItem,0);
+ InitData();
+ pData->Kurzname.AssignAscii( Name );
+ pData->aURL = URL;
+ pData->nUId = nUId;
+} */
+
+
+ControlItem::ControlItem( ControlData *pDataP )
+{
+DBG_CTOR(ControlItem,0);
+ pData = pDataP;
+}
+
+ControlSon::~ControlSon()
+{
+ if (pSons)
+ {
+ delete pSons;
+ pSons = NULL;
+ }
+}
+
+ControlItemSon::ControlItemSon(const String &Name, TTUniqueId aUIdP )
+: ControlItem( Name, aUIdP )
+{}
+
+/*ControlItemSon::ControlItemSon(const String &Name, const String &URL, const URLType aType )
+: ControlItem( Name, URL, aType )
+{}
+
+ControlItemSon::ControlItemSon(const String &Name, const String &URL, const ULONG nUId )
+: ControlItem( Name, URL, nUId )
+{}
+
+ControlItemSon::ControlItemSon(const char *Name, const String &URL, const ULONG nUId )
+: ControlItem( Name, URL, nUId )
+{}*/
+
+
+
+BOOL ControlDef::operator < (const ControlItem &rPar)
+{
+ return pData->Kurzname.CompareIgnoreCaseToAscii(rPar.pData->Kurzname) == COMPARE_LESS;
+}
+
+BOOL ControlDef::operator == (const ControlItem &rPar)
+{
+ return pData->Kurzname.CompareIgnoreCaseToAscii(rPar.pData->Kurzname) == COMPARE_EQUAL;
+}
+
+void ControlDef::Write( SvStream &aStream )
+{
+ if ( pSons )
+ aStream.WriteByteString( String('*').Append( pData->Kurzname ), RTL_TEXTENCODING_UTF8 );
+ else
+ aStream.WriteByteString( pData->Kurzname, RTL_TEXTENCODING_UTF8 );
+ aStream << ((USHORT)pData->aUId.GetUIdType());
+ if ( pData->aUId.IsStrId() )
+ aStream.WriteByteString( pData->aUId.GetString(), RTL_TEXTENCODING_UTF8 );
+ else
+ aStream << pData->aUId.GetULONG();
+ if ( pSons )
+ for ( int i = 0 ; pSons->Count() > i ; i++ )
+ ((ControlDef*)(*pSons)[i])->Write(aStream);
+}
+
+ControlDef::ControlDef(const String &Name, TTUniqueId aUIdP )
+: ControlItemSon( Name, aUIdP)
+{
+ DBG_CTOR(ControlDef,0);
+}
+
+/*ControlDef::ControlDef(const String &Name, const String &URL, const URLType aType )
+: ControlItemSon( Name, URL, aType )
+{
+ DBG_CTOR(ControlDef,0);
+} */
+
+ControlDef::ControlDef(const String &aOldName, const String &aNewName, ControlDef *pOriginal, BOOL bWithSons )
+: ControlItemSon("", pOriginal->pData->aUId)
+{
+ DBG_CTOR(ControlDef,0);
+ if ( pOriginal->pData->Kurzname == aOldName )
+ pData->Kurzname = aNewName;
+ else
+ pData->Kurzname = pOriginal->pData->Kurzname;
+
+ if ( bWithSons && pOriginal->pSons )
+ {
+ pSons = new CNames();
+ for ( USHORT i = 0; i < pOriginal->pSons->Count() ; i++)
+ {
+ ControlDef *pNewDef;
+ pNewDef = new ControlDef( aOldName, aNewName, pOriginal->SonGetObject(i) ,TRUE );
+ if (! SonInsert(pNewDef))
+ {
+ DBG_ERROR("Name Doppelt im CopyConstructor. Neuer Name = Controlname!!");
+ delete pNewDef;
+ }
+ }
+
+ }
+ else
+ pSons = NULL;
+}
+
+BOOL ControlItemUId::operator < (const ControlItem &rPar)
+{
+ return pData->aUId < rPar.pData->aUId;
+}
+
+BOOL ControlItemUId::operator == (const ControlItem &rPar)
+{
+ return pData->aUId == rPar.pData->aUId;
+}
+
+SV_IMPL_OP_PTRARR_SORT( CNames, ControlItem* )
+
+void CRevNames::Insert( String aName, TTUniqueId aUId, ULONG nSeq )
+{
+ ControlItem *pRN = new ReverseName(aName,aUId,nSeq);
+ USHORT nPos;
+ if ( Seek_Entry(pRN,&nPos) )
+ DeleteAndDestroy(nPos);
+
+ if ( !CNames::C40_PTR_INSERT( ControlItem, pRN) )
+ {
+ DBG_ERROR("Interner Fehler beim Speichern der Lokalen KurzNamen");
+ delete pRN;
+ }
+
+}
+
+String CRevNames::GetName( TTUniqueId aUId )
+{
+ ReverseName *pRN = new ReverseName(UniString(),aUId,0);
+ USHORT nPos;
+ BOOL bSeekOK = Seek_Entry(pRN,&nPos);
+
+ delete pRN;
+ if ( bSeekOK )
+ return GetObject(nPos)->pData->Kurzname;
+ else
+ {
+ if ( !aUId.IsStrId() && aUId.GetULONG() == UID_ACTIVE )
+ return CUniString("Active");
+ else
+ return GEN_RES_STR1( S_NAME_NOT_THERE, aUId.GetString() );
+ }
+}
+
+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 )
+, pControls(NULL)
+, pReverseSlots(NULL)
+, pReverseControls(NULL)
+, pReverseControlsSon(NULL)
+, pReverseUIds(NULL)
+, pSIds(NULL)
+, pCommunicationManager(NULL)
+, bUseIPC(FALSE)
+, IsBlock(FALSE)
+, SingleCommandBlock(TRUE)
+//, bQuietErrors(TRUE)
+, bQuietErrors(FALSE)
+, bReturnOK(TRUE)
+, nSequence(KEEP_SEQUENCES)
+, ProgPath()
+, nIdleCount(0)
+, nWindowHandlerCallLevel(0)
+, aDialogHandlerName()
+, pFehlerListe(NULL)
+{
+ 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 )
+, pControls(NULL)
+, pReverseSlots(NULL)
+, pReverseControls(NULL)
+, pReverseControlsSon(NULL)
+, pReverseUIds(NULL)
+, pSIds(NULL)
+, pCommunicationManager(NULL)
+, bUseIPC(TRUE)
+, IsBlock(FALSE)
+, SingleCommandBlock(TRUE)
+//, bQuietErrors(TRUE)
+, bQuietErrors(FALSE)
+, bReturnOK(TRUE)
+, nSequence(KEEP_SEQUENCES)
+, ProgPath()
+, nIdleCount(0)
+, nWindowHandlerCallLevel(0)
+, aDialogHandlerName()
+, pFehlerListe(NULL)
+{
+ pImpl = new ImplTestToolObj;
+ pImpl->ProgParam = String();
+ pImpl->bIsStart = FALSE;
+ pImpl->pMyBasic = pBas;
+
+ LoadIniFile();
+ InitTestToolObj();
+
+ pCommunicationManager = new CommunicationManagerClientViaSocketTT();
+ pCommunicationManager->SetDataReceivedHdl( LINK( this, TestToolObj, ReturnResultsLink ));
+}
+
+void TestToolObj::LoadIniFile() // Laden der IniEinstellungen, die durch den ConfigDialog geändert werden können
+{
+#define GETSET(aVar, KeyName, Dafault) \
+ { \
+ ByteString __##aVar##__; \
+ __##aVar##__ = aConf.ReadKey(KeyName,"No Entry"); \
+ if ( __##aVar##__.Equals("No Entry") ) \
+ { \
+ __##aVar##__ = Dafault; \
+ aConf.WriteKey(KeyName, __##aVar##__); \
+ } \
+ aVar = UniString( __##aVar##__, RTL_TEXTENCODING_UTF8 );\
+ }
+
+ Config aConf(Config::GetConfigName( Config::GetDefDirectory(), CUniString("testtool") ));
+ aConf.SetGroup("Path");
+
+ String aFB;
+ DirEntry aDirEntry( CUniString( DEF_BASE_DIR ), FSYS_STYLE_VFAT );
+ ByteString aText = ByteString( aDirEntry.GetFull(), RTL_TEXTENCODING_UTF8 );
+ GETSET( aFB, "Basisverzeichnis", aText );
+ pImpl->aFileBase = DirEntry(aFB);
+
+ 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");
+ }
+
+ String aLFB;
+ GETSET( aLFB, "LogBasisverzeichnis", ByteString( aFB, RTL_TEXTENCODING_UTF8 ) );
+ pImpl->aLogFileBase = DirEntry(aLFB);
+
+ String aHID;
+
+ aDirEntry = DirEntry( CUniString(DEF_HID_DIR), FSYS_STYLE_VFAT );
+ aText = ByteString( aDirEntry.GetFull(), RTL_TEXTENCODING_UTF8 );
+ GETSET( aHID, "HIDVerzeichnis", aText );
+ pImpl->aHIDDir = DirEntry(aHID);
+
+
+ aConf.SetGroup("Misc");
+
+ String aST;
+ GETSET( aST, "ServerTimeout", ByteString::CreateFromInt64(Time(0,0,45).GetTime()) ); // 45 Sekunden Initial
+ pImpl->aServerTimeout = Time(aST.ToInt64());
+
+}
+
+#define MAKE_TT_KEYWORD( cName, aType, aResultType, nID ) \
+{ \
+ SbxVariableRef pMeth; \
+ pMeth = Make( CUniString(cName), aType, aResultType ); \
+ pMeth->SetUserData( nID ); \
+}
+
+#define MAKE_REMOTE_COMMAND(aName, aId) \
+ {\
+ SbxTransportMethod *pMeth = new SbxTransportMethod( SbxVARIANT ); \
+ pMeth->SetName( aName ); \
+ pMeth->SetUserData( ID_RemoteCommand ); \
+ pMeth->nValue = aId.GetULONG(); \
+ Insert( pMeth ); \
+ StartListening( pMeth->GetBroadcaster(), TRUE ); \
+ }
+
+// SetUserData muß irgendwas sein, sonst wird es im Find rausgefiltert!!!
+#define MAKE_USHORT_CONSTANT(cName, nValue) \
+ {\
+ SbxProperty *pVal = new SbxProperty( CUniString( cName) , SbxINTEGER ); \
+ pVal->PutInteger( nValue ) ; \
+ pVal->SetUserData( 32000 ); \
+ Insert( pVal ); \
+ }
+
+#define RTLNAME "@SBRTL" // copied from basic/source/classes/sb.cxx
+
+void TestToolObj::InitTestToolObj()
+{
+ pImpl->nNumBorders = 0; // Für Profiling mit kästchen
+
+ pImpl->nMinRemoteCommandDelay = 0;
+ pImpl->nMaxRemoteCommandDelay = 0;
+ pImpl->bDoRemoteCommandDelay = FALSE;
+
+ pImpl->bLnaguageExtensionLoaded= FALSE;
+ pImpl->pTTSfxBroadcaster = NULL;
+
+ pImpl->nErrorCount = 0;
+ pImpl->nWarningCount = 0;
+ pImpl->nIncludeFileWarningCount = 0;
+
+ pImpl->nTestCaseLineNr = 0;
+
+ pFehlerListe = new CErrors; // Vor allem anderen. Wer weiss, wer alles einen Fehler auslöst.
+
+ In = new CmdStream();
+
+ pShortNames = new CRevNames;
+
+
+// overwrite standard "wait" method, cause we can do better than that!!
+// Insert Object into SbiStdObject but change listening.
+ SbxVariable* pRTL = pImpl->pMyBasic->Find( CUniString(RTLNAME), SbxCLASS_DONTCARE );
+ SbxObject* pRTLObject = PTR_CAST( SbxObject, pRTL );
+ if ( pRTLObject )
+ {
+ SbxVariableRef pWait;
+ pWait = pRTLObject->Make( CUniString("Wait"), SbxCLASS_METHOD, SbxNULL );
+ pWait->SetUserData( ID_Wait );
+ // change listener here
+ pRTLObject->EndListening( pWait->GetBroadcaster(), TRUE );
+ StartListening( pWait->GetBroadcaster(), TRUE );
+ }
+ else
+ {
+ DBG_ERROR("Testtool: Could not replace Wait method")
+ }
+
+ MAKE_TT_KEYWORD( "Kontext", SbxCLASS_METHOD, SbxNULL, ID_Kontext );
+ MAKE_TT_KEYWORD( "GetNextError", SbxCLASS_VARIABLE, SbxVARIANT, ID_GetError );
+ MAKE_TT_KEYWORD( "Start", SbxCLASS_METHOD, SbxSTRING, ID_Start );
+// pMeth = Make( "Kill", SbxCLASS_METHOD, SbxNULL );
+// pMeth->SetUserData( ID_Kill );
+ /* pMeth = Make( "TestReset", SbxCLASS_METHOD, SbxNULL );
+ pMeth->SetUserData( ID_Reset );*/
+ MAKE_TT_KEYWORD( "Use", SbxCLASS_METHOD, SbxNULL, ID_Use );
+ MAKE_TT_KEYWORD( "StartUse", SbxCLASS_METHOD, SbxNULL, ID_StartUse );
+ MAKE_TT_KEYWORD( "FinishUse", SbxCLASS_METHOD, SbxNULL, ID_FinishUse );
+
+ MAKE_TT_KEYWORD( "CaseLog", SbxCLASS_METHOD, SbxNULL, ID_CaseLog );
+ MAKE_TT_KEYWORD( "ExceptLog", SbxCLASS_METHOD, SbxNULL, ID_ExceptLog );
+ MAKE_TT_KEYWORD( "PrintLog", SbxCLASS_METHOD, SbxNULL, ID_PrintLog );
+ MAKE_TT_KEYWORD( "WarnLog", SbxCLASS_METHOD, SbxNULL, ID_WarnLog );
+ MAKE_TT_KEYWORD( "ErrorLog", SbxCLASS_METHOD, SbxNULL, ID_ErrorLog );
+ MAKE_TT_KEYWORD( "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 );
+
+/* Dialog Handler werden gebraucht, wenn im internen Testtool ein Dialog
+ hochgerissen wird. Nach versenden der Remote-Kommandos wird IdleHandler aktiviert.
+ Er testet, ob das Reschedule zum WaitForAnswer zurückkehrt. Bleibt das aus, so
+ wird erst der RemoteHandler zurückgesetzt und dann die Handler-Sub im Basic
+ gerufen.(Entkoppelt über PostUserEvent.)
+
+ In returndaten_verarbeiten wird flag für ausführung des nächsten remote-befehls
+ rückgesetzt. Der Handler wird damit auch entwertet. Er gilt also nur für den
+ nächsten Remotebefehl.
+*/
+ MAKE_TT_KEYWORD( "DialogHandler", SbxCLASS_METHOD, SbxNULL, ID_DialogHandler );
+
+ MAKE_TT_KEYWORD( "GetUnoApp", SbxCLASS_METHOD, SbxOBJECT, ID_GetUnoApp );
+ MAKE_TT_KEYWORD( "GetIServer", SbxCLASS_METHOD, SbxOBJECT, ID_GetIServer );
+
+ MAKE_TT_KEYWORD( "RemoteCommandDelay", SbxCLASS_METHOD, SbxNULL, ID_RemoteCommandDelay );
+
+ MAKE_TT_KEYWORD( "GetApplicationPath", SbxCLASS_METHOD, SbxSTRING, ID_GetApplicationPath );
+ MAKE_TT_KEYWORD( "MakeIniFileName", SbxCLASS_METHOD, SbxSTRING, ID_MakeIniFileName );
+
+/// active constants returning error and warning count
+ MAKE_TT_KEYWORD( "GetErrorCount", SbxCLASS_METHOD, SbxULONG, ID_GetErrorCount );
+ MAKE_TT_KEYWORD( "GetWarningCount", SbxCLASS_METHOD, SbxULONG, ID_GetWarningCount );
+ MAKE_TT_KEYWORD( "GetUseFileWarningCount", SbxCLASS_METHOD, SbxULONG, ID_GetUseFileWarningCount );
+
+ 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 );
+
+ // 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++ )
+ MAKE_REMOTE_COMMAND( pRCommands->GetObject( i )->pData->Kurzname, pRCommands->GetObject( i )->pData->aUId );
+
+
+// Konstanten für SetControlType
+ MAKE_USHORT_CONSTANT("CTBrowseBox",CONST_CTBrowseBox);
+ MAKE_USHORT_CONSTANT("CTTreeListBox",CONST_CTTreeListBox);
+
+// Konstanten für das Alignment des gesuchten Splitters
+ MAKE_USHORT_CONSTANT("AlignLeft",CONST_ALIGN_LEFT);
+ MAKE_USHORT_CONSTANT("AlignTop",CONST_ALIGN_TOP);
+ MAKE_USHORT_CONSTANT("AlignRight",CONST_ALIGN_RIGHT);
+ MAKE_USHORT_CONSTANT("AlignBottom",CONST_ALIGN_BOTTOM);
+
+/// What bar to use in RC_ShowBar and RC_IsBarVisible
+ MAKE_USHORT_CONSTANT("MenuBar",CONST_MenuBar);
+ MAKE_USHORT_CONSTANT("ToolBar",CONST_ToolBar);
+ MAKE_USHORT_CONSTANT("LocationBar",CONST_LocationBar);
+ MAKE_USHORT_CONSTANT("PersonalBar",CONST_PersonalBar);
+
+/// 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);
+
+
+ pImpl->pControlsObj = new Controls( CUniString("GetNextCloseWindow") );
+ pImpl->pControlsObj -> SetType( SbxVARIANT );
+ pImpl->pControlsObj->SetUserData( ID_GetNextCloseWindow );
+ Insert( pImpl->pControlsObj ); // Hier so umständlich wegen Compilerfehlers
+ pImpl->pControlsObj->ChangeListener();
+
+ for ( i=0;i<VAR_POOL_SIZE;i++)
+ {
+/* pMyVar = new SbxObject( "Dummy" );
+ pMyVar -> SetType( SbxVARIANT );*/
+
+// pMyVar = new SbxMethod( "Dummy", SbxVARIANT );
+
+ pImpl->pMyVars[i] = new SbxTransportMethod( SbxVARIANT );
+ pImpl->pMyVars[i] -> SetName( CUniString("VarDummy").Append(String::CreateFromInt32(i) ) );
+
+ Insert( pImpl->pMyVars[i] );
+// StartListening( pMyVars[i]->GetBroadcaster(), TRUE );
+
+ pImpl->pControlsObj = new Controls( CUniString("ControlDummy").Append(String::CreateFromInt32(i) ) );
+ pImpl->pControlsObj -> SetType( SbxVARIANT );
+ Insert( pImpl->pControlsObj ); // Hier so umständlich wegen Compilerfehlers
+ pImpl->pControlsObj->ChangeListener();
+ pImpl->pControlsObjs[i] = pImpl->pControlsObj;
+ }
+
+ pControls = new CNames();
+ pSIds = new CNames();
+ pNameKontext = pControls;
+
+ nMyVar = 0;
+ nControlsObj = 0;
+
+
+
+
+// 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()
+{
+ EndListening( ((StarBASIC*)GetParent())->GetBroadcaster() );
+ pImpl->pNextReturn.Clear();
+
+ pImpl->pControlsObj.Clear();
+
+ for ( int i = 0 ; i < VAR_POOL_SIZE ; i++ )
+ {
+ pImpl->pMyVars[i].Clear();
+ pImpl->pControlsObjs[i].Clear();
+ }
+
+ if (pControls)
+ delete pControls;
+ if (pReverseSlots)
+ delete pReverseSlots;
+ if (pReverseControls)
+ delete pReverseControls;
+ if (pReverseControlsSon)
+ delete pReverseControlsSon;
+ if (pReverseUIds)
+ delete pReverseUIds;
+ if (pSIds)
+ delete pSIds;
+ if (pFehlerListe)
+ {
+ delete pFehlerListe;
+ pFehlerListe = NULL; // da pFehlerListe static ist!!
+ }
+ if ( pCommunicationManager )
+ {
+ pCommunicationManager->StopCommunication();
+ delete pCommunicationManager;
+ }
+ delete In;
+ if ( pImpl->pTTSfxBroadcaster )
+ delete pImpl->pTTSfxBroadcaster;
+ delete pShortNames;
+ delete pImpl;
+}
+
+SfxBroadcaster& TestToolObj::GetTTBroadcaster()
+{
+ if ( !pImpl->pTTSfxBroadcaster )
+ pImpl->pTTSfxBroadcaster = new SfxBroadcaster;
+ return *pImpl->pTTSfxBroadcaster;
+}
+
+void TestToolObj::ReadNames( String Filename, CNames *&pNames, CNames *&pUIds, BOOL bIsFlat )
+{
+/*******************************************************************************
+**
+** Folgende Dateiendungen sind vorhanden
+**
+** hid.lst Langname UId
+** *.sid Slot Ids Kurzname Langname Datei ist flach
+** *.win Controlname Langname Datei mit *name und +name Notation
+**
+**
+*******************************************************************************/
+
+
+ SvFileStream Stream;
+ String aLine,aName,aLongname;
+ TTUniqueId aUId;
+ xub_StrLen nLineNr;
+ USHORT nElement;
+ ControlDef *pNewDef, *pNewDef2;
+ ControlDef *pFatherDef = NULL;
+
+ nLineNr = 0; // Wir sind ja noch vor der Datei
+
+ if (! pUIds)
+ {
+ String aName = (pImpl->aHIDDir + DirEntry(CUniString("hid.lst"))).GetFull();
+ {
+ TTExecutionStatusHint aHint( TT_EXECUTION_SHOW_ACTION, String(ResId(S_READING_LONGNAMES)), aName );
+ GetTTBroadcaster().Broadcast( aHint );
+ }
+ ReadFlat( aName ,pUIds, TRUE );
+ if ( !pUIds )
+ return;
+ pNewDef = new ControlDef("Active",0);
+ if (! pUIds->C40_PTR_INSERT(ControlItem, (ControlItem*&)pNewDef))
+ {
+ ADD_WARNING_LOG2( GEN_RES_STR1c( S_DOUBLE_NAME, "Active" ) , Filename, nLineNr );
+ delete pNewDef;
+ }
+
+ }
+
+ ADD_MESSAGE_LOG( Filename );
+
+ Stream.Open(Filename, STREAM_STD_READ);
+ if (!Stream.IsOpen())
+ {
+ ADD_ERROR(ERR_NO_FILE,GEN_RES_STR1(S_CANNOT_OPEN_FILE, Filename));
+ return;
+ }
+
+ if ( bIsFlat && !pNames )
+ {
+ TTExecutionStatusHint aHint( TT_EXECUTION_SHOW_ACTION, String(ResId(S_READING_SLOT_IDS)), Filename );
+ GetTTBroadcaster().Broadcast( aHint );
+ }
+ else
+ {
+ TTExecutionStatusHint aHint( TT_EXECUTION_SHOW_ACTION, String(ResId(S_READING_CONTROLS)), Filename );
+ GetTTBroadcaster().Broadcast( aHint );
+ }
+
+ if ( !pNames )
+ pNames = new CNames();
+
+ {
+ TTExecutionStatusHint aHint( TT_EXECUTION_ENTERWAIT );
+ GetTTBroadcaster().Broadcast( aHint );
+ }
+ while (!Stream.IsEof())
+ {
+ nLineNr++;
+
+ Stream.ReadByteStringLine(aLine, RTL_TEXTENCODING_IBM_850);
+ aLine.EraseLeadingChars();
+ aLine.EraseTrailingChars();
+ while ( aLine.SearchAscii(" ") != STRING_NOTFOUND )
+ aLine.SearchAndReplaceAllAscii(" ",UniString(' '));
+ if (aLine.Len() == 0) continue;
+ if (aLine.Copy(0,4).CompareIgnoreCaseToAscii("Rem ") == COMPARE_EQUAL) continue;
+ if (aLine.Copy(0,1).CompareToAscii("'") == COMPARE_EQUAL) continue;
+
+ if ( (aLine.GetTokenCount(cMyDelim) < 2 || aLine.GetTokenCount(cMyDelim) > 3) && aLine.CompareIgnoreCaseToAscii("*Active") != COMPARE_EQUAL )
+ {
+ ADD_WARNING_LOG2( GEN_RES_STR1( S_INVALID_LINE, aLine ), Filename, nLineNr );
+ continue;
+ }
+
+ aName = aLine.GetToken(0,cMyDelim);
+ aLongname = aLine.GetToken(1,cMyDelim);
+
+ String aFirstAllowedExtra, aAllowed;
+ aFirstAllowedExtra.AssignAscii("+*");
+ aAllowed.AssignAscii("_");
+ xub_StrLen nIndex = 0;
+ BOOL bOK = TRUE;
+
+ while ( bOK && nIndex < aName.Len() )
+ {
+ sal_Unicode aChar = aName.GetChar( nIndex );
+ BOOL bOKThis = FALSE;
+ bOKThis |= ( aAllowed.Search( aChar ) != STRING_NOTFOUND );
+ if ( !nIndex )
+ bOKThis |= ( aFirstAllowedExtra.Search( aChar ) != STRING_NOTFOUND );
+ bOKThis |= ( aChar >= 'A' && aChar <= 'Z' );
+ bOKThis |= ( aChar >= 'a' && aChar <= 'z' );
+ bOKThis |= ( aChar >= '0' && aChar <= '9' );
+
+ bOK &= bOKThis;
+ nIndex++;
+ }
+ if ( !bOK )
+ {
+ ADD_WARNING_LOG2( CUniString("Zeile \"").Append(aLine).AppendAscii("\" enthält ungültige Zeichen."), Filename, nLineNr );
+ continue;
+ }
+
+ BOOL bUnoName = ( bIsFlat && ( aLongname.Copy( 0, 4 ).CompareIgnoreCaseToAscii( ".uno" ) == COMPARE_EQUAL
+ || aLongname.Copy( 0, 4 ).CompareIgnoreCaseToAscii( "http" ) == COMPARE_EQUAL ) );
+ BOOL bMozillaName = ( !bIsFlat && aLongname.Copy( 0, 4 ).CompareIgnoreCaseToAscii( ".moz" ) == COMPARE_EQUAL );
+
+ if ( aName.GetChar(0) == '+' ) // Kompletten Eintrag kopieren
+ {
+ aName.Erase(0,1);
+ ControlDef WhatName(aLongname,0);
+ ControlDef *OldTree;
+ if (pNames->Seek_Entry(&WhatName,&nElement))
+ {
+ OldTree = (ControlDef*)pNames->GetObject(nElement);
+ pNewDef = new ControlDef(aLongname,aName,OldTree,TRUE);
+
+ if (! pNames->C40_PTR_INSERT(ControlItem, (ControlItem*&)pNewDef))
+ {
+ ADD_WARNING_LOG2( GEN_RES_STR1( S_DOUBLE_NAME, aLine ), Filename, nLineNr );
+ delete pNewDef;
+ pFatherDef = NULL;
+ }
+ else
+ {
+ pFatherDef = pNewDef;
+ }
+ }
+ else
+ {
+ ADD_WARNING_LOG2( GEN_RES_STR1( S_SHORTNAME_UNKNOWN, aLine ), Filename, nLineNr );
+ continue;
+ }
+
+ }
+ else
+ {
+
+ if (aName.CompareIgnoreCaseToAscii("*Active") == COMPARE_EQUAL)
+ aUId = TTUniqueId( UID_ACTIVE );
+ else if ( !( ( bIsFlat && bUnoName ) || ( !bIsFlat && bMozillaName ) ) )
+ { // Bestimmen der ID aus der Hid.Lst
+ ControlDef WhatName(aLongname,0);
+ if (pUIds->Seek_Entry(&WhatName,&nElement))
+ aUId = pUIds->GetObject(nElement)->pData->aUId;
+ else
+ {
+ ADD_WARNING_LOG2( GEN_RES_STR1( S_LONGNAME_UNKNOWN, aLine ), Filename, nLineNr );
+ continue;
+ }
+ }
+ else
+ {
+ if ( bUnoName ) // Ist immer auch flat
+ aUId = TTUniqueId( aLongname, UID_UNO );
+ else if ( bMozillaName )
+ aUId = TTUniqueId( aLongname, UID_MOZILLA );
+ else
+ {
+ DBG_ERROR("Unknown URL schema")
+ }
+ }
+
+
+
+ if (aName.GetChar(0) == '*' || bIsFlat) // Globaler Kurzname (Dialogname oder SId)
+ {
+ if (!bIsFlat)
+ aName.Erase(0,1);
+
+/* if ( bUnoName ) // Ist immer auch flat
+ pNewDef = new ControlDef(aName,aLongname,UNO);
+ else if ( bMozillaName )
+ pNewDef = new ControlDef(aName,aLongname,MOZILLA);
+ else*/
+ pNewDef = new ControlDef(aName,aUId);
+
+ if (!bIsFlat)
+ {
+ pNewDef->Sons( new CNames() );
+
+/* if ( bUnoName ) // Ist immer auch flat
+ pNewDef2 = new ControlDef(aName,aLongname,UNO);
+ else if ( bMozillaName )
+ pNewDef2 = new ControlDef(aName,aLongname,MOZILLA);
+ else*/
+ pNewDef2 = new ControlDef(aName,aUId);
+ if (!pNewDef->SonInsert( pNewDef2 )) // Dialog in eigenen Namespace eintragen
+ {
+ delete pNewDef2;
+ DBG_ERROR(" !!!! ACHTUNG !!!! Fehler beim einfügen in leere Liste!");
+ }
+ }
+
+ if (! pNames->C40_PTR_INSERT(ControlItem, (ControlItem*&)pNewDef))
+ {
+ ADD_WARNING_LOG2( GEN_RES_STR1( S_DOUBLE_NAME, aLine ), Filename, nLineNr );
+ delete pNewDef;
+ pFatherDef = NULL;
+ }
+ else
+ {
+ pFatherDef = pNewDef;
+ }
+ }
+ else
+ {
+ if (!pFatherDef)
+ {
+ ADD_WARNING_LOG2( GEN_RES_STR0( S_FIRST_SHORTNAME_REQ_ASTRX ), Filename, nLineNr );
+ }
+ else
+ {
+/* if ( bUnoName ) // Ist immer auch flat
+ pNewDef = new ControlDef(aName,aLongname,UNO);
+ else if ( bMozillaName )
+ pNewDef = new ControlDef(aName,aLongname,MOZILLA);
+ else*/
+ pNewDef = new ControlDef(aName,aUId);
+ if (! pFatherDef->SonInsert(pNewDef))
+ {
+ ADD_WARNING_LOG2( GEN_RES_STR1( S_DOUBLE_NAME, aLine ), Filename, nLineNr );
+ delete pNewDef;
+ }
+ }
+ }
+ }
+ GetpApp()->Reschedule();
+ }
+ {
+ TTExecutionStatusHint aHint( TT_EXECUTION_LEAVEWAIT );
+ GetTTBroadcaster().Broadcast( aHint );
+ }
+ {
+ TTExecutionStatusHint aHint( TT_EXECUTION_HIDE_ACTION );
+ GetTTBroadcaster().Broadcast( aHint );
+ }
+
+ Stream.Close();
+}
+
+
+void TestToolObj::AddName(String &aBisher, String &aNeu )
+{
+ String aSl( '/' );
+ if ( UniString(aSl).Append(aBisher).Append(aSl).ToUpperAscii().Search( UniString(aSl).Append(aNeu).Append(aSl).ToUpperAscii() ) == STRING_NOTFOUND )
+ {
+ aBisher += aSl;
+ aBisher += aNeu;
+ }
+}
+
+
+void TestToolObj::ReadFlat( String Filename, CNames *&pNames, BOOL bSortByName )
+// Wenn bSortByName == FALSE, dann nach UId Sortieren (ControlItemUId statt ControlDef)
+{
+ SvFileStream Stream;
+ String aLine,aName;
+ TTUniqueId aUId;
+ xub_StrLen nLineNr;
+ ControlItem *pNewItem;
+ USHORT nDoubleCount = 0;
+
+ Stream.Open(Filename, STREAM_STD_READ);
+
+ if (!Stream.IsOpen())
+ {
+ ADD_ERROR(ERR_NO_FILE,GEN_RES_STR1(S_CANNOT_OPEN_FILE, Filename));
+ return;
+ }
+
+ nLineNr = 0; // Wir sind ja noch vor der Datei
+
+ if ( !pNames )
+ pNames = new CNames();
+
+ {
+ TTExecutionStatusHint aHint( TT_EXECUTION_ENTERWAIT );
+ GetTTBroadcaster().Broadcast( aHint );
+ }
+ ADD_MESSAGE_LOG( Filename );
+ while (!Stream.IsEof())
+ {
+ nLineNr++;
+
+ Stream.ReadByteStringLine(aLine, RTL_TEXTENCODING_IBM_850);
+ aLine.EraseLeadingChars();
+ aLine.EraseTrailingChars();
+ while ( aLine.SearchAscii(" ") != STRING_NOTFOUND )
+ aLine.SearchAndReplaceAllAscii(" ",UniString(' '));
+ if (aLine.Len() == 0) continue;
+
+ if ( (aLine.GetTokenCount(cMyDelim) < 2 || aLine.GetTokenCount(cMyDelim) > 3) && aLine.CompareIgnoreCaseToAscii("*Active") != COMPARE_EQUAL )
+ {
+ ADD_WARNING_LOG2( GEN_RES_STR1( S_INVALID_LINE, aLine ), Filename, nLineNr );
+ continue;
+ }
+
+ aName = aLine.GetToken(0,cMyDelim);
+ aUId = TTUniqueId( aLine.GetToken(1,cMyDelim).ToInt64() );
+
+ if ( bSortByName )
+ pNewItem = new ControlDef( aName, aUId );
+ else
+ pNewItem = new ControlItemUId( aName, aUId );
+ if ( !pNames->C40_PTR_INSERT( ControlItem, pNewItem ) )
+ {
+ if ( bSortByName )
+ {
+ if ( nDoubleCount++ < 10 )
+ {
+ ADD_WARNING_LOG2( GEN_RES_STR1( S_DOUBLE_NAME, aLine ), Filename, nLineNr );
+ }
+ }
+ else
+ {
+ USHORT nNr;
+ pNames->Seek_Entry( pNewItem, &nNr );
+ AddName( pNames->GetObject(nNr)->pData->Kurzname, pNewItem->pData->Kurzname );
+ }
+ delete pNewItem;
+ }
+ GetpApp()->Reschedule();
+ }
+ {
+ TTExecutionStatusHint aHint( TT_EXECUTION_LEAVEWAIT );
+ GetTTBroadcaster().Broadcast( aHint );
+ }
+
+ Stream.Close();
+#ifdef DBG_UTIL
+// int i;
+// for ( i = 0 ; i < pNames->Count() ; i++ )
+// {
+// DBG_ERROR( pNames->GetObject(i)->pData->Kurzname );
+// }
+#endif
+}
+
+void ReadFlatArray( const ControlDefLoad arWas [], CNames *&pNames )
+{
+ USHORT nIndex = 0;
+
+ if ( !pNames )
+ pNames = new CNames();
+
+ while ( String::CreateFromAscii(arWas[nIndex].Kurzname).Len() > 0 )
+ {
+ TTUniqueId aUId (arWas[nIndex].nUId);
+ const ControlItem *pX = new ControlDef( arWas[nIndex].Kurzname, aUId);
+ pNames->C40_PTR_INSERT(ControlItem, pX);
+ nIndex++;
+ }
+}
+
+void TestToolObj::WaitForAnswer ()
+{
+ if ( bUseIPC )
+ {
+ #ifdef DBG_UTIL
+ USHORT nSysWinModeMemo = GetpApp()->GetSystemWindowMode();
+ GetpApp()->SetSystemWindowMode( 0 );
+ ModelessDialog aDlg(NULL);
+ aDlg.SetOutputSizePixel(Size(200,0));
+ aDlg.SetText(CUniString("Waiting for Answer"));
+ aDlg.Show( TRUE, SHOW_NOFOCUSCHANGE | SHOW_NOACTIVATE );
+ GetpApp()->SetSystemWindowMode( nSysWinModeMemo );
+ #endif
+ BOOL bWasRealWait = !bReturnOK;
+ BasicRuntime aRun( NULL );
+ if ( BasicRuntimeAccess::HasRuntime() )
+ aRun = BasicRuntimeAccess::GetRuntime();
+
+ // this timer to terminate Yield below
+ Timer aTimer;
+ aTimer.SetTimeout( pImpl->aServerTimeout.GetMSFromTime() );
+ aTimer.Start();
+ while ( !bReturnOK && aTimer.IsActive() && pCommunicationManager->IsCommunicationRunning()
+ && aRun.IsValid() && aRun.IsRun() )
+ {
+ #ifdef OS2
+ DosSleep(100);
+ #endif
+ GetpApp()->Yield();
+ if ( BasicRuntimeAccess::HasRuntime() )
+ aRun = BasicRuntimeAccess::GetRuntime();
+ else
+ aRun = BasicRuntime( NULL );
+ }
+ if ( bWasRealWait && aDialogHandlerName.Len() > 0 ) // Damit das ganze auch im Testtool läuft
+ CallDialogHandler(GetpApp());
+ }
+ else
+ {
+ Time Ende;
+
+ Ende += pImpl->aServerTimeout;
+ SvStream *pTemp = NULL;
+
+ while ( !bReturnOK && Ende > Time() )
+ {
+// pTemp = PlugInApplication::GetPlugInApp()->GetReturnFromExecute();
+ if ( pTemp )
+ {
+ ReturnResults( pTemp );
+ bReturnOK = TRUE;
+ }
+ else
+ {
+ GetpApp()->Reschedule();
+ }
+ nIdleCount = 0;
+ }
+ }
+
+
+ if ( !bReturnOK )
+ {
+ ADD_ERROR(ERR_EXEC_TIMEOUT,GEN_RES_STR1(S_TIMOUT_WAITING, String::CreateFromInt64(nSequence)));
+ bReturnOK = TRUE;
+ nSequence++;
+ }
+}
+
+
+IMPL_LINK( TestToolObj, IdleHdl, Application*, pApp )
+{
+ if ( !bReturnOK )
+ nIdleCount++;
+ if ( nIdleCount > 10 ) // d.h. Schon 10 mal hier gewesen und noch keinmal im WaitForAnswer
+ {
+ GetpApp()->RemoveIdleHdl( LINK( this, TestToolObj, IdleHdl ) );
+ GetpApp()->PostUserEvent( LINK( this, TestToolObj, CallDialogHandler ) );
+ }
+ return 0;
+}
+
+IMPL_LINK( TestToolObj, CallDialogHandler, Application*, pApp )
+{
+ nWindowHandlerCallLevel++;
+ String aName(aDialogHandlerName);
+ aDialogHandlerName.Erase();
+
+ ULONG nRememberSequence = nSequence; // Da sich die Sequence im DialogHandler ändert
+ (StarBASIC*)GetParent()->Call( aName );
+ nSequence = nRememberSequence;
+ // Die Sequenznummern werden dann zwar doppelt vergeben, aber wen kümmerts.
+
+ nWindowHandlerCallLevel--;
+ return 0;
+}
+
+
+void TestToolObj::BeginBlock()
+{
+ WaitForAnswer();
+ if ( IsError() )
+ return;
+
+ DBG_ASSERT(!IsBlock,"BeginBlock innerhalb eines Blockes")
+ In->Reset(nSequence);
+ IsBlock = TRUE;
+}
+
+
+void TestToolObj::SendViaSocket()
+{
+ if ( !pCommunicationManager )
+ {
+ DBG_ERROR("Kein CommunicationManager vorhanden!!")
+ return;
+ }
+
+ if ( !pCommunicationManager->IsCommunicationRunning() )
+ if ( !pCommunicationManager->StartCommunication( ProgPath, pImpl->ProgParam ) )
+ {
+ ADD_ERROR(ERR_RESTART_FAIL,GEN_RES_STR1(S_APPLICATION_START_FAILED, ProgPath));
+ }
+ else
+ {
+ if ( !pImpl->bIsStart )
+ {
+ ADD_ERROR(ERR_RESTART,GEN_RES_STR0(S_APPLICATION_RESTARTED));
+ }
+ }
+
+
+ bReturnOK = FALSE;
+ if ( pCommunicationManager->GetLastNewLink() )
+ {
+ if ( !pCommunicationManager->GetLastNewLink()->TransferDataStream( In->GetStream() ) )
+ {
+ ADD_ERROR(ERR_SEND_TIMEOUT,GEN_RES_STR1(S_TIMOUT_SENDING, String::CreateFromInt64(nSequence)));
+ nSequence++;
+ bReturnOK = TRUE; // Kein Return zu erwarten
+ }
+ }
+ else
+ {
+ ADD_ERROR(ERR_SEND_TIMEOUT,GEN_RES_STR1(S_NO_CONNECTION, String::CreateFromInt64(nSequence)));
+ nSequence++;
+ bReturnOK = TRUE; // Kein Return zu erwarten
+ }
+
+}
+
+void TestToolObj::EndBlock()
+{
+ if (IsBlock)
+ {
+ pImpl->LocalStarttime = Time::GetSystemTicks(); // Setzen der Anfangszeit für Performancemessung
+
+ In->GenCmdFlow (F_EndCommandBlock);
+
+ if ( pImpl->bDoRemoteCommandDelay )
+ {
+ ULONG nTimeWait = pImpl->nMinRemoteCommandDelay;
+ if ( pImpl->nMaxRemoteCommandDelay != pImpl->nMinRemoteCommandDelay )
+ nTimeWait += Time::GetSystemTicks() % ( pImpl->nMaxRemoteCommandDelay - pImpl->nMinRemoteCommandDelay );
+ Timer aTimer;
+ aTimer.SetTimeout( nTimeWait );
+ aTimer.Start();
+ while ( aTimer.IsActive() && pCommunicationManager->IsCommunicationRunning() )
+ {
+ #ifdef OS2
+ DosSleep(100);
+ #endif
+ GetpApp()->Yield();
+ }
+ }
+
+ if ( bUseIPC )
+ SendViaSocket();
+ else
+ {
+// PlugInApplication::GetPlugInApp()->ExecuteRemoteStatements( In->GetStream() );
+ bReturnOK = FALSE;
+ if ( aDialogHandlerName.Len() > 0 )
+ GetpApp()->InsertIdleHdl( LINK( this, TestToolObj, IdleHdl ), 1 );
+ }
+ IsBlock = FALSE;
+ }
+ else
+ {
+ DBG_ERROR("EndBlock außerhalb eines Blockes")
+ }
+}
+
+
+BOOL TestToolObj::Load( String aName, SbModule *pMod )
+{
+ BOOL bOk = TRUE;
+ SvFileStream aStrm( aName, STREAM_STD_READ );
+ if( aStrm.IsOpen() )
+ {
+ String aText, aLine;
+ BOOL bIsFirstLine = TRUE;
+ rtl_TextEncoding aFileEncoding = RTL_TEXTENCODING_IBM_850;
+ while( !aStrm.IsEof() && bOk )
+ {
+ aStrm.ReadByteStringLine( aLine, aFileEncoding );
+ if ( bIsFirstLine && IsTTSignatureForUnicodeTextfile( aLine ) )
+ aFileEncoding = RTL_TEXTENCODING_UTF8;
+ else
+ {
+ if ( !bIsFirstLine )
+ aText += '\n';
+ aText += aLine;
+ bIsFirstLine = FALSE;
+ }
+ if( aStrm.GetError() != SVSTREAM_OK )
+ bOk = FALSE;
+ }
+ aText.ConvertLineEnd();
+ pMod->SetName(CUniString("--").Append(aName));
+
+ 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;
+ UIdType aUIdType;
+ TTUniqueId aUId;
+ ControlDef *pNewDef, *pNewDef2;
+ ControlDef *pFatherDef = NULL;
+
+
+ aStream.Open(Filename, STREAM_STD_READ);
+ if (!aStream.IsOpen())
+ {
+ ADD_ERROR(ERR_NO_FILE,GEN_RES_STR1(S_CANNOT_OPEN_FILE, Filename));
+ return FALSE;
+ }
+
+ if ( !pSIds )
+ pSIds = new CNames();
+ if ( !pControls )
+ pControls = new CNames();
+
+ {
+ TTExecutionStatusHint aHint( TT_EXECUTION_ENTERWAIT );
+ GetTTBroadcaster().Broadcast( aHint );
+ }
+
+ USHORT nAnz;
+ aStream >> nAnz;
+ CNames *pNames = pSIds; // first read all the slots
+ BOOL bIsFlat = TRUE; // Slots do not have children
+
+ while ( nAnz && !aStream.IsEof() )
+ {
+
+ aStream.ReadByteString( aName, RTL_TEXTENCODING_UTF8 );
+
+ USHORT nType;
+ aStream >> nType;
+ aUIdType = UIdType( nType );
+ if ( TTUniqueId::IsStrId( aUIdType ) )
+ {
+ String aStrId;
+ aStream.ReadByteString( aStrId, RTL_TEXTENCODING_UTF8 );
+ aUId = TTUniqueId( aStrId, aUIdType );
+ }
+ else
+ {
+ ULONG nUId;
+ aStream >> nUId;
+ aUId = TTUniqueId( nUId );
+ }
+
+ if (aName.GetChar(0) == '*' || bIsFlat ) // Globaler Kurzname (Dialogname oder SId)
+ {
+ if (!bIsFlat)
+ aName.Erase(0,1);
+ pNewDef = new ControlDef(aName,aUId);
+
+ if (!bIsFlat)
+ {
+ pNewDef->Sons(new CNames());
+
+ pNewDef2 = new ControlDef(aName,aUId); // Noch einen machen
+ if (!pNewDef->SonInsert(pNewDef2)) // Dialog in eigenen Namespace eintragen
+ {
+ delete pNewDef2;
+ DBG_ERROR(" !!!! ACHTUNG !!!! Fehler beim einfügen in leere Liste!");
+ }
+ }
+
+ if (! pNames->C40_PTR_INSERT(ControlItem, (ControlItem*&)pNewDef))
+ {
+ DBG_ERROR(" !!!! ACHTUNG !!!! Fehler beim einfügen eines namens!");
+ delete pNewDef;
+ pFatherDef = NULL;
+ }
+ else
+ {
+ pFatherDef = pNewDef;
+ }
+ }
+ else
+ {
+ if (!pFatherDef)
+ {
+ DBG_ERROR( "Internal Error: Erster Kurzname muß mit * beginnen. Überspringe." );
+ }
+ else
+ {
+ pNewDef = new ControlDef(aName,aUId);
+ if (! pFatherDef->SonInsert(pNewDef))
+ {
+ delete pNewDef;
+ DBG_ERROR(" !!!! ACHTUNG !!!! Fehler beim einfügen eines namens!");
+ }
+ }
+ }
+
+
+ nAnz--;
+ if ( !nAnz && bIsFlat ) // We have read all slots
+ {
+ aStream >> nAnz;
+ pNames = pControls; // Now read the controls
+ bIsFlat = FALSE; // Controls *do* have children
+ }
+
+
+ GetpApp()->Reschedule();
+ }
+ {
+ TTExecutionStatusHint aHint( TT_EXECUTION_LEAVEWAIT );
+ GetTTBroadcaster().Broadcast( aHint );
+ }
+
+ aStream.Close();
+ return TRUE;
+return FALSE;
+}
+
+
+BOOL TestToolObj::WriteNamesBin( String Filename, CNames *pSIds, CNames *pControls )
+{
+ BOOL bOk = TRUE;
+ SvFileStream aStrm( String(Filename).AppendAscii(".bin"), STREAM_STD_WRITE );
+ if( aStrm.IsOpen() )
+ {
+ int i;
+ if ( pSIds )
+ {
+ aStrm << pSIds->Count();
+ for ( i = 0 ; pSIds->Count() > i && bOk ; i++ )
+ {
+ ((ControlDef*)(*pSIds)[i])->Write(aStrm);
+ if( aStrm.GetError() != SVSTREAM_OK )
+ bOk = FALSE;
+ }
+ }
+ else
+ aStrm << USHORT( 0 );
+
+ if ( pControls )
+ {
+ aStrm << pControls->Count();
+ for ( i = 0 ; pControls->Count() > i && bOk ; i++ )
+ {
+ ((ControlDef*)(*pControls)[i])->Write(aStrm);
+ if( aStrm.GetError() != SVSTREAM_OK )
+ bOk = FALSE;
+ }
+ }
+ else
+ aStrm << USHORT( 0 );
+ }
+ else
+ bOk = FALSE;
+ return bOk;
+}
+
+
+void TestToolObj::SFX_NOTIFY( SfxBroadcaster&, const TypeId&,
+ const SfxHint& rHint, const TypeId& )
+{
+ static CNames *pUIds = NULL; // Halten der hid.lst
+
+ const SbxHint* p = PTR_CAST(SbxHint,&rHint);
+ if( p )
+ {
+ SbxVariable* pVar = p->GetVar();
+ SbxArray* rPar = pVar->GetParameters();
+
+ ULONG nHintId = p->GetId();
+ ULONG nUserData = pVar->GetUserData();
+ if( nHintId == SBX_HINT_DATAWANTED )
+ {
+ nMyVar = 0;
+ nControlsObj = 0;
+ switch( nUserData )
+ {
+ case ID_Kontext:
+ if ( !rPar )
+ {
+ pNameKontext = pControls;
+
+ // So daß nicht immer mal wieder was aus einem alten Kontext dazwischenhaut
+ for (USHORT i=0;i<VAR_POOL_SIZE;i++)
+ {
+ pImpl->pMyVars[i] -> SetName( CUniString("VarDummy").Append(UniString::CreateFromInt32(i)) );
+ pImpl->pControlsObjs[i] -> SetName( CUniString("ControlDummy").Append(UniString::CreateFromInt32(i)) );
+ }
+ }
+ else if ( rPar && rPar->Count() == 2 )
+ {
+ USHORT nElement;
+ SbxVariableRef pArg = rPar->Get( 1 );
+ String aKontext = pArg->GetString();
+ ControlDef WhatName(aKontext,0);
+ if (pControls->Seek_Entry(&WhatName,&nElement))
+ {
+ pNameKontext = ((ControlDef*)pControls->GetObject(nElement))->GetSons();
+
+ // So daß nicht immer mal wieder was aus einem alten Kontext dazwischenhaut
+ for (USHORT i=0;i<VAR_POOL_SIZE;i++)
+ {
+ pImpl->pMyVars[i] -> SetName( CUniString("VarDummy").Append(UniString::CreateFromInt32(i)) );
+ pImpl->pControlsObjs[i] -> SetName( CUniString("ControlDummy").Append(UniString::CreateFromInt32(i)) );
+ }
+ }
+ }
+ else
+ SetError( SbxERR_WRONG_ARGS );
+ break;
+ case ID_Start:
+ if ( rPar && rPar->Count() >= 2 )
+ {
+ SbxVariableRef pArg = rPar->Get( 1 );
+ ProgPath = pArg->GetString();
+ if ( rPar && rPar->Count() >= 3 )
+ {
+ pArg = rPar->Get( 2 );
+ pImpl->ProgParam = pArg->GetString();
+ }
+
+ String aTmpStr(ProgPath);
+ aTmpStr += ' ';
+ aTmpStr += pImpl->ProgParam;
+ TTExecutionStatusHint aHint( TT_EXECUTION_SHOW_ACTION, String(ResId(S_STARTING_APPLICATION)), aTmpStr );
+ GetTTBroadcaster().Broadcast( aHint );
+
+ pImpl->bIsStart = TRUE;
+ BeginBlock();
+ EndBlock();
+ pImpl->bIsStart = FALSE;
+ {
+ TTExecutionStatusHint aHint( TT_EXECUTION_HIDE_ACTION );
+ GetTTBroadcaster().Broadcast( aHint );
+ }
+ }
+ break;
+// case ID_Kill:
+// if ( !rPar ) // rPar = NULL <=> Kein Parameter
+// {
+// }
+// else
+// SetError( SbxERR_WRONG_ARGS );
+// break;
+ case ID_SaveIDs:
+ if ( rPar && rPar->Count() >= 2 ) // Genau ein Parameter
+ {
+ SbxVariableRef pArg = rPar->Get( 1 );
+ DirEntry FilePath = pImpl->aFileBase + DirEntry(pArg->GetString(),FSYS_STYLE_VFAT);
+ WriteNamesBin( FilePath.GetFull(), pSIds, pControls );
+ }
+ else
+ SetError( SbxERR_WRONG_ARGS );
+ break;
+ case ID_AutoExecute:
+ if ( !rPar ) // rPar = NULL <=> Kein Parameter
+ {
+ pVar->PutBool(SingleCommandBlock);
+ }
+ else
+ SetError( SbxERR_WRONG_ARGS );
+ break;
+ case ID_Execute:
+ if ( !rPar ) // rPar = NULL <=> Kein Parameter
+ {
+ EndBlock();
+ BeginBlock();
+ }
+ else
+ SetError( SbxERR_WRONG_ARGS );
+ break;
+ case ID_DialogHandler:
+ if ( rPar && rPar->Count() >= 2 ) // Genau ein Parameter
+ {
+ SbxVariableRef pArg = rPar->Get( 1 );
+ aDialogHandlerName = pArg->GetString();
+ }
+ else
+ SetError( SbxERR_WRONG_ARGS );
+ break;
+ case ID_GetError:
+ if ( !rPar ) // rPar = NULL <=> Kein Parameter
+ {
+ WaitForAnswer();
+ if ( IS_ERROR() )
+ {
+// pVar->PutULong( GET_ERROR()->nError );
+ pVar->PutString( GET_ERROR()->aText );
+ POP_ERROR();
+ }
+ else
+ {
+// pVar->PutULong( 0 );
+ pVar->PutString( String() );
+ }
+ }
+ else
+ SetError( SbxERR_WRONG_ARGS );
+ break;
+ case ID_StartUse:
+ if ( !rPar ) // rPar = NULL <=> Kein Parameter
+ {
+ BasicRuntime aRun = BasicRuntimeAccess::GetRuntime();
+ aLogFileName = DirEntry(aRun.GetModuleName(SbxNAME_NONE)).GetBase().AppendAscii(".res");
+
+ ADD_RUN_LOG();
+ ADD_CASE_LOG(GEN_RES_STR0(S_READING_FILE));
+
+ pCommunicationManager->StopCommunication();
+ // Wait for asynchronous events to be processed, so communication will be restarted properly
+ while ( pCommunicationManager->IsCommunicationRunning() )
+ Application::Reschedule();
+
+ SingleCommandBlock = TRUE; // Bug 57188
+ IsBlock = FALSE;
+
+// pCommunicationManager->StartCommunication();
+
+ for (USHORT i=0;i<VAR_POOL_SIZE;i++)
+ {
+ pImpl->pMyVars[i] -> SetName( CUniString("VarDummy").Append(UniString::CreateFromInt32(i)) );
+ pImpl->pControlsObjs[i] -> SetName( CUniString("ControlDummy").Append(UniString::CreateFromInt32(i)) );
+ }
+ nMyVar = 0;
+ nControlsObj = 0;
+
+ if (pControls)
+ {
+ delete pControls;
+ pControls = NULL;
+ }
+ if (pReverseSlots)
+ {
+ delete pReverseSlots;
+ pReverseSlots = NULL;
+ }
+ if (pReverseControls)
+ {
+ delete pReverseControls;
+ pReverseControls = NULL;
+ }
+ if (pReverseControlsSon)
+ {
+ delete pReverseControlsSon;
+ pReverseControlsSon = NULL;
+ }
+ if (pSIds)
+ {
+ delete pSIds;
+ pSIds = NULL;
+ }
+ if (pUIds)
+ {
+ delete pUIds;
+ pUIds = NULL;
+ }
+ if (pReverseUIds)
+ {
+ delete pReverseUIds;
+ pReverseUIds = NULL;
+ }
+ pNameKontext = pControls;
+ pImpl->bLnaguageExtensionLoaded = FALSE;
+ SfxSimpleHint aHint( SBX_HINT_LANGUAGE_EXTENSION_LOADED );
+ GetTTBroadcaster().Broadcast( aHint );
+
+ pImpl->nMinRemoteCommandDelay = 0;
+ pImpl->nMaxRemoteCommandDelay = 0;
+ pImpl->bDoRemoteCommandDelay = FALSE;
+ pImpl->aTestCaseName.Erase();
+ pImpl->aTestCaseFileName.Erase();
+ pImpl->nTestCaseLineNr = 0;
+ }
+ else
+ SetError( SbxERR_WRONG_ARGS );
+ break;
+ case ID_Use:
+ if ( rPar && rPar->Count() >= 2 )
+ {
+ SbxVariableRef pArg = rPar->Get( 1 );
+ DirEntry FilePath(pArg->GetString(),FSYS_STYLE_VFAT);
+ if ( !FilePath.IsAbs() )
+ FilePath = pImpl->aFileBase + FilePath;
+ String Ext = FilePath.GetExtension();
+ if ( Ext.CompareIgnoreCaseToAscii("Win") == COMPARE_EQUAL )
+ {
+ ReadNames( FilePath.GetFull(),pControls,pUIds);
+ pImpl->bLnaguageExtensionLoaded = TRUE;
+ SfxSimpleHint aHint( SBX_HINT_LANGUAGE_EXTENSION_LOADED );
+ GetTTBroadcaster().Broadcast( aHint );
+ }
+ else if ( Ext.CompareIgnoreCaseToAscii("Sid") == COMPARE_EQUAL )
+ {
+ ReadNames( FilePath.GetFull(),pSIds,pUIds,FLAT);
+ pImpl->bLnaguageExtensionLoaded = TRUE;
+ SfxSimpleHint aHint( SBX_HINT_LANGUAGE_EXTENSION_LOADED );
+ GetTTBroadcaster().Broadcast( aHint );
+ }
+ else if ( Ext.CompareIgnoreCaseToAscii("Bin") == COMPARE_EQUAL )
+ {
+ ReadNamesBin( FilePath.GetFull(), pSIds, pControls );
+ pImpl->bLnaguageExtensionLoaded = TRUE;
+ SfxSimpleHint aHint( SBX_HINT_LANGUAGE_EXTENSION_LOADED );
+ GetTTBroadcaster().Broadcast( aHint );
+ }
+ else if ( Ext.CompareIgnoreCaseToAscii("Inc") == COMPARE_EQUAL )
+ {
+ {
+ TTExecutionStatusHint aHint( TT_EXECUTION_SHOW_ACTION, String(ResId(S_READING_BASIC_MODULE)), FilePath.GetFull() );
+ GetTTBroadcaster().Broadcast( aHint );
+ }
+ String aFullPathname = FilePath.GetFull();
+ StarBASIC *pBasic = (StarBASIC*)GetParent();
+ if ( !aModuleWinExistsHdl.Call( &aFullPathname ) &&
+ !pBasic->FindModule( CUniString( "--" ).Append(aFullPathname) ) )
+ {
+ SbModule *pMod;
+ pMod = pBasic->MakeModule( CUniString("--"), String() );
+ pMod->Clear();
+ if ( Load( aFullPathname, pMod ) )
+ {
+ if ( !IS_ERROR() )
+ {
+ pBasic->Compile( pMod );
+ pMod->RunInit();
+ }
+ }
+ else
+ {
+ ADD_ERROR( SbxERR_CANNOT_LOAD, FilePath.GetFull() );
+ }
+ }
+ {
+ TTExecutionStatusHint aHint( TT_EXECUTION_HIDE_ACTION );
+ GetTTBroadcaster().Broadcast( aHint );
+ }
+ }
+ else
+ {
+ ADD_ERROR(SbxERR_CANNOT_LOAD,FilePath.GetFull());
+ }
+ }
+ else
+ SetError( SbxERR_WRONG_ARGS );
+ break;
+ case ID_FinishUse:
+ if ( !rPar ) // rPar = NULL <=> Kein Parameter
+ {
+ ADD_CASE_LOG( String() ); // Case abschliessen
+ if (!pControls)
+ pControls = new CNames();
+
+ if (!pSIds)
+ pSIds = new CNames();
+
+ if (pUIds)
+ { // save some memory
+ delete pUIds;
+ pUIds = NULL;
+ }
+
+ pNameKontext = pControls;
+
+ if ( pImpl->bLnaguageExtensionLoaded )
+ {
+ SfxSimpleHint aHint( SBX_HINT_LANGUAGE_EXTENSION_LOADED );
+ GetTTBroadcaster().Broadcast( aHint );
+ }
+
+ pImpl->nIncludeFileWarningCount = pImpl->nWarningCount;
+ pImpl->nWarningCount = 0;
+ }
+ else
+ SetError( SbxERR_WRONG_ARGS );
+ break;
+ case ID_CaseLog:
+ if ( rPar ) // rPar != NULL <=> Es gibt Parameter
+ {
+ USHORT n;
+ String aX;
+ for ( n = 1; n < rPar->Count(); n++ )
+ {
+ SbxVariableRef pArg = rPar->Get( n );
+ aX += pArg->GetString();
+ }
+ pImpl->aTestCaseName = aX;
+ if ( pImpl->aTestCaseName.Len() && BasicRuntimeAccess::HasRuntime() )
+ {
+ BasicRuntime aRun = BasicRuntimeAccess::GetRuntime();
+ pImpl->aTestCaseFileName = aRun.GetModuleName(SbxNAME_SHORT_TYPES);
+ if ( pImpl->aTestCaseFileName.Copy(0,2).CompareToAscii( "--" ) == COMPARE_EQUAL )
+ pImpl->aTestCaseFileName.Erase(0,2);
+ pImpl->nTestCaseLineNr = aRun.GetLine();
+ }
+ else
+ {
+ pImpl->aTestCaseFileName.Erase();
+ pImpl->nTestCaseLineNr = 0;
+ }
+ ADD_CASE_LOG( aX );
+ }
+ break;
+ case ID_ExceptLog:
+ if ( IS_ERROR() )
+ {
+ BasicRuntime aRun = BasicRuntimeAccess::GetRuntime();
+ BOOL bWasNewError = FALSE;
+
+ if ( BasicRuntimeAccess::HasStack() )
+ {
+ for ( USHORT i = 0 ; i < BasicRuntimeAccess::GetStackEntryCount() -1 ; i++ )
+ {
+ BasicErrorStackEntry aThisEntry = BasicRuntimeAccess::GetStackEntry(i);
+ if ( !bWasNewError )
+ {
+ bWasNewError = TRUE;
+ ADD_ERROR_LOG( GET_ERROR()->aText, aThisEntry.GetModuleName(SbxNAME_SHORT_TYPES),
+ aThisEntry.GetLine(), aThisEntry.GetCol1(), aThisEntry.GetCol2() );
+ }
+ ADD_CALL_STACK_LOG( String(aThisEntry.GetModuleName(SbxNAME_SHORT_TYPES))
+ .AppendAscii(": ").Append(aThisEntry.GetMethodName(SbxNAME_SHORT_TYPES)),
+ aThisEntry.GetModuleName(SbxNAME_SHORT_TYPES),
+ aThisEntry.GetLine(), aThisEntry.GetCol1(), aThisEntry.GetCol2() );
+
+ }
+ BasicRuntimeAccess::DeleteStack();
+ }
+
+ BOOL bIsFirst = TRUE;
+ while ( aRun.IsValid() )
+ {
+ xub_StrLen nErrLn;
+ xub_StrLen nCol1;
+ xub_StrLen nCol2;
+ if ( bIsFirst )
+ {
+ bIsFirst = FALSE;
+ nErrLn = GET_ERROR()->nLine;
+ nCol1 = GET_ERROR()->nCol1;
+ nCol2 = GET_ERROR()->nCol2;
+ }
+ else
+ {
+ nErrLn = aRun.GetLine();
+ nCol1 = aRun.GetCol1();
+ nCol2 = aRun.GetCol2();
+ }
+
+ if ( !bWasNewError )
+ {
+ bWasNewError = TRUE;
+ ADD_ERROR_LOG( GET_ERROR()->aText, aRun.GetModuleName(SbxNAME_SHORT_TYPES),
+ nErrLn, nCol1, nCol2 );
+ }
+ ADD_CALL_STACK_LOG( String(aRun.GetModuleName(SbxNAME_SHORT_TYPES))
+ .AppendAscii(": ").Append(aRun.GetMethodName(SbxNAME_SHORT_TYPES)),
+ aRun.GetModuleName(SbxNAME_SHORT_TYPES),
+ nErrLn, nCol1, nCol2 );
+ aRun = aRun.GetNextRuntime();
+ }
+ }
+ break;
+ case ID_ErrorLog:
+ if ( IS_ERROR() )
+ {
+ BasicRuntime aRun = BasicRuntimeAccess::GetRuntime();
+ if ( BasicRuntimeAccess::HasStack() )
+ {
+ BasicErrorStackEntry aThisEntry = BasicRuntimeAccess::GetStackEntry( 0 );
+ ADD_ERROR_LOG( GET_ERROR()->aText, aThisEntry.GetModuleName(SbxNAME_SHORT_TYPES),
+ aThisEntry.GetLine(), aThisEntry.GetCol1(), aThisEntry.GetCol2() );
+ BasicRuntimeAccess::DeleteStack();
+ }
+ else
+ {
+ ADD_ERROR_LOG( GET_ERROR()->aText, aRun.GetModuleName(SbxNAME_SHORT_TYPES),
+ StarBASIC::GetErl(), aRun.GetCol1(), aRun.GetCol2() );
+ }
+ }
+ break;
+ case ID_PrintLog:
+ if ( rPar ) // rPar != NULL <=> Es gibt Parameter
+ {
+ USHORT n;
+ String aSammel;
+ for ( n = 1; n < rPar->Count(); n++ )
+ {
+ SbxVariableRef pArg = rPar->Get( n );
+ aSammel += pArg->GetString();
+ }
+ ADD_MESSAGE_LOG( aSammel );
+ }
+ break;
+ case ID_WarnLog:
+ if ( rPar ) // rPar != NULL <=> Es gibt Parameter
+ {
+ USHORT n;
+ String aSammel;
+ for ( n = 1; n < rPar->Count(); n++ )
+ {
+ SbxVariableRef pArg = rPar->Get( n );
+ aSammel += pArg->GetString();
+ }
+ ADD_WARNING_LOG( aSammel );
+
+ }
+ break;
+ case ID_ClearError:
+ while ( IS_ERROR() )
+ {
+ POP_ERROR();
+ }
+ break;
+ case ID_MaybeAddErr:
+ if ( ((StarBASIC*)GetParent())->GetErr() && ( !IS_ERROR() ||
+ pFehlerListe->GetObject(pFehlerListe->Count()-1)->nError != ((StarBASIC*)GetParent())->GetErr() ) )
+ {
+ ((StarBASIC*)GetParent())->MakeErrorText(((StarBASIC*)GetParent())->GetErr(),String());
+ ADD_ERROR_QUIET(((StarBASIC*)GetParent())->GetErr() , ((StarBASIC*)GetParent())->GetErrorText())
+ }
+ break;
+ case ID_GetNextCloseWindow:
+ if ( !rPar ) // rPar = NULL <=> Kein Parameter
+ {
+ SetError( SbxERR_NOTIMP );
+ break;
+// Das ist total rotten und muß wohl komplett neu!!
+
+ BOOL bWasBlock = IsBlock;
+ if ( !IsBlock ) // Impliziter call bei Aufruf mit Methode
+ if ( SingleCommandBlock )
+ BeginBlock();
+// if ( !IsError() )
+// In->GenCmdSlot (128,rPar);
+// ((Controls*)pVar)->pMethodVar->nValue = 128;
+
+ ULONG nOldValue = ((Controls*)pVar)->GetULong();
+ // Setzen, so daß beim Return der Wert stimmt
+ ((Controls*)pVar)->PutULong( 128 );
+ pImpl->pNextReturn = ((Controls*)pVar)->pMethodVar;
+ if ( SingleCommandBlock )
+ EndBlock();
+ WaitForAnswer();
+ if ( bWasBlock )
+ if ( SingleCommandBlock )
+ BeginBlock();
+ ((Controls*)pVar)->PutULong( nOldValue );
+
+ // Rücksetzen, so daß beim nächsten Aufruf alles klappt
+// ((Controls*)pVar)->SetUserData( 128 );
+
+
+// ((Controls*)pVar)->SetName("xxx");
+ // Setzen und rücksetzen der ID, so dass der Notify ohne Wirkung bleibt.
+ ((Controls*)pVar)->pMethodVar->SetUserData(ID_ErrorDummy);
+ ((Controls*)pVar)->PutULong( ((Controls*)pVar)->pMethodVar->GetULong() );
+ ((Controls*)pVar)->pMethodVar->SetUserData(ID_Control);
+
+ pShortNames->Insert( CUniString("xxx"), ((Controls*)pVar)->pMethodVar->nValue, nSequence );
+
+ nOldValue = ((Controls*)pVar)->GetULong();
+
+ SbxVariable *pMember;
+ if ( ! (pMember = ((Controls*)pVar)->Find(CUniString("ID"),SbxCLASS_DONTCARE)) )
+ {
+ pMember = new SbxProperty(CUniString("ID"),SbxULONG);
+ ((Controls*)pVar)->Insert(pMember);
+ }
+ pMember->PutULong(((Controls*)pVar)->pMethodVar->nValue);
+
+ if ( ! (pMember = ((Controls*)pVar)->Find(CUniString("name"),SbxCLASS_DONTCARE)) )
+ {
+ pMember = NULL;
+ }
+ else
+ pMember->PutString(CUniString("xxx"));
+
+
+
+ }
+ else
+ SetError( SbxERR_WRONG_ARGS );
+ break;
+ case ID_RemoteCommand:
+ {
+ if ( SingleCommandBlock )
+ BeginBlock();
+ else
+ if ( ((SbxTransportMethod*)pVar)->nValue & M_WITH_RETURN )
+ {
+ SetError( SbxERR_NOTIMP );
+ }
+ if ( !IsError() )
+ In->GenCmdCommand ((USHORT)(((SbxTransportMethod*)pVar)->nValue),rPar);
+ if ( !IsError() && ((SbxTransportMethod*)pVar)->nValue & M_WITH_RETURN )
+ {
+ pImpl->pNextReturn = ((SbxTransportMethod*)pVar);
+ aNextReturnId = TTUniqueId( ((SbxTransportMethod*)pVar)->nValue );
+ }
+ if ( SingleCommandBlock )
+ EndBlock();
+ if ( !IsError() && (USHORT)((SbxTransportMethod*)pVar)->nValue & M_WITH_RETURN )
+ {
+ WaitForAnswer();
+ }
+ // für einige noch etwas Nachbehandlung
+ switch ( ((SbxTransportMethod*)pVar)->nValue )
+ {
+ case RC_WinTree:
+// ::svt::OStringTransfer::CopyString(pVar->GetString(), pSomeWindowIDontHave );
+ break;
+ }
+
+ }
+ break;
+ case ID_Dispatch:
+ if ( !rPar || (rPar->Count() % 2) == 1 ) // rPar = NULL <=> Kein Parameter ansonsten Gerade Anzahl(Ungerade, da immer Anzahl+1
+ {
+ if ( SingleCommandBlock )
+ BeginBlock();
+ if ( !IsError() )
+ In->GenCmdSlot ( (USHORT)((SbxTransportMethod*)pVar)->nValue, rPar );
+ pVar->PutInteger( ((SbxTransportMethod*)pVar)->nValue );
+ if ( SingleCommandBlock )
+ EndBlock();
+ }
+ else
+ SetError( SbxERR_WRONG_ARGS );
+ break;
+ case ID_UNODispatch:
+ if ( !rPar ) // rPar = NULL <=> Kein Parameter ansonsten Gerade Anzahl(Ungerade, da immer Anzahl+1
+ {
+ if ( SingleCommandBlock )
+ BeginBlock();
+ if ( !IsError() )
+ In->GenCmdUNOSlot ( ((SbxTransportMethod*)pVar)->aUnoSlot );
+ pVar->PutString( ((SbxTransportMethod*)pVar)->aUnoSlot );
+ if ( SingleCommandBlock )
+ EndBlock();
+ }
+ else
+ SetError( SbxERR_WRONG_ARGS );
+ break;
+ case ID_Control:
+ case ID_StringControl:
+ if ( SingleCommandBlock )
+ BeginBlock();
+ else
+ if ( ((SbxTransportMethod*)pVar)->nValue & M_WITH_RETURN )
+ {
+ SetError( SbxERR_NOTIMP );
+ }
+ if ( !IsError() )
+ {
+ if ( nUserData == ID_Control )
+ {
+ In->GenCmdControl (pVar->GetParent()->GetULong(),
+ (USHORT)((SbxTransportMethod*)pVar)->nValue, rPar);
+ aNextReturnId = TTUniqueId( pVar->GetParent()->GetULong() );
+ }
+ else
+ {
+ In->GenCmdControl (pVar->GetParent()->GetString(),
+ (USHORT)((SbxTransportMethod*)pVar)->nValue, rPar);
+ aNextReturnId = TTUniqueId( pVar->GetParent()->GetString(), UID_UNKNOWN_STRING );
+ }
+
+
+ if ( !IsError() && ((SbxTransportMethod*)pVar)->nValue & M_WITH_RETURN )
+ {
+ pImpl->pNextReturn = ((SbxTransportMethod*)pVar);
+ }
+ else
+ {
+ pImpl->pNextReturn = NULL;
+ aNextReturnId = TTUniqueId();
+ }
+
+ }
+ if ( SingleCommandBlock )
+ EndBlock();
+ if ( !IsError() && (USHORT)((SbxTransportMethod*)pVar)->nValue & M_WITH_RETURN )
+ {
+ WaitForAnswer();
+ }
+
+ break;
+ case ID_GetUnoApp:
+ {
+ // Hier wird der Remote UNO Kram gestartet
+ // Eintrag in die Konfiguration unter
+ // org.openoffice.Office.Common/Start/Connection
+ // socket,host=0,port=12345;iiop;XBla
+ // oder
+ // socket,host=0,port=12345;urp;;XBla
+
+ String aString;
+ aString.AppendAscii( "socket,host=" );
+ aString += GetHostConfig();
+ aString.AppendAscii( ",port=" );
+ aString += String::CreateFromInt32( GetUnoPortConfig() );
+
+ Reference< XMultiServiceFactory > smgr_xMultiserviceFactory;
+ try
+ {
+ Reference< XMultiServiceFactory > xSMgr = comphelper::getProcessServiceFactory();
+// is allways there
+/* if ( ! xSMgr.is() )
+ {
+ xSMgr = ::cppu::createRegistryServiceFactory(OUString(RTL_CONSTASCII_USTRINGPARAM("applicat.rdb")), sal_True );
+ if ( xSMgr.is() )
+ comphelper::setProcessServiceFactory( xSMgr );
+ }*/
+
+ OUString aURL( aString );
+ Reference< XConnector > xConnector( xSMgr->createInstance(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.connection.Connector") ) ), UNO_QUERY );
+ Reference< XConnection > xConnection( xConnector->connect( aURL ) );
+
+ Reference< XBridgeFactory > xBridgeFactory( xSMgr->createInstance(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.bridge.BridgeFactory") ) ), UNO_QUERY );
+ Reference< XBridge > xBridge( xBridgeFactory->createBridge(
+ OUString(), OUString( RTL_CONSTASCII_USTRINGPARAM("urp") ),
+ xConnection, Reference< XInstanceProvider >() ) );
+
+ // Reference< XInterface > xRet( xBridge->getInstance( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.Desktop")) ) );
+ Reference< XInterface > xRet( xBridge->getInstance( OUString( RTL_CONSTASCII_USTRINGPARAM("StarOffice.ServiceManager")) ) );
+
+ // Reference< XNamingService > xNamingService(xRet, UNO_QUERY);
+
+ // Reference< XInterface > smgr = xNamingService->getRegisteredObject( OUString( RTL_CONSTASCII_USTRINGPARAM("StarOffice.ServiceManager" ) ) );
+
+ smgr_xMultiserviceFactory = Reference< XMultiServiceFactory >(xRet, UNO_QUERY);
+ //MBA fragen!!
+ }
+ catch( class Exception & rEx)
+ {
+ ADD_ERROR(SbxERR_BAD_ACTION, String( rEx.Message ) );
+ }
+ catch( ... )
+ {
+ ADD_ERROR(SbxERR_BAD_ACTION, CUniString( "Unknown Error" ) );
+ }
+
+ if( smgr_xMultiserviceFactory.is() )
+ {
+ Any aAny;
+// aAny <<= xBridge;
+ aAny <<= smgr_xMultiserviceFactory;
+
+ SbxObjectRef xMySbxObj = GetSbUnoObject( CUniString("RemoteUnoAppFuerTesttool"), aAny );
+ if ( xMySbxObj.Is() )
+ pVar->PutObject( xMySbxObj );
+ }
+ }
+ break;
+ case ID_GetIServer:
+ {
+ // Hier wird der Remote UNO Kram gestartet
+
+ String aString;
+// aString += GetHostConfig();
+// aString.AppendAscii( ":" );
+// aString += String::CreateFromInt32( GetUnoPortConfig() );
+
+ Reference< XMultiServiceFactory > xSMgr /* = comphelper::getProcessServiceFactory()*/;
+// if ( ! xSMgr.is() )
+ {
+ xSMgr = ::cppu::createRegistryServiceFactory(OUString(RTL_CONSTASCII_USTRINGPARAM("g:\\iserverproxy.rdb")), sal_True);
+// comphelper::setProcessServiceFactory( xSMgr );
+ }
+
+ OUString aURL( aString );
+ Reference< XConnector > xConnector( xSMgr->createInstance(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.connection.Connector") ) ), UNO_QUERY );
+ Reference< XConnection > xConnection( xConnector->connect( OUString( RTL_CONSTASCII_USTRINGPARAM("socket,host=grande,port=7453")) ) );
+
+ Reference< XBridgeFactory > xBridgeFactory( xSMgr->createInstance(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.bridge.BridgeFactory") ) ), UNO_QUERY );
+ Reference< XBridge > xBridge( xBridgeFactory->createBridge(
+ OUString(), OUString( RTL_CONSTASCII_USTRINGPARAM("urp") ),
+ xConnection, Reference< XInstanceProvider >() ) );
+
+ Reference< XInterface > xRet( xBridge->getInstance( OUString( RTL_CONSTASCII_USTRINGPARAM("XIServerProxy")) ) );
+
+
+/* Reference< XIServerProxy > xIS( xRet, UNO_QUERY );
+ if ( xIS.is() )
+ {
+ String aHost( xIS->getIServerHost() );
+
+// Reference < XInformationClient > xIC = xIS->createIServerClient( "XInformationClient" );
+ Reference < XInformationClient > xIC = xIS->createInformationClient();
+ xIC->getTree(OUString::createFromAscii("r:\\b_server\\config\\stand.lst"), OUString() );
+
+
+ Reference< XTypeProvider > xTP( xRet, UNO_QUERY );
+ Sequence < com::sun::star::uno::Type > s = xTP->getTypes();
+ }
+ */
+
+ if( xRet.is() )
+ {
+ Any aAny;
+ aAny <<= xRet;
+
+ SbxObjectRef xMySbxObj = GetSbUnoObject( CUniString("IServerProxy"), aAny );
+ if ( xMySbxObj.Is() )
+ pVar->PutObject( xMySbxObj );
+ }
+ // In Basic:
+ // msgbox dbg_SupportedInterfaces
+ // msgbox dbg_Properties
+ // msgbox dbg_Methods
+ }
+ break;
+ case ID_RemoteCommandDelay:
+ if ( rPar && rPar->Count() >= 2 && rPar->Count() <=3 )
+ {
+ switch (rPar->Get( 1 )->GetType())
+ {
+ case SbxLONG: // alles immer als Short übertragen
+ case SbxULONG:
+ case SbxLONG64:
+ case SbxULONG64:
+ case SbxDOUBLE:
+ case SbxINTEGER:
+ case SbxBYTE:
+ case SbxUSHORT:
+ case SbxINT:
+ case SbxUINT:
+ case SbxSINGLE:
+ pImpl->nMinRemoteCommandDelay = rPar->Get( 1 )->GetULong();
+ if ( rPar->Count() == 3 )
+ pImpl->nMaxRemoteCommandDelay = rPar->Get( 2 )->GetULong();
+ else
+ pImpl->nMaxRemoteCommandDelay = pImpl->nMinRemoteCommandDelay;
+ break;
+ case SbxBOOL:
+ pImpl->bDoRemoteCommandDelay = rPar->Get( 1 )->GetBool();
+ break;
+ default:
+ SbxBase::SetError( SbxERR_WRONG_ARGS );
+ break;
+ }
+ }
+ else
+ SetError( SbxERR_WRONG_ARGS );
+ break;
+ case ID_GetApplicationPath:
+ if ( !rPar )
+ {
+ OUString aUrl = Config::GetDefDirectory();
+ OUString aPath;
+ osl::FileBase::getSystemPathFromFileURL( aUrl, aPath );
+ pVar->PutString( String( aPath ) );
+ }
+ else
+ SetError( SbxERR_WRONG_ARGS );
+ break;
+ case ID_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 )
+ {
+ Timer aTimer;
+ aTimer.SetTimeout( nWait );
+ aTimer.Start();
+ while ( aTimer.IsActive() )
+ Application::Yield();
+ }
+ }
+ else
+ SetError( SbERR_BAD_ARGUMENT );
+ }
+ break;
+ case ID_GetErrorCount:
+ {
+ pVar->PutULong( pImpl->nErrorCount );
+ }
+ break;
+ case ID_GetWarningCount:
+ {
+ pVar->PutULong( pImpl->nWarningCount );
+ }
+ break;
+ case ID_GetUseFileWarningCount:
+ {
+ pVar->PutULong( pImpl->nIncludeFileWarningCount );
+ }
+ break;
+ case ID_GetTestCaseName:
+ {
+ pVar->PutString( pImpl->aTestCaseName );
+ }
+ break;
+ case ID_GetTestCaseFileName:
+ {
+ pVar->PutString( pImpl->aTestCaseFileName );
+ }
+ break;
+ case ID_GetTestCaseLineNr:
+ {
+ pVar->PutUShort( pImpl->nTestCaseLineNr );
+ }
+ break;
+ } // switch( nUserData )
+ } // if( nHintId == SBX_HINT_DATAWANTED )
+ else if( nHintId == SBX_HINT_DATACHANGED )
+ {
+ switch( nUserData )
+ {
+ case ID_AutoExecute:
+ if ( !rPar ) // rPar = NULL <=> Kein Parameter
+ {
+ SingleCommandBlock = pVar->GetBool();
+ if ( SingleCommandBlock )
+ EndBlock();
+ else
+ BeginBlock();
+ }
+ else
+ SetError( SbxERR_WRONG_ARGS );
+ break;
+ }
+ } // if( nHintId == SBX_HINT_DATACHANGED )
+ else if( nHintId == SBX_HINT_BASICSTART )
+ {
+ pImpl->nErrorCount = 0;
+ pImpl->nWarningCount = 0;
+ pImpl->nIncludeFileWarningCount = 0;
+ if (pFehlerListe)
+ delete pFehlerListe;
+ pFehlerListe = new CErrors;
+ } // if( nHintId == SBX_HINT_BASICSTART )
+ else if( nHintId == SBX_HINT_BASICSTOP )
+ {
+ // Log summary to journal
+ ADD_CASE_LOG( String() ); // Case abschliessen
+ ADD_MESSAGE_LOG( CUniString("***************************************************") );
+ if ( pImpl->nErrorCount )
+ {
+ ADD_WARNING_LOG( GEN_RES_STR1( S_ERRORS_DETECTED, String::CreateFromInt32( pImpl->nErrorCount ) ) );
+ pImpl->nWarningCount--; // Anpassen, da diese Warnung nicht in die Statistik soll
+ }
+ else
+ ADD_MESSAGE_LOG( GEN_RES_STR0( S_NO_ERRORS_DETECTED ) );
+
+ if ( pImpl->nWarningCount )
+ ADD_WARNING_LOG( GEN_RES_STR1( S_WARNINGS_DETECTED, String::CreateFromInt32( pImpl->nWarningCount ) ) )
+ else
+ ADD_MESSAGE_LOG( GEN_RES_STR0( S_NO_WARNINGS_DETECTED ) );
+
+ if ( pImpl->nIncludeFileWarningCount )
+ ADD_WARNING_LOG( GEN_RES_STR1( S_INCLUDE_FILE_WARNINGS_DETECTED, String::CreateFromInt32( pImpl->nIncludeFileWarningCount ) ) )
+ else
+ ADD_MESSAGE_LOG( GEN_RES_STR0( S_NO_INCLUDE_FILE_WARNINGS_DETECTED ) );
+ ADD_MESSAGE_LOG( CUniString("***************************************************") );
+
+ pImpl->nErrorCount = 0;
+ pImpl->nWarningCount = 0;
+ pImpl->nIncludeFileWarningCount = 0;
+ } // 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()));
+ if ( bQuietErrors )
+ ResetError();
+ }
+ }
+}
+
+
+SbxVariable* TestToolObj::Find( const String& Str, SbxClassType Type)
+{
+ if ( BasicRuntimeAccess::IsRunInit() ) // wegen Find im "Global" Befehl des Basic
+ return NULL;
+
+ SbxVariableRef Old = SbxObject::Find(Str, Type );
+ if (Old && Old->GetUserData() != ID_Dispatch && Old->GetUserData() != ID_UNODispatch && Old->GetUserData() != 0 )
+ return Old;
+ else
+ {
+ USHORT nElement;
+ ControlDef *pWhatName = new ControlDef(Str,0);
+
+ /// nach Controls suchen
+ if (pNameKontext && pNameKontext->Seek_Entry(pWhatName,&nElement))
+ {
+ delete pWhatName;
+ pWhatName = ((ControlDef*)pNameKontext->GetObject(nElement));
+ pImpl->pControlsObj = pImpl->pControlsObjs[nControlsObj++];
+ pImpl->pControlsObj->SetName(pWhatName->pData->Kurzname);
+
+ if ( pWhatName->pData->aUId.IsStrId() )
+ pImpl->pControlsObj->PutString(pWhatName->pData->aUId.GetString());
+ else
+ pImpl->pControlsObj->PutULong(pWhatName->pData->aUId.GetULONG());
+
+ pShortNames->Insert(pWhatName->pData->Kurzname,pWhatName->pData->aUId,nSequence);
+
+ SbxVariable *pMember;
+ if ( ! (pMember = pImpl->pControlsObj->Find(CUniString("ID"),SbxCLASS_DONTCARE)) )
+ {
+ pMember = new SbxProperty(CUniString("ID"),SbxULONG);
+ pImpl->pControlsObj->Insert(pMember);
+ }
+ if ( pWhatName->pData->aUId.IsStrId() )
+ pMember->PutString(pWhatName->pData->aUId.GetString());
+ else
+ pMember->PutULong(pWhatName->pData->aUId.GetULONG());
+
+ if ( ! (pMember = pImpl->pControlsObj->Find(CUniString("name"),SbxCLASS_DONTCARE)) )
+ {
+ pMember = NULL;
+ }
+ else
+ pMember->PutString(pWhatName->pData->Kurzname);
+
+ return pImpl->pControlsObj;
+ }
+
+ /// Nach slots suchen
+ if (pSIds && pSIds->Seek_Entry(pWhatName,&nElement))
+ {
+ SbxTransportMethodRef pMyVar;
+ pMyVar = pImpl->pMyVars[nMyVar++];
+ if ( nMyVar >= VAR_POOL_SIZE )
+ nMyVar = 0;
+ delete pWhatName;
+ pWhatName = ( (ControlDef*)pSIds->GetObject( nElement ) );
+ pMyVar->SetName( pWhatName->pData->Kurzname );
+
+ if ( pWhatName->pData->aUId.IsStrId() )
+ {
+ pMyVar->SetUserData( ID_UNODispatch );
+ pMyVar->aUnoSlot = pWhatName->pData->aUId.GetString();
+ }
+ else
+ {
+ pMyVar->SetUserData( ID_Dispatch );
+ pMyVar->nValue = pWhatName->pData->aUId.GetULONG();
+ pShortNames->Insert( Str, pWhatName->pData->aUId, nSequence );
+ }
+ return pMyVar;
+ }
+
+ /// es kann sich noch um eine SlotID handeln, die numerisch abgefragt wird, statt ausgeführt zu werden
+ if ( Str.Copy( Str.Len()-3, 3 ).CompareIgnoreCaseToAscii("_ID") == COMPARE_EQUAL && pSIds )
+ {
+ delete pWhatName;
+ pWhatName = new ControlDef( Str.Copy( 0, Str.Len()-3 ), 0 );
+ if ( pSIds->Seek_Entry( pWhatName, &nElement ) )
+ { // Nach slots suchen
+ SbxVariable *pReturn = new SbxVariable;
+ delete pWhatName;
+ pWhatName = ( (ControlDef*)pSIds->GetObject( nElement ) );
+ pReturn->SetName( pWhatName->pData->Kurzname );
+
+ if ( pWhatName->pData->aUId.IsStrId() )
+ pReturn->PutString(pWhatName->pData->aUId.GetString());
+ else
+ pReturn->PutULong(pWhatName->pData->aUId.GetULONG());
+ return pReturn;
+ }
+ }
+ ADD_ERROR(SbxERR_PROC_UNDEFINED,GEN_RES_STR1(S_UNKNOWN_SLOT_CONTROL, Str) );
+ if ( bQuietErrors )
+ { // Vorsichtshalber Control, falls noch ´ne Methode Folgt.
+ pImpl->pControlsObj->SetName(Str);
+ pImpl->pControlsObj->SetUserData( ID_ErrorDummy );
+ return pImpl->pControlsObj;
+ }
+ }
+ return NULL;
+}
+
+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;
+ xub_StrLen nTry2;
+ 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;
+
+ while ( !WasPrecompilerError() && (nTry2 = ImplSearch( aSource, nStart, nEnd, CUniString("try"), nTry+1 )) != STRING_NOTFOUND )
+ { // Wir rekursieren erstmal mit dem 2. Try
+ if ( nTry2 < nCatch )
+ nEnd += PreCompilePart( aSource, nTry2, nEndcatch+8, aCatchLabel, nLabelCount ) - nEndcatch-8;
+ else
+ nEnd = PreCompilePart( aSource, nTry2, nEnd, aFinalErrorLabel, nLabelCount );
+
+ if ( (nCatch = ImplSearch( aSource, nStart, nEnd, CUniString("catch"), nTry )) == STRING_NOTFOUND )
+ {
+ xub_StrLen l,c;
+ CalcPosition( aSource, nTry, l, c );
+ CError( SbERR_BAD_BLOCK, CUniString("catch"), l, c, c+2 );
+ return nEnd;
+ }
+ if ( (nEndcatch = ImplSearch( aSource, nStart, nEnd, CUniString("endcatch"), nCatch )) == STRING_NOTFOUND )
+ {
+ xub_StrLen l,c;
+ CalcPosition( aSource, nCatch, l, c );
+ CError( SbERR_BAD_BLOCK, CUniString("endcatch"), l, c, c+4 );
+ return nEnd;
+ }
+ }
+
+ String aReplacement;
+ int nTotalLength = -3 -5 -8; // try, catch und endcatch fallen raus
+
+ aReplacement.AppendAscii( "on error goto " );
+ aReplacement += aCatchLabel;
+ aSource.SearchAndReplaceAscii( "try", aReplacement, nTry );
+ nTotalLength += aReplacement.Len();
+
+
+// on error goto endcse
+// goto endctchXX
+// ctchXX:
+// if err = 35 or err = 18 then : resume : endif :
+// MaybeAddErr
+// on error goto endcse
+// resume ctchresXX
+// ctchresXX:
+ aReplacement.Erase();
+ aReplacement.AppendAscii( "on error goto " );
+ aReplacement += aFinalErrorLabel;
+ aReplacement.AppendAscii( " : goto " );
+ aReplacement += aEndcatchLabel;
+ aReplacement.AppendAscii( " : " );
+ aReplacement += aCatchLabel;
+ aReplacement.AppendAscii( ": if err = 35 or err = 18 then : on error goto 0 : resume : endif" );
+ aReplacement.AppendAscii( " : MaybeAddErr : on error goto " );
+ aReplacement += aFinalErrorLabel;
+ aReplacement.AppendAscii( " : resume " );
+ aReplacement += aCatchresLabel;
+ aReplacement.AppendAscii( " : " );
+ aReplacement += aCatchresLabel;
+ aReplacement.AppendAscii( ": " );
+ aSource.SearchAndReplaceAscii( "catch", aReplacement, nCatch );
+ nTotalLength += aReplacement.Len();
+
+
+ aReplacement.Erase();
+ aReplacement.AppendAscii("ClearError : ");
+ aReplacement += aEndcatchLabel;
+ aReplacement.AppendAscii(": ");
+ aSource.SearchAndReplaceAscii( "endcatch", aReplacement, nEndcatch );
+ nTotalLength += aReplacement.Len();
+
+ if ( aSource.Len() >= STRING_MAXLEN )
+ {
+ xub_StrLen l,c;
+ CalcPosition( aSource, nEndcatch, l, c );
+ CError( SbERR_PROG_TOO_LARGE, CUniString("endcatch"), l, c, c+2 );
+ }
+
+ return nEnd + nTotalLength;
+}
+
+
+void TestToolObj::PreCompileDispatchParts( String &aSource, String aStart, String aEnd, String aFinalLable )
+{
+ USHORT nLabelCount = 0;
+ xub_StrLen nPartPos = 0;
+
+ while ( !WasPrecompilerError() && (nPartPos = ImplSearch( aSource, nPartPos, aSource.Len(), aStart )) != STRING_NOTFOUND )
+ {
+ xub_StrLen nEndPart = ImplSearch( aSource, nPartPos, aSource.Len(), aEnd );
+ if ( nEndPart == STRING_NOTFOUND )
+ return;
+ nPartPos = PreCompilePart( aSource, nPartPos, nEndPart, aFinalLable, nLabelCount );
+ nPartPos += aEnd.Len();
+ }
+}
+
+
+BOOL TestToolObj::WasPrecompilerError()
+{
+ return bWasPrecompilerError;
+}
+
+String TestToolObj::PreCompile( String const &aSourceIn )
+{
+ // Im CTOR zu früh, und hier grade nicg rechtzeitig. Start und Stop von Programmausführung
+ StartListening( ((StarBASIC*)GetParent())->GetBroadcaster(), TRUE );
+
+ xub_StrLen nTestCase;
+ xub_StrLen nEndCase;
+ xub_StrLen nStartPos = 0;
+ String aSource(aSourceIn);
+ bWasPrecompilerError = FALSE;
+
+HACK("Ich gestehe alles: Ich war zu faul das richtig zu machen.")
+ aSource = String(' ').Append( aSource ); // Da Schlüsselworte an Position 0 sonst nicht gefunden werden
+
+
+// Erstmal alle "'" Kommentare raus
+
+ xub_StrLen nComment;
+ while ( (nComment = aSource.SearchAscii("'",nStartPos)) != STRING_NOTFOUND )
+ {
+ USHORT nStringEndCount = 0;
+ xub_StrLen nIndex = nComment;
+ while ( nIndex && aSource.GetChar(nIndex) != '\n' )
+ {
+ if ( aSource.GetChar(nIndex) == '"' )
+ nStringEndCount++;
+ nIndex--;
+ }
+ if ( (nStringEndCount & 1) == 0 ) // Wir waren also nicht innerhalb eines Strings
+ {
+ xub_StrLen nComEnd = aSource.SearchAscii("\n",nComment);
+
+ while ( aSource.GetChar(nComEnd) == _CR || aSource.GetChar(nComEnd) == _LF )
+ nComEnd--;
+
+ nComEnd++;
+
+ aSource.Erase(nComment,nComEnd-nComment);
+ }
+ else
+ nComment++;
+ nStartPos = nComment;
+ }
+
+
+ PreCompileDispatchParts( aSource, CUniString("sub"), CUniString("end sub"), CUniString("0") );
+ PreCompileDispatchParts( aSource, CUniString("function"), CUniString("end function"), CUniString("0") );
+ PreCompileDispatchParts( aSource, CUniString("testcase"), CUniString("endcase"), CUniString("endcse") );
+
+
+ xub_StrLen nMainPos = ImplSearch( aSource, 0, aSource.Len(), CUniString("sub main") );
+ aSource.SearchAndReplaceAscii("sub main",CUniString("Sub Main StartUse : LoadIncludeFiles : FinishUse "), nMainPos );
+ if ( aSource.Len() >= STRING_MAXLEN )
+ {
+ xub_StrLen l,c;
+ CalcPosition( aSource, nMainPos, l, c );
+ CError( SbERR_PROG_TOO_LARGE, CUniString("endcatch"), l, c, c+2 );
+ }
+
+ while ( (nTestCase = ImplSearch( aSource, 0, aSource.Len(), CUniString("testcase") ) ) != STRING_NOTFOUND )
+ {
+ xub_StrLen nTcEnd = aSource.SearchAscii("\n",nTestCase);
+
+ while ( aSource.GetChar(nTcEnd) == _CR || aSource.GetChar(nTcEnd) == _LF )
+ nTcEnd--;
+
+ nTcEnd++;
+
+ if ( aSource.SearchAscii(":",nTestCase) < nTcEnd )
+ nTcEnd = aSource.SearchAscii(":",nTestCase) -1;
+ String aSuffix = aSource.Copy(nTestCase+8,nTcEnd-nTestCase-8);
+ USHORT nOldLen;
+ do
+ {
+ nOldLen = aSuffix.Len();
+ aSuffix.EraseLeadingAndTrailingChars( ' ' );
+ aSuffix.EraseLeadingAndTrailingChars( 0x09 );
+ } while ( nOldLen != aSuffix.Len() );
+ aSource.Erase(nTestCase,nTcEnd-nTestCase);
+ aSource.Insert(CUniString("Sub ").Append(aSuffix).AppendAscii(" CaseLog \"").Append(aSuffix).AppendAscii("\" : on error goto endcse : TestEnter "),nTestCase);
+ }
+
+ while ( (nEndCase = ImplSearch( aSource, 0, aSource.Len(), CUniString("endcase") ) ) != STRING_NOTFOUND )
+ aSource.SearchAndReplaceAscii("endcase",CUniString("goto endsub : endcse: if err = 35 or err = 18 then : on error goto 0 : resume : endif : MaybeAddErr : ExceptLog : resume endcse_res : endcse_res: on error goto 0 : endsub: TestExit : ClearError : CaseLog \"\" : end sub "), nEndCase );
+
+ if ( aSource.Len() >= STRING_MAXLEN )
+ {
+ xub_StrLen l,c;
+ CalcPosition( aSource, 0, l, c );
+ CError( SbERR_PROG_TOO_LARGE, CUniString("endcatch"), l, c, c+2 );
+ }
+ return aSource;
+}
+
+void TestToolObj::AddToListByNr( CNames *&pControls, ControlItemUId *&pNewItem )
+{
+ USHORT nNr;
+ if ( pControls->Seek_Entry( pNewItem, &nNr ) )
+ {
+ AddName( pControls->GetObject(nNr)->pData->Kurzname, pNewItem->pData->Kurzname );
+ delete pNewItem;
+ pNewItem = (ControlItemUId*)pControls->GetObject(nNr); // für einfügen der Söhne
+ }
+ else
+ {
+ ControlItem* pNI = pNewItem;
+ pControls->C40_PTR_INSERT(ControlItem,pNI);
+ }
+}
+
+IMPL_LINK( TestToolObj, ReturnResultsLink, CommunicationLink*, pCommLink )
+{
+ return ReturnResults( pCommLink->GetServiceData() );
+}
+
+void TestToolObj::ReadHidLstByNumber()
+{
+ // Die Hid.Lst nach Nummern sortiert einlesen
+ if ( !pReverseUIds )
+ {
+ String aName = (pImpl->aHIDDir + DirEntry(CUniString("hid.lst"))).GetFull();
+
+ TTExecutionStatusHint aHint( TT_EXECUTION_SHOW_ACTION, String(ResId(S_READING_LONGNAMES)), aName );
+ GetTTBroadcaster().Broadcast( aHint );
+
+ ReadFlat( aName, pReverseUIds, FALSE );
+ {
+ TTExecutionStatusHint aHint( TT_EXECUTION_HIDE_ACTION );
+ GetTTBroadcaster().Broadcast( aHint );
+ }
+ }
+}
+
+void TestToolObj::SortControlsByNumber( BOOL bIncludeActive )
+{
+ // Die Controls einmal hirarchisch und einmal alle flach nach nummer sortiert
+ if ( !pReverseControls && !pReverseControlsSon && pControls )
+ {
+ pReverseControls = new CNames;
+ pReverseControlsSon = new CNames;
+ USHORT nWin,nCont;
+ const String aSl('/');
+ for ( nWin = 0 ; nWin < pControls->Count() ; nWin++ )
+ {
+ String aFatherName( pControls->GetObject(nWin)->pData->Kurzname );
+ ControlItemUId *pNewFather = new ControlItemUIdSon(aFatherName,pControls->GetObject(nWin)->pData->aUId);
+ AddToListByNr( pReverseControlsSon, pNewFather );
+ if (! ((ControlItemUIdSon*)pNewFather)->GetSons() )
+ ((ControlItemUIdSon*)pNewFather)->Sons( new CNames );
+
+ // Existieren Söhne, diese in beide Listen eintragen
+ CNames *pControlList = ((ControlItemSon*)pControls->GetObject(nWin))->GetSons();
+ if ( pControlList )
+ for ( nCont = 0 ; nCont < pControlList->Count() ; nCont++ )
+ {
+ ControlItemUId *pNewItem;
+
+ String aCombinedName( aFatherName );
+ aCombinedName.AppendAscii( ":" );
+ aCombinedName.Append( pControlList->GetObject(nCont)->pData->Kurzname );
+ pNewItem = new ControlItemUId( aCombinedName, pControlList->GetObject(nCont)->pData->aUId );
+ AddToListByNr( pReverseControls, pNewItem );
+
+ pNewItem = new ControlItemUId( pControlList->GetObject(nCont)->pData->Kurzname, pControlList->GetObject(nCont)->pData->aUId );
+ AddToListByNr( ((ControlItemUIdSon*)pNewFather)->GetSons(), pNewItem );
+ }
+ }
+ if ( !bIncludeActive )
+ {
+ ControlItem *pZeroItem = new ControlItemUId( UniString(), 0 );
+ USHORT nNr;
+ if ( pReverseControls->Seek_Entry( pZeroItem, &nNr ) )
+ {
+ pReverseControls->DeleteAndDestroy( nNr );
+// um VorlagenLaden/UntergeordneteIniDatei/SpeichernDlg/OrdnerDlg/OeffnenDlg/MessageBox/LetzteVersion/GrafikEinfuegenDlg/FarbeDlg/ExportierenDlg/DruckerEinrichten/DruckenDlg/DateiEinfuegenDlg/Active zu verhindern
+ }
+/* if ( pReverseControlsSon->Seek_Entry( pZeroItem, &nNr ) )
+ {
+ pReverseControlsSon->DeleteAndDestroy( nNr );
+// um VorlagenLaden/UntergeordneteIniDatei/SpeichernDlg/OrdnerDlg/OeffnenDlg/MessageBox/LetzteVersion/GrafikEinfuegenDlg/FarbeDlg/ExportierenDlg/DruckerEinrichten/DruckenDlg/DateiEinfuegenDlg/Active zu verhindern
+ }*/
+ delete pZeroItem;
+ }
+ }
+}
+
+
+BOOL TestToolObj::ReturnResults( SvStream *pIn )
+{
+
+ USHORT nId;
+ ULONG nClearSequence = 0;
+ BOOL bSequenceOK = TRUE;
+ CNames *pReverseControlsKontext = NULL;
+
+ CRetStream *pRetStream = new CRetStream(pIn);
+
+ pRetStream->Read( nId );
+ while( !pIn->IsEof() )
+ {
+ switch( nId )
+ {
+ case SIReturn:
+ {
+ USHORT nRet,nParams;
+ TTUniqueId aUId;
+ pRetStream->Read(nRet);
+ if ( pRetStream->GetNextType() == BinString )
+ {
+ String aUStrId; // UniqueStringID Used for Mozilla Integration
+ pRetStream->Read( aUStrId );
+ aUId = TTUniqueId( aUStrId, UID_UNKNOWN_STRING );
+ }
+ else
+ {
+ ULONG nUId;
+ pRetStream->Read( nUId ); // bei Sequence einfach die Sequence
+ aUId = TTUniqueId( nUId );
+ }
+ pRetStream->Read(nParams);
+
+ USHORT nNr1 = 0;
+ ULONG nLNr1 = 0;
+ String aString1;
+ BOOL bBool1 = FALSE;
+ SbxValueRef xValue1 = new SbxValue;
+
+ if( nParams & PARAM_USHORT_1 )
+ pRetStream->Read( nNr1 );
+ if( nParams & PARAM_ULONG_1 )
+ pRetStream->Read( nLNr1 );
+ if( nParams & PARAM_STR_1 )
+ {
+ pRetStream->Read( aString1 );
+ ReplaceNumbers ( aString1 );
+ }
+ else
+ aString1.Erase();
+ if( nParams & PARAM_BOOL_1 )
+ pRetStream->Read( bBool1 );
+ if( nParams & PARAM_SBXVALUE_1 )
+ pRetStream->Read( *xValue1 );
+ switch (nRet)
+ {
+ case RET_Sequence:
+ {
+ ULONG nUId = aUId.GetULONG();
+ if ( nSequence != nUId )
+ {
+ bSequenceOK = FALSE;
+ ADD_ERROR(SbxERR_BAD_ACTION, GEN_RES_STR2(S_RETURN_SEQUENCE_MISSMATCH, String::CreateFromInt64(nUId), String::CreateFromInt64(nSequence)) );
+ }
+ else
+ {
+ nClearSequence = nUId;
+ }
+ }
+ break;
+ case RET_Value:
+ if ( pImpl->pNextReturn )
+ {
+// ULONG nUserData = pImpl->pNextReturn->GetParent()->GetUserData();
+// pImpl->pNextReturn->GetParent()->SetUserData(0);
+// if ( nUId == pImpl->pNextReturn->GetParent()->GetULong() )
+ if ( aUId == aNextReturnId )
+ {
+ if( nParams & PARAM_ULONG_1 ) pImpl->pNextReturn->PutULong( nLNr1 );
+ if( nParams & PARAM_USHORT_1 ) pImpl->pNextReturn->PutUShort( nNr1 );
+ if( nParams & PARAM_STR_1 ) pImpl->pNextReturn->PutString( aString1 );
+ if( nParams & PARAM_BOOL_1 ) pImpl->pNextReturn->PutBool( bBool1 );
+ if( nParams & PARAM_SBXVALUE_1 )
+ {
+ SbxValues aValues( SbxDATE );
+ xValue1->Get( aValues );
+ pImpl->pNextReturn->Put( aValues );
+ }
+ }
+ else
+ {
+ ADD_ERROR(SbxERR_BAD_ACTION, GEN_RES_STR0(S_RETURNED_VALUE_ID_MISSMATCH) )
+ }
+// pImpl->pNextReturn->GetParent()->SetUserData(nUserData);
+ pImpl->pNextReturn = NULL;
+ }
+ else
+ {
+ ADD_ERROR(SbxERR_BAD_ACTION, GEN_RES_STR0(S_RETURNED_VALUE_NO_RECEIVER) )
+ }
+ break;
+ case RET_WinInfo:
+ {
+ if ( !pReverseControls && !pReverseControlsSon )
+ pReverseControlsKontext = NULL;
+
+ ReadHidLstByNumber();
+ SortControlsByNumber();
+
+ // Alle Slots nach Nummer Sortiert
+ if ( !pReverseSlots && pSIds )
+ {
+ pReverseSlots = new CNames;
+ USHORT nWin;
+ const String aSl('/');
+ for ( nWin = 0 ; nWin < pSIds->Count() ; nWin++ )
+ {
+ ControlItemUId *pNewItem = new ControlItemUId(pSIds->GetObject(nWin)->pData->Kurzname,pSIds->GetObject(nWin)->pData->aUId);
+ AddToListByNr( pReverseSlots, pNewItem );
+ }
+ }
+
+ WinInfoRec *pWinInfo = new WinInfoRec;
+ pWinInfo->aUId = aUId;
+ pWinInfo->nRType = nLNr1;
+ pWinInfo->aRName = aString1;
+ pWinInfo->bIsReset = bBool1;
+ pWinInfo->aKurzname.Erase();
+ pWinInfo->aSlotname.Erase();
+
+ // eventuell den Kontext feststellen. Passiert nur beim ersten Eintrag nach reset
+ if ( !pReverseControlsKontext && pReverseControlsSon )
+ {
+ USHORT nNr;
+ ControlItem *pNewItem = new ControlItemUId( String(), aUId );
+ if ( pReverseControlsSon->Seek_Entry(pNewItem,&nNr) )
+ {
+ pReverseControlsKontext = ((ControlItemUIdSon*)pReverseControlsSon->GetObject(nNr))->GetSons();
+ pWinInfo->aKurzname = CUniString("*");
+ }
+ else
+ pReverseControlsKontext = pReverseControls;
+
+ delete pNewItem;
+ }
+
+ // Reset. Muß nach bestimmen des Kontext stehen, da sonst mit dem reset-record
+ // der Kontext falsch gesetzt wird.
+ if ( pWinInfo->bIsReset )
+ pReverseControlsKontext = NULL; // Reihenfolge wichtig!
+
+
+ // Kurzname feststellen
+ if ( pReverseControlsKontext )
+ {
+ USHORT nNr;
+ ControlItem *pNewItem = new ControlItemUId( String(), aUId );
+ if ( pReverseControlsKontext->Seek_Entry(pNewItem,&nNr) )
+ pWinInfo->aKurzname += pReverseControlsKontext->GetObject(nNr)->pData->Kurzname;
+ delete pNewItem;
+ }
+
+ // Slotname feststellen
+ if ( pReverseSlots )
+ {
+ USHORT nNr;
+ ControlItem *pNewItem = new ControlItemUId( String(), aUId );
+ if ( pReverseSlots->Seek_Entry(pNewItem,&nNr) )
+ pWinInfo->aSlotname = pReverseSlots->GetObject(nNr)->pData->Kurzname;
+ delete pNewItem;
+ }
+
+ // Langname feststellen
+ if ( pReverseUIds )
+ {
+ USHORT nNr;
+ ControlItem *pNewItem = new ControlItemUId( String(), aUId );
+ if ( pReverseUIds->Seek_Entry(pNewItem,&nNr) )
+ pWinInfo->aLangname = pReverseUIds->GetObject(nNr)->pData->Kurzname;
+ delete pNewItem;
+ }
+
+ aWinInfoHdl.Call( pWinInfo );
+
+ delete pWinInfo;
+ }
+ break;
+ case RET_ProfileInfo:
+ {
+ ULONG nUId = aUId.GetULONG();
+ if ( nParams & PARAM_STR_1 )
+ {
+ DirEntry FilePath = pImpl->aLogFileBase + DirEntry(DirEntry(aLogFileName).GetBase().AppendAscii(".prf"));
+ SvFileStream aStrm( FilePath.GetFull(), STREAM_STD_WRITE );
+ if( aStrm.IsOpen() )
+ {
+ aString1.ConvertLineEnd(LINEEND_CRLF);
+ aStrm.Seek(STREAM_SEEK_TO_END);
+ aStrm << ByteString( aString1, RTL_TEXTENCODING_UTF8 ).GetBuffer();
+ aStrm.Close();
+ }
+ }
+ if ( nParams & PARAM_ULONG_1 )
+ {
+ switch ( nUId )
+ {
+ case S_ProfileReset: // nLNr1 = Anzahl Borders
+ {
+ pImpl->nNumBorders = nLNr1;
+ 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;
+
+ #ifdef DEBUG
+ if ( nLNr1 > (Time::GetSystemTicks() - pImpl->LocalStarttime) )
+ {
+ String aLine = CUniString("Testtoolzeit(").Append(String::CreateFromInt64(Time::GetSystemTicks() - pImpl->LocalStarttime)).AppendAscii(") kleiner Officezeit(").Append(String::CreateFromInt64(nLNr1)).AppendAscii(")\n");
+ DirEntry FilePath = pImpl->aLogFileBase + DirEntry(DirEntry(aLogFileName).GetBase().AppendAscii(".prf"));
+ SvFileStream aStrm( FilePath.GetFull(), STREAM_STD_WRITE );
+ if( aStrm.IsOpen() )
+ {
+ aLine.ConvertLineEnd(LINEEND_CRLF);
+ aStrm.Seek(STREAM_SEEK_TO_END);
+ aStrm << ByteString( aLine, RTL_TEXTENCODING_UTF8 ).GetBuffer();
+ aStrm.Close();
+ }
+ }
+ #endif
+
+ break;
+ }
+ case S_ProfileDump: // Gibt die daten aus.
+ {
+ if ( pImpl->nNumBorders == 0 ) // Also keine alte Rückmeldung vom Office
+ break;
+ DirEntry FilePath = pImpl->aLogFileBase + DirEntry(DirEntry(aLogFileName).GetBase().AppendAscii(".prf"));
+ SvFileStream aStrm( FilePath.GetFull(), STREAM_STD_WRITE );
+ if( aStrm.IsOpen() )
+ {
+ String aProfile;
+ USHORT i;
+
+ aProfile += String().Expand(15);
+ for ( i=0 ; i<pImpl->nNumBorders ; i++ )
+ aProfile += (CUniString("< ").Append(String::CreateFromInt64(pImpl->naValBorders[i]))).Expand(20);
+
+ aProfile += (CUniString(">= ").Append(TTFormat::ms2s(pImpl->naValBorders[pImpl->nNumBorders-1])));
+
+ aProfile += '\n';
+
+ aProfile += CUniString("Ereignisse").Expand(15);
+ for ( i=0 ; i<=pImpl->nNumBorders ; i++ )
+ aProfile += TTFormat::ms2s(pImpl->naNumEntries[i]).Expand(20);
+
+ aProfile += '\n';
+
+ aProfile += CUniString("Server Zeit").Expand(15);
+ for ( i=0 ; i<=pImpl->nNumBorders ; i++ )
+ aProfile += TTFormat::ms2s(pImpl->naRemoteTime[i]).Expand(20);
+
+ aProfile += '\n';
+
+ aProfile += CUniString("Testtool Zeit").Expand(15);
+ for ( i=0 ; i<=pImpl->nNumBorders ; i++ )
+ aProfile += TTFormat::ms2s(pImpl->naLocalTime[i]).Expand(20);
+
+ aProfile += '\n';
+
+ aProfile += CUniString("Overhead p.e.").Expand(15);
+ for ( i=0 ; i<=pImpl->nNumBorders ; i++ )
+ {
+ if ( pImpl->naNumEntries[i] > 0 )
+ aProfile += TTFormat::ms2s((pImpl->naLocalTime[i]-pImpl->naRemoteTime[i])/pImpl->naNumEntries[i]).Expand(20);
+ else
+ aProfile += CUniString( "??" ).Expand(20);
+ }
+
+ aProfile += '\n';
+
+ aProfile.ConvertLineEnd(LINEEND_CRLF);
+ aStrm.Seek(STREAM_SEEK_TO_END);
+ aStrm << ByteString( aProfile, RTL_TEXTENCODING_UTF8 ).GetBuffer();
+ aStrm.Close();
+ }
+ break;
+ }
+ default:
+ DBG_ERROR1("Unbekannter Sub Return Code bei Profile: %hu", nUId );
+ break;
+ }
+ }
+ }
+ break;
+ case RET_DirectLoging:
+ {
+ ULONG nUId = aUId.GetULONG();
+ 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;
+ default:
+ ;
+ }
+ }
+ break;
+ case RET_MacroRecorder:
+ {
+ SortControlsByNumber( TRUE );
+ String aCommand,aControls,aControl,aULongNames,aULongName;
+ BOOL bWriteNewKontext = FALSE;
+
+ aControls.Erase();
+ // Kurzname feststellen
+ if ( pReverseControls )
+ {
+ USHORT nNr;
+ ControlItem *pNewItem = new ControlItemUId( String(), aUId );
+ if ( pReverseControls->Seek_Entry(pNewItem,&nNr) )
+ aControls = pReverseControls->GetObject(nNr)->pData->Kurzname;
+ delete pNewItem;
+ }
+ if ( !aControls.Len() )
+ {
+ aControls = String::CreateFromAscii("UnknownControl:UnknownControl");
+ Sound::Beep( SOUND_WARNING );
+ }
+
+ aULongNames.Erase();
+ if( (nParams & PARAM_ULONG_1) && (nNr1 & M_RET_NUM_CONTROL) )
+ {
+ if ( pReverseControls )
+ {
+ USHORT nNr;
+ ControlItem *pNewItem = new ControlItemUId( String(), nLNr1 );
+ if ( pReverseControls->Seek_Entry(pNewItem,&nNr) )
+ aULongNames = pReverseControls->GetObject(nNr)->pData->Kurzname;
+ delete pNewItem;
+ }
+ if ( !aULongNames.Len() )
+ {
+ aULongNames = String::CreateFromAscii("Unknown:Unknown");
+ Sound::Beep( SOUND_WARNING );
+ }
+
+ // now determin the best common kontext
+ USHORT i,j;
+ BOOL bFoundUlongName = FALSE, bFoundControl = FALSE;
+ // check for current kontext
+ for ( i = 0 ; !bFoundUlongName && i < aULongNames.GetTokenCount('/') ; i++ )
+ bFoundUlongName = aLastRecordedKontext.Equals( aULongNames.GetToken(i,'/').GetToken( 0,':') );
+
+ for ( j = 0 ; !bFoundControl && j < aControls.GetTokenCount('/') ; j++ )
+ bFoundControl = aLastRecordedKontext.Equals( aControls.GetToken(j,'/').GetToken( 0,':') );
+
+ if ( bFoundUlongName && bFoundControl )
+ {
+ aULongName = aULongNames.GetToken(i-1,'/').GetToken( 1,':');
+ aControl = aControls.GetToken(j-1,'/').GetToken( 1,':');
+ }
+ else
+ { // see if we can find common kontext
+ BOOL bFound = FALSE;
+
+ String aCurrentKontext;
+ for ( i = 0 ; !bFound && i < aULongNames.GetTokenCount('/') ; i++ )
+ {
+ aCurrentKontext = aULongNames.GetToken(i,'/').GetToken( 0,':');
+
+ for ( j = 0 ; !bFound && j < aControls.GetTokenCount('/') ; j++ )
+ {
+ if ( aCurrentKontext.Equals( aControls.GetToken(j,'/').GetToken( 0,':') ) )
+ {
+ bFound = TRUE;
+ aULongName = aULongNames.GetToken(i,'/').GetToken( 1,':');
+ aControl = aControls.GetToken(j,'/').GetToken( 1,':');
+ aLastRecordedKontext = aCurrentKontext;
+ bWriteNewKontext = TRUE;
+ }
+ }
+ }
+ if ( !bFound )
+ {
+ // check if both contain toplevel
+ bFoundUlongName = FALSE;
+ bFoundControl = FALSE;
+ for ( i = 0 ; !bFoundUlongName && i < aULongNames.GetTokenCount('/') ; i++ )
+ bFoundUlongName = aULongNames.GetToken(i,'/').GetToken( 0,':').Equals( aULongNames.GetToken(i,'/').GetToken( 1,':') );
+
+ for ( j = 0 ; !bFoundControl && j < aControls.GetTokenCount('/') ; j++ )
+ bFoundControl = aControls.GetToken(j,'/').GetToken( 0,':').Equals( aControls.GetToken(j,'/').GetToken( 1,':') );
+
+ if ( bFoundUlongName && bFoundControl )
+ {
+ aULongName = aULongNames.GetToken(i-1,'/').GetToken( 1,':');
+ aControl = aControls.GetToken(j-1,'/').GetToken( 1,':');
+ if ( aLastRecordedKontext.Len() )
+ {
+ aLastRecordedKontext.Erase();
+ bWriteNewKontext = TRUE;
+ }
+ }
+ else
+ {
+ String aComment;
+ aComment = CUniString( "'could not Determin common kontext\n" );
+ Sound::Beep( SOUND_WARNING );
+ aWriteStringHdl.Call( &aComment );
+ aULongName = aULongNames.GetToken(i,'/');
+ aControl = aControls.GetToken(j,'/');
+ }
+ }
+ }
+
+ }
+ else
+ { // we only have a Control
+ USHORT i,j;
+ BOOL bFoundControl = FALSE;
+ // check for current kontext
+ for ( i = 0 ; !bFoundControl && i < aControls.GetTokenCount('/') ; i++ )
+ bFoundControl = aLastRecordedKontext.Equals( aControls.GetToken(i,'/').GetToken( 0,':') );
+ if ( bFoundControl )
+ aControl = aControls.GetToken(i-1,'/').GetToken( 1,':');
+ else
+ {
+ aLastRecordedKontext = aControls.GetToken(0,'/').GetToken( 0,':');
+ bWriteNewKontext = TRUE;
+ aControl = aControls.GetToken(0,'/').GetToken( 1,':');
+ }
+
+ }
+
+
+ if ( bWriteNewKontext )
+ {
+ String aCommand = CUniString( "Kontext" );
+ if ( aLastRecordedKontext.Len() )
+ {
+ aCommand.AppendAscii ( " \"" );
+ aCommand += aLastRecordedKontext;
+ aCommand.AppendAscii ( "\"" );
+ }
+ aCommand.AppendAscii( "\n" );
+ aWriteStringHdl.Call( &aCommand );
+ }
+
+ 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;
+ USHORT nNewModify = 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;
+ ULONG nNr;
+ pRetStream->Read( nNr );
+ pRetStream->Read( aString );
+ ReplaceNumbers (aString);
+
+ String aShortName;
+ aShortName = pShortNames->GetName(nNr);
+ aShortName.AppendAscii( " : " );
+ if ( nNr == 0 )
+ nNr = 1;
+
+ String aTmpStr(aShortName);
+ aTmpStr += aString;
+ ADD_ERROR(SbxERR_BAD_ACTION, aTmpStr/*, nNr*/);
+ break;
+ }
+ default:
+ DBG_ERROR1( "Unbekannter Request im Return Stream Nr: %iu", nId );
+ break;
+ }
+ if( !pIn->IsEof() )
+ pRetStream->Read( nId );
+ else
+ {
+ DBG_ERROR( "truncated input stream" );
+ }
+
+ }
+
+ delete pRetStream;
+ if ( bSequenceOK )
+ {
+ nSequence++;
+ pShortNames->Invalidate( nClearSequence - KEEP_SEQUENCES );
+ }
+
+ bReturnOK = TRUE;
+
+ return TRUE;
+} // RetService::Request()
+
+String TestToolObj::GetMethodName( ULONG nMethodId )
+{
+ USHORT nElement;
+ if ( !Controls::pClasses ) // Ist static, wird also nur einmal geladen
+ ReadFlatArray( Controls::arClasses, Controls::pClasses );
+ if ( Controls::pClasses )
+ {
+ for ( nElement = 0 ; nElement < Controls::pClasses->Count() ; nElement++ )
+ if ( Controls::pClasses->GetObject(nElement)->pData->aUId.GetULONG() == nMethodId )
+ return Controls::pClasses->GetObject(nElement)->pData->Kurzname;
+ }
+ return String();
+}
+
+String TestToolObj::GetKeyName( USHORT nKeyCode )
+{
+ USHORT nElement;
+ if ( !CmdStream::pKeyCodes ) // Ist static, wird also nur einmal geladen
+ ReadFlatArray( CmdStream::arKeyCodes, CmdStream::pKeyCodes );
+ if ( CmdStream::pKeyCodes )
+ {
+ for ( nElement = 0 ; nElement < CmdStream::pKeyCodes->Count() ; nElement++ )
+ if ( CmdStream::pKeyCodes->GetObject(nElement)->pData->aUId.GetULONG() == nKeyCode )
+ return CmdStream::pKeyCodes->GetObject(nElement)->pData->Kurzname;
+ }
+ return CUniString( "UnknownKeyCode" );
+}
+
+void TestToolObj::ReplaceNumbers(String &aText)
+{
+static ControlDefLoad __READONLY_DATA arRes_Type [] =
+#include "res_type.hxx"
+
+ static CNames *pRTypes = NULL;
+ xub_StrLen nStart,nGleich,nEnd,nStartPos = 0;
+ ULONG nNumber;
+ String aType,aResult;
+ BOOL bFound;
+
+ while ( (nStart = aText.Search(StartKenn,nStartPos)) != STRING_NOTFOUND &&
+ (nGleich = aText.SearchAscii("=",nStart+StartKenn.Len())) != STRING_NOTFOUND &&
+ (nEnd = aText.Search(EndKenn,nGleich+1)) != STRING_NOTFOUND)
+ {
+ aType = aText.Copy(nStart,nGleich-nStart);
+ nNumber = aText.Copy(nGleich+1,nEnd-nGleich-1).ToInt64();
+ bFound = FALSE;
+ if ( aType.CompareTo(UIdKenn) == COMPARE_EQUAL )
+ {
+ aResult = pShortNames->GetName(nNumber);
+ bFound = TRUE;
+ }
+ if ( aType.CompareTo(MethodKenn ) == COMPARE_EQUAL )
+ {
+ bFound = TRUE;
+ aResult = GetMethodName( nNumber );
+ }
+ if ( aType.CompareTo(RcKenn ) == COMPARE_EQUAL )
+ {
+ bFound = TRUE;
+ if ( !pRCommands ) // Ist static, wird also nur einmal geladen
+ ReadFlatArray( arR_Cmds, pRCommands );
+
+ USHORT nElement;
+ if ( pRCommands )
+ {
+ for ( nElement = 0 ; nElement < pRCommands->Count() ; nElement++ )
+ if ( pRCommands->GetObject(nElement)->pData->aUId.GetULONG() == nNumber )
+ {
+ aResult = pRCommands->GetObject(nElement)->pData->Kurzname;
+ nElement = pRCommands->Count();
+ }
+ }
+ }
+ if ( aType.CompareTo(TypeKenn ) == COMPARE_EQUAL )
+ {
+ bFound = TRUE;
+ if ( !pRTypes ) // Ist static, wird also nur einmal geladen
+ ReadFlatArray( arRes_Type, pRTypes );
+
+ USHORT nElement;
+ if ( pRTypes )
+ {
+ for ( nElement = 0 ; nElement < pRTypes->Count() ; nElement++ )
+ if ( pRTypes->GetObject(nElement)->pData->aUId.GetULONG() == nNumber )
+ {
+ aResult = pRTypes->GetObject(nElement)->pData->Kurzname;
+ nElement = pRTypes->Count();
+ }
+ }
+ }
+ if ( aType.CompareTo(SlotKenn ) == COMPARE_EQUAL )
+ {
+ aResult = pShortNames->GetName(nNumber);
+ bFound = TRUE;
+ }
+ if ( aType.CompareTo(TabKenn ) == COMPARE_EQUAL )
+ {
+ if ( nNumber > nStart )
+ aResult.Fill( nNumber - nStart +1 );
+ else
+ aResult = CUniString(" ");
+ bFound = TRUE;
+ }
+
+ nStartPos = nStart;
+ if ( bFound )
+ {
+ aText.Erase(nStart,nEnd+EndKenn.Len()-nStart);
+ aText.Insert(aResult,nStart);
+ nStartPos += aResult.Len();
+ }
+ else
+ nStartPos += StartKenn.Len();
+ }
+}
+
+
+SbTextType TestToolObj::GetSymbolType( const String &rSymbol, BOOL bWasControl )
+{
+ if ( rSymbol.CompareToAscii( "try" ) == COMPARE_EQUAL
+ || rSymbol.CompareToAscii( "catch" ) == COMPARE_EQUAL
+ || rSymbol.CompareToAscii( "endcatch" ) == COMPARE_EQUAL
+ || rSymbol.CompareToAscii( "testcase" ) == COMPARE_EQUAL
+ || rSymbol.CompareToAscii( "endcase" ) == COMPARE_EQUAL )
+ {
+ return TT_KEYWORD;
+ }
+
+
+ ControlDef WhatName( rSymbol, 0 );
+
+ if ( bWasControl )
+ {
+ if ( !Controls::pClasses ) // Ist static, wird also nur einmal geladen
+ ReadFlatArray( Controls::arClasses, Controls::pClasses );
+
+ if ( Controls::pClasses && Controls::pClasses->Seek_Entry( &WhatName ) )
+ return TT_METHOD;
+ else
+ return TT_NOMETHOD;
+ }
+
+ // Die Controls durchsuchen
+ if ( pControls )
+ {
+ USHORT nWin;
+
+ for ( nWin = 0 ; nWin < pControls->Count() ; nWin++ )
+ {
+ if ( ((ControlDef*)pControls->GetObject( nWin ))->SonSeek_Entry( &WhatName ) )
+ return TT_CONTROL;
+ }
+ }
+
+ // Die Slots durchsuchen
+ if ( pSIds && pSIds->Seek_Entry( &WhatName ) )
+ return TT_SLOT;
+
+ // Ist es ein RemoteCommand
+ if ( !pRCommands ) // Ist static, wird also nur einmal geladen
+ ReadFlatArray( arR_Cmds, pRCommands );
+ if ( pRCommands && pRCommands->Seek_Entry( &WhatName ) )
+ return TT_REMOTECMD;
+
+ // Wenns sonst nix war, dann vielleicht ein Lokales Kommando
+ SbxVariable *pVar = SbxObject::Find( rSymbol, SbxCLASS_DONTCARE );
+ if ( pVar && ( pVar->ISA(SbxMethod) || pVar->ISA(SbxProperty) ) )
+ {
+ return TT_LOCALCMD;
+ }
+
+ return SB_SYMBOL; // Alles was hier landet ist vom Typ SB_SYMBOL und bleibt es auch
+}
+
+
+#undef P_FEHLERLISTE
+#define P_FEHLERLISTE ((TestToolObj*)(GetParent()))->GetFehlerListe()
+
+Controls::Controls( String aName )
+: SbxObject( aName)
+{
+ pMethodVar = new SbxTransportMethod( SbxVARIANT );
+ pMethodVar -> SetName( CUniString("Dummy") );
+ Insert( pMethodVar );
+// pMethodVar = Make( CUniString("Dummy"), SbxCLASS_PROPERTY, SbxULONG );
+}
+
+
+Controls::~Controls()
+{}
+
+
+void Controls::ChangeListener()
+{
+ EndListening( pMethodVar->GetBroadcaster(), TRUE );
+ GetParent()->StartListening( pMethodVar->GetBroadcaster(), TRUE );
+}
+
+void Controls::SFX_NOTIFY( SfxBroadcaster&, const TypeId&,
+ const SfxHint& rHint, const TypeId& )
+{}
+
+
+
+SbxVariable* Controls::Find( const String& Str, SbxClassType Type)
+{
+ if ( !pClasses ) // Ist static, wird also nur einmal geladen
+ ReadFlatArray( arClasses, pClasses );
+
+ if ( GetUserData() == ID_ErrorDummy )
+ {
+ pMethodVar->SetName(UniString(GetName()).AppendAscii(".").Append(Str));
+ pMethodVar->SetUserData( ID_ErrorDummy );
+ return pMethodVar;
+ }
+
+
+ USHORT nElement;
+ ControlDef WhatName(Str,0);
+ if (pClasses && pClasses->Seek_Entry(&WhatName,&nElement))
+ {
+ pMethodVar->SetName(Str);
+ ULONG nUId = pClasses->GetObject(nElement)->pData->aUId.GetULONG();
+ pMethodVar->nValue = nUId;
+
+ if ( SbxValue::GetType() == SbxSTRING )
+ pMethodVar->SetUserData( ID_StringControl );
+ else
+ pMethodVar->SetUserData( ID_Control );
+ return pMethodVar;
+ }
+ else
+ { // mainly for ID and name
+ SbxVariableRef Old = SbxObject::Find(Str, Type );
+ if (Old)
+ return Old;
+ else if ( Str.CompareIgnoreCaseToAscii("ID") == COMPARE_EQUAL )
+ return NULL; // suppress generation of error in this case
+ }
+ ADD_ERROR(SbxERR_BAD_METHOD,GEN_RES_STR2(S_UNKNOWN_METHOD, GetName(), Str));
+ if ( ((TestToolObj*)(GetParent()))->bQuietErrors )
+ {
+ pMethodVar->SetName(UniString(GetName()).AppendAscii(".").Append(Str));
+ pMethodVar->SetUserData( ID_ErrorDummy );
+ pMethodVar->nValue = 0;
+ return pMethodVar;
+ }
+ return NULL;
+}
+
+
+String TTFormat::ms2s( ULONG nMilliSeconds )
+{
+ if ( nMilliSeconds < 100000 ) // 100 Sekunden
+ return String::CreateFromInt64( nMilliSeconds );
+ if ( nMilliSeconds < 100000*60 ) // 100 Minuten
+ return String::CreateFromInt32( nMilliSeconds / 1000 ).AppendAscii("Sec");
+ return String::CreateFromInt32( nMilliSeconds / 1000 / 60 ).AppendAscii("Min");
+}
+
+
+
diff --git a/automation/source/testtool/objtest.hxx b/automation/source/testtool/objtest.hxx
new file mode 100644
index 000000000000..16d30818f394
--- /dev/null
+++ b/automation/source/testtool/objtest.hxx
@@ -0,0 +1,394 @@
+/*************************************************************************
+ *
+ * $RCSfile: objtest.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: mh $ $Date: 2002-11-18 15:54:15 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2002
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2002 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2002 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _OBJTEST_HXX
+#define _OBJTEST_HXX
+
+#ifndef _FSYS_HXX //autogen
+#include <tools/fsys.hxx>
+#endif
+
+//#include <sbmeth.hxx>
+
+
+#include <testapp.hxx>
+#include <testtool.hxx>
+#include "cmdstrm.hxx"
+#ifndef _BASICRT_HXX
+#include <basic/basicrt.hxx>
+#endif
+#ifndef _BASIC_TESTTOOL_HXX_
+#include <basic/testtool.hxx>
+#endif
+
+// #define ID_BeginBlock 1
+// #define ID_EndBlock 2
+#define ID_Kontext 3
+#define ID_GetError 4
+#define ID_ErrorDummy 5 // Intern zum Behandlen von Fehlenden Controls und Methoden
+#define ID_RecordError 6
+#define ID_Start 7
+//#define ID_Kill 8
+//#define ID_Reset 9
+// #define ID_AppAbort 10
+#define ID_Dispatch 11
+#define ID_UNODispatch 12
+#define ID_Control 13
+#define ID_StartUse 14
+#define ID_Use 15
+#define ID_FinishUse 16
+#define ID_CaseLog 17
+#define ID_ExceptLog 18
+#define ID_PrintLog 19
+#define ID_WarnLog 20
+#define ID_ErrorLog 21
+#define ID_MaybeAddErr 22
+#define ID_ClearError 23
+#define ID_GetNextCloseWindow 24
+#define ID_RemoteCommand 27
+#define ID_SaveIDs 28
+#define ID_AutoExecute 29
+#define ID_Execute 30
+#define ID_DialogHandler 31
+#define ID_GetUnoApp 32
+#define ID_GetIServer 33
+#define ID_RemoteCommandDelay 34
+#define ID_GetApplicationPath 35
+#define ID_MakeIniFileName 36
+#define ID_StringControl 37
+#define ID_Wait 38
+#define ID_GetErrorCount 39
+#define ID_GetWarningCount 40
+#define ID_GetUseFileWarningCount 41
+#define ID_GetTestCaseName 42
+#define ID_GetTestCaseFileName 43
+#define ID_GetTestCaseLineNr 44
+
+
+#define ID_DoNothing 99
+
+#define DEF_HID_DIR "q:\\testtool\\" // Keine Panik, die werden als FAT Behandelt und
+#define DEF_BASE_DIR "q:\\testtool\\" // dann ins system-Format gewandelt. (DirEntry)
+
+void ReadFlatArray( const ControlDefLoad arWas [], CNames *&pNames );
+
+class ControlData
+{
+public:
+ String Kurzname;
+ TTUniqueId aUId;
+};
+
+DBG_NAMEEX( ControlItem )
+DBG_NAMEEX( ControlDef )
+class ControlItem
+{
+private:
+ void InitData() { pData = new ControlData; }
+public:
+ ControlData *pData;
+
+ ControlItem( const char *Name, TTUniqueId aUIdP );
+ ControlItem( const String &Name, TTUniqueId aUIdP );
+// ControlItem( const String &Name, const String &URL, const URLType aType );
+// ControlItem( const String &Name, const String &URL, const ULONG nUId );
+// ControlItem( const char *Name, const String &URL, const ULONG nUId );
+ ControlItem( ControlData *pDataP );
+ virtual ~ControlItem() {
+DBG_DTOR(ControlItem,0);
+ delete pData;
+ }
+ virtual BOOL operator < (const ControlItem &rPar)=0;
+ virtual BOOL operator == (const ControlItem &rPar)=0;
+// void Write( SvStream &aStream );
+};
+
+SV_DECL_PTRARR_SORT_DEL(CNames, ControlItem*, 50, 10)
+
+#define MK_SON_ACCESS( ClassName )\
+ BOOL SonInsert( const ClassName *pNewEntry ) { return pSons->C40_PTR_INSERT( ControlItem, (ControlItem*&)pNewEntry ); }\
+ BOOL SonSeek_Entry( const ClassName *pSearchEntry, USHORT *nRes = NULL) { return pSons->Seek_Entry( pSearchEntry, nRes ); }\
+ ClassName* SonGetObject( USHORT nNr ) { return (ClassName*)pSons->GetObject( nNr ); }
+
+class ControlSon
+{
+protected:
+ CNames *pSons; // um sicherzustelle, daß nur Söhne des richtien Type reinkommen
+
+public:
+ ControlSon() : pSons( NULL ) {};
+ ~ControlSon();
+// void Write( SvStream &aStream );
+
+ USHORT Son_Count() { return pSons->Count(); }
+ void Sons( CNames *pNewSons ) { pSons = pNewSons; }
+ CNames*& GetSons() { return pSons; }
+};
+
+class ControlItemSon : public ControlItem, public ControlSon
+{
+public:
+ ControlItemSon(const char *Name, TTUniqueId aUIdP )
+ : ControlItem( Name, aUIdP ) {}
+ ControlItemSon(const String &Name, TTUniqueId aUIdP );
+// ControlItemSon(const String &Name, const String &URL, const URLType aType );
+// ControlItemSon(const String &Name, const String &URL, const ULONG nUId );
+// ControlItemSon(const char *Name, const String &URL, const ULONG nUId );
+// void Write( SvStream &aStream );
+};
+
+class ControlDef : public ControlItemSon
+{
+public:
+ ControlDef(const char *Name, TTUniqueId aUIdP )
+ : ControlItemSon( Name, aUIdP ) {DBG_CTOR(ControlDef,0);}
+ ControlDef(const String &Name, TTUniqueId aUIdP );
+// ControlDef(const String &Name, const String &URL, const URLType aType );
+ ControlDef(const String &aOldName, const String &aNewName, ControlDef *pOriginal, BOOL bWithSons = FALSE );
+ ~ControlDef() {DBG_DTOR(ControlDef,0);}
+ virtual BOOL operator < (const ControlItem &rPar);
+ virtual BOOL operator == (const ControlItem &rPar);
+ void Write( SvStream &aStream );
+ MK_SON_ACCESS( ControlDef )
+};
+
+class ControlItemUId : public ControlItem
+{
+public:
+ ControlItemUId(String Name, TTUniqueId aUIdP)
+ : ControlItem( Name, aUIdP){}
+ virtual BOOL operator < (const ControlItem &rPar);
+ virtual BOOL operator == (const ControlItem &rPar);
+};
+
+class ControlItemUIdSon : public ControlItemUId, public ControlSon
+{
+public:
+ ControlItemUIdSon(String Name, TTUniqueId aUIdP) : ControlItemUId( Name, aUIdP) {}
+ MK_SON_ACCESS( ControlItemUId )
+};
+
+class ReverseName : public ControlItemUId
+{
+public:
+ ULONG LastSequence;
+
+ ReverseName(String Name, TTUniqueId aUIdP, ULONG nSeq) : ControlItemUId( Name, aUIdP), LastSequence(nSeq) {}
+};
+
+class CRevNames: public CNames
+{
+public:
+ void Insert( String aName, TTUniqueId aUId, ULONG nSeq );
+ String GetName( TTUniqueId aUId );
+ void Invalidate ( ULONG nSeq );
+};
+
+
+class SbxTransportMethod: public SbxMethod
+{
+public:
+ SbxTransportMethod( SbxDataType );
+ ULONG nValue;
+ String aUnoSlot;
+};
+SV_DECL_IMPL_REF(SbxTransportMethod);
+
+class Controls: public SbxObject
+{
+public:
+ Controls( String aName );
+ ~Controls();
+ void ChangeListener();
+
+ void SFX_NOTIFY( SfxBroadcaster&, const TypeId&, const SfxHint& rHint, const TypeId& );
+ virtual SbxVariable* Find( const String&, SbxClassType );
+ SbxTransportMethodRef pMethodVar; // zum Transport von Find nach Notify
+ static CNames *pClasses;
+ static ControlDefLoad __READONLY_DATA arClasses [];
+
+private:
+ TestToolObj* pTestToolObj;
+};
+SV_DECL_IMPL_REF(Controls);
+
+
+class ImplTestToolObj
+{
+public:
+// ImplTestToolObj()
+// ~ImplTestToolObj()
+
+ String ProgParam; // Parameter der zu Testenden APP; Gesetzt über Start
+
+ DirEntry aFileBase; // Grundpfad für die *.sid und *.win Dateien (Aus Configdatei)
+ DirEntry aLogFileBase; // Grundpfad für die *.res Dateien (Aus Configdatei)
+ DirEntry aHIDDir; // Verzeichnis, in dem die hid.lst gesucht wird
+
+ SbxTransportMethodRef pNextReturn; // Verweis auf die Var, die den Returnwert aufnimmt.
+
+ ControlsRef pControlsObj; // Jeweiliges Objekt, an dem Methoden aufgerufen weden.
+
+#define VAR_POOL_SIZE 8
+ SbxTransportMethodRef pMyVars[VAR_POOL_SIZE]; // Falls in Ausdrücken mehrere verwendet werden
+ ControlsRef pControlsObjs[VAR_POOL_SIZE];
+
+ Time aServerTimeout;
+
+
+// Profiling Datenfelder
+ ULONG LocalStarttime;
+ USHORT nNumBorders;
+ ULONG naValBorders[4];
+ ULONG naNumEntries[5];
+ ULONG naRemoteTime[5];
+ ULONG naLocalTime[5];
+
+ ULONG nMinRemoteCommandDelay;
+ ULONG nMaxRemoteCommandDelay;
+ BOOL bDoRemoteCommandDelay;
+
+ BOOL bLnaguageExtensionLoaded; // Wurde über 'use' was geladen? Für syntax highlighting
+ SfxBroadcaster *pTTSfxBroadcaster;
+
+ ULONG nErrorCount, nWarningCount, nIncludeFileWarningCount;
+
+ BOOL bIsStart; // set tu TRUE while command Start is initiating the communication
+
+ MyBasic* pMyBasic;
+
+ String aTestCaseName; // holds name of current TestCase
+ String aTestCaseFileName; // holds FileName of current TestCase
+ USHORT nTestCaseLineNr; // holds Line of current TestCase
+};
+
+
+class TTFormat
+{
+public:
+ static String ms2s( ULONG nMilliSeconds );
+};
+
+
+#define ADD_TO_LOG( aLogTypep, aMsgp, aFilenamep, nLinep, nCol1p, nCol2p)\
+{ \
+ TTLogMsg *pLogMsg = new TTLogMsg(); \
+ pLogMsg->aDebugData.aMsg = aMsgp; \
+ pLogMsg->aLogFileName = (pImpl->aLogFileBase + DirEntry(aLogFileName)).GetFull(); \
+ pLogMsg->aDebugData.aFilename = aFilenamep; \
+ pLogMsg->aDebugData.nLine = nLinep; \
+ pLogMsg->aDebugData.nCol1 = nCol1p; \
+ pLogMsg->aDebugData.nCol2 = nCol2p; \
+ pLogMsg->aDebugData.aLogType = aLogTypep; \
+ aLogHdl.Call( pLogMsg ); \
+ delete pLogMsg; \
+} \
+
+
+#define ADD_RUN_LOG() \
+ ADD_TO_LOG(LOG_RUN, String(), String(), 0, 0, 0) \
+
+#define ADD_ERROR_LOG(aMsg, aFilename, nLine, nCol1, nCol2) \
+{ \
+ ADD_TO_LOG(LOG_ERROR, aMsg, aFilename, nLine, nCol1, nCol2) \
+ pImpl->nErrorCount++; \
+}
+
+#define ADD_CALL_STACK_LOG(aMsg, aFilename, nLine, nCol1, nCol2) \
+ ADD_TO_LOG(LOG_CALL_STACK, aMsg, aFilename, nLine, nCol1, nCol2) \
+
+
+#define ADD_AUTO_LOG(aLogType, aMsg) \
+{ \
+ if ( BasicRuntimeAccess::HasRuntime() ) \
+ { \
+ BasicRuntime aRun = BasicRuntimeAccess::GetRuntime(); \
+ ADD_TO_LOG(aLogType, aMsg, aRun.GetModuleName(SbxNAME_SHORT_TYPES), \
+ aRun.GetLine(), aRun.GetCol1(), aRun.GetCol2()) \
+ } \
+ else \
+ { \
+ ADD_TO_LOG(aLogType, aMsg, UniString(), 0, 0, STRING_LEN) \
+ } \
+} \
+
+#define ADD_CASE_LOG(aMsg) \
+ ADD_AUTO_LOG(LOG_TEST_CASE, aMsg) \
+
+#define ADD_MESSAGE_LOG(aMsg) \
+ ADD_AUTO_LOG(LOG_MESSAGE, aMsg) \
+
+#define ADD_WARNING_LOG(aMsg) \
+{ \
+ ADD_AUTO_LOG(LOG_WARNING, aMsg) \
+ pImpl->nWarningCount++; \
+}
+
+#define ADD_WARNING_LOG2(aMsg, aFilename, nLine) \
+{ \
+ ADD_TO_LOG(LOG_WARNING, aMsg, aFilename, nLine, 0, STRING_LEN) \
+ pImpl->nWarningCount++; \
+}
+
+#define ADD_ASSERTION_LOG(aMsg) \
+ ADD_AUTO_LOG(LOG_ASSERTION, aMsg) \
+
+#endif
diff --git a/automation/source/testtool/tcommuni.cxx b/automation/source/testtool/tcommuni.cxx
new file mode 100644
index 000000000000..8e3a2bc9d2b5
--- /dev/null
+++ b/automation/source/testtool/tcommuni.cxx
@@ -0,0 +1,231 @@
+/*************************************************************************
+ *
+ * $RCSfile: tcommuni.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: mh $ $Date: 2002-11-18 15:54:21 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2002
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2002 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2002 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+
+#ifndef _SV_CONFIG_HXX //autogen
+#include <vcl/config.hxx>
+#endif
+#ifndef _SV_SVAPP_HXX //autogen
+#include <vcl/svapp.hxx>
+#endif
+#ifndef _TOOLS_TIME_HXX //autogen
+#include <tools/time.hxx>
+#endif
+#ifndef _DEBUG_HXX //autogen
+#include <tools/debug.hxx>
+#endif
+#ifndef _VOS_PROCESS_HXX_
+#include <vos/process.hxx>
+#endif
+
+#ifndef _BASIC_TTRESHLP_HXX
+#include <basic/ttstrhlp.hxx>
+#endif
+
+#include "rcontrol.hxx"
+#include "tcommuni.hxx"
+#include <basic/process.hxx>
+
+CommunicationManagerClientViaSocketTT::CommunicationManagerClientViaSocketTT()
+: CommunicationManagerClientViaSocket( ByteString( GetHostConfig(), RTL_TEXTENCODING_UTF8 ), GetTTPortConfig(), TRUE )
+, aAppPath()
+, aAppParams()
+, pProcess( NULL )
+{
+}
+
+
+BOOL CommunicationManagerClientViaSocketTT::StartCommunication()
+{
+ nRetryConnectCalls = 0;
+ return CommunicationManagerClientViaSocket::StartCommunication();
+}
+
+
+BOOL CommunicationManagerClientViaSocketTT::StartCommunication( String aApp, String aParams )
+{
+ aAppPath = aApp;
+ aAppParams = aParams;
+ return StartCommunication();
+}
+
+
+BOOL CommunicationManagerClientViaSocketTT::RetryConnect()
+{
+ if ( !nRetryConnectCalls++ )
+ {
+ // Die App ist wohl nicht da. Starten wir sie mal.
+ if ( aAppPath.Len() )
+ {
+ delete pProcess;
+
+ pProcess = new Process();
+ pProcess->SetImage( aAppPath, aAppParams );
+
+ BOOL bSucc = pProcess->Start();
+
+ if ( bSucc )
+ {
+ aFirstRetryCall = Time() + Time( 0, 1 ); // Max eine Minute Zeit
+ for ( int i = 10 ; i-- ; )
+ GetpApp()->Reschedule();
+ }
+ return bSucc;
+ }
+ return FALSE;
+ }
+ else
+ {
+ if ( aFirstRetryCall > Time() )
+ {
+ for ( int i = 10 ; i-- ; )
+ GetpApp()->Reschedule();
+ return TRUE;
+ }
+ else
+ return FALSE;
+ }
+}
+
+
+#define GETSET(aVar, KeyName, Dafault) \
+ aVar = aConf.ReadKey(KeyName,"No Entry"); \
+ if ( aVar.CompareTo("No Entry") == COMPARE_EQUAL ) \
+ { \
+ aVar = ByteString(Dafault); \
+ aConf.WriteKey(KeyName, aVar); \
+ }
+
+
+String GetHostConfig()
+{
+ String aHostToTalk;
+
+ for ( int i = 0 ; i < Application::GetCommandLineParamCount() ; i++ )
+ {
+ if ( Application::GetCommandLineParam( i ).Copy(0,6).CompareIgnoreCaseToAscii("-host=") == COMPARE_EQUAL
+#ifndef UNX
+ || Application::GetCommandLineParam( i ).Copy(0,6).CompareIgnoreCaseToAscii("/host=") == COMPARE_EQUAL
+#endif
+ )
+ return Application::GetCommandLineParam( i ).Copy(6);
+ }
+
+ ByteString abHostToTalk;
+ Config aConf(Config::GetConfigName( Config::GetDefDirectory(), CUniString("testtool") ));
+ aConf.SetGroup("Communication");
+
+ GETSET( abHostToTalk, "Host", "localhost" );
+ return UniString( abHostToTalk, RTL_TEXTENCODING_UTF8 );
+}
+
+
+ULONG GetTTPortConfig()
+{
+ String aPortToTalk;
+
+ for ( int i = 0 ; i < Application::GetCommandLineParamCount() ; i++ )
+ {
+ if ( Application::GetCommandLineParam( i ).Copy(0,6).CompareIgnoreCaseToAscii("-port=") == COMPARE_EQUAL
+#ifndef UNX
+ || Application::GetCommandLineParam( i ).Copy(0,6).CompareIgnoreCaseToAscii("/port=") == COMPARE_EQUAL
+#endif
+ )
+ {
+ aPortToTalk = Application::GetCommandLineParam( i ).Copy(6);
+ return aPortToTalk.ToInt64();
+ }
+ }
+
+ ByteString abPortToTalk;
+ Config aConf(Config::GetConfigName( Config::GetDefDirectory(), CUniString("testtool") ));
+ aConf.SetGroup("Communication");
+
+ GETSET( abPortToTalk, "TTPort", ByteString::CreateFromInt32(TESTTOOL_PORT) );
+ return abPortToTalk.ToInt64();
+}
+
+
+ULONG GetUnoPortConfig()
+{
+ String aPortToTalk;
+
+ for ( int i = 0 ; i < Application::GetCommandLineParamCount() ; i++ )
+ {
+ if ( Application::GetCommandLineParam( i ).Copy(0,9).CompareIgnoreCaseToAscii("-unoport=") == COMPARE_EQUAL
+#ifndef UNX
+ || Application::GetCommandLineParam( i ).Copy(0,9).CompareIgnoreCaseToAscii("/unoport=") == COMPARE_EQUAL
+#endif
+ )
+ {
+ aPortToTalk = Application::GetCommandLineParam( i ).Copy(6);
+ return aPortToTalk.ToInt64();
+ }
+ }
+
+ ByteString abPortToTalk;
+ Config aConf(Config::GetConfigName( Config::GetDefDirectory(), CUniString("testtool") ));
+ aConf.SetGroup("Communication");
+
+ GETSET( abPortToTalk, "UnoPort", ByteString::CreateFromInt32(UNO_PORT) );
+ return abPortToTalk.ToInt64();
+}
+
diff --git a/automation/source/testtool/tcommuni.hxx b/automation/source/testtool/tcommuni.hxx
new file mode 100644
index 000000000000..807930d36186
--- /dev/null
+++ b/automation/source/testtool/tcommuni.hxx
@@ -0,0 +1,100 @@
+/*************************************************************************
+ *
+ * $RCSfile: tcommuni.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: mh $ $Date: 2002-11-18 15:54:26 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2002
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2002 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2002 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#if SUPD >= 380
+#include <svtools/communi.hxx>
+#else
+#include <communi.hxx>
+#endif
+#include <tools/link.hxx>
+#include <svtools/svarray.hxx>
+
+#include <vos/thread.hxx>
+
+#ifndef _STRING_LIST
+DECLARE_LIST( StringList, String * );
+#define _STRING_LIST
+#endif
+
+class Process;
+
+class CommunicationManagerClientViaSocketTT : public CommunicationManagerClientViaSocket
+{
+public:
+ CommunicationManagerClientViaSocketTT();
+
+ virtual BOOL StartCommunication();
+ virtual BOOL StartCommunication( String aApp, String aParams );
+
+protected:
+ virtual BOOL RetryConnect();
+ USHORT nRetryConnectCalls;
+ Time aFirstRetryCall;
+ String aAppPath;
+ String aAppParams;
+ Process *pProcess;
+};
+
+
+String GetHostConfig();
+ULONG GetTTPortConfig();
+ULONG GetUnoPortConfig();
+