summaryrefslogtreecommitdiff
path: root/basic
diff options
context:
space:
mode:
authorAugust Sodora <augsod@gmail.com>2011-12-08 23:59:57 -0500
committerAugust Sodora <augsod@gmail.com>2011-12-08 23:59:57 -0500
commit99ec322768053a6341ec7b5b6c6e533fb478bbfa (patch)
tree9aabd9bac7f274e5da9bedd8559b3652ab6a31e0 /basic
parent3f5225ab63f7a1b1ebeb4dab375081ad7032872f (diff)
Remove archaic tests
Diffstat (limited to 'basic')
-rw-r--r--basic/Module_basic.mk1
-rw-r--r--basic/StaticLibrary_sample.mk48
-rw-r--r--basic/source/inc/collelem.hxx50
-rw-r--r--basic/source/sample/collelem.cxx79
-rw-r--r--basic/source/sample/object.cxx258
-rw-r--r--basic/source/sample/sample.bas39
-rw-r--r--basic/workben/mgrtest.cxx591
7 files changed, 0 insertions, 1066 deletions
diff --git a/basic/Module_basic.mk b/basic/Module_basic.mk
index 58ac0354cb6c..0fafc6c5dc8e 100644
--- a/basic/Module_basic.mk
+++ b/basic/Module_basic.mk
@@ -32,7 +32,6 @@ $(eval $(call gb_Module_add_targets,basic,\
AllLangResTarget_sb \
Library_sb \
Package_inc \
- StaticLibrary_sample \
))
$(eval $(call gb_Module_add_check_targets,basic,\
diff --git a/basic/StaticLibrary_sample.mk b/basic/StaticLibrary_sample.mk
deleted file mode 100644
index 2173a4250fff..000000000000
--- a/basic/StaticLibrary_sample.mk
+++ /dev/null
@@ -1,48 +0,0 @@
-# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
-#*************************************************************************
-#
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# Copyright 2000, 2011 Oracle and/or its affiliates.
-#
-# OpenOffice.org - a multi-platform office productivity suite
-#
-# This file is part of OpenOffice.org.
-#
-# OpenOffice.org is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Lesser General Public License version 3
-# only, as published by the Free Software Foundation.
-#
-# OpenOffice.org is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Lesser General Public License version 3 for more details
-# (a copy is included in the LICENSE file that accompanied this code).
-#
-# You should have received a copy of the GNU Lesser General Public License
-# version 3 along with OpenOffice.org. If not, see
-# <http://www.openoffice.org/license.html>
-# for a copy of the LGPLv3 License.
-#
-#*************************************************************************
-
-$(eval $(call gb_StaticLibrary_StaticLibrary,sample))
-
-$(eval $(call gb_StaticLibrary_add_package_headers,sample,basic_inc))
-
-$(eval $(call gb_StaticLibrary_set_include,sample,\
- $$(INCLUDE) \
- -I$(realpath $(SRCDIR)/basic/source/inc) \
-))
-
-$(eval $(call gb_StaticLibrary_add_api,sample,\
- udkapi \
- offapi \
-))
-
-$(eval $(call gb_StaticLibrary_add_exception_objects,sample,\
- basic/source/sample/collelem \
- basic/source/sample/object \
-))
-
-# vim: set noet sw=4 ts=4:
diff --git a/basic/source/inc/collelem.hxx b/basic/source/inc/collelem.hxx
deleted file mode 100644
index 8465fd4e462d..000000000000
--- a/basic/source/inc/collelem.hxx
+++ /dev/null
@@ -1,50 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-#ifndef _SAMPLE_COLLELEM_HXX
-#define _SAMPLE_COLLELEM_HXX
-
-#include <basic/sbxobj.hxx>
-
-// The sample-element is a small object that contains the
-// properties name and value and the method Say which couples
-// the passed text with its own name. The name can be set from
-// outside. Implementation works with dynamic elements only.
-
-class SampleElement : public SbxObject
-{
- // Broadcaster Notification
- virtual void SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType,
- const SfxHint& rHint, const TypeId& rHintType );
-public:
- SampleElement( const String& );
-};
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basic/source/sample/collelem.cxx b/basic/source/sample/collelem.cxx
deleted file mode 100644
index dc8feb59334a..000000000000
--- a/basic/source/sample/collelem.cxx
+++ /dev/null
@@ -1,79 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-#include <tools/errcode.hxx>
-#include <vcl/msgbox.hxx>
-#include <basic/sbx.hxx>
-#include "collelem.hxx"
-
-// The sample-element is a small object that contains the properties
-// name and value and the method say, which couples the passed text
-// with its own name and outputs it.
-
-SampleElement::SampleElement( const String& r ) : SbxObject( r )
-{
- // method say with a string-parameter
- SbxVariable* pMeth = Make( String( RTL_CONSTASCII_USTRINGPARAM("Say") ), SbxCLASS_METHOD, SbxEMPTY );
- pMeth->SetUserData( 0x12345678 );
- pMeth->ResetFlag( SBX_FIXED );
- SbxInfo* pInfo_ = new SbxInfo;
- pInfo_->AddParam( String( RTL_CONSTASCII_USTRINGPARAM("text") ), SbxSTRING, SBX_READ );
- pMeth->SetInfo( pInfo_ );
-}
-
-void SampleElement::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType,
- const SfxHint& rHint, const TypeId& rHintType )
-{
- const SbxHint* pHint = PTR_CAST(SbxHint,&rHint);
- if( pHint )
- {
- SbxVariable* pVar = pHint->GetVar();
- SbxArray* pPar_ = pVar->GetParameters();
- sal_uIntPtr t = pHint->GetId();
- if( t == SBX_HINT_DATAWANTED && pVar->GetUserData() == 0x12345678 )
- {
- // the say-method:
- // 1 parameter + return value
- if( !pPar_ || pPar_->Count() != 2 )
- SetError( SbxERR_WRONG_ARGS );
- else
- {
- String s( GetName() );
- s.AppendAscii( " says: " );
- s += pPar_->Get( 1 )->GetString();
- pPar_->Get( 0 )->SetType(SbxSTRING);
- pPar_->Get( 0 )->PutString( s );
- InfoBox( NULL, s ).Execute();
- }
- return;
- }
- SbxObject::SFX_NOTIFY( rBC, rBCType, rHint, rHintType );
- }
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basic/source/sample/object.cxx b/basic/source/sample/object.cxx
deleted file mode 100644
index 3d001624b967..000000000000
--- a/basic/source/sample/object.cxx
+++ /dev/null
@@ -1,258 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-#include <tools/errcode.hxx>
-#include <basic/sbxobj.hxx>
-#include <basic/sbx.hxx>
-#include <basic/sbxvar.hxx>
-#include <vcl/msgbox.hxx>
-
-#include "object.hxx"
-#include "collelem.hxx"
-
-// The sample-object has got the following elements:
-// 1) Properties:
-// Name the name
-// Value a double-value, both already as default
-// 2) Methods:
-// Create creating a new sub-element
-// Display display a text
-// Square Argument * Argument
-// Event calling a basic event handler
-// 3) Subobjects:
-// With Create() a new sub-element can be established, which
-// can be indexed if multiple objects of the same name exist.
-// This implementation is an example for a table-controlled version,
-// which can contain a lot of elements. The elements are taken from
-// the table into the object as required.
-// The collection can be found in COLLECTN.*, the collection's
-// objects in COLLELEM.*
-
-// The sample-object is in ..\app\mybasic.cxx implemented as follows
-// in StarBASIC:
-
-
-// The nArgs-field of a table entry is encrypted as follows:
-
-#define _ARGSMASK 0x00FF // up to 255 arguments
-#define _RWMASK 0x0F00 // mask for R/W-bits
-#define _TYPEMASK 0xF000 // mask for the entry's type
-
-#define _READ 0x0100 // can be read
-#define _BWRITE 0x0200 // can be used as Lvalue
-#define _LVALUE _BWRITE // can be used as Lvalue
-#define _READWRITE 0x0300 // both
-#define _OPT 0x0400 // sal_True: optional parameter
-#define _METHOD 0x1000 // mask-bit for a method
-#define _PROPERTY 0x2000 // mask-bit for a property
-#define _COLL 0x4000 // mask-bit for a collection
- // combination of the bits above:
-#define _FUNCTION 0x1100 // mask for function
-#define _LFUNCTION 0x1300 // mask for function that also works as Lvalue
-#define _ROPROP 0x2100 // mask Read Only-Property
-#define _WOPROP 0x2200 // mask Write Only-Property
-#define _RWPROP 0x2300 // mask Read/Write-Property
-#define _COLLPROP 0x4100 // mask Read-Collection-Element
-
-SampleObject::Methods SampleObject::aMethods[] = {
-// a sample-method (the return value is SbxNULL)
-{ "Display", SbxEMPTY, &SampleObject::Display, 1 | _FUNCTION },
- // a named parameter
- { "message", SbxSTRING, NULL, 0 },
-// a sample-function
-{ "Square", SbxDOUBLE, &SampleObject::Square, 1 | _FUNCTION },
- // a named parameter
- { "value", SbxDOUBLE, NULL, 0 },
-// Basic-Callback
-{ "Event", SbxEMPTY, &SampleObject::Event, 1 | _FUNCTION },
- // a named parameter
- { "event", SbxSTRING, NULL, 0 },
-// create element
-{ "Create", SbxEMPTY, &SampleObject::Create, 1 | _FUNCTION },
- // a named parameter
- { "name", SbxSTRING, NULL, 0 },
-
-{ NULL, SbxNULL, NULL, -1 }}; // end of the table
-
-SampleObject::SampleObject( const String& rClass ) : SbxObject( rClass )
-{
- SetName( String( RTL_CONSTASCII_USTRINGPARAM("Sample") ) );
- PutDouble( 1.0 );
-}
-
-// Finding an element:
-// It goes linearly through the method table until an adequate
-// method is found.
-// If the method/property hasn't been found, return only NULL
-// without error code so that a whole chain of objects can be
-// asked for their method/property.
-
-SbxVariable* SampleObject::Find( const String& rName, SbxClassType t )
-{
- SbxVariable* pRes = SbxObject::Find( rName, t );
- if( !pRes && t != SbxCLASS_OBJECT )
- {
- Methods* p = aMethods;
- short nIndex = 0;
- sal_Bool bFound = sal_False;
- while( p->nArgs != -1 )
- {
- if( rName.EqualsIgnoreCaseAscii( p->pName ) )
- {
- bFound = sal_True; break;
- }
- nIndex += ( p->nArgs & _ARGSMASK ) + 1;
- p = aMethods + nIndex;
- }
- if( bFound )
- {
- // isolate args-fields:
- short nAccess = ( p->nArgs & _RWMASK ) >> 8;
- short nType = ( p->nArgs & _TYPEMASK );
- String aName_ = String::CreateFromAscii( p->pName );
- SbxClassType eCT = SbxCLASS_OBJECT;
- if( nType & _PROPERTY )
- eCT = SbxCLASS_PROPERTY;
- else if( nType & _METHOD )
- eCT = SbxCLASS_METHOD;
- pRes = Make( aName_, eCT, p->eType );
- // We set the array-index + 1 because there are other standard-
- // properties existing which have to activated too.
- pRes->SetUserData( nIndex + 1 );
- pRes->SetFlags( nAccess );
- }
- }
- return pRes;
-}
-
-// activation of an element or ask for an info block
-
-void SampleObject::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCT,
- const SfxHint& rHint, const TypeId& rHT )
-{
- const SbxHint* pHint = PTR_CAST(SbxHint,&rHint);
- if( pHint )
- {
- SbxVariable* pVar = pHint->GetVar();
- SbxArray* pPar_ = pVar->GetParameters();
- sal_uInt16 nIndex = (sal_uInt16) pVar->GetUserData();
- // no index: hand on!
- if( nIndex )
- {
- sal_uIntPtr t = pHint->GetId();
- if( t == SBX_HINT_INFOWANTED )
- pVar->SetInfo( GetInfo( (short) pVar->GetUserData() ) );
- else
- {
- sal_Bool bWrite = sal_False;
- if( t == SBX_HINT_DATACHANGED )
- bWrite = sal_True;
- if( t == SBX_HINT_DATAWANTED || bWrite )
- {
- // parameter-test for methods:
- sal_uInt16 nPar = aMethods[ --nIndex ].nArgs & 0x00FF;
- // element 0 is the return value
- if( ( !pPar_ && nPar )
- || ( pPar_->Count() != nPar+1 ) )
- SetError( SbxERR_WRONG_ARGS );
- // alright, the call can be done
- else
- {
- (this->*(aMethods[ nIndex ].pFunc))( pVar, pPar_, bWrite );
- }
- }
- }
- }
- SbxObject::SFX_NOTIFY( rBC, rBCT, rHint, rHT );
- }
-}
-
-// construction of the info structure for single elements
-
-SbxInfo* SampleObject::GetInfo( short nIdx )
-{
- Methods* p = &aMethods[ nIdx ];
- SbxInfo* pInfo_ = new SbxInfo;
- short nPar = p->nArgs & _ARGSMASK;
- for( short i = 0; i < nPar; i++ )
- {
- p++;
- String aName_ = String::CreateFromAscii( p->pName );
- sal_uInt16 nFlags_ = ( p->nArgs >> 8 ) & 0x03;
- if( p->nArgs & _OPT )
- nFlags_ |= SBX_OPTIONAL;
- pInfo_->AddParam( aName_, p->eType, nFlags_ );
- }
- return pInfo_;
-}
-
-
-// Properties and methods lay down the return value in element 0 of the
-// Argv at Get (bPut = sal_False); at Put (bPut = sal_True) the value from
-// element 0 is saved.
-
-
-void SampleObject::Display( SbxVariable*, SbxArray* pPar_, sal_Bool )
-{
- // GetString() might perhaps cause an error!
- String s( pPar_->Get( 1 )->GetString() );
- if( !IsError() )
- InfoBox( NULL, s ).Execute();
-}
-
-void SampleObject::Square( SbxVariable* pVar, SbxArray* pPar_, sal_Bool )
-{
- double n = pPar_->Get( 1 )->GetDouble();
- pVar->PutDouble( n * n );
-}
-
-// Callback to BASIC:
-
-void SampleObject::Event( SbxVariable*, SbxArray* pPar_, sal_Bool )
-{
- Call( pPar_->Get( 1 )->GetString(), NULL );
-}
-
-
-void SampleObject::Create( SbxVariable* pVar, SbxArray* pPar_, sal_Bool )
-{
- pVar->PutObject(
- MakeObject( pPar_->Get( 1 )->GetString(), String( RTL_CONSTASCII_USTRINGPARAM("SampleElement") ) ) );
-}
-
-
-SbxObject* SampleObjectFac::CreateObject( const String& rClass )
-{
- if( rClass.EqualsIgnoreCaseAscii( "SampleObject" ) )
- return new SampleObject( rClass );
- if( rClass.EqualsIgnoreCaseAscii( "SampleElement" ) )
- return new SampleElement( rClass );
- return NULL;
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basic/source/sample/sample.bas b/basic/source/sample/sample.bas
deleted file mode 100644
index d0e416871af0..000000000000
--- a/basic/source/sample/sample.bas
+++ /dev/null
@@ -1,39 +0,0 @@
-' Sample-Programm fuer Sample-Objekte
-
-Sub Main
- Dim Sample As SampleObject
- Dim Element1 As Object, Element2 As Object
- Set Element1 = Sample!Create "Objekt"
- Set Element2 = Sample.Create "Objekt"
- Element1 = "Element 1"
- Element2 = "Element 2"
- For i = 0 to 1
- Print Sample.Objekt( i )
- Next
- 'Test der Event-Methode im Sample-Objekt
- Sample.Event "Bang"
-End Sub
-
-Sub Bang
- print "Sample-Callback: BANG!"
-End Sub
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/basic/workben/mgrtest.cxx b/basic/workben/mgrtest.cxx
deleted file mode 100644
index d2aefbfc6b8f..000000000000
--- a/basic/workben/mgrtest.cxx
+++ /dev/null
@@ -1,591 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-#include <vcl/svapp.hxx>
-#include <vcl/wrkwin.hxx>
-#include <vcl/toolbox.hxx>
-#include <vcl/msgbox.hxx>
-#include <vcl/sound.hxx>
-#include <basic/basmgr.hxx>
-#include <basic/sbx.hxx>
-#include <basic/sbmod.hxx>
-#include <basic/basrdll.hxx>
-
-//#include <sv.hxx>
-//#include <basic.hxx>
-//#include <sostor.hxx>
-
-// Defines for ToolBox-Id's
-#define TB_NEW 1
-#define TB_OPENSTORAGE 2
-#define TB_SAVESTORAGE 3
-#define TB_ORG 4
-#define TB_CREATELIB1 10
-#define TB_CREATELIB2 11
-#define TB_CREATELIB3 12
-#define TB_LOADLIB1 20
-#define TB_LOADLIB2 21
-#define TB_LOADLIB3 22
-#define TB_STORELIBX 30
-#define TB_UNLOADX 31
-#define TB_LOADX 32
-#define TB_EXECX 33
-#define TB_REMOVEX 34
-#define TB_REMOVEDELX 35
-
-#define TB_LIB0 40
-#define TB_LIB1 41
-#define TB_LIB2 42
-#define TB_LIB3 43
-
-const char* pLib1Str = "Lib1";
-const char* pLib2Str = "Lib2";
-const char* pLib3Str = "Lib3";
-
-// Test-Application
-class TestApp : public Application
-{
-public:
- virtual void Main( void );
- virtual void Main( int, char*[] );
-};
-
-// Test-Window with a ToolBox to choose a test from
-// and the typically used virtual methods
-class TestWindow : public WorkWindow
-{
-private:
- ToolBox aToolBox;
- BasicManager* pBasMgr;
-
- void CheckError();
- sal_uInt16 nLibX;
- DECL_LINK( BasicErrorHdl, StarBASIC * );
-
-
-public:
- TestWindow();
- ~TestWindow();
-
- virtual void Paint( const Rectangle& );
- virtual void Resize();
- virtual void KeyInput( const KeyEvent& rKeyEvt );
- virtual void MouseMove( const MouseEvent& rMEvt );
- virtual void MouseButtonDown( const MouseEvent& rMEvt );
- virtual void MouseButtonUp( const MouseEvent& rMEvt );
-
- DECL_LINK( TBSelect, ToolBox * );
- void UpdateToolBox();
- void ShowInfo();
-};
-
-TestWindow::~TestWindow()
-{
-}
-
-TestWindow::TestWindow() :
- WorkWindow( NULL, WB_APP | WB_STDWORK | WB_3DLOOK | WB_CLIPCHILDREN ) ,
- aToolBox( this, WinBits( WB_BORDER | WB_3DLOOK | WB_SCROLL | WB_LINESPACING ) )
-{
- nLibX = 0;
-
- aToolBox.SetButtonType( BUTTON_TEXT );
- aToolBox.SetLineCount( 2 );
- aToolBox.SetPosPixel( Point( 0, 0 ) );
- aToolBox.SetSelectHdl( LINK( this, TestWindow, TBSelect ) );
-
- Font aFont;
- aFont.SetName( "Helv" );
- aFont.SetSize( Size( 0, 6 ) );
- aFont.SetPitch( PITCH_VARIABLE );
- aFont.SetFamily( FAMILY_SWISS );
- aFont.SetTransparent( sal_True );
- aFont.SetAlign( ALIGN_TOP );
- aToolBox.SetFont( aFont );
- SetFont( aFont );
-
- aToolBox.InsertItem( TB_NEW, "New" );
- aToolBox.SetHelpText( TB_NEW, "New BasicManager" );
- aToolBox.InsertItem( TB_OPENSTORAGE, "Load" );
- aToolBox.SetHelpText( TB_OPENSTORAGE, "Load Storage D:\\MYSTORE.SVS" );
- aToolBox.InsertItem( TB_SAVESTORAGE, "Save" );
- aToolBox.SetHelpText( TB_SAVESTORAGE, "Save Storage D:\\MYSTORE.SVS" );
-
- aToolBox.InsertSeparator();
-
- aToolBox.InsertItem( TB_ORG, "Verwalten" );
- aToolBox.SetHelpText( TB_ORG, "Libaries verwalten" );
-
- aToolBox.InsertSeparator();
-
- aToolBox.InsertItem( TB_LIB0, "0" );
- aToolBox.SetHelpText( TB_LIB0, "Aktuelle Lib: STANDARD" );
- aToolBox.InsertItem( TB_LIB1, "1" );
- aToolBox.SetHelpText( TB_LIB1, "Aktuelle Lib: 1" );
- aToolBox.InsertItem( TB_LIB2, "2" );
- aToolBox.SetHelpText( TB_LIB2, "Aktuelle Lib: 2" );
- aToolBox.InsertItem( TB_LIB3, "3" );
- aToolBox.SetHelpText( TB_LIB3, "Aktuelle Lib: 3" );
-
- aToolBox.InsertBreak();
- aToolBox.InsertItem( TB_CREATELIB1, "CreateLib1" );
- aToolBox.SetHelpText( TB_CREATELIB1, "Create Libary LIB1" );
- aToolBox.InsertItem( TB_CREATELIB2, "CreateLib2" );
- aToolBox.SetHelpText( TB_CREATELIB2, "Create Libary LIB2" );
- aToolBox.InsertItem( TB_CREATELIB3, "CreateLib3" );
- aToolBox.SetHelpText( TB_CREATELIB3, "Create Libary LIB3" );
-
- aToolBox.InsertSeparator();
- aToolBox.InsertItem( TB_LOADLIB1, "LoadLib1" );
- aToolBox.SetHelpText( TB_LOADLIB1, "Load Libary LIB1" );
- aToolBox.InsertItem( TB_LOADLIB2, "LoadLib2" );
- aToolBox.SetHelpText( TB_LOADLIB2, "Load Libary LIB2" );
- aToolBox.InsertItem( TB_LOADLIB3, "LoadLib3" );
- aToolBox.SetHelpText( TB_LOADLIB3, "Load Libary LIB3" );
-
- aToolBox.InsertSeparator();
- aToolBox.InsertItem( TB_STORELIBX, "StoreLibX" );
- aToolBox.SetHelpText( TB_STORELIBX, "Store Libary LIBX" );
- aToolBox.InsertItem( TB_UNLOADX, "UnloadX" );
- aToolBox.SetHelpText( TB_UNLOADX, "Unload Libary LIBX" );
- aToolBox.InsertItem( TB_LOADX, "LoadX" );
- aToolBox.SetHelpText( TB_LOADX, "Load Libary LIBX" );
- aToolBox.InsertItem( TB_EXECX, "ExecX" );
- aToolBox.SetHelpText( TB_EXECX, "Execute 'Libary' LIBX" );
- aToolBox.InsertItem( TB_REMOVEX, "RemoveX" );
- aToolBox.SetHelpText( TB_REMOVEX, "Remove Libary LIBX" );
- aToolBox.InsertItem( TB_REMOVEDELX, "RemDelX" );
- aToolBox.SetHelpText( TB_REMOVEDELX, "Remove and delete Libary LIBX" );
-
- pBasMgr = 0;
-
- Show();
- UpdateToolBox();
- aToolBox.Show();
-}
-void TestWindow::ShowInfo()
-{
- Invalidate();
- Update();
- long nH = GetTextSize( "X" ).Height();
- if ( pBasMgr )
- {
- Point aPos( 10, aToolBox.GetSizePixel().Height()+5 );
- for ( sal_uInt16 nLib = 0; nLib < pBasMgr->GetLibCount(); nLib++ )
- {
- String aOutStr( nLib );
- aOutStr +=": ";
- StarBASIC* pL = pBasMgr->GetLib( nLib );
- aOutStr += '[';
- aOutStr += pBasMgr->GetLibName( nLib );
- aOutStr += "]<";
- if ( pL )
- aOutStr += pL->GetName();
- else
- aOutStr += "NoLoaded";
- aOutStr += ">, Storage='";
- aOutStr += pBasMgr->GetLibStorageName( nLib );
- aOutStr += "', bLoaded=";
- aOutStr += (sal_uInt16)pBasMgr->IsLibLoaded( nLib );
- DrawText( aPos, aOutStr );
- aPos.Y() += nH;
- }
- }
-}
-
-void TestWindow::UpdateToolBox()
-{
- // View of some buttons as checked or disabled if
- // wished by tests
- aToolBox.EnableItem( TB_ORG, (sal_Bool)(sal_uIntPtr)pBasMgr );
-
- aToolBox.EnableItem( TB_CREATELIB1, (sal_Bool)(sal_uIntPtr)pBasMgr );
- aToolBox.EnableItem( TB_CREATELIB2, (sal_Bool)(sal_uIntPtr)pBasMgr );
- aToolBox.EnableItem( TB_CREATELIB3, (sal_Bool)(sal_uIntPtr)pBasMgr );
-
- aToolBox.EnableItem( TB_LOADLIB1, (sal_Bool)(sal_uIntPtr)pBasMgr );
- aToolBox.EnableItem( TB_LOADLIB2, (sal_Bool)(sal_uIntPtr)pBasMgr );
- aToolBox.EnableItem( TB_LOADLIB3, (sal_Bool)(sal_uIntPtr)pBasMgr );
-
- aToolBox.EnableItem( TB_STORELIBX, (sal_Bool)(sal_uIntPtr)pBasMgr );
- aToolBox.EnableItem( TB_EXECX, (sal_Bool)(sal_uIntPtr)pBasMgr );
- aToolBox.EnableItem( TB_UNLOADX, (sal_Bool)(sal_uIntPtr)pBasMgr );
- aToolBox.EnableItem( TB_LOADX, (sal_Bool)(sal_uIntPtr)pBasMgr );
- aToolBox.EnableItem( TB_REMOVEX, (sal_Bool)(sal_uIntPtr)pBasMgr );
- aToolBox.EnableItem( TB_REMOVEDELX, (sal_Bool)(sal_uIntPtr)pBasMgr );
-
- aToolBox.CheckItem( TB_LIB0, nLibX == 0 );
- aToolBox.CheckItem( TB_LIB1, nLibX == 1 );
- aToolBox.CheckItem( TB_LIB2, nLibX == 2 );
- aToolBox.CheckItem( TB_LIB3, nLibX == 3 );
-}
-
-IMPL_LINK( TestWindow, TBSelect, ToolBox *, p )
-{
- sal_uInt16 nId = aToolBox.GetCurItemId();
- sal_Bool bChecked = aToolBox.IsItemChecked( nId );
- switch ( nId )
- {
- case TB_NEW:
- {
- delete pBasMgr;
- pBasMgr = new BasicManager( new StarBASIC );
- pBasMgr->SetStorageName( "d:\\mystore.svs" );
- }
- break;
- case TB_OPENSTORAGE:
- {
- delete pBasMgr;
- SvStorageRef xStorage = new SvStorage( "d:\\mystore.svs", STREAM_READ | STREAM_SHARE_DENYWRITE );
- DBG_ASSERT( xStorage.Is(), "Kein Storage!" );
- pBasMgr = new BasicManager( *xStorage );
- }
- break;
- case TB_SAVESTORAGE:
- {
- if ( pBasMgr)
- {
- SvStorageRef xStorage = new SvStorage( "d:\\mystore.svs" );
- DBG_ASSERT( xStorage.Is(), "Kein Storage!" );
- pBasMgr->Store( *xStorage );
- }
- }
- break;
- case TB_ORG:
- {
- if ( pBasMgr)
- {
- InfoBox( 0, "Organisieren..." ).Execute();
- }
- }
- break;
- case TB_CREATELIB1:
- {
- if ( pBasMgr )
- {
- sal_uInt16 nLib = pBasMgr->GetLibId( pBasMgr->CreateLib( pLib1Str ) );
- if ( nLib != LIB_NOTFOUND )
- {
- pBasMgr->SetLibStorageName( nLib, "d:\\mystore.svs" );
- StarBASIC* pLib = pBasMgr->GetLib( pLib1Str );
- DBG_ASSERT( pLib, "Lib?!" );
- String aSource( "Sub SubInLib1Mod1\nprint\"XXX\"\nEnd Sub");
- SbModule* pM = pLib->MakeModule( "ModLib1", aSource );
- DBG_ASSERT( pM, "Modul?" );
- pLib->Compile( pM );
- }
- else
- InfoBox( 0, "CreateLibary fehlgeschlagen..." ).Execute();
- }
- }
- break;
- case TB_CREATELIB2:
- {
- if ( pBasMgr )
- {
- sal_uInt16 nLib = pBasMgr->GetLibId( pBasMgr->CreateLib( pLib2Str ) );
- if ( nLib != LIB_NOTFOUND )
- {
- pBasMgr->SetLibStorageName( nLib, "d:\\mystore.svs" );
- StarBASIC* pLib = pBasMgr->GetLib( pLib2Str );
- DBG_ASSERT( pLib, "Lib?!" );
- SbModule* pM = pLib->MakeModule( "ModuleLib2", "Sub SubInLib2\n print \"Tralala\" \nEnd Sub\n" );
- pLib->Compile( pM );
- }
- else
- InfoBox( 0, "CreateLibary fehlgeschlagen..." ).Execute();
- }
- }
- break;
- case TB_CREATELIB3:
- {
- if ( pBasMgr )
- {
- // is in another storage!!!
- sal_uInt16 nLib = pBasMgr->GetLibId( pBasMgr->CreateLib( pLib3Str ) );
- if ( nLib != LIB_NOTFOUND )
- {
- pBasMgr->SetLibStorageName( nLib, "d:\\mystore2.svs" );
- StarBASIC* pLib = pBasMgr->GetLib( pLib3Str );
- DBG_ASSERT( pLib, "Lib?!" );
- SbModule* pM = pLib->MakeModule( "ModuleLib2", "Sub XYZInLib3\n print \"?!\" \nEnd Sub\n" );
- pLib->Compile( pM );
- }
- else
- InfoBox( 0, "CreateLibary fehlgeschlagen..." ).Execute();
- }
- }
- break;
- case TB_LOADLIB1:
- {
- if ( pBasMgr )
- {
- SvStorageRef xStorage = new SvStorage( "d:\\mystore.svs" );
- if ( !pBasMgr->AddLib( *xStorage, pLib1Str, sal_False ) )
- Sound::Beep();
- }
- }
- break;
- case TB_LOADLIB2:
- {
- if ( pBasMgr )
- {
- SvStorageRef xStorage = new SvStorage( "d:\\mystore.svs" );
- if ( !pBasMgr->AddLib( *xStorage, pLib2Str, sal_False ) )
- Sound::Beep();
- }
- }
- break;
- case TB_LOADLIB3:
- {
- if ( pBasMgr )
- {
- // is in another storage!!!
- SvStorageRef xStorage = new SvStorage( "d:\\mystore2.svs" );
- if ( !pBasMgr->AddLib( *xStorage, pLib3Str, sal_False ) )
- Sound::Beep();
- }
- }
- break;
- case TB_STORELIBX:
- {
- if ( pBasMgr )
- pBasMgr->StoreLib( nLibX );
- }
- break;
- case TB_UNLOADX:
- {
- if ( pBasMgr )
- pBasMgr->UnloadLib( nLibX );
- }
- break;
- case TB_LOADX:
- {
- if ( pBasMgr )
- pBasMgr->LoadLib( nLibX );
- }
- break;
- case TB_REMOVEX:
- {
- if ( pBasMgr )
- pBasMgr->RemoveLib( nLibX, sal_False );
- }
- break;
- case TB_REMOVEDELX:
- {
- if ( pBasMgr )
- pBasMgr->RemoveLib( nLibX, sal_True );
- }
- break;
- case TB_EXECX:
- {
- if ( pBasMgr )
- {
- StarBASIC* pBasic = pBasMgr->GetLib( nLibX );
- if ( pBasic && pBasic->GetModules()->Count() )
- {
- pBasic->SetErrorHdl( LINK( this, TestWindow, BasicErrorHdl ) );
-
- SbModule* pMod = (SbModule*)pBasic->GetModules()->Get( 0 );
- if ( pMod && pMod->GetMethods()->Count() )
- pMod->GetMethods()->Get(0)->GetInteger();
- }
- }
- }
- break;
-
- case TB_LIB0: nLibX = 0;
- break;
- case TB_LIB1: nLibX = 1;
- break;
- case TB_LIB2: nLibX = 2;
- break;
- case TB_LIB3: nLibX = 3;
- break;
- }
-
- UpdateToolBox();
- CheckError();
- ShowInfo();
- return 0;
-}
-
-void TestWindow::CheckError()
-{
- if ( pBasMgr )
- {
- BasicError* pError = pBasMgr->GetFirstError();
- while ( pError )
- {
- String aErrorStr;
- String aReasonStr;
- switch ( pError->GetErrorId() )
- {
- case BASERR_ID_STDLIBOPEN:
- aErrorStr = "Standard-Lib konnte nicht geoffnet werden.";
- break;
- case BASERR_ID_STDLIBSAVE:
- aErrorStr = "Standard-Lib konnte nicht gespeichert werden.";
- break;
- case BASERR_ID_LIBLOAD:
- aErrorStr = "Lib konnte nicht geoffnet werden.";
- break;
- case BASERR_ID_LIBCREATE:
- aErrorStr = "Lib konnte nicht erzeugt werden.";
- break;
- case BASERR_ID_LIBSAVE:
- aErrorStr = "Lib konnte nicht gespeichert werden.";
- break;
- case BASERR_ID_MGROPEN:
- aErrorStr = "Manager konnte nicht geladen werden.";
- break;
- case BASERR_ID_MGRSAVE:
- aErrorStr = "Manager konnte nicht gespeichert werden.";
- break;
- case BASERR_ID_UNLOADLIB:
- aErrorStr = "Libary konnte nicht entladen werden.";
- break;
- case BASERR_ID_REMOVELIB:
- aErrorStr = "Libary konnte nicht entfernt werden.";
- break;
- default:
- aErrorStr = "Unbekannter Fehler!";
- }
-
- switch ( pError->GetReason() )
- {
- case BASERR_REASON_OPENSTORAGE:
- aReasonStr = "Der Storage konnte nicht geoeffnet werden";
- break;
- case BASERR_REASON_OPENLIBSTORAGE:
- aReasonStr = "Der Lib-Storage konnte nicht geoeffnet werden";
- break;
- case BASERR_REASON_OPENMGRSTREAM:
- aReasonStr = "Der Manager-Stream konnte nicht geoeffnet werden";
- break;
- case BASERR_REASON_OPENLIBSTREAM:
- aReasonStr = "Der Basic-Stream konnte nicht geoeffnet werden";
- break;
- case BASERR_REASON_STDLIB:
- aReasonStr = "STANDARD-Lib";
- break;
- case BASERR_REASON_BASICLOADERROR:
- aReasonStr = "Fehler beim Laden des Basics";
- default:
- aReasonStr = " - ";
- }
-
- String aErr( aErrorStr );
- aErr += "\nGrund: ";
- aErr += aReasonStr;
- InfoBox( 0, aErr ).Execute();
-
- pError = pBasMgr->GetNextError();
- }
- pBasMgr->ClearErrors();
- }
-}
-
-void __EXPORT TestWindow::Paint( const Rectangle& rRec )
-{
-}
-
-void __EXPORT TestWindow::Resize()
-{
- Size aTBSz = aToolBox.CalcWindowSizePixel();
- aToolBox.SetSizePixel( Size( GetOutputSizePixel().Width(), aTBSz.Height()) );
- Invalidate();
- ShowInfo();
-}
-
-void __EXPORT TestWindow::KeyInput( const KeyEvent& rKEvt )
-{
- sal_uInt16 nCode = rKEvt.GetKeyCode().GetCode();
-
- // only for Alt-Return
- if ( ( nCode == KEY_RETURN ) && rKEvt.GetKeyCode().IsMod2() )
- ;
- else
- WorkWindow::KeyInput( rKEvt );
-
- UpdateToolBox();
-}
-
-void __EXPORT TestWindow::MouseMove( const MouseEvent& rMEvt )
-{
-}
-
-void __EXPORT TestWindow::MouseButtonDown( const MouseEvent& rMEvt )
-{
- ShowInfo();
-}
-
-void __EXPORT TestWindow::MouseButtonUp( const MouseEvent& rMEvt )
-{
- UpdateToolBox();
-}
-
-IMPL_LINK( TestWindow, BasicErrorHdl, StarBASIC *, pBasic )
-{
- String aErrorText( pBasic->GetErrorText() );
-
- String aErrorTextPrefix;
- if( pBasic->IsCompilerError() )
- {
- aErrorTextPrefix = "Compilererror: ";
- }
- else
- {
- aErrorTextPrefix = "Runtimeerror: ";
- aErrorTextPrefix += pBasic->GetErrorCode();
- aErrorTextPrefix += " ";
- }
-
- InfoBox( 0, String( aErrorTextPrefix + aErrorText ) ).Execute();
- return 0;
-}
-
-void __EXPORT TestApp::Main( void )
-{
- Main( 0, NULL );
-}
-
-void __EXPORT TestApp::Main( int, char*[] )
-{
- BasicDLL aBasiDLL;
- SvFactory::Init();
- EnableSVLook();
- TestWindow aWindow;
- Execute();
- SvFactory::DeInit();
-}
-
-
-TestApp aTestApp;
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */