Files
libreoffice/automation/source/testtool/objtest.cxx

3770 lines
142 KiB
C++
Raw Normal View History

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2002-11-18 14:54:26 +00:00
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
2002-11-18 14:54:26 +00:00
*
* OpenOffice.org - a multi-platform office productivity suite
2002-11-18 14:54:26 +00:00
*
* This file is part of OpenOffice.org.
2002-11-18 14:54:26 +00:00
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
2002-11-18 14:54:26 +00:00
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
2002-11-18 14:54:26 +00:00
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
2002-11-18 14:54:26 +00:00
*
************************************************************************/
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_automation.hxx"
#include "sysdir_win.hxx"
#include "registry_win.hxx"
#include "ittresid.hxx"
2002-11-18 14:54:26 +00:00
#include <osl/file.hxx>
#include <vcl/msgbox.hxx>
#include <vcl/sound.hxx>
#include <tools/config.hxx>
2002-11-18 14:54:26 +00:00
#include <vcl/svapp.hxx>
#include <svtools/stringtransfer.hxx>
#include <svl/brdcst.hxx>
#include <basic/sbx.hxx>
2002-11-18 14:54:26 +00:00
#include <com/sun/star/uno/Any.hxx>
#include <com/sun/star/frame/XDesktop.hpp>
#include <comphelper/processfactory.hxx>
#include <com/sun/star/bridge/XBridgeFactory.hpp>
#include <com/sun/star/connection/XConnector.hpp>
#include <com/sun/star/connection/XConnection.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/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;
2011-02-26 01:14:41 +01:00
using ::rtl::OUString;
2002-11-18 14:54:26 +00:00
#include <svtools/svmedit.hxx>
#ifdef UNX
#include <unistd.h> // readlink
#include <errno.h>
#endif
2002-11-18 14:54:26 +00:00
#include <basic/sbuno.hxx>
#include <basic/basicrt.hxx>
#include <basic/ttstrhlp.hxx>
#include "tcommuni.hxx"
#include "comm_bas.hxx"
2002-11-18 14:54:26 +00:00
#include <cretstrm.hxx>
#include "objtest.hxx"
#include "rcontrol.hxx"
#include <basic/testtool.hrc>
#include <basic/ttmsg.hrc>
#include <basic/mybasic.hxx>
#include <basic/testtool.hxx>
#include <basic/sbstar.hxx>
#include <algorithm>
#ifndef SBX_VALUE_DECL_DEFINED
#define SBX_VALUE_DECL_DEFINED
SV_DECL_REF(SbxValue)
#endif
SV_IMPL_REF(SbxValue)
static CommunicationFactory aComManFac;
2002-11-18 14:54:26 +00:00
#define cMyDelim ' '
#define P_FEHLERLISTE pFehlerListe
#define KEEP_SEQUENCES 100 // Keep Names of last 100 Calls
2002-11-18 14:54:26 +00:00
ControlDefLoad const Controls::arClasses [] =
2002-11-18 14:54:26 +00:00
#include "classes.hxx"
CNames *Controls::pClasses = NULL;
ControlDefLoad const TestToolObj::arR_Cmds [] =
2002-11-18 14:54:26 +00:00
#include "r_cmds.hxx"
CNames *TestToolObj::pRCommands = NULL;
CErrors *TestToolObj::pFehlerListe = NULL; // the errors from the testtool are stored here
2002-11-18 14:54:26 +00:00
DBG_NAME( ControlItem )
DBG_NAME( ControlDef )
ControlItem::ControlItem( const sal_Char *Name, rtl::OString aUIdP )
2002-11-18 14:54:26 +00:00
{
DBG_CTOR(ControlItem,0);
InitData();
pData->Kurzname.AssignAscii( Name );
pData->aUId = aUIdP;
}
ControlItem::ControlItem( const String &Name, rtl::OString aUIdP )
2002-11-18 14:54:26 +00:00
{
DBG_CTOR(ControlItem,0);
InitData();
pData->Kurzname = Name;
pData->aUId = aUIdP;
}
ControlItem::ControlItem( ControlData *pDataP )
{
DBG_CTOR(ControlItem,0);
pData = pDataP;
}
ControlSon::~ControlSon()
{
if (pSons)
{
delete pSons;
pSons = NULL;
}
}
ControlItemSon::ControlItemSon(const String &Name, rtl::OString aUIdP )
2002-11-18 14:54:26 +00:00
: ControlItem( Name, aUIdP )
{}
sal_Bool ControlDef::operator < (const ControlItem &rPar)
2002-11-18 14:54:26 +00:00
{
return pData->Kurzname.CompareIgnoreCaseToAscii(rPar.pData->Kurzname) == COMPARE_LESS;
}
sal_Bool ControlDef::operator == (const ControlItem &rPar)
2002-11-18 14:54:26 +00:00
{
return pData->Kurzname.CompareIgnoreCaseToAscii(rPar.pData->Kurzname) == COMPARE_EQUAL;
}
void ControlDef::Write( SvStream &aStream )
{
// FIXME: HELPID
2010-06-04 19:27:35 +02:00
(void)aStream;
2002-11-18 14:54:26 +00:00
}
ControlDef::ControlDef(const String &Name, rtl::OString aUIdP )
2002-11-18 14:54:26 +00:00
: ControlItemSon( Name, aUIdP)
{
DBG_CTOR(ControlDef,0);
}
ControlDef::ControlDef(const String &aOldName, const String &aNewName, ControlDef *pOriginal, sal_Bool bWithSons )
2002-11-18 14:54:26 +00:00
: 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++)
2002-11-18 14:54:26 +00:00
{
ControlDef *pNewDef;
pNewDef = new ControlDef( aOldName, aNewName, pOriginal->SonGetObject(i) ,sal_True );
2002-11-18 14:54:26 +00:00
if (! SonInsert(pNewDef))
{
2011-03-01 17:55:09 +01:00
OSL_FAIL("Name Doppelt im CopyConstructor. Neuer Name = Controlname!!");
2002-11-18 14:54:26 +00:00
delete pNewDef;
}
}
}
else
pSons = NULL;
}
sal_Bool ControlItemUId::operator < (const ControlItem &rPar)
2002-11-18 14:54:26 +00:00
{
return pData->aUId < rPar.pData->aUId;
}
sal_Bool ControlItemUId::operator == (const ControlItem &rPar)
2002-11-18 14:54:26 +00:00
{
return pData->aUId == rPar.pData->aUId;
}
SV_IMPL_OP_PTRARR_SORT( CNames, ControlItem* )
void CRevNames::Insert( String aName, rtl::OString aUId, sal_uLong nSeq )
2002-11-18 14:54:26 +00:00
{
ControlItem *pRN = new ReverseName(aName,aUId,nSeq);
sal_uInt16 nPos;
2002-11-18 14:54:26 +00:00
if ( Seek_Entry(pRN,&nPos) )
DeleteAndDestroy(nPos);
if ( !CNames::C40_PTR_INSERT( ControlItem, pRN) )
{
2011-03-01 17:55:09 +01:00
OSL_FAIL("Interner Fehler beim Speichern der Lokalen KurzNamen");
2002-11-18 14:54:26 +00:00
delete pRN;
}
}
String CRevNames::GetName( rtl::OString aUId )
2002-11-18 14:54:26 +00:00
{
ReverseName *pRN = new ReverseName(UniString(),aUId,0);
sal_uInt16 nPos;
sal_Bool bSeekOK = Seek_Entry(pRN,&nPos);
2002-11-18 14:54:26 +00:00
delete pRN;
if ( bSeekOK )
return GetObject(nPos)->pData->Kurzname;
else
{
// FIXME: HELPID
return String();
2002-11-18 14:54:26 +00:00
}
}
void CRevNames::Invalidate ( sal_uLong nSeq )
2002-11-18 14:54:26 +00:00
{
sal_uInt16 i;
2002-11-18 14:54:26 +00:00
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
2002-11-18 14:54:26 +00:00
: SbxObject( aName )
, bUseIPC(sal_True)
, bReturnOK(sal_True)
2002-11-18 14:54:26 +00:00
, 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)
2002-11-18 14:54:26 +00:00
, aDialogHandlerName()
, nWindowHandlerCallLevel(0)
, nIdleCount(0)
2002-11-18 14:54:26 +00:00
{
pImpl = new ImplTestToolObj;
pImpl->ProgParam = String();
pImpl->bIsStart = sal_False;
2002-11-18 14:54:26 +00:00
pImpl->pMyBasic = pBas;
LoadIniFile();
InitTestToolObj();
pCommunicationManager = new CommunicationManagerClientViaSocketTT();
pCommunicationManager->SetDataReceivedHdl( LINK( this, TestToolObj, ReturnResultsLink ));
}
void TestToolObj::LoadIniFile()
2002-11-18 14:54:26 +00:00
{
#define GETSET(aVar, KeyName, Dafault) \
{ \
ByteString __##aVar##__; \
__##aVar##__ = aConf.ReadKey(KeyName); \
if ( !__##aVar##__.Len() ) \
{ \
__##aVar##__ = Dafault; \
aConf.WriteKey(KeyName, __##aVar##__); \
} \
2002-11-18 14:54:26 +00:00
aVar = UniString( __##aVar##__, RTL_TEXTENCODING_UTF8 );\
}
2011-08-18 22:30:22 +01:00
#define NEWOLD( NewKey, OldKey ) \
{ \
rtl::OString aValue; \
if ( ( (aValue = aConf.ReadKey( OldKey )).getLength() ) && !aConf.ReadKey( NewKey ).getLength() ) \
aConf.WriteKey( NewKey, aValue ); \
}
2002-11-18 14:54:26 +00:00
Config aConf(Config::GetConfigName( Config::GetDefDirectory(), CUniString("testtool") ));
aConf.SetGroup("Misc");
ByteString aCurrentProfile = aConf.ReadKey( "CurrentProfile", "Path" );
aConf.SetGroup( aCurrentProfile );
2002-11-18 14:54:26 +00:00
NEWOLD( "BaseDir", "Basisverzeichnis" )
2002-11-18 14:54:26 +00:00
String aFB;
GETSET( aFB, "BaseDir", "" );
2002-11-18 14:54:26 +00:00
pImpl->aFileBase = DirEntry(aFB);
// remove old keys
2011-08-18 22:30:22 +01:00
if ( aConf.ReadKey("KeyCodes + Classes").getLength() != 0 ||
aConf.ReadKey("KeyCodes + Classes + Res_Type").getLength() != 0 )
2002-11-18 14:54:26 +00:00
{
aConf.DeleteKey("KeyCodes + Classes + Res_Type");
aConf.DeleteKey("KeyCodes + Classes");
}
NEWOLD( "LogBaseDir", "LogBasisverzeichnis" )
2002-11-18 14:54:26 +00:00
String aLFB;
GETSET( aLFB, "LogBaseDir", ByteString( aFB, RTL_TEXTENCODING_UTF8 ) );
2002-11-18 14:54:26 +00:00
pImpl->aLogFileBase = DirEntry(aLFB);
NEWOLD( "HIDDir", "HIDVerzeichnis" )
2002-11-18 14:54:26 +00:00
String aHID;
GETSET( aHID, "HIDDir", "" );
2002-11-18 14:54:26 +00:00
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()));
2002-11-18 14:54:26 +00:00
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();
2011-07-07 11:28:13 +02:00
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);
2011-08-12 10:17:16 +01:00
ByteString bsPath( rtl::OUStringToOString(sPath,
RTL_TEXTENCODING_UTF8) );
2011-07-07 11:28:13 +02:00
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" ) );
}
}
2002-11-18 14:54:26 +00:00
}
#define MAKE_TT_KEYWORD( cName, aType, aResultType, nID ) \
{ \
SbxVariableRef pMeth; \
pMeth = Make( CUniString(cName), aType, aResultType ); \
pMeth->SetUserData( nID ); \
}
2002-11-18 14:54:26 +00:00
// 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 ); \
2002-11-18 14:54:26 +00:00
}
#define RTLNAME "@SBRTL" // copied from basic/source/classes/sb.cxx
void TestToolObj::InitTestToolObj()
{
pImpl->nNumBorders = 0; // for profiling with boxes
2002-11-18 14:54:26 +00:00
pImpl->nMinRemoteCommandDelay = 0;
pImpl->nMaxRemoteCommandDelay = 0;
pImpl->bDoRemoteCommandDelay = sal_False;
2002-11-18 14:54:26 +00:00
pImpl->bLnaguageExtensionLoaded= sal_False;
2002-11-18 14:54:26 +00:00
pImpl->pTTSfxBroadcaster = NULL;
pImpl->nErrorCount = 0;
pImpl->nWarningCount = 0;
pImpl->nQAErrorCount = 0;
2002-11-18 14:54:26 +00:00
pImpl->nIncludeFileWarningCount = 0;
pImpl->xErrorList = new SbxDimArray( SbxSTRING );
pImpl->xWarningList = new SbxDimArray( SbxSTRING );
pImpl->xQAErrorList = new SbxDimArray( SbxSTRING );
pImpl->xIncludeFileWarningList = new SbxDimArray( SbxSTRING );
2002-11-18 14:54:26 +00:00
pImpl->nTestCaseLineNr = 0;
pImpl->bEnableQaErrors = sal_True;
pImpl->bDebugFindNoErrors = sal_False;
pImpl->pChildEnv = new Environment;
if (!pFehlerListe)
pFehlerListe = new CErrors;
2002-11-18 14:54:26 +00:00
In = new CmdStream();
pShortNames = new CRevNames;
pImpl->pHttpRequest = NULL;
2002-11-18 14:54:26 +00:00
// overwrite standard "wait" method, cause we can do better than that!!
// Insert Object into SbiStdObject but change listening.
SbxVariable* pRTL = pImpl->pMyBasic->Find( CUniString(RTLNAME), SbxCLASS_DONTCARE );
SbxObject* pRTLObject = PTR_CAST( SbxObject, pRTL );
if ( pRTLObject )
{
SbxVariableRef pWait;
pWait = pRTLObject->Make( CUniString("Wait"), SbxCLASS_METHOD, SbxNULL );
pWait->SetUserData( ID_Wait );
// change listener here
pRTLObject->EndListening( pWait->GetBroadcaster(), sal_True );
StartListening( pWait->GetBroadcaster(), sal_True );
2002-11-18 14:54:26 +00:00
}
else
{
2011-03-01 17:55:09 +01:00
OSL_FAIL("Testtool: Could not replace Wait method");
2002-11-18 14:54:26 +00:00
}
MAKE_TT_KEYWORD( "Kontext", SbxCLASS_METHOD, SbxNULL, ID_Kontext );
MAKE_TT_KEYWORD( "GetNextError", SbxCLASS_VARIABLE, SbxVARIANT, ID_GetError );
MAKE_TT_KEYWORD( "Start", SbxCLASS_METHOD, SbxSTRING, ID_Start );
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 );
2002-11-18 14:54:26 +00:00
MAKE_TT_KEYWORD( "MaybeAddErr", SbxCLASS_METHOD, SbxNULL, ID_MaybeAddErr );
MAKE_TT_KEYWORD( "ClearError", SbxCLASS_METHOD, SbxNULL, ID_ClearError );
MAKE_TT_KEYWORD( "SaveIDs", SbxCLASS_METHOD, SbxBOOL, ID_SaveIDs );
MAKE_TT_KEYWORD( "AutoExecute", SbxCLASS_PROPERTY, SbxBOOL, ID_AutoExecute ); // Attention! PROPERTY therefore a variable
2002-11-18 14:54:26 +00:00
MAKE_TT_KEYWORD( "Execute", SbxCLASS_METHOD, SbxNULL, ID_Execute );
MAKE_TT_KEYWORD( "StopOnSyntaxError", SbxCLASS_PROPERTY, SbxBOOL, ID_StopOnSyntaxError );
2002-11-18 14:54:26 +00:00
/* 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).
2002-11-18 14:54:26 +00:00
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.
2002-11-18 14:54:26 +00:00
*/
MAKE_TT_KEYWORD( "DialogHandler", SbxCLASS_METHOD, SbxNULL, ID_DialogHandler );
MAKE_TT_KEYWORD( "GetUnoApp", SbxCLASS_METHOD, SbxOBJECT, ID_GetUnoApp );
MAKE_TT_KEYWORD( "GetIServer", SbxCLASS_METHOD, SbxOBJECT, ID_GetIServer );
MAKE_TT_KEYWORD( "RemoteCommandDelay", SbxCLASS_METHOD, SbxNULL, ID_RemoteCommandDelay );
MAKE_TT_KEYWORD( "GetApplicationPath", SbxCLASS_METHOD, SbxSTRING, ID_GetApplicationPath );
MAKE_TT_KEYWORD( "GetCommonApplicationPath", SbxCLASS_METHOD, SbxSTRING, ID_GetCommonApplicationPath );
2002-11-18 14:54:26 +00:00
MAKE_TT_KEYWORD( "MakeIniFileName", SbxCLASS_METHOD, SbxSTRING, ID_MakeIniFileName );
/// active constants returning error and warning count
MAKE_TT_KEYWORD( "GetErrorCount", SbxCLASS_METHOD, SbxULONG, ID_GetErrorCount );
MAKE_TT_KEYWORD( "GetWarningCount", SbxCLASS_METHOD, SbxULONG, ID_GetWarningCount );
MAKE_TT_KEYWORD( "GetQAErrorCount", SbxCLASS_METHOD, SbxULONG, ID_GetQAErrorCount );
2002-11-18 14:54:26 +00:00
MAKE_TT_KEYWORD( "GetUseFileWarningCount", SbxCLASS_METHOD, SbxULONG, ID_GetUseFileWarningCount );
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 );
2002-11-18 14:54:26 +00:00
MAKE_TT_KEYWORD( "GetTestCaseName", SbxCLASS_METHOD, SbxSTRING, ID_GetTestCaseName );
MAKE_TT_KEYWORD( "GetTestCaseFileName", SbxCLASS_METHOD, SbxSTRING, ID_GetTestCaseFileName );
MAKE_TT_KEYWORD( "GetTestCaseLineNr", SbxCLASS_METHOD, SbxUSHORT, ID_GetTestCaseLineNr );
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 );
2002-11-18 14:54:26 +00:00
// Load the Remote Commands from list
if ( !pRCommands ) // is static and called only once therefore
2002-11-18 14:54:26 +00:00
ReadFlatArray( arR_Cmds, pRCommands );
sal_uInt16 i;
2002-11-18 14:54:26 +00:00
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 );
}
2002-11-18 14:54:26 +00:00
// constants for SetControlType
2002-11-18 14:54:26 +00:00
MAKE_USHORT_CONSTANT("CTBrowseBox",CONST_CTBrowseBox);
MAKE_USHORT_CONSTANT("CTValueSet",CONST_CTValueSet);
2002-11-18 14:54:26 +00:00
// constants for the alignment of the requested splitter
2002-11-18 14:54:26 +00:00
MAKE_USHORT_CONSTANT("AlignLeft",CONST_ALIGN_LEFT);
MAKE_USHORT_CONSTANT("AlignTop",CONST_ALIGN_TOP);
MAKE_USHORT_CONSTANT("AlignRight",CONST_ALIGN_RIGHT);
MAKE_USHORT_CONSTANT("AlignBottom",CONST_ALIGN_BOTTOM);
/// What dialog to use in RC_CloseSysDialog or RC_ExistsSysDialog
MAKE_USHORT_CONSTANT("FilePicker",CONST_FilePicker);
MAKE_USHORT_CONSTANT("FolderPicker",CONST_FolderPicker);
/// NodeTypes of the SAX Parser
MAKE_USHORT_CONSTANT("NodeTypeCharacter",CONST_NodeTypeCharacter);
MAKE_USHORT_CONSTANT("NodeTypeElement",CONST_NodeTypeElement);
MAKE_USHORT_CONSTANT("NodeTypeComment",CONST_NodeTypeComment);
/// ItemTypes for TreeListBox and maybe others
MAKE_USHORT_CONSTANT("ItemTypeText",CONST_ItemTypeText);
MAKE_USHORT_CONSTANT("ItemTypeBMP",CONST_ItemTypeBMP);
MAKE_USHORT_CONSTANT("ItemTypeCheckbox",CONST_ItemTypeCheckbox);
MAKE_USHORT_CONSTANT("ItemTypeContextBMP",CONST_ItemTypeContextBMP);
MAKE_USHORT_CONSTANT("ItemTypeUnknown",CONST_ItemTypeUnknown);
/// Return values for WaitSlot
MAKE_USHORT_CONSTANT("WSTimeout",CONST_WSTimeout);
MAKE_USHORT_CONSTANT("WSAborted",CONST_WSAborted);
MAKE_USHORT_CONSTANT("WSFinished",CONST_WSFinished);
2002-11-18 14:54:26 +00:00
pImpl->pControlsObj = new Controls( CUniString("GetNextCloseWindow") );
pImpl->pControlsObj->SetType( SbxVARIANT );
Insert( pImpl->pControlsObj );
2002-11-18 14:54:26 +00:00
pImpl->pControlsObj->SetUserData( ID_GetNextCloseWindow );
pImpl->pControlsObj->ChangeListener( this );
2002-11-18 14:54:26 +00:00
for ( i=0;i<VAR_POOL_SIZE;i++)
{
pImpl->pMyVars[i] = new SbxTransportMethod( SbxVARIANT );
pImpl->pMyVars[i]->SetName( CUniString("VarDummy").Append(String::CreateFromInt32(i) ) );
2002-11-18 14:54:26 +00:00
Insert( pImpl->pMyVars[i] );
}
m_pControls = new CNames();
m_pSIds = new CNames();
m_pNameKontext = m_pControls;
2002-11-18 14:54:26 +00:00
nMyVar = 0;
pImpl->pMyBasic->AddFactory( &aComManFac );
2002-11-18 14:54:26 +00:00
}
2010-11-08 21:20:54 +00:00
2002-11-18 14:54:26 +00:00
TestToolObj::~TestToolObj()
{
pImpl->pMyBasic->RemoveFactory( &aComManFac );
2002-11-18 14:54:26 +00:00
EndListening( ((StarBASIC*)GetParent())->GetBroadcaster() );
pImpl->pNextReturn.Clear();
pImpl->pControlsObj.Clear();
for ( int i = 0 ; i < VAR_POOL_SIZE ; i++ )
{
pImpl->pMyVars[i].Clear();
}
2011-07-29 11:13:09 +01:00
delete m_pControls;
delete m_pReverseSlots;
delete m_pReverseControls;
delete m_pReverseControlsSon;
delete m_pReverseUIds;
delete m_pSIds;
2002-11-18 14:54:26 +00:00
if (pFehlerListe)
{
delete pFehlerListe;
pFehlerListe = NULL; // because pFehlerListe is static!!
2002-11-18 14:54:26 +00:00
}
2011-07-29 11:13:09 +01:00
2002-11-18 14:54:26 +00:00
if ( pCommunicationManager )
{
pCommunicationManager->StopCommunication();
delete pCommunicationManager;
}
2011-07-29 11:13:09 +01:00
2002-11-18 14:54:26 +00:00
delete In;
2011-07-29 11:13:09 +01:00
delete pImpl->pTTSfxBroadcaster;
delete pImpl->pHttpRequest;
delete pImpl->pChildEnv;
pImpl->xErrorList.Clear();
pImpl->xWarningList.Clear();
pImpl->xQAErrorList.Clear();
pImpl->xIncludeFileWarningList.Clear();
2002-11-18 14:54:26 +00:00
delete pImpl;
delete pShortNames;
2002-11-18 14:54:26 +00:00
}
SfxBroadcaster& TestToolObj::GetTTBroadcaster()
{
if ( !pImpl->pTTSfxBroadcaster )
pImpl->pTTSfxBroadcaster = new SfxBroadcaster;
return *pImpl->pTTSfxBroadcaster;
}
void TestToolObj::ReadNames( String Filename, CNames *&pNames, CNames *&pUIds, sal_Bool bIsFlat )
2002-11-18 14:54:26 +00:00
{
/*******************************************************************************
**
** the following file extensions are available:
2002-11-18 14:54:26 +00:00
**
** 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
2002-11-18 14:54:26 +00:00
**
**
*******************************************************************************/
SvFileStream Stream;
String aLine,aShortname,aLongname;
rtl::OString aUId;
2002-11-18 14:54:26 +00:00
xub_StrLen nLineNr;
sal_uInt16 nElement;
2002-11-18 14:54:26 +00:00
ControlDef *pNewDef, *pNewDef2;
ControlDef *pFatherDef = NULL;
nLineNr = 0;
2002-11-18 14:54:26 +00:00
if (! pUIds)
{
String aFileName = (pImpl->aHIDDir + DirEntry(CUniString("hid.lst"))).GetFull();
2002-11-18 14:54:26 +00:00
{
TTExecutionStatusHint aHint( TT_EXECUTION_SHOW_ACTION, String(IttResId(S_READING_LONGNAMES)), aFileName );
2002-11-18 14:54:26 +00:00
GetTTBroadcaster().Broadcast( aHint );
}
ReadFlat( aFileName ,pUIds, sal_True );
2002-11-18 14:54:26 +00:00
if ( !pUIds )
return;
pNewDef = new ControlDef("Active",rtl::OString());
const ControlItem *pItem = pNewDef;
if (! pUIds->Insert(pItem))
2002-11-18 14:54:26 +00:00
{
ADD_WARNING_LOG2( GEN_RES_STR1c( S_DOUBLE_NAME, "Active" ), Filename, nLineNr );
2002-11-18 14:54:26 +00:00
delete pNewDef;
}
}
ADD_MESSAGE_LOG( Filename );
Stream.Open(Filename, STREAM_STD_READ);
if (!Stream.IsOpen())
{
ADD_ERROR(ERR_NO_FILE,GEN_RES_STR1(S_CANNOT_OPEN_FILE, Filename));
return;
}
if ( bIsFlat && !pNames )
{
TTExecutionStatusHint aHint( TT_EXECUTION_SHOW_ACTION, String(IttResId(S_READING_SLOT_IDS)), Filename );
2002-11-18 14:54:26 +00:00
GetTTBroadcaster().Broadcast( aHint );
}
else
{
TTExecutionStatusHint aHint( TT_EXECUTION_SHOW_ACTION, String(IttResId(S_READING_CONTROLS)), Filename );
2002-11-18 14:54:26 +00:00
GetTTBroadcaster().Broadcast( aHint );
}
if ( !pNames )
pNames = new CNames();
{
TTExecutionStatusHint aHint( TT_EXECUTION_ENTERWAIT );
GetTTBroadcaster().Broadcast( aHint );
}
while (!Stream.IsEof())
{
nLineNr++;
Stream.ReadByteStringLine(aLine, RTL_TEXTENCODING_IBM_850);
aLine.EraseLeadingChars();
aLine.EraseTrailingChars();
while ( aLine.SearchAscii(" ") != STRING_NOTFOUND )
aLine.SearchAndReplaceAllAscii(" ",UniString(' '));
if (aLine.Len() == 0) continue;
if (aLine.Copy(0,4).CompareIgnoreCaseToAscii("Rem ") == COMPARE_EQUAL) continue;
if (aLine.Copy(0,1).CompareToAscii("'") == COMPARE_EQUAL) continue;
if ( (aLine.GetTokenCount(cMyDelim) < 2 || aLine.GetTokenCount(cMyDelim) > 3) && aLine.CompareIgnoreCaseToAscii("*Active") != COMPARE_EQUAL )
{
ADD_WARNING_LOG2( GEN_RES_STR1( S_INVALID_LINE, aLine ), Filename, nLineNr );
continue;
}
aShortname = aLine.GetToken(0,cMyDelim);
2002-11-18 14:54:26 +00:00
aLongname = aLine.GetToken(1,cMyDelim);
String aFirstAllowedExtra, aAllowed;
aFirstAllowedExtra.AssignAscii("+*");
aAllowed.AssignAscii("_");
xub_StrLen nIndex = 0;
sal_Bool bOK = sal_True;
2002-11-18 14:54:26 +00:00
while ( bOK && nIndex < aShortname.Len() )
2002-11-18 14:54:26 +00:00
{
sal_Unicode aChar = aShortname.GetChar( nIndex );
sal_Bool bOKThis = sal_False;
2002-11-18 14:54:26 +00:00
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<74>lt ung<6E>ltige Zeichen."), Filename, nLineNr );
2002-11-18 14:54:26 +00:00
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" ) );
2002-11-18 14:54:26 +00:00
if ( aShortname.GetChar(0) == '+' ) // copy complete entry
2002-11-18 14:54:26 +00:00
{
aShortname.Erase(0,1);
ControlDef WhatName(aLongname,rtl::OString());
2002-11-18 14:54:26 +00:00
ControlDef *OldTree;
if (pNames->Seek_Entry(&WhatName,&nElement))
{
OldTree = (ControlDef*)pNames->GetObject(nElement);
pNewDef = new ControlDef(aLongname,aShortname,OldTree,sal_True);
2002-11-18 14:54:26 +00:00
const ControlItem *pItem = pNewDef;
if (! pNames->Insert(pItem))
2002-11-18 14:54:26 +00:00
{
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());
2002-11-18 14:54:26 +00:00
if (pUIds->Seek_Entry(&WhatName,&nElement))
aUId = pUIds->GetObject(nElement)->pData->aUId;
else
{
ADD_WARNING_LOG2( GEN_RES_STR1( S_LONGNAME_UNKNOWN, aLine ), Filename, nLineNr );
continue;
}
}
else
{
// FIXME: HELPID
2002-11-18 14:54:26 +00:00
}
if (aShortname.GetChar(0) == '*' || bIsFlat) // global short name (dialogue name or SId)
2002-11-18 14:54:26 +00:00
{
if (!bIsFlat)
aShortname.Erase(0,1);
pNewDef = new ControlDef(aShortname,aUId);
2002-11-18 14:54:26 +00:00
if (!bIsFlat)
{
pNewDef->Sons( new CNames() );
pNewDef2 = new ControlDef(aShortname,aUId);
if (!pNewDef->SonInsert( pNewDef2 )) // enter dialogue into its own namespace
2002-11-18 14:54:26 +00:00
{
delete pNewDef2;
2011-03-01 17:55:09 +01:00
OSL_FAIL(" !!!! ACHTUNG !!!! Fehler beim einf<6E>gen in leere Liste!");
2002-11-18 14:54:26 +00:00
}
}
const ControlItem *pItem = pNewDef;
if (! pNames->Insert(pItem))
2002-11-18 14:54:26 +00:00
{
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);
2002-11-18 14:54:26 +00:00
if (! pFatherDef->SonInsert(pNewDef))
{
ADD_WARNING_LOG2( GEN_RES_STR1( S_DOUBLE_NAME, aLine ), Filename, nLineNr );
delete pNewDef;
}
}
}
}
GetpApp()->Reschedule();
}
{
TTExecutionStatusHint aHint( TT_EXECUTION_LEAVEWAIT );
GetTTBroadcaster().Broadcast( aHint );
}
{
TTExecutionStatusHint aHint( TT_EXECUTION_HIDE_ACTION );
GetTTBroadcaster().Broadcast( aHint );
}
Stream.Close();
}
void TestToolObj::AddName(String &aBisher, String &aNeu )
{
String aSl( '/' );
if ( UniString(aSl).Append(aBisher).Append(aSl).ToUpperAscii().Search( UniString(aSl).Append(aNeu).Append(aSl).ToUpperAscii() ) == STRING_NOTFOUND )
{
aBisher += aSl;
aBisher += aNeu;
}
}
void TestToolObj::ReadFlat( String Filename, CNames *&pNames, sal_Bool bSortByName )
// if bSortByName == sal_False, sort by UId (ControlItemUId instead of ControlDef)
2002-11-18 14:54:26 +00:00
{
SvFileStream Stream;
String aLine,aLongname;
rtl::OString aUId;
2002-11-18 14:54:26 +00:00
xub_StrLen nLineNr;
ControlItem *pNewItem;
sal_uInt16 nDoubleCount = 0;
2002-11-18 14:54:26 +00:00
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;
2002-11-18 14:54:26 +00:00
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;
2002-11-18 14:54:26 +00:00
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);
2010-06-04 20:07:26 +02:00
// FIXME: HELPID
aUId = rtl::OUStringToOString( aLine.GetToken(1,cMyDelim), RTL_TEXTENCODING_UTF8 );
2002-11-18 14:54:26 +00:00
if ( bSortByName )
pNewItem = new ControlDef( aLongname, aUId );
2002-11-18 14:54:26 +00:00
else
pNewItem = new ControlItemUId( aLongname, aUId );
2002-11-18 14:54:26 +00:00
if ( !pNames->C40_PTR_INSERT( ControlItem, pNewItem ) )
{
if ( bSortByName )
{
if ( nDoubleCount++ < 10 )
{
ADD_WARNING_LOG2( GEN_RES_STR1( S_DOUBLE_NAME, aLine ), Filename, nLineNr );
}
}
else
{
sal_uInt16 nNr;
2002-11-18 14:54:26 +00:00
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;
2002-11-18 14:54:26 +00:00
if ( !pNames )
pNames = new CNames();
while ( String::CreateFromAscii(arWas[nIndex].Kurzname).Len() > 0 )
{
2010-06-04 20:07:26 +02:00
// FIXME: HELPID
rtl::OString aUId;// (arWas[nIndex].nUId);
2002-11-18 14:54:26 +00:00
const ControlItem *pX = new ControlDef( arWas[nIndex].Kurzname, aUId);
pNames->C40_PTR_INSERT(ControlItem, pX);
nIndex++;
}
}
void TestToolObj::WaitForAnswer ()
{
if ( bUseIPC )
{
sal_Bool bWasRealWait = !bReturnOK;
2002-11-18 14:54:26 +00:00
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 )
2002-11-18 14:54:26 +00:00
CallDialogHandler(GetpApp());
}
else
{
Time Ende;
Ende += pImpl->aServerTimeout;
SvStream *pTemp = NULL;
while ( !bReturnOK && Ende > Time() )
{
if ( pTemp )
{
ReturnResults( pTemp );
bReturnOK = sal_True;
2002-11-18 14:54:26 +00:00
}
else
{
GetpApp()->Reschedule();
}
nIdleCount = 0;
}
}
if ( !bReturnOK )
{
ADD_ERROR(ERR_EXEC_TIMEOUT,GEN_RES_STR1(S_TIMOUT_WAITING, String::CreateFromInt64(nSequence)));
bReturnOK = sal_True;
2002-11-18 14:54:26 +00:00
nSequence++;
}
}
IMPL_LINK( TestToolObj, IdleHdl, Application*, EMPTYARG )
2002-11-18 14:54:26 +00:00
{
if ( !bReturnOK )
nIdleCount++;
if ( nIdleCount > 10 ) // means been here for 10 times already and none of these in WaitForAnswer
2002-11-18 14:54:26 +00:00
{
GetpApp()->RemoveIdleHdl( LINK( this, TestToolObj, IdleHdl ) );
2002-11-18 14:54:26 +00:00
GetpApp()->PostUserEvent( LINK( this, TestToolObj, CallDialogHandler ) );
}
return 0;
}
IMPL_LINK( TestToolObj, CallDialogHandler, Application*, EMPTYARG )
2002-11-18 14:54:26 +00:00
{
nWindowHandlerCallLevel++;
String aHandlerName(aDialogHandlerName);
2002-11-18 14:54:26 +00:00
aDialogHandlerName.Erase();
sal_uLong nRememberSequence = nSequence;
((StarBASIC*)GetParent())->Call( aHandlerName );
2002-11-18 14:54:26 +00:00
nSequence = nRememberSequence;
2002-11-18 14:54:26 +00:00
nWindowHandlerCallLevel--;
return 0;
}
void TestToolObj::BeginBlock()
{
WaitForAnswer();
if ( IsError() )
return;
DBG_ASSERT(!IsBlock,"BeginBlock innerhalb eines Blockes");
2002-11-18 14:54:26 +00:00
In->Reset(nSequence);
IsBlock = sal_True;
2002-11-18 14:54:26 +00:00
}
void TestToolObj::SendViaSocket()
{
if ( !pCommunicationManager )
{
2011-03-01 17:55:09 +01:00
OSL_FAIL("Kein CommunicationManager vorhanden!!");
2002-11-18 14:54:26 +00:00
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) )
2002-11-18 14:54:26 +00:00
{
pImpl->pMyBasic->Call( CUniString( "startTheOffice" ) );
2002-11-18 14:54:26 +00:00
}
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
2002-11-18 14:54:26 +00:00
{
if ( !pImpl->bIsStart )
{
ADD_ERROR(ERR_RESTART,GEN_RES_STR0(S_APPLICATION_RESTARTED));
}
2002-11-18 14:54:26 +00:00
}
}
}
2002-11-18 14:54:26 +00:00
bReturnOK = sal_False;
2002-11-18 14:54:26 +00:00
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
2002-11-18 14:54:26 +00:00
}
}
else
{
ADD_ERROR(ERR_SEND_TIMEOUT,GEN_RES_STR1(S_NO_CONNECTION, String::CreateFromInt64(nSequence)));
nSequence++;
bReturnOK = sal_True;
2002-11-18 14:54:26 +00:00
}
}
void TestToolObj::EndBlock()
{
if (IsBlock)
{
pImpl->LocalStarttime = Time::GetSystemTicks(); // setting the initial time for performance measuring
2002-11-18 14:54:26 +00:00
In->GenCmdFlow (F_EndCommandBlock);
if ( pImpl->bDoRemoteCommandDelay )
{
sal_uLong nTimeWait = pImpl->nMinRemoteCommandDelay;
2002-11-18 14:54:26 +00:00
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;
2002-11-18 14:54:26 +00:00
if ( aDialogHandlerName.Len() > 0 )
GetpApp()->InsertIdleHdl( LINK( this, TestToolObj, IdleHdl ), 1 );
}
IsBlock = sal_False;
2002-11-18 14:54:26 +00:00
}
else
{
2011-03-01 17:55:09 +01:00
OSL_FAIL("EndBlock au<61>erhalb eines Blockes");
2002-11-18 14:54:26 +00:00
}
}
sal_Bool TestToolObj::Load( String aFileName, SbModule *pMod )
2002-11-18 14:54:26 +00:00
{
sal_Bool bOk = sal_True;
SvFileStream aStrm( aFileName, STREAM_STD_READ );
2002-11-18 14:54:26 +00:00
if( aStrm.IsOpen() )
{
String aText, aLine;
sal_Bool bIsFirstLine = sal_True;
2002-11-18 14:54:26 +00:00
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;
2002-11-18 14:54:26 +00:00
}
if( aStrm.GetError() != SVSTREAM_OK )
bOk = sal_False;
2002-11-18 14:54:26 +00:00
}
aText.ConvertLineEnd();
pMod->SetName(CUniString("--").Append(aFileName));
2002-11-18 14:54:26 +00:00
pMod->SetComment( GetRevision( aText ) );
2002-11-18 14:54:26 +00:00
SbModule* pOldModule = MyBasic::GetCompileModule();
MyBasic::SetCompileModule( pMod );
pMod->SetSource( PreCompile( aText ) );
MyBasic::SetCompileModule( pOldModule );
if ( WasPrecompilerError() )
bOk = sal_False;
2002-11-18 14:54:26 +00:00
}
else
bOk = sal_False;
2002-11-18 14:54:26 +00:00
return bOk;
}
sal_Bool TestToolObj::ReadNamesBin( String Filename, CNames *&pSIds, CNames *&pControls )
2002-11-18 14:54:26 +00:00
{
SvFileStream aStream;
String aName,aURL;
rtl::OString aUId;
2002-11-18 14:54:26 +00:00
ControlDef *pNewDef, *pNewDef2;
ControlDef *pFatherDef = NULL;
aStream.Open(Filename, STREAM_STD_READ);
if (!aStream.IsOpen())
{
ADD_ERROR(ERR_NO_FILE,GEN_RES_STR1(S_CANNOT_OPEN_FILE, Filename));
return sal_False;
2002-11-18 14:54:26 +00:00
}
if ( !pSIds )
pSIds = new CNames();
if ( !pControls )
pControls = new CNames();
{
TTExecutionStatusHint aHint( TT_EXECUTION_ENTERWAIT );
GetTTBroadcaster().Broadcast( aHint );
}
sal_uInt16 nAnz;
2002-11-18 14:54:26 +00:00
aStream >> nAnz;
CNames *pNames = pSIds; // first read all the slots
sal_Bool bIsFlat = sal_True; // Slots do not have children
2002-11-18 14:54:26 +00:00
while ( nAnz && !aStream.IsEof() )
{
aStream.ReadByteString( aName, RTL_TEXTENCODING_UTF8 );
sal_uInt16 nType;
2002-11-18 14:54:26 +00:00
aStream >> nType;
if ( !nType /* HasNumeric() */)
2002-11-18 14:54:26 +00:00
{
String aStrId;
aStream.ReadByteString( aStrId, RTL_TEXTENCODING_UTF8 );
// FIXME: HELPID
2002-11-18 14:54:26 +00:00
}
else
{
2011-07-07 11:28:13 +02:00
comm_UINT32 nUId;
2002-11-18 14:54:26 +00:00
aStream >> nUId;
2010-06-04 20:07:26 +02:00
aUId = rtl::OString();// nUId;
2002-11-18 14:54:26 +00:00
}
if (aName.GetChar(0) == '*' || bIsFlat ) // global short name (dialogue name or SId)
2002-11-18 14:54:26 +00:00
{
if (!bIsFlat)
aName.Erase(0,1);
pNewDef = new ControlDef(aName,aUId);
2002-11-18 14:54:26 +00:00
if (!bIsFlat)
{
pNewDef->Sons(new CNames());
pNewDef2 = new ControlDef(aName,aUId);
if (!pNewDef->SonInsert(pNewDef2)) // enter dialogue into its own namespace
2002-11-18 14:54:26 +00:00
{
delete pNewDef2;
2011-03-01 17:55:09 +01:00
OSL_FAIL(" !!!! ACHTUNG !!!! Fehler beim einf<6E>gen in leere Liste!");
2002-11-18 14:54:26 +00:00
}
}
const ControlItem *pItem = pNewDef;
if (! pNames->Insert(pItem))
2002-11-18 14:54:26 +00:00
{
2011-03-01 17:55:09 +01:00
OSL_FAIL(" !!!! ACHTUNG !!!! Fehler beim einf<6E>gen eines namens!");
2002-11-18 14:54:26 +00:00
delete pNewDef;
pFatherDef = NULL;
}
else
{
pFatherDef = pNewDef;
}
}
else
{
if (!pFatherDef)
{
2011-03-01 17:55:09 +01:00
OSL_FAIL( "Internal Error: Erster Kurzname mu<6D> mit * beginnen. <20>berspringe." );
2002-11-18 14:54:26 +00:00
}
else
{
pNewDef = new ControlDef(aName,aUId);
2002-11-18 14:54:26 +00:00
if (! pFatherDef->SonInsert(pNewDef))
{
delete pNewDef;
2011-03-01 17:55:09 +01:00
OSL_FAIL(" !!!! ACHTUNG !!!! Fehler beim einf<6E>gen eines namens!");
2002-11-18 14:54:26 +00:00
}
}
}
nAnz--;
if ( !nAnz && bIsFlat ) // We have read all slots
{
aStream >> nAnz;
pNames = pControls; // Now read the controls
bIsFlat = sal_False; // Controls *do* have children
2002-11-18 14:54:26 +00:00
}
GetpApp()->Reschedule();
}
{
TTExecutionStatusHint aHint( TT_EXECUTION_LEAVEWAIT );
GetTTBroadcaster().Broadcast( aHint );
}
aStream.Close();
return sal_True;
2002-11-18 14:54:26 +00:00
}
sal_Bool TestToolObj::WriteNamesBin( String Filename, CNames *pSIds, CNames *pControls )
2002-11-18 14:54:26 +00:00
{
sal_Bool bOk = sal_True;
2002-11-18 14:54:26 +00:00
SvFileStream aStrm( String(Filename).AppendAscii(".bin"), STREAM_STD_WRITE );
if( aStrm.IsOpen() )
{
sal_uInt16 i;
2002-11-18 14:54:26 +00:00
if ( pSIds )
{
aStrm << pSIds->Count();
for ( i = 0 ; pSIds->Count() > i && bOk ; i++ )
{
((ControlDef*)(*pSIds)[i])->Write(aStrm);
if( aStrm.GetError() != SVSTREAM_OK )
bOk = sal_False;
2002-11-18 14:54:26 +00:00
}
}
else
aStrm << sal_uInt16( 0 );
2002-11-18 14:54:26 +00:00
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;
2002-11-18 14:54:26 +00:00
}
}
else
aStrm << sal_uInt16( 0 );
2002-11-18 14:54:26 +00:00
}
else
bOk = sal_False;
2002-11-18 14:54:26 +00:00
return bOk;
}
void TestToolObj::SFX_NOTIFY( SfxBroadcaster&, const TypeId&,
const SfxHint& rHint, const TypeId& )
{
static CNames *pUIds = NULL; // hold the hid.lst
2002-11-18 14:54:26 +00:00
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();
2002-11-18 14:54:26 +00:00
if( nHintId == SBX_HINT_DATAWANTED )
{
nMyVar = 0;
switch( nHintUserData )
2002-11-18 14:54:26 +00:00
{
case ID_Kontext:
if ( !rPar )
{
m_pNameKontext = m_pControls;
2002-11-18 14:54:26 +00:00
for (sal_uInt16 i=0;i<VAR_POOL_SIZE;i++)
2002-11-18 14:54:26 +00:00
{
pImpl->pMyVars[i]->SetName( CUniString("VarDummy").Append(UniString::CreateFromInt32(i)) );
2002-11-18 14:54:26 +00:00
}
}
else if ( rPar && rPar->Count() == 2 )
{
sal_uInt16 nElement;
2002-11-18 14:54:26 +00:00
SbxVariableRef pArg = rPar->Get( 1 );
String aKontext = pArg->GetString();
ControlDef WhatName(aKontext,rtl::OString());
if (m_pControls && m_pControls->Seek_Entry(&WhatName,&nElement))
2002-11-18 14:54:26 +00:00
{
m_pNameKontext = ((ControlDef*)m_pControls->GetObject(nElement))->GetSons();
2002-11-18 14:54:26 +00:00
for (sal_uInt16 i=0;i<VAR_POOL_SIZE;i++)
2002-11-18 14:54:26 +00:00
{
pImpl->pMyVars[i]->SetName( CUniString("VarDummy").Append(UniString::CreateFromInt32(i)) );
2002-11-18 14:54:26 +00:00
}
}
}
else
SetError( SbxERR_WRONG_ARGS );
break;
case ID_Start:
if ( rPar && rPar->Count() >= 2 )
{
SbxVariableRef pArg = rPar->Get( 1 );
ProgPath = pArg->GetString();
if ( rPar && rPar->Count() >= 3 )
{
pArg = rPar->Get( 2 );
pImpl->ProgParam = pArg->GetString();
}
else
pImpl->ProgParam.Erase();
2002-11-18 14:54:26 +00:00
String aTmpStr(ProgPath);
aTmpStr += ' ';
aTmpStr += pImpl->ProgParam;
{
TTExecutionStatusHint aHint( TT_EXECUTION_SHOW_ACTION, String(IttResId(S_STARTING_APPLICATION)), aTmpStr );
GetTTBroadcaster().Broadcast( aHint );
}
2002-11-18 14:54:26 +00:00
pImpl->bIsStart = sal_True;
2002-11-18 14:54:26 +00:00
BeginBlock();
EndBlock();
pImpl->bIsStart = sal_False;
2002-11-18 14:54:26 +00:00
{
TTExecutionStatusHint aHint( TT_EXECUTION_HIDE_ACTION );
GetTTBroadcaster().Broadcast( aHint );
}
}
break;
case ID_KillApp:
pCommunicationManager->KillApplication();
break;
2002-11-18 14:54:26 +00:00
case ID_SaveIDs:
if ( rPar && rPar->Count() >= 2 ) // one parameter excactly
2002-11-18 14:54:26 +00:00
{
SbxVariableRef pArg = rPar->Get( 1 );
2011-05-07 13:58:31 +02:00
#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 );
2002-11-18 14:54:26 +00:00
}
else
SetError( SbxERR_WRONG_ARGS );
break;
case ID_AutoExecute:
if ( !rPar ) // rPar = NULL <=> no parameters
2002-11-18 14:54:26 +00:00
{
pVar->PutBool(SingleCommandBlock);
}
else
SetError( SbxERR_WRONG_ARGS );
break;
case ID_Execute:
if ( !rPar )
2002-11-18 14:54:26 +00:00
{
EndBlock();
BeginBlock();
}
else
SetError( SbxERR_WRONG_ARGS );
break;
case ID_DialogHandler:
if ( rPar && rPar->Count() >= 2 )
2002-11-18 14:54:26 +00:00
{
SbxVariableRef pArg = rPar->Get( 1 );
aDialogHandlerName = pArg->GetString();
}
else
SetError( SbxERR_WRONG_ARGS );
break;
case ID_GetError:
if ( !rPar )
2002-11-18 14:54:26 +00:00
{
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 )
2002-11-18 14:54:26 +00:00
{
{
BasicRuntime aRun = BasicRuntimeAccess::GetRuntime();
aLogFileName = DirEntry(aRun.GetModuleName(SbxNAME_NONE)).GetBase().AppendAscii(".res");
}
2002-11-18 14:54:26 +00:00
ADD_RUN_LOG();
ADD_CASE_LOG(GEN_RES_STR0(S_READING_FILE));
pCommunicationManager->StopCommunication();
// Wait for asynchronous events to be processed, so communication will be restarted properly
while ( pCommunicationManager->IsCommunicationRunning() )
Application::Reschedule();
Merge commit 'ooo/DEV300_m101' into integration/dev300_m101 * commit 'ooo/DEV300_m101': (185 commits) masterfix DEV300: #i10000# usage of L10N build_type masterfix: #i10000# INT16 -> sal_Int16 fixed compile errors after resync to m100, part2 gridsort: post-rebase fixes CWS gnumake3: found another tools integer type removetooltypes01: Fix build problems after rebase to DEV300m99 in basctl, cui, reportdesign, sw native359: #i114398# changing mac langpack icon native359: #i115669# fixing package description for solaris packages gnumake3: remove comphelper version; fix including extract.hxx locales34: #i106785# add Haitian_Haiti [ht-HT] to language list and locale data; locale data contributed by <jcpoulard> sb138: #i116659# timely termination of OnLogRotateThread accfixes: removed include of obsolete header file accfixes: removed obsolete file removetooltypes01: #i112600# Fix build problems on non-pro accfixes: moved some shared strings to svx part2 accfixes: moved some shared strings to svx accfixes: added more accessibility information and fixed tab orders in multiple dialogs (cui module) removetooltypes01: #i112600# Remove tools types for Mac specific parts fixed tab order in BasicIDE, Library dialog tab page added some accessible names in BasicIDE ... Conflicts: UnoControls/source/base/registercontrols.cxx accessibility/inc/accessibility/standard/vclxaccessiblelistboxlist.hxx automation/inc/automation/communi.hxx automation/inc/automation/simplecm.hxx automation/source/communi/communi.cxx automation/source/inc/rcontrol.hxx automation/source/miniapp/servuid.hxx automation/source/server/XMLParser.cxx automation/source/server/cmdbasestream.cxx automation/source/server/profiler.hxx automation/source/server/recorder.cxx automation/source/server/retstrm.hxx automation/source/server/server.cxx automation/source/server/sta_list.cxx automation/source/server/statemnt.cxx automation/source/server/statemnt.hxx automation/source/simplecm/packethandler.cxx automation/source/simplecm/simplecm.cxx automation/source/simplecm/tcpio.cxx automation/source/simplecm/tcpio.hxx automation/source/testtool/comm_bas.hxx automation/source/testtool/cretstrm.hxx automation/source/testtool/httprequest.cxx automation/source/testtool/httprequest.hxx automation/source/testtool/objtest.cxx automation/source/testtool/objtest.hxx basctl/source/basicide/baside2.cxx basctl/source/basicide/baside2.hxx basctl/source/basicide/baside2b.cxx basctl/source/basicide/baside3.cxx basctl/source/basicide/basides1.cxx basctl/source/basicide/basides2.cxx basctl/source/basicide/basidesh.cxx basctl/source/basicide/basidesh.src basctl/source/basicide/basobj3.cxx basctl/source/basicide/bastype2.cxx basctl/source/basicide/bastype3.cxx basctl/source/basicide/bastypes.cxx basctl/source/basicide/brkdlg.cxx basctl/source/basicide/iderdll.cxx basctl/source/basicide/macrodlg.cxx basctl/source/basicide/moduldl2.cxx basctl/source/basicide/moduldlg.cxx basctl/source/basicide/objdlg.cxx basctl/source/basicide/scriptdocument.cxx basctl/source/basicide/tbxctl.cxx basctl/source/basicide/tbxctl.hxx basctl/source/basicide/tbxctl.src basctl/source/dlged/dlged.cxx basctl/source/dlged/dlgedfunc.cxx basctl/source/dlged/dlgedobj.cxx basctl/source/inc/basidesh.hxx basctl/source/inc/bastypes.hxx basctl/source/inc/dlgedmod.hxx basctl/source/inc/dlgedpage.hxx crashrep/prj/build.lst cui/inc/pch/precompiled_cui.hxx cui/source/customize/acccfg.cxx cui/source/customize/acccfg.hrc cui/source/customize/acccfg.src cui/source/customize/cfg.cxx cui/source/customize/cfgutil.cxx cui/source/customize/macropg.cxx cui/source/customize/macropg.src cui/source/customize/selector.cxx cui/source/dialogs/SpellDialog.cxx cui/source/dialogs/commonlingui.cxx cui/source/dialogs/cuicharmap.cxx cui/source/dialogs/cuifmsearch.cxx cui/source/dialogs/cuigaldlg.cxx cui/source/dialogs/cuigrfflt.cxx cui/source/dialogs/hldocntp.cxx cui/source/dialogs/hldoctp.cxx cui/source/dialogs/hlinettp.cxx cui/source/dialogs/hlmailtp.cxx cui/source/dialogs/hlmarkwn.cxx cui/source/dialogs/hlmarkwn.src cui/source/dialogs/hltpbase.cxx cui/source/dialogs/iconcdlg.cxx cui/source/dialogs/passwdomdlg.cxx cui/source/dialogs/pastedlg.cxx cui/source/dialogs/scriptdlg.cxx cui/source/dialogs/thesdlg.cxx cui/source/dialogs/zoom.cxx cui/source/factory/dlgfact.hxx cui/source/inc/SpellDialog.hxx cui/source/inc/autocdlg.hxx cui/source/inc/backgrnd.hxx cui/source/inc/bbdlg.hxx cui/source/inc/cfg.hxx cui/source/inc/cfgutil.hxx cui/source/inc/cuigaldlg.hxx cui/source/inc/cuigrfflt.hxx cui/source/inc/cuitabarea.hxx cui/source/inc/cuitabline.hxx cui/source/inc/hldocntp.hxx cui/source/inc/hltpbase.hxx cui/source/inc/iconcdlg.hxx cui/source/inc/numpages.hxx cui/source/inc/page.hxx cui/source/inc/postdlg.hxx cui/source/inc/scriptdlg.hxx cui/source/inc/transfrm.hxx cui/source/inc/zoom.hxx cui/source/options/cfgchart.cxx cui/source/options/cuisrchdlg.cxx cui/source/options/dbregister.cxx cui/source/options/dbregister.src cui/source/options/fontsubs.cxx cui/source/options/internationaloptions.cxx cui/source/options/optasian.cxx cui/source/options/optchart.cxx cui/source/options/optcolor.cxx cui/source/options/optcolor.src cui/source/options/optfltr.cxx cui/source/options/optfltr.src cui/source/options/optgdlg.cxx cui/source/options/optgdlg.src cui/source/options/optgenrl.cxx cui/source/options/opthtml.cxx cui/source/options/optimprove.cxx cui/source/options/optinet2.cxx cui/source/options/optinet2.hxx cui/source/options/optjava.cxx cui/source/options/optlingu.cxx cui/source/options/optsave.cxx cui/source/options/optsave.hxx cui/source/options/treeopt.cxx cui/source/options/webconninfo.cxx cui/source/tabpages/autocdlg.cxx cui/source/tabpages/backgrnd.cxx cui/source/tabpages/border.cxx cui/source/tabpages/chardlg.cxx cui/source/tabpages/dstribut.cxx cui/source/tabpages/grfpage.cxx cui/source/tabpages/macroass.cxx cui/source/tabpages/measure.cxx cui/source/tabpages/numfmt.cxx cui/source/tabpages/numpages.cxx cui/source/tabpages/page.cxx cui/source/tabpages/paragrph.cxx cui/source/tabpages/swpossizetabpage.cxx cui/source/tabpages/tabarea.src cui/source/tabpages/textanim.cxx cui/source/tabpages/textattr.cxx cui/source/tabpages/tparea.cxx cui/source/tabpages/tpbitmap.cxx cui/source/tabpages/tpcolor.cxx cui/source/tabpages/tpgradnt.cxx cui/source/tabpages/tphatch.cxx cui/source/tabpages/tpline.cxx cui/source/tabpages/tplnedef.cxx cui/source/tabpages/tplneend.cxx cui/source/tabpages/tpshadow.cxx cui/source/tabpages/transfrm.cxx embedserv/source/embed/register.cxx extensions/inc/pch/precompiled_extensions.hxx extensions/inc/propctrlr.hrc extensions/source/abpilot/abpservices.cxx extensions/source/bibliography/bibload.cxx extensions/source/bibliography/datman.cxx extensions/source/bibliography/general.cxx extensions/source/dbpilots/dbpservices.cxx extensions/source/inc/componentmodule.cxx extensions/source/nsplugin/source/so_env.cxx extensions/source/ole/oleobjw.cxx extensions/source/ole/oleobjw.hxx extensions/source/oooimprovement/invite_job.cxx extensions/source/oooimprovement/onlogrotate_job.cxx extensions/source/plugin/base/service.cxx extensions/source/plugin/inc/plugin/unx/mediator.hxx extensions/source/plugin/inc/plugin/unx/plugcon.hxx extensions/source/plugin/unx/mediator.cxx extensions/source/plugin/unx/nppapi.cxx extensions/source/plugin/unx/plugcon.cxx extensions/source/preload/services.cxx extensions/source/propctrlr/formmetadata.cxx extensions/source/propctrlr/pcrservices.cxx extensions/source/resource/resource.cxx extensions/source/scanner/sane.hxx extensions/source/scanner/sanedlg.cxx extensions/source/scanner/scanunx.cxx extensions/source/scanner/scanwin.cxx extensions/source/scanner/twain.cxx extensions/source/scanner/twain.hxx extensions/source/update/check/updatecheckconfig.cxx extensions/test/stm/datatest.cxx extensions/test/stm/marktest.cxx extensions/test/stm/pipetest.cxx extensions/test/stm/testfactreg.cxx extensions/workben/testpgp.cxx forms/qa/complex/forms/CheckOGroupBoxModel.java forms/qa/makefile.mk forms/source/component/Button.cxx forms/source/component/Button.hxx forms/source/component/ListBox.cxx forms/source/inc/forms_module_impl.hxx forms/source/misc/services.cxx forms/source/solar/control/navtoolbar.cxx javainstaller2/prj/build.lst javainstaller2/src/JavaSetup/org/openoffice/setup/Util/ModuleCtrl.java lingucomponent/prj/build.lst lingucomponent/source/hyphenator/altlinuxhyph/hyphen/hyphenimp.cxx lingucomponent/source/spellcheck/spell/sreg.cxx lingucomponent/source/spellcheck/spell/sspellimp.cxx package/source/manifest/ManifestExport.cxx package/source/manifest/UnoRegister.cxx package/source/xstor/owriteablestream.cxx package/source/xstor/owriteablestream.hxx package/source/xstor/xstorage.hxx package/source/zippackage/ZipPackageFolder.cxx package/source/zippackage/ZipPackageStream.cxx setup_native/source/mac/ooo/DS_Store setup_native/source/win32/customactions/shellextensions/registerextensions.cxx xmlsecurity/prj/build.lst xmlsecurity/source/component/registerservices.cxx xmlsecurity/source/dialogs/stbcontrl.cxx xmlsecurity/source/framework/xsec_framework.cxx xmlsecurity/source/xmlsec/xsec_xmlsec.cxx xmlsecurity/tools/demo/util.hxx xmlsecurity/workben/signaturetest.cxx
2011-03-09 16:20:50 -06:00
SingleCommandBlock = sal_True;
IsBlock = sal_False;
2002-11-18 14:54:26 +00:00
for (sal_uInt16 i=0;i<VAR_POOL_SIZE;i++)
2002-11-18 14:54:26 +00:00
{
pImpl->pMyVars[i]->SetName( CUniString("VarDummy").Append(UniString::CreateFromInt32(i)) );
2002-11-18 14:54:26 +00:00
}
nMyVar = 0;
if (m_pControls)
2002-11-18 14:54:26 +00:00
{
delete m_pControls;
m_pControls = NULL;
2002-11-18 14:54:26 +00:00
}
if (m_pReverseSlots)
2002-11-18 14:54:26 +00:00
{
delete m_pReverseSlots;
m_pReverseSlots = NULL;
2002-11-18 14:54:26 +00:00
}
if (m_pReverseControls)
2002-11-18 14:54:26 +00:00
{
delete m_pReverseControls;
m_pReverseControls = NULL;
2002-11-18 14:54:26 +00:00
}
if (m_pReverseControlsSon)
2002-11-18 14:54:26 +00:00
{
delete m_pReverseControlsSon;
m_pReverseControlsSon = NULL;
2002-11-18 14:54:26 +00:00
}
if (m_pSIds)
2002-11-18 14:54:26 +00:00
{
delete m_pSIds;
m_pSIds = NULL;
2002-11-18 14:54:26 +00:00
}
if (pUIds)
{
delete pUIds;
pUIds = NULL;
}
if (m_pReverseUIds)
2002-11-18 14:54:26 +00:00
{
delete m_pReverseUIds;
m_pReverseUIds = NULL;
2002-11-18 14:54:26 +00:00
}
m_pNameKontext = m_pControls;
pImpl->bLnaguageExtensionLoaded = sal_False;
2002-11-18 14:54:26 +00:00
SfxSimpleHint aHint( SBX_HINT_LANGUAGE_EXTENSION_LOADED );
GetTTBroadcaster().Broadcast( aHint );
pImpl->nMinRemoteCommandDelay = 0;
pImpl->nMaxRemoteCommandDelay = 0;
pImpl->bDoRemoteCommandDelay = sal_False;
2002-11-18 14:54:26 +00:00
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 );
2002-11-18 14:54:26 +00:00
}
else
SetError( SbxERR_WRONG_ARGS );
break;
case ID_Use:
if ( rPar && rPar->Count() >= 2 )
{
SbxVariableRef pArg = rPar->Get( 1 );
2011-05-07 15:54:49 +02:00
#if defined(WNT)
DirEntry FilePath(pArg->GetString(),FSYS_STYLE_NTFS);
#else
DirEntry FilePath(pArg->GetString(),FSYS_STYLE_UNX);
#endif
2002-11-18 14:54:26 +00:00
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;
2002-11-18 14:54:26 +00:00
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;
2002-11-18 14:54:26 +00:00
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;
2002-11-18 14:54:26 +00:00
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() );
2002-11-18 14:54:26 +00:00
GetTTBroadcaster().Broadcast( aHint );
}
String aFullPathname = FilePath.GetFull();
StarBASIC *pBasic = (StarBASIC*)GetParent();
if ( !aModuleWinExistsHdl.Call( &aFullPathname ) &&
!pBasic->FindModule( CUniString( "--" ).Append(aFullPathname) ) )
{
SbModule *pMod;
pMod = pBasic->MakeModule( CUniString("--"), String() );
pMod->Clear();
if ( Load( aFullPathname, pMod ) )
{
if ( !IS_ERROR() )
{
pBasic->Compile( pMod );
pMod->RunInit();
}
}
else
{
ADD_ERROR( SbxERR_CANNOT_LOAD, FilePath.GetFull() );
}
}
{
TTExecutionStatusHint aHint( TT_EXECUTION_HIDE_ACTION );
GetTTBroadcaster().Broadcast( aHint );
}
}
else
{
ADD_ERROR(SbxERR_CANNOT_LOAD,FilePath.GetFull());
}
}
else
SetError( SbxERR_WRONG_ARGS );
break;
case ID_FinishUse:
if ( !rPar )
2002-11-18 14:54:26 +00:00
{
ADD_CASE_LOG( String() ); // close case
if (!m_pControls)
m_pControls = new CNames();
2002-11-18 14:54:26 +00:00
if (!m_pSIds)
m_pSIds = new CNames();
2002-11-18 14:54:26 +00:00
if (pUIds)
{ // save some memory
delete pUIds;
pUIds = NULL;
}
m_pNameKontext = m_pControls;
2002-11-18 14:54:26 +00:00
if ( pImpl->bLnaguageExtensionLoaded )
{
SfxSimpleHint aHint( SBX_HINT_LANGUAGE_EXTENSION_LOADED );
GetTTBroadcaster().Broadcast( aHint );
}
pImpl->nIncludeFileWarningCount = pImpl->nWarningCount;
pImpl->nWarningCount = 0;
*pImpl->xIncludeFileWarningList = *pImpl->xWarningList;
pImpl->xWarningList->SbxArray::Clear();
2002-11-18 14:54:26 +00:00
}
else
SetError( SbxERR_WRONG_ARGS );
break;
case ID_CaseLog:
if ( rPar ) // rPar != NULL <=> there are parameters
2002-11-18 14:54:26 +00:00
{
sal_uInt16 n;
2002-11-18 14:54:26 +00:00
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;
2002-11-18 14:54:26 +00:00
if ( BasicRuntimeAccess::HasStack() )
{
for ( sal_uInt16 i = 0 ; i < BasicRuntimeAccess::GetStackEntryCount() -1 ; i++ )
2002-11-18 14:54:26 +00:00
{
BasicErrorStackEntry aThisEntry = BasicRuntimeAccess::GetStackEntry(i);
if ( !bWasNewError )
{
bWasNewError = sal_True;
2002-11-18 14:54:26 +00:00
ADD_ERROR_LOG( GET_ERROR()->aText, aThisEntry.GetModuleName(SbxNAME_SHORT_TYPES),
aThisEntry.GetLine(), aThisEntry.GetCol1(), aThisEntry.GetCol2(), aThisEntry.GetSourceRevision() );
2002-11-18 14:54:26 +00:00
}
ADD_CALL_STACK_LOG( String(aThisEntry.GetModuleName(SbxNAME_SHORT_TYPES))
.AppendAscii(": ").Append(aThisEntry.GetMethodName(SbxNAME_SHORT_TYPES)),
aThisEntry.GetModuleName(SbxNAME_SHORT_TYPES),
aThisEntry.GetLine(), aThisEntry.GetCol1(), aThisEntry.GetCol2() );
}
BasicRuntimeAccess::DeleteStack();
}
sal_Bool bIsFirst = sal_True;
2002-11-18 14:54:26 +00:00
while ( aRun.IsValid() )
{
xub_StrLen nErrLn;
xub_StrLen nCol1;
xub_StrLen nCol2;
if ( bIsFirst )
{
bIsFirst = sal_False;
2002-11-18 14:54:26 +00:00
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;
2002-11-18 14:54:26 +00:00
ADD_ERROR_LOG( GET_ERROR()->aText, aRun.GetModuleName(SbxNAME_SHORT_TYPES),
nErrLn, nCol1, nCol2, aRun.GetSourceRevision() );
2002-11-18 14:54:26 +00:00
}
ADD_CALL_STACK_LOG( String(aRun.GetModuleName(SbxNAME_SHORT_TYPES))
.AppendAscii(": ").Append(aRun.GetMethodName(SbxNAME_SHORT_TYPES)),
aRun.GetModuleName(SbxNAME_SHORT_TYPES),
nErrLn, nCol1, nCol2 );
aRun = aRun.GetNextRuntime();
}
}
break;
case ID_ErrorLog:
if ( IS_ERROR() )
{
BasicRuntime aRun = BasicRuntimeAccess::GetRuntime();
if ( BasicRuntimeAccess::HasStack() )
{
BasicErrorStackEntry aThisEntry = BasicRuntimeAccess::GetStackEntry( 0 );
ADD_ERROR_LOG( GET_ERROR()->aText, aThisEntry.GetModuleName(SbxNAME_SHORT_TYPES),
aThisEntry.GetLine(), aThisEntry.GetCol1(), aThisEntry.GetCol2(), aThisEntry.GetSourceRevision() );
2002-11-18 14:54:26 +00:00
BasicRuntimeAccess::DeleteStack();
}
else
{
ADD_ERROR_LOG( GET_ERROR()->aText, aRun.GetModuleName(SbxNAME_SHORT_TYPES),
StarBASIC::GetErl(), aRun.GetCol1(), aRun.GetCol2(), aRun.GetSourceRevision() );
2002-11-18 14:54:26 +00:00
}
}
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;
2002-11-18 14:54:26 +00:00
case ID_PrintLog:
if ( rPar )
2002-11-18 14:54:26 +00:00
{
sal_uInt16 n;
2002-11-18 14:54:26 +00:00
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 )
2002-11-18 14:54:26 +00:00
{
sal_uInt16 n;
2002-11-18 14:54:26 +00:00
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() ) )
2002-11-18 14:54:26 +00:00
{
((StarBASIC*)GetParent())->MakeErrorText(((StarBASIC*)GetParent())->GetErrBasic(),String());
ADD_ERROR_QUIET(((StarBASIC*)GetParent())->GetErrBasic() , ((StarBASIC*)GetParent())->GetErrorText())
2002-11-18 14:54:26 +00:00
}
break;
case ID_GetNextCloseWindow:
if ( !rPar )
2002-11-18 14:54:26 +00:00
{
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);
2002-11-18 14:54:26 +00:00
if ( !IsError() && ((SbxTransportMethod*)pVar)->nValue & M_WITH_RETURN )
{
pImpl->pNextReturn = ((SbxTransportMethod*)pVar);
2010-06-04 20:07:26 +02:00
// FIXME: HELPID
aNextReturnId = rtl::OString();
2002-11-18 14:54:26 +00:00
}
if ( SingleCommandBlock )
EndBlock();
if ( !IsError() && (sal_uInt16)((SbxTransportMethod*)pVar)->nValue & M_WITH_RETURN )
2002-11-18 14:54:26 +00:00
{
WaitForAnswer();
}
2002-11-18 14:54:26 +00:00
switch ( ((SbxTransportMethod*)pVar)->nValue )
{
case RC_WinTree:
break;
}
}
break;
case ID_Dispatch:
if ( !rPar || (rPar->Count() % 2) == 1 )
2002-11-18 14:54:26 +00:00
{
if ( SingleCommandBlock )
BeginBlock();
if ( !IsError() )
In->GenCmdSlot ( (sal_uInt16)((SbxTransportMethod*)pVar)->nValue, rPar );
pVar->PutInteger( (sal_uInt16)((SbxTransportMethod*)pVar)->nValue );
2002-11-18 14:54:26 +00:00
if ( SingleCommandBlock )
EndBlock();
}
else
SetError( SbxERR_WRONG_ARGS );
break;
case ID_UNODispatch:
if ( !rPar )
2002-11-18 14:54:26 +00:00
{
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 ) )
2002-11-18 14:54:26 +00:00
{
if ( SingleCommandBlock )
BeginBlock();
2002-11-18 14:54:26 +00:00
else
if ( ((SbxTransportMethod*)pVar)->nValue & M_WITH_RETURN )
{
SetError( SbxERR_NOTIMP );
}
if ( !IsError() )
2002-11-18 14:54:26 +00:00
{
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);
2010-06-04 20:07:26 +02:00
// 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();
}
2002-11-18 14:54:26 +00:00
}
if ( SingleCommandBlock )
EndBlock();
if ( !IsError() && (sal_uInt16)((SbxTransportMethod*)pVar)->nValue & M_WITH_RETURN )
2002-11-18 14:54:26 +00:00
{
WaitForAnswer();
2002-11-18 14:54:26 +00:00
}
}
break;
case ID_GetUnoApp:
{
// the remote UNO stuff is started here
// entry into the configuration at
2002-11-18 14:54:26 +00:00
// org.openoffice.Office.Common/Start/Connection
// socket,host=0,port=12345;iiop;XBla
// or
// socket,host=0,port=12345;urp;;XBla
2002-11-18 14:54:26 +00:00
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!!
2002-11-18 14:54:26 +00:00
}
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
2002-11-18 14:54:26 +00:00
String aString;
2010-11-08 21:20:54 +00:00
Reference< XMultiServiceFactory > xSMgr;
2002-11-18 14:54:26 +00:00
{
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
2002-11-18 14:54:26 +00:00
case SbxULONG:
2010-12-21 15:47:58 +00:00
case SbxSALINT64:
case SbxSALUINT64:
2002-11-18 14:54:26 +00:00
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;
2002-11-18 14:54:26 +00:00
case ID_MakeIniFileName:
if ( rPar && rPar->Count() == 2 )
{
OUString aUrl = Config::GetConfigName( String(), rPar->Get( 1 )->GetString() );
OUString aPath;
osl::FileBase::getSystemPathFromFileURL( aUrl, aPath );
pVar->PutString( String( aPath ) );
}
else
SetError( SbxERR_WRONG_ARGS );
break;
case ID_Wait:
{
if( rPar && rPar->Count() == 2 )
{
long nWait = rPar->Get(1)->GetLong();
if( nWait >= 0 )
{
#ifdef DEBUG
Time aStart;
#endif
2002-11-18 14:54:26 +00:00
Timer aTimer;
aTimer.SetTimeout( nWait );
aTimer.Start();
while ( aTimer.IsActive() )
Application::Yield();
#ifdef DEBUG
Time aEnd;
Time aDiff = aEnd - aStart;
long aMS = long( aDiff.GetMSFromTime() );
if ( Abs( aMS - nWait ) > 100 )
{
2011-03-04 21:30:05 +01:00
OSL_TRACE("Wait was off limit by %i", aDiff.GetMSFromTime() - nWait );
}
#endif
2002-11-18 14:54:26 +00:00
}
}
else
SetError( SbERR_BAD_NUMBER_OF_ARGS );
2002-11-18 14:54:26 +00:00
}
break;
case ID_GetErrorCount:
{
pVar->PutULong( pImpl->nErrorCount );
}
break;
case ID_GetWarningCount:
{
pVar->PutULong( pImpl->nWarningCount );
}
break;
case ID_GetQAErrorCount:
{
pVar->PutULong( pImpl->nQAErrorCount );
}
break;
2002-11-18 14:54:26 +00:00
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;
2002-11-18 14:54:26 +00:00
case ID_GetTestCaseName:
{
pVar->PutString( pImpl->aTestCaseName );
}
break;
case ID_GetTestCaseFileName:
{
pVar->PutString( pImpl->aTestCaseFileName );
}
break;
case ID_GetTestCaseLineNr:
{
pVar->PutUShort( pImpl->nTestCaseLineNr );
}
break;
case ID_SetChildEnv:
{
if( rPar && rPar->Count() == 3 )
{
pImpl->pChildEnv->erase( rPar->Get(1)->GetString() );
pImpl->pChildEnv->insert( EnvironmentVariable( rPar->Get(1)->GetString(), rPar->Get(2)->GetString() ) );
}
else
SetError( SbERR_BAD_NUMBER_OF_ARGS );
}
break;
case ID_GetChildEnv:
{
if( rPar && rPar->Count() == 2 )
{
Environment::const_iterator aIter = pImpl->pChildEnv->find( rPar->Get(1)->GetString() );
if ( aIter != pImpl->pChildEnv->end() )
pVar->PutString( (*aIter).second );
else
pVar->PutString( String() );
}
else
SetError( SbERR_BAD_NUMBER_OF_ARGS );
}
break;
case ID_GetLinkDestination:
{
if( rPar && rPar->Count() == 2 )
{
String aSource,aDest;
aSource = rPar->Get(1)->GetString();
#ifdef UNX
ByteString aByteSource( aSource, osl_getThreadTextEncoding() );
char cDest[1024];
int nLen = 0;
if ( ( nLen = readlink( aByteSource.GetBuffer(), cDest, sizeof(cDest) ) ) >= 0 )
{
aDest = String( cDest, nLen, osl_getThreadTextEncoding() );
}
else
{
int nErr = errno;
switch ( nErr )
{
case EINVAL: aDest = aSource;
break;
default:
SetError( SbERR_ACCESS_ERROR );
}
}
#else
aDest = aSource;
#endif
pVar->PutString( aDest );
}
else
SetError( SbERR_BAD_NUMBER_OF_ARGS );
}
break;
case ID_GetRegistryValue:
{
if( rPar && rPar->Count() == 3 )
{
String aValue;
#ifdef WNT
aValue = ReadRegistry( rPar->Get(1)->GetString(), rPar->Get(2)->GetString() );
#endif
pVar->PutString( aValue );
}
else
SetError( SbERR_BAD_NUMBER_OF_ARGS );
}
break;
case ID_HTTPSend:
{
if( rPar && ( rPar->Count() == 4 || rPar->Count() == 5 ) )
{
if ( !pImpl->pHttpRequest )
pImpl->pHttpRequest = new HttpRequest;
pImpl->pHttpRequest->SetRequest( ByteString( rPar->Get(1)->GetString(), RTL_TEXTENCODING_ASCII_US ), ByteString( rPar->Get(2)->GetString(), RTL_TEXTENCODING_ASCII_US ), rPar->Get(3)->GetUShort() );
if ( pImpl->pHttpRequest->Execute() )
{
if ( rPar->Count() == 5 )
{ // filename is given
SvFileStream aDestination( rPar->Get(4)->GetString(), STREAM_STD_READWRITE | STREAM_TRUNC );
(*(pImpl->pHttpRequest->GetBody())) >> aDestination;
if ( aDestination.GetError() != ERRCODE_NONE )
SetError( SbERR_ACCESS_ERROR );
aDestination.Close();
}
pVar->PutUShort( pImpl->pHttpRequest->GetResultId() );
}
else
SetError( SbERR_ACCESS_ERROR );
}
else
SetError( SbERR_BAD_NUMBER_OF_ARGS );
}
break;
case ID_HTTPSetProxy:
{
if( rPar && rPar->Count() == 3 )
{
if ( !pImpl->pHttpRequest )
pImpl->pHttpRequest = new HttpRequest;
pImpl->pHttpRequest->SetProxy( ByteString( rPar->Get(1)->GetString(), RTL_TEXTENCODING_ASCII_US ), rPar->Get(2)->GetUShort() );
}
else
SetError( SbERR_BAD_NUMBER_OF_ARGS );
}
break;
} // switch( nHintUserData )
2002-11-18 14:54:26 +00:00
} // if( nHintId == SBX_HINT_DATAWANTED )
else if( nHintId == SBX_HINT_DATACHANGED )
{
switch( nHintUserData )
2002-11-18 14:54:26 +00:00
{
case ID_AutoExecute:
if ( !rPar )
2002-11-18 14:54:26 +00:00
{
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;
2002-11-18 14:54:26 +00:00
}
} // if( nHintId == SBX_HINT_DATACHANGED )
else if( nHintId == SBX_HINT_BASICSTART )
{
pImpl->nErrorCount = 0;
pImpl->nWarningCount = 0;
pImpl->nQAErrorCount = 0;
2002-11-18 14:54:26 +00:00
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
2002-11-18 14:54:26 +00:00
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;
2002-11-18 14:54:26 +00:00
} // if( nHintId == SBX_HINT_BASICSTART )
else if( nHintId == SBX_HINT_BASICSTOP )
{
// Log summary to journal
ADD_CASE_LOG( String() ); // close case
2002-11-18 14:54:26 +00:00
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
2002-11-18 14:54:26 +00:00
}
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;
2002-11-18 14:54:26 +00:00
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
2002-11-18 14:54:26 +00:00
} // if( nHintId == SBX_HINT_BASICSTOP )
WaitForAnswer();
if ( IsError() && ( !IS_ERROR() || GET_ERROR()->nError != GetError() ) )
{
((StarBASIC*)GetParent())->MakeErrorText(GetError(),String());
ADD_ERROR_QUIET(GetError(),String(pVar->GetName()).AppendAscii(": ").
Append(((StarBASIC*)GetParent())->GetErrorText()));
}
}
}
void TestToolObj::DebugFindNoErrors( sal_Bool bDebugFindNoErrors )
{
pImpl->bDebugFindNoErrors = bDebugFindNoErrors;
}
2002-11-18 14:54:26 +00:00
SbxVariable* TestToolObj::Find( const String& aStr, SbxClassType aType)
2002-11-18 14:54:26 +00:00
{
2011-07-07 11:28:13 +02:00
if ( BasicRuntimeAccess::IsRunInit()
|| ( aStr == String( RTL_CONSTASCII_USTRINGPARAM( "ThisComponent" ) ) ) ) // because of find in the "global" command of the basic
2002-11-18 14:54:26 +00:00
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 )
2002-11-18 14:54:26 +00:00
return Old;
else if ( aStr.SearchAscii(":") != STRING_NOTFOUND )
{ // ignore qualified names e.g. main:FormWizard If this was removed an error would be generated
}
2002-11-18 14:54:26 +00:00
else
{
sal_uInt16 nElement;
ControlDef *pWhatName = new ControlDef(aStr,rtl::OString());
2002-11-18 14:54:26 +00:00
/// look for controls
if (m_pNameKontext && m_pNameKontext->Seek_Entry(pWhatName,&nElement))
2002-11-18 14:54:26 +00:00
{
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 );
2002-11-18 14:54:26 +00:00
// Will be set on method-child further down
// FIXME: HELPID
pImpl->pControlsObj->SetUserData( ID_StringControl );
2002-11-18 14:54:26 +00:00
pShortNames->Insert(pWhatName->pData->Kurzname,pWhatName->pData->aUId,nSequence);
SbxVariable *pMember = pImpl->pControlsObj->Find(CUniString("ID"),SbxCLASS_DONTCARE);
if ( pMember == NULL )
2002-11-18 14:54:26 +00:00
{
SbxProperty* pID = new SbxProperty(CUniString("ID"),SbxVARIANT);
pImpl->pControlsObj->Insert(pID);
pImpl->pControlsObj->SetDfltProperty(pID);
pMember = pID;
2002-11-18 14:54:26 +00:00
}
// FIXME: HELPID
pMember = pImpl->pControlsObj->Find(CUniString("name"),SbxCLASS_DONTCARE);
if ( pMember != NULL )
2002-11-18 14:54:26 +00:00
pMember->PutString(pWhatName->pData->Kurzname);
return pImpl->pControlsObj;
}
/// look for slots
if (m_pSIds && m_pSIds->Seek_Entry(pWhatName,&nElement))
2002-11-18 14:54:26 +00:00
{
SbxTransportMethodRef pMyVar;
pMyVar = pImpl->pMyVars[nMyVar++];
if ( nMyVar >= VAR_POOL_SIZE )
nMyVar = 0;
delete pWhatName;
pWhatName = ( (ControlDef*)m_pSIds->GetObject( nElement ) );
2002-11-18 14:54:26 +00:00
pMyVar->SetName( pWhatName->pData->Kurzname );
// FIXME: HELPID
2002-11-18 14:54:26 +00:00
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 )
2002-11-18 14:54:26 +00:00
{
delete pWhatName;
pWhatName = new ControlDef( aStr.Copy( 0, aStr.Len()-3 ), rtl::OString() );
if ( m_pSIds->Seek_Entry( pWhatName, &nElement ) )
{ // look for slots
2002-11-18 14:54:26 +00:00
SbxVariable *pReturn = new SbxVariable;
delete pWhatName;
pWhatName = ( (ControlDef*)m_pSIds->GetObject( nElement ) );
2002-11-18 14:54:26 +00:00
pReturn->SetName( pWhatName->pData->Kurzname );
// FIXME: HELPID
2002-11-18 14:54:26 +00:00
return pReturn;
}
}
if ( !pImpl->bDebugFindNoErrors )
{
ADD_ERROR(SbxERR_PROC_UNDEFINED,GEN_RES_STR1(S_UNKNOWN_SLOT_CONTROL, aStr) );
2002-11-18 14:54:26 +00:00
}
2011-05-16 12:02:52 +02:00
delete pWhatName;
2002-11-18 14:54:26 +00:00
}
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 )
2002-11-18 14:54:26 +00:00
{
bWasPrecompilerError = sal_True;
2002-11-18 14:54:26 +00:00
if ( aCErrorHdl.IsSet() )
{
ErrorEntry aErrorEntry( code, rMsg, l, c1, c2 );
return (sal_Bool)aCErrorHdl.Call( &aErrorEntry );
2002-11-18 14:54:26 +00:00
}
else
{
ADD_ERROR( code, rMsg )
return sal_True;
2002-11-18 14:54:26 +00:00
}
}
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" )
2002-11-18 14:54:26 +00:00
sal_Bool IsAlphaChar( sal_Unicode cChar )
2002-11-18 14:54:26 +00:00
{
return ( cChar >= 'a' && cChar <= 'z' ) ||
2002-11-18 14:54:26 +00:00
( cChar >= 'A' && cChar <= 'Z' );
}
sal_Bool IsInsideString( const String& aSource, const xub_StrLen nStart )
2002-11-18 14:54:26 +00:00
{
sal_Bool bInside = sal_False;
2002-11-18 14:54:26 +00:00
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 )
2002-11-18 14:54:26 +00:00
{
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 )
2002-11-18 14:54:26 +00:00
{
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 )
{
2002-11-18 14:54:26 +00:00
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
2002-11-18 14:54:26 +00:00
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 );
2002-11-18 14:54:26 +00:00
}
void TestToolObj::PreCompileDispatchParts( String &aSource, String aStart, String aEnd, String aFinalLable )
{
sal_uInt16 nLabelCount = 0;
2002-11-18 14:54:26 +00:00
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();
2002-11-18 14:54:26 +00:00
}
}
sal_Bool TestToolObj::WasPrecompilerError()
2002-11-18 14:54:26 +00:00
{
return bWasPrecompilerError;
}
String TestToolObj::PreCompile( String const &aSourceIn )
{
StartListening( ((StarBASIC*)GetParent())->GetBroadcaster(), sal_True );
2002-11-18 14:54:26 +00:00
xub_StrLen nTestCase;
xub_StrLen nEndCase;
xub_StrLen nStartPos = 0;
String aSource(aSourceIn);
bWasPrecompilerError = sal_False;
2002-11-18 14:54:26 +00:00
HACK("Ich gestehe alles: Ich war zu faul das richtig zu machen.")
aSource = String(' ').Append( aSource );
2002-11-18 14:54:26 +00:00
xub_StrLen nComment;
while ( (nComment = aSource.SearchAscii("'",nStartPos)) != STRING_NOTFOUND )
{
sal_uInt16 nStringEndCount = 0;
2002-11-18 14:54:26 +00:00
xub_StrLen nIndex = nComment;
while ( nIndex && aSource.GetChar(nIndex) != '\n' )
{
if ( aSource.GetChar(nIndex) == '"' )
nStringEndCount++;
nIndex--;
}
if ( (nStringEndCount & 1) == 0 )
2002-11-18 14:54:26 +00:00
{
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;
2002-11-18 14:54:26 +00:00
do
{
nOldLen = aSuffix.Len();
aSuffix.EraseLeadingAndTrailingChars( ' ' );
aSuffix.EraseLeadingAndTrailingChars( 0x09 );
} while ( nOldLen != aSuffix.Len() );
aSource.Erase(nTestCase,nTcEnd-nTestCase);
aSource.Insert(CUniString("Sub ").Append(aSuffix).AppendAscii(" CaseLog \"").Append(aSuffix).AppendAscii("\" : on error goto endcse : TestEnter "),nTestCase);
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// Attention!!! The lable endsub is officially used to exit a sub instead of using 'exit sub' or 'return'
/////////////////////////////////////////////////////////////////////////////////////////////////////////
2002-11-18 14:54:26 +00:00
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 );
2002-11-18 14:54:26 +00:00
if ( aSource.Len() >= STRING_MAXLEN )
{
xub_StrLen l,c;
CalcPosition( aSource, 0, l, c );
CError( SbERR_PROG_TOO_LARGE, CUniString("endcatch"), l, c, c+2 );
}
return aSource;
}
void TestToolObj::AddToListByNr( CNames *&pControls, ControlItemUId *&pNewItem )
{
sal_uInt16 nNr;
2002-11-18 14:54:26 +00:00
if ( pControls->Seek_Entry( pNewItem, &nNr ) )
{
AddName( pControls->GetObject(nNr)->pData->Kurzname, pNewItem->pData->Kurzname );
delete pNewItem;
pNewItem = (ControlItemUId*)pControls->GetObject(nNr);
2002-11-18 14:54:26 +00:00
}
else
{
ControlItem* pNI = pNewItem;
pControls->C40_PTR_INSERT(ControlItem,pNI);
}
}
IMPL_LINK( TestToolObj, ReturnResultsLink, CommunicationLink*, pCommLink )
{
return ReturnResults( pCommLink->GetServiceData() );
}
void TestToolObj::ReadHidLstByNumber()
{
if ( !m_pReverseUIds )
2002-11-18 14:54:26 +00:00
{
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 );
2002-11-18 14:54:26 +00:00
{
TTExecutionStatusHint aHint( TT_EXECUTION_HIDE_ACTION );
GetTTBroadcaster().Broadcast( aHint );
}
}
}
void TestToolObj::SortControlsByNumber( sal_Bool bIncludeActive )
2002-11-18 14:54:26 +00:00
{
if ( !m_pReverseControls && !m_pReverseControlsSon && m_pControls )
2002-11-18 14:54:26 +00:00
{
m_pReverseControls = new CNames;
m_pReverseControlsSon = new CNames;
sal_uInt16 nWin,nCont;
2002-11-18 14:54:26 +00:00
const String aSl('/');
for ( nWin = 0 ; nWin < m_pControls->Count() ; nWin++ )
2002-11-18 14:54:26 +00:00
{
String aFatherName( m_pControls->GetObject(nWin)->pData->Kurzname );
ControlItemUId *pNewFather = new ControlItemUIdSon(aFatherName,m_pControls->GetObject(nWin)->pData->aUId);
AddToListByNr( m_pReverseControlsSon, pNewFather );
2002-11-18 14:54:26 +00:00
if (! ((ControlItemUIdSon*)pNewFather)->GetSons() )
((ControlItemUIdSon*)pNewFather)->Sons( new CNames );
CNames *pControlList = ((ControlItemSon*)m_pControls->GetObject(nWin))->GetSons();
2002-11-18 14:54:26 +00:00
if ( pControlList )
for ( nCont = 0 ; nCont < pControlList->Count() ; nCont++ )
{
ControlItemUId *pNewItem;
String aCombinedName( aFatherName );
aCombinedName.AppendAscii( ":" );
aCombinedName.Append( pControlList->GetObject(nCont)->pData->Kurzname );
pNewItem = new ControlItemUId( aCombinedName, pControlList->GetObject(nCont)->pData->aUId );
AddToListByNr( m_pReverseControls, pNewItem );
2002-11-18 14:54:26 +00:00
pNewItem = new ControlItemUId( pControlList->GetObject(nCont)->pData->Kurzname, pControlList->GetObject(nCont)->pData->aUId );
AddToListByNr( ((ControlItemUIdSon*)pNewFather)->GetSons(), pNewItem );
}
}
if ( !bIncludeActive )
{
// FIXME: HELPID
ControlItem *pZeroItem = new ControlItemUId( UniString(), rtl::OString() );
sal_uInt16 nNr;
if ( m_pReverseControls->Seek_Entry( pZeroItem, &nNr ) )
2002-11-18 14:54:26 +00:00
{
m_pReverseControls->DeleteAndDestroy( nNr );
// to prevent VorlagenLaden/UntergeordneteIniDatei/SpeichernDlg/OrdnerDlg/OeffnenDlg/MessageBox/LetzteVersion/GrafikEinfuegenDlg/FarbeDlg/ExportierenDlg/DruckerEinrichten/DruckenDlg/DateiEinfuegenDlg/Active
2002-11-18 14:54:26 +00:00
}
delete pZeroItem;
}
}
}
sal_Bool TestToolObj::ReturnResults( SvStream *pIn )
2002-11-18 14:54:26 +00:00
{
sal_uInt16 nId;
sal_Bool bSequenceOK = sal_True;
2002-11-18 14:54:26 +00:00
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;
2002-11-18 14:54:26 +00:00
pRetStream->Read(nRet);
if ( pRetStream->GetNextType() == BinString )
{
String aUStrId; // UniqueStringID Used for Mozilla Integration
pRetStream->Read( aUStrId );
// FIXME: HELPID
2002-11-18 14:54:26 +00:00
}
else
{
2011-07-07 11:28:13 +02:00
comm_UINT32 nUId;
pRetStream->Read( nUId );
// FIXME: HELPID
2002-11-18 14:54:26 +00:00
}
pRetStream->Read(nParams);
sal_uInt16 nNr1 = 0;
2011-07-07 11:28:13 +02:00
comm_UINT32 nLNr1 = 0;
2002-11-18 14:54:26 +00:00
String aString1;
sal_Bool bBool1 = sal_False;
2002-11-18 14:54:26 +00:00
SbxValueRef xValue1 = new SbxValue;
2011-07-07 11:28:13 +02:00
if( nParams & PARAM_UINT16_1 )
2002-11-18 14:54:26 +00:00
pRetStream->Read( nNr1 );
2011-07-07 11:28:13 +02:00
if( nParams & PARAM_UINT32_1 )
2002-11-18 14:54:26 +00:00
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
2002-11-18 14:54:26 +00:00
}
break;
case RET_Value:
if ( pImpl->pNextReturn )
{
if ( aNextReturnId.equals( aUId ) )
2002-11-18 14:54:26 +00:00
{
2011-07-07 11:28:13 +02:00
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
2002-11-18 14:54:26 +00:00
{
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 )
2002-11-18 14:54:26 +00:00
pReverseControlsKontext = NULL;
ReadHidLstByNumber();
SortControlsByNumber();
if ( !m_pReverseSlots && m_pSIds )
2002-11-18 14:54:26 +00:00
{
m_pReverseSlots = new CNames;
sal_uInt16 nWin;
2002-11-18 14:54:26 +00:00
const String aSl('/');
for ( nWin = 0 ; nWin < m_pSIds->Count() ; nWin++ )
2002-11-18 14:54:26 +00:00
{
ControlItemUId *pNewItem = new ControlItemUId(m_pSIds->GetObject(nWin)->pData->Kurzname,m_pSIds->GetObject(nWin)->pData->aUId);
AddToListByNr( m_pReverseSlots, pNewItem );
2002-11-18 14:54:26 +00:00
}
}
WinInfoRec *pWinInfo = new WinInfoRec;
// FIXME: HELPID
pWinInfo->nRType = (sal_uInt16)nLNr1; // just sal_uLong for Transport, data is always USHORT
2002-11-18 14:54:26 +00:00
pWinInfo->aRName = aString1;
pWinInfo->bIsReset = bBool1;
pWinInfo->aKurzname.Erase();
pWinInfo->aSlotname.Erase();
// detect context maybe - happens only at the first entry after reset
if ( !pReverseControlsKontext && m_pReverseControlsSon )
2002-11-18 14:54:26 +00:00
{
sal_uInt16 nNr;
2002-11-18 14:54:26 +00:00
ControlItem *pNewItem = new ControlItemUId( String(), aUId );
if ( m_pReverseControlsSon->Seek_Entry(pNewItem,&nNr) )
2002-11-18 14:54:26 +00:00
{
pReverseControlsKontext = ((ControlItemUIdSon*)m_pReverseControlsSon->GetObject(nNr))->GetSons();
2002-11-18 14:54:26 +00:00
pWinInfo->aKurzname = CUniString("*");
}
else
pReverseControlsKontext = m_pReverseControls;
2002-11-18 14:54:26 +00:00
delete pNewItem;
}
// Reset. Must be done after determining the context because the context is set the
// wrong way with the reset record otherwise.
2002-11-18 14:54:26 +00:00
if ( pWinInfo->bIsReset )
pReverseControlsKontext = NULL; // order important!
2002-11-18 14:54:26 +00:00
// get short name
2002-11-18 14:54:26 +00:00
if ( pReverseControlsKontext )
{
sal_uInt16 nNr;
2002-11-18 14:54:26 +00:00
ControlItem *pNewItem = new ControlItemUId( String(), aUId );
if ( pReverseControlsKontext->Seek_Entry(pNewItem,&nNr) )
{
2002-11-18 14:54:26 +00:00
pWinInfo->aKurzname += pReverseControlsKontext->GetObject(nNr)->pData->Kurzname;
}
2002-11-18 14:54:26 +00:00
delete pNewItem;
}
if ( m_pReverseSlots )
2002-11-18 14:54:26 +00:00
{
sal_uInt16 nNr;
2002-11-18 14:54:26 +00:00
ControlItem *pNewItem = new ControlItemUId( String(), aUId );
if ( m_pReverseSlots->Seek_Entry(pNewItem,&nNr) )
pWinInfo->aSlotname = m_pReverseSlots->GetObject(nNr)->pData->Kurzname;
2002-11-18 14:54:26 +00:00
delete pNewItem;
}
// FIXME: HELPID
2002-11-18 14:54:26 +00:00
aWinInfoHdl.Call( pWinInfo );
delete pWinInfo;
}
break;
case RET_ProfileInfo:
{
// FIXME: HELPID
2002-11-18 14:54:26 +00:00
}
break;
case RET_DirectLoging:
{
// FIXME: HELPID
2002-11-18 14:54:26 +00:00
}
break;
case RET_MacroRecorder:
{
SortControlsByNumber( sal_True );
2002-11-18 14:54:26 +00:00
String aCommand,aControls,aControl,aULongNames,aULongName;
sal_Bool bWriteNewKontext = sal_False;
2002-11-18 14:54:26 +00:00
aControls.Erase();
if ( m_pReverseControls )
2002-11-18 14:54:26 +00:00
{
sal_uInt16 nNr;
2002-11-18 14:54:26 +00:00
ControlItem *pNewItem = new ControlItemUId( String(), aUId );
if ( m_pReverseControls->Seek_Entry(pNewItem,&nNr) )
aControls = m_pReverseControls->GetObject(nNr)->pData->Kurzname;
2002-11-18 14:54:26 +00:00
delete pNewItem;
}
if ( !aControls.Len() )
{
aControls = String::CreateFromAscii("UnknownControl:UnknownControl");
Sound::Beep( SOUND_WARNING );
}
aULongNames.Erase();
2011-07-07 11:28:13 +02:00
if( (nParams & PARAM_UINT32_1) && (nNr1 & M_RET_NUM_CONTROL) )
2002-11-18 14:54:26 +00:00
{
if ( m_pReverseControls )
2002-11-18 14:54:26 +00:00
{
sal_uInt16 nNr;
2010-06-04 20:07:26 +02:00
// FIXME: HELPID
ControlItem *pNewItem = new ControlItemUId( String(), rtl::OString( /*nLNr1*/ ) );
if ( m_pReverseControls->Seek_Entry(pNewItem,&nNr) )
aULongNames = m_pReverseControls->GetObject(nNr)->pData->Kurzname;
2002-11-18 14:54:26 +00:00
delete pNewItem;
}
if ( !aULongNames.Len() )
{
aULongNames = String::CreateFromAscii("Unknown:Unknown");
Sound::Beep( SOUND_WARNING );
}
// now determine the best common kontext
sal_uInt16 i,j;
sal_Bool bFoundUlongName = sal_False, bFoundControl = sal_False;
2002-11-18 14:54:26 +00:00
// 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;
2002-11-18 14:54:26 +00:00
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;
2002-11-18 14:54:26 +00:00
aULongName = aULongNames.GetToken(i,'/').GetToken( 1,':');
aControl = aControls.GetToken(j,'/').GetToken( 1,':');
aLastRecordedKontext = aCurrentKontext;
bWriteNewKontext = sal_True;
2002-11-18 14:54:26 +00:00
}
}
}
if ( !bFound )
{
// check if both contain toplevel
bFoundUlongName = sal_False;
bFoundControl = sal_False;
2002-11-18 14:54:26 +00:00
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;
2002-11-18 14:54:26 +00:00
}
}
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;
2002-11-18 14:54:26 +00:00
// 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;
2002-11-18 14:54:26 +00:00
aControl = aControls.GetToken(0,'/').GetToken( 1,':');
}
}
if ( bWriteNewKontext )
{
String aKontextCommand = CUniString( "Kontext" );
2002-11-18 14:54:26 +00:00
if ( aLastRecordedKontext.Len() )
{
aKontextCommand.AppendAscii ( " \"" );
aKontextCommand += aLastRecordedKontext;
aKontextCommand.AppendAscii ( "\"" );
2002-11-18 14:54:26 +00:00
}
aKontextCommand.AppendAscii( "\n" );
aWriteStringHdl.Call( &aKontextCommand );
2002-11-18 14:54:26 +00:00
}
aCommand = aControl;
// Add Method name
String aMethod = GetMethodName( nNr1 & ~M_RET_NUM_CONTROL );
aCommand += '.';
aCommand += aMethod;
sal_Bool bWasParam = sal_False;
2002-11-18 14:54:26 +00:00
if( nParams & PARAM_STR_1 )
{
bWasParam = sal_True;
2002-11-18 14:54:26 +00:00
aCommand.AppendAscii( " \"" );
if ( nNr1 & M_KEY_STRING )
{
sal_uInt16 nModify = 0;
sal_Bool bIsProsa = sal_False;
2002-11-18 14:54:26 +00:00
xub_StrLen i;
for ( i = 0; i < aString1.Len(); i++ )
{
if ( ((sal_uInt16)aString1.GetChar(i)) == 1 ) // we have a special char
2002-11-18 14:54:26 +00:00
{
i++;
if ( !bIsProsa )
{
aCommand.AppendAscii( "<" );
bIsProsa = sal_True;
2002-11-18 14:54:26 +00:00
}
else
aCommand.AppendAscii( " " );
sal_uInt16 nKeyCode = (sal_uInt16)aString1.GetChar(i) & KEY_CODE;
sal_uInt16 nNewModify = (sal_uInt16)aString1.GetChar(i) & KEY_MODTYPE;
2002-11-18 14:54:26 +00:00
if ( nNewModify != nModify )
{ // generate modifiers
sal_uInt16 nChanged = ( nNewModify ^ nModify );
2002-11-18 14:54:26 +00:00
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;
2002-11-18 14:54:26 +00:00
}
aCommand += aString1.GetChar(i);
nModify = 0;
}
}
if ( bIsProsa )
{
aCommand.AppendAscii( ">" );
bIsProsa = sal_False;
2002-11-18 14:54:26 +00:00
}
}
else
{
aCommand += aString1;
}
aCommand.AppendAscii( "\"" );
}
2011-07-07 11:28:13 +02:00
if( nParams & PARAM_UINT32_1 )
2002-11-18 14:54:26 +00:00
{
if ( bWasParam )
aCommand.AppendAscii( ", " );
else
aCommand.AppendAscii( " " );
bWasParam = sal_True;
2002-11-18 14:54:26 +00:00
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;
2002-11-18 14:54:26 +00:00
if ( bBool1 )
aCommand.AppendAscii( "true" );
else
aCommand.AppendAscii( "false" );
}
aCommand.AppendAscii( "\n" );
aWriteStringHdl.Call( &aCommand );
}
break;
default:
2011-03-04 21:30:05 +01:00
OSL_TRACE( "Unbekannter Return Code: %iu", nRet );
2002-11-18 14:54:26 +00:00
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
{
2011-07-07 11:28:13 +02:00
comm_UINT32 nUId;
pRetStream->Read( nUId );
// FIXME: HELPID
}
2002-11-18 14:54:26 +00:00
pRetStream->Read( aString );
ReplaceNumbers (aString);
String aShortName;
aShortName = pShortNames->GetName(aUId);
2002-11-18 14:54:26 +00:00
aShortName.AppendAscii( " : " );
String aTmpStr(aShortName);
aTmpStr += aString;
ADD_ERROR(SbxERR_BAD_ACTION, aTmpStr/*, nNr*/);
break;
}
default:
2011-03-04 21:30:05 +01:00
OSL_TRACE( "Unbekannter Request im Return Stream Nr: %iu", nId );
2002-11-18 14:54:26 +00:00
break;
}
if( !pIn->IsEof() )
pRetStream->Read( nId );
else
{
2011-03-01 17:55:09 +01:00
OSL_FAIL( "truncated input stream" );
2002-11-18 14:54:26 +00:00
}
}
delete pRetStream;
if ( bSequenceOK )
{
sal_uLong nClearSequence = 0; // before a lot of code was deleted, this was a funct. global var.
2002-11-18 14:54:26 +00:00
nSequence++;
pShortNames->Invalidate( nClearSequence - KEEP_SEQUENCES );
}
bReturnOK = sal_True;
2002-11-18 14:54:26 +00:00
return sal_True;
2002-11-18 14:54:26 +00:00
} // RetService::Request()
String TestToolObj::GetMethodName( sal_uLong nMethodId )
2002-11-18 14:54:26 +00:00
{
sal_uInt16 nElement;
if ( !Controls::pClasses )
2002-11-18 14:54:26 +00:00
ReadFlatArray( Controls::arClasses, Controls::pClasses );
if ( Controls::pClasses )
{
// FIXME: HELPID
(void)nElement;
2010-06-04 19:27:35 +02:00
(void)nMethodId;
2002-11-18 14:54:26 +00:00
}
return String();
}
String TestToolObj::GetKeyName( sal_uInt16 nKeyCode )
2002-11-18 14:54:26 +00:00
{
sal_uInt16 nElement;
if ( !CmdStream::pKeyCodes )
2002-11-18 14:54:26 +00:00
ReadFlatArray( CmdStream::arKeyCodes, CmdStream::pKeyCodes );
if ( CmdStream::pKeyCodes )
{
// FIXME: HELPID
(void)nElement;
2010-06-04 19:27:35 +02:00
(void)nKeyCode;
2002-11-18 14:54:26 +00:00
}
return CUniString( "UnknownKeyCode" );
}
void TestToolObj::ReplaceNumbers(String &aText)
{
static ControlDefLoad const arRes_Type [] =
2002-11-18 14:54:26 +00:00
#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;
2002-11-18 14:54:26 +00:00
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;
2002-11-18 14:54:26 +00:00
if ( aType.CompareTo(UIdKenn) == COMPARE_EQUAL )
{
2010-06-04 20:07:26 +02:00
// FIXME: HELPID
aResult = pShortNames->GetName(rtl::OString(/*nNumber*/));
bFound = sal_True;
2002-11-18 14:54:26 +00:00
}
if ( aType.CompareTo(MethodKenn ) == COMPARE_EQUAL )
{
bFound = sal_True;
2002-11-18 14:54:26 +00:00
aResult = GetMethodName( nNumber );
}
if ( aType.CompareTo(RcKenn ) == COMPARE_EQUAL )
{
bFound = sal_True;
if ( !pRCommands )
2002-11-18 14:54:26 +00:00
ReadFlatArray( arR_Cmds, pRCommands );
sal_uInt16 nElement;
2002-11-18 14:54:26 +00:00
if ( pRCommands )
{
// FIXME: HELPID
(void)nElement;
2002-11-18 14:54:26 +00:00
}
}
if ( aType.CompareTo(TypeKenn ) == COMPARE_EQUAL )
{
bFound = sal_True;
if ( !pRTypes )
2002-11-18 14:54:26 +00:00
ReadFlatArray( arRes_Type, pRTypes );
sal_uInt16 nElement;
2002-11-18 14:54:26 +00:00
if ( pRTypes )
{
// FIXME: HELPID
(void)nElement;
2002-11-18 14:54:26 +00:00
}
}
if ( aType.CompareTo(SlotKenn ) == COMPARE_EQUAL )
{
2010-06-04 20:07:26 +02:00
// FIXME: HELPID
aResult = pShortNames->GetName(rtl::OString(/*nNumber*/));
bFound = sal_True;
2002-11-18 14:54:26 +00:00
}
if ( aType.CompareTo(TabKenn ) == COMPARE_EQUAL )
{
if ( nNumber > nStart )
aResult.Fill( (sal_uInt16)nNumber - nStart +1 );
2002-11-18 14:54:26 +00:00
else
aResult = CUniString(" ");
bFound = sal_True;
2002-11-18 14:54:26 +00:00
}
nStartPos = nStart;
if ( bFound )
{
aText.Erase(nStart,nEnd+EndKenn.Len()-nStart);
aText.Insert(aResult,nStart);
nStartPos = nStartPos + aResult.Len();
2002-11-18 14:54:26 +00:00
}
else
nStartPos = nStartPos + StartKenn.Len();
2002-11-18 14:54:26 +00:00
}
}
SbTextType TestToolObj::GetSymbolType( const String &rSymbol, sal_Bool bWasControl )
2002-11-18 14:54:26 +00:00
{
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 )
2002-11-18 14:54:26 +00:00
{
return TT_KEYWORD;
}
ControlDef WhatName( rSymbol, rtl::OString() );
2002-11-18 14:54:26 +00:00
if ( bWasControl )
{
if ( !Controls::pClasses )
2002-11-18 14:54:26 +00:00
ReadFlatArray( Controls::arClasses, Controls::pClasses );
CWS-TOOLING: integrate CWS cmcfixes51 2008-12-08 10:12:55 +0100 cmc r264975 : #i96203# protect with ifdefs to avoid unused symbol on mac 2008-12-05 12:23:47 +0100 cmc r264898 : CWS-TOOLING: rebase CWS cmcfixes51 to trunk@264807 (milestone: DEV300:m37) 2008-12-01 14:45:17 +0100 cmc r264606 : #i76655# ehlos apparently required 2008-11-28 17:49:30 +0100 cmc r264567 : #i96655# remove newly unused method 2008-11-28 10:41:28 +0100 cmc r264531 : #i96647# better ppc-bridges flushCode impl 2008-11-27 12:58:40 +0100 cmc r264478 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 12:32:49 +0100 cmc r264476 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 12:26:02 +0100 cmc r264475 : #i96655# redundant old table export helpers 2008-11-27 11:49:06 +0100 cmc r264473 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 11:38:35 +0100 cmc r264471 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 11:14:21 +0100 cmc r264467 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 11:06:22 +0100 cmc r264464 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 10:58:18 +0100 cmc r264462 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 10:41:44 +0100 cmc r264461 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 10:19:24 +0100 cmc r264460 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 10:13:39 +0100 cmc r264459 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 10:06:14 +0100 cmc r264458 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 09:59:54 +0100 cmc r264457 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 09:52:51 +0100 cmc r264456 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 09:48:26 +0100 cmc r264454 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 09:40:20 +0100 cmc r264452 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 09:35:26 +0100 cmc r264451 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 09:31:00 +0100 cmc r264450 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 09:24:08 +0100 cmc r264449 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 00:26:15 +0100 cmc r264443 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 00:21:01 +0100 cmc r264442 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 00:09:40 +0100 cmc r264441 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 23:51:56 +0100 cmc r264440 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 23:49:09 +0100 cmc r264439 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 18:09:54 +0100 cmc r264432 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 18:07:40 +0100 cmc r264431 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 17:28:02 +0100 cmc r264429 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 17:27:39 +0100 cmc r264428 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 17:18:36 +0100 cmc r264426 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 16:22:16 +0100 cmc r264415 : #i96624# make implicit braces and brackets explicit to avoid warnings 2008-11-26 16:00:23 +0100 cmc r264409 : #i90426# remove warnings from svtools 2008-11-26 15:59:17 +0100 cmc r264408 : #i90426# remove warnings 2008-11-26 15:47:32 +0100 cmc r264404 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 14:46:57 +0100 cmc r264394 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 14:19:50 +0100 cmc r264387 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 14:15:26 +0100 cmc r264386 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 14:11:26 +0100 cmc r264384 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 13:44:23 +0100 cmc r264380 : #i96084# comfirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 13:12:24 +0100 cmc r264372 : #i96604# silence new warnings 2008-11-26 12:35:02 +0100 cmc r264369 : #i96203# make qstarter work in 3-layer land 2008-11-26 12:33:04 +0100 cmc r264368 : #i96170# ensure gtypes are up and running
2008-12-11 07:05:03 +00:00
if ( (Controls::pClasses && Controls::pClasses->Seek_Entry( &WhatName ))
|| rSymbol.EqualsIgnoreCaseAscii( "ID" )
|| rSymbol.EqualsIgnoreCaseAscii( "Name" ) )
2002-11-18 14:54:26 +00:00
return TT_METHOD;
else
return TT_NOMETHOD;
}
if ( m_pControls )
2002-11-18 14:54:26 +00:00
{
sal_uInt16 nWin;
2002-11-18 14:54:26 +00:00
for ( nWin = 0 ; nWin < m_pControls->Count() ; nWin++ )
2002-11-18 14:54:26 +00:00
{
if ( ((ControlDef*)m_pControls->GetObject( nWin ))->SonSeek_Entry( &WhatName ) )
2002-11-18 14:54:26 +00:00
return TT_CONTROL;
}
}
if ( m_pSIds && m_pSIds->Seek_Entry( &WhatName ) )
2002-11-18 14:54:26 +00:00
return TT_SLOT;
if ( !pRCommands )
2002-11-18 14:54:26 +00:00
ReadFlatArray( arR_Cmds, pRCommands );
if ( pRCommands && pRCommands->Seek_Entry( &WhatName ) )
return TT_REMOTECMD;
2002-11-18 14:54:26 +00:00
SbxVariable *pVar = SbxObject::Find( rSymbol, SbxCLASS_DONTCARE );
if ( pVar && ( pVar->ISA(SbxMethod) || pVar->ISA(SbxProperty) ) )
{
return TT_LOCALCMD;
}
return SB_SYMBOL;
2002-11-18 14:54:26 +00:00
}
#undef P_FEHLERLISTE
#define P_FEHLERLISTE TestToolObj::pFehlerListe
2002-11-18 14:54:26 +00:00
Controls::Controls( String aCName )
: SbxObject( aCName)
2002-11-18 14:54:26 +00:00
{
pMethodVar = new SbxTransportMethod( SbxVARIANT );
pMethodVar->SetName( CUniString("Dummy") );
2002-11-18 14:54:26 +00:00
Insert( pMethodVar );
}
Controls::~Controls()
{}
void Controls::ChangeListener( SbxObject* parent )
2002-11-18 14:54:26 +00:00
{
EndListening( pMethodVar->GetBroadcaster(), sal_True );
parent->StartListening( pMethodVar->GetBroadcaster(), sal_True );
2002-11-18 14:54:26 +00:00
}
void Controls::SFX_NOTIFY( SfxBroadcaster&, const TypeId&,
const SfxHint&, const TypeId& )
2002-11-18 14:54:26 +00:00
{}
SbxVariable* Controls::Find( const String& aStr, SbxClassType aType)
2002-11-18 14:54:26 +00:00
{
if ( !pClasses )
2002-11-18 14:54:26 +00:00
ReadFlatArray( arClasses, pClasses );
if ( GetUserData() == ID_ErrorDummy )
{
pMethodVar->SetName(UniString(GetName()).AppendAscii(".").Append(aStr));
2002-11-18 14:54:26 +00:00
pMethodVar->SetUserData( ID_ErrorDummy );
return pMethodVar;
}
sal_uInt16 nElement;
ControlDef WhatName(aStr,rtl::OString());
2002-11-18 14:54:26 +00:00
if (pClasses && pClasses->Seek_Entry(&WhatName,&nElement))
{
pMethodVar->SetName(aStr);
// FIXME: HELPID
sal_uLong nUId = 0;
2002-11-18 14:54:26 +00:00
pMethodVar->nValue = nUId;
pMethodVar->SetUserData( GetUserData() );
2002-11-18 14:54:26 +00:00
return pMethodVar;
}
else
{ // mainly for ID and name
SbxVariableRef Old = SbxObject::Find(aStr, aType );
2002-11-18 14:54:26 +00:00
if (Old)
return Old;
else if ( aStr.EqualsIgnoreCaseAscii("ID") )
2002-11-18 14:54:26 +00:00
return NULL; // suppress generation of error in this case
}
ADD_ERROR(SbxERR_BAD_METHOD,GEN_RES_STR2(S_UNKNOWN_METHOD, GetName(), aStr));
2002-11-18 14:54:26 +00:00
return NULL;
}
String TTFormat::ms2s( sal_uLong nMilliSeconds )
2002-11-18 14:54:26 +00:00
{
if ( nMilliSeconds < 100000 )
2002-11-18 14:54:26 +00:00
return String::CreateFromInt64( nMilliSeconds );
if ( nMilliSeconds < 100000*60 )
2002-11-18 14:54:26 +00:00
return String::CreateFromInt32( nMilliSeconds / 1000 ).AppendAscii("Sec");
return String::CreateFromInt32( nMilliSeconds / 1000 / 60 ).AppendAscii("Min");
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */