summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2017-05-15 21:20:00 +0100
committerCaolán McNamara <caolanm@redhat.com>2017-05-16 09:15:44 +0100
commit541f9b96bec7caacf42f724ad2399d484502b2e2 (patch)
tree725777d3cc13494645b5d78a2f2f1a13cff3bded
parentf528f9499bd91b700c549575e88fa102cfffede9 (diff)
drop extensions workben
Change-Id: I799d1edae8408fe12e642aed447961a626283852
-rw-r--r--extensions/workben/makefile.mk143
-rw-r--r--extensions/workben/pythonautotest.cxx607
-rw-r--r--extensions/workben/pythontest.cxx540
-rw-r--r--extensions/workben/testcomponent.cxx205
-rw-r--r--extensions/workben/testframecontrol.cxx291
-rw-r--r--extensions/workben/testpgp.cxx741
-rw-r--r--extensions/workben/testresource.cxx80
-rw-r--r--extensions/workben/testresource.src24
8 files changed, 0 insertions, 2631 deletions
diff --git a/extensions/workben/makefile.mk b/extensions/workben/makefile.mk
deleted file mode 100644
index aec365fcd8c8..000000000000
--- a/extensions/workben/makefile.mk
+++ /dev/null
@@ -1,143 +0,0 @@
-#
-# This file is part of the LibreOffice project.
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-#
-# This file incorporates work covered by the following license notice:
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed
-# with this work for additional information regarding copyright
-# ownership. The ASF licenses this file to you under the Apache
-# License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
-#
-
-PRJ=..
-
-PRJNAME=extensions
-TARGET=workben
-LIBTARGET=NO
-
-TESTAPP=testpgp
-
-.IF "$(TESTAPP)" == "testresource" || "$(TESTAPP)" == "testframecontrol"
-TARGETTYPE=GUI
-.ELSE
-TARGETTYPE=CUI
-.ENDIF
-
-JVM_TARGET=jvmtest
-
-ENABLE_EXCEPTIONS=TRUE
-
-# --- Settings -----------------------------------------------------
-
-.INCLUDE : settings.mk
-
-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
-
-OBJFILES= $(OBJ)$/testpgp.obj
-
-APP1TARGET= testpgp
-APP1OBJS= $(OBJFILES)
-APP1STDLIBS= \
- $(CPPUHELPERLIB)\
- $(CPPULIB) \
- $(SALLIB)
-
-.ENDIF # testpgp
-
-#
-# std testcomponent
-#
-.IF "$(TESTAPP)" == "testcomponent"
-
-OBJFILES= $(OBJ)$/testcomponent.obj
-
-APP2TARGET = testcomponent
-APP2OBJS = $(OBJ)$/testcomponent.obj
-APP2STDLIBS = \
- $(TOOLSLIB) \
- $(SALLIB)
-
-.ENDIF # testcomponent
-
-#
-# test python.
-#
-.IF "$(TESTAPP)" == "phytontest"
-OBJFILES= $(OBJ)$/pythontest.obj
-.ENDIF # phytontest
-
-#
-# python auto test
-#
-.IF "$(TESTAPP)" == "phytonautotest"
-OBJFILES= $(OBJ)$/pythonautotest.obj
-.ENDIF # phytonautotest
-
-#
-# testresource.
-#
-.IF "$(TESTAPP)" == "testresource"
-
-OBJFILES= $(OBJ)$/testresource.obj
-
-SRS2NAME = testresource
-SRC2FILES= testresource.src
-RESLIB2SRSFILES= $(SRS)$/testresource.srs
-RESLIB2NAME= testresource
-
-APP2TARGET= testresource
-APP2OBJS= $(OBJ)$/testresource.obj
-APP2STDLIBS=$(TOOLSLIB) \
- $(VCLLIB) \
- $(SALLIB)
-
-.ENDIF # testresource
-
-#
-# testframecontrol.
-#
-.IF "$(TESTAPP)" == "testframecontrol"
-
-OBJFILES= $(OBJ)$/testframecontrol.obj
-
-APP3TARGET= testframecontrol
-APP3OBJS= $(OBJ)$/testframecontrol.obj
-APP3STDLIBS=$(TOOLSLIB) \
- $(SVTOOLLIB) \
- $(VCLLIB)
-
-.ENDIF # testframecontrol
-
-# --- Targets ------------------------------------------------------
-
-.INCLUDE : target.mk
-
diff --git a/extensions/workben/pythonautotest.cxx b/extensions/workben/pythonautotest.cxx
deleted file mode 100644
index e4804608bf5e..000000000000
--- a/extensions/workben/pythonautotest.cxx
+++ /dev/null
@@ -1,607 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
- */
-
-#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 <osl/diagnose.h>
-#include <usr/services.hxx>
-#include <vcl/svapp.hxx>
-#include <usr/ustring.hxx>
-#include <usr/weak.hxx>
-#include <osl/conditn.hxx>
-
-using namespace usr;
-
-using ::rtl::StringToOUString;
-
-#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() 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;
- }
-
-
- explicit 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:
-
- osl::Condition 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()
-{
- OSL_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
- OSL_ASSERT( xInvoke->hasProperty( L"list" ) );
- anyList = xInvoke->getValue( L"list" );
-
- OSL_ASSERT( anyList.getReflection() == XInvokation_getReflection() );
- XInvokationRef *pRef = ( XInvokationRef * ) anyList.get();
- OSL_ASSERT( (*pRef).is() );
-
- OSL_ASSERT( (*pRef)->hasMethod( L"append" ) );
- OSL_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>() );
-
- OSL_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() 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 SAL_CALL 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 !
- {
- OSL_ASSERT( xInvoke->hasProperty( L"nIntTest" ) );
- UsrAny any = xInvoke->getValue( L"nIntTest" );
-
- OSL_ASSERT( any.getReflection()->getTypeClass() == TypeClass_LONG );
- OSL_ASSERT( any.getINT32() == 5 );
-
- // simple test: set an int !
- xInvoke->setValue( L"nIntTest" , UsrAny( (INT32) 10 ) );
- any = xInvoke->getValue( L"nIntTest" );
-
- OSL_ASSERT( any.getReflection()->getTypeClass() == TypeClass_LONG );
- OSL_ASSERT( any.getINT32() == 10 );
- }
-
- // call a python method !
- {
- xEngine->run( L"def foo():\n"
- L" return 'this is foo'\n" , XInterfaceRef() , Sequence<UsrAny> () );
- OSL_ASSERT( xInvoke->hasMethod( L"foo" ) );
- UsrAny any = xInvoke->invoke( L"foo" ,
- Sequence<UsrAny>(),
- Sequence<INT16>() ,
- Sequence<UsrAny> () );
- OSL_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
- OSL_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();
- OSL_ASSERT( xIntrospection.is() );
-
- // no further test, simply call them
- xIntrospection->getMethods(0);
- xIntrospection->getProperties(0);
-
- OSL_ASSERT( xIntrospection->getSuppliedMethodConcepts() == 0 );
- OSL_ASSERT( xIntrospection->getSuppliedPropertyConcepts() == 0 );
-
- Property prop = xIntrospection->getProperty( L"nIntTest" ,0 );
- OSL_ASSERT( prop.Name == L"nIntTest" );
- OSL_ASSERT( prop.Type->getTypeClass() == TypeClass_LONG );
-
- XIdlMethodRef method = xIntrospection->getMethod( L"foo" , 0 );
- OSL_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" );
- OSL_ASSERT( any.getReflection()->getTypeClass() == TypeClass_LONG );
- OSL_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> () );
-
- OSL_ASSERT( xInvoke->hasProperty( L"dMathTest" ) );
- UsrAny any = xInvoke->getValue( L"dMathTest" );
-
- OSL_ASSERT( any.getReflection()->getTypeClass() == TypeClass_DOUBLE );
- OSL_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" );
- OSL_ASSERT( any.getReflection()->getTypeClass() == TypeClass_LONG );
- OSL_ASSERT( any.getINT32() == 15 );
-
- any = xInvoke->getValue( L"z" );
- OSL_ASSERT( any.getReflection()->getTypeClass() == TypeClass_LONG );
- OSL_ASSERT( any.getINT32() == 15 );
- }
-
- // Test exactName interface
- {
- UsrAny any = xInvoke->getValue( L"__builtins__" );
- OSL_ASSERT( any.getReflection()->getTypeClass() == TypeClass_INTERFACE );
-
- XInvokationRef rInv( *((XInterfaceRef *) any.get() ), USR_QUERY );
- OSL_ASSERT( rInv.is() );
-
- XExactNameRef rName( *((XInterfaceRef*) any.get() ), USR_QUERY );
- OSL_ASSERT( rName.is() );
-
- UString str = rName->getExactName( L"SYNTAXERROR" );
- OSL_ASSERT( str.len() );
- }
-
-
- // Test exactName interface of the engine itself
- {
- XExactNameRef rName( xInvoke , USR_QUERY );
- OSL_ASSERT( rName.is() );
- UString str = rName->getExactName( L"STARDIV" );
- OSL_ASSERT( str.len() );
- }
-
-
- return 0;
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/workben/pythontest.cxx b/extensions/workben/pythontest.cxx
deleted file mode 100644
index b7174dbe12ab..000000000000
--- a/extensions/workben/pythontest.cxx
+++ /dev/null
@@ -1,540 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
- */
-
-
-#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 <osl/diagnose.h>
-#include <usr/services.hxx>
-#include <vcl/svapp.hxx>
-#include <usr/ustring.hxx>
-#include <usr/weak.hxx>
-#include <osl/conditn.hxx>
-
-using namespace usr;
-
-using ::rtl::StringToOUString;
-
-
-#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:
-
- osl::Condition 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()
-{
- OSL_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 SAL_CALL 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;
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/workben/testcomponent.cxx b/extensions/workben/testcomponent.cxx
deleted file mode 100644
index e9bed4c909b4..000000000000
--- a/extensions/workben/testcomponent.cxx
+++ /dev/null
@@ -1,205 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
- */
-
-
-// testcomponent - Loads a service and its testcomponent from dlls performs a test.
-// Expands the dll-names depending on the actual environment.
-// Example : testcomponent com.sun.star.io.Pipe stm
-
-// Therefore the testcode must exist in teststm and the testservice must be named test.com.sun.star.io.Pipe
-
-
-#include <stdio.h>
-#include <smart/com/sun/star/registry/XImplementationRegistration.hxx>
-#include <smart/com/sun/star/lang/XComponent.hxx>
-
-#include <osl/diagnose.h>
-#include <usr/services.hxx>
-#include <vcl/svapp.hxx>
-#include <usr/ustring.hxx>
-#include <osl/conditn.hxx>
-
-#include <smart/com/sun/star/test/XSimpleTest.hxx>
-
-using namespace usr;
-
-using ::rtl::OWStringToOString;
-
-
-// Needed to switch on solaris threads
-#ifdef __sun
-extern "C" void ChangeGlobalInit();
-#endif
-
-int SAL_CALL main (int argc, char **argv)
-{
-
- if( argc < 3) {
- printf( "usage : testcomponent service dll [additional dlls]\n" );
- exit( 0 );
- }
-#ifdef __sun
- // switch on threads in solaris
- ChangeGlobalInit();
-#endif
-
- // create service manager
-// XMultiServiceFactoryRef xSMgr = getProcessServiceManager();
- XMultiServiceFactoryRef xSMgr = createRegistryServiceManager();
- OSL_ASSERT( xSMgr.is() );
- registerUsrServices( xSMgr );
- setProcessServiceManager( xSMgr );
-
- XImplementationRegistrationRef xReg;
- XSimpleRegistryRef xSimpleReg;
-
- try {
- // Create registration service
- XInterfaceRef x = xSMgr->createInstance(
- UString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.registry.ImplementationRegistration" )) );
- x->queryInterface( XImplementationRegistration::getSmartUik() , xReg );
-
- }
- catch( Exception& e ) {
- printf( "%s\n" , OWStringToOString( e.getName() , CHARSET_SYSTEM ).getStr() );
- exit(1);
- }
-
- 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(RTL_CONSTASCII_USTRINGPARAM( "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);
- }
-
-
- 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(RTL_CONSTASCII_USTRINGPARAM( "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);
- }
-
-
- // 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);
- }
- catch(...) {
- printf( "testcomponent : uncaught unknown exception\n" );
- exit(1);
- }
-
-
- // 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;
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/workben/testframecontrol.cxx b/extensions/workben/testframecontrol.cxx
deleted file mode 100644
index 593ea72897b1..000000000000
--- a/extensions/workben/testframecontrol.cxx
+++ /dev/null
@@ -1,291 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
- */
-
-
-#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>
-
-using namespace usr;
-
-
-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();
-
-public:
- FrameControlApplication() {}
-
-private:
- void init();
- void deinit();
-
-private:
- Listener_Impl* _pListener;
- XControlRef _xControl;
-
- WorkWindow* _pWorkWin;
-};
-
-FrameControlApplication g_App;
-
-
-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 )
- {
- }
-
-
- XInterfaceRef xInst = xMgr->createInstance( L"stardiv.one.frame.FrameControl" );
- if (xInst->queryInterface( XControl::getSmartUik(), _xControl ))
- {
- _pWorkWin = VclPtr<WorkWindow>::Create( nullptr, 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();
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/workben/testpgp.cxx b/extensions/workben/testpgp.cxx
deleted file mode 100644
index 743b08f6fb39..000000000000
--- a/extensions/workben/testpgp.cxx
+++ /dev/null
@@ -1,741 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
- */
-
-#include <sal/types.h>
-#ifndef _RTL_WSTRING_
-#include <rtl/wstring>
-#endif
-
-#include <usr/smartservices.hxx>
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
-#include <com/sun/star/io/XInputStream.hpp>
-#include <com/sun/star/io/XOutputStream.hpp>
-#include <com/sun/star/pgp/RecipientsEvent.hpp>
-#include <com/sun/star/pgp/SignatureEvent.hpp>
-#include <com/sun/star/pgp/XPGPDecoder.hpp>
-#include <com/sun/star/pgp/XPGPDecoderListener.hpp>
-#include <com/sun/star/pgp/XPGPEncoder.hpp>
-#include <com/sun/star/pgp/XPGPPreferences.hpp>
-#include <com/sun/star/uno/XInterface.hpp>
-#include <com/sun/star/uno/Any.h>
-#include <com/sun/star/uno/Reference.h>
-#include <com/sun/star/uno/Sequence.hxx>
-#include <cppuhelper/weak.hxx>
-
-#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:
- explicit DataSource_Impl(int fd = 0);
- virtual ~DataSource_Impl();
-
- 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() throw(RuntimeException);
-
- virtual void SAL_CALL release() 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()
- throw (NotConnectedException, IOException);
-
- virtual void SAL_CALL closeInput()
- throw (NotConnectedException, IOException);
-};
-
-/*========================================================================
- *
- * DataSink_Impl interface.
- *
- *======================================================================*/
-class DataSink_Impl :
- public OWeakObject,
- public XOutputStream
-{
- Sequence<sal_Int8> m_buffer;
-
-public:
- DataSink_Impl();
- virtual ~DataSink_Impl();
-
- const Sequence<sal_Int8>& getBuffer() const { return m_buffer; }
-
- /** XInterface.
- */
- virtual sal_Bool SAL_CALL queryInterface (
- const Uik &rUik, Any &rIfc) throw(RuntimeException);
-
- virtual void SAL_CALL acquire() throw(RuntimeException);
- virtual void SAL_CALL release() throw(RuntimeException);
-
- /** XOutputStream.
- */
- virtual void SAL_CALL writeBytes (
- const Sequence<sal_Int8> &rBuffer)
- throw (NotConnectedException,
- BufferSizeExceededException,
- IOException);
-
- virtual void SAL_CALL flush()
- throw (NotConnectedException,
- BufferSizeExceededException,
- IOException);
-
- virtual void SAL_CALL closeOutput()
- throw (NotConnectedException,
- BufferSizeExceededException,
- IOException);
-};
-
-/*========================================================================
- *
- * DecoderListener_Impl interface.
- *
- *======================================================================*/
-class DecoderListener_Impl :
- public OWeakObject,
- public XPGPDecoderListener
-{
-public:
- DecoderListener_Impl();
- virtual ~DecoderListener_Impl();
-
- /** XInterface.
- */
- virtual sal_Bool SAL_CALL queryInterface (
- const Uik &rUik, Any &rIfc) throw(RuntimeException);
-
- virtual void SAL_CALL acquire() throw(RuntimeException);
-
- virtual void SAL_CALL release() 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()
-{
-}
-
-/*
- * 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];
- memset (buffer, 0, sizeof(buffer));
-
- int k = read (m_fd, buffer, sizeof(buffer));
- while (k > 0)
- {
- sal_Int32 n = m_buffer.getLength();
- m_buffer.realloc (n + k);
-
- memcpy (m_buffer.getArray() + n, buffer, k);
- n += k;
-
- memset (buffer, 0, 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 (css::uno::queryInterface (
- rUik, rIfc,
- (static_cast< XInputStream* >(this))))
- return sal_True;
- else
- return OWeakObject::queryInterface (rUik, rIfc);
-}
-
-/*
- * XInterface: acquire.
- */
-void SAL_CALL DataSource_Impl::acquire() throw(RuntimeException)
-{
- OWeakObject::acquire();
-}
-
-/*
- * XInterface: release.
- */
-void SAL_CALL DataSource_Impl::release() 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 = SAL_BOUND(k, 0, nBytesToRead);
- if (k > 0)
- {
- rData.realloc(k);
- memcpy (
- 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()
- throw (NotConnectedException, IOException)
-{
- sal_Int32 k = m_buffer.getLength() - m_position;
- return ((k > 0) ? k : 0);
-}
-
-/*
- * XInputStream: closeInput.
- */
-void SAL_CALL DataSource_Impl::closeInput()
- throw (NotConnectedException, IOException)
-{
-}
-
-/*========================================================================
- *
- * DataSink_Impl implementation.
- *
- *======================================================================*/
-/*
- * DataSink_Impl.
- */
-DataSink_Impl::DataSink_Impl()
-{
-}
-
-/*
- * ~DataSink_Impl.
- */
-DataSink_Impl::~DataSink_Impl()
-{
-}
-
-/*
- * XInterface: queryInterface.
- */
-sal_Bool SAL_CALL DataSink_Impl::queryInterface (
- const Uik &rUik, Any &rIfc) throw(RuntimeException)
-{
- if (css::uno::queryInterface (
- rUik, rIfc,
- (static_cast< XOutputStream* >(this))))
- return sal_True;
- else
- return OWeakObject::queryInterface (rUik, rIfc);
-}
-
-/*
- * XInterface: acquire.
- */
-void SAL_CALL DataSink_Impl::acquire() throw(RuntimeException)
-{
- OWeakObject::acquire();
-}
-
-/*
- * XInterface: release.
- */
-void SAL_CALL DataSink_Impl::release() 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());
-
- memcpy (
- m_buffer.getArray() + n,
- rBuffer.getConstArray(),
- rBuffer.getLength());
- }
-}
-
-/*
- * XOutputStream: flush.
- */
-void SAL_CALL DataSink_Impl::flush()
- 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()
- throw (NotConnectedException, BufferSizeExceededException, IOException)
-{
- flush();
-}
-
-/*========================================================================
- *
- * DecoderListener_Impl implementation.
- *
- *======================================================================*/
-/*
- * DecoderListener_Impl.
- */
-DecoderListener_Impl::DecoderListener_Impl()
-{
-}
-
-/*
- * ~DecoderListener_Impl.
- */
-DecoderListener_Impl::~DecoderListener_Impl()
-{
-}
-
-/*
- * XInterface: queryInterface.
- */
-sal_Bool SAL_CALL DecoderListener_Impl::queryInterface (
- const Uik &rUik, Any &rIfc) throw(RuntimeException)
-{
- if (css::uno::queryInterface (
- rUik, rIfc,
- (static_cast< XEventListener* >(this)),
- (static_cast< XPGPDecoderListener* >(this))))
- return sal_True;
- else
- return OWeakObject::queryInterface (rUik, rIfc);
-}
-
-/*
- * XInterface: acquire.
- */
-void SAL_CALL DecoderListener_Impl::acquire() throw(RuntimeException)
-{
- OWeakObject::acquire();
-}
-
-/*
- * XInterface: release.
- */
-void SAL_CALL DecoderListener_Impl::release() 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);
-}
-
-/*
- * 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 (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 = SAL_N_ELEMENTS(aRecipients);
-
- 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)
- {
-
- }
-
- return 0;
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/workben/testresource.cxx b/extensions/workben/testresource.cxx
deleted file mode 100644
index 65be9b946b23..000000000000
--- a/extensions/workben/testresource.cxx
+++ /dev/null
@@ -1,80 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
- */
-
-
-#include <smart/com/sun/star/registry/XImplementationRegistration.hxx>
-#include <smart/com/sun/star/script/XInvocation.hxx>
-
-#include <rtl/ustring.hxx>
-#include <osl/diagnose.h>
-#include <usr/services.hxx>
-#include <vcl/svapp.hxx>
-
-using namespace usr;
-using ::rtl::StringToOUString;
-
-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();
- OSL_ENSURE( b, "hasString" );
-
- UString aStr = xResLoader->invoke( L"getString", Args, OutPos, OutArgs ).getString();
- OSL_ENSURE( aStr == L"Hello", "getString" );
-
- Args.getArray()[0].setINT32( 1001 );
- b = xResLoader->invoke( L"hasString", Args, OutPos, OutArgs ).getBOOL();
- OSL_ENSURE( !b, "!hasString" );
-
- xReg->revokeImplementation( aDllName, XSimpleRegistryRef() );
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/workben/testresource.src b/extensions/workben/testresource.src
deleted file mode 100644
index 66997042c411..000000000000
--- a/extensions/workben/testresource.src
+++ /dev/null
@@ -1,24 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
- */
-String 1000
-{
- Text = "Hello";
-};
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */