summaryrefslogtreecommitdiff
path: root/extensions/workben
diff options
context:
space:
mode:
Diffstat (limited to 'extensions/workben')
-rw-r--r--extensions/workben/makefile.mk247
-rw-r--r--extensions/workben/pythonautotest.cxx657
-rw-r--r--extensions/workben/pythontest.cxx591
-rw-r--r--extensions/workben/testcomponent.cxx261
-rw-r--r--extensions/workben/testframecontrol.cxx355
-rw-r--r--extensions/workben/testpgp.cxx918
-rw-r--r--extensions/workben/testresource.cxx125
-rw-r--r--extensions/workben/testresource.src64
8 files changed, 3218 insertions, 0 deletions
diff --git a/extensions/workben/makefile.mk b/extensions/workben/makefile.mk
new file mode 100644
index 000000000000..66fd82861e1b
--- /dev/null
+++ b/extensions/workben/makefile.mk
@@ -0,0 +1,247 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 16:16:56 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..
+
+PRJNAME=extensions
+TARGET=workben
+LIBTARGET=NO
+
+TESTAPP=testpgp
+#TESTAPP=testcomponent
+#TESTAPP=pythontest
+#TESTAPP=pythonautotest
+#TESTAPP=testresource
+#TESTAPP=testframecontrol
+
+.IF "$(TESTAPP)" == "testresource" || "$(TESTAPP)" == "testframecontrol"
+TARGETTYPE=GUI
+.ELSE
+TARGETTYPE=CUI
+.ENDIF
+
+JVM_TARGET=jvmtest
+
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+UNOUCRDEP=$(SOLARBINDIR)$/applicat.rdb
+UNOUCRRDB=$(SOLARBINDIR)$/applicat.rdb
+UNOUCROUT=$(OUT)$/inc$/$(PRJNAME)$/$(TARGET)
+INCPRE+=$(UNOUCROUT)
+
+# --- Files --------------------------------------------------------
+
+#
+# testpgp.
+#
+.IF "$(TESTAPP)" == "testpgp"
+
+UNOTYPES= \
+ com.sun.star.lang.XMultiServiceFactory \
+ com.sun.star.io.XInputStream \
+ com.sun.star.io.XOutputStream \
+ com.sun.star.pgp.RecipientsEvent \
+ com.sun.star.pgp.SignatureEvent \
+ com.sun.star.pgp.XPGPDecoder \
+ com.sun.star.pgp.XPGPDecoderListener \
+ com.sun.star.pgp.XPGPEncoder \
+ com.sun.star.pgp.XPGPPreferences \
+ com.sun.star.uno.TypeClass \
+ com.sun.star.uno.XInterface \
+ com.sun.star.uno.XWeak
+
+CXXFILES= testpgp.cxx
+OBJFILES= $(OBJ)$/testpgp.obj
+
+APP1TARGET= testpgp
+APP1OBJS= $(OBJFILES)
+APP1STDLIBS=$(USRLIB) \
+ $(CPPUHELPERLIB)\
+ $(CPPULIB) \
+ $(VOSLIB) \
+ $(SALLIB)
+
+APP1DEPN= $(L)$/usr.lib
+APP1DEF= $(MISC)$/$(APP1TARGET).def
+
+.ENDIF # testpgp
+
+#
+# std testcomponent
+#
+.IF "$(TESTAPP)" == "testcomponent"
+
+CXXFILES= testcomponent.cxx
+OBJFILES= $(OBJ)$/testcomponent.obj
+
+APP2TARGET = testcomponent
+APP2OBJS = $(OBJ)$/testcomponent.obj
+APP2STDLIBS = $(UNOLIB) \
+ $(VOSLIB) \
+ $(USRLIB) \
+ $(TOOLSLIB) \
+ $(SALLIB) \
+ $(RTLLIB) \
+ $(ONELIB)
+
+.ENDIF # testcomponent
+
+#
+# test python.
+#
+.IF "$(TESTAPP)" == "phytontest"
+
+CXXFILES= phytontest.cxx
+OBJFILES= $(OBJ)$/pythontest.obj
+
+#APP4TARGET= pythontest
+#APP4OBJS= $(OBJ)$/pythontest.obj
+#APP4STDLIBS=$(TOOLSLIB) \
+# $(USRLIB) \
+# $(UNOLIB) \
+# $(VOSLIB) \
+# $(RTLLIB)
+
+#APP1DEPN= $(LB)$/one.lib
+#APP4DEF= $(MISC)$/$(APP4TARGET).def
+
+.ENDIF # phytontest
+
+#
+# python auto test
+#
+.IF "$(TESTAPP)" == "phytonautotest"
+
+CXXFILES= phytonautotest.cxx
+OBJFILES= $(OBJ)$/pythonautotest.obj
+
+#APP5TARGET= pythonautotest
+#APP5OBJS = $(OBJ)$/pythonautotest.obj
+#APP5STDLIBS=$(TOOLSLIB) \
+# $(USRLIB) \
+# $(UNOLIB) \
+# $(VOSLIB) \
+# $(RTLLIB)
+#APP5DEF= $(MISC)$/$(APP5TARGET).def
+
+.ENDIF # phytonautotest
+
+#
+# testresource.
+#
+.IF "$(TESTAPP)" == "testresource"
+
+CXXFILES= testresource.cxx
+OBJFILES= $(OBJ)$/testresource.obj
+
+SRS2NAME = testresource
+SRC2FILES= testresource.src
+RESLIB2SRSFILES= $(SRS)$/testresource.srs
+RESLIB2NAME= testresource
+
+APP2TARGET= testresource
+APP2OBJS= $(OBJ)$/testresource.obj
+APP2STDLIBS=$(TOOLSLIB) \
+ $(VCLLIB) \
+ $(ONELIB) \
+ $(USRLIB) \
+ $(UNOLIB) \
+ $(SALLIB) \
+ $(RTLLIB)
+
+APP2DEF= $(MISC)$/$(APP3TARGET).def
+
+.ENDIF # testresource
+
+#
+# testframecontrol.
+#
+.IF "$(TESTAPP)" == "testframecontrol"
+
+CXXFILES= testframecontrol.cxx
+OBJFILES= $(OBJ)$/testframecontrol.obj
+
+APP3TARGET= testframecontrol
+APP3OBJS= $(OBJ)$/testframecontrol.obj
+APP3STDLIBS=$(TOOLSLIB) \
+ $(ONELIB) \
+ $(USRLIB) \
+ $(UNOLIB) \
+ $(VOSLIB) \
+ $(OSLLIB) \
+ $(RTLLIB) \
+ $(SVTOOLLIB) \
+ $(VCLLIB)
+
+APP3DEF= $(MISC)$/$(APP3TARGET).def
+
+.ENDIF # testframecontrol
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/extensions/workben/pythonautotest.cxx b/extensions/workben/pythonautotest.cxx
new file mode 100644
index 000000000000..318fdb84dbf5
--- /dev/null
+++ b/extensions/workben/pythonautotest.cxx
@@ -0,0 +1,657 @@
+/*************************************************************************
+ *
+ * $RCSfile: pythonautotest.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:16:56 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include <stdio.h>
+#include <stardiv/uno/repos/implementationregistration.hxx>
+#include <stardiv/uno/script/script.hxx>
+#include <stardiv/uno/beans/exactname.hxx>
+
+#include <rtl/ustring.hxx>
+#include <vos/dynload.hxx>
+#include <vos/diagnose.hxx>
+#include <usr/services.hxx>
+#include <vcl/svapp.hxx>
+#include <usr/ustring.hxx>
+#include <usr/weak.hxx>
+#include <tools/string.hxx>
+#include <vos/conditn.hxx>
+#include <assert.h>
+
+#ifdef _USE_NAMESPACE
+using namespace rtl;
+using namespace vos;
+using namespace usr;
+#endif
+
+#define PCHAR_TO_USTRING(x) StringToOUString(String(x),CHARSET_SYSTEM)
+#define USTRING_TO_PCHAR(x) OUStringToString(x , CHARSET_DONTKNOW ).GetCharStr()
+
+
+
+
+
+/*****
+*
+* A Test root object !
+*
+*****/
+class MyPythonRoot :
+ public XInvokation,
+ public OWeakObject
+{
+public:
+ MyPythonRoot() { m_iTestValue = 15; }
+ BOOL queryInterface( Uik aUik, XInterfaceRef & rOut );
+ void acquire() { OWeakObject::acquire(); }
+ void release() { OWeakObject::release(); }
+ void* getImplementation(Reflection *p) { return OWeakObject::getImplementation(p); }
+
+public:
+ XIntrospectionAccessRef getIntrospection(void) const THROWS( (UsrSystemException) )
+ { return XIntrospectionAccessRef(); }
+
+ UsrAny invoke( const UString& FunctionName,
+ const Sequence< UsrAny >& Params,
+ Sequence< INT16 >& OutParamIndex,
+ Sequence< UsrAny >& OutParam)
+ THROWS( ( IllegalArgumentException,
+ CannotConvertException,
+ InvocationTargetException,
+ UsrSystemException) );
+ void setValue(const UString& PropertyName, const UsrAny& Value)
+ THROWS( ( UnknownPropertyException,
+ CannotConvertException,
+ InvocationTargetException,
+ UsrSystemException) );
+
+ UsrAny getValue(const UString& PropertyName)
+ THROWS( ( UnknownPropertyException,
+ UsrSystemException) );
+ BOOL hasMethod(const UString& Name) const THROWS( (UsrSystemException) );
+ BOOL hasProperty(const UString& Name) const THROWS( (UsrSystemException) );
+
+
+ void getTestValueViaInout( int &inout )
+ { inout = m_iTestValue; }
+
+ INT32 getTestValue() const
+ { return m_iTestValue; }
+
+ void setTestValue( INT32 i )
+ { m_iTestValue = i; }
+
+ void printTestValue()
+ { fprintf( stderr, "TestValue : %d\n" , getTestValue() ); }
+
+ void addTestValue( INT32 i )
+ { m_iTestValue += i; }
+
+private:
+
+ INT32 m_iTestValue;
+};
+
+BOOL MyPythonRoot::queryInterface( Uik aUik, XInterfaceRef &rOut )
+{
+ if( aUik == XInvokation::getSmartUik() ) {
+ rOut = ( XInvokation * ) this;
+ }
+ else {
+ return OWeakObject::queryInterface( aUik , rOut );
+ }
+ return TRUE;
+
+}
+
+UsrAny MyPythonRoot::invoke( const UString& FunctionName,
+ const Sequence< UsrAny >& Params,
+ Sequence< INT16 >& OutParamIndex,
+ Sequence< UsrAny >& OutParam)
+ THROWS( ( IllegalArgumentException,
+ CannotConvertException,
+ InvocationTargetException,
+ UsrSystemException) )
+{
+ if( L"printTestValue" == FunctionName ) {
+ printTestValue();
+ }
+ else if( L"addTestValue" == FunctionName ) {
+ addTestValue( Params.getConstArray()[0].getINT32() );
+ }
+ else if( L"getTestValueViaInout" == FunctionName ) {
+ int i = Params.getConstArray()[0].getINT32();
+ getTestValueViaInout( i );
+ OutParam.getArray()[0].setINT32( i );
+ }
+ else {
+ THROW( InvocationTargetException() );
+ }
+
+ return UsrAny();
+}
+
+void MyPythonRoot::setValue(const UString& PropertyName, const UsrAny& Value)
+ THROWS( ( UnknownPropertyException,
+ CannotConvertException,
+ InvocationTargetException,
+ UsrSystemException) )
+{
+ if( L"TestValue" == PropertyName ) {
+ setTestValue( Value.getINT32() );
+ }
+ else {
+ THROW( UnknownPropertyException() );
+ }
+}
+
+UsrAny MyPythonRoot::getValue(const UString& PropertyName)
+ THROWS( ( UnknownPropertyException,
+ UsrSystemException) )
+{
+ UsrAny aRet;
+
+ if( L"TestValue" == PropertyName ) {
+ aRet.setINT32( getTestValue() );
+ }
+ else {
+ THROW( UnknownPropertyException() );
+ }
+
+ return aRet;
+}
+
+
+BOOL MyPythonRoot::hasMethod(const UString& Name) const THROWS( (UsrSystemException) )
+{
+ if( L"printTestValue" == Name ) {
+ return TRUE;
+ }
+ else if( L"addTestValue" == Name ) {
+ return TRUE;
+ }
+ else if( L"getTestValueViaInout" == Name ) {
+ return TRUE;
+ }
+ return FALSE;
+}
+
+
+BOOL MyPythonRoot::hasProperty(const UString& Name) const THROWS( (UsrSystemException) )
+{
+ if( L"TestValue" == Name ) {
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+
+/*****
+*
+* A test engine listener to check the debug interface
+*
+*****/
+class TestListener :
+ public XEngineListener,
+ public OWeakObject
+{
+public:
+
+ TestListener()
+ {
+ m_pDebuggingRef = 0;
+ }
+
+
+ TestListener( XDebuggingRef *p )
+ {
+ attach( p );
+ }
+
+ ~TestListener()
+ {
+ if( m_pDebuggingRef ) {
+ detach();
+ }
+ }
+
+ BOOL queryInterface( Uik aUik, XInterfaceRef & rOut );
+ void acquire() { OWeakObject::acquire(); }
+ void release() { OWeakObject::release(); }
+ void* getImplementation(Reflection *p) { return OWeakObject::getImplementation(p); }
+
+
+ void attach( XDebuggingRef *p )
+ {
+ m_pDebuggingRef = p;
+ }
+
+ void detach( );
+
+
+ virtual void disposing( const EventObject &o )
+ {
+ if( m_pDebuggingRef ) {
+ detach();
+ }
+ }
+ virtual void interrupt(const InterruptEngineEvent& Evt) THROWS( (UsrSystemException) )
+ {
+ }
+
+ virtual void running(const EventObject& Evt) THROWS( (UsrSystemException) )
+ {
+ (*m_pDebuggingRef)->stop();
+
+ m_aDebugCondition.set();
+ }
+
+ virtual void finished(const FinishEngineEvent& Evt) THROWS( (UsrSystemException) )
+ {
+ m_aDebugCondition.set();
+ }
+
+
+ void cmdLine();
+protected:
+
+ OCondition m_aDebugCondition;
+ XDebuggingRef *m_pDebuggingRef;
+};
+
+
+
+void TestListener::cmdLine()
+{
+ // Condition is set by running listener
+ m_aDebugCondition.wait();
+ m_aDebugCondition.reset();
+ (*m_pDebuggingRef)->doContinue();
+ m_aDebugCondition.wait();
+}
+
+void TestListener::detach()
+{
+ assert( m_pDebuggingRef );
+
+ m_pDebuggingRef = 0;
+}
+
+BOOL TestListener::queryInterface( Uik aUik, XInterfaceRef & rOut )
+{
+ if( aUik == XEngineListener::getSmartUik() )
+ rOut = (XEngineListener*)this;
+ else
+ return OWeakObject::queryInterface( aUik, rOut );
+ return TRUE;
+}
+
+
+void checkInvokation( const XInvokationRef &xInvoke )
+{
+ UsrAny anyList;
+
+ // check exporting an object as an invokation
+ assert( xInvoke->hasProperty( L"list" ) );
+ anyList = xInvoke->getValue( L"list" );
+
+ assert( anyList.getReflection() == XInvokation_getReflection() );
+ XInvokationRef *pRef = ( XInvokationRef * ) anyList.get();
+ assert( (*pRef).is() );
+
+ assert( (*pRef)->hasMethod( L"append" ) );
+ assert( (*pRef)->hasMethod( L"count" ) );
+
+ Sequence<UsrAny> seq(1);
+ UsrAny any( (INT32) 1);
+ (seq.getArray())[0] = any;
+
+ any = (*pRef)->invoke( L"count" , seq , Sequence<INT16>(), Sequence<UsrAny>() );
+ int nOldSize = any.getINT32();
+
+ any = (*pRef)->invoke( L"append" , seq , Sequence<INT16>(), Sequence<UsrAny>() );
+ any = (*pRef)->invoke( L"count" , seq , Sequence<INT16>(), Sequence<UsrAny>() );
+
+ assert( nOldSize + 1 == any.getINT32() );
+}
+
+// just for testing !
+class PythonCodeLibrary :
+ public XLibraryAccess,
+ public OWeakObject
+{
+
+ BOOL queryInterface( Uik aUik, XInterfaceRef & rOut );
+ void acquire() { OWeakObject::acquire(); }
+ void release() { OWeakObject::release(); }
+ void* getImplementation(Reflection *p) { return OWeakObject::getImplementation(p); }
+
+
+ virtual BOOL isFunction(const UString& FunctionName) THROWS( (UsrSystemException) )
+ {
+ return FALSE;
+ }
+
+ virtual BOOL isValidPath(const UString& PathName) THROWS( (UsrSystemException) )
+ {
+ return FALSE;
+ }
+
+ virtual Sequence< UString > getModuleNames(void) THROWS( (UsrSystemException) )
+ {
+ return Sequence<UString> ();
+ }
+
+ virtual UString getModuleSource(const UString& ModulName) THROWS( (UsrSystemException) )
+ {
+ if( ModulName == L"testmodul" ) {
+ return UString( L"def testmethod():\n"
+ L" return 42\n");
+ }
+ return UString();
+ }
+
+ virtual Sequence< BYTE > getModuleCode(const UString& ModuleName) THROWS( (UsrSystemException) )
+ {
+ return Sequence< BYTE > ();
+ }
+
+ virtual UString getFunctionSource(const UString& FunctionName) THROWS( (UsrSystemException) )
+ {
+ return UString();
+ }
+ virtual Sequence< BYTE > getFunctionCode(const UString& FunctionName) THROWS( (UsrSystemException) )
+ {
+ return Sequence< BYTE > ();
+ }
+};
+
+BOOL PythonCodeLibrary::queryInterface( Uik aUik, XInterfaceRef & rOut )
+{
+ if( XLibraryAccess::getSmartUik() == aUik ) {
+ rOut = (XLibraryAccess* ) this;
+ }
+ else {
+ return OWeakObject::queryInterface( aUik , rOut );
+ }
+
+ return TRUE;
+}
+
+
+
+/*
+ * main.
+ */
+int __LOADONCALLAPI main (int argc, char **argv)
+{
+ // necessary startup code
+ XMultiServiceFactoryRef xSMgr = createRegistryServiceManager();
+ registerUsrServices( xSMgr );
+ setProcessServiceManager( xSMgr );
+
+ XInterfaceRef x = xSMgr->createInstance( L"stardiv.uno.repos.ImplementationRegistration" );
+ XImplementationRegistrationRef xReg( x, USR_QUERY );
+ sal_Char szBuf[1024];
+
+ ORealDynamicLoader::computeModuleName( "pythonengine", szBuf, 1024 );
+ UString aDllName( StringToOUString( szBuf, CHARSET_SYSTEM ) );
+ xReg->registerImplementation( L"stardiv.loader.SharedLibrary", aDllName, XSimpleRegistryRef() );
+
+ x = xSMgr->createInstance( L"stardiv.script.Python" );
+ XEngineRef xEngine( x, USR_QUERY );
+ XInvokationRef xInvoke( x, USR_QUERY );
+ XDebuggingRef xDebug( x , USR_QUERY );
+
+ XInterfaceRef rRoot( (XInvokation * )new MyPythonRoot , USR_QUERY );
+ xEngine->setRoot( rRoot );
+
+
+ // execute a simple script
+ xEngine->run( L"nIntTest = 5\n"
+ L"list = [2,3,4]\n" , XInterfaceRef(), Sequence<UsrAny> () );
+
+ /****
+ *
+ * Xinvokation - Test
+ *
+ *****/
+ // get/set an int !
+ {
+ assert( xInvoke->hasProperty( L"nIntTest" ) );
+ UsrAny any = xInvoke->getValue( L"nIntTest" );
+
+ assert( any.getReflection()->getTypeClass() == TypeClass_LONG );
+ assert( any.getINT32() == 5 );
+
+ // simple test: set an int !
+ xInvoke->setValue( L"nIntTest" , UsrAny( (INT32) 10 ) );
+ any = xInvoke->getValue( L"nIntTest" );
+
+ assert( any.getReflection()->getTypeClass() == TypeClass_LONG );
+ assert( any.getINT32() == 10 );
+ }
+
+ // call a python method !
+ {
+ xEngine->run( L"def foo():\n"
+ L" return 'this is foo'\n" , XInterfaceRef() , Sequence<UsrAny> () );
+ assert( xInvoke->hasMethod( L"foo" ) );
+ UsrAny any = xInvoke->invoke( L"foo" ,
+ Sequence<UsrAny>(),
+ Sequence<INT16>() ,
+ Sequence<UsrAny> () );
+ assert( any.getString() == L"this is foo" );
+ }
+
+
+ // check exception handling !
+ {
+ TRY {
+ xInvoke->invoke( L"foo" , Sequence<UsrAny>(1) , Sequence<INT16>(), Sequence<UsrAny> () );
+ // wrong number of arguments
+ assert( 0 );
+ }
+ CATCH ( IllegalArgumentException , e ) {
+ }
+ CATCH ( InvocationTargetException , e ) {
+ }
+ CATCH ( CannotConvertException , e ) {
+ // empty any cannot be converted
+ }
+ }
+
+ // check InOut-Parameter
+ checkInvokation( xInvoke );
+
+ /*******
+ *
+ * Check Introspection Access
+ *
+ *******/
+ {
+ XIntrospectionAccessRef xIntrospection = xInvoke->getIntrospection();
+ assert( xIntrospection.is() );
+
+ // no further test, simply call them
+ xIntrospection->getMethods(0);
+ xIntrospection->getProperties(0);
+
+ assert( xIntrospection->getSuppliedMethodConcepts() == 0 );
+ assert( xIntrospection->getSuppliedPropertyConcepts() == 0 );
+
+ Property prop = xIntrospection->getProperty( L"nIntTest" ,0 );
+ assert( prop.Name == L"nIntTest" );
+ assert( prop.Type->getTypeClass() == TypeClass_LONG );
+
+ XIdlMethodRef method = xIntrospection->getMethod( L"foo" , 0 );
+ assert( method->getName() == L"foo" );
+ }
+
+
+ /******
+ *
+ * Multithreading test
+ *
+ *******/
+
+ /******
+ *
+ * XDebuggingTest
+ *
+ ******/
+ // stop/doContinue + runAsync listener
+ {
+ // test hangs, if something is wrong
+
+ TestListener *pListener = new TestListener( &xDebug );
+ XEngineListenerRef ref( (XEngineListener * ) pListener , USR_QUERY );
+
+ // single listener check !
+ xEngine->runAsync( L"pass\n"
+ , XInterfaceRef() , Sequence<UsrAny> () , ref );
+ pListener->cmdLine();
+ }
+
+ // ListenerAdministration check !
+ {
+ // test hangs, if something is wrong
+
+ TestListener *pListener = new TestListener( &xDebug );
+ XEngineListenerRef ref( (XEngineListener * ) pListener , USR_QUERY );
+
+ // engine listener check !
+ xEngine->addEngineListener( ref );
+ xEngine->runAsync( L"pass\n"
+ , XInterfaceRef() , Sequence<UsrAny> () , XEngineListenerRef() );
+ pListener->cmdLine();
+ xEngine->removeEngineListener( ref);
+
+ }
+
+ // check the import mechanism
+ {
+ XLibraryAccessRef xLibrary( ( XLibraryAccess * ) new PythonCodeLibrary , USR_QUERY );
+ xEngine->setLibraryAccess( xLibrary );
+
+ xEngine->run( L"import testmodul\n"
+ L"x = testmodul.testmethod()\n" , XInterfaceRef() , Sequence<UsrAny>() );
+ UsrAny any = xInvoke->getValue( L"x" );
+ assert( any.getReflection()->getTypeClass() == TypeClass_LONG );
+ assert( any.getINT32() == 42 );
+ }
+
+ // check other imports
+ {
+ // Check, if the libraries are available at run time
+ xEngine->run( L"import math\n"
+ L"dMathTest = math.exp(0)\n" , XInterfaceRef() , Sequence<UsrAny> () );
+
+ assert( xInvoke->hasProperty( L"dMathTest" ) );
+ UsrAny any = xInvoke->getValue( L"dMathTest" );
+
+ assert( any.getReflection()->getTypeClass() == TypeClass_DOUBLE );
+ assert( any.getDouble() == 1. );
+ }
+
+ // Test connection to root object !
+ {
+ xEngine->run( L"x = stardiv.root.TestValue\n"
+ L"y = stardiv.inout(5)\n"
+ L"stardiv.root.getTestValueViaInout(y)\n"
+ L"z = y.value\n" , XInterfaceRef() , Sequence<UsrAny> () );
+
+ UsrAny any = xInvoke->getValue( L"x" );
+ assert( any.getReflection()->getTypeClass() == TypeClass_LONG );
+ assert( any.getINT32() == 15 );
+
+ any = xInvoke->getValue( L"z" );
+ assert( any.getReflection()->getTypeClass() == TypeClass_LONG );
+ assert( any.getINT32() == 15 );
+ }
+
+ // Test exactName interface
+ {
+ UsrAny any = xInvoke->getValue( L"__builtins__" );
+ assert( any.getReflection()->getTypeClass() == TypeClass_INTERFACE );
+
+ XInvokationRef rInv( *((XInterfaceRef *) any.get() ), USR_QUERY );
+ assert( rInv.is() );
+
+ XExactNameRef rName( *((XInterfaceRef*) any.get() ), USR_QUERY );
+ assert( rName.is() );
+
+ UString str = rName->getExactName( L"SYNTAXERROR" );
+ assert( str.len() );
+ }
+
+
+ // Test exactName interface of the engine itself
+ {
+ XExactNameRef rName( xInvoke , USR_QUERY );
+ assert( rName.is() );
+ UString str = rName->getExactName( L"STARDIV" );
+ assert( str.len() );
+ }
+
+
+ return 0;
+}
+
diff --git a/extensions/workben/pythontest.cxx b/extensions/workben/pythontest.cxx
new file mode 100644
index 000000000000..1862bec6c943
--- /dev/null
+++ b/extensions/workben/pythontest.cxx
@@ -0,0 +1,591 @@
+/*************************************************************************
+ *
+ * $RCSfile: pythontest.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:16:56 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <stdio.h>
+#include <stardiv/uno/repos/implementationregistration.hxx>
+#include <stardiv/uno/script/script.hxx>
+#include <stardiv/uno/beans/exactname.hxx>
+
+#include <rtl/ustring.hxx>
+#include <vos/dynload.hxx>
+#include <vos/diagnose.hxx>
+#include <usr/services.hxx>
+#include <vcl/svapp.hxx>
+#include <usr/ustring.hxx>
+#include <usr/weak.hxx>
+#include <tools/string.hxx>
+#include <vos/conditn.hxx>
+#include <assert.h>
+
+#ifdef _USE_NAMESPACE
+using namespace rtl;
+using namespace vos;
+using namespace usr;
+#endif
+
+#define PCHAR_TO_USTRING(x) StringToOUString(String(x),CHARSET_SYSTEM)
+
+
+
+class NullEngineListenerRef : public XEngineListenerRef
+{
+ virtual void interrupt(const InterruptEngineEvent& Evt) THROWS( (UsrSystemException) ) {}
+ virtual void running(const EventObject& Evt) THROWS( (UsrSystemException) ) {}
+ virtual void finished(const FinishEngineEvent& Evt) THROWS( (UsrSystemException) ) {}
+};
+
+#define USTRING_TO_PCHAR(x) OUStringToString(x , CHARSET_DONTKNOW ).GetCharStr()
+
+class CmdDebugger :
+ public XEngineListener,
+ public OWeakObject
+{
+public:
+
+ CmdDebugger()
+ {
+ m_pDebuggingRef = 0;
+ m_pEngineRef = 0;
+ m_bIsTerminating = FALSE;
+ m_bIsRunning = FALSE;
+ }
+
+
+ CmdDebugger( XDebuggingRef *p, XEngineRef *pEngine , XInvokationRef *pInvokation)
+ {
+ attach( p , pEngine , pInvokation );
+ }
+
+ ~CmdDebugger()
+ {
+ if( m_pDebuggingRef ) {
+ detach();
+ }
+ }
+
+ BOOL queryInterface( Uik aUik, XInterfaceRef & rOut );
+ void acquire() { OWeakObject::acquire(); }
+ void release() { OWeakObject::release(); }
+ void* getImplementation(Reflection *p) { return OWeakObject::getImplementation(p); }
+
+
+ void attach( XDebuggingRef *p , XEngineRef *pEngine , XInvokationRef *pInvokation )
+ {
+ m_pDebuggingRef = p;
+ m_pEngineRef = pEngine;
+ m_pInvokationRef = pInvokation;
+ m_bIsRunning = FALSE;
+ m_bIsTerminating = FALSE;
+ }
+
+ void detach( );
+
+
+ virtual void disposing( const EventObject &o )
+ {
+ if( m_pDebuggingRef ) {
+ detach();
+ }
+ }
+ virtual void interrupt(const InterruptEngineEvent& Evt) THROWS( (UsrSystemException) )
+ {
+ if( m_pDebuggingRef && ! m_bIsTerminating ) {
+ (*m_pDebuggingRef)->stop();
+ fprintf( stderr, "%s\n" , USTRING_TO_PCHAR(Evt.ErrorMessage ) );
+ fprintf( stderr, "%s.%s (%d)\n", USTRING_TO_PCHAR(Evt.SourceCode),
+ USTRING_TO_PCHAR(Evt.Name ),
+ Evt.StartLine );
+ m_aDebugCondition.set();
+ m_bIsRunning = TRUE;
+ }
+ }
+
+ virtual void running(const EventObject& Evt) THROWS( (UsrSystemException) )
+ {
+ if( m_pDebuggingRef && ! m_bIsTerminating ) {
+ (*m_pDebuggingRef)->stop();
+
+ m_aDebugCondition.set();
+ m_bIsRunning = TRUE;
+ fprintf( stderr, "%s\n" , "Script starts\n" );
+ }
+ }
+
+ virtual void finished(const FinishEngineEvent& Evt) THROWS( (UsrSystemException) )
+ {
+ if( m_pDebuggingRef && ! m_bIsTerminating ) {
+ m_aDebugCondition.set();
+ m_bIsRunning = FALSE;
+ fprintf( stderr , "%s\n", USTRING_TO_PCHAR( Evt.ErrorMessage ) );
+ }
+ }
+
+ void dumpIntrospectionToStream( const XIntrospectionAccessRef &, FILE *f );
+ void dumpVarToStream( const char *pcName, const UsrAny &any, FILE *f );
+
+
+ void cmdLine();
+protected:
+
+ OCondition m_aDebugCondition;
+ XDebuggingRef *m_pDebuggingRef;
+ XEngineRef *m_pEngineRef;
+ XInvokationRef *m_pInvokationRef;
+ int m_bIsRunning;
+ int m_bIsTerminating; // The listeners ignore everything when set
+};
+
+
+
+void CmdDebugger::cmdLine()
+{
+ char pcLine[80];
+ fprintf( stderr, "entering debugger\n" );
+ while( TRUE ) {
+
+ m_aDebugCondition.wait();
+
+ fprintf( stderr , "(debug %d) : " , m_bIsRunning );
+ fflush( stderr);
+ fgets( pcLine , 79 , stdin );
+
+ if( strlen( pcLine) ) pcLine[strlen(pcLine)-1] =0;
+ String sLine( pcLine );
+
+ if( ! strcmp( pcLine , "g" ) ) {
+ if( m_bIsRunning ) {
+ m_aDebugCondition.reset();
+ (*m_pDebuggingRef)->doContinue();
+ }
+ else fprintf( stderr,"no script running !\n" );
+ }
+ else if( ! strcmp( pcLine , "s" ) ) {
+ if( m_bIsRunning ) {
+ m_aDebugCondition.reset();
+ (*m_pDebuggingRef)->stepOver();
+ }
+ else fprintf(stderr, "no script running !\n" );
+ }
+ else if( ! strcmp( pcLine , "so" ) ) {
+ if( m_bIsRunning ) {
+ m_aDebugCondition.reset();
+ (*m_pDebuggingRef)->stepOut();
+ }
+ else fprintf(stderr, "no script running !\n" );
+ }
+ else if( ! strcmp( pcLine , "si" ) ) {
+ if( m_bIsRunning ) {
+ m_aDebugCondition.reset();
+ (*m_pDebuggingRef)->stepIn();
+ }
+ else fprintf(stderr, "no script running !\n" );
+ }
+ else if( ! strncmp( pcLine , "sbp" , 3 ) ){
+ if( m_bIsRunning ) {
+ (*m_pDebuggingRef)->setBreakPoint( UString( L"<string>" ),
+ atoi(&pcLine[3]) , TRUE );
+ }
+ }
+ else if( ! strncmp( pcLine , "rbp" , 3 ) ){
+ if( m_bIsRunning ) {
+ (*m_pDebuggingRef)->setBreakPoint( UString( L"<string>" ),
+ atoi(&pcLine[3]) , FALSE );
+ }
+ }
+ else if( ! strncmp( pcLine , "dv " , 3 ) ) {
+ if( m_bIsRunning ) {
+ int nCallstack = 0;
+ if( sLine.GetQuotedTokenCount( String("''"),' ' ) == 3 ) {
+ nCallstack = atoi( sLine.GetQuotedToken( 3 , String("''"), ' ' ).GetCharStr() );
+ }
+
+ UString str = (*m_pDebuggingRef)->dumpVariable(
+ PCHAR_TO_USTRING( &pcLine[3]),nCallstack);
+ fprintf( stderr, "%s\n" , USTRING_TO_PCHAR( str ) );
+ }
+ }
+ else if( ! strncmp( pcLine , "sv " , 3 ) ) {
+ int nCallstack = 0;
+ if( sLine.GetQuotedTokenCount( String("''"),' ' ) == 3 ) {
+ nCallstack = atoi( sLine.GetQuotedToken( 3 , String("''"), ' ' ).GetCharStr() );
+ }
+ (*m_pDebuggingRef)->setVariable(
+ StringToOUString( sLine.GetQuotedToken( 1 , String("''"), ' ' ), CHARSET_SYSTEM ),
+ StringToOUString( sLine.GetQuotedToken( 2 , String("''"), ' ' ), CHARSET_SYSTEM ),
+ nCallstack );
+
+ }
+ else if( ! strncmp( pcLine , "ci" ,2 ) ) {
+ if( m_bIsRunning ) {
+ UString *aUString ;
+ ContextInformation ci = (*m_pDebuggingRef)->getContextInformation(atoi(&pcLine[2]));
+ int i,iMax;
+
+ fprintf( stderr, "File %s (%d)\n", USTRING_TO_PCHAR(ci.Name),
+ ci.StartLine );
+ fprintf( stderr, "Available variables : \n" );
+ aUString = ci.LocalVariableNames.getArray();
+ iMax = ci.LocalVariableNames.getLen();
+
+ for( i = 0 ; i < iMax ; i++ ) {
+ fprintf( stderr, " %s\n" , USTRING_TO_PCHAR( aUString[i]) );
+ }
+ }
+ }
+ else if ( !strcmp( pcLine , "d" ) ) {
+ if( m_bIsRunning ) {
+ UString * aUString ;
+ Sequence<UString> seq = (*m_pDebuggingRef)->getStackTrace();
+
+ aUString = seq.getArray();
+ int iMax = seq.getLen();
+ for( int i = 0; i < iMax ; i++ ) {
+ fprintf( stderr , "%s\n" , USTRING_TO_PCHAR( aUString[i] ) );
+ }
+ }
+ }
+ else if( !strcmp( pcLine , "c" ) ) {
+ if( m_bIsRunning ) {
+ (*m_pEngineRef)->cancel();
+ m_aDebugCondition.reset();
+ }
+ else fprintf( stderr,"no script running !\n" );
+ }
+ else if( !strcmp( pcLine , "q" ) ) {
+ if( m_bIsRunning ) {
+ m_aDebugCondition.reset();
+ (*m_pEngineRef)->cancel();
+ }
+ else {
+ m_bIsTerminating = TRUE;
+ fprintf(stderr, "Debugger terminates\n" );
+ break;
+ }
+ }
+ else if( ! strcmp( pcLine , "id" ) ) {
+
+ XIntrospectionAccessRef ref = (*m_pInvokationRef)->getIntrospection();
+
+ dumpIntrospectionToStream( ref , stderr );
+
+
+ }
+ else if( ! strncmp( pcLine , "idv" , 3) ) {
+ TRY {
+ UsrAny any = (*m_pInvokationRef)->getValue( PCHAR_TO_USTRING( &(pcLine[4]) ) );
+ dumpVarToStream( &(pcLine[4]) , any , stderr );
+ }
+ CATCH(UnknownPropertyException,e) {
+ fprintf( stderr, "UnknownPropertyException\n" );
+ }
+ CATCH(IllegalArgumentException,e) {
+ fprintf( stderr, "IllegalArgumentException\n" );
+ }
+ }
+ else if( !strcmp( pcLine , "t" ) ) {
+ }
+ else if( !strcmp( pcLine , "h" ) ) {
+ fprintf( stderr , "\nvalid commands :\n"
+ "Go : g\n"
+ "StepOver : s\n"
+ "StepIn : si\n"
+ "StepOut : so\n"
+ "Set BreakPoint : sbp Line [ModuleName]\n"
+ "Remove BreakPoint : rbp [Line] [ModuleName]\n"
+ "via XDebugging Interface :\n"
+ " dump Variable : dv varname [CallStack]\n"
+ " set Variable : sv varname value [CallStack]\n"
+ "globals via XInvokation Interface :\n"
+ " dump Global vars : id\n"
+ " dump Variable : idv varname\n"
+ " set Variable : isv varname value\n"
+ "ContextInformation : ci\n"
+ "Dump callstack : d\n"
+ "Cancel : c (stops actual script)\n"
+ "Quit : q (exits debugger)\n"
+ );
+ }
+ else if( ! strlen( pcLine ) ) {
+ }
+ else {
+ fprintf( stderr , "unknown command %s\n" , pcLine );
+ }
+ }
+}
+
+void CmdDebugger::dumpIntrospectionToStream( const XIntrospectionAccessRef &ref, FILE *f )
+{
+ int i,iMax;
+ fprintf( stderr, "Callable Attributes (Methods) :\n" );
+ Sequence<XIdlMethodRef> seq = ref->getMethods( 0 );
+ iMax = seq.getLen();
+ XIdlMethodRef *aRef = seq.getArray();
+ for( i = 0; i < iMax ; i++ ) {
+ fprintf( f, " %s\n" , USTRING_TO_PCHAR( aRef[i]->getName( ) ) );
+ }
+
+ fprintf( stderr, "Other attributes\n" );
+ Sequence<Property> seqProp = ref->getProperties( 0 );
+ iMax = seqProp.getLen();
+ Property *aProp = seqProp.getArray();
+ for( i = 0; i < iMax ; i ++ ) {
+ fprintf( f, " %s %s\n" , USTRING_TO_PCHAR( aProp[i].Type->getName() ),
+ USTRING_TO_PCHAR( aProp[i].Name ) );
+ }
+
+}
+
+void CmdDebugger::dumpVarToStream( const char *pc , const UsrAny &aValue, FILE *f )
+{
+ TypeClass type = aValue.getReflection()->getTypeClass();
+
+ if( TypeClass_INT == type ) {
+ fprintf( f, "INT32 %s : %d\n" , pc , aValue.getINT32() );
+ }
+ else if( TypeClass_ENUM == type ) {
+ fprintf( f, "ENUM %s : %d\n", pc , aValue.getEnumAsINT32() );
+ }
+ else if( TypeClass_STRING == type ) {
+ fprintf( f, "STRING %s : %s\n" , pc , USTRING_TO_PCHAR( aValue.getString()) );
+ }
+ else if( TypeClass_BOOLEAN == type ) {
+ fprintf( f, "BOOL %s : %d\n", pc , aValue.getBOOL() );
+ }
+ else if( TypeClass_CHAR == type ) {
+ fprintf( f, "char %s : %d\n", pc , ( INT32) aValue.getChar() );
+ }
+ else if( TypeClass_SHORT == type ) {
+ fprintf( f, "INT16 %s : %d\n", pc , (INT32) aValue.getINT16());
+ }
+ else if( TypeClass_LONG == type ) {
+ fprintf( f, "LONG %s : %d\n", pc , (INT32) aValue.getINT32());
+ }
+ else if( TypeClass_UNSIGNED_SHORT == type ) {
+ fprintf( f, "UINT16 %s : %d\n", pc , (INT32) aValue.getUINT16() );
+ }
+ else if( TypeClass_UNSIGNED_BYTE == type ) {
+ fprintf( f, "Byte %s : %d\n", pc , (INT32) aValue.getBYTE() );
+ }
+ else if( TypeClass_UNSIGNED_INT == type ) {
+ fprintf( f, "UINT32 %s : %d\n", pc , aValue.getUINT32() );
+ }
+ else if( TypeClass_FLOAT == type ) {
+ fprintf( f, "float %s : %f\n" , pc , aValue.getFloat() );
+ }
+ else if( TypeClass_DOUBLE == type ) {
+ fprintf( f, "double %s : %f\n" , pc , aValue.getDouble() );
+ }
+ else if( TypeClass_VOID == type ) {
+ fprintf( f, "void %s :\n" , pc );
+ }
+ else if( TypeClass_INTERFACE == type ) {
+ // Check, what has been put in
+ if( aValue.getReflection() == XPropertySet_getReflection() ) {
+ // XPropertySet !
+ XPropertySetRef *pRef = ( XPropertySetRef * ) aValue.get();
+ XPropertySetInfoRef refInfo = (*pRef)->getPropertySetInfo();
+ Sequence< Property > seq = refInfo->getProperties();
+ int i,iMax = seq.getLen();
+
+ Property *pArray;
+ pArray = seq.getArray();
+ fprintf( stderr, "Property List :\n" );
+ for( i = 0; i < iMax ; i ++ ) {
+ fprintf( f, "%s\t %s\n" , USTRING_TO_PCHAR(pArray[i].Type->getName()),
+ USTRING_TO_PCHAR( pArray[i].Name ) );
+ }
+ }
+ else if( aValue.getReflection() == XInvokation_getReflection() ) {
+ XInvokationRef *pRef = ( XInvokationRef * ) aValue.get();
+ XIntrospectionAccessRef refIntro = (*pRef)->getIntrospection();
+
+ dumpIntrospectionToStream( refIntro, stderr );
+ }
+ }
+ else if( TypeClass_SEQUENCE == type ) {
+ fprintf( f , "%s Sequence \n" , pc );
+ String s( " " );
+ s += pc;
+ SequenceReflection *pSeqRefl = ( SequenceReflection * ) aValue.getReflection();
+
+ int i,iMax = pSeqRefl->getLen( aValue );
+
+ for( i = 0 ; i < iMax ; i ++ ) {
+ dumpVarToStream( s.GetCharStr() , pSeqRefl->get( aValue , i ) , stderr );
+ }
+ }
+ else {
+ fprintf( f, "%s : unknown %d\n" , pc , type );
+ }
+
+}
+
+void CmdDebugger::detach()
+{
+ assert( m_pDebuggingRef );
+
+ m_bIsRunning = FALSE;
+ m_pDebuggingRef = 0;
+ m_pEngineRef = 0;
+ m_pInvokationRef = 0;
+}
+
+// Methoden von XInterface
+BOOL CmdDebugger::queryInterface( Uik aUik, XInterfaceRef & rOut )
+{
+ if( aUik == XEngineListener::getSmartUik() )
+ rOut = (XEngineListener*)this;
+ else
+ return OWeakObject::queryInterface( aUik, rOut );
+ return TRUE;
+}
+
+
+
+
+
+
+/*
+ * main.
+ */
+int __LOADONCALLAPI main (int argc, char **argv)
+{
+ XMultiServiceFactoryRef xSMgr = createRegistryServiceManager();
+ registerUsrServices( xSMgr );
+ setProcessServiceManager( xSMgr );
+
+ XInterfaceRef x = xSMgr->createInstance( L"stardiv.uno.repos.ImplementationRegistration" );
+ XImplementationRegistrationRef xReg( x, USR_QUERY );
+ sal_Char szBuf[1024];
+
+ ORealDynamicLoader::computeModuleName( "pythonengine", szBuf, 1024 );
+ UString aDllName( StringToOUString( szBuf, CHARSET_SYSTEM ) );
+ xReg->registerImplementation( L"stardiv.loader.SharedLibrary", aDllName, XSimpleRegistryRef() );
+
+ ORealDynamicLoader::computeModuleName( "aps", szBuf, 1024 );
+ aDllName = UString( StringToOUString( szBuf, CHARSET_SYSTEM ) );
+ xReg->registerImplementation( L"stardiv.loader.SharedLibrary", aDllName, XSimpleRegistryRef() );
+
+ XInterfaceRef y = xSMgr->createInstance( L"stardiv.script.Python" );
+ XEngineRef yEngine( y, USR_QUERY );
+
+ x = xSMgr->createInstance( L"stardiv.script.Python" );
+ XEngineRef xEngine( x, USR_QUERY );
+
+
+ UString Script;
+
+ Sequence<UsrAny> args(3);
+ UsrAny *pArray = args.getArray();
+ pArray[0].setString( L"Arg_0" );
+ pArray[1].setString( L"Arg_1" );
+ pArray[2].setString( L"Arg_2" );
+
+ if( argc > 2) {
+ Script = StringToOUString( String( argv[2] ) , CHARSET_DONTKNOW );
+ }
+
+ XInvokationRef xInvokation( x , USR_QUERY );
+ XDebuggingRef xDebug( x , USR_QUERY );
+
+ CmdDebugger *pDbg = new CmdDebugger( &xDebug , &xEngine , &xInvokation );
+
+ XEngineListenerRef xDebugRef( (XEngineListener *) pDbg , USR_QUERY);
+ xEngine->addEngineListener( xDebugRef );
+
+
+ if( argc >1 && ! strcmp( argv[1] , "1" ) ) {
+ fprintf( stderr, "one thread only\n" );
+ Script = UString( L"print 'Hello World'\n" );
+ xEngine->runAsync( Script , XInterfaceRef(), args , XEngineListenerRef() );
+ }
+ else if( argc >1 && ! strcmp( argv[1] , "2" ) ) {
+
+ xEngine->runAsync( UString( L"x=1\nprint 1\n") , XInterfaceRef(), args , XEngineListenerRef() );
+ xEngine->runAsync( UString( L"x=x+1\nprint 2\n") , XInterfaceRef(), args , XEngineListenerRef() );
+ xEngine->runAsync( UString( L"x=x+1\nprint 3\n") , XInterfaceRef(), args , XEngineListenerRef());
+ xEngine->runAsync( UString( L"x=x+1\nprint 4\n") , XInterfaceRef(), args , XEngineListenerRef() );
+
+
+
+ }
+ else if( argc >1 && ! strcmp( argv[1] , "3" ) ) {
+
+ fprintf( stderr , "1st thread in engine y, next 5 threads in engine x\n" );
+ yEngine->runAsync( UString( L"print 1\n") , XInterfaceRef(), args , XEngineListenerRef() );
+ xEngine->runAsync( UString( L"print 2\n") , XInterfaceRef(), args , XEngineListenerRef() );
+ xEngine->runAsync( UString( L"print 3\n") , XInterfaceRef(), args , XEngineListenerRef() );
+ xEngine->runAsync( UString( L"print 4\n") , XInterfaceRef(), args , XEngineListenerRef());
+ xEngine->runAsync( UString( L"print 5\n") , XInterfaceRef(), args , XEngineListenerRef());
+ xEngine->runAsync( UString( L"print 6\n") , XInterfaceRef(), args , XEngineListenerRef());
+
+
+ }
+ pDbg->cmdLine();
+
+ xEngine->removeEngineListener( xDebugRef );
+
+ xReg->revokeImplementation( aDllName, XSimpleRegistryRef() );
+
+ fprintf( stderr, "main terminates\n" );
+ return 0;
+}
+
diff --git a/extensions/workben/testcomponent.cxx b/extensions/workben/testcomponent.cxx
new file mode 100644
index 000000000000..1457567b38b2
--- /dev/null
+++ b/extensions/workben/testcomponent.cxx
@@ -0,0 +1,261 @@
+/*************************************************************************
+ *
+ * $RCSfile: testcomponent.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:16:56 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+//------------------------------------------------------
+// testcomponent - Loads a service and its testcomponent from dlls performs a test.
+// Expands the dll-names depending on the actual environment.
+// Example : testcomponent stardiv.uno.io.Pipe stm
+//
+// Therefor the testcode must exist in teststm and the testservice must be named test.stardiv.uno.io.Pipe
+//
+
+#include <stdio.h>
+#include <smart/com/sun/star/registry/XImplementationRegistration.hxx>
+#include <smart/com/sun/star/lang/XComponent.hxx>
+//#include <com/sun/star/registry/ stardiv/uno/repos/simplreg.hxx>
+
+#include <vos/dynload.hxx>
+#include <vos/diagnose.hxx>
+#include <usr/services.hxx>
+#include <vcl/svapp.hxx>
+#include <usr/ustring.hxx>
+#include <tools/string.hxx>
+#include <vos/conditn.hxx>
+
+#include <assert.h>
+
+#include <smart/com/sun/star/test/XSimpleTest.hxx>
+
+#ifdef _USE_NAMESPACE
+using namespace rtl;
+using namespace vos;
+using namespace usr;
+#endif
+
+
+// Needed to switch on solaris threads
+#ifdef SOLARIS
+extern "C" void ChangeGlobalInit();
+#endif
+
+int __LOADONCALLAPI main (int argc, char **argv)
+{
+
+ if( argc < 3) {
+ printf( "usage : testcomponent service dll [additional dlls]\n" );
+ exit( 0 );
+ }
+#ifdef SOLARIS
+ // switch on threads in solaris
+ ChangeGlobalInit();
+#endif
+
+ // create service manager
+// XMultiServiceFactoryRef xSMgr = getProcessServiceManager();
+ XMultiServiceFactoryRef xSMgr = createRegistryServiceManager();
+ assert( xSMgr.is() );
+ registerUsrServices( xSMgr );
+ setProcessServiceManager( xSMgr );
+
+ XImplementationRegistrationRef xReg;
+ XSimpleRegistryRef xSimpleReg;
+
+ TRY {
+ // Create registration service
+ XInterfaceRef x = xSMgr->createInstance(
+ UString::createFromAscii( "com.sun.star.registry.ImplementationRegistration" ) );
+ x->queryInterface( XImplementationRegistration::getSmartUik() , xReg );
+
+/* x = xSMgr->createInstance( L"stardiv.uno.repos.SimpleRegistry" );
+ assert( x.is() );
+ x->queryInterface( XSimpleRegistry::getSmartUik() , xSimpleReg );
+ assert( xSimpleReg.is() );
+ xSimpleReg->open( L"testcomp.rdb" , FALSE , TRUE );
+*/ }
+ CATCH( Exception ,e ) {
+ printf( "%s\n" , OWStringToOString( e.getName() , CHARSET_SYSTEM ).getStr() );
+ exit(1);
+ }
+ END_CATCH;
+
+ sal_Char szBuf[1024];
+ OString sTestName;
+
+ TRY {
+ // Load dll for the tested component
+ for( int n = 2 ; n <argc ; n ++ ) {
+ ORealDynamicLoader::computeModuleName( argv[n] , szBuf, 1024 );
+ UString aDllName( OStringToOWString( szBuf, CHARSET_SYSTEM ) );
+
+ xReg->registerImplementation(
+ UString::createFromAscii( "com.sun.star.loader.SharedLibrary" ),
+ aDllName,
+ xSimpleReg );
+ }
+ }
+ CATCH( Exception, e ) {
+ printf( "Couldn't reach dll %s\n" , szBuf );
+ printf( "%s\n" , OWStringToOString( e.getName() , CHARSET_SYSTEM ).getStr() );
+
+ exit(1);
+ }
+ END_CATCH;
+
+
+ TRY {
+ // Load dll for the test component
+ sTestName = "test";
+ sTestName += argv[2];
+
+ ORealDynamicLoader::computeModuleName( sTestName.getStr() , szBuf, 1024 );
+ UString aDllName = OStringToOWString( szBuf, CHARSET_SYSTEM );
+ xReg->registerImplementation(
+ UString::createFromAscii( "com.sun.star.loader.SharedLibrary" ) ,
+ aDllName,
+ xSimpleReg );
+ }
+ CATCH( Exception , e ) {
+ printf( "Couldn't reach dll %s\n" , szBuf );
+ printf( "%s\n" , OWStringToOString( e.getName() , CHARSET_SYSTEM ).getStr() );
+ exit(1);
+ }
+ END_CATCH;
+
+
+ // Instantiate test service
+ sTestName = "test.";
+ sTestName += argv[1];
+
+ XInterfaceRef xIntTest = xSMgr->createInstance( OStringToOWString( sTestName , CHARSET_SYSTEM ) );
+ XSimpleTestRef xTest( xIntTest , USR_QUERY );
+
+ if( ! xTest.is() ) {
+ printf( "Couldn't instantiate test service \n" );
+ exit( 1 );
+ }
+
+
+ INT32 nHandle = 0;
+ INT32 nNewHandle;
+ INT32 nErrorCount = 0;
+ INT32 nWarningCount = 0;
+
+ // loop until all test are performed
+ while( nHandle != -1 ) {
+
+ // Instantiate serivce
+ XInterfaceRef x = xSMgr->createInstance( OStringToOWString( argv[1] , CHARSET_SYSTEM ) );
+ if( ! x.is() ) {
+ printf( "Couldn't instantiate service !\n" );
+ exit( 1 );
+ }
+
+ // do the test
+ TRY {
+ nNewHandle = xTest->test( OStringToOWString( argv[1] , CHARSET_SYSTEM ) , x , nHandle );
+ }
+ CATCH ( Exception , e ) {
+ printf( "testcomponent : uncaught exception %s\n" ,
+ OWStringToOString( e.getName(), CHARSET_SYSTEM ).getStr() );
+ exit(1);
+ }
+ AND_CATCH_ALL() {
+ printf( "testcomponent : uncaught unknown exception\n" );
+ exit(1);
+ }
+ END_CATCH;
+
+
+ // print errors and warning
+ Sequence<UString> seqErrors = xTest->getErrors();
+ Sequence<UString> seqWarnings = xTest->getWarnings();
+ if( seqWarnings.getLen() > nWarningCount ) {
+ printf( "Warnings during test %d!\n" , nHandle );
+ for( ; nWarningCount < seqWarnings.getLen() ; nWarningCount ++ ) {
+ printf( "Warning\n%s\n---------\n" ,
+ OWStringToOString( seqWarnings.getArray()[nWarningCount], CHARSET_SYSTEM ).getStr() );
+ }
+ }
+
+
+ if( seqErrors.getLen() > nErrorCount ) {
+ printf( "Errors during test %d!\n" , nHandle );
+ for( ; nErrorCount < seqErrors.getLen() ; nErrorCount ++ ) {
+ printf( "%s\n" ,
+ OWStringToOString(
+ seqErrors.getArray()[nErrorCount], CHARSET_SYSTEM ).getStr() );
+ }
+ }
+
+ nHandle = nNewHandle;
+ }
+
+ if( xTest->testPassed() ) {
+ printf( "Test passed !\n" );
+ }
+ else {
+ printf( "Test failed !\n" );
+ }
+
+ XComponentRef rComp( xSMgr , USR_QUERY );
+ rComp->dispose();
+ return 0;
+}
diff --git a/extensions/workben/testframecontrol.cxx b/extensions/workben/testframecontrol.cxx
new file mode 100644
index 000000000000..4404dd0202b1
--- /dev/null
+++ b/extensions/workben/testframecontrol.cxx
@@ -0,0 +1,355 @@
+/*************************************************************************
+ *
+ * $RCSfile: testframecontrol.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:16:56 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#pragma hdrstop
+//#include <vos/mutex.hxx>
+#include <vos/dynload.hxx>
+
+#include <vcl/wrkwin.hxx>
+#include <vcl/svapp.hxx>
+
+#include <stardiv/uno/repos/implementationregistration.hxx>
+#include <stardiv/uno/repos/serinfo.hxx>
+#include <stardiv/uno/awt/vcllstnr.hxx>
+#include <stardiv/uno/awt/device.hxx>
+#include <stardiv/uno/awt/graphics.hxx>
+#include <stardiv/uno/awt/vclwin.hxx>
+
+#include <usr/services.hxx>
+
+#include <svtools/unoiface.hxx>
+
+#ifdef _USE_NAMESPACE
+using namespace vos;
+using namespace usr;
+#endif
+
+//==================================================================================================
+class Listener_Impl
+ : public UsrObject
+ , public XMouseListener
+ , public XMouseMotionListener
+ , public XKeyListener
+ , public XWindowListener
+ , public XFocusListener
+ , public XPaintListener
+{
+public:
+ SMART_UNO_DECLARATION( Listener_Impl, UsrObject );
+
+ virtual BOOL queryInterface( Uik aUik, XInterfaceRef& rOut );
+
+ // XMouseListener
+ virtual void mousePressed( const VclMouseEvent& evt );
+ virtual void mouseReleased( const VclMouseEvent& evt );
+ virtual void mouseEntered( const VclMouseEvent& evt );
+ virtual void mouseExited( const VclMouseEvent& evt );
+
+ // XMouseMotionListener
+ virtual void mouseDragged( const VclMouseEvent& evt );
+ virtual void mouseMoved( const VclMouseEvent& evt );
+
+ // XKeyListener
+ virtual void keyPressed( const VclKeyEvent& evt );
+ virtual void keyReleased( const VclKeyEvent& evt );
+
+ // XFocusListener
+ virtual void focusGained( const FocusEvent& evt );
+ virtual void focusLost( const FocusEvent& evt );
+
+ // XWindowListener
+ virtual void windowResized( const WindowEvent& evt );
+ virtual void windowMoved( const WindowEvent& evt );
+ virtual void windowShown( const EventObject& evt );
+ virtual void windowHidden( const EventObject& evt );
+
+ // XPaintListener
+ virtual void windowPaint( const PaintEvent& evt );
+
+ // XEventListener
+ virtual void disposing( const EventObject& evt );
+
+public:
+ void addAllListeners( const XControlRef& xControl );
+ void removeAllListeners( const XControlRef& xControl );
+};
+
+//--------------------------------------------------------------------------------------------------
+void Listener_Impl::addAllListeners( const XControlRef& xControl )
+{
+ XWindowRef xWindow( xControl, USR_QUERY );
+
+ xWindow->addMouseListener( (XMouseListener*)this );
+ xWindow->addMouseMotionListener( (XMouseMotionListener*)this );
+ xWindow->addKeyListener( (XKeyListener*)this );
+ xWindow->addFocusListener( (XFocusListener*)this );
+ xWindow->addWindowListener( (XWindowListener*)this );
+ xWindow->addPaintListener( (XPaintListener*)this );
+ // cast due to ambiguities
+ xControl->addEventListener( (XEventListener*)(XPaintListener*)this );
+}
+
+//--------------------------------------------------------------------------------------------------
+void Listener_Impl::removeAllListeners( const XControlRef& xControl )
+{
+ XWindowRef xWindow( xControl, USR_QUERY );
+
+ xWindow->removeMouseListener( (XMouseListener*)this );
+ xWindow->removeMouseMotionListener( (XMouseMotionListener*)this );
+ xWindow->removeKeyListener( (XKeyListener*)this );
+ xWindow->removeFocusListener( (XFocusListener*)this );
+ xWindow->removeWindowListener( (XWindowListener*)this );
+ xWindow->removePaintListener( (XPaintListener*)this );
+ // cast due to ambiguities
+ xControl->removeEventListener( (XEventListener*)(XPaintListener*)this );
+}
+
+//--------------------------------------------------------------------------------------------------
+SMART_UNO_IMPLEMENTATION( Listener_Impl, UsrObject );
+
+//--------------------------------------------------------------------------------------------------
+BOOL Listener_Impl::queryInterface( Uik aUik, XInterfaceRef& rOut )
+{
+ if (aUik == XMouseListener::getSmartUik())
+ rOut = (XMouseListener*)this;
+ else if (aUik == XMouseMotionListener::getSmartUik())
+ rOut = (XMouseMotionListener*)this;
+ else if (aUik == XWindowListener::getSmartUik())
+ rOut = (XWindowListener*)this;
+ else if (aUik == XFocusListener::getSmartUik())
+ rOut = (XFocusListener*)this;
+ else if (aUik == XKeyListener::getSmartUik())
+ rOut = (XKeyListener*)this;
+ else if (aUik == XPaintListener::getSmartUik())
+ rOut = (XPaintListener*)this;
+ else if (aUik == ((XEventListener*)NULL)->getSmartUik())
+ rOut = (XEventListener*)(XMouseListener*)this;
+ else
+ return UsrObject::queryInterface( aUik, rOut );
+
+ return TRUE;
+}
+
+//--------------------------------------------------------------------------------------------------
+// XMouseListener
+void Listener_Impl::mousePressed( const VclMouseEvent& evt ) {}
+void Listener_Impl::mouseReleased( const VclMouseEvent& evt ) {}
+void Listener_Impl::mouseEntered( const VclMouseEvent& evt ) {}
+void Listener_Impl::mouseExited( const VclMouseEvent& evt ) {}
+
+// XMouseMotionListener
+void Listener_Impl::mouseDragged( const VclMouseEvent& evt ) {}
+void Listener_Impl::mouseMoved( const VclMouseEvent& evt ) {}
+
+// XKeyListener
+void Listener_Impl::keyPressed( const VclKeyEvent& evt ) {}
+void Listener_Impl::keyReleased( const VclKeyEvent& evt ) {}
+
+// XFocusListener
+void Listener_Impl::focusGained( const FocusEvent& evt ) {}
+void Listener_Impl::focusLost( const FocusEvent& evt ) {}
+
+// XWindowListener
+void Listener_Impl::windowResized( const WindowEvent& evt ) {}
+void Listener_Impl::windowMoved( const WindowEvent& evt ) {}
+void Listener_Impl::windowShown( const EventObject& evt ) {}
+void Listener_Impl::windowHidden( const EventObject& evt ) {}
+
+// XPaintListener
+void Listener_Impl::windowPaint( const PaintEvent& evt )
+{
+ if (evt.Source.is())
+ {
+ XControlRef xControl( evt.Source, USR_QUERY );
+ if (xControl.is())
+ {
+ XDeviceRef xDev( xControl->getPeer(), USR_QUERY );
+ XGraphicsRef xGraphics = xDev->createGraphics();
+ xGraphics->drawLine( 0, 0, 200, 200 );
+ xGraphics->drawLine( 200, 0, 0, 200 );
+ }
+ }
+}
+
+// XEventListener
+void Listener_Impl::disposing( const EventObject& evt ) {}
+
+
+//==================================================================================================
+class FrameControlApplication
+ : public Application
+{
+public:
+ virtual void Main();
+ virtual void ShowStatusText( const XubString& rText );
+
+public:
+ FrameControlApplication() {}
+
+private:
+ void init();
+ void deinit();
+
+private:
+ Listener_Impl* _pListener;
+ XControlRef _xControl;
+
+ WorkWindow* _pWorkWin;
+};
+
+FrameControlApplication g_App;
+
+#ifdef __MWERKS__
+Application* pApp = &g_App;
+#endif
+
+
+//--------------------------------------------------------------------------------------------------
+void FrameControlApplication::init()
+{
+ XMultiServiceFactoryRef xMgr = createRegistryServiceManager( L"test.rdb" );
+ registerUsrServices( xMgr );
+ setProcessServiceManager( xMgr );
+ InitExtVclToolkit();
+ Application::RegisterUnoServices();
+
+ XServiceRegistryRef xRegMgr(xMgr, USR_QUERY);
+
+ XImplementationRegistrationRef xIR( xMgr->createInstance(L"stardiv.uno.repos.ImplementationRegistration"), USR_QUERY );
+ TRY
+ {
+ char szDllName[_MAX_PATH]="";
+
+ ORealDynamicLoader::computeModuleName("fc", szDllName, _MAX_PATH);
+ UString aFCDllName = StringToOUString(szDllName, CHARSET_SYSTEM);
+ xIR->registerImplementation(L"stardiv.loader.SharedLibrary", aFCDllName, XSimpleRegistryRef() );
+ }
+ CATCH( CannotRegisterImplementationException, e )
+ {
+ }
+ END_CATCH;
+
+
+
+ // ...
+
+ XInterfaceRef xInst = xMgr->createInstance( L"stardiv.one.frame.FrameControl" );
+ if (xInst->queryInterface( XControl::getSmartUik(), _xControl ))
+ {
+ _pWorkWin = new WorkWindow( NULL, WB_APP | WB_STDWORK );
+ _pWorkWin->Show();
+ XWindowPeerRef xParent( _pWorkWin->GetComponentInterface() );
+
+ XToolkitRef xToolkit( xMgr->createInstance( L"stardiv.vcl.VclToolkit" ), USR_QUERY );
+ //xToolkit = XToolkitRef( xMgr->createInstance( L"stardiv.uno.awt.Toolkit" ), USR_QUERY );
+ _xControl->createPeer( xToolkit, xParent );
+ XWindowRef xWin( _xControl, USR_QUERY );
+ xWin->setPosSize( 50, 50, 400, 400, PosSize_POSSIZE );
+ xWin->setVisible( TRUE );
+
+ _pListener = new Listener_Impl();
+ _pListener->acquire();
+ _pListener->addAllListeners( _xControl );
+ // ... on paint a cross should be drawn
+ }
+}
+
+//--------------------------------------------------------------------------------------------------
+void FrameControlApplication::deinit()
+{
+ if (_pListener)
+ {
+
+ _pListener->removeAllListeners( _xControl );
+ _xControl->dispose(); // disposing event should occur
+ _pListener->release();
+ _pListener = NULL;
+
+ _xControl = XControlRef();
+ }
+
+ _pWorkWin->Hide();
+ delete _pWorkWin;
+}
+
+
+//--------------------------------------------------------------------------------------------------
+void FrameControlApplication::Main()
+{
+// void TestErrcodes();
+// TestErrcodes();
+
+ EnterMultiThread();
+ SetAppName( "RadioActiveControl-Demo" );
+ EnableSVLook();
+
+ init();
+
+ Execute();
+
+ deinit();
+}
+
+//--------------------------------------------------------------------------------------------------
+void FrameControlApplication::ShowStatusText( const XubString& rStatus )
+{
+ Application::GetAppWindow()->SetText( rStatus );
+}
diff --git a/extensions/workben/testpgp.cxx b/extensions/workben/testpgp.cxx
new file mode 100644
index 000000000000..0271d837bf62
--- /dev/null
+++ b/extensions/workben/testpgp.cxx
@@ -0,0 +1,918 @@
+/*************************************************************************
+ *
+ * $RCSfile: testpgp.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:16:56 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _SAL_TYPES_H_
+#include <sal/types.h>
+#endif
+
+#ifndef _RTL_MEMORY_H_
+#include <rtl/memory.h>
+#endif
+#ifndef _RTL_WSTRING_
+#include <rtl/wstring>
+#endif
+
+#ifndef _VOS_MACROS_HXX_
+#include <vos/macros.hxx>
+#endif
+
+#ifndef _USR_SMARTSERVICES_HXX_
+#include <usr/smartservices.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_IO_XINPUTSTREAM_HPP_
+#include <com/sun/star/io/XInputStream.hpp>
+#endif
+#ifndef _COM_SUN_STAR_IO_XOUTPUTSTREAM_HPP_
+#include <com/sun/star/io/XOutputStream.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_PGP_RECIPIENTSEVENT_HPP_
+#include <com/sun/star/pgp/RecipientsEvent.hpp>
+#endif
+#ifndef _COM_SUN_STAR_PGP_SIGNATUREEVENT_HPP_
+#include <com/sun/star/pgp/SignatureEvent.hpp>
+#endif
+#ifndef _COM_SUN_STAR_PGP_XPGPDECODER_HPP_
+#include <com/sun/star/pgp/XPGPDecoder.hpp>
+#endif
+#ifndef _COM_SUN_STAR_PGP_XPGPDECODERLISTENER_HPP_
+#include <com/sun/star/pgp/XPGPDecoderListener.hpp>
+#endif
+#ifndef _COM_SUN_STAR_PGP_XPGPENCODER_HPP_
+#include <com/sun/star/pgp/XPGPEncoder.hpp>
+#endif
+#ifndef _COM_SUN_STAR_PGP_XPGPPREFERENCES_HPP_
+#include <com/sun/star/pgp/XPGPPreferences.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_UNO_XINTERFACE_HPP_
+#include <com/sun/star/uno/XInterface.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_UNO_ANY_H_
+#include <com/sun/star/uno/Any.h>
+#endif
+#ifndef _COM_SUN_STAR_UNO_REFERENCE_H_
+#include <com/sun/star/uno/Reference.h>
+#endif
+#ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_
+#include <com/sun/star/uno/Sequence.hxx>
+#endif
+
+#ifndef _CPPUHELPER_WEAK_HXX_
+#include <cppuhelper/weak.hxx>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <fcntl.h>
+#include <io.h>
+
+using namespace com::sun::star::lang;
+using namespace com::sun::star::io;
+using namespace com::sun::star::pgp;
+using namespace com::sun::star::uno;
+
+/*========================================================================
+ *
+ * DataSource_Impl interface.
+ *
+ *======================================================================*/
+class DataSource_Impl :
+ public OWeakObject,
+ public XInputStream
+{
+ Sequence<sal_Int8> m_buffer;
+ sal_Int32 m_position;
+ int m_fd;
+
+public:
+ DataSource_Impl (int fd = 0);
+ virtual ~DataSource_Impl (void);
+
+ void setBuffer (const Sequence<sal_Int8> &rBuffer);
+
+ /** XInterface.
+ */
+ virtual sal_Bool SAL_CALL queryInterface (
+ const Uik &rUik, Any &rIfc) throw(RuntimeException);
+
+ virtual void SAL_CALL acquire (void) throw(RuntimeException);
+
+ virtual void SAL_CALL release (void) throw(RuntimeException);
+
+ /** XInputStream.
+ */
+ virtual sal_Int32 SAL_CALL readBytes (
+ Sequence<sal_Int8> &rData, sal_Int32 nBytesToRead)
+ throw (NotConnectedException,
+ BufferSizeExceededException,
+ IOException);
+
+ virtual sal_Int32 SAL_CALL readSomeBytes (
+ Sequence<sal_Int8> &rData, sal_Int32 nMaxBytesToRead)
+ throw (NotConnectedException,
+ BufferSizeExceededException,
+ IOException);
+
+ virtual void SAL_CALL skipBytes (sal_Int32 nBytesToSkip)
+ throw (NotConnectedException,
+ BufferSizeExceededException,
+ IOException);
+
+ virtual sal_Int32 SAL_CALL available (void)
+ throw (NotConnectedException, IOException);
+
+ virtual void SAL_CALL closeInput (void)
+ throw (NotConnectedException, IOException);
+};
+
+/*========================================================================
+ *
+ * DataSink_Impl interface.
+ *
+ *======================================================================*/
+class DataSink_Impl :
+ public OWeakObject,
+ public XOutputStream
+{
+ Sequence<sal_Int8> m_buffer;
+
+public:
+ DataSink_Impl (void);
+ virtual ~DataSink_Impl (void);
+
+ const Sequence<sal_Int8>& getBuffer (void) const { return m_buffer; }
+
+ /** XInterface.
+ */
+ virtual sal_Bool SAL_CALL queryInterface (
+ const Uik &rUik, Any &rIfc) throw(RuntimeException);
+
+ virtual void SAL_CALL acquire (void) throw(RuntimeException);
+ virtual void SAL_CALL release (void) throw(RuntimeException);
+
+ /** XOutputStream.
+ */
+ virtual void SAL_CALL writeBytes (
+ const Sequence<sal_Int8> &rBuffer)
+ throw (NotConnectedException,
+ BufferSizeExceededException,
+ IOException);
+
+ virtual void SAL_CALL flush (void)
+ throw (NotConnectedException,
+ BufferSizeExceededException,
+ IOException);
+
+ virtual void SAL_CALL closeOutput (void)
+ throw (NotConnectedException,
+ BufferSizeExceededException,
+ IOException);
+};
+
+/*========================================================================
+ *
+ * DecoderListener_Impl interface.
+ *
+ *======================================================================*/
+class DecoderListener_Impl :
+ public OWeakObject,
+ public XPGPDecoderListener
+{
+public:
+ DecoderListener_Impl (void);
+ virtual ~DecoderListener_Impl (void);
+
+ /** XInterface.
+ */
+ virtual sal_Bool SAL_CALL queryInterface (
+ const Uik &rUik, Any &rIfc) throw(RuntimeException);
+
+ virtual void SAL_CALL acquire (void) throw(RuntimeException);
+
+ virtual void SAL_CALL release (void) throw(RuntimeException);
+
+ /** XEventListener.
+ */
+ virtual void SAL_CALL disposing (const EventObject &rSource);
+
+ /** XPGPDecoderListener.
+ */
+ virtual void SAL_CALL decrypted (const RecipientsEvent &rEvent);
+ virtual void SAL_CALL verified (const SignatureEvent &rEvent);
+};
+
+/*========================================================================
+ *
+ * DataSource_Impl implementation.
+ *
+ *======================================================================*/
+/*
+ * DataSource_Impl.
+ */
+DataSource_Impl::DataSource_Impl (int fd)
+ : m_fd (fd), m_position (0)
+{
+}
+
+/*
+ * ~DataSource_Impl.
+ */
+DataSource_Impl::~DataSource_Impl (void)
+{
+}
+
+/*
+ * DataSource_Impl: setBuffer.
+ */
+void DataSource_Impl::setBuffer (const Sequence<sal_Int8> &rBuffer)
+{
+ m_buffer = rBuffer;
+ if (!m_buffer.getLength())
+ {
+ // Fill buffer from file descriptor.
+ char buffer[1024];
+ rtl_zeroMemory (buffer, sizeof(buffer));
+
+ int k = read (m_fd, buffer, sizeof(buffer));
+ while (k > 0)
+ {
+ sal_Int32 n = m_buffer.getLength();
+ m_buffer.realloc (n + k);
+
+ rtl_copyMemory (m_buffer.getArray() + n, buffer, k);
+ n += k;
+
+ rtl_zeroMemory (buffer, k);
+ k = read (m_fd, buffer, sizeof(buffer));
+ }
+ }
+ m_position = 0;
+}
+
+/*
+ * XInterface: queryInterface.
+ */
+sal_Bool SAL_CALL DataSource_Impl::queryInterface (
+ const Uik &rUik, Any &rIfc) throw(RuntimeException)
+{
+ if (com::sun::star::uno::queryInterface (
+ rUik, rIfc,
+ SAL_STATIC_CAST (XInputStream*, this)))
+ return sal_True;
+ else
+ return OWeakObject::queryInterface (rUik, rIfc);
+}
+
+/*
+ * XInterface: acquire.
+ */
+void SAL_CALL DataSource_Impl::acquire (void) throw(RuntimeException)
+{
+ OWeakObject::acquire();
+}
+
+/*
+ * XInterface: release.
+ */
+void SAL_CALL DataSource_Impl::release (void) throw(RuntimeException)
+{
+ OWeakObject::release();
+}
+
+/*
+ * XInputStream: readBytes.
+ */
+sal_Int32 SAL_CALL DataSource_Impl::readBytes (
+ Sequence<sal_Int8> &rData, sal_Int32 nBytesToRead)
+ throw (NotConnectedException, BufferSizeExceededException, IOException)
+{
+ if (nBytesToRead < 0)
+ throw IOException();
+
+ sal_Int32 k = m_buffer.getLength() - m_position;
+ k = VOS_BOUND(k, 0, nBytesToRead);
+ if (k > 0)
+ {
+ rData.realloc(k);
+ rtl_copyMemory (
+ rData.getArray(), m_buffer.getConstArray() + m_position, k);
+ m_position += k;
+ }
+ return k;
+}
+
+/*
+ * XInputStream: readSomeBytes.
+ */
+sal_Int32 SAL_CALL DataSource_Impl::readSomeBytes (
+ Sequence<sal_Int8> &rData, sal_Int32 nMaxBytesToRead)
+ throw (NotConnectedException, BufferSizeExceededException, IOException)
+{
+ return readBytes (rData, nMaxBytesToRead);
+}
+
+/*
+ * XInputStream: skipBytes.
+ */
+void SAL_CALL DataSource_Impl::skipBytes (sal_Int32 nBytesToSkip)
+ throw (NotConnectedException, BufferSizeExceededException, IOException)
+{
+ if (nBytesToSkip < 0)
+ throw IOException();
+
+ m_position += nBytesToSkip;
+}
+
+/*
+ * XInputStream: available.
+ */
+sal_Int32 SAL_CALL DataSource_Impl::available (void)
+ throw (NotConnectedException, IOException)
+{
+ sal_Int32 k = m_buffer.getLength() - m_position;
+ return ((k > 0) ? k : 0);
+}
+
+/*
+ * XInputStream: closeInput.
+ */
+void SAL_CALL DataSource_Impl::closeInput (void)
+ throw (NotConnectedException, IOException)
+{
+}
+
+/*========================================================================
+ *
+ * DataSink_Impl implementation.
+ *
+ *======================================================================*/
+/*
+ * DataSink_Impl.
+ */
+DataSink_Impl::DataSink_Impl (void)
+{
+}
+
+/*
+ * ~DataSink_Impl.
+ */
+DataSink_Impl::~DataSink_Impl (void)
+{
+}
+
+/*
+ * XInterface: queryInterface.
+ */
+sal_Bool SAL_CALL DataSink_Impl::queryInterface (
+ const Uik &rUik, Any &rIfc) throw(RuntimeException)
+{
+ if (com::sun::star::uno::queryInterface (
+ rUik, rIfc,
+ SAL_STATIC_CAST (XOutputStream*, this)))
+ return sal_True;
+ else
+ return OWeakObject::queryInterface (rUik, rIfc);
+}
+
+/*
+ * XInterface: acquire.
+ */
+void SAL_CALL DataSink_Impl::acquire (void) throw(RuntimeException)
+{
+ OWeakObject::acquire();
+}
+
+/*
+ * XInterface: release.
+ */
+void SAL_CALL DataSink_Impl::release (void) throw(RuntimeException)
+{
+ OWeakObject::release();
+}
+
+/*
+ * XOutputStream: writeBytes.
+ */
+void SAL_CALL DataSink_Impl::writeBytes (const Sequence<sal_Int8> &rBuffer)
+ throw (NotConnectedException, BufferSizeExceededException, IOException)
+{
+ if (rBuffer.getLength())
+ {
+ sal_Int32 n = m_buffer.getLength();
+ m_buffer.realloc (n + rBuffer.getLength());
+
+ rtl_copyMemory (
+ m_buffer.getArray() + n,
+ rBuffer.getConstArray(),
+ rBuffer.getLength());
+ }
+}
+
+/*
+ * XOutputStream: flush.
+ */
+void SAL_CALL DataSink_Impl::flush (void)
+ throw (NotConnectedException, BufferSizeExceededException, IOException)
+{
+ if (m_buffer.getLength())
+ {
+ // Write data to stdout.
+ const sal_Int8 *pData = m_buffer.getConstArray();
+ sal_Int32 nData = m_buffer.getLength();
+
+ int prev = ::setmode (1, O_BINARY);
+ if (!(prev < 0))
+ {
+ int k = ::write (1, pData, nData);
+ if (k > 0)
+ ::write (1, "\n", 1);
+ ::setmode (1, prev);
+ }
+ }
+}
+
+/*
+ * XOutputStream: closeOutput.
+ */
+void SAL_CALL DataSink_Impl::closeOutput (void)
+ throw (NotConnectedException, BufferSizeExceededException, IOException)
+{
+ flush();
+}
+
+/*========================================================================
+ *
+ * DecoderListener_Impl implementation.
+ *
+ *======================================================================*/
+/*
+ * DecoderListener_Impl.
+ */
+DecoderListener_Impl::DecoderListener_Impl (void)
+{
+}
+
+/*
+ * ~DecoderListener_Impl.
+ */
+DecoderListener_Impl::~DecoderListener_Impl (void)
+{
+}
+
+/*
+ * XInterface: queryInterface.
+ */
+sal_Bool SAL_CALL DecoderListener_Impl::queryInterface (
+ const Uik &rUik, Any &rIfc) throw(RuntimeException)
+{
+ if (com::sun::star::uno::queryInterface (
+ rUik, rIfc,
+ SAL_STATIC_CAST (XEventListener*, this),
+ SAL_STATIC_CAST (XPGPDecoderListener*, this)))
+ return sal_True;
+ else
+ return OWeakObject::queryInterface (rUik, rIfc);
+}
+
+/*
+ * XInterface: acquire.
+ */
+void SAL_CALL DecoderListener_Impl::acquire (void) throw(RuntimeException)
+{
+ OWeakObject::acquire();
+}
+
+/*
+ * XInterface: release.
+ */
+void SAL_CALL DecoderListener_Impl::release (void) throw(RuntimeException)
+{
+ OWeakObject::release();
+}
+
+/*
+ * XEventListener: disposing.
+ */
+void SAL_CALL DecoderListener_Impl::disposing (const EventObject &rSource)
+{
+}
+
+/*
+ * XPGPDecoderListener: decrypted.
+ */
+void SAL_CALL DecoderListener_Impl::decrypted (const RecipientsEvent &rEvent)
+{
+}
+
+/*
+ * XPGPDecoderListener: verified.
+ */
+void SAL_CALL DecoderListener_Impl::verified (const SignatureEvent &rEvent)
+{
+}
+
+/*========================================================================
+ *
+ * Main.
+ *
+ *======================================================================*/
+inline rtl::OWString S2U (const sal_Char *ascii)
+{
+ return rtl::OWString::createFromAscii (ascii);
+}
+
+#if 0 /* OLD */
+
+/*
+ * queryModuleActivator.
+ */
+BOOL queryModuleActivator (
+ const XServiceManagerRef &rxManager,
+ XServiceActivatorRef &rxActivator)
+{
+ XServiceProviderRef xProv;
+ XInterfaceRef xProvInst;
+
+ xProv = rxManager->queryServiceProvider (
+ L"stardiv.uno.ServiceActivator.module");
+ if (!xProv.is())
+ {
+ printf ("Error: no ServiceActivator service.\n");
+ return FALSE;
+ }
+
+ xProvInst = xProv->createInstance();
+ if (!xProvInst.is())
+ {
+ printf ("Error: no ServiceActivator instance.\n");
+ return FALSE;
+ }
+
+ return xProvInst->queryInterface (
+ XServiceActivator::getSmartUik(), rxActivator);
+}
+
+/*
+ * install.
+ */
+BOOL install (
+ const XServiceActivatorRef &rxActivator,
+ const char *prefix)
+{
+ String aModule ("module://");
+ char pBuffer[1024];
+
+ NAMESPACE_VOS(ORealDynamicLoader)::computeModuleName (
+ prefix, pBuffer, sizeof(pBuffer));
+ aModule += pBuffer;
+
+ return rxActivator->install (
+ StringToUString (aModule, CHARSET_SYSTEM));
+}
+
+/*
+ * uninstall.
+ */
+BOOL uninstall (
+ const XServiceActivatorRef &rxActivator,
+ const char *prefix)
+{
+ String aModule ("module://");
+ char pBuffer[1024];
+
+ NAMESPACE_VOS(ORealDynamicLoader)::computeModuleName (
+ prefix, pBuffer, sizeof(pBuffer));
+ aModule += pBuffer;
+
+ return rxActivator->deinstall (
+ StringToUString (aModule, CHARSET_SYSTEM));
+}
+
+#endif /* OLD */
+
+/*
+ * main.
+ */
+int SAL_CALL main (int argc, char **argv)
+{
+ enum Option
+ {
+ OPTION_INSTALL = 0x01,
+ OPTION_UNINSTALL = 0x02,
+
+ OPTION_DECRYPT = 0x04,
+ OPTION_ENCRYPT = 0x08,
+ OPTION_SIGN = 0x10,
+
+ OPTION_FILE = 0x20,
+ OPTION_HELP = 0x40
+ };
+
+ int fd = 0;
+ unsigned long nOptions = 0;
+
+ for (int i = 1; i < argc; i++)
+ {
+ const char *opt = argv[i];
+ if (opt[0] == '-')
+ {
+ switch (opt[1])
+ {
+ case 'i':
+ nOptions |= OPTION_INSTALL;
+ break;
+
+ case 'u':
+ nOptions |= OPTION_UNINSTALL;
+ break;
+
+ case 'd':
+ nOptions |= OPTION_DECRYPT;
+ break;
+
+ case 'e':
+ nOptions |= OPTION_ENCRYPT;
+ break;
+
+ case 's':
+ nOptions |= OPTION_SIGN;
+ break;
+
+ case 'f':
+ nOptions |= OPTION_FILE;
+ break;
+
+ case 'h':
+ default:
+ nOptions |= OPTION_HELP;
+ break;
+ }
+ }
+ else
+ {
+ if (nOptions & OPTION_FILE)
+ {
+ if ((fd = open (argv[i], O_RDONLY | O_BINARY)) < 0)
+ {
+ printf ("Error: can't open file: %s\n", argv[i]);
+ exit (0);
+ }
+ }
+ }
+ }
+
+ if ((nOptions == 0) || (nOptions & OPTION_HELP))
+ {
+ printf ("Options:\n");
+ printf ("-i\tinstall module\n");
+ printf ("-u\tuninstall module\n");
+ printf ("-d\tdecrypt and verify\n");
+ printf ("-e\tencrypt test pattern\n");
+ printf ("-s\tsign test pattern\n");
+ printf ("-h\thelp\n");
+ exit (0);
+ }
+
+ Reference<XMultiServiceFactory> xManager (
+ usr::createDefaultSmartRegistryServiceFactory());
+ if (!xManager.is())
+ {
+ printf ("Error: no ProcessServiceManager.\n");
+ exit (1);
+ }
+ usr::setProcessServiceFactory (xManager);
+
+ if (nOptions & OPTION_INSTALL)
+ {
+#if 0 /* OLD */
+ XServiceActivatorRef xActivator;
+ if (queryModuleActivator (xManager, xActivator))
+ {
+ if (install (xActivator, "pgp"))
+ printf ("Module PGP installed.\n");
+ else
+ printf ("Error: module PGP not installed.\n");
+ }
+ nOptions &= ~OPTION_INSTALL;
+#endif /* OLD */
+ }
+
+ if (nOptions & (OPTION_DECRYPT | OPTION_ENCRYPT | OPTION_SIGN))
+ {
+ Reference<XMultiServiceFactory> xProv (
+ xManager->createInstance (
+ S2U("com.sun.star.pgp.PGPFactory")),
+ UNO_QUERY);
+ if (!xProv.is())
+ {
+ printf ("Error: no PGPFactory service.\n");
+ exit (1);
+ }
+
+ Reference<XInterface> xProvInst (
+ xProv->createInstance (
+ S2U("com.sun.star.pgp.SimplePGPMailer")));
+ if (!xProvInst.is())
+ {
+ printf ("Error: no SimplePGPMailer service.\n");
+ exit (2);
+ }
+
+ Reference<XPGPPreferences> xPrefs (xProvInst, UNO_QUERY);
+ if (xPrefs.is())
+ {
+ unsigned long nDefaults = 0;
+
+ if (xPrefs->getEncryptByDefault())
+ nDefaults |= OPTION_ENCRYPT;
+ if (xPrefs->getSignByDefault())
+ nDefaults |= OPTION_SIGN;
+ if (xPrefs->getAutoDecrypt())
+ nDefaults |= OPTION_DECRYPT;
+
+ if (nDefaults)
+ {
+ }
+ }
+
+ static const sal_Int8 pData[] = "" /* "Hello PGP World." */;
+ Sequence<sal_Int8> buffer (pData, sizeof (pData) - 1);
+
+ if (nOptions & (OPTION_ENCRYPT | OPTION_SIGN))
+ {
+ Reference<XPGPEncoder> xEncoder (xProvInst, UNO_QUERY);
+ if (!xEncoder.is())
+ {
+ printf ("Error: no PGPEncoder interface.\n");
+ exit (4);
+ }
+
+ DataSource_Impl *source = new DataSource_Impl (fd);
+ source->setBuffer (buffer);
+
+ DataSink_Impl *sink = new DataSink_Impl;
+
+ Reference<XInputStream> xPlainText (source);
+ Reference<XOutputStream> xCipherText (sink);
+
+ if (nOptions & OPTION_ENCRYPT)
+ {
+ rtl::OWString aRecipients[] =
+ {
+ S2U("er@stardiv.de"),
+ // L"mhu@stardivision.de",
+ S2U("mhu@rabbit")
+ };
+
+ sal_Int32 nRecipients =
+ sizeof(aRecipients) / sizeof(aRecipients[0]);
+
+ if (nOptions & OPTION_SIGN)
+ {
+ xEncoder->encryptAndSign (
+ Sequence<rtl::OWString>(aRecipients, nRecipients),
+ xPlainText,
+ xCipherText);
+ nOptions &= ~OPTION_SIGN;
+ }
+ else
+ {
+ xEncoder->encrypt (
+ Sequence<rtl::OWString>(aRecipients, nRecipients),
+ xPlainText,
+ xCipherText);
+ }
+ nOptions &= ~OPTION_ENCRYPT;
+ }
+
+ if (nOptions & OPTION_SIGN)
+ {
+ sal_Bool bDataIsAscii = (fd == 0); // stdin.
+
+ xEncoder->sign (
+ bDataIsAscii,
+ xPlainText,
+ xCipherText);
+ nOptions &= ~OPTION_SIGN;
+ }
+
+ buffer = sink->getBuffer();
+ }
+
+ if (nOptions & OPTION_DECRYPT)
+ {
+ Reference<XPGPDecoder> xDecoder (xProvInst, UNO_QUERY);
+ if (!xDecoder.is())
+ {
+ printf ("Error: no PGPDecoder interface.\n");
+ exit (5);
+ }
+
+ DataSource_Impl *source = new DataSource_Impl;
+ source->setBuffer (buffer);
+
+ DataSink_Impl *sink = new DataSink_Impl;
+
+ Reference<XInputStream> xCipherText (source);
+ Reference<XOutputStream> xPlainText (sink);
+
+ Reference<XPGPDecoderListener> xListener (
+ new DecoderListener_Impl);
+ xDecoder->addDecoderListener (xListener);
+
+ xDecoder->decryptAndVerify (
+ xCipherText,
+ xPlainText);
+ nOptions &= ~OPTION_DECRYPT;
+
+ xDecoder->removeDecoderListener (xListener);
+
+ buffer = sink->getBuffer();
+ }
+ }
+
+ if (nOptions & OPTION_UNINSTALL)
+ {
+#if 0 /* OLD */
+ XServiceActivatorRef xActivator;
+ if (queryModuleActivator (xManager, xActivator))
+ {
+ if (uninstall (xActivator, "pgp"))
+ printf ("Module PGP uninstalled.\n");
+ else
+ printf ("Error: module PGP not uninstalled.\n");
+ }
+ nOptions &= ~OPTION_UNINSTALL;
+#endif /* OLD */
+ }
+
+ return 0;
+}
+
diff --git a/extensions/workben/testresource.cxx b/extensions/workben/testresource.cxx
new file mode 100644
index 000000000000..dc4a82fb203c
--- /dev/null
+++ b/extensions/workben/testresource.cxx
@@ -0,0 +1,125 @@
+/*************************************************************************
+ *
+ * $RCSfile: testresource.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:16:56 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <smart/com/sun/star/registry/XImplementationRegistration.hxx>
+#include <smart/com/sun/star/script/XInvocation.hxx>
+
+#include <rtl/ustring.hxx>
+#include <vos/dynload.hxx>
+#include <vos/diagnose.hxx>
+#include <usr/services.hxx>
+#include <vcl/svapp.hxx>
+
+#ifdef _USE_NAMESPACE
+using namespace rtl;
+using namespace vos;
+using namespace usr;
+#endif
+
+class MyApp : public Application
+{
+public:
+ void Main();
+};
+
+MyApp aMyApp;
+
+// -----------------------------------------------------------------------
+
+void MyApp::Main()
+{
+ XMultiServiceFactoryRef xSMgr = createRegistryServiceManager();
+ registerUsrServices( xSMgr );
+ setProcessServiceManager( xSMgr );
+
+ XInterfaceRef x = xSMgr->createInstance( L"com.sun.star.registry.ImplementationRegistration" );
+ XImplementationRegistrationRef xReg( x, USR_QUERY );
+ sal_Char szBuf[1024];
+ ORealDynamicLoader::computeModuleName( "res", szBuf, 1024 );
+ UString aDllName( StringToOUString( szBuf, CHARSET_SYSTEM ) );
+ xReg->registerImplementation( L"com.sun.star.loader.SharedLibrary", aDllName, XSimpleRegistryRef() );
+
+ x = xSMgr->createInstance( L"com.sun.star.resource.VclStringResourceLoader" );
+ XInvocationRef xResLoader( x, USR_QUERY );
+ XIntrospectionAccessRef xIntrospection = xResLoader->getIntrospection();
+ UString aFileName( L"TestResource" );
+ UsrAny aVal;
+ aVal.setString( aFileName );
+ xResLoader->setValue( L"FileName", aVal );
+
+ Sequence< UsrAny > Args( 1 );
+ Sequence< INT16 > OutPos;
+ Sequence< UsrAny > OutArgs;
+ Args.getArray()[0].setINT32( 1000 );
+
+ BOOL b = xResLoader->invoke( L"hasString", Args, OutPos, OutArgs ).getBOOL();
+ VOS_ENSHURE( b, "hasString" );
+
+ UString aStr = xResLoader->invoke( L"getString", Args, OutPos, OutArgs ).getString();
+ VOS_ENSHURE( aStr == L"Hello", "getString" );
+
+ Args.getArray()[0].setINT32( 1001 );
+ b = xResLoader->invoke( L"hasString", Args, OutPos, OutArgs ).getBOOL();
+ VOS_ENSHURE( !b, "!hasString" );
+
+ xReg->revokeImplementation( aDllName, XSimpleRegistryRef() );
+}
+
diff --git a/extensions/workben/testresource.src b/extensions/workben/testresource.src
new file mode 100644
index 000000000000..92b6dae1cb81
--- /dev/null
+++ b/extensions/workben/testresource.src
@@ -0,0 +1,64 @@
+/*************************************************************************
+ *
+ * $RCSfile: testresource.src,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:16:56 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+String 1000
+{
+ Text = "Hello";
+};