diff options
author | August Sodora <augsod@gmail.com> | 2011-12-07 00:55:10 -0500 |
---|---|---|
committer | August Sodora <augsod@gmail.com> | 2011-12-07 00:56:22 -0500 |
commit | a2eb0cf44bbd15ae24f9423d3bc6e420691c300d (patch) | |
tree | b11ce54011011e96217d9b504e81ec87aaef38a4 /automation/source/testtool | |
parent | e2621785569969374cc3bc39fae0341d8b848612 (diff) |
Remove testtool
Diffstat (limited to 'automation/source/testtool')
19 files changed, 0 insertions, 6383 deletions
diff --git a/automation/source/testtool/Makefile b/automation/source/testtool/Makefile deleted file mode 100644 index c07c6c8cf22e..000000000000 --- a/automation/source/testtool/Makefile +++ /dev/null @@ -1,60 +0,0 @@ -# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- -# Version: MPL 1.1 / GPLv3+ / LGPLv3+ -# -# The contents of this file are subject to the Mozilla Public License Version -# 1.1 (the "License"); you may not use this file except in compliance with -# the License or as specified alternatively below. You may obtain a copy of -# the License at http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS IS" basis, -# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -# for the specific language governing rights and limitations under the -# License. -# -# Major Contributor(s): -# Copyright (C) 2011 Red Hat, Inc., David Tardon <dtardon@redhat.com> -# (initial developer) -# -# All Rights Reserved. -# -# For minor contributions see the git repository. -# -# Alternatively, the contents of this file may be used under the terms of -# either the GNU General Public License Version 3 or later (the "GPLv3+"), or -# the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), -# in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable -# instead of those above. - -gb_PARTIALBUILD:=T -include $(GBUILDDIR)/gbuild_simple.mk - -BASEDIR := $(dir $(firstword $(MAKEFILE_LIST))) - -define filter_header -$(1).hxx : $(3)/$(2) - $(PERL) $(BASEDIR)/filter.pl $(3) $(2) $(1) $(4) - -endef - -$(eval $(call filter_header,classes,rcontrol.hxx,$(realpath $(BASEDIR)/../inc),M_)) -$(eval $(call filter_header,keycodes,vcl/keycodes.hxx,$(OUTDIR)/inc,KEY_)) -$(eval $(call filter_header,r_cmds,rcontrol.hxx,$(realpath $(BASEDIR)/../inc),RC_)) -$(eval $(call filter_header,res_type,tools/wintypes.hxx,$(OUTDIR)/inc,WINDOW_)) - -$(CURDIR)/testtool.ini : $(BASEDIR)/testtool.ini -ifeq ($(GUI),UNX) - sed -e s/!INIFILESUFFIX!/rc/ -e s/!BRANDPATH!// $< > $@ -else ifeq ($(GUI),WNT) - sed -e s/!INIFILESUFFIX!/.ini/ -e s/!BRANDPATH!/../ $< > $@ -endif - -.DEFAULT_GOAL := all -.PHONY : all -all : \ - classes.hxx \ - keycodes.hxx \ - r_cmds.hxx \ - res_type.hxx \ - $(CURDIR)/testtool.ini - -# vim: set ts=4 sw=4 noet: diff --git a/automation/source/testtool/cmdstrm.cxx b/automation/source/testtool/cmdstrm.cxx deleted file mode 100644 index e51d63d6ce12..000000000000 --- a/automation/source/testtool/cmdstrm.cxx +++ /dev/null @@ -1,453 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include <vcl/keycod.hxx> -#include <basic/sbx.hxx> -#include <tools/stream.hxx> - -#include "cmdstrm.hxx" -#include "rcontrol.hxx" -#include "objtest.hxx" -#include "ittresid.hxx" -#include "svcommstream.hxx" -#include <basic/testtool.hrc> - -ControlDefLoad const CmdStream::arKeyCodes [] = -#include <keycodes.hxx> -CNames *CmdStream::pKeyCodes = NULL; - -ResMgr* IttResId::getIttResMgr() -{ - static ResMgr* pMgr = NULL; - if( ! pMgr ) - pMgr = CREATEVERSIONRESMGR( stt ); - return pMgr; -} - -CmdStream::CmdStream() -{ - pSammel = new SvMemoryStream(); - pCommStream = new SvCommStream( pSammel ); -} - -CmdStream::~CmdStream() -{ - delete pCommStream; - delete pSammel; -} - - -#define PUT_CHAR(ch) \ - sal_uInt16 nMCode = nModify + ch; \ - sal_uInt16 _Code = 1; \ - if ( (nMCode & 0xFF) == 0 ) \ - _Code |= 2; \ - if ( (nMCode >> 8) == 0 ) \ - _Code |= 4; \ - Result += (char) _Code; \ - Result += (char) ( nMCode & 0xFF ); \ - Result += (char) ( nMCode >> 8 ) - - -String CmdStream::WandleKeyEventString( String aKeys ) -{ - if ( !pKeyCodes ) - ReadFlatArray(arKeyCodes,pKeyCodes); - if ( !pKeyCodes ) - return aKeys; - - xub_StrLen nPos1 = 0; - while ( (nPos1 = aKeys.Search('<',nPos1)) != STRING_NOTFOUND) - { - xub_StrLen nPos2 = aKeys.Search('>',nPos1); - if ( nPos2 != STRING_NOTFOUND ) - { - String Work = aKeys.Copy(nPos1+1,nPos2-nPos1+1-2); - aKeys.Erase(nPos1,nPos2-nPos1+1); // includes removing <>'s - String Result, Token; - sal_uInt16 nModify = 0; - while ( Work.Len() > 0 ) - { - Token = Work.GetToken(0,' '); - Work.Erase(0,Token.Len()+1); - ControlDef WhatName(Token,rtl::OString()); - sal_uInt16 nElement; - if (pKeyCodes->Seek_Entry(&WhatName,&nElement)) - { - // FIXME: HELPID - sal_uInt16 nCode = 0;//(sal_uInt16) pKeyCodes->GetObject(nElement)->pData->aUId.GetNum(); - if ( nCode >= KEY_SHIFT ) - nModify ^= nCode; - else - { - if ( ( nModify == 0 ) && - (((nCode & 0xFF00) == KEYGROUP_NUM) || - ((nCode & 0xFF00) == KEYGROUP_ALPHA) || - ( nCode == KEY_SPACE) || - ( nCode == KEY_ADD) || - ( nCode == KEY_SUBTRACT) || - ( nCode == KEY_MULTIPLY) || - ( nCode == KEY_DIVIDE) || - ( nCode == KEY_POINT) || - ( nCode == KEY_COMMA) || - ( nCode == KEY_LESS) || - ( nCode == KEY_GREATER) || - ( nCode == KEY_EQUAL) ) ) - { - switch ( nCode ) - { - case KEY_SPACE: Token = ' '; break; - case KEY_ADD: Token = '+'; break; - case KEY_SUBTRACT: Token = '-'; break; - case KEY_MULTIPLY: Token = '*'; break; - case KEY_DIVIDE: Token = '/'; break; - case KEY_POINT: Token = '.'; break; - case KEY_COMMA: Token = ','; break; - case KEY_LESS: Token = '<'; break; - case KEY_GREATER: Token = '>'; break; - case KEY_EQUAL: Token = '='; break; - default: -// if ( nModify == 0 ) -// Token.ToLower(); -// else -// Token.ToUpper(); - ; - } - Result += Token; - } - else - { - PUT_CHAR (nCode); - } - } - } - else - { - Result += '<'; - Result += Token; - Result += ' '; - Result += String( IttResId( S_INVALID_KEYCODE ) ); - Result += '>'; - } - } - aKeys.Insert(Result,nPos1); - nPos1 = nPos1 + Result.Len(); - } - else - nPos1 = aKeys.Len() + 1; - } - - return aKeys; -} - - -void CmdStream::WriteSortedParams( SbxArray* rPar, sal_Bool IsKeyString ) -{ - sal_uInt16 nParams = PARAM_NONE; - sal_uInt16 nNr1=0,nNr2=0,nNr3=0,nNr4=0; - comm_UINT32 nLNr1=0; - String aString1,aString2; - sal_Bool bBool1=sal_False,bBool2=sal_False; - - if ( rPar ) - { - for ( sal_uInt16 i = 1; i < rPar->Count() ; i++) - { - switch (rPar->Get( i )->GetType()) - { - case SbxLONG: // always pass everything as Short - case SbxULONG: - case SbxSALINT64: - case SbxSALUINT64: - case SbxDOUBLE: - case SbxINTEGER: - case SbxBYTE: - case SbxUSHORT: - case SbxINT: - case SbxUINT: - case SbxSINGLE: - if ( (nParams & PARAM_UINT16_1) == 0 ) - { - nParams |= PARAM_UINT16_1; - nNr1 = rPar->Get( i )->GetUShort(); - } - else if ( (nParams & PARAM_UINT16_2) == 0 ) - { - nParams |= PARAM_UINT16_2; - nNr2 = rPar->Get( i )->GetUShort(); - } - else if ( (nParams & PARAM_UINT16_3) == 0 ) - { - nParams |= PARAM_UINT16_3; - nNr3 = rPar->Get( i )->GetUShort(); - } - else if ( (nParams & PARAM_UINT16_4) == 0 ) - { - nParams |= PARAM_UINT16_4; - nNr4 = rPar->Get( i )->GetUShort(); - } - else - SbxBase::SetError( SbxERR_WRONG_ARGS ); - break; - case SbxOBJECT: // whenever a control is passed. TabPage, MenuBar - { - SbxProperty *pMember = NULL; - if ( rPar->Get( i )->ISA( SbxObject ) ) - pMember = ((SbxObject*)rPar->Get( i ))->GetDfltProperty(); - if ( pMember != NULL ) - { - if ( pMember->GetType() == SbxSTRING ) - { - if ( nParams & PARAM_STR_1 ) - if ( nParams & PARAM_STR_2 ) - SbxBase::SetError( SbxERR_WRONG_ARGS ); - else - { - nParams |= PARAM_STR_2; - aString2 = pMember->GetString(); - } - else - { - nParams |= PARAM_STR_1; - aString1 = pMember->GetString(); - } - break; - } - else if ( pMember->GetType() == SbxULONG ) - { - if ( nParams & PARAM_UINT32_1 ) - SbxBase::SetError( SbxERR_WRONG_ARGS ); - else - { - nParams |= PARAM_UINT32_1; - nLNr1 = pMember->GetULong(); - } - } - else - SbxBase::SetError( SbxERR_NAMED_NOT_FOUND ); - } - else - { - SbxBase::SetError( SbxERR_NAMED_NOT_FOUND ); - } - } - break; - case SbxSTRING: - case SbxCHAR: - if ( nParams & PARAM_STR_1 ) - if ( nParams & PARAM_STR_2 ) - SbxBase::SetError( SbxERR_WRONG_ARGS ); - else - { - nParams |= PARAM_STR_2; - aString2 = rPar->Get( i )->GetString(); - } - else - { - nParams |= PARAM_STR_1; - aString1 = rPar->Get( i )->GetString(); - } - break; - case SbxBOOL: - if ( nParams & PARAM_BOOL_1 ) - if ( nParams & PARAM_BOOL_2 ) - SbxBase::SetError( SbxERR_WRONG_ARGS ); - else - { - nParams |= PARAM_BOOL_2; - bBool2 = rPar->Get( i )->GetBool(); - } - else - { - nParams |= PARAM_BOOL_1; - bBool1 = rPar->Get( i )->GetBool(); - } - break; - default: - SbxBase::SetError( SbxERR_WRONG_ARGS ); - break; - } - } - } - Write (nParams); - if( nParams & PARAM_UINT16_1 ) Write( nNr1 ); - if( nParams & PARAM_UINT16_2 ) Write( nNr2 ); - if( nParams & PARAM_UINT16_3 ) Write( nNr3 ); - if( nParams & PARAM_UINT16_4 ) Write( nNr4 ); - if( nParams & PARAM_UINT32_1 ) Write( nLNr1 ); - if( nParams & PARAM_STR_1 ) Write( aString1, IsKeyString ); - if( nParams & PARAM_STR_2 ) Write( aString2, IsKeyString ); - if( nParams & PARAM_BOOL_1 ) Write( bBool1 ); - if( nParams & PARAM_BOOL_2 ) Write( bBool2 ); -} - -void CmdStream::GenCmdCommand( sal_uInt16 nNr, SbxArray* rPar ) -{ - Write(sal_uInt16(SICommand)); - Write(nNr); - WriteSortedParams(rPar, (nNr & M_KEY_STRING) != 0 ); -} - -void CmdStream::GenCmdSlot( sal_uInt16 nNr, SbxArray* rPar ) -{ - Write(sal_uInt16(SISlot)); - Write(nNr); - if (rPar) - { - sal_uInt16 nAnz = (rPar->Count()-1) >> 1; - Write(nAnz); - sal_Bool bWriteUnoSlot = rPar->Get( 1 )->GetType() == SbxSTRING; - - for (sal_uInt16 n = 1 ; n <= nAnz ; n++) - { - /// #59513# not necessary anymore -// sal_uLong nUserData = rPar->Get( 2*n-1 )->GetUserData(); -// rPar->Get( 2*n-1 )->SetUserData(ID_DoNothing); // prevents execution of the slots that are passed as parameters - - if ( bWriteUnoSlot ) - Write(rPar->Get( 2*n-1 )->GetString()); - else - Write(rPar->Get( 2*n-1 )->GetUShort()); - switch (rPar->Get( 2*n )->GetType()) - { - case SbxINTEGER: - case SbxBYTE: - case SbxUSHORT: - case SbxINT: - case SbxUINT: - case SbxSINGLE: - if ( !bWriteUnoSlot ) - Write( (sal_uInt16)BinUINT16 ); - Write(rPar->Get( 2*n )->GetUShort()); - break; - case SbxLONG: - case SbxULONG: - case SbxSALINT64: - case SbxSALUINT64: - case SbxDOUBLE: - if ( !bWriteUnoSlot ) - Write( (sal_uInt16)BinUINT32 ); - Write(rPar->Get( 2*n )->GetULong()); - break; - case SbxSTRING: - case SbxCHAR: - if ( !bWriteUnoSlot ) - Write( (sal_uInt16)BinString); - Write((String)rPar->Get( 2*n )->GetString()); // Cast for OS/2 - break; - case SbxBOOL: - if ( !bWriteUnoSlot ) - Write( (sal_uInt16)BinBool); - Write(rPar->Get( 2*n )->GetBool()); - break; - default: - SbxBase::SetError( SbxERR_WRONG_ARGS ); - break; - } - - /// #59513# //don't need this anymore (see prior comment?) -// rPar->Get( 2*n-1 )->SetUserData(nUserData); // Set it back, so everything's clean. - } - } - else - Write(sal_uInt16(0)); -} - -void CmdStream::GenCmdUNOSlot( const String &aURL ) -{ - Write( sal_uInt16(SIUnoSlot) ); -/* Write( sal_uInt16(0) ); // The SID_OPENURL is entered here. - // That must be wired hard in the Office and not here of course - // as the ID might change - - // Because the ID must also be taken for the PoolItem from the Office, it is not - // necessary to send a PoolItem here. - - Write( sal_uInt16(0) ); // number of PoolItems - - // instead there's an extra string sent by the Office which is changed to an - // SfxStringItem with the respective ID - Write( aURL ); // String for the PoolItem*/ - - Write( aURL ); // UNO URL -} - -void CmdStream::GenCmdControl( comm_UINT32 nUId, sal_uInt16 nMethodId, SbxArray* rPar ) -{ - Write(sal_uInt16(SIControl)); - Write(nUId); - Write(nMethodId); - WriteSortedParams(rPar, (nMethodId & M_KEY_STRING) != 0 ); -} - -void CmdStream::GenCmdControl( String aUId, sal_uInt16 nMethodId, SbxArray* rPar ) -{ - Write(sal_uInt16(SIStringControl)); - Write(aUId); - Write(nMethodId); - WriteSortedParams(rPar, (nMethodId & M_KEY_STRING) != 0 ); -} - -void CmdStream::GenCmdFlow( sal_uInt16 nArt ) -{ - Write(sal_uInt16(SIFlow)); - Write(nArt); - Write(sal_uInt16(PARAM_NONE)); // type of the following parameters -} - -void CmdStream::GenCmdFlow( sal_uInt16 nArt, comm_UINT32 nNr1 ) -{ - Write(sal_uInt16(SIFlow)); - Write(nArt); - Write(sal_uInt16(PARAM_UINT32_1)); // type of the following parameters - Write(nNr1); -} - -void CmdStream::Write( String aString, sal_Bool IsKeyString ) -{ - if ( IsKeyString ) - Write( WandleKeyEventString( aString ), sal_False ); - else - Write( aString.GetBuffer(), aString.Len() ); -} - -SvMemoryStream* CmdStream::GetStream() -{ - return pSammel; -} - -void CmdStream::Reset( comm_UINT32 nSequence ) -{ - delete pCommStream; - delete pSammel; - pSammel = new SvMemoryStream(); - pCommStream = new SvCommStream( pSammel ); - GenCmdFlow (F_Sequence,nSequence); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/automation/source/testtool/cmdstrm.hxx b/automation/source/testtool/cmdstrm.hxx deleted file mode 100644 index 7b8afef71f53..000000000000 --- a/automation/source/testtool/cmdstrm.hxx +++ /dev/null @@ -1,79 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef _CMDSTRM_HXX -#define _CMDSTRM_HXX - -#include <objtest.hxx> -#include <testapp.hxx> -#include "cmdbasestream.hxx" - -class CmdStream : public CmdBaseStream -{ -public: - CmdStream(); - ~CmdStream(); - - void WriteSortedParams( SbxArray* rPar, sal_Bool IsKeyString = sal_False ); - - void GenCmdCommand( sal_uInt16 nNr, SbxArray* rPar ); - - void GenCmdSlot( sal_uInt16 nNr, SbxArray* rPar ); - - void GenCmdUNOSlot( const String &aURL ); - - void GenCmdControl( comm_UINT32 nUId, sal_uInt16 nMethodId, SbxArray* rPar ); - void GenCmdControl( String aUId, sal_uInt16 nMethodId, SbxArray* rPar ); - - - void GenCmdFlow( sal_uInt16 nArt ); - void GenCmdFlow( sal_uInt16 nArt, comm_UINT32 nNr1 ); - - void Reset(comm_UINT32 nSequence); - - SvMemoryStream* GetStream(); - - static CNames *pKeyCodes; // names of special keys MOD1, F1, LEFT ... - static ControlDefLoad const arKeyCodes []; - -private: - String WandleKeyEventString( String aKeys ); // uses pKeyCodes. <RETURN> <SHIFT LEFT LEFT> - - using CmdBaseStream::Write; - void Write( comm_UINT16 nNr ){CmdBaseStream::Write( nNr );} - void Write( comm_UINT32 nNr ){CmdBaseStream::Write( nNr );} - void Write( const comm_UniChar* aString, comm_UINT16 nLenInChars ){CmdBaseStream::Write( aString, nLenInChars );} - void Write( comm_BOOL bBool ){CmdBaseStream::Write( bBool );} -// new - void Write( String aString, sal_Bool IsKeyString = sal_False ); - - SvMemoryStream *pSammel; -}; - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/automation/source/testtool/comm_bas.cxx b/automation/source/testtool/comm_bas.cxx deleted file mode 100644 index 5279a49b2d4c..000000000000 --- a/automation/source/testtool/comm_bas.cxx +++ /dev/null @@ -1,430 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - - -#include "comm_bas.hxx" -#include <tools/errcode.hxx> -#include <basic/sbxobj.hxx> -#include <basic/sbx.hxx> -#include <basic/sbxvar.hxx> -#include <vcl/svapp.hxx> -#include <automation/communi.hxx> -#include <basic/ttstrhlp.hxx> - -// The CommunicationManager consists of the following elements: -// 1) Properties: -// none -// 2) Methods: -// CommunicationLink StartCommunication( Host, Port ) -// StopAllCommunication -// sal_Bool IsCommunicationRunning -// String GetMyName -// sal_Bool IsLinkValid( CommunicationLink ) -// SetCommunicationEventHandler( String ) - -// The CommunicationLink consists of the following elements: -// 1) Properties: -// none -// 2) Methods: -// StopCommunication -// String GetMyName -// String GetHostName -// Send( String ) -// String GetString - - -// This implementation is an example for a table-controlled -// version that can contain a lot of elements. The elements are -// taken from the table to the object when needed. - -// The nArgs-field of a table entry is encrypted as follows: - -#define _ARGSMASK 0x00FF // up to 255 arguments -#define _RWMASK 0x0F00 // mask for R/W-Bits -#define _TYPEMASK 0xF000 // mask for the entry type - -#define _READ 0x0100 // can be read -#define _BWRITE 0x0200 // can be used as Lvalue -#define _LVALUE _BWRITE // can be used as Lvalue -#define _READWRITE 0x0300 // both -#define _OPT 0x0400 // TRUE: optional parameter -#define _METHOD 0x1000 // mask bit for a method -#define _PROPERTY 0x2000 // mask bit for a property -#define _COLL 0x4000 // mask bit for a collection - // combination of bits above: -#define _FUNCTION 0x1100 // mask for a function -#define _LFUNCTION 0x1300 // mask for a function, that works as Lvalue too -#define _ROPROP 0x2100 // mask Read Only-Property -#define _WOPROP 0x2200 // mask Write Only-Property -#define _RWPROP 0x2300 // mask Read/Write-Property -#define _COLLPROP 0x4100 // mask Read-Collection-Element - - -CommunicationWrapper::Methods CommunicationWrapper::aManagerMethods[] = { - -{ "StartCommunication", SbxEMPTY, &CommunicationWrapper::MStartCommunication, 2 | _FUNCTION }, - - { "Host", SbxSTRING, NULL, 0 }, - { "Port", SbxLONG, NULL, 0 }, - -{ "StopAllCommunication", SbxEMPTY, &CommunicationWrapper::MStopAllCommunication, 0 | _FUNCTION }, - -{ "IsCommunicationRunning", SbxBOOL, &CommunicationWrapper::MIsCommunicationRunning, 0 | _FUNCTION }, -// as FQDN -{ "GetMyName", SbxSTRING, &CommunicationWrapper::MGetMyName, 0 | _FUNCTION }, - -{ "IsLinkValid", SbxBOOL, &CommunicationWrapper::MIsLinkValid, 1 | _FUNCTION }, - - { "Link", SbxOBJECT, NULL, 0 }, - -{ "SetCommunicationEventHandler", SbxEMPTY, &CommunicationWrapper::MSetCommunicationEventHandler, 1 | _FUNCTION }, - - { "FuncName", SbxSTRING, NULL, 0 }, - -{ NULL, SbxNULL, NULL, -1 }}; // end of the table - - - - - - -CommunicationWrapper::Methods CommunicationWrapper::aLinkMethods[] = { - -{ "StopCommunication", SbxEMPTY, &CommunicationWrapper::LStopCommunication, 0 | _FUNCTION }, - -{ "GetMyName", SbxSTRING, &CommunicationWrapper::LGetMyName, 0 | _FUNCTION }, - -{ "GetHostName", SbxSTRING, &CommunicationWrapper::LGetHostName, 0 | _FUNCTION }, - -{ "Send", SbxEMPTY, &CommunicationWrapper::LSend, 1 | _FUNCTION }, - - { "SendString", SbxSTRING, NULL, 0 }, - -{ "GetString", SbxSTRING, &CommunicationWrapper::LGetString, 0 | _FUNCTION }, - -{ NULL, SbxNULL, NULL, -1 }}; // end of the table - - - - - -// constructor for the manager -CommunicationWrapper::CommunicationWrapper( const String& rClass ) : SbxObject( rClass ) -, m_pLink( NULL ) -, m_bIsManager( sal_True ) -, m_bCatchOpen( sal_False ) -, m_pNewLink( NULL ) -{ - m_pMethods = &aManagerMethods[0]; - m_pManager = new CommunicationManagerClientViaSocket; - m_pManager->SetConnectionOpenedHdl( LINK( this, CommunicationWrapper, Open ) ); - m_pManager->SetConnectionClosedHdl( LINK( this, CommunicationWrapper, Close ) ); - m_pManager->SetDataReceivedHdl( LINK( this, CommunicationWrapper, Data ) ); -} - -// constructor for the link -CommunicationWrapper::CommunicationWrapper( CommunicationLink *pThisLink ) : SbxObject( CUniString("Link") ) -, m_pLink( pThisLink ) -, m_bIsManager( sal_False ) -, m_bCatchOpen( sal_False ) -, m_pNewLink( NULL ) -{ - m_pMethods = &aLinkMethods[0]; - m_pManager = (CommunicationManagerClientViaSocket*)pThisLink->GetCommunicationManager(); -} - -// deconstructor -CommunicationWrapper::~CommunicationWrapper() -{ - if ( m_bIsManager ) - delete m_pManager; -} - - -// Search for an element: -// Here it goes through the method table until an appropriate one -// has been found. -// If the method/property has not been found, get back only NULL -// without error code because that way a whole chain of objects -// can be asked for the method/property. - -SbxVariable* CommunicationWrapper::Find( const String& rName, SbxClassType t ) -{ - // Does the element exist already? - SbxVariable* pRes = SbxObject::Find( rName, t ); - if( !pRes && t != SbxCLASS_OBJECT ) - { - // look for it if not - Methods* p = m_pMethods; - short nIndex = 0; - sal_Bool bFound = sal_False; - while( p->nArgs != -1 ) - { - if( rName.CompareIgnoreCaseToAscii( p->pName ) == COMPARE_EQUAL ) - { - bFound = sal_True; break; - } - nIndex += ( p->nArgs & _ARGSMASK ) + 1; - p = m_pMethods + nIndex; - } - if( bFound ) - { - // isolate args-fields: - short nAccess = ( p->nArgs & _RWMASK ) >> 8; - short nType = ( p->nArgs & _TYPEMASK ); - String aName( p->pName, RTL_TEXTENCODING_ASCII_US ); - SbxClassType eCT = SbxCLASS_OBJECT; - if( nType & _PROPERTY ) - eCT = SbxCLASS_PROPERTY; - else if( nType & _METHOD ) - eCT = SbxCLASS_METHOD; - pRes = Make( aName, eCT, p->eType ); - // We set the array-index + 1, because there are still - // other standard properties existing, which have to be activated. - pRes->SetUserData( nIndex + 1 ); - pRes->SetFlags( nAccess ); - } - } - return pRes; -} - -// activation of an element or asking for an infoblock - -void CommunicationWrapper::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCT, - const SfxHint& rHint, const TypeId& rHT ) -{ - const SbxHint* pHint = PTR_CAST(SbxHint,&rHint); - if( pHint ) - { - SbxVariable* pVar = pHint->GetVar(); - SbxArray* pPar = pVar->GetParameters(); - sal_uInt16 nIndex = (sal_uInt16) pVar->GetUserData(); - // no index: hand on! - if( nIndex ) - { - sal_uLong t = pHint->GetId(); - if( t == SBX_HINT_INFOWANTED ) - pVar->SetInfo( GetInfo( (short) pVar->GetUserData() ) ); - else - { - sal_Bool bWrite = sal_False; - if( t == SBX_HINT_DATACHANGED ) - bWrite = sal_True; - if( t == SBX_HINT_DATAWANTED || bWrite ) - { - // parameter test for methods: - sal_uInt16 nPar = m_pMethods[ --nIndex ].nArgs & 0x00FF; - // element 0 is the return value - if( ( !pPar && nPar ) - || ( pPar && pPar->Count() != nPar+1 ) ) - SetError( SbxERR_WRONG_ARGS ); - - else - { - (this->*(m_pMethods[ nIndex ].pFunc))( pVar, pPar, bWrite ); - } - } - } - } - SbxObject::SFX_NOTIFY( rBC, rBCT, rHint, rHT ); - } -} - -// construction of the info-structure for single elements - -SbxInfo* CommunicationWrapper::GetInfo( short nIdx ) -{ - Methods* p = &m_pMethods[ nIdx ]; - // if there's a help-file some time: - // SbxInfo* pInfo = new SbxInfo( helpfilename, p->nHelpId ); - SbxInfo* pRetInfo = new SbxInfo; - short nPar = p->nArgs & _ARGSMASK; - for( short i = 0; i < nPar; i++ ) - { - p++; - String aName( p->pName, RTL_TEXTENCODING_ASCII_US ); - sal_uInt16 nIFlags = ( p->nArgs >> 8 ) & 0x03; - if( p->nArgs & _OPT ) - nIFlags |= SBX_OPTIONAL; - pRetInfo->AddParam( aName, p->eType, nIFlags ); - } - return pRetInfo; -} - - -//////////////////////////////////////////////////////////////////////////// - -// help methods for the manager - -IMPL_LINK( CommunicationWrapper, Open, CommunicationLink*, pLink ) -{ - if ( m_bCatchOpen ) - m_pNewLink = pLink; - else - Events( CUniString("Open"), pLink ); - return 1; -} - -IMPL_LINK( CommunicationWrapper, Close, CommunicationLink*, pLink ) -{ - Events( CUniString("Close"), pLink ); - return 1; -} - -IMPL_LINK( CommunicationWrapper, Data, CommunicationLink*, pLink ) -{ - Events( CUniString("Data"), pLink ); - return 1; -} - -void CommunicationWrapper::Events( String aType, CommunicationLink* pLink ) -{ - if ( m_aEventHandlerName.Len() ) - { - SbxArrayRef pPar = new SbxArray( SbxVARIANT ); - pPar->Put( new SbxVariable( SbxSTRING ), 1 ); - pPar->Get( 1 )->PutString( aType ); - - pPar->Put( new SbxVariable( SbxOBJECT ), 2 ); - pPar->Get( 2 )->PutObject( new CommunicationWrapper( pLink ) ); - - Call( m_aEventHandlerName, pPar ); - } - else - delete pLink->GetServiceData(); // give away the stream to prevent blocking -} - - -//////////////////////////////////////////////////////////////////////////// - -// Properties and methods put down the return value for Get (bPut = sal_False) at -// element 0 of the Argv; for Put (bPut = sal_True) the value from element 0 is saved. - -// the methods: - -// manager -void CommunicationWrapper::MStartCommunication( SbxVariable* pVar, SbxArray* pPar, sal_Bool /*bWrite*/ ) -{ // CommunicationLink StartCommunication( Host, Port ) - m_bCatchOpen = sal_True; - if ( m_pManager->StartCommunication( rtl::OUStringToOString( pPar->Get( 1 )->GetString(), RTL_TEXTENCODING_UTF8 ), pPar->Get( 2 )->GetULong() ) ) - { - while ( !m_pNewLink ) - GetpApp()->Reschedule(); - m_bCatchOpen = sal_False; - CommunicationWrapper *pNewLinkWrapper = new CommunicationWrapper( m_pNewLink ); - m_pNewLink = NULL; - pVar->PutObject( pNewLinkWrapper ); - } - -} - -void CommunicationWrapper::MStopAllCommunication( SbxVariable* /*pVar*/, SbxArray* /*pPar*/, sal_Bool /*bWrite*/ ) -{ // StopAllCommunication - m_pManager->StopCommunication(); -} - -void CommunicationWrapper::MIsCommunicationRunning( SbxVariable* pVar, SbxArray* /*pPar*/, sal_Bool /*bWrite*/ ) -{ // sal_Bool IsCommunicationRunning - pVar->PutBool( m_pManager->IsCommunicationRunning() ); -} - -void CommunicationWrapper::MGetMyName( SbxVariable* pVar, SbxArray* /*pPar*/, sal_Bool /*bWrite*/ ) -{ // String GetMyName - pVar->PutString( UniString( m_pManager->GetMyName( CM_FQDN ), RTL_TEXTENCODING_UTF8 ) ); -} - -void CommunicationWrapper::MIsLinkValid( SbxVariable* pVar, SbxArray* pPar, sal_Bool /*bWrite*/ ) -{ // sal_Bool IsLinkValid( CommunicationLink ) - CommunicationWrapper *pWrapper = (CommunicationWrapper*)(pPar->Get( 1 )->GetObject()); - pVar->PutBool( m_pManager->IsLinkValid( pWrapper->GetCommunicationLink() ) ); -} - -void CommunicationWrapper::MSetCommunicationEventHandler( SbxVariable* /*pVar*/, SbxArray* pPar, sal_Bool /*bWrite*/ ) -{ // SetCommunicationEventHandler( String ) - m_aEventHandlerName = pPar->Get( 1 )->GetString(); -} - - - - - -// Link -void CommunicationWrapper::LStopCommunication( SbxVariable* /*pVar*/, SbxArray* /*pPar*/, sal_Bool /*bWrite*/ ) -{ // StopCommunication - m_pLink->StopCommunication(); -} - -void CommunicationWrapper::LGetMyName( SbxVariable* pVar, SbxArray* /*pPar*/, sal_Bool /*bWrite*/ ) -{ // String GetMyName - pVar->PutString( UniString( m_pLink->GetMyName( CM_FQDN ), RTL_TEXTENCODING_UTF8 ) ); -} - -void CommunicationWrapper::LGetHostName( SbxVariable* pVar, SbxArray* /*pPar*/, sal_Bool /*bWrite*/ ) -{ // String GetHostName - pVar->PutString( UniString( m_pLink->GetCommunicationPartner( CM_FQDN ), RTL_TEXTENCODING_UTF8 ) ); -} - -void CommunicationWrapper::LSend( SbxVariable* /*pVar*/, SbxArray* pPar, sal_Bool /*bWrite*/ ) -{ // Send(String ) - SvStream *pSendStream = m_pLink->GetBestCommunicationStream(); - String aSendString = pPar->Get( 1 )->GetString(); - pSendStream->WriteByteString( aSendString, RTL_TEXTENCODING_UTF8 ); - m_pLink->TransferDataStream( pSendStream ); - delete pSendStream; -} - -void CommunicationWrapper::LGetString( SbxVariable* pVar, SbxArray* /*pPar*/, sal_Bool /*bWrite*/ ) -{ // String GetString - SvStream *pReceiveStream = m_pLink->GetServiceData(); - if ( pReceiveStream ) - { - sal_uLong nLength = pReceiveStream->Seek( STREAM_SEEK_TO_END ); - pReceiveStream->Seek( STREAM_SEEK_TO_BEGIN ); - char *pBuffer = new char[nLength]; - pReceiveStream->Read( pBuffer, nLength ); - String aReceive( - pBuffer, sal::static_int_cast< xub_StrLen >( nLength ), - RTL_TEXTENCODING_UTF8 ); - delete [] pBuffer; - pVar->PutString( aReceive ); - delete pReceiveStream; - } - else - pVar->PutString( UniString() ); -} - - - -SbxObject* CommunicationFactory::CreateObject( const String& rClass ) -{ - if( rClass.CompareIgnoreCaseToAscii( "CommunicationManager" ) == COMPARE_EQUAL ) - return new CommunicationWrapper( rClass ); - return NULL; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/automation/source/testtool/comm_bas.hxx b/automation/source/testtool/comm_bas.hxx deleted file mode 100644 index 4b1af375235b..000000000000 --- a/automation/source/testtool/comm_bas.hxx +++ /dev/null @@ -1,117 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef _COMM_BAS_HXX -#define _COMM_BAS_HXX - -#include <basic/sbxfac.hxx> -#include <basic/sbxvar.hxx> -#include <basic/sbxobj.hxx> - -class CommunicationManagerClientViaSocket; -class CommunicationLink; - -class CommunicationWrapper : public SbxObject // one for manager(s) and links -{ - // definition of a table entry. That's done here because the - // methods and properties can be declared private that way. -#if defined ( ICC ) || defined ( C50 ) -public: -#endif - typedef void( CommunicationWrapper::*pMeth ) - ( SbxVariable* pThis, SbxArray* pArgs, sal_Bool bWrite ); -#if defined ( ICC ) -private: -#endif - - struct Methods { - const char* pName; - SbxDataType eType; - pMeth pFunc; - short nArgs; - }; - static Methods aManagerMethods[]; // method table - static Methods aLinkMethods[]; // method table - Methods *m_pMethods; // current method table - - // methods - // manager - void MStartCommunication( SbxVariable* pVar, SbxArray* pPar, sal_Bool bWrite ); - void MStopAllCommunication( SbxVariable* pVar, SbxArray* pPar, sal_Bool bWrite ); - void MIsCommunicationRunning( SbxVariable* pVar, SbxArray* pPar, sal_Bool bWrite ); - void MGetMyName( SbxVariable* pVar, SbxArray* pPar, sal_Bool bWrite ); - void MIsLinkValid( SbxVariable* pVar, SbxArray* pPar, sal_Bool bWrite ); - void MSetCommunicationEventHandler( SbxVariable* pVar, SbxArray* pPar, sal_Bool bWrite ); - - // link - void LStopCommunication( SbxVariable* pVar, SbxArray* pPar, sal_Bool bWrite ); - void LGetMyName( SbxVariable* pVar, SbxArray* pPar, sal_Bool bWrite ); - void LGetHostName( SbxVariable* pVar, SbxArray* pPar, sal_Bool bWrite ); - void LSend( SbxVariable* pVar, SbxArray* pPar, sal_Bool bWrite ); - void LGetString( SbxVariable* pVar, SbxArray* pPar, sal_Bool bWrite ); - - // internal members and methods - CommunicationManagerClientViaSocket *m_pManager; - CommunicationLink *m_pLink; - sal_Bool m_bIsManager; - - DECL_LINK( Open, CommunicationLink* ); - DECL_LINK( Close, CommunicationLink* ); - DECL_LINK( Data, CommunicationLink* ); - void Events( String aType, CommunicationLink* pLink ); - sal_Bool m_bCatchOpen; - CommunicationLink *m_pNewLink; - String m_aEventHandlerName; - - using SbxVariable::GetInfo; - SbxInfo* GetInfo( short nIdx ); - - // Broadcaster Notification - virtual void SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType, - const SfxHint& rHint, const TypeId& rHintType ); -public: - CommunicationWrapper( const String& ); - CommunicationWrapper( CommunicationLink *pThisLink ); - ~CommunicationWrapper(); - - virtual SbxVariable* Find( const String&, SbxClassType ); - - CommunicationLink* GetCommunicationLink() { return m_pLink; } -}; - - - -class CommunicationFactory : public SbxFactory -{ -public: - virtual SbxObject* CreateObject( const String& ); -}; - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/automation/source/testtool/cretstrm.cxx b/automation/source/testtool/cretstrm.cxx deleted file mode 100644 index 64e217cedcee..000000000000 --- a/automation/source/testtool/cretstrm.cxx +++ /dev/null @@ -1,71 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include "cretstrm.hxx" -#include <tools/debug.hxx> -#include "rcontrol.hxx" -#include "svcommstream.hxx" - - -SV_IMPL_REF(SbxBase) - -CRetStream::CRetStream(SvStream *pIn) -{ - pSammel = pIn; - delete pCommStream; - pCommStream = new SvCommStream( pSammel ); -} - -CRetStream::~CRetStream() -{ - delete pCommStream; -} - -void CRetStream::Read ( String &aString ) -{ - comm_UniChar* pStr; - sal_uInt16 nLenInChars; - CmdBaseStream::Read( pStr, nLenInChars ); - - aString = String( pStr, nLenInChars ); - delete [] pStr; -} - -void CRetStream::Read( SbxValue &aValue ) -{ - *pSammel >> nId; - if (nId != BinSbxValue) - { - OSL_TRACE( "Falscher Typ im Stream: Erwartet SbxValue, gefunden :%hu", nId ); - } - SbxBaseRef xBase = SbxBase::Load( *pSammel ); - if ( IS_TYPE( SbxValue, xBase ) ) - aValue = *PTR_CAST( SbxValue, &xBase ); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/automation/source/testtool/cretstrm.hxx b/automation/source/testtool/cretstrm.hxx deleted file mode 100644 index 9f1385dae540..000000000000 --- a/automation/source/testtool/cretstrm.hxx +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef _CRETSTRM_HXX -#define _CRETSTRM_HXX - -#include <tools/stream.hxx> -#include <basic/sbxvar.hxx> - -#include "cmdbasestream.hxx" - -class CRetStream : public CmdBaseStream -{ - SvStream *pSammel; - sal_uInt16 nId; - -public: - CRetStream( SvStream *pIn ); - ~CRetStream(); - - using CmdBaseStream::Read; - void Read ( comm_UINT16 &nNr ){CmdBaseStream::Read ( nNr );} - void Read ( comm_UINT32 &nNr ){CmdBaseStream::Read ( nNr );} - virtual void Read ( rtl::OString* &pId ){CmdBaseStream::Read ( pId );} - void Read ( comm_BOOL &bBool ){CmdBaseStream::Read ( bBool );} - void Read( String &aString ); - void Read( SbxValue &aValue ); -}; - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/automation/source/testtool/filter.pl b/automation/source/testtool/filter.pl deleted file mode 100644 index 825c379440d0..000000000000 --- a/automation/source/testtool/filter.pl +++ /dev/null @@ -1,125 +0,0 @@ -#!/usr/bin/perl -#************************************************************************* -#* -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# Copyright 2000, 2010 Oracle and/or its affiliates. -# -# OpenOffice.org - a multi-platform office productivity suite -# -# This file is part of OpenOffice.org. -# -# OpenOffice.org is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License version 3 -# only, as published by the Free Software Foundation. -# -# OpenOffice.org is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License version 3 for more details -# (a copy is included in the LICENSE file that accompanied this code). -# -# You should have received a copy of the GNU Lesser General Public License -# version 3 along with OpenOffice.org. If not, see -# <http://www.openoffice.org/license.html> -# for a copy of the LGPLv3 License. -# -#************************************************************************/ - -$debug = ""; -$ctrue = 1; -$cfalse = 0; -# reads a block -# Parameter: FileHandle -# list of Regular Expressions which terminate the block. -# for '#ifdef' block would then be ("^#else\$", "^#endif\$") - -sub read_block { - - local($file) = @_; - print "reading block '$file' ",scalar(@_),"\n" if $debug; - while ( <$file> ) { - chop; - s/\s*$//; # remove trailing whitespaces - s/^\s*//; # remove leading whitespaces - print "Input : \"$_\"\n" if $debug; - s/\/\/.*//; # Remove line comment - s/\/\*.*?\*\///g; # remove comments within one line - s/\s+/ /g; # Change all whitespace into a single blank - s/ *$//; # Remove whitespace at end - s/^# /#/; # Change # <command> to #<command> - - - @line = split(/ /,$_,3); - - $_ = $line[0]; - if ( $_ && /^#/ ) { # Line starts with '#' -> preprocessor command - print "proccessing line: @line\n" if $debug; - if (/#define/) - { - if ( $line[1] =~ /^$namefilter/ ) - { - $mykey = $line[1]; - $mykey =~ s/^$namefilter//; - $count += 1; - print OUT "$mykey ", $line[2], "\n"; - print OUT2 "\t{ \"$mykey\", ", $line[2] ," },\n"; - } - } - } - } - print "Leaving read_block at the end\n" if $debug; -} - -# Read a file. -# first parameter ist the filename -sub read_file { - - local ($filename,$file) = @_; - $file++; # String increment - local $TempFileName = $basename."/".$filename; - print "reading file $TempFileName as $file\n" if $debug; - open($file, $TempFileName) || die "error: Could not open file $TempFileName. "; - - &read_block($file); # read data - close($file); - print "done reading $filename\n" if $debug; -} - -# main starts here - -$basename = "."; -$basename = $ARGV[0] if defined($ARGV[0]); - -$filename = "app.hrc"; -$filename = $ARGV[1] if defined($ARGV[1]); - - -$outfilebase = $filename; -$outfilebase =~ s/\.[^.]+$//; # cut off suffix -$outfilebase = $ARGV[2] if defined($ARGV[2]); - - -$namefilter = $ARGV[3] if defined($ARGV[3]); - - -print "Generating $outfilebase:\n" if $debug; - -$count = 0; - -open(OUT,">$outfilebase"); -open(OUT2,">$outfilebase.hxx"); -print OUT2 "\{\n"; - -&read_file ($filename,"f00"); - -print OUT2 "\t{ \"\" ,0 }\n\};\n"; - -close(OUT); -close(OUT2); - -if ( $count == 0 ) -{ - die "Error: No Entries Found generating \"$outfilebase.hxx\". Testtool will not work!" -} - diff --git a/automation/source/testtool/httprequest.cxx b/automation/source/testtool/httprequest.cxx deleted file mode 100644 index e52be94ff6c9..000000000000 --- a/automation/source/testtool/httprequest.cxx +++ /dev/null @@ -1,218 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - - -#include <stdio.h> -#include "httprequest.hxx" -#include <osl/socket.hxx> -#include <tools/debug.hxx> - - -void HttpRequest::Init() -{ - nResultId = 0; - aHeader = rtl::OString(); - aContentType = rtl::OString(); - delete pStream; - pStream = NULL; -} - -HttpRequest::HttpRequest() - : nStatus(HTTP_INIT), pOutSocket(NULL), - nResultId(0), pStream(NULL) -{ -} - -HttpRequest::~HttpRequest() -{ - delete pStream; - delete pOutSocket; -} - -void HttpRequest::SetRequest( rtl::OString aHost, rtl::OString aPath, sal_uInt16 nPort ) -{ - nStatus = HTTP_REQUEST_SET; - Init(); - aRequestHost = aHost; - aRequestPath = aPath; - nRequestPort = nPort; -} - -void HttpRequest::SetProxy( rtl::OString aHost, sal_uInt16 nPort ) -{ - nStatus = HTTP_REQUEST_SET; - Init(); - aProxyHost = aHost; - nProxyPort = nPort; -} - -sal_Bool HttpRequest::Execute() -{ - nStatus = HTTP_REQUEST_PENDING; - Init(); - - // Open channel to standard redir host - osl::SocketAddr aConnectAddr; - - if ( aProxyHost.getLength() ) - { - aConnectAddr = osl::SocketAddr( rtl::OStringToOUString( aProxyHost, RTL_TEXTENCODING_UTF8 ), nProxyPort ); - } - else - { - aConnectAddr = osl::SocketAddr( rtl::OStringToOUString( aRequestHost, RTL_TEXTENCODING_UTF8 ), nRequestPort ); - } - - TimeValue aTV; - aTV.Seconds = 10; // wait for 10 seconds - aTV.Nanosec = 0; - - pOutSocket = new osl::ConnectorSocket(); - if ( pOutSocket->connect( aConnectAddr, &aTV ) != osl_Socket_Ok ) - { - delete pOutSocket; - pOutSocket = NULL; - nStatus = HTTP_REQUEST_ERROR; - return sal_False; - } - - SendString( pOutSocket, "GET " ); - if ( aProxyHost.getLength() ) - { - //GET http://staroffice-doc.germany.sun.com/cgi-bin/htdig/binarycopy.sh?CopyIt=++CopyIt++ HTTP/1.0 - SendString( pOutSocket, "http://" ); - SendString( pOutSocket, aRequestHost ); - SendString( pOutSocket, ":" ); - SendString( pOutSocket, rtl::OString::valueOf( (sal_Int32) nRequestPort ) ); - SendString( pOutSocket, aRequestPath ); - SendString( pOutSocket, " HTTP/1.0\n" ); - - SendString( pOutSocket, "Proxy-Connection: Keep-Alive\n" ); - } - else - { - //GET /cgi-bin/htdig/binarycopy.sh?CopyIt=++CopyIt++ HTTP/1.0 - SendString( pOutSocket, aRequestPath ); - SendString( pOutSocket, " HTTP/1.0\n" ); - - SendString( pOutSocket, "Connection: Keep-Alive\n" ); - } - - SendString( pOutSocket, "User-Agent: Mozilla/4.7 [de] (Linux; I)" ); - SendString( pOutSocket, "Host: " ); - SendString( pOutSocket, aRequestHost ); - // Terminate with empty line - SendString( pOutSocket, "\n\n" ); - - - -#define BUFFRE_SIZE 0x10000 // 64K Buffer - char* pBuffer = new char[ BUFFRE_SIZE ]; - - sal_Bool bWasError = ( nStatus != HTTP_REQUEST_PENDING ); - - sal_uLong nDataRead; - pStream = new SvMemoryStream( 0x10000, 0x10000 ); - while ( !bWasError ) - { - bWasError |= ( BUFFRE_SIZE != ( nDataRead = pOutSocket->read( pBuffer, BUFFRE_SIZE ) ) ); - - pStream->Write( pBuffer, nDataRead ); - } - - delete [] pBuffer; - pOutSocket->shutdown(); - pOutSocket->close(); - - pStream->Seek( 0 ); - - rtl::OString aLine; - sal_Bool bInsideHeader = sal_True; - sal_Int32 nIndex; - while ( bInsideHeader ) - { - pStream->ReadLine( aLine ); - if ( !aLine.getLength() ) - bInsideHeader = sal_False; - else - { - if ( IsItem( "HTTP/", aLine ) ) { - nIndex = 0; - nResultId = (sal_uInt16)aLine.getToken( (sal_Int32)1, ' ', nIndex ).toInt32(); - } - if ( IsItem( "Content-Type:", aLine ) ) - { - aContentType = aLine.copy( 13 ); - aContentType.trim(); - } - aHeader += aLine; - aHeader += "\n"; - } - } - - if ( nStatus == HTTP_REQUEST_PENDING ) - { - nStatus = HTTP_REQUEST_DONE; - return sal_True; - } - else - { - nStatus = HTTP_REQUEST_ERROR; - return sal_False; - } -} -/* -HTTP/1.1 200 OK -Date: Tue, 22 Jan 2002 14:16:20 GMT -Server: Apache/1.3.14 (Unix) (SuSE/Linux) mod_throttle/3.0 mod_layout/1.0 mod_f -astcgi/2.2.2 mod_jk -Set-Cookie2: JSESSIONID=ffkpgb7tm1;Version=1;Discard;Path="/bugtracker" -Set-Cookie: JSESSIONID=ffkpgb7tm1;Path=/bugtracker -Servlet-Engine: Tomcat Web Server/3.2.1 (JSP 1.1; Servlet 2.2; Java 1.3.0; Linux - 2.4.0-4GB i386; java.vendor=Sun Microsystems Inc.) -Connection: close -Content-Type: text/xml; charset=ISO-8859-1 - */ -void HttpRequest::SendString( osl::StreamSocket* pSocket , rtl::OString aText ) -{ - if ( nStatus == HTTP_REQUEST_PENDING ) - pSocket->write( aText.getStr(), aText.getLength() ); -} - -sal_Bool HttpRequest::IsItem( rtl::OString aItem, rtl::OString aLine ) -{ - return aItem.match( aLine ); -} - - -SvMemoryStream* HttpRequest::GetBody() -{ - return pStream; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/automation/source/testtool/httprequest.hxx b/automation/source/testtool/httprequest.hxx deleted file mode 100644 index a8f333718db5..000000000000 --- a/automation/source/testtool/httprequest.hxx +++ /dev/null @@ -1,84 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef _HTTPREQUEST_HXX_ -#define _HTTPREQUEST_HXX_ - -#define HTTP_INIT 0 -#define HTTP_REQUEST_SET 1 -#define HTTP_REQUEST_PENDING 2 -#define HTTP_REQUEST_DONE 3 -#define HTTP_REQUEST_ERROR 4 - -#include <tools/stream.hxx> -#include <rtl/string.hxx> - -namespace osl -{ - class StreamSocket; - class ConnectorSocket; -} - -class HttpRequest -{ - rtl::OString aRequestPath; - rtl::OString aRequestHost; - sal_uInt16 nRequestPort; - rtl::OString aProxyHost; - sal_uInt16 nProxyPort; - - sal_uInt16 nStatus; - osl::ConnectorSocket *pOutSocket; - - rtl::OString aHeader; - sal_uInt16 nResultId; - rtl::OString aContentType; - SvMemoryStream* pStream; - - void SendString( osl::StreamSocket* pSocket, ::rtl::OString aText ); - sal_Bool IsItem( rtl::OString aItem, rtl::OString aLine ); - void Init(); -public: - HttpRequest(); - ~HttpRequest(); - - void SetRequest( rtl::OString aHost, rtl::OString aPath, sal_uInt16 nPort ); - void SetProxy( rtl::OString aHost, sal_uInt16 nPort ); - - sal_Bool Execute(); - - rtl::OString GetHeader() const { return aHeader; } - SvMemoryStream* GetBody(); - - rtl::OString GetContentType() const { return aContentType; } - sal_uInt16 GetResultId() const { return nResultId; } -}; - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/automation/source/testtool/objtest.cxx b/automation/source/testtool/objtest.cxx deleted file mode 100644 index ff8745d6ab71..000000000000 --- a/automation/source/testtool/objtest.cxx +++ /dev/null @@ -1,3762 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - - -#include "sysdir_win.hxx" -#include "registry_win.hxx" -#include "ittresid.hxx" -#include <osl/file.hxx> -#include <vcl/msgbox.hxx> -#include <vcl/sound.hxx> -#include <tools/config.hxx> -#include <vcl/svapp.hxx> -#include <svtools/stringtransfer.hxx> -#include <svl/brdcst.hxx> -#include <basic/sbx.hxx> -#include <com/sun/star/uno/Any.hxx> -#include <com/sun/star/frame/XDesktop.hpp> -#include <comphelper/processfactory.hxx> -#include <comphelper/string.hxx> -#include <com/sun/star/bridge/XBridgeFactory.hpp> -#include <com/sun/star/connection/XConnector.hpp> -#include <com/sun/star/connection/XConnection.hpp> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <com/sun/star/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 ::rtl::OUString; - -#include <svtools/svmedit.hxx> - -#ifdef UNX -#include <unistd.h> // readlink -#include <errno.h> -#endif - -#include <basic/sbuno.hxx> - -#include <basic/basicrt.hxx> -#include <basic/ttstrhlp.hxx> -#include "tcommuni.hxx" -#include "comm_bas.hxx" -#include <cretstrm.hxx> - -#include "objtest.hxx" -#include "rcontrol.hxx" - -#include <basic/testtool.hrc> -#include <basic/ttmsg.hrc> - -#include <basic/mybasic.hxx> -#include <basic/testtool.hxx> -#include <basic/sbstar.hxx> - -#include <algorithm> - -#ifndef SBX_VALUE_DECL_DEFINED -#define SBX_VALUE_DECL_DEFINED -SV_DECL_REF(SbxValue) -#endif -SV_IMPL_REF(SbxValue) - -static CommunicationFactory aComManFac; - -#define cMyDelim ' ' -#define P_FEHLERLISTE pFehlerListe -#define KEEP_SEQUENCES 100 // Keep Names of last 100 Calls - - -ControlDefLoad const Controls::arClasses [] = -#include "classes.hxx" -CNames *Controls::pClasses = NULL; - -ControlDefLoad const TestToolObj::arR_Cmds [] = -#include "r_cmds.hxx" -CNames *TestToolObj::pRCommands = NULL; -CErrors *TestToolObj::pFehlerListe = NULL; // the errors from the testtool are stored here - - -DBG_NAME( ControlItem ) -DBG_NAME( ControlDef ) - -ControlItem::ControlItem( const sal_Char *Name, rtl::OString aUIdP ) -{ -DBG_CTOR(ControlItem,0); - InitData(); - pData->Kurzname.AssignAscii( Name ); - pData->aUId = aUIdP; -} - -ControlItem::ControlItem( const String &Name, rtl::OString aUIdP ) -{ -DBG_CTOR(ControlItem,0); - InitData(); - pData->Kurzname = Name; - pData->aUId = aUIdP; -} - -ControlSon::~ControlSon() -{ - if (pSons) - { - delete pSons; - pSons = NULL; - } -} - -ControlItemSon::ControlItemSon(const String &Name, rtl::OString aUIdP ) -: ControlItem( Name, aUIdP ) -{} - -sal_Bool ControlDef::operator < (const ControlItem &rPar) -{ - return pData->Kurzname.CompareIgnoreCaseToAscii(rPar.pData->Kurzname) == COMPARE_LESS; -} - -sal_Bool ControlDef::operator == (const ControlItem &rPar) -{ - return pData->Kurzname.CompareIgnoreCaseToAscii(rPar.pData->Kurzname) == COMPARE_EQUAL; -} - -void ControlDef::Write( SvStream &aStream ) -{ - // FIXME: HELPID - (void)aStream; -} - -ControlDef::ControlDef(const String &Name, rtl::OString aUIdP ) -: ControlItemSon( Name, aUIdP) -{ - DBG_CTOR(ControlDef,0); -} - -ControlDef::ControlDef(const String &aOldName, const String &aNewName, ControlDef *pOriginal, sal_Bool bWithSons ) -: ControlItemSon("", pOriginal->pData->aUId) -{ - DBG_CTOR(ControlDef,0); - if ( pOriginal->pData->Kurzname == aOldName ) - pData->Kurzname = aNewName; - else - pData->Kurzname = pOriginal->pData->Kurzname; - - if ( bWithSons && pOriginal->pSons ) - { - pSons = new CNames(); - for ( sal_uInt16 i = 0; i < pOriginal->pSons->Count() ; i++) - { - ControlDef *pNewDef; - pNewDef = new ControlDef( aOldName, aNewName, pOriginal->SonGetObject(i) ,sal_True ); - if (! SonInsert(pNewDef)) - { - OSL_FAIL("Name Doppelt im CopyConstructor. Neuer Name = Controlname!!"); - delete pNewDef; - } - } - - } - else - pSons = NULL; -} - -sal_Bool ControlItemUId::operator < (const ControlItem &rPar) -{ - return pData->aUId < rPar.pData->aUId; -} - -sal_Bool ControlItemUId::operator == (const ControlItem &rPar) -{ - return pData->aUId == rPar.pData->aUId; -} - -SV_IMPL_OP_PTRARR_SORT( CNames, ControlItem* ) - -void CRevNames::Insert( String aName, rtl::OString aUId, sal_uLong nSeq ) -{ - ControlItem *pRN = new ReverseName(aName,aUId,nSeq); - sal_uInt16 nPos; - if ( Seek_Entry(pRN,&nPos) ) - DeleteAndDestroy(nPos); - - if ( !CNames::C40_PTR_INSERT( ControlItem, pRN) ) - { - OSL_FAIL("Interner Fehler beim Speichern der Lokalen KurzNamen"); - delete pRN; - } - -} - -String CRevNames::GetName( rtl::OString aUId ) -{ - ReverseName *pRN = new ReverseName(UniString(),aUId,0); - sal_uInt16 nPos; - sal_Bool bSeekOK = Seek_Entry(pRN,&nPos); - - delete pRN; - if ( bSeekOK ) - return GetObject(nPos)->pData->Kurzname; - else - { - // FIXME: HELPID - return String(); - } -} - -void CRevNames::Invalidate ( sal_uLong nSeq ) -{ - sal_uInt16 i; - for (i = 0; i < Count() ;) - { - if (((ReverseName*)GetObject(i))->LastSequence < nSeq) - DeleteAndDestroy(i); - else - i++; - } -} - - -SV_IMPL_PTRARR(CErrors, ErrorEntry*) - - -SbxTransportMethod::SbxTransportMethod( SbxDataType DT ) -: SbxMethod(CUniString("Dummy"),DT) -{ - nValue = 0; -} - - -TestToolObj::TestToolObj( String aName, MyBasic* pBas ) // call in the testtool -: SbxObject( aName ) -, bUseIPC(sal_True) -, bReturnOK(sal_True) -, nSequence(KEEP_SEQUENCES) -, ProgPath() -, IsBlock(sal_False) -, SingleCommandBlock(sal_True) -, m_pControls(NULL) -, m_pNameKontext(NULL) -, m_pSIds(NULL) -, m_pReverseSlots(NULL) -, m_pReverseControls(NULL) -, m_pReverseControlsSon(NULL) -, m_pReverseUIds(NULL) -, pCommunicationManager(NULL) -, aDialogHandlerName() -, nWindowHandlerCallLevel(0) -, nIdleCount(0) -{ - pImpl = new ImplTestToolObj; - pImpl->ProgParam = String(); - pImpl->bIsStart = sal_False; - pImpl->pMyBasic = pBas; - - LoadIniFile(); - InitTestToolObj(); - - pCommunicationManager = new CommunicationManagerClientViaSocketTT(); - pCommunicationManager->SetDataReceivedHdl( LINK( this, TestToolObj, ReturnResultsLink )); -} - -void TestToolObj::LoadIniFile() -{ -#define GETSET(aVar, KeyName, Dafault) \ - { \ - ByteString __##aVar##__; \ - __##aVar##__ = aConf.ReadKey(KeyName); \ - if ( !__##aVar##__.Len() ) \ - { \ - __##aVar##__ = Dafault; \ - aConf.WriteKey(KeyName, __##aVar##__); \ - } \ - aVar = UniString( __##aVar##__, RTL_TEXTENCODING_UTF8 );\ - } - -#define NEWOLD( NewKey, OldKey ) \ - { \ - rtl::OString aValue; \ - if ( ( (aValue = aConf.ReadKey( OldKey )).getLength() ) && !aConf.ReadKey( NewKey ).getLength() ) \ - aConf.WriteKey( NewKey, aValue ); \ - } - - - Config aConf(Config::GetConfigName( Config::GetDefDirectory(), CUniString("testtool") )); - aConf.SetGroup("Misc"); - ByteString aCurrentProfile = aConf.ReadKey( "CurrentProfile", "Path" ); - aConf.SetGroup( aCurrentProfile ); - - NEWOLD( "BaseDir", "Basisverzeichnis" ) - String aFB; - GETSET( aFB, "BaseDir", "" ); - pImpl->aFileBase = DirEntry(aFB); - - // remove old keys - if ( aConf.ReadKey("KeyCodes + Classes").getLength() != 0 || - aConf.ReadKey("KeyCodes + Classes + Res_Type").getLength() != 0 ) - { - aConf.DeleteKey("KeyCodes + Classes + Res_Type"); - aConf.DeleteKey("KeyCodes + Classes"); - } - - NEWOLD( "LogBaseDir", "LogBasisverzeichnis" ) - String aLFB; - GETSET( aLFB, "LogBaseDir", rtl::OUStringToOString(aFB, RTL_TEXTENCODING_UTF8) ); - pImpl->aLogFileBase = DirEntry(aLFB); - - NEWOLD( "HIDDir", "HIDVerzeichnis" ) - String aHID; - GETSET( aHID, "HIDDir", "" ); - pImpl->aHIDDir = DirEntry(aHID); - - - aConf.SetGroup("Misc"); - - String aST; - GETSET( aST, "ServerTimeout", rtl::OString::valueOf(Time(0,0,45).GetTime()) ); // 45 seconds initial - pImpl->aServerTimeout = Time(sal_uLong(aST.ToInt64())); - - String aSOSE; - aCurrentProfile = aConf.ReadKey( "CurrentProfile", "Misc" ); - aConf.SetGroup( aCurrentProfile ); - GETSET( aSOSE, "StopOnSyntaxError", "0" ); - pImpl->bStopOnSyntaxError = aSOSE.EqualsAscii("1"); - - - aConf.SetGroup("GUI Platform"); - -// #i68804# Write default Communication section to testtoolrc/.ini -// this is not fastest but too keep defaultsettings in one place in the code - GetHostConfig(); - GetTTPortConfig(); - GetUnoPortConfig(); - - aConf.SetGroup("Crashreporter"); - - String aUP; - GETSET( aUP, "UseProxy", "false" ); - String aPS; - GETSET( aPS, "ProxyServer", "" ); - String aPP; - GETSET( aPP, "ProxyPort", "" ); - String aAC; - GETSET( aAC, "AllowContact", "false" ); - String aRA; - GETSET( aRA, "ReturnAddress", "" ); - - OUString sPath; - if( osl_getExecutableFile( (rtl_uString**)&sPath ) == osl_Process_E_None) - { - sPath = sPath.copy(7); // strip file:// - - int i = sPath.lastIndexOf('/'); - if (i >= 0) - i = sPath.lastIndexOf('/', i-1 ); - - if (i >= 0) - { - sPath = sPath.copy(0, i); - ByteString bsPath( rtl::OUStringToOString(sPath, - RTL_TEXTENCODING_UTF8) ); - - aConf.SetGroup( "OOoProgramDir" ); - String aOPD; - // testtool is installed in Basis3.x/program/ dir nowadays - bsPath += "/../program"; - GETSET( aOPD, "Current", bsPath); - - ByteString aSrcRoot(getenv("SRC_ROOT")); - aConf.SetGroup( "_profile_Default" ); - if (aSrcRoot.Len()) - { - String aPBD; - aSrcRoot += "/testautomation"; - GETSET( aPBD, "BaseDir", aSrcRoot ); - - String aPHD; - aSrcRoot += "/global/hid"; - GETSET( aPHD, "HIDDir", aSrcRoot ); - } - else - { - String aPBD; - bsPath += "/qatesttool"; - GETSET( aPBD, "BaseDir", bsPath ); - - String aPHD; - bsPath += "/global/hid"; - GETSET( aPHD, "HIDDir", bsPath ); - } - - String aLD; - GETSET( aLD, "LogBaseDir", ByteString( "/tmp" ) ); - } - } -} - -#define MAKE_TT_KEYWORD( cName, aType, aResultType, nID ) \ -{ \ - SbxVariableRef pMeth; \ - pMeth = Make( CUniString(cName), aType, aResultType ); \ - pMeth->SetUserData( nID ); \ -} - -// SetUserData must be something, it will be filtered out later otherwise!!! -#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; // for profiling with boxes - - pImpl->nMinRemoteCommandDelay = 0; - pImpl->nMaxRemoteCommandDelay = 0; - pImpl->bDoRemoteCommandDelay = sal_False; - - pImpl->bLnaguageExtensionLoaded= sal_False; - pImpl->pTTSfxBroadcaster = NULL; - - pImpl->nErrorCount = 0; - pImpl->nWarningCount = 0; - pImpl->nQAErrorCount = 0; - pImpl->nIncludeFileWarningCount = 0; - - pImpl->xErrorList = new SbxDimArray( SbxSTRING ); - pImpl->xWarningList = new SbxDimArray( SbxSTRING ); - pImpl->xQAErrorList = new SbxDimArray( SbxSTRING ); - pImpl->xIncludeFileWarningList = new SbxDimArray( SbxSTRING ); - - pImpl->nTestCaseLineNr = 0; - - pImpl->bEnableQaErrors = sal_True; - pImpl->bDebugFindNoErrors = sal_False; - - pImpl->pChildEnv = new Environment; - - if (!pFehlerListe) - pFehlerListe = new CErrors; - - In = new CmdStream(); - - pShortNames = new CRevNames; - - pImpl->pHttpRequest = NULL; - -// overwrite standard "wait" method, cause we can do better than that!! -// Insert Object into SbiStdObject but change listening. - SbxVariable* pRTL = pImpl->pMyBasic->Find( CUniString(RTLNAME), SbxCLASS_DONTCARE ); - SbxObject* pRTLObject = PTR_CAST( SbxObject, pRTL ); - if ( pRTLObject ) - { - SbxVariableRef pWait; - pWait = pRTLObject->Make( CUniString("Wait"), SbxCLASS_METHOD, SbxNULL ); - pWait->SetUserData( ID_Wait ); - // change listener here - pRTLObject->EndListening( pWait->GetBroadcaster(), sal_True ); - StartListening( pWait->GetBroadcaster(), sal_True ); - } - else - { - OSL_FAIL("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 ); - MAKE_TT_KEYWORD( "Use", SbxCLASS_METHOD, SbxNULL, ID_Use ); - MAKE_TT_KEYWORD( "StartUse", SbxCLASS_METHOD, SbxNULL, ID_StartUse ); - MAKE_TT_KEYWORD( "FinishUse", SbxCLASS_METHOD, SbxNULL, ID_FinishUse ); - - MAKE_TT_KEYWORD( "CaseLog", SbxCLASS_METHOD, SbxNULL, ID_CaseLog ); - MAKE_TT_KEYWORD( "ExceptLog", SbxCLASS_METHOD, SbxNULL, ID_ExceptLog ); - MAKE_TT_KEYWORD( "PrintLog", SbxCLASS_METHOD, SbxNULL, ID_PrintLog ); - MAKE_TT_KEYWORD( "WarnLog", SbxCLASS_METHOD, SbxNULL, ID_WarnLog ); - MAKE_TT_KEYWORD( "ErrorLog", SbxCLASS_METHOD, SbxNULL, ID_ErrorLog ); - MAKE_TT_KEYWORD( "QAErrorLog", SbxCLASS_METHOD, SbxNULL, ID_QAErrorLog ); - MAKE_TT_KEYWORD( "EnableQaErrors", SbxCLASS_PROPERTY, SbxBOOL, ID_EnableQaErrors ); - MAKE_TT_KEYWORD( "MaybeAddErr", SbxCLASS_METHOD, SbxNULL, ID_MaybeAddErr ); - MAKE_TT_KEYWORD( "ClearError", SbxCLASS_METHOD, SbxNULL, ID_ClearError ); - MAKE_TT_KEYWORD( "SaveIDs", SbxCLASS_METHOD, SbxBOOL, ID_SaveIDs ); - MAKE_TT_KEYWORD( "AutoExecute", SbxCLASS_PROPERTY, SbxBOOL, ID_AutoExecute ); // Attention! PROPERTY therefore a variable - MAKE_TT_KEYWORD( "Execute", SbxCLASS_METHOD, SbxNULL, ID_Execute ); - MAKE_TT_KEYWORD( "StopOnSyntaxError", SbxCLASS_PROPERTY, SbxBOOL, ID_StopOnSyntaxError ); - -/* Dialog Handler are needed for dialogues in the internal testtool. - remote commands the IdleHandler is activated. It tests whether the - reschedule returns to WaitForAnswer. If this is not the case, the - RemoteHandler is resetted and then the Handler-Sub is called in the - basic (uncoupled by PostUserEvent). - - In returndaten_verarbeiten flag after flag is resetted for the execution - of the next remote command. The Handler is devalued too then. - So it counts for the next remote command only. -*/ - MAKE_TT_KEYWORD( "DialogHandler", SbxCLASS_METHOD, SbxNULL, ID_DialogHandler ); - - MAKE_TT_KEYWORD( "GetUnoApp", SbxCLASS_METHOD, SbxOBJECT, ID_GetUnoApp ); - MAKE_TT_KEYWORD( "GetIServer", SbxCLASS_METHOD, SbxOBJECT, ID_GetIServer ); - - MAKE_TT_KEYWORD( "RemoteCommandDelay", SbxCLASS_METHOD, SbxNULL, ID_RemoteCommandDelay ); - - MAKE_TT_KEYWORD( "GetApplicationPath", SbxCLASS_METHOD, SbxSTRING, ID_GetApplicationPath ); - MAKE_TT_KEYWORD( "GetCommonApplicationPath", SbxCLASS_METHOD, SbxSTRING, ID_GetCommonApplicationPath ); - MAKE_TT_KEYWORD( "MakeIniFileName", SbxCLASS_METHOD, SbxSTRING, ID_MakeIniFileName ); - -/// active constants returning error and warning count - MAKE_TT_KEYWORD( "GetErrorCount", SbxCLASS_METHOD, SbxULONG, ID_GetErrorCount ); - MAKE_TT_KEYWORD( "GetWarningCount", SbxCLASS_METHOD, SbxULONG, ID_GetWarningCount ); - MAKE_TT_KEYWORD( "GetQAErrorCount", SbxCLASS_METHOD, SbxULONG, ID_GetQAErrorCount ); - MAKE_TT_KEYWORD( "GetUseFileWarningCount", SbxCLASS_METHOD, SbxULONG, ID_GetUseFileWarningCount ); - - MAKE_TT_KEYWORD( "GetErrorList", SbxCLASS_METHOD, SbxOBJECT, ID_GetErrorList ); - MAKE_TT_KEYWORD( "GetWarningList", SbxCLASS_METHOD, SbxOBJECT, ID_GetWarningList ); - MAKE_TT_KEYWORD( "GetQAErrorList", SbxCLASS_METHOD, SbxOBJECT, ID_GetQAErrorList ); - MAKE_TT_KEYWORD( "GetUseFileWarningList", SbxCLASS_METHOD, SbxOBJECT, ID_GetUseFileWarningList ); - - MAKE_TT_KEYWORD( "GetTestCaseName", SbxCLASS_METHOD, SbxSTRING, ID_GetTestCaseName ); - MAKE_TT_KEYWORD( "GetTestCaseFileName", SbxCLASS_METHOD, SbxSTRING, ID_GetTestCaseFileName ); - MAKE_TT_KEYWORD( "GetTestCaseLineNr", SbxCLASS_METHOD, SbxUSHORT, ID_GetTestCaseLineNr ); - - MAKE_TT_KEYWORD( "SetChildEnv", SbxCLASS_METHOD, SbxNULL, ID_SetChildEnv ); - MAKE_TT_KEYWORD( "GetChildEnv", SbxCLASS_METHOD, SbxSTRING, ID_GetChildEnv ); - - MAKE_TT_KEYWORD( "GetLinkDestination", SbxCLASS_METHOD, SbxSTRING, ID_GetLinkDestination ); - MAKE_TT_KEYWORD( "GetRegistryValue", SbxCLASS_METHOD, SbxSTRING, ID_GetRegistryValue ); - - MAKE_TT_KEYWORD( "KillApp", SbxCLASS_METHOD, SbxNULL, ID_KillApp ); - - MAKE_TT_KEYWORD( "HTTPSend", SbxCLASS_METHOD, SbxUSHORT, ID_HTTPSend ); - MAKE_TT_KEYWORD( "HTTPSetProxy", SbxCLASS_METHOD, SbxNULL, ID_HTTPSetProxy ); - - // Load the Remote Commands from list - if ( !pRCommands ) // is static and called only once therefore - ReadFlatArray( arR_Cmds, pRCommands ); - sal_uInt16 i; - for ( i = 0 ; i < pRCommands->Count() ; i++ ) - { - SbxTransportMethod *pMeth = new SbxTransportMethod( SbxVARIANT ); - pMeth->SetName( pRCommands->GetObject( i )->pData->Kurzname ); - pMeth->SetUserData( ID_RemoteCommand ); - // FIXME: HELPID - pMeth->nValue = 0; - Insert( pMeth ); - StartListening( pMeth->GetBroadcaster(), sal_True ); - } - -// constants for SetControlType - MAKE_USHORT_CONSTANT("CTBrowseBox",CONST_CTBrowseBox); - MAKE_USHORT_CONSTANT("CTValueSet",CONST_CTValueSet); - -// constants for the alignment of the requested splitter - MAKE_USHORT_CONSTANT("AlignLeft",CONST_ALIGN_LEFT); - MAKE_USHORT_CONSTANT("AlignTop",CONST_ALIGN_TOP); - MAKE_USHORT_CONSTANT("AlignRight",CONST_ALIGN_RIGHT); - MAKE_USHORT_CONSTANT("AlignBottom",CONST_ALIGN_BOTTOM); - -/// What dialog to use in RC_CloseSysDialog or RC_ExistsSysDialog - MAKE_USHORT_CONSTANT("FilePicker",CONST_FilePicker); - MAKE_USHORT_CONSTANT("FolderPicker",CONST_FolderPicker); - -/// NodeTypes of the SAX Parser - MAKE_USHORT_CONSTANT("NodeTypeCharacter",CONST_NodeTypeCharacter); - MAKE_USHORT_CONSTANT("NodeTypeElement",CONST_NodeTypeElement); - MAKE_USHORT_CONSTANT("NodeTypeComment",CONST_NodeTypeComment); - - -/// ItemTypes for TreeListBox and maybe others - MAKE_USHORT_CONSTANT("ItemTypeText",CONST_ItemTypeText); - MAKE_USHORT_CONSTANT("ItemTypeBMP",CONST_ItemTypeBMP); - MAKE_USHORT_CONSTANT("ItemTypeCheckbox",CONST_ItemTypeCheckbox); - MAKE_USHORT_CONSTANT("ItemTypeContextBMP",CONST_ItemTypeContextBMP); - MAKE_USHORT_CONSTANT("ItemTypeUnknown",CONST_ItemTypeUnknown); - - -/// Return values for WaitSlot - MAKE_USHORT_CONSTANT("WSTimeout",CONST_WSTimeout); - MAKE_USHORT_CONSTANT("WSAborted",CONST_WSAborted); - MAKE_USHORT_CONSTANT("WSFinished",CONST_WSFinished); - - - pImpl->pControlsObj = new Controls( CUniString("GetNextCloseWindow") ); - pImpl->pControlsObj->SetType( SbxVARIANT ); - Insert( pImpl->pControlsObj ); - pImpl->pControlsObj->SetUserData( ID_GetNextCloseWindow ); - pImpl->pControlsObj->ChangeListener( this ); - - for ( i=0;i<VAR_POOL_SIZE;i++) - { - pImpl->pMyVars[i] = new SbxTransportMethod( SbxVARIANT ); - pImpl->pMyVars[i]->SetName( CUniString("VarDummy").Append(String::CreateFromInt32(i) ) ); - - Insert( pImpl->pMyVars[i] ); - } - - m_pControls = new CNames(); - m_pSIds = new CNames(); - m_pNameKontext = m_pControls; - - nMyVar = 0; - - pImpl->pMyBasic->AddFactory( &aComManFac ); -} - - -TestToolObj::~TestToolObj() -{ - pImpl->pMyBasic->RemoveFactory( &aComManFac ); - EndListening( ((StarBASIC*)GetParent())->GetBroadcaster() ); - pImpl->pNextReturn.Clear(); - - pImpl->pControlsObj.Clear(); - - for ( int i = 0 ; i < VAR_POOL_SIZE ; i++ ) - { - pImpl->pMyVars[i].Clear(); - } - - delete m_pControls; - delete m_pReverseSlots; - delete m_pReverseControls; - delete m_pReverseControlsSon; - delete m_pReverseUIds; - delete m_pSIds; - - if (pFehlerListe) - { - delete pFehlerListe; - pFehlerListe = NULL; // because pFehlerListe is static!! - } - - if ( pCommunicationManager ) - { - pCommunicationManager->StopCommunication(); - delete pCommunicationManager; - } - - delete In; - delete pImpl->pTTSfxBroadcaster; - delete pImpl->pHttpRequest; - delete pImpl->pChildEnv; - - pImpl->xErrorList.Clear(); - pImpl->xWarningList.Clear(); - pImpl->xQAErrorList.Clear(); - pImpl->xIncludeFileWarningList.Clear(); - - delete pImpl; - - delete pShortNames; -} - -SfxBroadcaster& TestToolObj::GetTTBroadcaster() -{ - if ( !pImpl->pTTSfxBroadcaster ) - pImpl->pTTSfxBroadcaster = new SfxBroadcaster; - return *pImpl->pTTSfxBroadcaster; -} - -void TestToolObj::ReadNames( String Filename, CNames *&pNames, CNames *&pUIds, sal_Bool bIsFlat ) -{ -/******************************************************************************* -** -** the following file extensions are available: -** -** hid.lst long name UId -** *.sid Slot Ids short name long name file is flat -** *.win Controlname long name file with *name and +name notation -** -** -*******************************************************************************/ - - - SvFileStream Stream; - String aLine,aShortname,aLongname; - rtl::OString aUId; - xub_StrLen nLineNr; - sal_uInt16 nElement; - ControlDef *pNewDef, *pNewDef2; - ControlDef *pFatherDef = NULL; - - nLineNr = 0; - - if (! pUIds) - { - String aFileName = (pImpl->aHIDDir + DirEntry(CUniString("hid.lst"))).GetFull(); - { - TTExecutionStatusHint aHint( TT_EXECUTION_SHOW_ACTION, String(IttResId(S_READING_LONGNAMES)), aFileName ); - GetTTBroadcaster().Broadcast( aHint ); - } - ReadFlat( aFileName ,pUIds, sal_True ); - if ( !pUIds ) - return; - pNewDef = new ControlDef("Active",rtl::OString()); - const ControlItem *pItem = pNewDef; - if (! pUIds->Insert(pItem)) - { - ADD_WARNING_LOG2( GEN_RES_STR1c( S_DOUBLE_NAME, "Active" ), Filename, nLineNr ); - delete pNewDef; - } - - } - - ADD_MESSAGE_LOG( Filename ); - - Stream.Open(Filename, STREAM_STD_READ); - if (!Stream.IsOpen()) - { - ADD_ERROR(ERR_NO_FILE,GEN_RES_STR1(S_CANNOT_OPEN_FILE, Filename)); - return; - } - - if ( bIsFlat && !pNames ) - { - TTExecutionStatusHint aHint( TT_EXECUTION_SHOW_ACTION, String(IttResId(S_READING_SLOT_IDS)), Filename ); - GetTTBroadcaster().Broadcast( aHint ); - } - else - { - TTExecutionStatusHint aHint( TT_EXECUTION_SHOW_ACTION, String(IttResId(S_READING_CONTROLS)), Filename ); - GetTTBroadcaster().Broadcast( aHint ); - } - - if ( !pNames ) - pNames = new CNames(); - - { - TTExecutionStatusHint aHint( TT_EXECUTION_ENTERWAIT ); - GetTTBroadcaster().Broadcast( aHint ); - } - while (!Stream.IsEof()) - { - nLineNr++; - - Stream.ReadByteStringLine(aLine, RTL_TEXTENCODING_IBM_850); - aLine.EraseLeadingChars(); - aLine.EraseTrailingChars(); - while ( aLine.SearchAscii(" ") != STRING_NOTFOUND ) - aLine.SearchAndReplaceAllAscii(" ",UniString(' ')); - if (aLine.Len() == 0) continue; - if (aLine.Copy(0,4).CompareIgnoreCaseToAscii("Rem ") == COMPARE_EQUAL) continue; - if (aLine.Copy(0,1).CompareToAscii("'") == COMPARE_EQUAL) continue; - - if ( (aLine.GetTokenCount(cMyDelim) < 2 || aLine.GetTokenCount(cMyDelim) > 3) && aLine.CompareIgnoreCaseToAscii("*Active") != COMPARE_EQUAL ) - { - ADD_WARNING_LOG2( GEN_RES_STR1( S_INVALID_LINE, aLine ), Filename, nLineNr ); - continue; - } - - aShortname = aLine.GetToken(0,cMyDelim); - aLongname = aLine.GetToken(1,cMyDelim); - - String aFirstAllowedExtra, aAllowed; - aFirstAllowedExtra.AssignAscii("+*"); - aAllowed.AssignAscii("_"); - xub_StrLen nIndex = 0; - sal_Bool bOK = sal_True; - - while ( bOK && nIndex < aShortname.Len() ) - { - sal_Unicode aChar = aShortname.GetChar( nIndex ); - sal_Bool bOKThis = sal_False; - bOKThis |= ( aAllowed.Search( aChar ) != STRING_NOTFOUND ); - if ( !nIndex ) - bOKThis |= ( aFirstAllowedExtra.Search( aChar ) != STRING_NOTFOUND ); - bOKThis |= ( aChar >= 'A' && aChar <= 'Z' ); - bOKThis |= ( aChar >= 'a' && aChar <= 'z' ); - bOKThis |= ( aChar >= '0' && aChar <= '9' ); - - bOK &= bOKThis; - nIndex++; - } - if ( !bOK ) - { - ADD_WARNING_LOG2( CUniString("Zeile \"").Append(aLine).AppendAscii("\" enth�lt ung�ltige Zeichen."), Filename, nLineNr ); - continue; - } - - sal_Bool bUnoName = ( aLongname.Copy( 0, 5 ).EqualsIgnoreCaseAscii( ".uno:" ) - || aLongname.Copy( 0, 4 ).EqualsIgnoreCaseAscii( "http" ) - || aLongname.Copy( 0, 15 ).EqualsIgnoreCaseAscii( "private:factory" ) - || aLongname.Copy( 0, 8 ).EqualsIgnoreCaseAscii( "service:" ) - || aLongname.Copy( 0, 6 ).EqualsIgnoreCaseAscii( "macro:" ) - || aLongname.Copy( 0, 8 ).EqualsIgnoreCaseAscii( ".HelpId:" ) ); - // generic method to mark longnames as symbolic - if ( aLongname.Copy( 0, 4 ).EqualsIgnoreCaseAscii( "sym:" ) ) - { - bUnoName = sal_True; - aLongname.Erase( 0, 4 ); - } - sal_Bool bMozillaName = ( !bIsFlat && aLongname.Copy( 0, 4 ).EqualsIgnoreCaseAscii( ".moz" ) ); - - if ( aShortname.GetChar(0) == '+' ) // copy complete entry - { - aShortname.Erase(0,1); - ControlDef WhatName(aLongname,rtl::OString()); - ControlDef *OldTree; - if (pNames->Seek_Entry(&WhatName,&nElement)) - { - OldTree = (ControlDef*)pNames->GetObject(nElement); - pNewDef = new ControlDef(aLongname,aShortname,OldTree,sal_True); - - const ControlItem *pItem = pNewDef; - if (! pNames->Insert(pItem)) - { - ADD_WARNING_LOG2( GEN_RES_STR1( S_DOUBLE_NAME, aLine ), Filename, nLineNr ); - delete pNewDef; - pFatherDef = NULL; - } - else - { - pFatherDef = pNewDef; - } - } - else - { - ADD_WARNING_LOG2( GEN_RES_STR1( S_SHORTNAME_UNKNOWN, aLine ), Filename, nLineNr ); - continue; - } - - } - else - { - // FIXME: HELPID - if ( !bUnoName && !bMozillaName ) - { // get the ID from the Hid.Lst - ControlDef WhatName(aLongname,rtl::OString()); - if (pUIds->Seek_Entry(&WhatName,&nElement)) - aUId = pUIds->GetObject(nElement)->pData->aUId; - else - { - ADD_WARNING_LOG2( GEN_RES_STR1( S_LONGNAME_UNKNOWN, aLine ), Filename, nLineNr ); - continue; - } - } - else - { - // FIXME: HELPID - } - if (aShortname.GetChar(0) == '*' || bIsFlat) // global short name (dialogue name or SId) - { - if (!bIsFlat) - aShortname.Erase(0,1); - pNewDef = new ControlDef(aShortname,aUId); - if (!bIsFlat) - { - pNewDef->Sons( new CNames() ); - pNewDef2 = new ControlDef(aShortname,aUId); - if (!pNewDef->SonInsert( pNewDef2 )) // enter dialogue into its own namespace - { - delete pNewDef2; - OSL_FAIL(" !!!! ACHTUNG !!!! Fehler beim einf�gen in leere Liste!"); - } - } - const ControlItem *pItem = pNewDef; - if (! pNames->Insert(pItem)) - { - ADD_WARNING_LOG2( GEN_RES_STR1( S_DOUBLE_NAME, aLine ), Filename, nLineNr ); - delete pNewDef; - pFatherDef = NULL; - } - else - { - pFatherDef = pNewDef; - } - } - else - { - if (!pFatherDef) - { - ADD_WARNING_LOG2( GEN_RES_STR0( S_FIRST_SHORTNAME_REQ_ASTRX ), Filename, nLineNr ); - } - else - { - pNewDef = new ControlDef(aShortname,aUId); - if (! pFatherDef->SonInsert(pNewDef)) - { - ADD_WARNING_LOG2( GEN_RES_STR1( S_DOUBLE_NAME, aLine ), Filename, nLineNr ); - delete pNewDef; - } - } - } - } - GetpApp()->Reschedule(); - } - { - TTExecutionStatusHint aHint( TT_EXECUTION_LEAVEWAIT ); - GetTTBroadcaster().Broadcast( aHint ); - } - { - TTExecutionStatusHint aHint( TT_EXECUTION_HIDE_ACTION ); - GetTTBroadcaster().Broadcast( aHint ); - } - - Stream.Close(); -} - -void TestToolObj::AddName(String &aBisher, String &aNeu ) -{ - String aSl( '/' ); - if ( UniString(aSl).Append(aBisher).Append(aSl).ToUpperAscii().Search( UniString(aSl).Append(aNeu).Append(aSl).ToUpperAscii() ) == STRING_NOTFOUND ) - { - aBisher += aSl; - aBisher += aNeu; - } -} - -void TestToolObj::ReadFlat( String Filename, CNames *&pNames, sal_Bool bSortByName ) -// if bSortByName == sal_False, sort by UId (ControlItemUId instead of ControlDef) -{ - SvFileStream Stream; - String aLine,aLongname; - rtl::OString aUId; - xub_StrLen nLineNr; - ControlItem *pNewItem; - sal_uInt16 nDoubleCount = 0; - - Stream.Open(Filename, STREAM_STD_READ); - - if (!Stream.IsOpen()) - { - ADD_ERROR(ERR_NO_FILE,GEN_RES_STR1(S_CANNOT_OPEN_FILE, Filename)); - return; - } - - nLineNr = 0; - - if ( !pNames ) - pNames = new CNames(); - - { - TTExecutionStatusHint aHint( TT_EXECUTION_ENTERWAIT ); - GetTTBroadcaster().Broadcast( aHint ); - } - ADD_MESSAGE_LOG( Filename ); - while (!Stream.IsEof()) - { - nLineNr++; - Stream.ReadByteStringLine(aLine, RTL_TEXTENCODING_IBM_850); - aLine.EraseLeadingChars(); - aLine.EraseTrailingChars(); - while ( aLine.SearchAscii(" ") != STRING_NOTFOUND ) - aLine.SearchAndReplaceAllAscii(" ",UniString(' ')); - if (aLine.Len() == 0) - continue; - - if ( (aLine.GetTokenCount(cMyDelim) < 2 || aLine.GetTokenCount(cMyDelim) > 3) && aLine.CompareIgnoreCaseToAscii("*Active") != COMPARE_EQUAL ) - { - ADD_WARNING_LOG2( GEN_RES_STR1( S_INVALID_LINE, aLine ), Filename, nLineNr ); - continue; - } - - aLongname = aLine.GetToken(0,cMyDelim); - // FIXME: HELPID - aUId = rtl::OUStringToOString( aLine.GetToken(1,cMyDelim), RTL_TEXTENCODING_UTF8 ); - - if ( bSortByName ) - pNewItem = new ControlDef( aLongname, aUId ); - else - pNewItem = new ControlItemUId( aLongname, aUId ); - if ( !pNames->C40_PTR_INSERT( ControlItem, pNewItem ) ) - { - if ( bSortByName ) - { - if ( nDoubleCount++ < 10 ) - { - ADD_WARNING_LOG2( GEN_RES_STR1( S_DOUBLE_NAME, aLine ), Filename, nLineNr ); - } - } - else - { - sal_uInt16 nNr; - pNames->Seek_Entry( pNewItem, &nNr ); - AddName( pNames->GetObject(nNr)->pData->Kurzname, pNewItem->pData->Kurzname ); - } - delete pNewItem; - } - GetpApp()->Reschedule(); - } - { - TTExecutionStatusHint aHint( TT_EXECUTION_LEAVEWAIT ); - GetTTBroadcaster().Broadcast( aHint ); - } - - Stream.Close(); -} - -void ReadFlatArray( const ControlDefLoad arWas [], CNames *&pNames ) -{ - sal_uInt16 nIndex = 0; - - if ( !pNames ) - pNames = new CNames(); - - while ( String::CreateFromAscii(arWas[nIndex].Kurzname).Len() > 0 ) - { - // FIXME: HELPID - rtl::OString aUId;// (arWas[nIndex].nUId); - const ControlItem *pX = new ControlDef( arWas[nIndex].Kurzname, aUId); - pNames->C40_PTR_INSERT(ControlItem, pX); - nIndex++; - } -} - -void TestToolObj::WaitForAnswer () -{ - if ( bUseIPC ) - { - sal_Bool bWasRealWait = !bReturnOK; - BasicRuntime aRun( NULL ); - if ( BasicRuntimeAccess::HasRuntime() ) - aRun = BasicRuntimeAccess::GetRuntime(); - - // this timer to terminate Yield below - Timer aTimer; - aTimer.SetTimeout( pImpl->aServerTimeout.GetMSFromTime() ); - aTimer.Start(); - while ( !bReturnOK && aTimer.IsActive() && pCommunicationManager->IsCommunicationRunning() - && aRun.IsValid() && aRun.IsRun() ) - { - GetpApp()->Yield(); - if ( BasicRuntimeAccess::HasRuntime() ) - aRun = BasicRuntimeAccess::GetRuntime(); - else - aRun = BasicRuntime( NULL ); - } - if ( bWasRealWait && aDialogHandlerName.Len() > 0 ) - CallDialogHandler(GetpApp()); - } - else - { - Time Ende( Time::SYSTEM ); - - Ende += pImpl->aServerTimeout; - SvStream *pTemp = NULL; - - while ( !bReturnOK && Ende > Time( Time::SYSTEM ) ) - { - if ( pTemp ) - { - ReturnResults( pTemp ); - bReturnOK = sal_True; - } - else - { - GetpApp()->Reschedule(); - } - nIdleCount = 0; - } - } - - if ( !bReturnOK ) - { - ADD_ERROR(ERR_EXEC_TIMEOUT,GEN_RES_STR1(S_TIMOUT_WAITING, String::CreateFromInt64(nSequence))); - bReturnOK = sal_True; - nSequence++; - } -} - - -IMPL_LINK( TestToolObj, IdleHdl, Application*, EMPTYARG ) -{ - if ( !bReturnOK ) - nIdleCount++; - if ( nIdleCount > 10 ) // means been here for 10 times already and none of these in WaitForAnswer - { - GetpApp()->RemoveIdleHdl( LINK( this, TestToolObj, IdleHdl ) ); - GetpApp()->PostUserEvent( LINK( this, TestToolObj, CallDialogHandler ) ); - } - return 0; -} - -IMPL_LINK( TestToolObj, CallDialogHandler, Application*, EMPTYARG ) -{ - nWindowHandlerCallLevel++; - String aHandlerName(aDialogHandlerName); - aDialogHandlerName.Erase(); - - sal_uLong nRememberSequence = nSequence; - ((StarBASIC*)GetParent())->Call( aHandlerName ); - nSequence = nRememberSequence; - - nWindowHandlerCallLevel--; - return 0; -} - - -void TestToolObj::BeginBlock() -{ - WaitForAnswer(); - if ( IsError() ) - return; - - DBG_ASSERT(!IsBlock,"BeginBlock innerhalb eines Blockes"); - In->Reset(nSequence); - IsBlock = sal_True; -} - - -void TestToolObj::SendViaSocket() -{ - if ( !pCommunicationManager ) - { - OSL_FAIL("Kein CommunicationManager vorhanden!!"); - return; - } - - if ( !pCommunicationManager->IsCommunicationRunning() ) - { - // first try to run basic sub "startTheOffice" see i86540 - SbxVariable* pMeth = pImpl->pMyBasic->Find( CUniString( "startTheOffice" ), SbxCLASS_DONTCARE); - if( !pImpl->bIsStart && pMeth && pMeth->ISA(SbxMethod) ) - { - pImpl->pMyBasic->Call( CUniString( "startTheOffice" ) ); - } - else - { - pImpl->pMyBasic->ResetError(); // reset error produced by failed Find above - if ( !pCommunicationManager->StartCommunication( ProgPath, pImpl->ProgParam, pImpl->pChildEnv ) ) - { - ADD_ERROR(ERR_RESTART_FAIL,GEN_RES_STR1(S_APPLICATION_START_FAILED, ProgPath)); - } - else - { - if ( !pImpl->bIsStart ) - { - ADD_ERROR(ERR_RESTART,GEN_RES_STR0(S_APPLICATION_RESTARTED)); - } - } - } - } - - bReturnOK = sal_False; - if ( pCommunicationManager->GetLastNewLink() ) - { - if ( !pCommunicationManager->GetLastNewLink()->TransferDataStream( In->GetStream() ) ) - { - ADD_ERROR(ERR_SEND_TIMEOUT,GEN_RES_STR1(S_TIMOUT_SENDING, String::CreateFromInt64(nSequence))); - nSequence++; - bReturnOK = sal_True; // no return to be expected - } - } - else - { - ADD_ERROR(ERR_SEND_TIMEOUT,GEN_RES_STR1(S_NO_CONNECTION, String::CreateFromInt64(nSequence))); - nSequence++; - bReturnOK = sal_True; - } - -} - -void TestToolObj::EndBlock() -{ - if (IsBlock) - { - pImpl->LocalStarttime = Time::GetSystemTicks(); // setting the initial time for performance measuring - - In->GenCmdFlow (F_EndCommandBlock); - - if ( pImpl->bDoRemoteCommandDelay ) - { - sal_uLong nTimeWait = pImpl->nMinRemoteCommandDelay; - if ( pImpl->nMaxRemoteCommandDelay != pImpl->nMinRemoteCommandDelay ) - nTimeWait += Time::GetSystemTicks() % ( pImpl->nMaxRemoteCommandDelay - pImpl->nMinRemoteCommandDelay ); - Timer aTimer; - aTimer.SetTimeout( nTimeWait ); - aTimer.Start(); - while ( aTimer.IsActive() && pCommunicationManager->IsCommunicationRunning() ) - { - GetpApp()->Yield(); - } - } - - if ( bUseIPC ) - SendViaSocket(); - else - { - bReturnOK = sal_False; - if ( aDialogHandlerName.Len() > 0 ) - GetpApp()->InsertIdleHdl( LINK( this, TestToolObj, IdleHdl ), 1 ); - } - IsBlock = sal_False; - } - else - { - OSL_FAIL("EndBlock au�erhalb eines Blockes"); - } -} - - -sal_Bool TestToolObj::Load( String aFileName, SbModule *pMod ) -{ - sal_Bool bOk = sal_True; - SvFileStream aStrm( aFileName, STREAM_STD_READ ); - if( aStrm.IsOpen() ) - { - String aText, aLine; - sal_Bool bIsFirstLine = sal_True; - rtl_TextEncoding aFileEncoding = RTL_TEXTENCODING_IBM_850; - while( !aStrm.IsEof() && bOk ) - { - aStrm.ReadByteStringLine( aLine, aFileEncoding ); - if ( bIsFirstLine && IsTTSignatureForUnicodeTextfile( aLine ) ) - aFileEncoding = RTL_TEXTENCODING_UTF8; - else - { - if ( !bIsFirstLine ) - aText += '\n'; - aText += aLine; - bIsFirstLine = sal_False; - } - if( aStrm.GetError() != SVSTREAM_OK ) - bOk = sal_False; - } - aText.ConvertLineEnd(); - pMod->SetName(CUniString("--").Append(aFileName)); - - pMod->SetComment( GetRevision( aText ) ); - - SbModule* pOldModule = MyBasic::GetCompileModule(); - MyBasic::SetCompileModule( pMod ); - - pMod->SetSource( PreCompile( aText ) ); - - MyBasic::SetCompileModule( pOldModule ); - if ( WasPrecompilerError() ) - bOk = sal_False; - - } - else - bOk = sal_False; - return bOk; -} - - -sal_Bool TestToolObj::ReadNamesBin( String Filename, CNames *&pSIds, CNames *&pControls ) -{ - SvFileStream aStream; - String aName,aURL; - rtl::OString aUId; - ControlDef *pNewDef, *pNewDef2; - ControlDef *pFatherDef = NULL; - - - aStream.Open(Filename, STREAM_STD_READ); - if (!aStream.IsOpen()) - { - ADD_ERROR(ERR_NO_FILE,GEN_RES_STR1(S_CANNOT_OPEN_FILE, Filename)); - return sal_False; - } - - if ( !pSIds ) - pSIds = new CNames(); - if ( !pControls ) - pControls = new CNames(); - - { - TTExecutionStatusHint aHint( TT_EXECUTION_ENTERWAIT ); - GetTTBroadcaster().Broadcast( aHint ); - } - - sal_uInt16 nAnz; - aStream >> nAnz; - CNames *pNames = pSIds; // first read all the slots - sal_Bool bIsFlat = sal_True; // Slots do not have children - - while ( nAnz && !aStream.IsEof() ) - { - - aStream.ReadByteString( aName, RTL_TEXTENCODING_UTF8 ); - - sal_uInt16 nType; - aStream >> nType; - if ( !nType /* HasNumeric() */) - { - String aStrId; - aStream.ReadByteString( aStrId, RTL_TEXTENCODING_UTF8 ); - // FIXME: HELPID - } - else - { - comm_UINT32 nUId; - aStream >> nUId; - aUId = rtl::OString();// nUId; - } - - if (aName.GetChar(0) == '*' || bIsFlat ) // global short name (dialogue name or SId) - { - if (!bIsFlat) - aName.Erase(0,1); - pNewDef = new ControlDef(aName,aUId); - - if (!bIsFlat) - { - pNewDef->Sons(new CNames()); - pNewDef2 = new ControlDef(aName,aUId); - if (!pNewDef->SonInsert(pNewDef2)) // enter dialogue into its own namespace - { - delete pNewDef2; - OSL_FAIL(" !!!! ACHTUNG !!!! Fehler beim einf�gen in leere Liste!"); - } - } - - const ControlItem *pItem = pNewDef; - if (! pNames->Insert(pItem)) - { - OSL_FAIL(" !!!! ACHTUNG !!!! Fehler beim einf�gen eines namens!"); - delete pNewDef; - pFatherDef = NULL; - } - else - { - pFatherDef = pNewDef; - } - } - else - { - if (!pFatherDef) - { - OSL_FAIL( "Internal Error: Erster Kurzname mu� mit * beginnen. �berspringe." ); - } - else - { - pNewDef = new ControlDef(aName,aUId); - if (! pFatherDef->SonInsert(pNewDef)) - { - delete pNewDef; - OSL_FAIL(" !!!! ACHTUNG !!!! Fehler beim einf�gen eines namens!"); - } - } - } - nAnz--; - if ( !nAnz && bIsFlat ) // We have read all slots - { - aStream >> nAnz; - pNames = pControls; // Now read the controls - bIsFlat = sal_False; // Controls *do* have children - } - GetpApp()->Reschedule(); - } - { - TTExecutionStatusHint aHint( TT_EXECUTION_LEAVEWAIT ); - GetTTBroadcaster().Broadcast( aHint ); - } - - aStream.Close(); - return sal_True; -} - - -sal_Bool TestToolObj::WriteNamesBin( String Filename, CNames *pSIds, CNames *pControls ) -{ - sal_Bool bOk = sal_True; - SvFileStream aStrm( String(Filename).AppendAscii(".bin"), STREAM_STD_WRITE ); - if( aStrm.IsOpen() ) - { - sal_uInt16 i; - if ( pSIds ) - { - aStrm << pSIds->Count(); - for ( i = 0 ; pSIds->Count() > i && bOk ; i++ ) - { - ((ControlDef*)(*pSIds)[i])->Write(aStrm); - if( aStrm.GetError() != SVSTREAM_OK ) - bOk = sal_False; - } - } - else - aStrm << sal_uInt16( 0 ); - - if ( pControls ) - { - aStrm << pControls->Count(); - for ( i = 0 ; pControls->Count() > i && bOk ; i++ ) - { - ((ControlDef*)(*pControls)[i])->Write(aStrm); - if( aStrm.GetError() != SVSTREAM_OK ) - bOk = sal_False; - } - } - else - aStrm << sal_uInt16( 0 ); - } - else - bOk = sal_False; - return bOk; -} - - -void TestToolObj::SFX_NOTIFY( SfxBroadcaster&, const TypeId&, - const SfxHint& rHint, const TypeId& ) -{ - static CNames *pUIds = NULL; // hold the hid.lst - - const SbxHint* p = PTR_CAST(SbxHint,&rHint); - if( p ) - { - SbxVariable* pVar = p->GetVar(); - SbxArray* rPar = pVar->GetParameters(); - - sal_uLong nHintId = p->GetId(); - sal_uLong nHintUserData = pVar->GetUserData(); - if( nHintId == SBX_HINT_DATAWANTED ) - { - nMyVar = 0; - switch( nHintUserData ) - { - case ID_Kontext: - if ( !rPar ) - { - m_pNameKontext = m_pControls; - - - for (sal_uInt16 i=0;i<VAR_POOL_SIZE;i++) - { - pImpl->pMyVars[i]->SetName( CUniString("VarDummy").Append(UniString::CreateFromInt32(i)) ); - } - } - else if ( rPar && rPar->Count() == 2 ) - { - sal_uInt16 nElement; - SbxVariableRef pArg = rPar->Get( 1 ); - String aKontext = pArg->GetString(); - ControlDef WhatName(aKontext,rtl::OString()); - if (m_pControls && m_pControls->Seek_Entry(&WhatName,&nElement)) - { - m_pNameKontext = ((ControlDef*)m_pControls->GetObject(nElement))->GetSons(); - - - for (sal_uInt16 i=0;i<VAR_POOL_SIZE;i++) - { - pImpl->pMyVars[i]->SetName( CUniString("VarDummy").Append(UniString::CreateFromInt32(i)) ); - } - } - } - else - SetError( SbxERR_WRONG_ARGS ); - break; - case ID_Start: - if ( rPar && rPar->Count() >= 2 ) - { - SbxVariableRef pArg = rPar->Get( 1 ); - ProgPath = pArg->GetString(); - if ( rPar && rPar->Count() >= 3 ) - { - pArg = rPar->Get( 2 ); - pImpl->ProgParam = pArg->GetString(); - } - else - pImpl->ProgParam.Erase(); - - String aTmpStr(ProgPath); - aTmpStr += ' '; - aTmpStr += pImpl->ProgParam; - { - TTExecutionStatusHint aHint( TT_EXECUTION_SHOW_ACTION, String(IttResId(S_STARTING_APPLICATION)), aTmpStr ); - GetTTBroadcaster().Broadcast( aHint ); - } - - pImpl->bIsStart = sal_True; - BeginBlock(); - EndBlock(); - pImpl->bIsStart = sal_False; - { - TTExecutionStatusHint aHint( TT_EXECUTION_HIDE_ACTION ); - GetTTBroadcaster().Broadcast( aHint ); - } - } - break; - case ID_KillApp: - pCommunicationManager->KillApplication(); - break; - case ID_SaveIDs: - if ( rPar && rPar->Count() >= 2 ) // one parameter excactly - { - SbxVariableRef pArg = rPar->Get( 1 ); - #if defined(WNT) - DirEntry FilePath = pImpl->aFileBase + DirEntry(pArg->GetString(),FSYS_STYLE_NTFS); - #else - DirEntry FilePath = pImpl->aFileBase + DirEntry(pArg->GetString(),FSYS_STYLE_UNX); - #endif - WriteNamesBin( FilePath.GetFull(), m_pSIds, m_pControls ); - } - else - SetError( SbxERR_WRONG_ARGS ); - break; - case ID_AutoExecute: - if ( !rPar ) // rPar = NULL <=> no parameters - { - pVar->PutBool(SingleCommandBlock); - } - else - SetError( SbxERR_WRONG_ARGS ); - break; - case ID_Execute: - if ( !rPar ) - { - EndBlock(); - BeginBlock(); - } - else - SetError( SbxERR_WRONG_ARGS ); - break; - case ID_DialogHandler: - if ( rPar && rPar->Count() >= 2 ) - { - SbxVariableRef pArg = rPar->Get( 1 ); - aDialogHandlerName = pArg->GetString(); - } - else - SetError( SbxERR_WRONG_ARGS ); - break; - case ID_GetError: - if ( !rPar ) - { - WaitForAnswer(); - if ( IS_ERROR() ) - { - pVar->PutString( GET_ERROR()->aText ); - POP_ERROR(); - } - else - { - pVar->PutString( String() ); - } - } - else - SetError( SbxERR_WRONG_ARGS ); - break; - case ID_StartUse: - if ( !rPar ) - { - { - BasicRuntime aRun = BasicRuntimeAccess::GetRuntime(); - aLogFileName = DirEntry(aRun.GetModuleName(SbxNAME_NONE)).GetBase().AppendAscii(".res"); - } - - ADD_RUN_LOG(); - ADD_CASE_LOG(GEN_RES_STR0(S_READING_FILE)); - - pCommunicationManager->StopCommunication(); - // Wait for asynchronous events to be processed, so communication will be restarted properly - while ( pCommunicationManager->IsCommunicationRunning() ) - Application::Reschedule(); - - SingleCommandBlock = sal_True; - IsBlock = sal_False; - - for (sal_uInt16 i=0;i<VAR_POOL_SIZE;i++) - { - pImpl->pMyVars[i]->SetName( CUniString("VarDummy").Append(UniString::CreateFromInt32(i)) ); - } - nMyVar = 0; - - if (m_pControls) - { - delete m_pControls; - m_pControls = NULL; - } - if (m_pReverseSlots) - { - delete m_pReverseSlots; - m_pReverseSlots = NULL; - } - if (m_pReverseControls) - { - delete m_pReverseControls; - m_pReverseControls = NULL; - } - if (m_pReverseControlsSon) - { - delete m_pReverseControlsSon; - m_pReverseControlsSon = NULL; - } - if (m_pSIds) - { - delete m_pSIds; - m_pSIds = NULL; - } - if (pUIds) - { - delete pUIds; - pUIds = NULL; - } - if (m_pReverseUIds) - { - delete m_pReverseUIds; - m_pReverseUIds = NULL; - } - m_pNameKontext = m_pControls; - pImpl->bLnaguageExtensionLoaded = sal_False; - SfxSimpleHint aHint( SBX_HINT_LANGUAGE_EXTENSION_LOADED ); - GetTTBroadcaster().Broadcast( aHint ); - - pImpl->nMinRemoteCommandDelay = 0; - pImpl->nMaxRemoteCommandDelay = 0; - pImpl->bDoRemoteCommandDelay = sal_False; - pImpl->aTestCaseName.Erase(); - pImpl->aTestCaseFileName.Erase(); - pImpl->nTestCaseLineNr = 0; - - pImpl->bEnableQaErrors = sal_True; - pImpl->bDebugFindNoErrors = sal_False; - - pImpl->pChildEnv->clear(); - - String aName( CUniString( "StopOnSyntaxError" ) ); - SbxVariableRef xStopOnSyntaxError = SbxObject::Find( aName, SbxCLASS_PROPERTY ); - if ( xStopOnSyntaxError.Is() ) - xStopOnSyntaxError->PutBool( pImpl->bStopOnSyntaxError ); - else - SetError( SbxERR_BAD_ACTION ); - } - else - SetError( SbxERR_WRONG_ARGS ); - break; - case ID_Use: - if ( rPar && rPar->Count() >= 2 ) - { - SbxVariableRef pArg = rPar->Get( 1 ); - #if defined(WNT) - DirEntry FilePath(pArg->GetString(),FSYS_STYLE_NTFS); - #else - DirEntry FilePath(pArg->GetString(),FSYS_STYLE_UNX); - #endif - if ( !FilePath.IsAbs() ) - FilePath = pImpl->aFileBase + FilePath; - String Ext = FilePath.GetExtension(); - if ( Ext.CompareIgnoreCaseToAscii("Win") == COMPARE_EQUAL ) - { - ReadNames( FilePath.GetFull(),m_pControls,pUIds); - pImpl->bLnaguageExtensionLoaded = sal_True; - SfxSimpleHint aHint( SBX_HINT_LANGUAGE_EXTENSION_LOADED ); - GetTTBroadcaster().Broadcast( aHint ); - } - else if ( Ext.CompareIgnoreCaseToAscii("Sid") == COMPARE_EQUAL ) - { - ReadNames( FilePath.GetFull(),m_pSIds,pUIds,FLAT); - pImpl->bLnaguageExtensionLoaded = sal_True; - SfxSimpleHint aHint( SBX_HINT_LANGUAGE_EXTENSION_LOADED ); - GetTTBroadcaster().Broadcast( aHint ); - } - else if ( Ext.CompareIgnoreCaseToAscii("Bin") == COMPARE_EQUAL ) - { - ReadNamesBin( FilePath.GetFull(), m_pSIds, m_pControls ); - pImpl->bLnaguageExtensionLoaded = sal_True; - SfxSimpleHint aHint( SBX_HINT_LANGUAGE_EXTENSION_LOADED ); - GetTTBroadcaster().Broadcast( aHint ); - } - else if ( Ext.CompareIgnoreCaseToAscii("Inc") == COMPARE_EQUAL ) - { - { - TTExecutionStatusHint aHint( TT_EXECUTION_SHOW_ACTION, String(IttResId(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 ) - { - ADD_CASE_LOG( String() ); // close case - if (!m_pControls) - m_pControls = new CNames(); - - if (!m_pSIds) - m_pSIds = new CNames(); - - if (pUIds) - { // save some memory - delete pUIds; - pUIds = NULL; - } - - m_pNameKontext = m_pControls; - - if ( pImpl->bLnaguageExtensionLoaded ) - { - SfxSimpleHint aHint( SBX_HINT_LANGUAGE_EXTENSION_LOADED ); - GetTTBroadcaster().Broadcast( aHint ); - } - - pImpl->nIncludeFileWarningCount = pImpl->nWarningCount; - pImpl->nWarningCount = 0; - - *pImpl->xIncludeFileWarningList = *pImpl->xWarningList; - pImpl->xWarningList->SbxArray::Clear(); - } - else - SetError( SbxERR_WRONG_ARGS ); - break; - case ID_CaseLog: - if ( rPar ) // rPar != NULL <=> there are parameters - { - sal_uInt16 n; - String aX; - for ( n = 1; n < rPar->Count(); n++ ) - { - SbxVariableRef pArg = rPar->Get( n ); - aX += pArg->GetString(); - } - pImpl->aTestCaseName = aX; - if ( pImpl->aTestCaseName.Len() && BasicRuntimeAccess::HasRuntime() ) - { - BasicRuntime aRun = BasicRuntimeAccess::GetRuntime(); - pImpl->aTestCaseFileName = aRun.GetModuleName(SbxNAME_SHORT_TYPES); - if ( pImpl->aTestCaseFileName.Copy(0,2).CompareToAscii( "--" ) == COMPARE_EQUAL ) - pImpl->aTestCaseFileName.Erase(0,2); - pImpl->nTestCaseLineNr = aRun.GetLine(); - } - else - { - pImpl->aTestCaseFileName.Erase(); - pImpl->nTestCaseLineNr = 0; - } - ADD_CASE_LOG( aX ); - } - break; - case ID_ExceptLog: - if ( IS_ERROR() ) - { - BasicRuntime aRun = BasicRuntimeAccess::GetRuntime(); - sal_Bool bWasNewError = sal_False; - - if ( BasicRuntimeAccess::HasStack() ) - { - for ( sal_uInt16 i = 0 ; i < BasicRuntimeAccess::GetStackEntryCount() -1 ; i++ ) - { - BasicErrorStackEntry aThisEntry = BasicRuntimeAccess::GetStackEntry(i); - if ( !bWasNewError ) - { - bWasNewError = sal_True; - ADD_ERROR_LOG( GET_ERROR()->aText, aThisEntry.GetModuleName(SbxNAME_SHORT_TYPES), - aThisEntry.GetLine(), aThisEntry.GetCol1(), aThisEntry.GetCol2(), aThisEntry.GetSourceRevision() ); - } - ADD_CALL_STACK_LOG( String(aThisEntry.GetModuleName(SbxNAME_SHORT_TYPES)) - .AppendAscii(": ").Append(aThisEntry.GetMethodName(SbxNAME_SHORT_TYPES)), - aThisEntry.GetModuleName(SbxNAME_SHORT_TYPES), - aThisEntry.GetLine(), aThisEntry.GetCol1(), aThisEntry.GetCol2() ); - - } - BasicRuntimeAccess::DeleteStack(); - } - - sal_Bool bIsFirst = sal_True; - while ( aRun.IsValid() ) - { - xub_StrLen nErrLn; - xub_StrLen nCol1; - xub_StrLen nCol2; - if ( bIsFirst ) - { - bIsFirst = sal_False; - nErrLn = GET_ERROR()->nLine; - nCol1 = GET_ERROR()->nCol1; - nCol2 = GET_ERROR()->nCol2; - } - else - { - nErrLn = aRun.GetLine(); - nCol1 = aRun.GetCol1(); - nCol2 = aRun.GetCol2(); - } - - if ( !bWasNewError ) - { - bWasNewError = sal_True; - ADD_ERROR_LOG( GET_ERROR()->aText, aRun.GetModuleName(SbxNAME_SHORT_TYPES), - nErrLn, nCol1, nCol2, aRun.GetSourceRevision() ); - } - ADD_CALL_STACK_LOG( String(aRun.GetModuleName(SbxNAME_SHORT_TYPES)) - .AppendAscii(": ").Append(aRun.GetMethodName(SbxNAME_SHORT_TYPES)), - aRun.GetModuleName(SbxNAME_SHORT_TYPES), - nErrLn, nCol1, nCol2 ); - aRun = aRun.GetNextRuntime(); - } - } - break; - case ID_ErrorLog: - if ( IS_ERROR() ) - { - BasicRuntime aRun = BasicRuntimeAccess::GetRuntime(); - if ( BasicRuntimeAccess::HasStack() ) - { - BasicErrorStackEntry aThisEntry = BasicRuntimeAccess::GetStackEntry( 0 ); - ADD_ERROR_LOG( GET_ERROR()->aText, aThisEntry.GetModuleName(SbxNAME_SHORT_TYPES), - aThisEntry.GetLine(), aThisEntry.GetCol1(), aThisEntry.GetCol2(), aThisEntry.GetSourceRevision() ); - BasicRuntimeAccess::DeleteStack(); - } - else - { - ADD_ERROR_LOG( GET_ERROR()->aText, aRun.GetModuleName(SbxNAME_SHORT_TYPES), - StarBASIC::GetErl(), aRun.GetCol1(), aRun.GetCol2(), aRun.GetSourceRevision() ); - } - } - break; - case ID_QAErrorLog: - if ( rPar ) - { - sal_uInt16 n; - String aSammel; - for ( n = 1; n < rPar->Count(); n++ ) - { - SbxVariableRef pArg = rPar->Get( n ); - aSammel += pArg->GetString(); - } - ADD_QA_ERROR_LOG( aSammel ); - } - break; - case ID_PrintLog: - if ( rPar ) - { - sal_uInt16 n; - String aSammel; - for ( n = 1; n < rPar->Count(); n++ ) - { - SbxVariableRef pArg = rPar->Get( n ); - aSammel += pArg->GetString(); - } - ADD_MESSAGE_LOG( aSammel ); - } - break; - case ID_WarnLog: - if ( rPar ) - { - sal_uInt16 n; - String aSammel; - for ( n = 1; n < rPar->Count(); n++ ) - { - SbxVariableRef pArg = rPar->Get( n ); - aSammel += pArg->GetString(); - } - ADD_WARNING_LOG( aSammel ); - - } - break; - case ID_ClearError: - while ( IS_ERROR() ) - { - POP_ERROR(); - } - break; - case ID_MaybeAddErr: - if ( ((StarBASIC*)GetParent())->GetErrBasic() && ( !IS_ERROR() || - pFehlerListe->GetObject(pFehlerListe->Count()-1)->nError != ((StarBASIC*)GetParent())->GetErrBasic() ) ) - { - ((StarBASIC*)GetParent())->MakeErrorText(((StarBASIC*)GetParent())->GetErrBasic(),String()); - ADD_ERROR_QUIET(((StarBASIC*)GetParent())->GetErrBasic() , ((StarBASIC*)GetParent())->GetErrorText()) - } - break; - case ID_GetNextCloseWindow: - if ( !rPar ) - { - SetError( SbxERR_NOTIMP ); - } - else - SetError( SbxERR_WRONG_ARGS ); - break; - case ID_RemoteCommand: - { - if ( SingleCommandBlock ) - BeginBlock(); - else - if ( ((SbxTransportMethod*)pVar)->nValue & M_WITH_RETURN ) - { - SetError( SbxERR_NOTIMP ); - } - if ( !IsError() ) - In->GenCmdCommand ((sal_uInt16)(((SbxTransportMethod*)pVar)->nValue),rPar); - if ( !IsError() && ((SbxTransportMethod*)pVar)->nValue & M_WITH_RETURN ) - { - pImpl->pNextReturn = ((SbxTransportMethod*)pVar); - // FIXME: HELPID - aNextReturnId = rtl::OString(); - } - if ( SingleCommandBlock ) - EndBlock(); - if ( !IsError() && (sal_uInt16)((SbxTransportMethod*)pVar)->nValue & M_WITH_RETURN ) - { - WaitForAnswer(); - } - - switch ( ((SbxTransportMethod*)pVar)->nValue ) - { - case RC_WinTree: - break; - } - - } - break; - case ID_Dispatch: - if ( !rPar || (rPar->Count() % 2) == 1 ) - { - if ( SingleCommandBlock ) - BeginBlock(); - if ( !IsError() ) - In->GenCmdSlot ( (sal_uInt16)((SbxTransportMethod*)pVar)->nValue, rPar ); - pVar->PutInteger( (sal_uInt16)((SbxTransportMethod*)pVar)->nValue ); - if ( SingleCommandBlock ) - EndBlock(); - } - else - SetError( SbxERR_WRONG_ARGS ); - break; - case ID_UNODispatch: - if ( !rPar ) - { - if ( SingleCommandBlock ) - BeginBlock(); - if ( !IsError() ) - In->GenCmdUNOSlot ( ((SbxTransportMethod*)pVar)->aUnoSlot ); - pVar->PutString( ((SbxTransportMethod*)pVar)->aUnoSlot ); - if ( SingleCommandBlock ) - EndBlock(); - } - else - SetError( SbxERR_WRONG_ARGS ); - break; - case ID_Control: - case ID_StringControl: - // if only the object is given in the script we don't have to do anything (object stands for itself) - if ( !pVar->ISA( SbxObject ) ) - { - if ( SingleCommandBlock ) - BeginBlock(); - else - if ( ((SbxTransportMethod*)pVar)->nValue & M_WITH_RETURN ) - { - SetError( SbxERR_NOTIMP ); - } - if ( !IsError() ) - { - SbxVariable *pMember = NULL; - if ( pVar->GetParent() ) - pMember = pVar->GetParent()->Find(CUniString("ID"),SbxCLASS_DONTCARE); - if ( pMember == NULL ) - { - SetError( SbxERR_NAMED_NOT_FOUND ); - } - else - { - if ( nHintUserData == ID_Control ) - { - In->GenCmdControl (pMember->GetULong(), - (sal_uInt16)((SbxTransportMethod*)pVar)->nValue, rPar); - // FIXME: HELPID - aNextReturnId = rtl::OString(); - } - else - { - In->GenCmdControl (pMember->GetString(), - (sal_uInt16)((SbxTransportMethod*)pVar)->nValue, rPar); - // FIXME: HELPID - } - } - - if ( !IsError() && ((SbxTransportMethod*)pVar)->nValue & M_WITH_RETURN ) - { - pImpl->pNextReturn = ((SbxTransportMethod*)pVar); - } - else - { - pImpl->pNextReturn = NULL; - aNextReturnId = rtl::OString(); - } - - } - if ( SingleCommandBlock ) - EndBlock(); - if ( !IsError() && (sal_uInt16)((SbxTransportMethod*)pVar)->nValue & M_WITH_RETURN ) - { - WaitForAnswer(); - } - } - - break; - case ID_GetUnoApp: - { - // the remote UNO stuff is started here - // entry into the configuration at - // org.openoffice.Office.Common/Start/Connection - // socket,host=0,port=12345;iiop;XBla - // or - // 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(); - - 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("StarOffice.ServiceManager")) ) ); - - smgr_xMultiserviceFactory = Reference< XMultiServiceFactory >(xRet, UNO_QUERY); - // ask MBA!! - } - 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 <<= smgr_xMultiserviceFactory; - - SbxObjectRef xMySbxObj = GetSbUnoObject( CUniString("RemoteUnoAppFuerTesttool"), aAny ); - if ( xMySbxObj.Is() ) - pVar->PutObject( xMySbxObj ); - } - } - break; - case ID_GetIServer: - { - // remote UNO stuff is started here - - String aString; - - Reference< XMultiServiceFactory > xSMgr; - { - xSMgr = ::cppu::createRegistryServiceFactory(OUString(RTL_CONSTASCII_USTRINGPARAM("g:\\iserverproxy.rdb")), sal_True); - } - - 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")) ) ); - - - 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: // pass always everything as Short - case SbxULONG: - case SbxSALINT64: - case SbxSALUINT64: - case SbxDOUBLE: - case SbxINTEGER: - case SbxBYTE: - case SbxUSHORT: - case SbxINT: - case SbxUINT: - case SbxSINGLE: - pImpl->nMinRemoteCommandDelay = rPar->Get( 1 )->GetULong(); - if ( rPar->Count() == 3 ) - pImpl->nMaxRemoteCommandDelay = rPar->Get( 2 )->GetULong(); - else - pImpl->nMaxRemoteCommandDelay = pImpl->nMinRemoteCommandDelay; - break; - case SbxBOOL: - pImpl->bDoRemoteCommandDelay = rPar->Get( 1 )->GetBool(); - break; - default: - SbxBase::SetError( SbxERR_WRONG_ARGS ); - break; - } - } - else - SetError( SbxERR_WRONG_ARGS ); - break; - case ID_GetApplicationPath: - if ( !rPar ) - { - OUString aUrl = Config::GetDefDirectory(); - OUString aPath; - osl::FileBase::getSystemPathFromFileURL( aUrl, aPath ); - pVar->PutString( String( aPath ) ); - } - else - SetError( SbxERR_WRONG_ARGS ); - break; - case ID_GetCommonApplicationPath: - if ( !rPar ) - { -#ifdef WNT - //////// adapted this from setup2\win\source\system\winos.cxx - String aSysPath; - aSysPath = _SHGetSpecialFolder_COMMON_APPDATA(); - if ( aSysPath.Len() ) - { - pVar->PutString( aSysPath ); - } - else // default to ID_GetApplicationPath (same as in setup) - { - OUString aUrl = Config::GetDefDirectory(); - OUString aPath; - osl::FileBase::getSystemPathFromFileURL( aUrl, aPath ); - pVar->PutString( String( aPath ) ); - } -#else -#if UNX - pVar->PutString( CUniString( "/etc" ) ); -#else -#error not implemented -#endif -#endif - } - else - SetError( SbxERR_WRONG_ARGS ); - break; - case ID_MakeIniFileName: - if ( rPar && rPar->Count() == 2 ) - { - OUString aUrl = Config::GetConfigName( String(), rPar->Get( 1 )->GetString() ); - OUString aPath; - osl::FileBase::getSystemPathFromFileURL( aUrl, aPath ); - pVar->PutString( String( aPath ) ); - } - else - SetError( SbxERR_WRONG_ARGS ); - break; - case ID_Wait: - { - if( rPar && rPar->Count() == 2 ) - { - long nWait = rPar->Get(1)->GetLong(); - if( nWait >= 0 ) - { -#ifdef DEBUG - Time aStart; -#endif - Timer aTimer; - aTimer.SetTimeout( nWait ); - aTimer.Start(); - while ( aTimer.IsActive() ) - Application::Yield(); -#ifdef DEBUG - Time aEnd; - Time aDiff = aEnd - aStart; - long aMS = long( aDiff.GetMSFromTime() ); - if ( Abs( aMS - nWait ) > 100 ) - { - OSL_TRACE("Wait was off limit by %i", aDiff.GetMSFromTime() - nWait ); - } -#endif - } - } - else - SetError( SbERR_BAD_NUMBER_OF_ARGS ); - } - break; - case ID_GetErrorCount: - { - pVar->PutULong( pImpl->nErrorCount ); - } - break; - case ID_GetWarningCount: - { - pVar->PutULong( pImpl->nWarningCount ); - } - break; - case ID_GetQAErrorCount: - { - pVar->PutULong( pImpl->nQAErrorCount ); - } - break; - case ID_GetUseFileWarningCount: - { - pVar->PutULong( pImpl->nIncludeFileWarningCount ); - } - break; - case ID_GetErrorList: - { - if ( ! pImpl->xErrorList->GetDims() ) - pImpl->xErrorList->AddDim( 1, 32000 ); - pVar->PutObject( pImpl->xErrorList ); - } - break; - case ID_GetWarningList: - { - if ( ! pImpl->xWarningList->GetDims() ) - pImpl->xWarningList->AddDim( 1, 32000 ); - pVar->PutObject( pImpl->xWarningList ); - } - break; - case ID_GetQAErrorList: - { - if ( ! pImpl->xQAErrorList->GetDims() ) - pImpl->xQAErrorList->AddDim( 1, 32000 ); - pVar->PutObject( pImpl->xQAErrorList ); - } - break; - case ID_GetUseFileWarningList: - { - if ( ! pImpl->xIncludeFileWarningList->GetDims() ) - pImpl->xIncludeFileWarningList->AddDim( 1, 32000 ); - pVar->PutObject( pImpl->xIncludeFileWarningList ); - } - break; - case ID_GetTestCaseName: - { - pVar->PutString( pImpl->aTestCaseName ); - } - break; - case ID_GetTestCaseFileName: - { - pVar->PutString( pImpl->aTestCaseFileName ); - } - break; - case ID_GetTestCaseLineNr: - { - pVar->PutUShort( pImpl->nTestCaseLineNr ); - } - break; - case ID_SetChildEnv: - { - if( rPar && rPar->Count() == 3 ) - { - pImpl->pChildEnv->erase( rPar->Get(1)->GetString() ); - pImpl->pChildEnv->insert( EnvironmentVariable( rPar->Get(1)->GetString(), rPar->Get(2)->GetString() ) ); - } - else - SetError( SbERR_BAD_NUMBER_OF_ARGS ); - } - break; - case ID_GetChildEnv: - { - if( rPar && rPar->Count() == 2 ) - { - Environment::const_iterator aIter = pImpl->pChildEnv->find( rPar->Get(1)->GetString() ); - if ( aIter != pImpl->pChildEnv->end() ) - pVar->PutString( (*aIter).second ); - else - pVar->PutString( String() ); - } - else - SetError( SbERR_BAD_NUMBER_OF_ARGS ); - } - break; - case ID_GetLinkDestination: - { - if( rPar && rPar->Count() == 2 ) - { - String aSource,aDest; - aSource = rPar->Get(1)->GetString(); -#ifdef UNX - rtl::OString aByteSource(rtl::OUStringToOString(aSource, osl_getThreadTextEncoding())); - char cDest[1024]; - int nLen = 0; - if ( ( nLen = readlink( aByteSource.getStr(), cDest, sizeof(cDest) ) ) >= 0 ) - { - aDest = String( cDest, nLen, osl_getThreadTextEncoding() ); - } - else - { - int nErr = errno; - switch ( nErr ) - { - case EINVAL: aDest = aSource; - break; - default: - SetError( SbERR_ACCESS_ERROR ); - } - } -#else - aDest = aSource; -#endif - pVar->PutString( aDest ); - } - else - SetError( SbERR_BAD_NUMBER_OF_ARGS ); - } - break; - case ID_GetRegistryValue: - { - if( rPar && rPar->Count() == 3 ) - { - String aValue; -#ifdef WNT - aValue = ReadRegistry( rPar->Get(1)->GetString(), rPar->Get(2)->GetString() ); -#endif - pVar->PutString( aValue ); - } - else - SetError( SbERR_BAD_NUMBER_OF_ARGS ); - } - break; - case ID_HTTPSend: - { - if( rPar && ( rPar->Count() == 4 || rPar->Count() == 5 ) ) - { - if ( !pImpl->pHttpRequest ) - pImpl->pHttpRequest = new HttpRequest; - pImpl->pHttpRequest->SetRequest( rtl::OUStringToOString( rPar->Get(1)->GetString(), RTL_TEXTENCODING_ASCII_US ), rtl::OUStringToOString( rPar->Get(2)->GetString(), RTL_TEXTENCODING_ASCII_US ), rPar->Get(3)->GetUShort() ); - - if ( pImpl->pHttpRequest->Execute() ) - { - if ( rPar->Count() == 5 ) - { // filename is given - SvFileStream aDestination( rPar->Get(4)->GetString(), STREAM_STD_READWRITE | STREAM_TRUNC ); - (*(pImpl->pHttpRequest->GetBody())) >> aDestination; - if ( aDestination.GetError() != ERRCODE_NONE ) - SetError( SbERR_ACCESS_ERROR ); - aDestination.Close(); - } - pVar->PutUShort( pImpl->pHttpRequest->GetResultId() ); - } - else - SetError( SbERR_ACCESS_ERROR ); - } - else - SetError( SbERR_BAD_NUMBER_OF_ARGS ); - } - break; - case ID_HTTPSetProxy: - { - if( rPar && rPar->Count() == 3 ) - { - if ( !pImpl->pHttpRequest ) - pImpl->pHttpRequest = new HttpRequest; - pImpl->pHttpRequest->SetProxy( rtl::OUStringToOString( rPar->Get(1)->GetString(), RTL_TEXTENCODING_ASCII_US ), rPar->Get(2)->GetUShort() ); - } - else - SetError( SbERR_BAD_NUMBER_OF_ARGS ); - } - break; - } // switch( nHintUserData ) - } // if( nHintId == SBX_HINT_DATAWANTED ) - else if( nHintId == SBX_HINT_DATACHANGED ) - { - switch( nHintUserData ) - { - case ID_AutoExecute: - if ( !rPar ) - { - SingleCommandBlock = pVar->GetBool(); - if ( SingleCommandBlock ) - EndBlock(); - else - BeginBlock(); - } - else - SetError( SbxERR_WRONG_ARGS ); - break; - case ID_EnableQaErrors: - if ( !rPar ) - pImpl->bEnableQaErrors = pVar->GetBool(); - else - SetError( SbxERR_WRONG_ARGS ); - break; - } - } // if( nHintId == SBX_HINT_DATACHANGED ) - else if( nHintId == SBX_HINT_BASICSTART ) - { - pImpl->nErrorCount = 0; - pImpl->nWarningCount = 0; - pImpl->nQAErrorCount = 0; - pImpl->nIncludeFileWarningCount = 0; - - pImpl->xErrorList->SbxArray::Clear(); // call SbxArray::Clear because SbxVarArray::Clear only clears dimensions but no content - pImpl->xWarningList->SbxArray::Clear(); // call SbxArray::Clear because SbxVarArray::Clear only clears dimensions but no content - pImpl->xQAErrorList->SbxArray::Clear(); // call SbxArray::Clear because SbxVarArray::Clear only clears dimensions but no content - pImpl->xIncludeFileWarningList->SbxArray::Clear(); // call SbxArray::Clear because SbxVarArray::Clear only clears dimensions but no content - - if (pFehlerListe) - delete pFehlerListe; - pFehlerListe = new CErrors; - - for (sal_uInt16 i=0;i<VAR_POOL_SIZE;i++) - { - pImpl->pMyVars[i]->SetName( CUniString("VarDummy").Append(UniString::CreateFromInt32(i)) ); - } - nMyVar = 0; - - } // if( nHintId == SBX_HINT_BASICSTART ) - else if( nHintId == SBX_HINT_BASICSTOP ) - { - // Log summary to journal - ADD_CASE_LOG( String() ); // close case - ADD_MESSAGE_LOG( CUniString("***************************************************") ); - if ( pImpl->nErrorCount ) - { - ADD_WARNING_LOG( GEN_RES_STR1( S_ERRORS_DETECTED, String::CreateFromInt32( pImpl->nErrorCount ) ) ); - pImpl->nWarningCount--; // adjust because this warning shall not be in the statistics - } - else - ADD_MESSAGE_LOG( GEN_RES_STR0( S_NO_ERRORS_DETECTED ) ); - - if ( pImpl->nWarningCount ) - ADD_WARNING_LOG( GEN_RES_STR1( S_WARNINGS_DETECTED, String::CreateFromInt32( pImpl->nWarningCount ) ) ) - else - ADD_MESSAGE_LOG( GEN_RES_STR0( S_NO_WARNINGS_DETECTED ) ); - - if ( pImpl->nIncludeFileWarningCount ) - ADD_WARNING_LOG( GEN_RES_STR1( S_INCLUDE_FILE_WARNINGS_DETECTED, String::CreateFromInt32( pImpl->nIncludeFileWarningCount ) ) ) - else - ADD_MESSAGE_LOG( GEN_RES_STR0( S_NO_INCLUDE_FILE_WARNINGS_DETECTED ) ); - ADD_MESSAGE_LOG( CUniString("***************************************************") ); - - pImpl->nErrorCount = 0; - pImpl->nWarningCount = 0; - pImpl->nQAErrorCount = 0; - pImpl->nIncludeFileWarningCount = 0; - - pImpl->xErrorList->SbxArray::Clear(); // call SbxArray::Clear because SbxVarArray::Clear only clears dimensions but no content - pImpl->xWarningList->SbxArray::Clear(); // call SbxArray::Clear because SbxVarArray::Clear only clears dimensions but no content - pImpl->xQAErrorList->SbxArray::Clear(); // call SbxArray::Clear because SbxVarArray::Clear only clears dimensions but no content - pImpl->xIncludeFileWarningList->SbxArray::Clear(); // call SbxArray::Clear because SbxVarArray::Clear only clears dimensions but no content - } // if( nHintId == SBX_HINT_BASICSTOP ) - WaitForAnswer(); - if ( IsError() && ( !IS_ERROR() || GET_ERROR()->nError != GetError() ) ) - { - ((StarBASIC*)GetParent())->MakeErrorText(GetError(),String()); - ADD_ERROR_QUIET(GetError(),String(pVar->GetName()).AppendAscii(": "). - Append(((StarBASIC*)GetParent())->GetErrorText())); - } - } -} - -void TestToolObj::DebugFindNoErrors( sal_Bool bDebugFindNoErrors ) -{ - pImpl->bDebugFindNoErrors = bDebugFindNoErrors; -} - -SbxVariable* TestToolObj::Find( const String& aStr, SbxClassType aType) -{ - if ( BasicRuntimeAccess::IsRunInit() - || ( aStr == String( RTL_CONSTASCII_USTRINGPARAM( "ThisComponent" ) ) ) ) // because of find in the "global" command of the basic - return NULL; - - SbxVariableRef Old = SbxObject::Find(aStr, aType ); - // do not return any objects from pMyVars[] - if (Old && Old->GetUserData() != ID_Dispatch - && Old->GetUserData() != ID_UNODispatch - && Old->GetUserData() != ID_ErrorDummy - && Old->GetUserData() != 0 ) - return Old; - else if ( aStr.SearchAscii(":") != STRING_NOTFOUND ) - { // ignore qualified names e.g. main:FormWizard If this was removed an error would be generated - } - else - { - - sal_uInt16 nElement; - ControlDef *pWhatName = new ControlDef(aStr,rtl::OString()); - - /// look for controls - if (m_pNameKontext && m_pNameKontext->Seek_Entry(pWhatName,&nElement)) - { - delete pWhatName; - pWhatName = ((ControlDef*)m_pNameKontext->GetObject(nElement)); - -//// new Controls Object every time - pImpl->pControlsObj = new Controls( pWhatName->pData->Kurzname ); - pImpl->pControlsObj->SetType( SbxOBJECT ); - pImpl->pControlsObj->ChangeListener( this ); - - - // Will be set on method-child further down - // FIXME: HELPID - pImpl->pControlsObj->SetUserData( ID_StringControl ); - - pShortNames->Insert(pWhatName->pData->Kurzname,pWhatName->pData->aUId,nSequence); - - SbxVariable *pMember = pImpl->pControlsObj->Find(CUniString("ID"),SbxCLASS_DONTCARE); - if ( pMember == NULL ) - { - SbxProperty* pID = new SbxProperty(CUniString("ID"),SbxVARIANT); - pImpl->pControlsObj->Insert(pID); - pImpl->pControlsObj->SetDfltProperty(pID); - pMember = pID; - } - // FIXME: HELPID - pMember = pImpl->pControlsObj->Find(CUniString("name"),SbxCLASS_DONTCARE); - if ( pMember != NULL ) - pMember->PutString(pWhatName->pData->Kurzname); - - return pImpl->pControlsObj; - } - - /// look for slots - if (m_pSIds && m_pSIds->Seek_Entry(pWhatName,&nElement)) - { - SbxTransportMethodRef pMyVar; - pMyVar = pImpl->pMyVars[nMyVar++]; - if ( nMyVar >= VAR_POOL_SIZE ) - nMyVar = 0; - delete pWhatName; - pWhatName = ( (ControlDef*)m_pSIds->GetObject( nElement ) ); - pMyVar->SetName( pWhatName->pData->Kurzname ); - - // FIXME: HELPID - return pMyVar; - } - - /// it might be a SlotID that is asked numerically instead of being executed - if ( aStr.Copy( aStr.Len()-3, 3 ).CompareIgnoreCaseToAscii("_ID") == COMPARE_EQUAL && m_pSIds ) - { - delete pWhatName; - pWhatName = new ControlDef( aStr.Copy( 0, aStr.Len()-3 ), rtl::OString() ); - if ( m_pSIds->Seek_Entry( pWhatName, &nElement ) ) - { // look for slots - SbxVariable *pReturn = new SbxVariable; - delete pWhatName; - pWhatName = ( (ControlDef*)m_pSIds->GetObject( nElement ) ); - pReturn->SetName( pWhatName->pData->Kurzname ); - - // FIXME: HELPID - return pReturn; - } - } - if ( !pImpl->bDebugFindNoErrors ) - { - ADD_ERROR(SbxERR_PROC_UNDEFINED,GEN_RES_STR1(S_UNKNOWN_SLOT_CONTROL, aStr) ); - } - - delete pWhatName; - } - return NULL; -} - -String TestToolObj::GetRevision( String const &aSourceIn ) -{ - // search $Revision: 1.40 $ - xub_StrLen nPos; - if ( ( nPos = aSourceIn.SearchAscii( "$Revision:" ) ) != STRING_NOTFOUND ) - return aSourceIn.Copy( nPos+ 10, aSourceIn.SearchAscii( "$", nPos+10 ) -nPos-10); - else - return String::CreateFromAscii("No Revision found"); -} - -sal_Bool TestToolObj::CError( sal_uLong code, const String& rMsg, xub_StrLen l, xub_StrLen c1, xub_StrLen c2 ) -{ - bWasPrecompilerError = sal_True; - if ( aCErrorHdl.IsSet() ) - { - ErrorEntry aErrorEntry( code, rMsg, l, c1, c2 ); - return (sal_Bool)aCErrorHdl.Call( &aErrorEntry ); - } - else - { - ADD_ERROR( code, rMsg ) - return sal_True; - } -} - -void TestToolObj::CalcPosition( String const &aSource, xub_StrLen nPos, xub_StrLen &l, xub_StrLen &c ) -{ - l = 1; - xub_StrLen nAkt = 0; - xub_StrLen nNext; - while ( (nNext = aSource.Search( '\n', nAkt )) != STRING_NOTFOUND && nNext < nPos ) - { - l++; - nAkt = nNext+1; - } - c = nPos - nAkt; -} - - -#define CATCH_LABEL CUniString( "ctch" ) -#define CATCHRES_LABEL CUniString( "ctchres" ) -#define ENDCATCH_LABEL CUniString( "endctch" ) - -sal_Bool IsAlphaChar( sal_Unicode cChar ) -{ - return ( cChar >= 'a' && cChar <= 'z' ) || - ( cChar >= 'A' && cChar <= 'Z' ); -} - -sal_Bool IsInsideString( const String& aSource, const xub_StrLen nStart ) -{ - sal_Bool bInside = sal_False; - xub_StrLen nPos = nStart-1; - - while ( nPos && aSource.GetChar(nPos) != _CR && aSource.GetChar(nPos) != _LF ) - { - if ( aSource.GetChar(nPos) == '"' ) - bInside = !bInside; - nPos--; - } - return bInside; -} - -sal_Bool IsValidHit( const String& aSource, const xub_StrLen nStart, const xub_StrLen nEnd ) -{ - return !IsAlphaChar( aSource.GetChar(nStart-1) ) && !IsAlphaChar( aSource.GetChar(nEnd+1)) - && !IsInsideString( aSource, nStart ); -} - - -xub_StrLen TestToolObj::ImplSearch( const String &aSource, const xub_StrLen nStart, const xub_StrLen nEnd, const String &aSearch, const xub_StrLen nSearchStart ) -{ - xub_StrLen nPos = aSource.Search( aSearch, std::max( nSearchStart, nStart ) ); - if ( nPos > nEnd - aSearch.Len() || nPos == STRING_NOTFOUND ) - return STRING_NOTFOUND; - else - { - if ( IsValidHit( aSource, nPos, nPos+aSearch.Len()-1 ) ) - return nPos; - else - return ImplSearch( aSource, nStart, nEnd, aSearch, nPos+aSearch.Len() ); - } -} - -xub_StrLen TestToolObj::PreCompilePart( String &aSource, xub_StrLen nStart, xub_StrLen nEnd, String aFinalErrorLabel, sal_uInt16 &nLabelCount ) -{ - xub_StrLen nTry,nCatch,nEndcatch; - if( (nTry = ImplSearch( aSource, nStart, nEnd, CUniString("try"), nStart )) == STRING_NOTFOUND ) - return nEnd; - if ( (nCatch = ImplSearch( aSource, nStart, nEnd, CUniString("catch"), nTry )) == STRING_NOTFOUND ) - { - xub_StrLen l,c; - CalcPosition( aSource, nTry, l, c ); - CError( SbERR_BAD_BLOCK, CUniString("catch"), l, c, c+2 ); - return nEnd; - } - if ( (nEndcatch = ImplSearch( aSource, nStart, nEnd, CUniString("endcatch"), nCatch )) == STRING_NOTFOUND ) - { - xub_StrLen l,c; - CalcPosition( aSource, nCatch, l, c ); - CError( SbERR_BAD_BLOCK, CUniString("endcatch"), l, c, c+4 ); - return nEnd; - } - - nLabelCount++; - String aStr = String::CreateFromInt32( nLabelCount ); - String aCatchLabel(CATCH_LABEL); - aCatchLabel += aStr; - String aCatchresLabel(CATCHRES_LABEL); - aCatchresLabel += aStr; - String aEndcatchLabel( ENDCATCH_LABEL); - aEndcatchLabel += aStr; - - xub_StrLen nTry2 = 0; - while ( !WasPrecompilerError() && (nTry2 = ImplSearch( aSource, nStart, nEnd, CUniString("try"), nTry+1 )) != STRING_NOTFOUND ) - { - 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 and endcatch are separated out - - aReplacement.AppendAscii( "on error goto " ); - aReplacement += aCatchLabel; - aSource.SearchAndReplaceAscii( "try", aReplacement, nTry ); - nTotalLength += aReplacement.Len(); - - aReplacement.Erase(); - aReplacement.AppendAscii( "on error goto " ); - aReplacement += aFinalErrorLabel; - aReplacement.AppendAscii( " : goto " ); - aReplacement += aEndcatchLabel; - aReplacement.AppendAscii( " : " ); - aReplacement += aCatchLabel; - aReplacement.AppendAscii( ": if err = 35 or err = 18 then : on error goto 0 : resume : endif" ); - aReplacement.AppendAscii( " : MaybeAddErr : on error goto " ); - aReplacement += aFinalErrorLabel; - aReplacement.AppendAscii( " : resume " ); - aReplacement += aCatchresLabel; - aReplacement.AppendAscii( " : " ); - aReplacement += aCatchresLabel; - aReplacement.AppendAscii( ": " ); - aSource.SearchAndReplaceAscii( "catch", aReplacement, nCatch ); - nTotalLength += aReplacement.Len(); - - - aReplacement.Erase(); - aReplacement.AppendAscii("ClearError : "); - aReplacement += aEndcatchLabel; - aReplacement.AppendAscii(": "); - aSource.SearchAndReplaceAscii( "endcatch", aReplacement, nEndcatch ); - nTotalLength += aReplacement.Len(); - - if ( aSource.Len() >= STRING_MAXLEN ) - { - xub_StrLen l,c; - CalcPosition( aSource, nEndcatch, l, c ); - CError( SbERR_PROG_TOO_LARGE, CUniString("endcatch"), l, c, c+2 ); - } - - return xub_StrLen( nEnd + nTotalLength ); -} - - -void TestToolObj::PreCompileDispatchParts( String &aSource, String aStart, String aEnd, String aFinalLable ) -{ - sal_uInt16 nLabelCount = 0; - xub_StrLen nPartPos = 0; - - while ( !WasPrecompilerError() && (nPartPos = ImplSearch( aSource, nPartPos, aSource.Len(), aStart )) != STRING_NOTFOUND ) - { - xub_StrLen nEndPart = ImplSearch( aSource, nPartPos, aSource.Len(), aEnd ); - if ( nEndPart == STRING_NOTFOUND ) - return; - nPartPos = PreCompilePart( aSource, nPartPos, nEndPart, aFinalLable, nLabelCount ); - nPartPos = nPartPos + aEnd.Len(); - } -} - - -sal_Bool TestToolObj::WasPrecompilerError() -{ - return bWasPrecompilerError; -} - -String TestToolObj::PreCompile( String const &aSourceIn ) -{ - - StartListening( ((StarBASIC*)GetParent())->GetBroadcaster(), sal_True ); - - xub_StrLen nTestCase; - xub_StrLen nEndCase; - xub_StrLen nStartPos = 0; - String aSource(aSourceIn); - bWasPrecompilerError = sal_False; - -HACK("Ich gestehe alles: Ich war zu faul das richtig zu machen.") - aSource = String(' ').Append( aSource ); - - - - xub_StrLen nComment; - while ( (nComment = aSource.SearchAscii("'",nStartPos)) != STRING_NOTFOUND ) - { - sal_uInt16 nStringEndCount = 0; - xub_StrLen nIndex = nComment; - while ( nIndex && aSource.GetChar(nIndex) != '\n' ) - { - if ( aSource.GetChar(nIndex) == '"' ) - nStringEndCount++; - nIndex--; - } - if ( (nStringEndCount & 1) == 0 ) - { - xub_StrLen nComEnd = aSource.SearchAscii("\n",nComment); - - while ( aSource.GetChar(nComEnd) == _CR || aSource.GetChar(nComEnd) == _LF ) - nComEnd--; - - nComEnd++; - - aSource.Erase(nComment,nComEnd-nComment); - } - else - nComment++; - nStartPos = nComment; - } - - - PreCompileDispatchParts( aSource, CUniString("sub"), CUniString("end sub"), CUniString("0") ); - PreCompileDispatchParts( aSource, CUniString("function"), CUniString("end function"), CUniString("0") ); - PreCompileDispatchParts( aSource, CUniString("testcase"), CUniString("endcase"), CUniString("endcse") ); - - - xub_StrLen nMainPos = ImplSearch( aSource, 0, aSource.Len(), CUniString("sub main") ); - aSource.SearchAndReplaceAscii("sub main",CUniString("Sub Main StartUse : LoadIncludeFiles : FinishUse "), nMainPos ); - if ( aSource.Len() >= STRING_MAXLEN ) - { - xub_StrLen l,c; - CalcPosition( aSource, nMainPos, l, c ); - CError( SbERR_PROG_TOO_LARGE, CUniString("endcatch"), l, c, c+2 ); - } - - while ( (nTestCase = ImplSearch( aSource, 0, aSource.Len(), CUniString("testcase") ) ) != STRING_NOTFOUND ) - { - xub_StrLen nTcEnd = aSource.SearchAscii("\n",nTestCase); - - while ( aSource.GetChar(nTcEnd) == _CR || aSource.GetChar(nTcEnd) == _LF ) - nTcEnd--; - - nTcEnd++; - - if ( aSource.SearchAscii(":",nTestCase) < nTcEnd ) - nTcEnd = aSource.SearchAscii(":",nTestCase) -1; - String aSuffix = aSource.Copy(nTestCase+8,nTcEnd-nTestCase-8); - sal_uInt16 nOldLen; - do - { - nOldLen = aSuffix.Len(); - aSuffix = comphelper::string::strip(aSuffix, ' '); - aSuffix = comphelper::string::strip(aSuffix, 0x09); - } while ( nOldLen != aSuffix.Len() ); - aSource.Erase(nTestCase,nTcEnd-nTestCase); - aSource.Insert(CUniString("Sub ").Append(aSuffix).AppendAscii(" CaseLog \"").Append(aSuffix).AppendAscii("\" : on error goto endcse : TestEnter "),nTestCase); - } - - ///////////////////////////////////////////////////////////////////////////////////////////////////////// - // Attention!!! The lable endsub is officially used to exit a sub instead of using 'exit sub' or 'return' - ///////////////////////////////////////////////////////////////////////////////////////////////////////// - while ( (nEndCase = ImplSearch( aSource, 0, aSource.Len(), CUniString("endcase") ) ) != STRING_NOTFOUND ) - aSource.SearchAndReplaceAscii("endcase",CUniString("goto endsub : endcse: if ( err = 35 and StopOnSyntaxError ) or err = 18 then : on error goto 0 : resume : endif : MaybeAddErr : ExceptLog : resume endcse_res : endcse_res: on error goto 0 : endsub: TestExit : ClearError : CaseLog \"\" : end sub "), nEndCase ); - - if ( aSource.Len() >= STRING_MAXLEN ) - { - xub_StrLen l,c; - CalcPosition( aSource, 0, l, c ); - CError( SbERR_PROG_TOO_LARGE, CUniString("endcatch"), l, c, c+2 ); - } - return aSource; -} - -void TestToolObj::AddToListByNr( CNames *&pControls, ControlItemUId *&pNewItem ) -{ - sal_uInt16 nNr; - if ( pControls->Seek_Entry( pNewItem, &nNr ) ) - { - AddName( pControls->GetObject(nNr)->pData->Kurzname, pNewItem->pData->Kurzname ); - delete pNewItem; - pNewItem = (ControlItemUId*)pControls->GetObject(nNr); - } - else - { - ControlItem* pNI = pNewItem; - pControls->C40_PTR_INSERT(ControlItem,pNI); - } -} - -IMPL_LINK( TestToolObj, ReturnResultsLink, CommunicationLink*, pCommLink ) -{ - return ReturnResults( pCommLink->GetServiceData() ); -} - -void TestToolObj::ReadHidLstByNumber() -{ - - if ( !m_pReverseUIds ) - { - String aName = (pImpl->aHIDDir + DirEntry(CUniString("hid.lst"))).GetFull(); - - { - TTExecutionStatusHint aHint( TT_EXECUTION_SHOW_ACTION, String(IttResId(S_READING_LONGNAMES)), aName ); - GetTTBroadcaster().Broadcast( aHint ); - } - - ReadFlat( aName, m_pReverseUIds, sal_False ); - - { - TTExecutionStatusHint aHint( TT_EXECUTION_HIDE_ACTION ); - GetTTBroadcaster().Broadcast( aHint ); - } - } -} - -void TestToolObj::SortControlsByNumber( sal_Bool bIncludeActive ) -{ - - if ( !m_pReverseControls && !m_pReverseControlsSon && m_pControls ) - { - m_pReverseControls = new CNames; - m_pReverseControlsSon = new CNames; - sal_uInt16 nWin,nCont; - const String aSl('/'); - for ( nWin = 0 ; nWin < m_pControls->Count() ; nWin++ ) - { - String aFatherName( m_pControls->GetObject(nWin)->pData->Kurzname ); - ControlItemUId *pNewFather = new ControlItemUIdSon(aFatherName,m_pControls->GetObject(nWin)->pData->aUId); - AddToListByNr( m_pReverseControlsSon, pNewFather ); - if (! ((ControlItemUIdSon*)pNewFather)->GetSons() ) - ((ControlItemUIdSon*)pNewFather)->Sons( new CNames ); - - - CNames *pControlList = ((ControlItemSon*)m_pControls->GetObject(nWin))->GetSons(); - if ( pControlList ) - for ( nCont = 0 ; nCont < pControlList->Count() ; nCont++ ) - { - ControlItemUId *pNewItem; - - String aCombinedName( aFatherName ); - aCombinedName.AppendAscii( ":" ); - aCombinedName.Append( pControlList->GetObject(nCont)->pData->Kurzname ); - pNewItem = new ControlItemUId( aCombinedName, pControlList->GetObject(nCont)->pData->aUId ); - AddToListByNr( m_pReverseControls, pNewItem ); - - pNewItem = new ControlItemUId( pControlList->GetObject(nCont)->pData->Kurzname, pControlList->GetObject(nCont)->pData->aUId ); - AddToListByNr( ((ControlItemUIdSon*)pNewFather)->GetSons(), pNewItem ); - } - } - if ( !bIncludeActive ) - { - // FIXME: HELPID - ControlItem *pZeroItem = new ControlItemUId( UniString(), rtl::OString() ); - sal_uInt16 nNr; - if ( m_pReverseControls->Seek_Entry( pZeroItem, &nNr ) ) - { - m_pReverseControls->DeleteAndDestroy( nNr ); -// to prevent VorlagenLaden/UntergeordneteIniDatei/SpeichernDlg/OrdnerDlg/OeffnenDlg/MessageBox/LetzteVersion/GrafikEinfuegenDlg/FarbeDlg/ExportierenDlg/DruckerEinrichten/DruckenDlg/DateiEinfuegenDlg/Active - } - delete pZeroItem; - } - } -} - - -sal_Bool TestToolObj::ReturnResults( SvStream *pIn ) -{ - - sal_uInt16 nId; - sal_Bool bSequenceOK = sal_True; - CNames *pReverseControlsKontext = NULL; - - CRetStream *pRetStream = new CRetStream(pIn); - - pRetStream->Read( nId ); - while( !pIn->IsEof() ) - { - switch( nId ) - { - case SIReturn: - { - sal_uInt16 nRet,nParams; - rtl::OString aUId; - pRetStream->Read(nRet); - if ( pRetStream->GetNextType() == BinString ) - { - String aUStrId; // UniqueStringID Used for Mozilla Integration - pRetStream->Read( aUStrId ); - // FIXME: HELPID - } - else - { - comm_UINT32 nUId; - pRetStream->Read( nUId ); - // FIXME: HELPID - } - pRetStream->Read(nParams); - - sal_uInt16 nNr1 = 0; - comm_UINT32 nLNr1 = 0; - String aString1; - sal_Bool bBool1 = sal_False; - SbxValueRef xValue1 = new SbxValue; - - if( nParams & PARAM_UINT16_1 ) - pRetStream->Read( nNr1 ); - if( nParams & PARAM_UINT32_1 ) - pRetStream->Read( nLNr1 ); - if( nParams & PARAM_STR_1 ) - { - pRetStream->Read( aString1 ); - ReplaceNumbers ( aString1 ); - } - else - aString1.Erase(); - if( nParams & PARAM_BOOL_1 ) - pRetStream->Read( bBool1 ); - if( nParams & PARAM_SBXVALUE_1 ) - pRetStream->Read( *xValue1 ); - switch (nRet) - { - case RET_Sequence: - { - // FIXME: HELPID - } - break; - case RET_Value: - if ( pImpl->pNextReturn ) - { - if ( aNextReturnId.equals( aUId ) ) - { - if( nParams & PARAM_UINT32_1 ) // FIXME this is to allow negative numbers, hoping that no large numbers are interpreted wrong. should have new PARAM_LONG_1 instead - { - if ( nLNr1 > 0x7fffffff ) - pImpl->pNextReturn->PutLong( long(nLNr1 - 0xffffffff) -1 ); - else - pImpl->pNextReturn->PutULong( nLNr1 ); - } - if( nParams & PARAM_UINT16_1 ) pImpl->pNextReturn->PutUShort( nNr1 ); - if( nParams & PARAM_STR_1 ) pImpl->pNextReturn->PutString( aString1 ); - if( nParams & PARAM_BOOL_1 ) pImpl->pNextReturn->PutBool( bBool1 ); - if( nParams & PARAM_SBXVALUE_1 ) // FIXME: allow generic datatype - { - SbxValues aValues( SbxDATE ); - xValue1->Get( aValues ); - pImpl->pNextReturn->Put( aValues ); - } - } - else - { - ADD_ERROR(SbxERR_BAD_ACTION, GEN_RES_STR0(S_RETURNED_VALUE_ID_MISSMATCH) ) - } - pImpl->pNextReturn = NULL; - } - else - { - ADD_ERROR(SbxERR_BAD_ACTION, GEN_RES_STR0(S_RETURNED_VALUE_NO_RECEIVER) ) - } - break; - case RET_WinInfo: - { - if ( !m_pReverseControls && !m_pReverseControlsSon ) - pReverseControlsKontext = NULL; - - ReadHidLstByNumber(); - SortControlsByNumber(); - - - if ( !m_pReverseSlots && m_pSIds ) - { - m_pReverseSlots = new CNames; - sal_uInt16 nWin; - const String aSl('/'); - for ( nWin = 0 ; nWin < m_pSIds->Count() ; nWin++ ) - { - ControlItemUId *pNewItem = new ControlItemUId(m_pSIds->GetObject(nWin)->pData->Kurzname,m_pSIds->GetObject(nWin)->pData->aUId); - AddToListByNr( m_pReverseSlots, pNewItem ); - } - } - - WinInfoRec *pWinInfo = new WinInfoRec; - // FIXME: HELPID - pWinInfo->nRType = (sal_uInt16)nLNr1; // just sal_uLong for Transport, data is always USHORT - pWinInfo->aRName = aString1; - pWinInfo->bIsReset = bBool1; - pWinInfo->aKurzname.Erase(); - pWinInfo->aSlotname.Erase(); - - // detect context maybe - happens only at the first entry after reset - if ( !pReverseControlsKontext && m_pReverseControlsSon ) - { - sal_uInt16 nNr; - ControlItem *pNewItem = new ControlItemUId( String(), aUId ); - if ( m_pReverseControlsSon->Seek_Entry(pNewItem,&nNr) ) - { - pReverseControlsKontext = ((ControlItemUIdSon*)m_pReverseControlsSon->GetObject(nNr))->GetSons(); - pWinInfo->aKurzname = CUniString("*"); - } - else - pReverseControlsKontext = m_pReverseControls; - - delete pNewItem; - } - - // Reset. Must be done after determining the context because the context is set the - // wrong way with the reset record otherwise. - if ( pWinInfo->bIsReset ) - pReverseControlsKontext = NULL; // order important! - - - // get short name - if ( pReverseControlsKontext ) - { - sal_uInt16 nNr; - ControlItem *pNewItem = new ControlItemUId( String(), aUId ); - if ( pReverseControlsKontext->Seek_Entry(pNewItem,&nNr) ) - { - pWinInfo->aKurzname += pReverseControlsKontext->GetObject(nNr)->pData->Kurzname; - } - delete pNewItem; - } - - - if ( m_pReverseSlots ) - { - sal_uInt16 nNr; - ControlItem *pNewItem = new ControlItemUId( String(), aUId ); - if ( m_pReverseSlots->Seek_Entry(pNewItem,&nNr) ) - pWinInfo->aSlotname = m_pReverseSlots->GetObject(nNr)->pData->Kurzname; - delete pNewItem; - } - - - // FIXME: HELPID - aWinInfoHdl.Call( pWinInfo ); - delete pWinInfo; - } - break; - case RET_ProfileInfo: - { - // FIXME: HELPID - } - break; - case RET_DirectLoging: - { - // FIXME: HELPID - } - break; - case RET_MacroRecorder: - { - SortControlsByNumber( sal_True ); - String aCommand,aControls,aControl,aULongNames,aULongName; - sal_Bool bWriteNewKontext = sal_False; - - aControls.Erase(); - - if ( m_pReverseControls ) - { - sal_uInt16 nNr; - ControlItem *pNewItem = new ControlItemUId( String(), aUId ); - if ( m_pReverseControls->Seek_Entry(pNewItem,&nNr) ) - aControls = m_pReverseControls->GetObject(nNr)->pData->Kurzname; - delete pNewItem; - } - if ( !aControls.Len() ) - { - aControls = String::CreateFromAscii("UnknownControl:UnknownControl"); - Sound::Beep( SOUND_WARNING ); - } - - aULongNames.Erase(); - if( (nParams & PARAM_UINT32_1) && (nNr1 & M_RET_NUM_CONTROL) ) - { - if ( m_pReverseControls ) - { - sal_uInt16 nNr; - // FIXME: HELPID - ControlItem *pNewItem = new ControlItemUId( String(), rtl::OString( /*nLNr1*/ ) ); - if ( m_pReverseControls->Seek_Entry(pNewItem,&nNr) ) - aULongNames = m_pReverseControls->GetObject(nNr)->pData->Kurzname; - delete pNewItem; - } - if ( !aULongNames.Len() ) - { - aULongNames = String::CreateFromAscii("Unknown:Unknown"); - Sound::Beep( SOUND_WARNING ); - } - - // now determine the best common kontext - sal_uInt16 i,j; - sal_Bool bFoundUlongName = sal_False, bFoundControl = sal_False; - // check for current kontext - for ( i = 0 ; !bFoundUlongName && i < aULongNames.GetTokenCount('/') ; i++ ) - bFoundUlongName = aLastRecordedKontext.Equals( aULongNames.GetToken(i,'/').GetToken( 0,':') ); - - for ( j = 0 ; !bFoundControl && j < aControls.GetTokenCount('/') ; j++ ) - bFoundControl = aLastRecordedKontext.Equals( aControls.GetToken(j,'/').GetToken( 0,':') ); - - if ( bFoundUlongName && bFoundControl ) - { - aULongName = aULongNames.GetToken(i-1,'/').GetToken( 1,':'); - aControl = aControls.GetToken(j-1,'/').GetToken( 1,':'); - } - else - { // see if we can find common kontext - sal_Bool bFound = sal_False; - - String aCurrentKontext; - for ( i = 0 ; !bFound && i < aULongNames.GetTokenCount('/') ; i++ ) - { - aCurrentKontext = aULongNames.GetToken(i,'/').GetToken( 0,':'); - - for ( j = 0 ; !bFound && j < aControls.GetTokenCount('/') ; j++ ) - { - if ( aCurrentKontext.Equals( aControls.GetToken(j,'/').GetToken( 0,':') ) ) - { - bFound = sal_True; - aULongName = aULongNames.GetToken(i,'/').GetToken( 1,':'); - aControl = aControls.GetToken(j,'/').GetToken( 1,':'); - aLastRecordedKontext = aCurrentKontext; - bWriteNewKontext = sal_True; - } - } - } - if ( !bFound ) - { - // check if both contain toplevel - bFoundUlongName = sal_False; - bFoundControl = sal_False; - for ( i = 0 ; !bFoundUlongName && i < aULongNames.GetTokenCount('/') ; i++ ) - bFoundUlongName = aULongNames.GetToken(i,'/').GetToken( 0,':').Equals( aULongNames.GetToken(i,'/').GetToken( 1,':') ); - - for ( j = 0 ; !bFoundControl && j < aControls.GetTokenCount('/') ; j++ ) - bFoundControl = aControls.GetToken(j,'/').GetToken( 0,':').Equals( aControls.GetToken(j,'/').GetToken( 1,':') ); - - if ( bFoundUlongName && bFoundControl ) - { - aULongName = aULongNames.GetToken(i-1,'/').GetToken( 1,':'); - aControl = aControls.GetToken(j-1,'/').GetToken( 1,':'); - if ( aLastRecordedKontext.Len() ) - { - aLastRecordedKontext.Erase(); - bWriteNewKontext = sal_True; - } - } - else - { - String aComment; - aComment = CUniString( "'could not Determin common kontext\n" ); - Sound::Beep( SOUND_WARNING ); - aWriteStringHdl.Call( &aComment ); - aULongName = aULongNames.GetToken(i,'/'); - aControl = aControls.GetToken(j,'/'); - } - } - } - - } - else - { // we only have a Control - sal_uInt16 i; - sal_Bool bFoundControl = sal_False; - // check for current kontext - for ( i = 0 ; !bFoundControl && i < aControls.GetTokenCount('/') ; i++ ) - bFoundControl = aLastRecordedKontext.Equals( aControls.GetToken(i,'/').GetToken( 0,':') ); - if ( bFoundControl ) - aControl = aControls.GetToken(i-1,'/').GetToken( 1,':'); - else - { - aLastRecordedKontext = aControls.GetToken(0,'/').GetToken( 0,':'); - bWriteNewKontext = sal_True; - aControl = aControls.GetToken(0,'/').GetToken( 1,':'); - } - - } - - - if ( bWriteNewKontext ) - { - String aKontextCommand = CUniString( "Kontext" ); - if ( aLastRecordedKontext.Len() ) - { - aKontextCommand.AppendAscii ( " \"" ); - aKontextCommand += aLastRecordedKontext; - aKontextCommand.AppendAscii ( "\"" ); - } - aKontextCommand.AppendAscii( "\n" ); - aWriteStringHdl.Call( &aKontextCommand ); - } - - aCommand = aControl; - - // Add Method name - String aMethod = GetMethodName( nNr1 & ~M_RET_NUM_CONTROL ); - aCommand += '.'; - aCommand += aMethod; - - sal_Bool bWasParam = sal_False; - - if( nParams & PARAM_STR_1 ) - { - bWasParam = sal_True; - aCommand.AppendAscii( " \"" ); - if ( nNr1 & M_KEY_STRING ) - { - sal_uInt16 nModify = 0; - sal_Bool bIsProsa = sal_False; - xub_StrLen i; - for ( i = 0; i < aString1.Len(); i++ ) - { - if ( ((sal_uInt16)aString1.GetChar(i)) == 1 ) // we have a special char - { - i++; - if ( !bIsProsa ) - { - aCommand.AppendAscii( "<" ); - bIsProsa = sal_True; - } - else - aCommand.AppendAscii( " " ); - - sal_uInt16 nKeyCode = (sal_uInt16)aString1.GetChar(i) & KEY_CODE; - sal_uInt16 nNewModify = (sal_uInt16)aString1.GetChar(i) & KEY_MODTYPE; - if ( nNewModify != nModify ) - { // generate modifiers - sal_uInt16 nChanged = ( nNewModify ^ nModify ); - if ( nChanged & KEY_SHIFT ) - { - aCommand += GetKeyName( KEY_SHIFT ); - aCommand.AppendAscii( " " ); - } - if ( nChanged & KEY_MOD1 ) - { - aCommand += GetKeyName( KEY_MOD1 ); - aCommand.AppendAscii( " " ); - } - if ( nChanged & KEY_MOD2 ) - { - aCommand += GetKeyName( KEY_MOD2 ); - aCommand.AppendAscii( " " ); - } - } - aCommand += GetKeyName( nKeyCode ); - nModify = nNewModify; - } - else - { - if ( bIsProsa ) - { - aCommand.AppendAscii( ">" ); - bIsProsa = sal_False; - } - aCommand += aString1.GetChar(i); - nModify = 0; - } - } - if ( bIsProsa ) - { - aCommand.AppendAscii( ">" ); - bIsProsa = sal_False; - } - } - else - { - aCommand += aString1; - } - aCommand.AppendAscii( "\"" ); - } - if( nParams & PARAM_UINT32_1 ) - { - if ( bWasParam ) - aCommand.AppendAscii( ", " ); - else - aCommand.AppendAscii( " " ); - bWasParam = sal_True; - if ( nNr1 & M_RET_NUM_CONTROL ) - { - aCommand.Append( aULongName ); - } - else - { - aCommand.Append( String::CreateFromInt64( nLNr1 ) ); - } - } - if( nParams & PARAM_BOOL_1 ) - { - if ( bWasParam ) - aCommand.AppendAscii( ", " ); - else - aCommand.AppendAscii( " " ); - bWasParam = sal_True; - if ( bBool1 ) - aCommand.AppendAscii( "true" ); - else - aCommand.AppendAscii( "false" ); - } - - aCommand.AppendAscii( "\n" ); - - aWriteStringHdl.Call( &aCommand ); - } - break; - default: - OSL_TRACE( "Unbekannter Return Code: %iu", nRet ); - break; - } - - break; - } - case SIReturnError: - { - String aString; - rtl::OString aUId; - if ( pRetStream->GetNextType() == BinString ) - { - String aUStrId; // UniqueStringID Used for Mozilla Integration - pRetStream->Read( aUStrId ); - // FIXME: HELPID - } - else - { - comm_UINT32 nUId; - pRetStream->Read( nUId ); - // FIXME: HELPID - } - pRetStream->Read( aString ); - ReplaceNumbers (aString); - - String aShortName; - aShortName = pShortNames->GetName(aUId); - aShortName.AppendAscii( " : " ); - - String aTmpStr(aShortName); - aTmpStr += aString; - ADD_ERROR(SbxERR_BAD_ACTION, aTmpStr/*, nNr*/); - break; - } - default: - OSL_TRACE( "Unbekannter Request im Return Stream Nr: %iu", nId ); - break; - } - if( !pIn->IsEof() ) - pRetStream->Read( nId ); - else - { - OSL_FAIL( "truncated input stream" ); - } - - } - - delete pRetStream; - if ( bSequenceOK ) - { - sal_uLong nClearSequence = 0; // before a lot of code was deleted, this was a funct. global var. - nSequence++; - pShortNames->Invalidate( nClearSequence - KEEP_SEQUENCES ); - } - - bReturnOK = sal_True; - - return sal_True; -} // RetService::Request() - -String TestToolObj::GetMethodName( sal_uLong nMethodId ) -{ - sal_uInt16 nElement; - if ( !Controls::pClasses ) - ReadFlatArray( Controls::arClasses, Controls::pClasses ); - if ( Controls::pClasses ) - { - // FIXME: HELPID - (void)nElement; - (void)nMethodId; - } - return String(); -} - -String TestToolObj::GetKeyName( sal_uInt16 nKeyCode ) -{ - sal_uInt16 nElement; - if ( !CmdStream::pKeyCodes ) - ReadFlatArray( CmdStream::arKeyCodes, CmdStream::pKeyCodes ); - if ( CmdStream::pKeyCodes ) - { - // FIXME: HELPID - (void)nElement; - (void)nKeyCode; - } - return CUniString( "UnknownKeyCode" ); -} - -void TestToolObj::ReplaceNumbers(String &aText) -{ -static ControlDefLoad const arRes_Type [] = -#include "res_type.hxx" - - static CNames *pRTypes = NULL; - xub_StrLen nStart = STRING_NOTFOUND; - xub_StrLen nGleich = STRING_NOTFOUND; - xub_StrLen nEnd = STRING_NOTFOUND; - xub_StrLen nStartPos = 0; - sal_uLong nNumber; - String aType; - String aResult; - sal_Bool bFound; - - while ( (nStart = aText.Search(StartKenn,nStartPos)) != STRING_NOTFOUND && - (nGleich = aText.SearchAscii("=",nStart+StartKenn.Len())) != STRING_NOTFOUND && - (nEnd = aText.Search(EndKenn,nGleich+1)) != STRING_NOTFOUND) - { - aType = aText.Copy(nStart,nGleich-nStart); - nNumber = (sal_uLong)aText.Copy(nGleich+1,nEnd-nGleich-1).ToInt64(); - bFound = sal_False; - if ( aType.CompareTo(UIdKenn) == COMPARE_EQUAL ) - { - // FIXME: HELPID - aResult = pShortNames->GetName(rtl::OString(/*nNumber*/)); - bFound = sal_True; - } - if ( aType.CompareTo(MethodKenn ) == COMPARE_EQUAL ) - { - bFound = sal_True; - aResult = GetMethodName( nNumber ); - } - if ( aType.CompareTo(RcKenn ) == COMPARE_EQUAL ) - { - bFound = sal_True; - if ( !pRCommands ) - ReadFlatArray( arR_Cmds, pRCommands ); - - sal_uInt16 nElement; - if ( pRCommands ) - { - // FIXME: HELPID - (void)nElement; - } - } - if ( aType.CompareTo(TypeKenn ) == COMPARE_EQUAL ) - { - bFound = sal_True; - if ( !pRTypes ) - ReadFlatArray( arRes_Type, pRTypes ); - - sal_uInt16 nElement; - if ( pRTypes ) - { - // FIXME: HELPID - (void)nElement; - } - } - if ( aType.CompareTo(SlotKenn ) == COMPARE_EQUAL ) - { - // FIXME: HELPID - aResult = pShortNames->GetName(rtl::OString(/*nNumber*/)); - bFound = sal_True; - } - if ( aType.CompareTo(TabKenn ) == COMPARE_EQUAL ) - { - if ( nNumber > nStart ) - aResult.Fill( (sal_uInt16)nNumber - nStart +1 ); - else - aResult = CUniString(" "); - bFound = sal_True; - } - - nStartPos = nStart; - if ( bFound ) - { - aText.Erase(nStart,nEnd+EndKenn.Len()-nStart); - aText.Insert(aResult,nStart); - nStartPos = nStartPos + aResult.Len(); - } - else - nStartPos = nStartPos + StartKenn.Len(); - } -} - - -SbTextType TestToolObj::GetSymbolType( const String &rSymbol, sal_Bool bWasControl ) -{ - if ( rSymbol.CompareToAscii( "try" ) == COMPARE_EQUAL - || rSymbol.CompareToAscii( "catch" ) == COMPARE_EQUAL - || rSymbol.CompareToAscii( "endcatch" ) == COMPARE_EQUAL - || rSymbol.CompareToAscii( "testcase" ) == COMPARE_EQUAL - || rSymbol.CompareToAscii( "endcase" ) == COMPARE_EQUAL ) - { - return TT_KEYWORD; - } - - - ControlDef WhatName( rSymbol, rtl::OString() ); - - if ( bWasControl ) - { - if ( !Controls::pClasses ) - ReadFlatArray( Controls::arClasses, Controls::pClasses ); - - if ( (Controls::pClasses && Controls::pClasses->Seek_Entry( &WhatName )) - || rSymbol.EqualsIgnoreCaseAscii( "ID" ) - || rSymbol.EqualsIgnoreCaseAscii( "Name" ) ) - return TT_METHOD; - else - return TT_NOMETHOD; - } - - - if ( m_pControls ) - { - sal_uInt16 nWin; - - for ( nWin = 0 ; nWin < m_pControls->Count() ; nWin++ ) - { - if ( ((ControlDef*)m_pControls->GetObject( nWin ))->SonSeek_Entry( &WhatName ) ) - return TT_CONTROL; - } - } - - - if ( m_pSIds && m_pSIds->Seek_Entry( &WhatName ) ) - return TT_SLOT; - - - if ( !pRCommands ) - ReadFlatArray( arR_Cmds, pRCommands ); - if ( pRCommands && pRCommands->Seek_Entry( &WhatName ) ) - return TT_REMOTECMD; - - - SbxVariable *pVar = SbxObject::Find( rSymbol, SbxCLASS_DONTCARE ); - if ( pVar && ( pVar->ISA(SbxMethod) || pVar->ISA(SbxProperty) ) ) - { - return TT_LOCALCMD; - } - - return SB_SYMBOL; -} - - -#undef P_FEHLERLISTE -#define P_FEHLERLISTE TestToolObj::pFehlerListe - -Controls::Controls( String aCName ) -: SbxObject( aCName) -{ - pMethodVar = new SbxTransportMethod( SbxVARIANT ); - pMethodVar->SetName( CUniString("Dummy") ); - Insert( pMethodVar ); -} - - -Controls::~Controls() -{} - - -void Controls::ChangeListener( SbxObject* parent ) -{ - EndListening( pMethodVar->GetBroadcaster(), sal_True ); - parent->StartListening( pMethodVar->GetBroadcaster(), sal_True ); -} - -void Controls::SFX_NOTIFY( SfxBroadcaster&, const TypeId&, - const SfxHint&, const TypeId& ) -{} - - - -SbxVariable* Controls::Find( const String& aStr, SbxClassType aType) -{ - if ( !pClasses ) - ReadFlatArray( arClasses, pClasses ); - - if ( GetUserData() == ID_ErrorDummy ) - { - pMethodVar->SetName(UniString(GetName()).AppendAscii(".").Append(aStr)); - pMethodVar->SetUserData( ID_ErrorDummy ); - return pMethodVar; - } - - - sal_uInt16 nElement; - ControlDef WhatName(aStr,rtl::OString()); - if (pClasses && pClasses->Seek_Entry(&WhatName,&nElement)) - { - pMethodVar->SetName(aStr); - // FIXME: HELPID - sal_uLong nUId = 0; - pMethodVar->nValue = nUId; - - pMethodVar->SetUserData( GetUserData() ); - return pMethodVar; - } - else - { // mainly for ID and name - SbxVariableRef Old = SbxObject::Find(aStr, aType ); - if (Old) - return Old; - else if ( aStr.EqualsIgnoreCaseAscii("ID") ) - return NULL; // suppress generation of error in this case - } - ADD_ERROR(SbxERR_BAD_METHOD,GEN_RES_STR2(S_UNKNOWN_METHOD, GetName(), aStr)); - return NULL; -} - - -String TTFormat::ms2s( sal_uLong nMilliSeconds ) -{ - if ( nMilliSeconds < 100000 ) - return String::CreateFromInt64( nMilliSeconds ); - if ( nMilliSeconds < 100000*60 ) - return String::CreateFromInt32( nMilliSeconds / 1000 ).AppendAscii("Sec"); - return String::CreateFromInt32( nMilliSeconds / 1000 / 60 ).AppendAscii("Min"); -} - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/automation/source/testtool/objtest.hxx b/automation/source/testtool/objtest.hxx deleted file mode 100644 index 3c7ab881b4ad..000000000000 --- a/automation/source/testtool/objtest.hxx +++ /dev/null @@ -1,394 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef _OBJTEST_HXX -#define _OBJTEST_HXX - -#include <tools/fsys.hxx> - - -#include <testapp.hxx> -#include <testtool.hxx> -#include "cmdstrm.hxx" -#include <basic/basicrt.hxx> -#include "httprequest.hxx" - -#include <map> - -// #define ID_BeginBlock 1 -// #define ID_EndBlock 2 -#define ID_Kontext 3 -#define ID_GetError 4 -#define ID_ErrorDummy 5 // internal for handling of missing controls and methods -#define ID_RecordError 6 -#define ID_Start 7 -//#define ID_Kill 8 -//#define ID_Reset 9 -// #define ID_AppAbort 10 -#define ID_Dispatch 11 -#define ID_UNODispatch 12 -#define ID_Control 13 -#define ID_StartUse 14 -#define ID_Use 15 -#define ID_FinishUse 16 -#define ID_CaseLog 17 -#define ID_ExceptLog 18 -#define ID_PrintLog 19 -#define ID_WarnLog 20 -#define ID_ErrorLog 21 -#define ID_EnableQaErrors 22 -#define ID_QAErrorLog 23 -#define ID_MaybeAddErr 24 -#define ID_ClearError 25 -#define ID_GetNextCloseWindow 26 -#define ID_RemoteCommand 27 -#define ID_SaveIDs 28 -#define ID_AutoExecute 29 -#define ID_Execute 30 -#define ID_DialogHandler 31 -#define ID_GetUnoApp 32 -#define ID_GetIServer 33 -#define ID_RemoteCommandDelay 34 -#define ID_GetApplicationPath 35 -#define ID_GetCommonApplicationPath 36 -#define ID_MakeIniFileName 37 -#define ID_StringControl 38 -#define ID_Wait 39 -#define ID_GetErrorCount 40 -#define ID_GetWarningCount 41 -#define ID_GetQAErrorCount 42 -#define ID_GetUseFileWarningCount 43 -#define ID_GetErrorList 44 -#define ID_GetWarningList 45 -#define ID_GetQAErrorList 46 -#define ID_GetUseFileWarningList 47 -#define ID_GetTestCaseName 48 -#define ID_GetTestCaseFileName 49 -#define ID_GetTestCaseLineNr 50 -#define ID_StopOnSyntaxError 51 -#define ID_SetChildEnv 52 -#define ID_GetChildEnv 53 -#define ID_GetLinkDestination 54 -#define ID_GetRegistryValue 55 -#define ID_KillApp 56 -#define ID_HTTPSend 57 -#define ID_HTTPSetProxy 58 -#define ID_DoNothing 99 - -void ReadFlatArray( const ControlDefLoad arWas [], CNames *&pNames ); - -class ControlData -{ -public: - String Kurzname; - rtl::OString aUId; -}; - -DBG_NAMEEX( ControlItem ) -DBG_NAMEEX( ControlDef ) -class ControlItem -{ -private: - void InitData() { pData = new ControlData; } -public: - ControlData *pData; - - ControlItem( const char *Name, rtl::OString aUIdP ); - ControlItem( const String &Name, rtl::OString aUIdP ); - virtual ~ControlItem() { -DBG_DTOR(ControlItem,0); - delete pData; - } - virtual sal_Bool operator < (const ControlItem &rPar)=0; - virtual sal_Bool operator == (const ControlItem &rPar)=0; -}; - -SV_DECL_PTRARR_SORT_DEL(CNames, ControlItem*, 50, 10) - -#define MK_SON_ACCESS( ClassName )\ - sal_Bool SonInsert( const ClassName *pNewEntry ) { const ControlItem *pItem = pNewEntry; return pSons->Insert( pItem ); }\ - sal_Bool SonSeek_Entry( const ClassName *pSearchEntry, sal_uInt16 *nRes = NULL) { return pSons->Seek_Entry( pSearchEntry, nRes ); }\ - ClassName* SonGetObject( sal_uInt16 nNr ) { return (ClassName*)pSons->GetObject( nNr ); } - -class ControlSon -{ -protected: - CNames *pSons; - -public: - ControlSon() : pSons( NULL ) {}; - ~ControlSon(); - - sal_uInt16 Son_Count() { return pSons->Count(); } - void Sons( CNames *pNewSons ) { pSons = pNewSons; } - CNames*& GetSons() { return pSons; } -}; - -class ControlItemSon : public ControlItem, public ControlSon -{ -public: - ControlItemSon(const char *Name, rtl::OString aUIdP ) - : ControlItem( Name, aUIdP ) {} - ControlItemSon(const String &Name, rtl::OString aUIdP ); -}; - -class ControlDef : public ControlItemSon -{ -public: - ControlDef(const char *Name, rtl::OString aUIdP ) - : ControlItemSon( Name, aUIdP ) {DBG_CTOR(ControlDef,0);} - ControlDef(const String &Name, rtl::OString aUIdP ); - ControlDef(const String &aOldName, const String &aNewName, ControlDef *pOriginal, sal_Bool bWithSons = sal_False ); - ~ControlDef() {DBG_DTOR(ControlDef,0);} - virtual sal_Bool operator < (const ControlItem &rPar); - virtual sal_Bool operator == (const ControlItem &rPar); - void Write( SvStream &aStream ); - MK_SON_ACCESS( ControlDef ) -}; - -class ControlItemUId : public ControlItem -{ -public: - ControlItemUId(String Name, rtl::OString aUIdP) - : ControlItem( Name, aUIdP){} - virtual sal_Bool operator < (const ControlItem &rPar); - virtual sal_Bool operator == (const ControlItem &rPar); -}; - -class ControlItemUIdSon : public ControlItemUId, public ControlSon -{ -public: - ControlItemUIdSon(String Name, rtl::OString aUIdP) : ControlItemUId( Name, aUIdP) {} - MK_SON_ACCESS( ControlItemUId ) -}; - -class ReverseName : public ControlItemUId -{ -public: - sal_uLong LastSequence; - - ReverseName(String Name, rtl::OString aUIdP, sal_uLong nSeq) : ControlItemUId( Name, aUIdP), LastSequence(nSeq) {} -}; - -class CRevNames: public CNames -{ -public: - void Insert( String aName, rtl::OString aUId, sal_uLong nSeq ); - String GetName( rtl::OString aUId ); - void Invalidate ( sal_uLong nSeq ); -}; - - -class SbxTransportMethod: public SbxMethod -{ -public: - SbxTransportMethod( SbxDataType ); - sal_uLong nValue; - String aUnoSlot; -}; -SV_DECL_IMPL_REF(SbxTransportMethod); - -class Controls: public SbxObject -{ -public: - Controls( String aCName ); - ~Controls(); - void ChangeListener( SbxObject* pParent ); - - void SFX_NOTIFY( SfxBroadcaster&, const TypeId&, const SfxHint& rHint, const TypeId& ); - virtual SbxVariable* Find( const String&, SbxClassType ); - SbxTransportMethodRef pMethodVar; // for transport from Find to Notify - static CNames *pClasses; - static ControlDefLoad const arClasses []; -}; -SV_DECL_IMPL_REF(Controls); - -typedef std::map< String, String > Environment; - -class ImplTestToolObj -{ -public: - String ProgParam; // parameters of the APP to be tested; set over Start - - DirEntry aFileBase; // base path for the *.sid and *.win files (from the configfile) - DirEntry aLogFileBase; // base path for the *.res files (from the configfile) - DirEntry aHIDDir; // directory in which the hid.lst is searched for - - SbxTransportMethodRef pNextReturn; - - ControlsRef pControlsObj; - - -#define VAR_POOL_SIZE 8 - SbxTransportMethodRef pMyVars[VAR_POOL_SIZE]; - - Time aServerTimeout; - - -// profiling data fields - sal_uLong LocalStarttime; - sal_uInt16 nNumBorders; - sal_uLong naValBorders[4]; - sal_uLong naNumEntries[5]; - sal_uLong naRemoteTime[5]; - sal_uLong naLocalTime[5]; - - sal_uLong nMinRemoteCommandDelay; - sal_uLong nMaxRemoteCommandDelay; - sal_Bool bDoRemoteCommandDelay; - - sal_Bool bLnaguageExtensionLoaded; // something loaded via 'use'? for syntax highlighting - SfxBroadcaster *pTTSfxBroadcaster; - - sal_uLong nErrorCount; - sal_uLong nWarningCount; - sal_uLong nQAErrorCount; - sal_uLong nIncludeFileWarningCount; - - SbxDimArrayRef xErrorList; - SbxDimArrayRef xWarningList; - SbxDimArrayRef xQAErrorList; - SbxDimArrayRef xIncludeFileWarningList; - - sal_Bool bIsStart; // set tu sal_True while command Start is initiating the communication - - MyBasic* pMyBasic; - - String aTestCaseName; // holds name of current TestCase - String aTestCaseFileName; // holds FileName of current TestCase - sal_uInt16 nTestCaseLineNr; // holds Line of current TestCase - - sal_Bool bEnableQaErrors; // include QA errors in report - sal_Bool bDebugFindNoErrors; // suppress generating errors when find of variables is called for variable viewing purposes - - sal_Bool bStopOnSyntaxError; // catch syntax errors in testcases or not - - Environment *pChildEnv; // Environment Variables for child Process - - HttpRequest *pHttpRequest; // used for sending HTTP requests - - ImplTestToolObj() : aServerTimeout( Time::EMPTY ) {} -}; - - -class TTFormat -{ -public: - static String ms2s( sal_uLong nMilliSeconds ); -}; - - -#define ADD_TO_LOG( aLogTypep, aMsgp, aFilenamep, nLinep, nCol1p, nCol2p, aRevisionp, pLogList )\ -{ \ - TTLogMsg *pLogMsg = new TTLogMsg(); \ - pLogMsg->aDebugData.aMsg = aMsgp; \ - pLogMsg->aLogFileName = (pImpl->aLogFileBase + DirEntry(aLogFileName)).GetFull(); \ - pLogMsg->aDebugData.aFilename = aFilenamep; \ - pLogMsg->aDebugData.nLine = nLinep; \ - pLogMsg->aDebugData.nCol1 = nCol1p; \ - pLogMsg->aDebugData.nCol2 = nCol2p; \ - pLogMsg->aDebugData.aLogType = aLogTypep; \ - aLogHdl.Call( pLogMsg ); \ - void* pDummyForWarningAboutNULL = pLogList; \ - if( pDummyForWarningAboutNULL ) \ - { \ - SbxDimArray* pLogArray = (SbxDimArray*)pLogList; \ - SbxVariable* pLogLine = new SbxVariable( SbxSTRING ); \ - String aCollect; \ - aCollect.Append( pLogMsg->aDebugData.aFilename ); \ - aCollect.AppendAscii( ";" ); \ - aCollect.Append( String::CreateFromInt32( nLinep ) ); \ - aCollect.AppendAscii( ";" ); \ - aCollect.Append( aRevisionp ); \ - aCollect.AppendAscii( ";" ); \ - aCollect.Append( pLogMsg->aDebugData.aMsg ); \ - pLogLine->PutString( aCollect ); \ - pLogArray->Insert( pLogLine, pLogArray->Count() ); \ - } \ - delete pLogMsg; \ -} \ - - -#define ADD_RUN_LOG() \ - ADD_TO_LOG(LOG_RUN, String(), String(), 0, 0, 0, String(), NULL) \ - -#define ADD_ERROR_LOG(aMsg, aFilename, nLine, nCol1, nCol2, aRevision) \ -{ \ - ADD_TO_LOG(LOG_ERROR, aMsg, aFilename, nLine, nCol1, nCol2, aRevision, &pImpl->xErrorList) \ - pImpl->nErrorCount++; \ -} - -#define ADD_CALL_STACK_LOG(aMsg, aFilename, nLine, nCol1, nCol2) \ - ADD_TO_LOG(LOG_CALL_STACK, aMsg, aFilename, nLine, nCol1, nCol2, String(), NULL) \ - - -#define ADD_AUTO_LOG(aLogType, aMsg, pLogList) \ -{ \ - if ( BasicRuntimeAccess::HasRuntime() ) \ - { \ - BasicRuntime aRun = BasicRuntimeAccess::GetRuntime(); \ - ADD_TO_LOG(aLogType, aMsg, aRun.GetModuleName(SbxNAME_SHORT_TYPES), \ - aRun.GetLine(), aRun.GetCol1(), aRun.GetCol2(), aRun.GetSourceRevision(), pLogList) \ - } \ - else \ - { \ - ADD_TO_LOG(aLogType, aMsg, UniString(), 0, 0, STRING_LEN, String(), pLogList) \ - } \ -} \ - -#define ADD_CASE_LOG(aMsg) \ - ADD_AUTO_LOG(LOG_TEST_CASE, aMsg, NULL) \ - -#define ADD_MESSAGE_LOG(aMsg) \ - ADD_AUTO_LOG(LOG_MESSAGE, aMsg, NULL) \ - -#define ADD_WARNING_LOG(aMsg) \ -{ \ - ADD_AUTO_LOG(LOG_WARNING, aMsg, &pImpl->xWarningList) \ - pImpl->nWarningCount++; \ -} - -#define ADD_WARNING_LOG2(aMsg, aFilename, nLine ) \ -{ \ - ADD_TO_LOG(LOG_WARNING, aMsg, aFilename, nLine, 0, STRING_LEN, String(), &pImpl->xWarningList) \ - pImpl->nWarningCount++; \ -} - -#define ADD_ASSERTION_LOG(aMsg) \ - ADD_AUTO_LOG(LOG_ASSERTION, aMsg, NULL) \ - -#define ADD_QA_ERROR_LOG(aMsg) \ - if ( pImpl->bEnableQaErrors ) \ - { \ - ADD_AUTO_LOG(LOG_QA_ERROR, aMsg, &pImpl->xQAErrorList) \ - pImpl->nQAErrorCount++; \ - } - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/automation/source/testtool/registry_win.cxx b/automation/source/testtool/registry_win.cxx deleted file mode 100644 index ea2b27ac8320..000000000000 --- a/automation/source/testtool/registry_win.cxx +++ /dev/null @@ -1,82 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - - -//////////////////////////////////////////////////////////////////////////// -//// -//// Windows ONLY -//// -//////////////////////////////////////////////////////////////////////////// - - -#include "registry_win.hxx" -#include <osl/thread.h> -#include <sal/macros.h> -#include <windows.h> - - -String ReadRegistry( String aKey, String aValueName ) -{ - String aRet; - HKEY hBaseKey; - if ( aKey.GetToken( 0, '\\' ).EqualsIgnoreCaseAscii( "HKEY_CURRENT_USER" ) ) - hBaseKey = HKEY_CURRENT_USER; - else if ( aKey.GetToken( 0, '\\' ).EqualsIgnoreCaseAscii( "HKEY_LOCAL_MACHINE" ) ) - hBaseKey = HKEY_LOCAL_MACHINE; - else - { - return aRet; - } - - aKey.Erase( 0, aKey.Search( '\\' )+1 ); - - HKEY hRegKey; - - if ( RegOpenKeyW( hBaseKey, - reinterpret_cast<LPCWSTR>(aKey.GetBuffer()), - &hRegKey ) == ERROR_SUCCESS ) - { - LONG lRet; - sal_Unicode PathW[_MAX_PATH ]; - DWORD lSize = SAL_N_ELEMENTS(PathW); - DWORD Type = REG_SZ; - - lRet = RegQueryValueExW(hRegKey, reinterpret_cast<LPCWSTR>(aValueName.GetBuffer()), NULL, &Type, (LPBYTE)PathW, &lSize); - - if ((lRet == ERROR_SUCCESS) && (Type == REG_SZ)) - { - aRet = String( PathW ); - } - - RegCloseKey(hRegKey); - } - return aRet; -} - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/automation/source/testtool/registry_win.hxx b/automation/source/testtool/registry_win.hxx deleted file mode 100644 index 4a9492d80d2b..000000000000 --- a/automation/source/testtool/registry_win.hxx +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - - -#include <tools/string.hxx> - -String ReadRegistry( String aKey, String aValueName ); - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/automation/source/testtool/sysdir_win.cxx b/automation/source/testtool/sysdir_win.cxx deleted file mode 100644 index b8ecb8752929..000000000000 --- a/automation/source/testtool/sysdir_win.cxx +++ /dev/null @@ -1,103 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - - -//////////////////////////////////////////////////////////////////////////// -//// -//// Windows ONLY -//// -//////////////////////////////////////////////////////////////////////////// - - -#ifndef _SHOBJ_H -#if defined _MSC_VER -#pragma warning(push, 1) -#pragma warning(disable: 4917) -#endif -#include <shlobj.h> -#if defined _MSC_VER -#pragma warning(pop) -#endif -#endif -// as we define it ourselves further down the line we remove it here -#ifdef IS_ERROR - #undef IS_ERROR -#endif - -#include <tchar.h> -#include "sysdir_win.hxx" - - -//////// copied this from setup2\win\source\system\winos.cxx - -void _SHFree( void *pv ) -{ - IMalloc *pMalloc; - if( NOERROR == SHGetMalloc(&pMalloc) ) - { - pMalloc->Free( pv ); - pMalloc->Release(); - } -} - -#define ALLOC(type, n) ((type *) HeapAlloc(GetProcessHeap(), 0, sizeof(type) * n )) -#define FREE(p) HeapFree(GetProcessHeap(), 0, p) - -UniString _SHGetSpecialFolder( int nFolderID ) -{ - - LPITEMIDLIST pidl; - HRESULT hHdl = SHGetSpecialFolderLocation( NULL, nFolderID, &pidl ); - UniString aFolder; - - if( hHdl == NOERROR ) - { - WCHAR *lpFolderW; - lpFolderW = ALLOC( WCHAR, 16000 ); - - SHGetPathFromIDListW( pidl, lpFolderW ); - aFolder = UniString( reinterpret_cast<const sal_Unicode*>(lpFolderW) ); - - FREE( lpFolderW ); - _SHFree( pidl ); - } - return aFolder; -} - - -/////////////// end of copy - - - -String _SHGetSpecialFolder_COMMON_APPDATA() -{ - return _SHGetSpecialFolder( CSIDL_COMMON_APPDATA ); -} - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/automation/source/testtool/sysdir_win.hxx b/automation/source/testtool/sysdir_win.hxx deleted file mode 100644 index c27e3e434e75..000000000000 --- a/automation/source/testtool/sysdir_win.hxx +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - - -#include <tools/string.hxx> - -String _SHGetSpecialFolder_COMMON_APPDATA(); - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/automation/source/testtool/tcommuni.cxx b/automation/source/testtool/tcommuni.cxx deleted file mode 100644 index 44dc5f2fec18..000000000000 --- a/automation/source/testtool/tcommuni.cxx +++ /dev/null @@ -1,201 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - - - -#include <tools/config.hxx> -#include <vcl/svapp.hxx> -#include <tools/time.hxx> -#include <tools/debug.hxx> -#include <vcl/timer.hxx> - -#include <basic/ttstrhlp.hxx> - -#include "rcontrol.hxx" -#include "tcommuni.hxx" -#include <basic/testtool.hxx> - -CommunicationManagerClientViaSocketTT::CommunicationManagerClientViaSocketTT() -: CommunicationManagerClientViaSocket( sal_True ) -, aFirstRetryCall( Time::EMPTY ) -, aAppPath() -, aAppParams() -, pProcess( NULL ) -{ -} - - -sal_Bool CommunicationManagerClientViaSocketTT::StartCommunication() -{ - bApplicationStarted = sal_False; - return CommunicationManagerClientViaSocket::StartCommunication( rtl::OUStringToOString( GetHostConfig(), RTL_TEXTENCODING_UTF8 ), GetTTPortConfig() ); -} - - -sal_Bool CommunicationManagerClientViaSocketTT::StartCommunication( String aApp, String aParams, Environment *pChildEnv ) -{ - aAppPath = aApp; - aAppParams = aParams; - aAppEnv = (*pChildEnv); - return StartCommunication(); -} - - -sal_Bool CommunicationManagerClientViaSocketTT::RetryConnect() -{ - if ( !bApplicationStarted ) - { - - if ( aAppPath.Len() ) - { - delete pProcess; - - pProcess = new Process(); - pProcess->SetImage( aAppPath, aAppParams, &aAppEnv ); - - sal_Bool bSucc = pProcess->Start(); - bApplicationStarted = sal_True; - - if ( bSucc ) - { - aFirstRetryCall = Time( Time::SYSTEM ) + Time( 0, 1 ); - for ( int i = 10 ; i-- ; ) - GetpApp()->Reschedule(); - } - return bSucc; - } - return sal_False; - } - else - { - if ( aFirstRetryCall > Time( Time::SYSTEM ) ) - { - Timer aWait; - aWait.SetTimeout( 500 ); - aWait.Start(); - while ( aWait.IsActive() ) - GetpApp()->Yield(); - return sal_True; - } - else - return sal_False; - } -} - -sal_Bool CommunicationManagerClientViaSocketTT::KillApplication() -{ - if ( pProcess ) - return pProcess->Terminate(); - return sal_True; -} - -#define GETSET(aVar, KeyName, Dafault) \ - aVar = aConf.ReadKey(KeyName,"No Entry"); \ - if (aVar.equalsL(RTL_CONSTASCII_STRINGPARAM("No Entry"))) \ - { \ - aVar = Dafault; \ - aConf.WriteKey(KeyName, aVar); \ - } - -String GetHostConfig() -{ - String aHostToTalk; - - for ( sal_uInt16 i = 0 ; i < Application::GetCommandLineParamCount() ; i++ ) - { - if ( Application::GetCommandLineParam( i ).Copy(0,6).CompareIgnoreCaseToAscii("-host=") == COMPARE_EQUAL -#ifndef UNX - || Application::GetCommandLineParam( i ).Copy(0,6).CompareIgnoreCaseToAscii("/host=") == COMPARE_EQUAL -#endif - ) - return Application::GetCommandLineParam( i ).Copy(6); - } - - rtl::OString abHostToTalk; - Config aConf(Config::GetConfigName( Config::GetDefDirectory(), CUniString("testtool") )); - aConf.SetGroup("Communication"); - - GETSET( abHostToTalk, "Host", DEFAULT_HOST ); - return rtl::OStringToOUString(abHostToTalk, RTL_TEXTENCODING_UTF8); -} - - -sal_uLong GetTTPortConfig() -{ - String aPortToTalk; - - for ( sal_uInt16 i = 0 ; i < Application::GetCommandLineParamCount() ; i++ ) - { - if ( Application::GetCommandLineParam( i ).Copy(0,6).CompareIgnoreCaseToAscii("-port=") == COMPARE_EQUAL -#ifndef UNX - || Application::GetCommandLineParam( i ).Copy(0,6).CompareIgnoreCaseToAscii("/port=") == COMPARE_EQUAL -#endif - ) - { - aPortToTalk = Application::GetCommandLineParam( i ).Copy(6); - return (sal_uLong)aPortToTalk.ToInt64(); - } - } - - rtl::OString abPortToTalk; - Config aConf(Config::GetConfigName( Config::GetDefDirectory(), CUniString("testtool") )); - aConf.SetGroup("Communication"); - - GETSET( abPortToTalk, "TTPort", - rtl::OString::valueOf(static_cast<sal_Int32>(TESTTOOL_DEFAULT_PORT)) ); - return (sal_uLong)abPortToTalk.toInt32(); -} - - -sal_uLong GetUnoPortConfig() -{ - String aPortToTalk; - - for ( sal_uInt16 i = 0 ; i < Application::GetCommandLineParamCount() ; i++ ) - { - if ( Application::GetCommandLineParam( i ).Copy(0,9).CompareIgnoreCaseToAscii("-unoport=") == COMPARE_EQUAL -#ifndef UNX - || Application::GetCommandLineParam( i ).Copy(0,9).CompareIgnoreCaseToAscii("/unoport=") == COMPARE_EQUAL -#endif - ) - { - aPortToTalk = Application::GetCommandLineParam( i ).Copy(6); - return (sal_uLong)aPortToTalk.ToInt64(); - } - } - - rtl::OString abPortToTalk; - Config aConf(Config::GetConfigName( Config::GetDefDirectory(), CUniString("testtool") )); - aConf.SetGroup("Communication"); - - GETSET( abPortToTalk, "UnoPort", - rtl::OString::valueOf(static_cast<sal_Int32>(UNO_DEFAULT_PORT)) ); - return (sal_uLong)abPortToTalk.toInt32(); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/automation/source/testtool/tcommuni.hxx b/automation/source/testtool/tcommuni.hxx deleted file mode 100644 index 6d3f9af6ed5f..000000000000 --- a/automation/source/testtool/tcommuni.hxx +++ /dev/null @@ -1,64 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include <automation/communi.hxx> -#include <tools/link.hxx> -#include <svl/svarray.hxx> - -#include <osl/thread.hxx> -#include <basic/process.hxx> - -class Process; - -class CommunicationManagerClientViaSocketTT : public CommunicationManagerClientViaSocket -{ -public: - CommunicationManagerClientViaSocketTT(); - - using CommunicationManagerClientViaSocket::StartCommunication; - virtual sal_Bool StartCommunication(); - virtual sal_Bool StartCommunication( String aApp, String aParams, Environment *pChildEnv ); - - sal_Bool KillApplication(); - -protected: - virtual sal_Bool RetryConnect(); - sal_Bool bApplicationStarted; - Time aFirstRetryCall; - String aAppPath; - String aAppParams; - Environment aAppEnv; - Process *pProcess; -}; - - -String GetHostConfig(); -sal_uLong GetTTPortConfig(); -sal_uLong GetUnoPortConfig(); - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/automation/source/testtool/testtool.ini b/automation/source/testtool/testtool.ini deleted file mode 100644 index 86db21b09b52..000000000000 --- a/automation/source/testtool/testtool.ini +++ /dev/null @@ -1,16 +0,0 @@ -[Bootstrap] -URE_BOOTSTRAP=${ORIGIN}/fundamental!INIFILESUFFIX! -UserInstallation=${SYSUSERCONFIG}/.oootesttool - -[Misc] -CurrentProfile=_profile_Default - -[OOoProgramDir] -Type=Path - -[Crashreporter] -UseProxy=false -ProxyServer=none -ProxyPort=8080 -AllowContact=false -ReturnAddress= |