summaryrefslogtreecommitdiff
path: root/javaunohelper
diff options
context:
space:
mode:
Diffstat (limited to 'javaunohelper')
-rw-r--r--javaunohelper/com/sun/star/comp/JavaUNOHelperServices.java64
-rw-r--r--javaunohelper/com/sun/star/comp/helper/Bootstrap.java329
-rw-r--r--javaunohelper/com/sun/star/comp/helper/BootstrapException.java91
-rw-r--r--javaunohelper/com/sun/star/comp/helper/ComponentContext.java310
-rw-r--r--javaunohelper/com/sun/star/comp/helper/ComponentContextEntry.java73
-rw-r--r--javaunohelper/com/sun/star/comp/helper/RegistryServiceFactory.java168
-rw-r--r--javaunohelper/com/sun/star/comp/helper/SharedLibraryLoader.java159
-rw-r--r--javaunohelper/com/sun/star/comp/helper/UnoInfo.java115
-rw-r--r--javaunohelper/com/sun/star/comp/helper/makefile.mk54
-rw-r--r--javaunohelper/com/sun/star/comp/juhtest/SmoketestCommandEnvironment.java151
-rw-r--r--javaunohelper/com/sun/star/comp/juhtest/makefile.mk50
-rw-r--r--javaunohelper/com/sun/star/comp/makefile.mk49
-rwxr-xr-xjavaunohelper/com/sun/star/lib/uno/adapter/ByteArrayToXInputStreamAdapter.java161
-rw-r--r--javaunohelper/com/sun/star/lib/uno/adapter/InputStreamToXInputStreamAdapter.java166
-rw-r--r--javaunohelper/com/sun/star/lib/uno/adapter/OutputStreamToXOutputStreamAdapter.java87
-rw-r--r--javaunohelper/com/sun/star/lib/uno/adapter/XInputStreamToInputStreamAdapter.java207
-rwxr-xr-xjavaunohelper/com/sun/star/lib/uno/adapter/XOutputStreamToByteArrayAdapter.java121
-rw-r--r--javaunohelper/com/sun/star/lib/uno/adapter/XOutputStreamToOutputStreamAdapter.java111
-rw-r--r--javaunohelper/com/sun/star/lib/uno/adapter/makefile.mk54
-rw-r--r--javaunohelper/com/sun/star/lib/uno/helper/ComponentBase.java141
-rw-r--r--javaunohelper/com/sun/star/lib/uno/helper/Factory.java268
-rw-r--r--javaunohelper/com/sun/star/lib/uno/helper/InterfaceContainer.java856
-rw-r--r--javaunohelper/com/sun/star/lib/uno/helper/MultiTypeInterfaceContainer.java165
-rw-r--r--javaunohelper/com/sun/star/lib/uno/helper/PropertySet.java1102
-rw-r--r--javaunohelper/com/sun/star/lib/uno/helper/PropertySetMixin.java1093
-rw-r--r--javaunohelper/com/sun/star/lib/uno/helper/UnoUrl.java412
-rw-r--r--javaunohelper/com/sun/star/lib/uno/helper/WeakAdapter.java102
-rw-r--r--javaunohelper/com/sun/star/lib/uno/helper/WeakBase.java143
-rw-r--r--javaunohelper/com/sun/star/lib/uno/helper/makefile.mk49
-rw-r--r--javaunohelper/inc/makefile.mk47
-rw-r--r--javaunohelper/inc/pch/precompiled_javaunohelper.cxx31
-rw-r--r--javaunohelper/inc/pch/precompiled_javaunohelper.hxx34
-rw-r--r--javaunohelper/prj/build.lst10
-rw-r--r--javaunohelper/prj/d.lst7
-rw-r--r--javaunohelper/source/bootstrap.cxx191
-rw-r--r--javaunohelper/source/javaunohelper.cxx326
-rw-r--r--javaunohelper/source/javaunohelper.map9
-rw-r--r--javaunohelper/source/makefile.mk134
-rw-r--r--javaunohelper/source/preload.cxx161
-rw-r--r--javaunohelper/source/vm.cxx150
-rw-r--r--javaunohelper/source/vm.hxx58
-rw-r--r--javaunohelper/test/com/sun/star/comp/helper/Bootstrap_Test.java117
-rw-r--r--javaunohelper/test/com/sun/star/comp/helper/ComponentContext_Test.java99
-rw-r--r--javaunohelper/test/com/sun/star/comp/helper/RegistryServiceFactory_Test.java100
-rw-r--r--javaunohelper/test/com/sun/star/comp/helper/SharedLibraryLoader_Test.java194
-rw-r--r--javaunohelper/test/com/sun/star/comp/helper/makefile.mk52
-rw-r--r--javaunohelper/test/com/sun/star/lib/uno/helper/AWeakBase.java50
-rw-r--r--javaunohelper/test/com/sun/star/lib/uno/helper/ComponentBase_Test.java153
-rw-r--r--javaunohelper/test/com/sun/star/lib/uno/helper/Factory_Test.java207
-rw-r--r--javaunohelper/test/com/sun/star/lib/uno/helper/InterfaceContainer_Test.java992
-rw-r--r--javaunohelper/test/com/sun/star/lib/uno/helper/MultiTypeInterfaceContainer_Test.java372
-rw-r--r--javaunohelper/test/com/sun/star/lib/uno/helper/PropertySet_Test.java1693
-rw-r--r--javaunohelper/test/com/sun/star/lib/uno/helper/ProxyProvider.java165
-rw-r--r--javaunohelper/test/com/sun/star/lib/uno/helper/UnoUrlTest.java261
-rw-r--r--javaunohelper/test/com/sun/star/lib/uno/helper/WeakBase_Test.java251
-rw-r--r--javaunohelper/test/com/sun/star/lib/uno/helper/makefile.mk68
-rw-r--r--javaunohelper/util/delzip0
-rw-r--r--javaunohelper/util/juh.component34
-rw-r--r--javaunohelper/util/makefile.mk58
-rw-r--r--javaunohelper/util/manifest3
-rw-r--r--javaunohelper/util/settings.pmk28
61 files changed, 0 insertions, 12906 deletions
diff --git a/javaunohelper/com/sun/star/comp/JavaUNOHelperServices.java b/javaunohelper/com/sun/star/comp/JavaUNOHelperServices.java
deleted file mode 100644
index 7df6497a1..000000000
--- a/javaunohelper/com/sun/star/comp/JavaUNOHelperServices.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-package com.sun.star.comp;
-
-import com.sun.star.lib.uno.helper.Factory;
-import com.sun.star.lang.XSingleComponentFactory;
-import com.sun.star.comp.juhtest.SmoketestCommandEnvironment;
-
-
-/** This class is the registration class for all services in this module.
- *
- * Note that not all files which can be used as service need to be registered
- * by this class.
- */
-public class JavaUNOHelperServices {
-
- static private final String __service_smoketestCommandEnv =
- "com.sun.star.deployment.test.SmoketestCommandEnvironment";
-
- /**
- * Gives a factory for creating the service.
- * This method is called by the <code>JavaLoader</code>
- * <p>
- * @return returns a <code>XSingleComponentFactory</code> for creating
- * the component
- * @param sImplName the name of the implementation for which a
- * service is desired
- * @see com.sun.star.comp.loader.JavaLoader
- */
- public static XSingleComponentFactory __getComponentFactory(String sImplName)
- {
- XSingleComponentFactory xFactory = null;
-
- if ( sImplName.equals( SmoketestCommandEnvironment.class.getName() ) )
- xFactory = Factory.createComponentFactory(SmoketestCommandEnvironment.class,
- SmoketestCommandEnvironment.getServiceNames());
-
- return xFactory;
- }
-}
diff --git a/javaunohelper/com/sun/star/comp/helper/Bootstrap.java b/javaunohelper/com/sun/star/comp/helper/Bootstrap.java
deleted file mode 100644
index 3156bbabb..000000000
--- a/javaunohelper/com/sun/star/comp/helper/Bootstrap.java
+++ /dev/null
@@ -1,329 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-package com.sun.star.comp.helper;
-
-import com.sun.star.bridge.UnoUrlResolver;
-import com.sun.star.bridge.XUnoUrlResolver;
-import com.sun.star.comp.loader.JavaLoader;
-import com.sun.star.container.XSet;
-import com.sun.star.lang.XInitialization;
-import com.sun.star.lang.XMultiServiceFactory;
-import com.sun.star.lang.XMultiComponentFactory;
-import com.sun.star.lang.XSingleComponentFactory;
-import com.sun.star.lib.util.NativeLibraryLoader;
-import com.sun.star.loader.XImplementationLoader;
-import com.sun.star.uno.UnoRuntime;
-import com.sun.star.uno.XComponentContext;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.PrintStream;
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.Random;
-
-/** Bootstrap offers functionality to obtain a context or simply
- a service manager.
- The service manager can create a few basic services, whose implementations are:
- <ul>
- <li>com.sun.star.comp.loader.JavaLoader</li>
- <li>com.sun.star.comp.urlresolver.UrlResolver</li>
- <li>com.sun.star.comp.bridgefactory.BridgeFactory</li>
- <li>com.sun.star.comp.connections.Connector</li>
- <li>com.sun.star.comp.connections.Acceptor</li>
- <li>com.sun.star.comp.servicemanager.ServiceManager</li>
- </ul>
-
- Other services can be inserted into the service manager by
- using its XSet interface:
- <pre>
- XSet xSet = UnoRuntime.queryInterface( XSet.class, aMultiComponentFactory );
- // insert the service manager
- xSet.insert( aSingleComponentFactory );
- </pre>
-*/
-public class Bootstrap {
-
- private static void insertBasicFactories(
- XSet xSet, XImplementationLoader xImpLoader )
- throws Exception
- {
- // insert the factory of the loader
- xSet.insert( xImpLoader.activate(
- "com.sun.star.comp.loader.JavaLoader", null, null, null ) );
-
- // insert the factory of the URLResolver
- xSet.insert( xImpLoader.activate(
- "com.sun.star.comp.urlresolver.UrlResolver", null, null, null ) );
-
- // insert the bridgefactory
- xSet.insert( xImpLoader.activate(
- "com.sun.star.comp.bridgefactory.BridgeFactory", null, null, null ) );
-
- // insert the connector
- xSet.insert( xImpLoader.activate(
- "com.sun.star.comp.connections.Connector", null, null, null ) );
-
- // insert the acceptor
- xSet.insert( xImpLoader.activate(
- "com.sun.star.comp.connections.Acceptor", null, null, null ) );
- }
-
- /** Bootstraps an initial component context with service manager and basic
- jurt components inserted.
- @param context_entries the hash table contains mappings of entry names (type string) to
- context entries (type class ComponentContextEntry).
- @return a new context.
- */
- static public XComponentContext createInitialComponentContext( Hashtable context_entries )
- throws Exception
- {
- XImplementationLoader xImpLoader = UnoRuntime.queryInterface(
- XImplementationLoader.class, new JavaLoader() );
-
- // Get the factory of the ServiceManager
- XSingleComponentFactory smgr_fac = UnoRuntime.queryInterface(
- XSingleComponentFactory.class, xImpLoader.activate(
- "com.sun.star.comp.servicemanager.ServiceManager", null, null, null ) );
-
- // Create an instance of the ServiceManager
- XMultiComponentFactory xSMgr = UnoRuntime.queryInterface(
- XMultiComponentFactory.class, smgr_fac.createInstanceWithContext( null ) );
-
- // post init loader
- XInitialization xInit = UnoRuntime.queryInterface(
- XInitialization.class, xImpLoader );
- Object[] args = new Object [] { xSMgr };
- xInit.initialize( args );
-
- // initial component context
- if (context_entries == null)
- context_entries = new Hashtable( 1 );
- // add smgr
- context_entries.put(
- "/singletons/com.sun.star.lang.theServiceManager",
- new ComponentContextEntry( null, xSMgr ) );
- // ... xxx todo: add standard entries
- XComponentContext xContext = new ComponentContext( context_entries, null );
-
- // post init smgr
- xInit = UnoRuntime.queryInterface(
- XInitialization.class, xSMgr );
- args = new Object [] { null, xContext }; // no registry, default context
- xInit.initialize( args );
-
- XSet xSet = UnoRuntime.queryInterface( XSet.class, xSMgr );
- // insert the service manager
- xSet.insert( smgr_fac );
- // and basic jurt factories
- insertBasicFactories( xSet, xImpLoader );
-
- return xContext;
- }
-
- /**
- * Bootstraps a servicemanager with the jurt base components registered.
- * <p>
- * @return a freshly boostrapped service manager
- * @see com.sun.star.lang.ServiceManager
- */
- static public XMultiServiceFactory createSimpleServiceManager() throws Exception
- {
- return UnoRuntime.queryInterface(
- XMultiServiceFactory.class, createInitialComponentContext( null ).getServiceManager() );
- }
-
-
- /** Bootstraps the initial component context from a native UNO installation.
-
- @see "cppuhelper/defaultBootstrap_InitialComponentContext()"
- */
- static public final XComponentContext defaultBootstrap_InitialComponentContext()
- throws Exception
- {
- return defaultBootstrap_InitialComponentContext( null, null );
- }
- /** Bootstraps the initial component context from a native UNO installation.
-
- @param ini_file
- ini_file (may be null: uno.rc besides cppuhelper lib)
- @param bootstrap_parameters
- bootstrap parameters (maybe null)
-
- @see "cppuhelper/defaultBootstrap_InitialComponentContext()"
- */
- static public final XComponentContext defaultBootstrap_InitialComponentContext(
- String ini_file, Hashtable bootstrap_parameters )
- throws Exception
- {
- // jni convenience: easier to iterate over array than calling Hashtable
- String pairs [] = null;
- if (null != bootstrap_parameters)
- {
- pairs = new String [ 2 * bootstrap_parameters.size() ];
- Enumeration keys = bootstrap_parameters.keys();
- int n = 0;
- while (keys.hasMoreElements())
- {
- String name = (String)keys.nextElement();
- pairs[ n++ ] = name;
- pairs[ n++ ] = (String)bootstrap_parameters.get( name );
- }
- }
-
- if (! m_loaded_juh)
- {
- NativeLibraryLoader.loadLibrary( Bootstrap.class.getClassLoader(), "juh" );
- m_loaded_juh = true;
- }
- return UnoRuntime.queryInterface(
- XComponentContext.class,
- cppuhelper_bootstrap(
- ini_file, pairs, Bootstrap.class.getClassLoader() ) );
- }
-
- static private boolean m_loaded_juh = false;
- static private native Object cppuhelper_bootstrap(
- String ini_file, String bootstrap_parameters [], ClassLoader loader )
- throws Exception;
-
- /**
- * Bootstraps the component context from a UNO installation.
- *
- * @return a bootstrapped component context.
- *
- * @since UDK 3.1.0
- */
- public static final XComponentContext bootstrap()
- throws BootstrapException {
-
- XComponentContext xContext = null;
-
- try {
- // create default local component context
- XComponentContext xLocalContext =
- createInitialComponentContext( null );
- if ( xLocalContext == null )
- throw new BootstrapException( "no local component context!" );
-
- // find office executable relative to this class's class loader
- String sOffice =
- System.getProperty( "os.name" ).startsWith( "Windows" ) ?
- "soffice.exe" : "soffice";
- File fOffice = NativeLibraryLoader.getResource(
- Bootstrap.class.getClassLoader(), sOffice );
- if ( fOffice == null )
- throw new BootstrapException( "no office executable found!" );
-
- // create random pipe name
- String sPipeName = "uno" +
- Long.toString( (new Random()).nextLong() & 0x7fffffffffffffffL );
-
- // create call with arguments
- String[] cmdArray = new String[7];
- cmdArray[0] = fOffice.getPath();
- cmdArray[1] = "-nologo";
- cmdArray[2] = "-nodefault";
- cmdArray[3] = "-norestore";
- cmdArray[4] = "-nocrashreport";
- cmdArray[5] = "-nolockcheck";
- cmdArray[6] = "-accept=pipe,name=" + sPipeName + ";urp;";
-
- // start office process
- Process p = Runtime.getRuntime().exec( cmdArray );
- pipe( p.getInputStream(), System.out, "CO> " );
- pipe( p.getErrorStream(), System.err, "CE> " );
-
- // initial service manager
- XMultiComponentFactory xLocalServiceManager =
- xLocalContext.getServiceManager();
- if ( xLocalServiceManager == null )
- throw new BootstrapException( "no initial service manager!" );
-
- // create a URL resolver
- XUnoUrlResolver xUrlResolver =
- UnoUrlResolver.create( xLocalContext );
-
- // connection string
- String sConnect = "uno:pipe,name=" + sPipeName +
- ";urp;StarOffice.ComponentContext";
-
- // wait until office is started
- for (int i = 0;; ++i) {
- try {
- // try to connect to office
- Object context = xUrlResolver.resolve( sConnect );
- xContext = UnoRuntime.queryInterface(
- XComponentContext.class, context);
- if ( xContext == null )
- throw new BootstrapException( "no component context!" );
- break;
- } catch ( com.sun.star.connection.NoConnectException ex ) {
- // Wait 500 ms, then try to connect again, but do not wait
- // longer than 5 min (= 600 * 500 ms) total:
- if (i == 600) {
- throw new BootstrapException(ex.toString());
- }
- Thread.currentThread().sleep( 500 );
- }
- }
- } catch ( BootstrapException e ) {
- throw e;
- } catch ( java.lang.RuntimeException e ) {
- throw e;
- } catch ( java.lang.Exception e ) {
- throw new BootstrapException( e );
- }
-
- return xContext;
- }
-
- private static void pipe(
- final InputStream in, final PrintStream out, final String prefix ) {
-
- new Thread( "Pipe: " + prefix) {
- public void run() {
- BufferedReader r = new BufferedReader(
- new InputStreamReader( in ) );
- try {
- for ( ; ; ) {
- String s = r.readLine();
- if ( s == null ) {
- break;
- }
- out.println( prefix + s );
- }
- } catch ( java.io.IOException e ) {
- e.printStackTrace( System.err );
- }
- }
- }.start();
- }
-}
diff --git a/javaunohelper/com/sun/star/comp/helper/BootstrapException.java b/javaunohelper/com/sun/star/comp/helper/BootstrapException.java
deleted file mode 100644
index 3136358c2..000000000
--- a/javaunohelper/com/sun/star/comp/helper/BootstrapException.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-package com.sun.star.comp.helper;
-
-/**
- * BootstrapException is a checked exception that wraps an exception
- * thrown by the original target.
- *
- * @since UDK 3.1.0
- */
-public class BootstrapException extends java.lang.Exception {
-
- /**
- * This field holds the target exception.
- */
- private Exception m_target = null;
-
- /**
- * Constructs a <code>BootstrapException</code> with <code>null</code> as
- * the target exception.
- */
- public BootstrapException() {
- super();
- }
-
- /**
- * Constructs a <code>BootstrapException</code> with the specified
- * detail message.
- *
- * @param message the detail message
- */
- public BootstrapException( String message ) {
- super( message );
- }
-
- /**
- * Constructs a <code>BootstrapException</code> with the specified
- * detail message and a target exception.
- *
- * @param message the detail message
- * @param target the target exception
- */
- public BootstrapException( String message, Exception target ) {
- super( message );
- m_target = target;
- }
-
- /**
- * Constructs a <code>BootstrapException</code> with a target exception.
- *
- * @param target the target exception
- */
- public BootstrapException( Exception target ) {
- super();
- m_target = target;
- }
-
- /**
- * Get the thrown target exception.
- *
- * @return the target exception
- */
- public Exception getTargetException() {
- return m_target;
- }
-}
diff --git a/javaunohelper/com/sun/star/comp/helper/ComponentContext.java b/javaunohelper/com/sun/star/comp/helper/ComponentContext.java
deleted file mode 100644
index 27c57adc5..000000000
--- a/javaunohelper/com/sun/star/comp/helper/ComponentContext.java
+++ /dev/null
@@ -1,310 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-package com.sun.star.comp.helper;
-
-import com.sun.star.uno.UnoRuntime;
-import com.sun.star.uno.Any;
-
-import com.sun.star.uno.XComponentContext;
-import com.sun.star.lang.XMultiComponentFactory;
-import com.sun.star.lang.XSingleComponentFactory;
-import com.sun.star.lang.XComponent;
-import com.sun.star.lang.XEventListener;
-import com.sun.star.lang.EventObject;
-
-import java.util.Hashtable;
-import java.util.Enumeration;
-import java.util.Vector;
-
-
-//==================================================================================================
-class Disposer implements XEventListener
-{
- private XComponent m_xComp;
-
- //----------------------------------------------------------------------------------------------
- Disposer( XComponent xComp )
- {
- m_xComp = xComp;
- }
- //______________________________________________________________________________________________
- public void disposing( EventObject Source )
- {
- m_xComp.dispose();
- }
-}
-
-/** Component context implementation.
-*/
-public class ComponentContext implements XComponentContext, XComponent
-{
- private static final boolean DEBUG = false;
- private static final String SMGR_NAME = "/singletons/com.sun.star.lang.theServiceManager";
- private static final String TDMGR_NAME = "/singletons/com.sun.star.reflection.theTypeDescriptionManager";
-
- private Hashtable m_table;
- private XComponentContext m_xDelegate;
-
- private XMultiComponentFactory m_xSMgr;
- private boolean m_bDisposeSMgr;
-
- private Vector m_eventListener;
-
- /** Ctor to create a component context passing a hashtable for values and a delegator
- reference. Entries of the passed hashtable are either direct values or
- ComponentContextEntry objects.
-
- @param table
- entries
- @param xDelegate
- if values are not found, request is delegated to this object
- */
- public ComponentContext( Hashtable table, XComponentContext xDelegate )
- {
- m_eventListener = new Vector();
- m_table = table;
- m_xDelegate = xDelegate;
- m_xSMgr = null;
- m_bDisposeSMgr = false;
-
- Object o = table.get( SMGR_NAME );
- if (o != null)
- {
- if (o instanceof ComponentContextEntry)
- {
- o = ((ComponentContextEntry)o).m_value;
- }
- m_xSMgr = UnoRuntime.queryInterface(
- XMultiComponentFactory.class, o );
- }
- if (m_xSMgr != null)
- {
- m_bDisposeSMgr = true;
- }
- else if (m_xDelegate != null)
- {
- m_xSMgr = m_xDelegate.getServiceManager();
- }
-
- // listen for delegate
- XComponent xComp = UnoRuntime.queryInterface(
- XComponent.class, m_xDelegate );
- if (xComp != null)
- {
- xComp.addEventListener( new Disposer( this ) );
- }
- }
-
- // XComponentContext impl
- //______________________________________________________________________________________________
- public Object getValueByName( String rName )
- {
- Object o = m_table.get( rName );
- if (o != null)
- {
- if (o instanceof ComponentContextEntry)
- {
- ComponentContextEntry entry = (ComponentContextEntry)o;
- if (entry.m_lateInit != null)
- {
- Object xInstance = null;
-
- try
- {
- String serviceName = (String)entry.m_lateInit;
- if (serviceName != null)
- {
- if (m_xSMgr != null)
- {
- xInstance = m_xSMgr.createInstanceWithContext( serviceName, this );
- }
- else
- {
- if (DEBUG)
- System.err.println( "### no service manager instance for late init of singleton instance \"" + rName + "\"!" );
- }
- }
- else
- {
- XSingleComponentFactory xCompFac =
- UnoRuntime.queryInterface(
- XSingleComponentFactory.class, entry.m_lateInit );
- if (xCompFac != null)
- {
- xInstance = xCompFac.createInstanceWithContext( this );
- }
- else
- {
- if (DEBUG)
- System.err.println( "### neither service name nor service factory given for late init of singleton instance \"" + rName + "\"!" );
- }
- }
- }
- catch (com.sun.star.uno.Exception exc)
- {
- if (DEBUG)
- System.err.println( "### exception occurred on late init of singleton instance \"" + rName + "\": " + exc.getMessage() );
- }
-
- if (xInstance != null)
- {
- synchronized (entry)
- {
- if (entry.m_lateInit != null)
- {
- entry.m_value = xInstance;
- entry.m_lateInit = null;
- }
- else // inited in the meantime
- {
- // dispose fresh service instance
- XComponent xComp = UnoRuntime.queryInterface(
- XComponent.class, xInstance );
- if (xComp != null)
- {
- xComp.dispose();
- }
- }
- }
- }
- else
- {
- if (DEBUG)
- System.err.println( "### failed late init of singleton instance \"" + rName + "\"!" );
- }
- }
- return entry.m_value;
- }
- else // direct value in map
- {
- return o;
- }
- }
- else if (m_xDelegate != null)
- {
- return m_xDelegate.getValueByName( rName );
- }
- else
- {
- return Any.VOID;
- }
- }
- //______________________________________________________________________________________________
- public XMultiComponentFactory getServiceManager()
- {
- return m_xSMgr;
- }
-
- // XComponent impl
- //______________________________________________________________________________________________
- public void dispose()
- {
- if (DEBUG)
- System.err.print( "> disposing context " + this );
-
- // fire events
- EventObject evt = new EventObject( this );
- Enumeration eventListener = m_eventListener.elements();
- while (eventListener.hasMoreElements())
- {
- XEventListener listener = (XEventListener)eventListener.nextElement();
- listener.disposing( evt );
- }
- m_eventListener.removeAllElements();
-
- XComponent tdmgr = null;
- // dispose values, then service manager, then typdescription manager
- Enumeration keys = m_table.keys();
- while (keys.hasMoreElements())
- {
- String name = (String)keys.nextElement();
- if (! name.equals( SMGR_NAME ))
- {
- Object o = m_table.get( name );
- if (o instanceof ComponentContextEntry)
- {
- o = ((ComponentContextEntry)o).m_value;
- }
-
- XComponent xComp = UnoRuntime.queryInterface( XComponent.class, o );
- if (xComp != null)
- {
- if (name.equals( TDMGR_NAME ))
- {
- tdmgr = xComp;
- }
- else
- {
- xComp.dispose();
- }
- }
- }
- }
- m_table.clear();
-
- // smgr
- if (m_bDisposeSMgr)
- {
- XComponent xComp = UnoRuntime.queryInterface(
- XComponent.class, m_xSMgr );
- if (xComp != null)
- {
- xComp.dispose();
- }
- }
- m_xSMgr = null;
-
- // tdmgr
- if (tdmgr != null)
- {
- tdmgr.dispose();
- }
-
- if (DEBUG)
- System.err.println( "... finished" );
- }
- //______________________________________________________________________________________________
- public void addEventListener( XEventListener xListener )
- {
- if (xListener == null)
- throw new com.sun.star.uno.RuntimeException( "Listener must not be null" );
- if (m_eventListener.contains( xListener ))
- throw new com.sun.star.uno.RuntimeException( "Listener already registred." );
-
- m_eventListener.addElement( xListener );
- }
- //______________________________________________________________________________________________
- public void removeEventListener( XEventListener xListener )
- {
- if (xListener == null)
- throw new com.sun.star.uno.RuntimeException( "Listener must not be null" );
- if (! m_eventListener.contains( xListener ))
- throw new com.sun.star.uno.RuntimeException( "Listener is not registered." );
-
- m_eventListener.removeElement( xListener );
- }
-}
diff --git a/javaunohelper/com/sun/star/comp/helper/ComponentContextEntry.java b/javaunohelper/com/sun/star/comp/helper/ComponentContextEntry.java
deleted file mode 100644
index 48e999d57..000000000
--- a/javaunohelper/com/sun/star/comp/helper/ComponentContextEntry.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-package com.sun.star.comp.helper;
-
-/** Component context entry for constructing ComponentContext objects.
- <p>
- A ComponentContextEntry is separated into a late-init and direct-value
- purpose.
- The first one is commonly used for singleton objects of the component
- context, that are raised on first-time retrieval of the key.
- You have to pass a com.sun.star.lang.XSingleComponentFactory
- or string (=> service name) object for this.
- </p>
-*/
-public class ComponentContextEntry
-{
- /** if late init of service instance, set service name (String) or
- component factory (XSingleComponentFactory), null otherwise
- */
- public Object m_lateInit;
- /** set entry value
- */
- public Object m_value;
-
- /** Creating a late-init singleton entry component context entry.
- The second parameter will be ignored and overwritten during
- instanciation of the singleton instance.
-
- @param lateInit
- object factory or service string
- @param value
- pass null (dummy separating from second ctor signature)
- */
- public ComponentContextEntry( Object lateInit, Object value )
- {
- this.m_lateInit = lateInit;
- this.m_value = value;
- }
- /** Creating a direct value component context entry.
-
- @param value
- pass null
- */
- public ComponentContextEntry( Object value )
- {
- this.m_lateInit = null;
- this.m_value = value;
- }
-}
diff --git a/javaunohelper/com/sun/star/comp/helper/RegistryServiceFactory.java b/javaunohelper/com/sun/star/comp/helper/RegistryServiceFactory.java
deleted file mode 100644
index c748187ba..000000000
--- a/javaunohelper/com/sun/star/comp/helper/RegistryServiceFactory.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-
-package com.sun.star.comp.helper;
-
-
-import com.sun.star.lang.XMultiServiceFactory;
-import com.sun.star.uno.UnoRuntime;
-import com.sun.star.uno.RuntimeException;
-
-/** The class provides a set of methods which create instances of the
- com.sun.star.lang.RegistryServiceManager service.
-
- @deprecated use class Bootstrap instead
-*/
-public class RegistryServiceFactory {
- static {
- System.loadLibrary("juh");
- }
-
- private static native Object createRegistryServiceFactory(
- String writeRegistryFile,
- String readRegistryFile,
- boolean readOnly,
- ClassLoader loader);
-
- /**
- * This bootstraps an initial service factory working on a registry. If the first or both
- * parameters contain a value then the service factory is initialized with a simple registry
- * or a nested registry. Otherwise the service factory must be initialized later with a valid
- * registry.
- *<BR>
- * @param writeRegistryFile file name of the simple registry or the first registry file of
- * the nested registry which will be opened with read/write rights. This
- * file will be created if necessary.
- * @param readRegistryFile file name of the second registry file of the nested registry
- * which will be opened with readonly rights.
- * @return a new RegistryServiceFactory.
- */
- public static XMultiServiceFactory create(String writeRegistryFile, String readRegistryFile)
- throws com.sun.star.uno.Exception
- {
- return create(writeRegistryFile, readRegistryFile, false);
- }
-
- /**
- * This bootstraps an initial service factory working on a registry. If the first or both
- * parameters contain a value then the service factory is initialized with a simple registry
- * or a nested registry. Otherwise the service factory must be initialized later with a valid
- * registry.
- *<BR>
- * @param writeRegistryFile file name of the simple registry or the first registry file of
- * the nested registry which will be opened with read/write rights. This
- * file will be created if necessary.
- * @param readRegistryFile file name of the second registry file of the nested registry
- * which will be opened with readonly rights.
- * @param readOnly flag which specify that the first registry file will be opened with
- * readonly rights. Default is FALSE. If this flag is used the registry
- * will not be created if not exist.
- *
- * @return a new RegistryServiceFactory
- */
- public static XMultiServiceFactory create(String writeRegistryFile, String readRegistryFile, boolean readOnly)
- throws com.sun.star.uno.Exception
- {
- // Ensure that we are on a native threads vm
- // (binary UNO does use native threads).
- String vm_info = System.getProperty("java.vm.info");
- if(vm_info != null && vm_info.indexOf("green") != -1)
- throw new RuntimeException(RegistryServiceFactory.class.toString() + ".create - can't use binary UNO with green threads");
-
-
- if (writeRegistryFile == null && readRegistryFile == null)
- throw new com.sun.star.uno.Exception("No registry is specified!");
-
-// if (writeRegistryFile != null) {
-// java.io.File file = new java.io.File(writeRegistryFile);
-
-// if (file.exists()) {
-// if (!file.isFile())
-// throw new com.sun.star.uno.Exception(writeRegistryFile + " is not a file!");
-// } else
-// throw new com.sun.star.uno.Exception(writeRegistryFile + " doese not exist!");
-// }
-
-// if (readRegistryFile != null) {
-// java.io.File file = new java.io.File(readRegistryFile);
-
-// if (file.exists()) {
-// if (!file.isFile())
-// throw new com.sun.star.uno.Exception(readRegistryFile + " is not a file!");
-// } else
-// throw new com.sun.star.uno.Exception(readRegistryFile + " doese not exist!");
-// }
-
- Object obj = createRegistryServiceFactory(
- writeRegistryFile, readRegistryFile, readOnly,
- RegistryServiceFactory.class.getClassLoader() );
- return UnoRuntime.queryInterface(
- XMultiServiceFactory.class, obj );
- }
-
- /**
- * This bootstraps an initial service factory working on a registry file.
- *<BR>
- * @param registryFile file name of the registry to use/ create; if this is an empty
- * string, the default registry is used instead
- *
- * @return a new RegistryServiceFactory.
- */
- public static XMultiServiceFactory create(String registryFile)
- throws com.sun.star.uno.Exception
- {
- return create(registryFile, null, false);
- }
-
- /**
- * This bootstraps an initial service factory working on a registry file.
- *<BR>
- * @param registryFile file name of the registry to use/ create; if this is an empty
- * string, the default registry is used instead
- * @param readOnly flag which specify that the registry file will be opened with
- * readonly rights. Default is FALSE. If this flag is used the registry
- * will not be created if not exist.
- *
- * @return a new RegistryServiceFactory.
- */
- public static XMultiServiceFactory create(String registryFile, boolean readOnly)
- throws com.sun.star.uno.Exception
- {
- return create(registryFile, null, readOnly);
- }
-
- /**
- * This bootstraps a service factory without initialize a registry.
- *<BR>
- * @return a new RegistryServiceFactory.
- */
- public static XMultiServiceFactory create() throws com.sun.star.uno.Exception {
- return create( null, null, false );
- }
-}
-
diff --git a/javaunohelper/com/sun/star/comp/helper/SharedLibraryLoader.java b/javaunohelper/com/sun/star/comp/helper/SharedLibraryLoader.java
deleted file mode 100644
index 590c6251f..000000000
--- a/javaunohelper/com/sun/star/comp/helper/SharedLibraryLoader.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-package com.sun.star.comp.helper;
-
-import com.sun.star.uno.UnoRuntime;
-import com.sun.star.lang.XMultiServiceFactory;
-import com.sun.star.lang.XSingleServiceFactory;
-import com.sun.star.registry.XRegistryKey;
-
-/**
- * @deprecated use class Bootstrap bootstrapping a native UNO installation
- * and use the shared library loader service.
- *
- * The <code>SharedLibraryLoader</code> class provides the functionality of the <code>com.sun.star.loader.SharedLibrary</code>
- * service.
- * <p>
- * @see com.sun.star.loader.SharedLibrary
- * @see "com.sun.star.comp.servicemanager.ServiceManager"
- * @see com.sun.star.lang.ServiceManager
- */
-public class SharedLibraryLoader {
- /**
- * The default library which contains the SharedLibraryLoader component
- */
- public static final String DEFAULT_LIBRARY = "shlibloader.uno";
-
- /**
- * The default implementation name
- */
- public static final String DEFAULT_IMPLEMENTATION = "com.sun.star.comp.stoc.DLLComponentLoader";
-
- static {
- System.loadLibrary("juh");
- }
-
- private static native boolean component_writeInfo(
- String libName, XMultiServiceFactory smgr, XRegistryKey regKey,
- ClassLoader loader );
-
- private static native Object component_getFactory(
- String libName, String implName, XMultiServiceFactory smgr,
- XRegistryKey regKey, ClassLoader loader );
-
- /**
- * Supplies the ServiceFactory of the default SharedLibraryLoader.
- * The defaults are "shlibloader.uno"
- * for the library and "com.sun.star.comp.stoc.DLLComponentLoader"
- * for the component name.
- * <p>
- * @return the factory for the "com.sun.star.comp.stoc.DLLComponentLoader" component.
- * @param smgr the ServiceManager
- * @param regKey the root registry key
- * @see com.sun.star.loader.SharedLibrary
- * @see com.sun.star.lang.ServiceManager
- * @see com.sun.star.registry.RegistryKey
- */
- public static XSingleServiceFactory getServiceFactory(
- XMultiServiceFactory smgr,
- XRegistryKey regKey )
- {
- return UnoRuntime.queryInterface(
- XSingleServiceFactory.class,
- component_getFactory(
- DEFAULT_LIBRARY, DEFAULT_IMPLEMENTATION, smgr, regKey,
- SharedLibraryLoader.class.getClassLoader() ) );
- }
-
- /**
- * Loads and returns a specific factory for a given library and implementation name.
- * <p>
- * @return the factory of the component
- * @param libName the name of the shared library
- * @param impName the implementation name of the component
- * @param smgr the ServiceManager
- * @param regKey the root registry key
- * @see com.sun.star.loader.SharedLibrary
- * @see com.sun.star.lang.ServiceManager
- * @see com.sun.star.registry.RegistryKey
- */
- public static XSingleServiceFactory getServiceFactory(
- String libName,
- String impName,
- XMultiServiceFactory smgr,
- XRegistryKey regKey )
- {
- return UnoRuntime.queryInterface(
- XSingleServiceFactory.class,
- component_getFactory(
- libName, impName, smgr, regKey,
- SharedLibraryLoader.class.getClassLoader() ) );
- }
-
- /**
- * Registers the SharedLibraryLoader under a RegistryKey.
- * <p>
- * @return true if the registration was successfull - otherwise false
- * @param smgr the ServiceManager
- * @param regKey the root key under that the component should be registered
- * @see com.sun.star.loader.SharedLibrary
- * @see com.sun.star.lang.ServiceManager
- * @see com.sun.star.registry.RegistryKey
- */
- public static boolean writeRegistryServiceInfo(
- com.sun.star.lang.XMultiServiceFactory smgr,
- com.sun.star.registry.XRegistryKey regKey )
- {
- return component_writeInfo(
- DEFAULT_LIBRARY, smgr, regKey,
- SharedLibraryLoader.class.getClassLoader() );
- }
-
- /**
- * Registers the SharedLibraryLoader under a RegistryKey.
- * <p>
- * @return true if the registration was successfull - otherwise false
- * @param libName name of the shared library
- * @param smgr the ServiceManager
- * @param regKey the root key under that the component should be registered
- * @see com.sun.star.loader.SharedLibrary
- * @see com.sun.star.lang.ServiceManager
- * @see com.sun.star.registry.RegistryKey
- */
- public static boolean writeRegistryServiceInfo(
- String libName,
- com.sun.star.lang.XMultiServiceFactory smgr,
- com.sun.star.registry.XRegistryKey regKey )
-
- throws com.sun.star.registry.InvalidRegistryException,
- com.sun.star.uno.RuntimeException
- {
- return component_writeInfo(
- libName, smgr, regKey, SharedLibraryLoader.class.getClassLoader() );
- }
-}
-
diff --git a/javaunohelper/com/sun/star/comp/helper/UnoInfo.java b/javaunohelper/com/sun/star/comp/helper/UnoInfo.java
deleted file mode 100644
index 896974b9e..000000000
--- a/javaunohelper/com/sun/star/comp/helper/UnoInfo.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-package com.sun.star.comp.helper;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLClassLoader;
-
-/**
- * UnoInfo offers functionality to obtain the UNO jar files.
- */
-public final class UnoInfo {
-
- /**
- * do not instantiate
- */
- private UnoInfo() {}
-
- /**
- * Gets the URL base.
- *
- * @return the URL base
- */
- private static String getBase() {
-
- final String JUHJAR = "/juh.jar";
-
- String base = null;
-
- URLClassLoader cl = (URLClassLoader) UnoInfo.class.getClassLoader();
- URL[] urls = cl.getURLs();
- for ( int i = 0; i < urls.length; i++ ) {
- String url = urls[i].toString();
- if ( url.endsWith( JUHJAR ) )
- {
- int index = url.lastIndexOf( JUHJAR );
- if ( index >= 0 ) {
- base = url.substring( 0, index + 1 );
- break;
- }
- }
- }
-
- return base;
- }
-
- /**
- * Gets a list of URLs for the given jar files.
- *
- * @return the list of URLs
- */
- private static URL[] getURLs( String[] jarFileNames ) {
-
- URL[] jars = new URL[jarFileNames.length];
- String base = getBase();
- for ( int i = 0; i < jarFileNames.length; i++ ) {
- try {
- jars[i] = new URL( base + jarFileNames[i] );
- } catch ( MalformedURLException e ) {
- return null;
- }
- }
-
- return jars;
- }
-
- /**
- * Gets the UNO jar files.
- *
- * @return the UNO jar files
- */
- public static URL[] getJars() {
-
- String[] jarFileNames = new String[] {
- "jurt.jar",
- "ridl.jar",
- "juh.jar" };
-
- return getURLs( jarFileNames );
- }
-
- /**
- * Gets the extra UNO types.
- *
- * @return the extra UNO types
- */
- public static URL[] getExtraTypes() {
- return new URL[0];
- }
-}
diff --git a/javaunohelper/com/sun/star/comp/helper/makefile.mk b/javaunohelper/com/sun/star/comp/helper/makefile.mk
deleted file mode 100644
index 3752abc7d..000000000
--- a/javaunohelper/com/sun/star/comp/helper/makefile.mk
+++ /dev/null
@@ -1,54 +0,0 @@
-#*************************************************************************
-#
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# Copyright 2000, 2010 Oracle and/or its affiliates.
-#
-# OpenOffice.org - a multi-platform office productivity suite
-#
-# This file is part of OpenOffice.org.
-#
-# OpenOffice.org is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Lesser General Public License version 3
-# only, as published by the Free Software Foundation.
-#
-# OpenOffice.org is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Lesser General Public License version 3 for more details
-# (a copy is included in the LICENSE file that accompanied this code).
-#
-# You should have received a copy of the GNU Lesser General Public License
-# version 3 along with OpenOffice.org. If not, see
-# <http://www.openoffice.org/license.html>
-# for a copy of the LGPLv3 License.
-#
-#*************************************************************************
-
-PRJ=..$/..$/..$/..$/..
-
-PRJNAME = juhelper
-PACKAGE = com$/sun$/star$/comp$/helper
-TARGET = com_sun_star_comp_helper
-
-# --- Settings -----------------------------------------------------
-
-.INCLUDE : settings.mk
-.INCLUDE: $(PRJ)$/util$/settings.pmk
-
-# --- Files --------------------------------------------------------
-
-JAVAFILES= \
- ComponentContextEntry.java \
- ComponentContext.java \
- Bootstrap.java \
- SharedLibraryLoader.java \
- RegistryServiceFactory.java \
- BootstrapException.java \
- UnoInfo.java
-
-JAVACLASSFILES= $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
-
-# --- Targets ------------------------------------------------------
-
-.INCLUDE : target.mk
diff --git a/javaunohelper/com/sun/star/comp/juhtest/SmoketestCommandEnvironment.java b/javaunohelper/com/sun/star/comp/juhtest/SmoketestCommandEnvironment.java
deleted file mode 100644
index a28d3a145..000000000
--- a/javaunohelper/com/sun/star/comp/juhtest/SmoketestCommandEnvironment.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-package com.sun.star.comp.juhtest;
-
-import com.sun.star.lang.XMultiComponentFactory;
-import com.sun.star.lib.uno.helper.WeakBase;
-import com.sun.star.uno.UnoRuntime;
-import com.sun.star.uno.XComponentContext;
-import com.sun.star.lang.XServiceInfo;
-import com.sun.star.ucb.XCommandEnvironment;
-
-/** This service is for use by the smoketest which checks the installation of
- * extensions. The service provides the XCommandEnvironment interface, which
- * is needed for adding extensions.
- */
-public class SmoketestCommandEnvironment extends WeakBase
- implements XServiceInfo, XCommandEnvironment {
-
- static private final String __serviceName =
- "com.sun.star.deployment.test.SmoketestCommandEnvironment";
-
- private XComponentContext m_cmpCtx;
- private XMultiComponentFactory m_xMCF;
-
-
- public SmoketestCommandEnvironment(XComponentContext xCompContext) {
- try {
- m_cmpCtx = xCompContext;
- m_xMCF = m_cmpCtx.getServiceManager();
- }
- catch( Exception e ) {
- e.printStackTrace();
- }
- }
-
- public static String[] getServiceNames() {
- String[] sSupportedServiceNames = { __serviceName};
- return sSupportedServiceNames;
- }
-
- //XServiceInfo -------------------------------------------------------------
- public String[] getSupportedServiceNames() {
- return getServiceNames();
- }
-
-
- public boolean supportsService( String sServiceName ) {
- boolean bSupported = false;
- if (sServiceName.equals(__serviceName))
- bSupported = true;
- return bSupported;
- }
-
- public String getImplementationName() {
- return SmoketestCommandEnvironment.class.getName();
- }
-
- //XCommandEnvironment ================================================
- public com.sun.star.task.XInteractionHandler getInteractionHandler()
- {
- return new InteractionImpl();
- }
-
- public com.sun.star.ucb.XProgressHandler getProgressHandler()
- {
- return new ProgressImpl();
- }
-}
-
-
-
-
-class InteractionImpl implements com.sun.star.task.XInteractionHandler
-{
- public void handle( com.sun.star.task.XInteractionRequest xRequest )
- {
- Object request = xRequest.getRequest();
-
- boolean approve = true;
- boolean abort = false;
-// Object install_Exception =
-// AnyConverter.toObject(
-// com.sun.star.deployment.InstallException.class, request);
-// if (install_Exception != null)
-// {
-// approve = true;
-// }
-
- com.sun.star.task.XInteractionContinuation[] conts = xRequest.getContinuations();
- for (int i = 0; i < conts.length; i++)
- {
- if (approve)
- {
- com.sun.star.task.XInteractionApprove xApprove =
- UnoRuntime.queryInterface(com.sun.star.task.XInteractionApprove.class, conts[i]);
- if (xApprove != null)
- xApprove.select();
- //don't query again for ongoing extensions
- approve = false;
- }
- else if (abort)
- {
- com.sun.star.task.XInteractionAbort xAbort =
- UnoRuntime.queryInterface(com.sun.star.task.XInteractionAbort.class, conts[i]);
- if (xAbort != null)
- xAbort.select();
- //don't query again for ongoing extensions
- abort = false;
- }
- }
- }
-}
-
-class ProgressImpl implements com.sun.star.ucb.XProgressHandler
-{
- public void push(Object status)
- {
- }
-
- public void update(Object status)
- {
- }
-
- public void pop()
- {
- }
-}
diff --git a/javaunohelper/com/sun/star/comp/juhtest/makefile.mk b/javaunohelper/com/sun/star/comp/juhtest/makefile.mk
deleted file mode 100644
index 0d65b961a..000000000
--- a/javaunohelper/com/sun/star/comp/juhtest/makefile.mk
+++ /dev/null
@@ -1,50 +0,0 @@
-#*************************************************************************
-#
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# Copyright 2000, 2010 Oracle and/or its affiliates.
-#
-# OpenOffice.org - a multi-platform office productivity suite
-#
-# This file is part of OpenOffice.org.
-#
-# OpenOffice.org is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Lesser General Public License version 3
-# only, as published by the Free Software Foundation.
-#
-# OpenOffice.org is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Lesser General Public License version 3 for more details
-# (a copy is included in the LICENSE file that accompanied this code).
-#
-# You should have received a copy of the GNU Lesser General Public License
-# version 3 along with OpenOffice.org. If not, see
-# <http://www.openoffice.org/license.html>
-# for a copy of the LGPLv3 License.
-#
-#*************************************************************************
-
-PRJ=..$/..$/..$/..$/..
-
-PRJNAME = juhelper
-PACKAGE = com$/sun$/star$/comp$/juhtest
-TARGET = com_sun_star_comp_juhtest
-
-# --- Settings -----------------------------------------------------
-
-.INCLUDE : settings.mk
-.INCLUDE: $(PRJ)$/util$/settings.pmk
-
-# --- Files --------------------------------------------------------
-#todo: we do not want include juh.jar here but use the output tree.
-JARFILES = unoil.jar ridl.jar jurt.jar
-
-JAVAFILES= \
- SmoketestCommandEnvironment.java
-
-JAVACLASSFILES= $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
-
-# --- Targets ------------------------------------------------------
-
-.INCLUDE : target.mk
diff --git a/javaunohelper/com/sun/star/comp/makefile.mk b/javaunohelper/com/sun/star/comp/makefile.mk
deleted file mode 100644
index bde016b47..000000000
--- a/javaunohelper/com/sun/star/comp/makefile.mk
+++ /dev/null
@@ -1,49 +0,0 @@
-#*************************************************************************
-#
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# Copyright 2000, 2010 Oracle and/or its affiliates.
-#
-# OpenOffice.org - a multi-platform office productivity suite
-#
-# This file is part of OpenOffice.org.
-#
-# OpenOffice.org is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Lesser General Public License version 3
-# only, as published by the Free Software Foundation.
-#
-# OpenOffice.org is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Lesser General Public License version 3 for more details
-# (a copy is included in the LICENSE file that accompanied this code).
-#
-# You should have received a copy of the GNU Lesser General Public License
-# version 3 along with OpenOffice.org. If not, see
-# <http://www.openoffice.org/license.html>
-# for a copy of the LGPLv3 License.
-#
-#*************************************************************************
-
-PRJ=..$/..$/..$/..
-
-PRJNAME = juhelper
-PACKAGE = com$/sun$/star$/comp
-TARGET = com_sun_star_comp
-
-# --- Settings -----------------------------------------------------
-
-.INCLUDE : settings.mk
-.INCLUDE: $(PRJ)$/util$/settings.pmk
-
-# --- Files --------------------------------------------------------
-JARFILES = ridl.jar jurt.jar unoil.jar
-JAVAFILES= \
- JavaUNOHelperServices.java
-
-
-JAVACLASSFILES= $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
-
-# --- Targets ------------------------------------------------------
-
-.INCLUDE : target.mk
diff --git a/javaunohelper/com/sun/star/lib/uno/adapter/ByteArrayToXInputStreamAdapter.java b/javaunohelper/com/sun/star/lib/uno/adapter/ByteArrayToXInputStreamAdapter.java
deleted file mode 100755
index 60b4fe009..000000000
--- a/javaunohelper/com/sun/star/lib/uno/adapter/ByteArrayToXInputStreamAdapter.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-/*
- * ByteArrayXInputStram.java
- *
- * Created on 10. April 2003, 15:45
- */
-
-package com.sun.star.lib.uno.adapter;
-
-/**
- *
- * @author lo119109
- */
-
-import com.sun.star.io.XInputStream;
-import com.sun.star.io.XSeekable;
-import com.sun.star.lib.uno.helper.ComponentBase;
-
-public class ByteArrayToXInputStreamAdapter
- extends ComponentBase
- implements XInputStream, XSeekable
-{
-
- byte[] m_bytes;
- int m_length;
- int m_pos;
-
- boolean m_open;
-
- /** Creates a new instance of ByteArrayXInputStram */
- public ByteArrayToXInputStreamAdapter(byte[] bytes) {
- init(bytes);
- }
-
- public void init(byte[] bytes) {
- // System.err.println("ByteArrayXInputStream");
- m_bytes = bytes;
- m_length = bytes.length;
- m_pos = 0;
- m_open = true;
- }
-
- private void _check() throws com.sun.star.io.NotConnectedException, com.sun.star.io.IOException {
- if (m_bytes == null) {
- // System.err.println("check failed no bytes!");
- throw new com.sun.star.io.NotConnectedException("no bytes");
- }
- if(!m_open) {
- // System.err.println("check failed: closed");
- throw new com.sun.star.io.IOException("input closed");
- }
- }
-
- public int available() throws com.sun.star.io.NotConnectedException, com.sun.star.io.IOException {
- _check();
- long a = m_length - m_pos;
- if (a != (int)a)
- throw new com.sun.star.io.IOException("integer overflow");
- else {
- // System.err.println("available() -> "+a);
- return (int)a;
- }
- }
-
- public void closeInput() throws com.sun.star.io.NotConnectedException, com.sun.star.io.IOException {
- // System.err.println("closeInput()");
- _check();
- m_open = false;
- }
-
- public int readBytes(byte[][] values, int param) throws com.sun.star.io.NotConnectedException, com.sun.star.io.BufferSizeExceededException, com.sun.star.io.IOException {
- // System.err.println("readbytes(..., "+param+")");
- _check();
- try {
- int remain = (int)(m_length - m_pos);
- if (param > remain) param = remain;
- /* ARGH!!! */
- if (values[0] == null){
- values[0] = new byte[param];
- // System.err.println("allocated new buffer of "+param+" bytes");
- }
- System.arraycopy(m_bytes, m_pos, values[0], 0, param);
- // System.err.println("readbytes() -> "+param);
- m_pos += param;
- return param;
- } catch (ArrayIndexOutOfBoundsException ae) {
- // System.err.println("readbytes() -> ArrayIndexOutOfBounds");
- ae.printStackTrace();
- throw new com.sun.star.io.BufferSizeExceededException("buffer overflow");
- } catch (Exception e) {
- // System.err.println("readbytes() -> Exception: "+e.getMessage());
- e.printStackTrace();
- throw new com.sun.star.io.IOException("error accessing buffer");
- }
- }
-
- public int readSomeBytes(byte[][] values, int param) throws com.sun.star.io.NotConnectedException, com.sun.star.io.BufferSizeExceededException, com.sun.star.io.IOException {
- // System.err.println("readSomebytes()");
- return readBytes(values, param);
- }
-
- public void skipBytes(int param) throws com.sun.star.io.NotConnectedException, com.sun.star.io.BufferSizeExceededException, com.sun.star.io.IOException {
- // System.err.println("skipBytes("+param+")");
- _check();
- if (param > (m_length - m_pos))
- throw new com.sun.star.io.BufferSizeExceededException("buffer overflow");
- m_pos += param;
- }
-
- public long getLength() throws com.sun.star.io.IOException {
- // System.err.println("getLength() -> "+m_length);
- if (m_bytes != null) return m_length;
- else throw new com.sun.star.io.IOException("no bytes");
- }
-
- public long getPosition() throws com.sun.star.io.IOException {
- // System.err.println("getPosition() -> "+m_pos);
- if (m_bytes != null) return m_pos;
- else throw new com.sun.star.io.IOException("no bytes");
- }
-
- public void seek(long param) throws com.sun.star.lang.IllegalArgumentException, com.sun.star.io.IOException {
- // System.err.println("seek("+param+")");
- if (m_bytes != null){
- if (param < 0 || param > m_length) throw new com.sun.star.lang.IllegalArgumentException("invalid seek position");
- else m_pos = (int)param;
- }else throw new com.sun.star.io.IOException("no bytes");
- }
-
- public void finalize() throws Throwable{
- // System.err.println("finalizer called for ByteArrayXInputStream!");
- super.finalize();
- }
-
-}
diff --git a/javaunohelper/com/sun/star/lib/uno/adapter/InputStreamToXInputStreamAdapter.java b/javaunohelper/com/sun/star/lib/uno/adapter/InputStreamToXInputStreamAdapter.java
deleted file mode 100644
index f143bf82f..000000000
--- a/javaunohelper/com/sun/star/lib/uno/adapter/InputStreamToXInputStreamAdapter.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-package com.sun.star.lib.uno.adapter;
-
-import java.io.IOException;
-import com.sun.star.io.XInputStream;
-import java.io.InputStream;
-
-/** The <code>InputStreamToInputXStreamAdapter</code> wraps the
- Java <code>InputStream</code> object into a
- UNO <code>XInputStream</code> object.
- This allows users to access an <code>InputStream</code>
- as if it were an <code>XInputStream</code>.
- */
-public class InputStreamToXInputStreamAdapter implements XInputStream {
-
- /**
- * Internal store to the InputStream
- */
- private InputStream iIn;
-
- /**
- * Constructor.
- *
- * @param in The <code>XInputStream</code> to be
- * accessed as an <code>InputStream</code>.
- */
- public InputStreamToXInputStreamAdapter (InputStream in)
- {
- iIn = in;
- }
-
- public int available() throws
- com.sun.star.io.IOException
- {
-
- int bytesAvail;
-
- try {
- bytesAvail = iIn.available();
- } catch (IOException e) {
- throw new com.sun.star.io.IOException(e.toString());
- }
-
- return(bytesAvail);
- }
-
- public void closeInput() throws
- com.sun.star.io.IOException
- {
- try {
- iIn.close();
- } catch (IOException e) {
- throw new com.sun.star.io.IOException(e.toString());
- }
- }
-
- public int readBytes(byte[][] b, int len) throws
- com.sun.star.io.IOException
- {
- int count = 0;
- try {
- long bytesRead=0;
- if (len >iIn.available()) {
- bytesRead = iIn.read(b[0], 0, iIn.available());
- }
- else{
- bytesRead = iIn.read(b[0], 0, len);
- }
- // Casting bytesRead to an int is okay, since the user can
- // only pass in an integer length to read, so the bytesRead
- // must <= len.
- //
- if (bytesRead <= 0) {
- return(0);
- }
- return ((int)bytesRead);
-
-
- } catch (IOException e) {
- throw new com.sun.star.io.IOException("reader error: "+e.toString());
- }
- }
-
- public int readSomeBytes(byte[][] b, int len) throws
- com.sun.star.io.IOException
- {
- int count = 0;
- try {
- long bytesRead=0;
- if (len >iIn.available()) {
- bytesRead = iIn.read(b[0], 0, iIn.available());
- }
- else{
- bytesRead = iIn.read(b[0], 0, len);
- }
- // Casting bytesRead to an int is okay, since the user can
- // only pass in an integer length to read, so the bytesRead
- // must <= len.
- //
- if (bytesRead <= 0) {
- return(0);
- }
- return ((int)bytesRead);
-
-
- } catch (IOException e) {
- throw new com.sun.star.io.IOException("reader error: "+e.toString());
- }
- }
-
- public void skipBytes(int n) throws
- com.sun.star.io.IOException
- {
- int avail;
- int tmpLongVal = n;
- int tmpIntVal;
-
- try {
- avail = iIn.available();
- } catch (IOException e) {
- throw new com.sun.star.io.IOException(e.toString());
- }
-
- do {
- if (tmpLongVal >= Integer.MAX_VALUE) {
- tmpIntVal = Integer.MAX_VALUE;
- } else {
- // Casting is safe here.
- tmpIntVal = (int)tmpLongVal;
- }
- tmpLongVal -= tmpIntVal;
-
- try {
- iIn.skip(tmpIntVal);
- } catch (IOException e) {
- throw new com.sun.star.io.IOException(e.toString());
- }
- } while (tmpLongVal > 0);
- }
-}
-
diff --git a/javaunohelper/com/sun/star/lib/uno/adapter/OutputStreamToXOutputStreamAdapter.java b/javaunohelper/com/sun/star/lib/uno/adapter/OutputStreamToXOutputStreamAdapter.java
deleted file mode 100644
index 0f69faffa..000000000
--- a/javaunohelper/com/sun/star/lib/uno/adapter/OutputStreamToXOutputStreamAdapter.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-package com.sun.star.lib.uno.adapter;
-
-import java.io.IOException;
-import com.sun.star.io.XOutputStream;
-import java.io.OutputStream;
-
-/** The <code>OutputStreamToXOutputStreamAdapter</code> wraps
- a a UNO <code>XOutputStream</code> into a Java <code>OutputStream</code>
- object in a Java. This allows users to access an <code>OutputStream</code>
- as if it were an <code>XOutputStream</code>.
- */
-public class OutputStreamToXOutputStreamAdapter implements XOutputStream {
-
- /**
- * Internal handle to the OutputStream
- */
- OutputStream iOut;
-
- /**
- * Constructor.
- *
- * @param out The <code>XOutputStream</code> to be
- * accessed as an <code>OutputStream</code>.
- */
- public OutputStreamToXOutputStreamAdapter(OutputStream out) {
- iOut = out;
- }
-
- public void closeOutput() throws
- com.sun.star.io.IOException
- {
- try {
- iOut.close();
- } catch (IOException e) {
- throw new com.sun.star.io.IOException(e.toString());
- }
- }
-
- public void flush() throws
- com.sun.star.io.IOException
- {
- try {
- iOut.flush();
- } catch (IOException e) {
- throw new com.sun.star.io.IOException(e.toString());
- }
- }
-
- public void writeBytes(byte[] b) throws
- com.sun.star.io.IOException
- {
-
- try {
- iOut.write(b);
- } catch (IOException e) {
- throw new com.sun.star.io.IOException(e.toString());
- }
- }
-
-}
diff --git a/javaunohelper/com/sun/star/lib/uno/adapter/XInputStreamToInputStreamAdapter.java b/javaunohelper/com/sun/star/lib/uno/adapter/XInputStreamToInputStreamAdapter.java
deleted file mode 100644
index 696956964..000000000
--- a/javaunohelper/com/sun/star/lib/uno/adapter/XInputStreamToInputStreamAdapter.java
+++ /dev/null
@@ -1,207 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-package com.sun.star.lib.uno.adapter;
-
-import java.io.IOException;
-import com.sun.star.io.XInputStream;
-import java.io.InputStream;
-
-/**
- * The <code>XInputStreamToInputStreamAdapter</code> wraps
- * the UNO <code>XInputStream</code> object in a Java
- * <code>InputStream</code>. This allows users to access
- * an <code>XInputStream</code> as if it were an
- * <code>InputStream</code>.
- *
- * @author Brian Cameron
- */
-public class XInputStreamToInputStreamAdapter extends InputStream {
-
- /**
- * Internal handle to the XInputStream
- */
- private XInputStream xin;
-
- /**
- * Constructor.
- *
- * @param in The <code>XInputStream</code> to be
- * accessed as an <code>InputStream</code>.
- */
- public XInputStreamToInputStreamAdapter (XInputStream in) {
- xin = in;
- }
-
- public int available() throws IOException {
-
- int bytesAvail;
-
- try {
- bytesAvail = xin.available();
- } catch (Exception e) {
- throw new IOException(e.toString());
- }
-
- return(bytesAvail);
- }
-
- public void close() throws IOException {
- try {
- xin.closeInput();
- } catch (Exception e) {
- throw new IOException(e.toString());
- }
- }
-
- public int read () throws IOException {
- byte [][] tmp = new byte [1][1];
- try {
- long bytesRead = xin.readBytes(tmp, 1);
-
- if (bytesRead <= 0) {
- return (-1);
- } else {
- int tmpInt = tmp[0][0];
- if (tmpInt< 0 ){
- tmpInt = 256 +tmpInt;
- }
- return(tmpInt);
- }
-
- } catch (Exception e) {
- throw new IOException(e.toString());
- }
- }
-
- public int read (byte[] b) throws IOException {
-
- byte [][] tmp = new byte [1][b.length];
- int bytesRead;
-
- try {
- bytesRead = xin.readBytes(tmp, b.length);
- if (bytesRead <= 0) {
- return(-1);
- } else if (bytesRead < b.length) {
- System.arraycopy(tmp[0], 0, b, 0, bytesRead);
- } else {
- System.arraycopy(tmp[0], 0, b, 0, b.length);
- }
- } catch (Exception e) {
- throw new IOException(e.toString());
- }
-
- return (bytesRead);
- }
-
- public int read(byte[] b, int off, int len) throws IOException {
- int count = 0;
- byte [][] tmp = new byte [1][b.length];
- try {
- long bytesRead=0;
- int av = xin.available();
- if ( av != 0 && len > av) {
- bytesRead = xin.readBytes(tmp, av);
- }
- else{
- bytesRead = xin.readBytes(tmp,len);
- }
- // Casting bytesRead to an int is okay, since the user can
- // only pass in an integer length to read, so the bytesRead
- // must <= len.
- //
- if (bytesRead <= 0) {
- return(-1);
- } else if (bytesRead < len) {
- System.arraycopy(tmp[0], 0, b, off, (int)bytesRead);
- } else {
- System.arraycopy(tmp[0], 0, b, off, len);
- }
-
- return ((int)bytesRead);
-
-
- } catch (Exception e) {
- throw new IOException("reader error: "+e.toString());
- }
- }
-
- public long skip(long n) throws IOException {
-
- int avail;
- long tmpLongVal = n;
- int tmpIntVal;
-
- try {
- avail = xin.available();
- } catch (Exception e) {
- throw new IOException(e.toString());
- }
-
- do {
- if (tmpLongVal >= Integer.MAX_VALUE) {
- tmpIntVal = Integer.MAX_VALUE;
- } else {
- // Casting is safe here.
- tmpIntVal = (int)tmpLongVal;
- }
- tmpLongVal -= tmpIntVal;
-
- try {
- xin.skipBytes(tmpIntVal);
- } catch (Exception e) {
- throw new IOException(e.toString());
- }
- } while (tmpLongVal > 0);
-
- if ( avail != 0 && avail < n) {
- return(avail);
- } else {
- return(n);
- }
- }
-
- /**
- * Tests if this input stream supports the mark and reset methods.
- * The markSupported method of
- * <code>XInputStreamToInputStreamAdapter</code> returns false.
- *
- * @returns false
- */
- public boolean markSupported() {
- return false;
- }
-
- public void mark(int readlimit) {
- // Not supported.
- }
-
- public void reset() throws IOException {
- // Not supported.
- }
-}
-
diff --git a/javaunohelper/com/sun/star/lib/uno/adapter/XOutputStreamToByteArrayAdapter.java b/javaunohelper/com/sun/star/lib/uno/adapter/XOutputStreamToByteArrayAdapter.java
deleted file mode 100755
index 8812f02b0..000000000
--- a/javaunohelper/com/sun/star/lib/uno/adapter/XOutputStreamToByteArrayAdapter.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-/*
- * ByteArrayXOutputStream.java
- *
- * Created on 11. April 2003, 14:20
- */
-
-package com.sun.star.lib.uno.adapter;
-
-/**
- *
- * @author lo119109
- */
-
-import com.sun.star.io.*;
-import com.sun.star.lib.uno.helper.ComponentBase;
-
-public class XOutputStreamToByteArrayAdapter
- extends ComponentBase
- implements XOutputStream
-{
- private int initialSize = 100240; // 10 kb
- private int size = 0;
- private int position = 0;
- private boolean externalBuffer = false;
- private boolean closed = false;
- private byte[] buffer;
-
- /** Creates a new instance of ByteArrayXOutputStream */
- public XOutputStreamToByteArrayAdapter() {
- this(null);
- }
-
- public XOutputStreamToByteArrayAdapter(byte[] aBuffer) {
- if (aBuffer != null) {
- externalBuffer = true;
- buffer = aBuffer;
- size = buffer.length;
- // System.err.println("new outputbuffer with external storage");
- } else {
- size = initialSize;
- buffer = new byte[size];
- // System.err.println("new outputbuffer with internal storage");
- }
- }
-
- public byte[] getBuffer() {
- return buffer;
- }
-
- public void closeOutput()
- throws com.sun.star.io.NotConnectedException,
- com.sun.star.io.BufferSizeExceededException,
- com.sun.star.io.IOException
- {
- // trim buffer
- if ( buffer.length > position && !externalBuffer )
- {
- byte[] newBuffer = new byte[position];
- System.arraycopy(buffer, 0, newBuffer, 0, position);
- buffer = newBuffer;
- }
- closed = true;
- }
-
- public void flush()
- throws com.sun.star.io.NotConnectedException,
- com.sun.star.io.BufferSizeExceededException,
- com.sun.star.io.IOException
- {
- }
-
- public void writeBytes(byte[] values)
- throws com.sun.star.io.NotConnectedException,
- com.sun.star.io.BufferSizeExceededException,
- com.sun.star.io.IOException
- {
- // System.err.println("writeBytes("+values.length+")");
- if ( values.length > size-position )
- {
- if ( externalBuffer )
- throw new BufferSizeExceededException("out of buffer space, cannot grow external buffer");
- byte[] newBuffer = null;
- while ( values.length > size-position )
- size *= 2;
- // System.err.println("new buffer size is "+size+" bytes.");
- newBuffer = new byte[size];
- System.arraycopy(buffer, 0, newBuffer, 0, position);
- buffer = newBuffer;
- }
- System.arraycopy(values, 0, buffer, position, values.length);
- position += values.length;
- }
-
-}
diff --git a/javaunohelper/com/sun/star/lib/uno/adapter/XOutputStreamToOutputStreamAdapter.java b/javaunohelper/com/sun/star/lib/uno/adapter/XOutputStreamToOutputStreamAdapter.java
deleted file mode 100644
index e8f521b5e..000000000
--- a/javaunohelper/com/sun/star/lib/uno/adapter/XOutputStreamToOutputStreamAdapter.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-package com.sun.star.lib.uno.adapter;
-
-import java.io.IOException;
-import com.sun.star.io.XOutputStream;
-import java.io.OutputStream;
-
-/**
- * The <code>XOutputStreamToOutputStreamAdapter</code> wraps
- * the UNO <code>XOutputStream</code> object in a Java
- * <code>OutputStream</code>. This allows users to access
- * an <code>XOutputStream</code> as if it were an
- * <code>OutputStream</code>.
- *
- * @author Brian Cameron
- */
-public class XOutputStreamToOutputStreamAdapter extends OutputStream {
-
- /**
- * Internal handle to the XInputStream
- */
- XOutputStream xout;
-
- /**
- * Constructor.
- *
- * @param out The <code>XOutputStream</code> to be
- * accessed as an <code>OutputStream</code>.
- */
- public XOutputStreamToOutputStreamAdapter(XOutputStream out) {
- xout = out;
- }
-
- public void close() throws IOException {
- try {
- xout.closeOutput();
- } catch (Exception e) {
- throw new IOException(e.toString());
- }
- }
-
- public void flush() throws IOException {
- try {
- xout.flush();
- } catch (Exception e) {
- throw new IOException(e.toString());
- }
- }
-
- public void write(byte[] b) throws IOException {
-
- try {
- xout.writeBytes(b);
- } catch (Exception e) {
- throw new IOException(e.toString());
- }
- }
-
- public void write(byte[] b, int off, int len) throws IOException {
-
- byte[] tmp = new byte[len];
-
- // Copy the input array into a temp array, and write it out.
- //
- System.arraycopy(b, off, tmp, 0, len);
-
- try {
- xout.writeBytes(tmp);
- } catch (Exception e) {
- throw new IOException(e.toString());
- }
- }
-
- public void write(int b) throws IOException {
-
- byte [] oneByte = new byte [1];
- oneByte[0] = (byte) b;
-
- try {
- xout.writeBytes(oneByte);
- } catch (Exception e) {
- throw new IOException(e.toString());
- }
- }
-}
diff --git a/javaunohelper/com/sun/star/lib/uno/adapter/makefile.mk b/javaunohelper/com/sun/star/lib/uno/adapter/makefile.mk
deleted file mode 100644
index 793f5fb1d..000000000
--- a/javaunohelper/com/sun/star/lib/uno/adapter/makefile.mk
+++ /dev/null
@@ -1,54 +0,0 @@
-#*************************************************************************
-#
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# Copyright 2000, 2010 Oracle and/or its affiliates.
-#
-# OpenOffice.org - a multi-platform office productivity suite
-#
-# This file is part of OpenOffice.org.
-#
-# OpenOffice.org is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Lesser General Public License version 3
-# only, as published by the Free Software Foundation.
-#
-# OpenOffice.org is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Lesser General Public License version 3 for more details
-# (a copy is included in the LICENSE file that accompanied this code).
-#
-# You should have received a copy of the GNU Lesser General Public License
-# version 3 along with OpenOffice.org. If not, see
-# <http://www.openoffice.org/license.html>
-# for a copy of the LGPLv3 License.
-#
-#*************************************************************************
-
-PRJ=..$/..$/..$/..$/..$/..
-
-PRJNAME = juhelper
-PACKAGE = com$/sun$/star$/lib$/uno$/adapter
-TARGET = com_sun_star_lib_uno_adapter
-
-# --- Settings -----------------------------------------------------
-
-.INCLUDE : settings.mk
-.INCLUDE: $(PRJ)$/util$/settings.pmk
-
-# --- Files --------------------------------------------------------
-
-JAVAFILES= \
- XInputStreamToInputStreamAdapter.java \
- XOutputStreamToOutputStreamAdapter.java \
- InputStreamToXInputStreamAdapter.java \
- OutputStreamToXOutputStreamAdapter.java \
- ByteArrayToXInputStreamAdapter.java \
- XOutputStreamToByteArrayAdapter.java
-
-
-JAVACLASSFILES= $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
-
-# --- Targets ------------------------------------------------------
-
-.INCLUDE : target.mk
diff --git a/javaunohelper/com/sun/star/lib/uno/helper/ComponentBase.java b/javaunohelper/com/sun/star/lib/uno/helper/ComponentBase.java
deleted file mode 100644
index 283391832..000000000
--- a/javaunohelper/com/sun/star/lib/uno/helper/ComponentBase.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-package com.sun.star.lib.uno.helper;
-import com.sun.star.lang.XComponent;
-import com.sun.star.lang.XEventListener;
-import com.sun.star.lang.EventObject;
-import com.sun.star.uno.Type;
-
-/** This class can be used as the base class for UNO components. In addition to the functionality ,which
- * is inherited from WeakBase, it implements com.sun.star.lang.XComponent.
- */
-public class ComponentBase extends WeakBase implements XComponent
-{
- private final boolean DEBUG= false;
- protected MultiTypeInterfaceContainer listenerContainer;
- protected boolean bInDispose= false;
- protected boolean bDisposed= false;
- static final Type EVT_LISTENER_TYPE= new Type(XEventListener.class);
-
-
- /** Creates a new instance of CompBase */
- public ComponentBase()
- {
- super();
- listenerContainer= new MultiTypeInterfaceContainer();
- }
-
- /** Override to perform extra clean-up work. Provided for subclasses. It is
- called during dispose()
- */
- protected void preDisposing()
- {
- }
- /** Override to become notified right before the disposing action is performed.
- */
- protected void postDisposing()
- {
- }
-
-
- /** Method of XComponent. It is called by the owning client when the component is not needed
- * anymore. The registered listeners are notified that this method has been called.
- */
- public void dispose()
- {
- // Determine in a thread-safe way if this is the first call to this method.
- // Only then we proceed with the notification of event listeners.
- // It is an error to call this method more then once.
- boolean bDoDispose= false;
- synchronized (this)
- {
- if ( ! bInDispose && ! bDisposed)
- {
- bDoDispose= true;
- bInDispose= true;
- }
- }
- // The notification occures in an unsynchronized block in order to avoid
- // deadlocks if one of the listeners calls back in a different thread on
- // a synchronized method which uses the same object.
- if (bDoDispose)
- {
- try
- {
- preDisposing();
- listenerContainer.disposeAndClear(new EventObject(this));
- //notify subclasses that disposing is in progress
- postDisposing();
- }
- finally
- {
- // finally makes sure that the flags are set even if a RuntimeException is thrown.
- // That ensures that this function is only called once.
- bDisposed= true;
- bInDispose= false;
- }
- }
- else
- {
- // in a multithreaded environment, it can't be avoided, that dispose is called twice.
- // However this condition is traced, because it MAY indicate an error.
- if (DEBUG)
- System.out.println("OComponentHelper::dispose() - dispose called twice" );
- }
- }
-
- /** Method of XComponent.
- */
- public void removeEventListener(XEventListener xEventListener)
- {
- listenerContainer.removeInterface( EVT_LISTENER_TYPE, xEventListener);
- }
-
- public void addEventListener(XEventListener listener)
- {
- boolean bDoDispose= false;
- synchronized (this)
- {
- if (bDisposed || bInDispose)
- bDoDispose= true;
- else
- listenerContainer.addInterface(EVT_LISTENER_TYPE, listener);
- }
- if (bDoDispose )
- {
- listener.disposing( new EventObject(this));
- }
- }
-
- protected void finalize() throws Throwable
- {
- if ( ! bInDispose && ! bDisposed)
- dispose();
- super.finalize();
- }
-}
diff --git a/javaunohelper/com/sun/star/lib/uno/helper/Factory.java b/javaunohelper/com/sun/star/lib/uno/helper/Factory.java
deleted file mode 100644
index aa67282ca..000000000
--- a/javaunohelper/com/sun/star/lib/uno/helper/Factory.java
+++ /dev/null
@@ -1,268 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-package com.sun.star.lib.uno.helper;
-
-import com.sun.star.uno.XComponentContext;
-import com.sun.star.lang.XSingleComponentFactory;
-import com.sun.star.lang.XServiceInfo;
-import com.sun.star.lang.XInitialization;
-import com.sun.star.registry.XRegistryKey;
-
-import com.sun.star.uno.UnoRuntime;
-
-
-/** Factory helper class supporting com.sun.star.lang.XServiceInfo and
- com.sun.star.lang.XSingleComponentFactory.
-
- @attention
- This factory implementation does not support lang.XSingleServiceFactory.
-*/
-public class Factory
- extends ComponentBase
- implements XSingleComponentFactory, XServiceInfo
-{
- private static final boolean DEBUG = false;
-
- /** Creates an object factory supporting interfaces
- com.sun.star.lang.XSingleComponentFactory and
- com.sun.star.lang.XServiceInfo
-
- @param impl_class
- implementation class
- @param impl_name
- implementation name
- @param supported_services
- services implemented
- @return
- object factory
-
- @since UDK 3.2.13
- */
- public static XSingleComponentFactory createComponentFactory(
- Class impl_class, String impl_name, String supported_services [] )
- throws com.sun.star.uno.RuntimeException
- {
- return new Factory( impl_class, impl_name, supported_services );
- }
-
- /** Creates an object factory supporting interfaces
- com.sun.star.lang.XSingleComponentFactory and
- com.sun.star.lang.XServiceInfo
-
- The implementation name is the name of the implementation class.
-
- @param impl_class
- implementation class
- @param supported_services
- services implemented
- @return
- object factory
- */
- public static XSingleComponentFactory createComponentFactory(
- Class impl_class, String supported_services [] )
- throws com.sun.star.uno.RuntimeException
- {
- return createComponentFactory(
- impl_class, impl_class.getName(), supported_services );
- }
- /** Writes component's implementation info to given registry key.
-
- @param impl_name
- name of implementation
- @param supported_services
- supported services of implementation
- @param xKey
- registry key to write to
- @return
- success
- */
- public static boolean writeRegistryServiceInfo(
- String impl_name, String supported_services [], XRegistryKey xKey )
- {
- try
- {
- XRegistryKey xNewKey = xKey.createKey( "/" + impl_name + "/UNO/SERVICES" );
- for ( int nPos = 0; nPos < supported_services.length; ++nPos )
- {
- xNewKey.createKey( supported_services[ nPos ] );
- }
- return true;
- }
- catch (com.sun.star.registry.InvalidRegistryException exc)
- {
- if (DEBUG)
- {
- System.err.println(
- "##### " + Factory.class.getName() + ".writeRegistryServiceInfo -- exc: " +
- exc.toString() );
- }
- }
- return false;
- }
-
- //==============================================================================================
- private String m_impl_name;
- private String [] m_supported_services;
- private Class m_impl_class;
- private java.lang.reflect.Method m_method;
- private java.lang.reflect.Constructor m_ctor;
-
- private Factory(
- Class impl_class, String impl_name, String supported_services [] )
- {
- m_impl_name = impl_name;
- m_supported_services = supported_services;
- m_impl_class = impl_class;
- m_method = null;
- m_ctor = null;
-
- Class params [] = new Class [] { XComponentContext.class };
-
- try
- {
- // seeking for "public static Object __create( XComponentContext )"
- m_method = m_impl_class.getMethod( "__create", params );
- int mod = m_method.getModifiers();
- if (!m_method.getReturnType().equals( Object.class ) ||
- !java.lang.reflect.Modifier.isStatic( mod ) ||
- !java.lang.reflect.Modifier.isPublic( mod ))
- {
- m_method = null;
- }
- }
- catch (Exception exc)
- {
- }
-
- if (null == m_method)
- {
- try
- {
- // ctor with context
- m_ctor = m_impl_class.getConstructor( params );
- }
- catch (Exception exc)
- {
- // else take default ctor
- }
- }
- }
-
- //______________________________________________________________________________________________
- private final Object instantiate( XComponentContext xContext )
- throws com.sun.star.uno.Exception
- {
- try
- {
- if (DEBUG)
- System.out.print( "instantiating " + m_impl_class.toString() + " using " );
- if (null != m_method)
- {
- if (DEBUG)
- System.out.println( "__create( XComponentContext )..." );
- return m_method.invoke( null, new Object [] { xContext } );
- }
- if (null != m_ctor)
- {
- if (DEBUG)
- System.out.println( "ctor( XComponentContext )..." );
- return m_ctor.newInstance( new Object [] { xContext } );
- }
- if (DEBUG)
- System.out.println( "default ctor..." );
- return m_impl_class.newInstance(); // default ctor
- }
- catch (java.lang.reflect.InvocationTargetException exc)
- {
- Throwable targetException = exc.getTargetException();
- if (targetException instanceof java.lang.RuntimeException)
- throw (java.lang.RuntimeException)targetException;
- else if (targetException instanceof com.sun.star.uno.RuntimeException)
- throw (com.sun.star.uno.RuntimeException)targetException;
- else if (targetException instanceof com.sun.star.uno.Exception)
- throw (com.sun.star.uno.Exception)targetException;
- else
- throw new com.sun.star.uno.Exception( targetException.toString(), this );
- }
- catch (IllegalAccessException exc)
- {
- throw new com.sun.star.uno.RuntimeException( exc.toString(), this );
- }
- catch (InstantiationException exc)
- {
- throw new com.sun.star.uno.RuntimeException( exc.toString(), this );
- }
- }
- // XSingleComponentFactory impl
- //______________________________________________________________________________________________
- public final Object createInstanceWithContext(
- XComponentContext xContext )
- throws com.sun.star.uno.Exception
- {
- return instantiate( xContext );
- }
- //______________________________________________________________________________________________
- public final Object createInstanceWithArgumentsAndContext(
- Object arguments [], XComponentContext xContext )
- throws com.sun.star.uno.Exception
- {
- Object inst = instantiate( xContext );
- XInitialization xInit = UnoRuntime.queryInterface(
- XInitialization.class, inst );
- if (null == xInit)
- {
- throw new com.sun.star.lang.IllegalArgumentException(
- "cannot pass arguments to component; no XInitialization implemented!", this,
- (short)0 );
- }
- xInit.initialize( arguments );
- return inst;
- }
-
- // XServiceInfo impl
- //______________________________________________________________________________________________
- public final String getImplementationName()
- {
- return m_impl_name;
- }
- //______________________________________________________________________________________________
- public final boolean supportsService( String service_name )
- {
- for ( int nPos = 0; nPos < m_supported_services.length; ++nPos )
- {
- if (m_supported_services[ nPos ].equals( service_name ))
- return true;
- }
- return false;
- }
- //______________________________________________________________________________________________
- public final String [] getSupportedServiceNames()
- {
- return m_supported_services;
- }
-}
-
diff --git a/javaunohelper/com/sun/star/lib/uno/helper/InterfaceContainer.java b/javaunohelper/com/sun/star/lib/uno/helper/InterfaceContainer.java
deleted file mode 100644
index c029fcf54..000000000
--- a/javaunohelper/com/sun/star/lib/uno/helper/InterfaceContainer.java
+++ /dev/null
@@ -1,856 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-package com.sun.star.lib.uno.helper;
-import java.util.Iterator;
-import java.util.ListIterator;
-import java.util.NoSuchElementException;
-import java.util.Collection;
-import com.sun.star.lang.EventObject;
-import com.sun.star.lang.XEventListener;
-import com.sun.star.uno.UnoRuntime;
-
-/**
- * This class is a container for interfaces.
- *
- * It is intended to be used as storage for UNO interface of a specific type.
- * The client has to ensure that the container contains only elements of the same
- * type. If one needs to store different types, then one uses OMultiTypeInterfaceContainer.
- * When the client calls disposeAndClear, the contained objects are queried for
- * com.sun.star.lang.XEventListener and disposing is called. Afterwards
- * the list cannot be used anymore.
- *
- * This list does not allow null values.
- * All methods are thread-safe. The same holds true for
- * iterators, issued by this class. Several iterators can exist at the same time and can also
- * be modified (java.util.ListIterator.add, java.util.ListIterator.remove etc.). To make this work,
- * the InterfaceContainer provides the iterators with copys of the list's data.
- * The add and remove calls on the iterator modify the data in the iterator's list as well as
- * in InterfaceContainer. Modification on InterfaceContainer, however, are not
- * synchronized with existing iterators. For example
- * <pre>
- * InterfaceContainer cont= new InterfaceContainer();
- * ListIterator it= cont.listIterator();
- *
- * cont.add( someInterface);
- * // one cannot obtain someInterface through iterator it,
- * // instead get a new iterator
- * it= cont.listIterator();
- * // it now keeps a fresh copy of cont and hence contains someInterface
- *
- * // Adding an interface on the iterator will cause the interface also to be added
- * // to InterfaceContainer
- * it.add( someOtherInterface);
- * // someOtherInterface is now in it and cont
- * ListIterator it2= cont.listIterator();
- * //someOtherInterface can also be obtained by all newly created iterators, e.g. it2.
- * </pre>
- *
- * The add and remove methods of an iterator work on a particular location within a list,
- * dependent on what the value of the iterator's cursor is. After the call the value at the
- * appropriate position has been modified. Since the iterator received a copy of InterfaceContainer's
- * data, InterfaceContainer may have been modified (by List methods or through other iterators).
- * Therefore both data sets may not contain the same elements anymore. Consequently, a List method
- * that modifies data, does not modify InterfaceContainer's data at a certain index
- * (according to the iterators cursor). Instead, new elements are added at the end of list. When
- * Iterator.remove is called, then the first occurrence of that element in InterfaceContainer
- * is removed.
- * ListIterator.set is not supported.
- *
- * A lot of methods resemble those of the to java.util.List interface, allthough
- * this class does not implement it. However, the list iterators returned, for example by
- * the listIterator method implement the java.util.ListIterator interface.
- * Implementing the List interface would mean to support all none - optional methods as
- * prescribed by the interface declaration. Among those is the subList method which returns
- * a range of values of the list's data wrapped in a List implementation. Changes to the sub
- * list have to cause changes in the main list. This is a problem, since this class is to be
- * used in a multi-threaded environment. The sub list could work on a copy as the iterators
- * do, but all the functions which work on an given index could not be properly supported.
- * Unfortunatly, the List interface documentation states that all optional methods implemented
- * by the list have to be implemented in the sub list. That would mean to do without all those
- * critical methods, allthough they might work well in the "main list" (as opposed to sub list).
- */
-public class InterfaceContainer implements Cloneable
-{
- final boolean DEBUG= false;
- /**
- * The array buffer into which the elements of the ArrayList are stored.
- * The capacity of the ArrayList is the length of this array buffer.
- */
- Object elementData[];
-
- /**
- * The size of the ArrayList (the number of elements it contains).
- *
- * @serial
- */
- private int size;
-
-
- //private ArrayList data= new ArrayList();
- /** Creates a new instance of InterfaceContainer */
- public InterfaceContainer()
- {
- this(10);
- }
- /**
- * Constructs an empty list with the specified initial capacity.
- *
- * @param initialCapacity the initial capacity of the list.
- * @exception IllegalArgumentException if the specified initial capacity
- * is negative
- */
- public InterfaceContainer(int initialCapacity)
- {
- if (initialCapacity < 0)
- throw new java.lang.IllegalArgumentException("Illegal Capacity: "+
- initialCapacity);
- this.elementData = new Object[initialCapacity];
- }
-
- /**
- * Trims the capacity of this <tt>ArrayList</tt> instance to be the
- * list's current size. An application can use this operation to minimize
- * the storage of an <tt>ArrayList</tt> instance.
- */
- synchronized public void trimToSize()
- {
- int oldCapacity = elementData.length;
- if (size < oldCapacity)
- {
- Object oldData[] = elementData;
- elementData = new Object[size];
- System.arraycopy(oldData, 0, elementData, 0, size);
- }
- }
-
- /**
- * Increases the capacity of this <tt>ArrayList</tt> instance, if
- * necessary, to ensure that it can hold at least the number of elements
- * specified by the minimum capacity argument.
- *
- * @param minCapacity the desired minimum capacity.
- */
- synchronized public void ensureCapacity(int minCapacity)
- {
- int oldCapacity = elementData.length;
- if (minCapacity > oldCapacity)
- {
- Object oldData[] = elementData;
- int newCapacity = (oldCapacity * 3)/2 + 1;
- if (newCapacity < minCapacity)
- newCapacity = minCapacity;
- elementData = new Object[newCapacity];
- System.arraycopy(oldData, 0, elementData, 0, size);
- }
- }
-
- /**
- * Appends the specified element to the end of this list.
- *
- * @param o element to be appended to this list.
- * @return <tt>true</tt> (as per the general contract of Collection.add).
- */
- synchronized public boolean add(Object o)
- {
- boolean ret= false;
- if (elementData != null && o != null)
- {
- ensureCapacity(size + 1); // Increments modCount!!
- elementData[size++] = o;
- ret= true;
- }
- return ret;
- }
-
- /**
- * Inserts the specified element at the specified position in this
- * list. Shifts the element currently at that position (if any) and
- * any subsequent elements to the right (adds one to their indices).
- *
- * @param index index at which the specified element is to be inserted.
- * @param element element to be inserted.
- * @throws IndexOutOfBoundsException if index is out of range
- * <tt>(index &lt; 0 || index &gt; size())</tt>.
- */
- synchronized public void add(int index, Object element)
- {
- if (elementData != null && element != null)
- {
- if (index > size || index < 0)
- throw new IndexOutOfBoundsException(
- "Index: "+index+", Size: "+size);
-
- ensureCapacity(size+1);
- System.arraycopy(elementData, index, elementData, index + 1,
- size - index);
- elementData[index] = element;
- size++;
- }
- }
-
-
- /**
- * Appends all of the elements in the specified Collection to the end of
- * this list, in the order that they are returned by the
- * specified Collection's Iterator. The behavior of this operation is
- * undefined if the specified Collection is modified while the operation
- * is in progress. (This implies that the behavior of this call is
- * undefined if the specified Collection is this list, and this
- * list is nonempty.)
- *
- * @param c the elements to be inserted into this list.
- * @throws IndexOutOfBoundsException if index out of range <tt>(index
- * &lt; 0 || index &gt; size())</tt>.
- */
- synchronized public boolean addAll(Collection c)
- {
- int numNew = c.size();
- ensureCapacity(size + numNew);
-
- Iterator e = c.iterator();
- for (int i=0; i<numNew; i++)
- {
- Object o= e.next();
- if (o != null)
- elementData[size++] = o;
- }
- return numNew != 0;
- }
- /**
- * Inserts all of the elements in the specified Collection into this
- * list, starting at the specified position. Shifts the element
- * currently at that position (if any) and any subsequent elements to
- * the right (increases their indices). The new elements will appear
- * in the list in the order that they are returned by the
- * specified Collection's iterator.
- *
- * @param index index at which to insert first element
- * from the specified collection.
- * @param c elements to be inserted into this list.
- * @throws IndexOutOfBoundsException if index out of range <tt>(index
- * &lt; 0 || index &gt; size())</tt>.
- */
- synchronized public boolean addAll(int index, Collection c)
- {
- boolean ret= false;
- if (elementData != null)
- {
- if (index > size || index < 0)
- throw new IndexOutOfBoundsException(
- "Index: "+index+", Size: "+size);
- // only add the non-null elements
- int sizeCol= c.size();
- Object[] arColl= new Object[sizeCol];
- Iterator icol= c.iterator();
- int curIndex= 0;
- for (int i=0; i < sizeCol; i++)
- {
- Object o= icol.next();
- if (o != null)
- arColl[curIndex++]= o;
- }
- int numNew = curIndex;
- ensureCapacity(size + numNew); // Increments modCount!!
-
- int numMoved = size - index;
- if (numMoved > 0)
- System.arraycopy(elementData, index, elementData, index + numNew,
- numMoved);
-
- for (int i=0; i<numNew; i++)
- {
- elementData[index++]= arColl[i];
- }
- size += numNew;
- ret= numNew != 0;
- }
- return ret;
- }
-
- /**
- * Removes all of the elements from this list. The list will
- * be empty after this call returns.
- */
- synchronized public void clear()
- {
- if (elementData != null)
- {
- // Let gc do its work
- for (int i = 0; i < size; i++)
- elementData[i] = null;
-
- size = 0;
- }
- }
- /**
- * Returns <tt>true</tt> if this list contains the specified element.
- *
- * @param elem element whose presence in this List is to be tested.
- */
- synchronized public boolean contains(Object elem)
- {
- return indexOf(elem) >= 0;
- }
-
- synchronized public boolean containsAll(Collection collection)
- {
- boolean retVal= true;
- if (elementData != null && collection != null)
- {
- Iterator it= collection.iterator();
- while (it.hasNext())
- {
- Object obj= it.next();
- if (false == contains(obj))
- {
- retVal= false;
- break;
- }
- }
- }
- return retVal;
- }
- /**
- * Returns the element at the specified position in this list.
- *
- * @param index index of element to return.
- * @return the element at the specified position in this list.
- * @throws IndexOutOfBoundsException if index is out of range <tt>(index
- * &lt; 0 || index &gt;= size())</tt>.
- */
- synchronized public Object get(int index)
- {
- if (elementData != null)
- {
- RangeCheck(index);
- return elementData[index];
- }
- return null;
- }
-
- /**
- * Searches for the first occurrence of the given argument, testing
- * for equality using the <tt>equals</tt> method.
- *
- * @param elem an object.
- * @return the index of the first occurrence of the argument in this
- * list; returns <tt>-1</tt> if the object is not found.
- * @see Object#equals(Object)
- */
- synchronized public int indexOf(Object elem)
- {
- int index= -1;
- if (elementData != null && elem != null)
- {
- for (int i = 0; i < size; i++)
- {
- if (elem == elementData[i])
- {
- index= i;
- break;
- }
- }
-
- if (index == -1)
- {
- for (int i = 0; i < size; i++)
- {
- if (UnoRuntime.areSame(elem, elementData[i]))
- {
- index= i;
- break;
- }
- }
- }
- }
- return index;
- }
- /**
- * Tests if this list has no elements.
- *
- * @return <tt>true</tt> if this list has no elements;
- * <tt>false</tt> otherwise.
- */
- synchronized public boolean isEmpty()
- {
- return size == 0;
- }
-
- synchronized public Iterator iterator()
- {
- if (elementData != null)
- {
- InterfaceContainer aCopy= (InterfaceContainer) clone();
- return new Itr(aCopy);
- }
- return null;
- }
- /**
- * Returns the index of the last occurrence of the specified object in
- * this list.
- *
- * @param elem the desired element.
- * @return the index of the last occurrence of the specified object in
- * this list; returns -1 if the object is not found.
- */
- synchronized public int lastIndexOf(Object elem)
- {
- int index= -1;
- if (elementData != null && elem != null)
- {
- for (int i = size-1; i >= 0; i--)
- {
- if (elem == elementData[i])
- {
- index= i;
- break;
- }
- }
- if (index == -1)
- {
- for (int i = size-1; i >= 0; i--)
- {
- if (UnoRuntime.areSame(elem, elementData[i]))
- {
- index= i;
- break;
- }
- }
- }
- }
- return index;
- }
-
- /**
- * Returns a shallow copy of this <tt>ArrayList</tt> instance. The contained
- * references are copied but the objects not.
- *
- * @return a clone of this <tt>List</tt> instance.
- */
- synchronized public Object clone()
- {
- Object ret= null;
- if (elementData != null)
- {
- InterfaceContainer cont= new InterfaceContainer();
- cont.elementData = new Object[size];
- cont.size= size;
- System.arraycopy(elementData, 0, cont.elementData, 0, size);
- ret= cont;
- }
- return ret;
- }
- synchronized public ListIterator listIterator()
- {
- return listIterator(0);
- }
-
- /** The iterator keeps a copy of the list. Changes to InterfaceContainer do not
- * affect the data of the iterator. Conversly, changes to the iterator are effect
- * InterfaceContainer.
- */
- synchronized public ListIterator listIterator(int index)
- {
- if (elementData != null)
- {
- InterfaceContainer aCopy= (InterfaceContainer) clone();
- return new LstItr(aCopy, index);
- }
- return null;
- }
- /**
- * Removes the element at the specified position in this list.
- * Shifts any subsequent elements to the left (subtracts one from their
- * indices).
- *
- * @param index the index of the element to removed.
- * @return the element that was removed from the list.
- * @throws IndexOutOfBoundsException if index out of range <tt>(index
- * &lt; 0 || index &gt;= size())</tt>.
- */
- synchronized public Object remove(int index)
- {
- Object ret= null;
- if (elementData != null)
- {
- RangeCheck(index);
- ret= elementData[index];
-
- int numMoved = size - index - 1;
- if (numMoved > 0)
- System.arraycopy(elementData, index+1, elementData, index,
- numMoved);
- elementData[--size] = null; // Let gc do its work
- }
- return ret;
- }
-
-
- /** Parameter obj may */
- synchronized public boolean remove(Object obj)
- {
- boolean ret= false;
- if (elementData != null && obj != null)
- {
- int index= indexOf(obj);
- if (index != -1)
- {
- ret= true;
- remove(index);
- }
- }
- return ret;
- }
-
- synchronized public boolean removeAll(Collection collection)
- {
- boolean retVal= false;
- if (elementData != null && collection != null)
- {
- Iterator it= collection.iterator();
- while (it.hasNext())
- {
- Object obj= it.next();
- boolean bMod= remove( obj);
- if (bMod)
- retVal= true;
- }
- }
- return retVal;
- }
-
- synchronized public boolean retainAll(Collection collection)
- {
- boolean retVal= false;
- if (elementData != null && collection != null)
- {
- // iterate over data
- Object[] arRetained= new Object[size];
- int indexRetained= 0;
- for(int i= 0; i < size; i++)
- {
- Object curElem= elementData[i];
- // try to find the element in collection
- Iterator itColl= collection.iterator();
- boolean bExists= false;
- while (itColl.hasNext())
- {
- if (curElem == itColl.next())
- {
- // current element is in collection
- bExists= true;
- break;
- }
- }
- if (bExists == false)
- {
- itColl= collection.iterator();
- while (itColl.hasNext())
- {
- Object o= itColl.next();
- if (o != null)
- {
- if (UnoRuntime.areSame(o, curElem))
- {
- bExists= true;
- break;
- }
- }
- }
- }
- if (bExists == true)
- arRetained[indexRetained++]= curElem;
- }
- retVal= size != indexRetained;
- if (indexRetained > 0)
- {
- elementData= arRetained;
- size= indexRetained;
- }
- }
- return retVal;
- }
-
-
- /** Not supported.
- * @param index index of element to replace.
- * @param element element to be stored at the specified position.
- * @return the element previously at the specified position.
- * @throws IndexOutOfBoundsException if index out of range
- * <tt>(index &lt; 0 || index &gt;= size())</tt>.
- */
- synchronized public Object set(int index, Object element)
- {
- Object ret= null;
- if (elementData != null && element != null)
- {
- RangeCheck(index);
- ret = elementData[index];
- elementData[index] = element;
- }
- return ret;
- }
-
- /**
- * Returns the number of elements in this list.
- *
- * @return the number of elements in this list.
- */
- synchronized public int size()
- {
- if (elementData != null)
- return size;
- return 0;
- }
-
-
- /**
- * Returns an array containing all of the elements in this list
- * in the correct order.
- *
- * @return an array containing all of the elements in this list
- * in the correct order.
- */
- synchronized public Object[] toArray()
- {
- if (elementData != null)
- {
- Object[] result = new Object[size];
- System.arraycopy(elementData, 0, result, 0, size);
- return result;
- }
- return null;
- }
-
- /**
- * Returns an array containing all of the elements in this list in the
- * correct order. The runtime type of the returned array is that of the
- * specified array. If the list fits in the specified array, it is
- * returned therein. Otherwise, a new array is allocated with the runtime
- * type of the specified array and the size of this list.<p>
- *
- * If the list fits in the specified array with room to spare (i.e., the
- * array has more elements than the list), the element in the array
- * immediately following the end of the collection is set to
- * <tt>null</tt>. This is useful in determining the length of the list
- * <i>only</i> if the caller knows that the list does not contain any
- * <tt>null</tt> elements.
- *
- * @param a the array into which the elements of the list are to
- * be stored, if it is big enough; otherwise, a new array of the
- * same runtime type is allocated for this purpose.
- * @return an array containing the elements of the list.
- * @throws ArrayStoreException if the runtime type of a is not a supertype
- * of the runtime type of every element in this list.
- */
- synchronized public Object[] toArray(Object a[])
- {
- if (a.length < size)
- a = (Object[])java.lang.reflect.Array.newInstance(
- a.getClass().getComponentType(), size);
- if (elementData != null)
- System.arraycopy(elementData, 0, a, 0, size);
-
- if (a.length > size)
- a[size] = null;
-
- return a;
- }
-
- /**
- * Check if the given index is in range. If not, throw an appropriate
- * runtime exception.
- */
- private void RangeCheck(int index)
- {
- if (index >= size || index < 0)
- throw new IndexOutOfBoundsException(
- "Index: "+index+", Size: "+size);
- }
-
- public void disposeAndClear(EventObject evt)
- {
- Iterator aIt;
- synchronized (this)
- {
- aIt= iterator();
- // Container freigeben, falls im disposing neue Eintraege kommen
- // set the member to null, the iterator delete the values
- clear();
- elementData= null;
- size= 0;
- }
- if (aIt != null)
- {
- while( aIt.hasNext() )
- {
- try
- {
- Object o= aIt.next();
- XEventListener evtListener= UnoRuntime.queryInterface(
- XEventListener.class, o);
- if( evtListener != null )
- evtListener.disposing( evt );
- }
- catch ( RuntimeException e)
- {
- // be robust, if e.g. a remote bridge has disposed already.
- // there is no way, to delegate the error to the caller :o(.
- }
- }
- }
- }
-
-
- private class Itr implements Iterator
- {
- InterfaceContainer dataIt;
- /**
- * Index of element to be returned by subsequent call to next.
- */
- int cursor= 0;
- /**
- * Index of element returned by most recent call to next or
- * previous. Reset to -1 if this element is deleted by a call
- * to remove.
- */
- int lastRet = -1;
-
- /** The object that has been returned by most recent call to next
- * or previous. Reset to null if this element is deleted by a call
- * to remove.
- */
- Object lastRetObj= null;
-
- Itr(InterfaceContainer _data)
- {
- dataIt= _data;
- }
-
- synchronized public boolean hasNext()
- {
- return cursor !=dataIt.size();
- }
-
- public synchronized Object next()
- {
- try
- {
- Object next = dataIt.get(cursor);
- lastRet = cursor++;
- lastRetObj= next;
- return next;
- }
- catch(java.lang.IndexOutOfBoundsException e)
- {
- throw new java.util.NoSuchElementException();
- }
- }
-
- /** Removes the interface from the list, that has been last returned by a
- * call to next(). This is done according to the specification of the interface
- * method. The element is also removed from InterfaceContainer but independent
- * of the location. If the element is multiple times in InterfaceContainer then
- * it is up to the java.util.ArrayList implementation what element is removed.
- */
- public synchronized void remove()
- {
- if (lastRet == -1)
- throw new IllegalStateException();
- // Remove the entry from InterfaceContainer.
- InterfaceContainer.this.remove(lastRetObj);
- dataIt.remove(lastRet);
-
- if (lastRet < cursor)
- cursor--;
- lastRet = -1;
- lastRetObj= null;
- }
- }
-
- private class LstItr extends Itr implements ListIterator
- {
-
- LstItr(InterfaceContainer _data, int _index)
- {
- super(_data);
- cursor= _index;
- }
-
- /** Inserts an element to the iterators list according to the specification
- * of this interface method. The element is also added to InterfaceContainer
- * but its location within the list cannot be guaranteed.
- */
- public synchronized void add(Object o)
- {
- InterfaceContainer.this.add(o);
- dataIt.add(cursor++, o);
- lastRet = -1;
- lastRetObj= null;
- }
-
- synchronized public boolean hasPrevious()
- {
- return cursor != 0;
- }
-
- synchronized public int nextIndex()
- {
- return cursor;
- }
-
- public synchronized Object previous()
- {
- try
- {
- Object previous = dataIt.get(--cursor);
- lastRet = cursor;
- lastRetObj= previous;
- return previous;
- } catch(IndexOutOfBoundsException e)
- {
- throw new NoSuchElementException();
- }
- }
-
- synchronized public int previousIndex()
- {
- return cursor-1;
- }
-
- /** This is not possible since several iterators can modify InterfaceContainer
- */
- public synchronized void set(Object o)
- {
- throw new UnsupportedOperationException();
- }
-
-
- } // class LstItr
-}
-
diff --git a/javaunohelper/com/sun/star/lib/uno/helper/MultiTypeInterfaceContainer.java b/javaunohelper/com/sun/star/lib/uno/helper/MultiTypeInterfaceContainer.java
deleted file mode 100644
index e61362b2b..000000000
--- a/javaunohelper/com/sun/star/lib/uno/helper/MultiTypeInterfaceContainer.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-package com.sun.star.lib.uno.helper;
-import com.sun.star.uno.Type;
-import com.sun.star.lang.EventObject;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Iterator;
-
-public class MultiTypeInterfaceContainer
-{
-
- private Map map= new HashMap();
-
- /** Creates a new instance of MultiTypeInterfaceContainer */
- public MultiTypeInterfaceContainer()
- {
- }
-
- /** only returns types which have at least one value in InterfaceContainer
- * return value can contain an element null, if someone called
- * addInterface (null, interf)
- */
- synchronized public Type[] getContainedTypes()
- {
- int size;
- Type[] retVal= null;
-
- if ( (size=map.size()) > 0)
- {
- Type [] arTypes= new Type[size];
- Iterator it= map.keySet().iterator();
-
- int countTypes= 0;
- while (it.hasNext())
- {
- Object key= it.next();
- InterfaceContainer cont= (InterfaceContainer) map.get(key);
- if (cont != null && cont.size() > 0)
- {
- if (key == null)
- arTypes[countTypes++]= new Type();
- else if (key instanceof Type)
- arTypes[countTypes++]= (Type) key;
- else if (key instanceof Class)
- arTypes[countTypes++]= new Type((Class) key);
- else
- arTypes[countTypes++]= new Type(key.getClass());
- }
- }
-
- if (countTypes != size)
- {
- retVal= new Type[countTypes];
- System.arraycopy(arTypes, 0, retVal, 0, countTypes);
- }
- else
- retVal= arTypes;
- }
- if (retVal == null)
- retVal= new Type[0];
- return retVal;
- }
-
- /** param key can be null */
- synchronized public InterfaceContainer getContainer(Object key)
- {
- InterfaceContainer retVal= null;
- Iterator it= map.keySet().iterator();
- while (it.hasNext())
- {
- Object obj= it.next();
- if (obj == null && key == null)
- {
- retVal= (InterfaceContainer) map.get(null);
- break;
- }
- else if( obj != null && obj.equals(key))
- {
- retVal= (InterfaceContainer) map.get(obj);
- break;
- }
- }
- return retVal;
- }
-
-
- synchronized public int addInterface(Object ckey, Object iface)
- {
- //If the key is a Type then it does not matter if the objects are different
- // if they represent the same type. This is because Types overrides hashCode and
- // equals. For example:
- // Type a= new Type(XInterface.class);
- // Type b= new Type(XInterface.class);
- // Allthough a != b , the map interprets both as being the same.
- InterfaceContainer cont= (InterfaceContainer) map.get(ckey);
- if (cont != null)
- {
- cont.add(iface);
- }
- else
- {
- cont= new InterfaceContainer();
- cont.add(iface);
- map.put(ckey, cont);
- }
- return cont.size();
- }
-
-
- synchronized public int removeInterface(Object key, Object iface)
- {
- int retVal= 0;
- InterfaceContainer cont= (InterfaceContainer) map.get(key);
- if (cont != null)
- {
- cont.remove(iface);
- retVal= cont.size();
- }
- return retVal;
- }
-
- public void disposeAndClear(EventObject evt)
- {
- Iterator it= null;
- synchronized(this)
- {
- it= map.values().iterator();
- }
- while (it.hasNext() )
- ((InterfaceContainer) it.next()).disposeAndClear(evt);
- }
-
- synchronized public void clear()
- {
- Iterator it= map.values().iterator();
- while (it.hasNext())
- ((InterfaceContainer) it.next()).clear();
- }
-}
diff --git a/javaunohelper/com/sun/star/lib/uno/helper/PropertySet.java b/javaunohelper/com/sun/star/lib/uno/helper/PropertySet.java
deleted file mode 100644
index d50e6d837..000000000
--- a/javaunohelper/com/sun/star/lib/uno/helper/PropertySet.java
+++ /dev/null
@@ -1,1102 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-package com.sun.star.lib.uno.helper;
-
-import com.sun.star.uno.Type;
-import com.sun.star.lang.EventObject;
-import com.sun.star.lang.WrappedTargetException;
-import com.sun.star.uno.TypeClass;
-import com.sun.star.uno.AnyConverter;
-import com.sun.star.uno.XInterface;
-import com.sun.star.uno.Any;
-import com.sun.star.uno.UnoRuntime;
-import com.sun.star.beans.XPropertyChangeListener;
-import com.sun.star.beans.XVetoableChangeListener;
-import com.sun.star.beans.PropertyChangeEvent;
-import com.sun.star.beans.XPropertySet;
-import com.sun.star.beans.Property;
-import com.sun.star.beans.PropertyAttribute;
-import com.sun.star.beans.UnknownPropertyException;
-import com.sun.star.beans.XPropertiesChangeListener;
-import com.sun.star.beans.XPropertySetInfo;
-import com.sun.star.beans.XFastPropertySet;
-import com.sun.star.beans.PropertyVetoException;
-import com.sun.star.beans.XMultiPropertySet;
-import java.util.Iterator;
-import java.util.Collection;
-import java.util.HashMap;
-import java.lang.reflect.Field;
-import com.sun.star.lang.DisposedException;
-
-
-/** This class is an implementation of the interfaces com.sun.star.beans.XPropertySet,
- * com.sun.star.beans.XFastPropertySet and com.sun.star.beans.XMultiPropertySet. This
- * class has to be inherited to be used. The values of properties are stored in member
- * variables of the inheriting class. By overriding the methods
- * {@link #convertPropertyValue convertPropertyValue},
- * {@link #setPropertyValueNoBroadcast setPropertyValueNoBroadcast} and
- * {@link #getPropertyValue(Property)} one can determine how
- * property values are stored.
- * When using the supplied implementations of this class then the member variables which
- * hold property values have to be declared in the class which inherits last in the inheriting
- * chain and they have to be public<p>
- * Properties have to be registered by one of the registerProperty methods. They take among other
- * arguments an Object named <em>id</em> which has to be a String that represents the name of
- * the member variable. The registering has to occur in the constructor of the inheriting class.
- * It is no allowed to add or change properties later on.<p>
- * Example:
- * <pre>
- * public class Foo extends PropertySet
- * {
- * protected int intProp;
- *
- * public Foo()
- * {
- * registerProperty("PropertyA", 0, new Type(int.class), (short)0, "intProp");
- * }
- * }
- *
- * </pre>
- */
-public class PropertySet extends ComponentBase implements XPropertySet, XFastPropertySet,
-XMultiPropertySet
-{
- private HashMap _nameToPropertyMap;
- private HashMap _handleToPropertyMap;
- private HashMap _propertyToIdMap;
- private Property[] arProperties;
-
- private int lastHandle= 1;
-
- protected XPropertySetInfo propertySetInfo;
- protected MultiTypeInterfaceContainer aBoundLC= new MultiTypeInterfaceContainer();
- protected MultiTypeInterfaceContainer aVetoableLC= new MultiTypeInterfaceContainer();
- public PropertySet()
- {
- super();
- initMappings();
- }
-
- /** Registers a property with this helper class and associates the argument <em>id</em> with it.
- * <em>id</em> is used to identify the storage of the property value. How property values are stored
- * and retrieved is determined by the methods {@link #convertPropertyValue convertPropertyValue},
- * {@link #setPropertyValueNoBroadcast setPropertyValueNoBroadcast} and {@link #getPropertyValue(Property) getPropertyValue}
- * These methods expect <em>id</em> to be a java.lang.String which represents the name of a member variable
- * which holds the property value.
- * Only properties which are registered can be accessed. Registration has to occur during
- * initialization of the inheriting class (i.e. within the contructor).
- * @param prop The property to be registered.
- * @param id Identifies the properties storage.
- * @see #getPropertyId
- */
- protected void registerProperty(Property prop, Object id)
- {
- putProperty(prop);
- assignPropertyId(prop, id);
- }
-
- /** Registers a property with this helper class and associates the argument id with it.
- * It does the same as {@link #registerProperty(Property, Object)}. The first four
- * arguments are used to construct a Property object.
- * Registration has to occur during
- * initialization of the inheriting class (i.e. within the contructor)
- * @param name The property's name (Property.Name).
- * @param handle The property's handle (Property.Handle).
- * @param Type The property's type (Property.Type).
- * @param attributes The property's attributes (Property.Attributes).
- * @param id Identifies the property's storage.
- */
- protected void registerProperty(String name, int handle, Type type, short attributes, Object id)
- {
- Property p= new Property(name, handle, type, attributes);
- registerProperty(p, id);
- }
-
- /** Registers a property with this class and associates the argument id with it.
- * It does the same as {@link #registerProperty(Property, Object)}. The first three
- * arguments are used to construct a Property object. The value for the Property.Handle
- * is generated and does not have to be specified here. Use this method for registering
- * a property if you do not care about the Property's handles.
- * Registration has to occur during
- * initialization of the inheriting class (i.e. within the contructor).
- * @param name The property's name (Property.Name).
- * @param handle The property's handle (Property.Handle).
- * @param Type The property's type (Property.Type).
- * @param attributes The property's attributes (Property.Attributes).
- * @param id Identifies the property's storage.
- */
- protected void registerProperty(String name, Type type, short attributes, Object id)
- {
- Property p= new Property(name, lastHandle++, type, attributes);
- registerProperty(p, id);
- }
-
- /** Registers a property with this class. This method expects that property values
- * are stored in member variables as is the case if the methods convertPropertyValue,
- * setPropertyValueNoBroadcast and getPropertyValue(Property) are not overridden.
- * It is presumed that the type of the member variable
- * corresponds Property.Type. For example, if the TypeClass of Property.Type is to be
- * a TypeClass.SHORT then the member must be a short or java.lang.Short.
- * The handle for the property is generated.<br>
- * If there is no member with the specified name or if the member has an incompatible type
- * then a com.sun.star.uno.RuntimeException is thrown.
- * @param propertyName The name of the property.
- * @param memberName The name of the member variable that holds the value of the property.
- * @param attributes The property attributes.
- */
- protected void registerProperty(String propertyName, String memberName, short attributes)
- {
- Field propField= null;
- try
- {
- propField= getClass().getDeclaredField(memberName);
- }
- catch (NoSuchFieldException e)
- {
- throw new com.sun.star.uno.RuntimeException("there is no member variable: " + memberName);
- }
- Class cl= propField.getType();
- Type t= new Type(cl);
- if (t.getTypeClass() != TypeClass.UNKNOWN)
- {
- Property p= new Property(propertyName, lastHandle++, t, attributes);
- registerProperty(p,memberName);
- }
- else
- throw new com.sun.star.uno.RuntimeException("the member has an unknown type: " + memberName);
- }
-
- /** Registers a property with this class.
- * It is presumed that the name of property is equal to the name of the member variable
- * that holds the property value.
- * @param propertyName The name of the property and the member variable that holds the property's value.
- * @param attributes The property attributes.
- * @see #registerProperty(String, String, short)
- */
- protected void registerProperty(String propertyName, short attributes)
- {
- registerProperty(propertyName, propertyName, attributes);
- }
-
-
-
- /** Returns the Property object for a given property name or null if that property does
- * not exists (i.e. it has not been registered). Override this method
- * if you want to implement your own mapping from property names to Property objects.
- * Then you also have to override {@link #initMappings}, {@link #getProperties()} and
- * {@link #putProperty(Property)}.
- * @param propertyName The name of the property (Property.Name)
- * @return The Property object with the name <em>propertyName</em>.
- */
- protected Property getProperty(String propertyName)
- {
- return (Property) _nameToPropertyMap.get(propertyName);
- }
-
- /** Returns the Property object with a handle (Property.Handle) as specified by the argument
- * <em>nHandle</em>. The method returns null if there is no such property (i.e. it has not
- * been registered). Override this method if you want to implement your own mapping from handles
- * to Property objects. Then you also have to override {@link #initMappings}, {@link #putProperty(Property)}.
- * @param nHandle The handle of the property (Property.Handle).
- * @return The Property object with the handle <em>nHandle</em>
- */
- protected Property getPropertyByHandle(int nHandle)
- {
- return (Property) _handleToPropertyMap.get(new Integer(nHandle));
- }
-
- /** Returns an array of all Property objects or an array of length null if there
- * are no properties. Override this method if you want to implement your own mapping from names
- * to Property objects. Then you also have to override {@link #initMappings}, {@link #getProperty(String)} and
- * {@link #putProperty}.
- * @return Array of all Property objects.
- */
- protected Property[] getProperties()
- {
- if (arProperties == null)
- {
- Collection values= _nameToPropertyMap.values();
- arProperties= (Property[]) values.toArray(new Property[_nameToPropertyMap.size()]);
- }
- return arProperties;
- }
-
- /** Stores a Property object so that it can be retrieved subsequently by
- * {@link #getProperty(String)},{@link #getProperties()},{@link #getPropertyByHandle(int)}.
- * Override this method if you want to implement your own mapping from handles
- * to Property objects and names to Property objects. Then you also need to override {@link #initMappings},
- * {@link #getProperty(String)},{@link #getProperties()},{@link #getPropertyByHandle(int)}.
- * @param prop The Property object that is to be stored.
- */
- protected void putProperty(Property prop)
- {
- _nameToPropertyMap.put(prop.Name, prop);
- if (prop.Handle != -1)
- _handleToPropertyMap.put(new Integer(prop.Handle), prop);
- }
-
- /** Assigns an identifyer object to a Property object so that the identifyer
- * can be obtained by {@link #getPropertyId getPropertyId} later on. The identifyer
- * is used to specify a certain storage for the property's value. If you do not
- * override {@link #setPropertyValueNoBroadcast setPropertyValueNoBroadcast} or {@link #getPropertyValue(Property)}
- * then the argument <em>id</em> has to be a java.lang.String that equals the name of
- * the member variable that holds the Property's value.
- * Override this method if you want to implement your own mapping from Property objects to ids or
- * if you need ids of a type other then java.lang.String.
- * Then you also need to override {@link #initMappings initMappings} and {@link #getPropertyId getPropertyId}.
- * @param prop The Property object that is being assigned an id.
- * @param id The object which identifies the storage used for the property's value.
- * @see #registerProperty(Property, Object)
- */
- protected void assignPropertyId(Property prop, Object id)
- {
- if (id instanceof String && ((String) id).equals("") == false)
- _propertyToIdMap.put(prop, id);
- }
-
- /** Returns the identifyer object for a certain Property. The object must have been
- * previously assigned to the Property object by {@link #assignPropertyId assignPropertyId}.
- * Override this method if you want to implement your own mapping from Property objects to ids.
- * Then you also need to override {@link #initMappings initMappings} and {@link #assignPropertyId assignPropertyId}.
- * @param prop The property for which the id is to be retrieved.
- * @return The id object that identifies the storage used for the property's value.
- * @see #registerProperty(Property, Object)
- */
- protected Object getPropertyId(Property prop)
- {
- return _propertyToIdMap.get(prop);
- }
-
- /** Initializes data structures used for mappings of property names to property object,
- * property handles to property objects and property objects to id objects.
- * Override this method if you want to implement your own mappings. Then you also need to
- * override {@link #putProperty putProperty},{@link #getProperty getProperty}, {@link #getPropertyByHandle},
- * {@link #assignPropertyId assignPropertyId} and {@link #getPropertyId getPropertyId}.
- */
- protected void initMappings()
- {
- _nameToPropertyMap= new HashMap();
- _handleToPropertyMap= new HashMap();
- _propertyToIdMap= new HashMap();
- }
-
- /** Makes sure that listeners which are kept in aBoundLC (XPropertyChangeListener) and aVetoableLC
- * (XVetoableChangeListener) receive a disposing call. Also those listeners are relesased.
- */
- protected void postDisposing()
- {
- // Create an event with this as sender
- EventObject aEvt= new EventObject(this);
-
- // inform all listeners to reelease this object
- aBoundLC.disposeAndClear(aEvt);
- aVetoableLC.disposeAndClear(aEvt);
- }
-
- //XPropertySet ----------------------------------------------------
- synchronized public void addPropertyChangeListener(String str, XPropertyChangeListener xPropertyChangeListener)
- throws UnknownPropertyException, WrappedTargetException
- {
- // only add listeners if you are not disposed
- if (! bInDispose && ! bDisposed)
- {
- if (str.length() > 0)
- {
- Property prop= getProperty(str);
- if (prop == null)
- throw new UnknownPropertyException("Property " + str + " is unknown");
-
- // Add listener for a certain property
- if ((prop.Attributes & PropertyAttribute.BOUND) > 0)
- aBoundLC.addInterface(str, xPropertyChangeListener);
- else
- //ignore silently
- return;
- }
- else
- // Add listener for all properties
- listenerContainer.addInterface(XPropertyChangeListener.class, xPropertyChangeListener);
- }
- }
- //XPropertySet ----------------------------------------------------
- synchronized public void addVetoableChangeListener(String str, com.sun.star.beans.XVetoableChangeListener xVetoableChangeListener) throws com.sun.star.beans.UnknownPropertyException, com.sun.star.lang.WrappedTargetException
- {
- // only add listeners if you are not disposed
- if (! bInDispose && ! bDisposed)
- {
- if (str.length() > 0)
- {
- Property prop= getProperty(str);
- if (prop == null)
- throw new UnknownPropertyException("Property " + str + " is unknown");
-
- // Add listener for a certain property
- if ((prop.Attributes & PropertyAttribute.CONSTRAINED) > 0)
- aVetoableLC.addInterface(str, xVetoableChangeListener);
- else
- //ignore silently
- return;
- }
- else
- // Add listener for all properties
- listenerContainer.addInterface(XVetoableChangeListener.class, xVetoableChangeListener);
- }
- }
- //XPropertySet ----------------------------------------------------
- public com.sun.star.beans.XPropertySetInfo getPropertySetInfo()
- {
- if (propertySetInfo == null)
- {
- synchronized (this)
- {
- if (propertySetInfo == null)
- propertySetInfo= new PropertySetInfo();
- }
- }
- return propertySetInfo;
- }
- //XPropertySet ----------------------------------------------------
- public Object getPropertyValue(String name) throws UnknownPropertyException, WrappedTargetException
- {
- Object ret= null;
- if (bInDispose || bDisposed)
- throw new com.sun.star.lang.DisposedException("The component has been disposed already");
-
- Property prop= getProperty(name);
- if (prop == null)
- throw new UnknownPropertyException("The property " + name + " is unknown");
-
- synchronized (this)
- {
- ret= getPropertyValue(prop);
- }
- // null must not be returned. Either a void any is returned or an any containing
- // an interface type and a null reference.
- if (ret == null)
- {
- if (prop.Type.getTypeClass() == TypeClass.INTERFACE)
- ret= new Any(prop.Type, null);
- else
- ret= new Any(new Type(void.class), null);
- }
- return ret;
- }
-
- //XPropertySet ----------------------------------------------------
- synchronized public void removePropertyChangeListener(String propName, XPropertyChangeListener listener) throws UnknownPropertyException, WrappedTargetException
- { // all listeners are automaticly released in a dispose call
- if (!bInDispose && !bDisposed)
- {
- if (propName.length() > 0)
- {
- Property prop = getProperty(propName);
- if (prop == null)
- throw new UnknownPropertyException("Property " + propName + " is unknown");
- aBoundLC.removeInterface(propName, listener);
- }
- else
- listenerContainer.removeInterface(XPropertyChangeListener.class, listener);
- }
- }
-
- //XPropertySet ----------------------------------------------------
- synchronized public void removeVetoableChangeListener(String propName, XVetoableChangeListener listener) throws UnknownPropertyException, WrappedTargetException
- {// all listeners are automaticly released in a dispose call
- if (!bInDispose && !bDisposed)
- {
- if (propName.length() > 0)
- {
- Property prop = getProperty(propName);
- if (prop == null)
- throw new UnknownPropertyException("Property " + propName + " is unknown");
- aVetoableLC.removeInterface(propName, listener);
- }
- else
- listenerContainer.removeInterface(XVetoableChangeListener.class, listener);
- }
- }
-
- //XPropertySet ----------------------------------------------------
- /** Sets the value of a property.
- * The idl description for this interfaces, stipulates that the argument value is an Any. Since a java.lang.Object
- * reference has the same meaning as an Any this function accepts
- * java anys (com.sun.star.uno.Any) and all other appropriate objects as arguments. The value argument can be one
- * of these:
- * <ul>
- * <li>java.lang.Boolean</li>
- * <li>java.lang.Character</li>
- * <li>java.lang.Byte</li>
- * <li>java.lang.Short</li>
- * <li>java.lang.Integer</li>
- * <li>java.lang.Long</li>
- * <li>java.lang.Float</li>
- * <li>java.lang.Double</li>
- * <li>java.lang.String</li>
- * <li>com.sun.star.uno.Type</li>
- * <li><em>objects which implement UNO interfaces</em></li>
- * <li><em>arrays which contain elements of the types above</em></li>
- * <li>com.sun.star.uno.Any containing an instance of one of the above types</li>
- * </ul>
- *
- * Properties can have the attribute com.sun.star.beans.PropertyAttribute.MAYBEVOID, which means that the value
- * (not the type) can be void. In order to assign a void value to a property one can either pass an Any which
- * contains a null reference or pass null directly. In bothe cases the null reference is only accepted if
- * the PropertyAttribute.MAYBEVOID attribute is set for the property.
- *
- * Properties which have the attribute MAYBEVOID set (Property.Attributes) can have a void value. The following
- * considerations presume that the Property has that attribute set. Further, when mentioning an Any's value we
- * actually refer to the object returned by Any.getObject.
- * If the argument <em>value</em> is null, or it is an Any whose value is null (but with a valid Type)
- * then the member variable used for storing the property's value is set to null.
- * Therefore those properties can only be stored in objects
- * and primitive types are not allowed (one can use the wrapper classes instead,e.g. java.lang.Byte) .
- * If a property's value is kept in a member variable of type Any and that reference is still null
- * then when setPropertyValue is called with
- * <em>value</em> = null then the member variable is assigned an Any with type void and a null value.
- * Or if the argument is an Any with a null value then it is assigned to the member variable.
- * Further, if the variable already
- * references an Any and setPropertyValue is called with <em>value</em> = null, then the variable is assigned
- * a new Any with the same type as the previously referenced Any and with a null value.
- * @param name The name of the property.
- * @param value The new value of the property.
- * * */
- public void setPropertyValue(String name, Object value) throws UnknownPropertyException,
- PropertyVetoException, com.sun.star.lang.IllegalArgumentException, WrappedTargetException
- {
- Property prop= getProperty(name);
- if (prop == null)
- throw new UnknownPropertyException("Property " + name + " is unknown");
- setPropertyValue(prop, value);
- }
-
- /** Sets the value of a property. It checks if the property's attributes (READONLY,MAYBEVOID), allow that the
- * new value can be set. It also causes the notification of listeners.
- * @param prop The property whose value is to be set.
- * @param value The new value for the property.
- */
- protected void setPropertyValue(Property prop, Object value) throws UnknownPropertyException,
- PropertyVetoException, com.sun.star.lang.IllegalArgumentException, WrappedTargetException
- {
- if ((prop.Attributes & PropertyAttribute.READONLY) == PropertyAttribute.READONLY)
- throw new com.sun.star.beans.PropertyVetoException();
- // The value may be null only if MAYBEVOID attribute is set
- boolean bVoidValue= false;
- if (value instanceof Any)
- bVoidValue= ((Any) value).getObject() == null;
- else
- bVoidValue= value == null;
- if (bVoidValue && (prop.Attributes & PropertyAttribute.MAYBEVOID) == 0)
- throw new com.sun.star.lang.IllegalArgumentException("The property must have a value; the MAYBEVOID attribute is not set!");
- if (bInDispose || bDisposed)
- throw new DisposedException("Component is already disposed");
-
- //Check if the argument is allowed
- boolean bValueOk= false;
- if (value instanceof Any)
- bValueOk= checkType(((Any) value).getObject());
- else
- bValueOk= checkType(value);
- if (! bValueOk)
- throw new com.sun.star.lang.IllegalArgumentException("No valid UNO type");
-
-
- boolean bConversionOk= false;
- Object[] outConvertedVal= new Object[1];
- Object[] outOldValue= new Object[1];
- synchronized (this)
- {
- bConversionOk= convertPropertyValue(prop, outConvertedVal, outOldValue, value);
- }
-
- //The next step following the conversion is to set the new value of the property. Prior to this
- // the XVetoableChangeListener s have to be notified.
- if (bConversionOk)
- {
- // If the property is CONSTRAINED, then we must notify XVetoableChangeListener. The listener can throw a com.sun.star.lang.beans.PropertyVetoException which
- // will cause this method to return (the exception is not caught here).
- fire( new Property[]{prop}, outConvertedVal, outOldValue, true);
-
- synchronized (this)
- {
- setPropertyValueNoBroadcast(prop, outConvertedVal[0]);
- }
- // fire a change event (XPropertyChangeListener, PropertyAttribute.BOUND
- fire( new Property[]{prop}, outConvertedVal, outOldValue, false);
- }
- }
-
- /** Converts a value in a way so that it is appropriate for storing as a property value, that is
- * {@link #setPropertyValueNoBroadcast setPropertyValueNoBroadcast} can process the value without any further
- * conversion. This implementation presumes that
- * the values are stored in member variables of the furthest inheriting class. For example,
- * class A inherits this class then members of class A
- * can hold property values. If there is a class B which inherits A then only members of B can hold
- * property values. The variables must be public. A property must have been registered (e.g. by
- * {@link #registerProperty(Property, Object)} in order for this method to work. The identifyer argument (type Object)
- * used in the registerProperty methods must
- * be a java.lang.String, which is, the name of the member variable that holds the property value.
- * If one opts to store values differently then one may override
- * this method, as well as {@link #setPropertyValueNoBroadcast setPropertyValueNoBroadcast} and
- * {@link #getPropertyValue(Property) getPropertyValue(Property)}.
- * This method is always called as a result of a call to one of the setter methods, such as
- * {@link #setPropertyValue(String,Object) XPropertySet.setPropertyValue},
- * {@link #setFastPropertyValue XFastPropertySet.setFastPropertyValue}
- * and {@link #setPropertyValues XMultiPropertySet.setPropertyValues}.
- * If this method fails, that is, it returns false or throws an exception, then no listeners are notified and the
- * property value, that was intended to be changed, remains untouched.<br /> This method does not have to deal with property attributes, such as
- * PropertyAttribute.READONLY or PropertyAttribute.MAYBEVOID. The processing of these attributes occurs
- * in the calling methods.<br />
- * Only if this method returns successfully further processing, such
- * as listener notification and finally the modifiction of the property's value, will occur.<br />
- *
- * The actual modification of a property's value is done by {@link #setPropertyValueNoBroadcast setPropertyValueNoBroadcast}
- * which is called subsequent to convertPropertyValue.
- *<p>
- * This method converts values by help of the com.sun.star.uno.AnyConverter which only does a few widening
- * conversions on integer types and floating point types. For example, there is the property PropA with a Type equivalent
- * to int.class and the
- * value of the property is to be stored in a member variable of type int with name intProp. Then setPropertyValue is
- * called:
- * <pre>
- * set.setPropertyValue( "PropA", new Byte( (byte)111));
- * </pre>
- * At some point setPropertyValue will call convertPropertyValue and pass in the Byte object. Since we allow
- * that Byte values can be used with the property and know that the value is to be stored in intProp (type int)
- * we convert the Byte object into an Integer object which is then returned in the out-parameter <em>newVal</em>. This
- * conversion is actually performed by the AnyConverter. Later
- * the setPropertyValueNoBroadcast is called with that Integer object and the int value can be easily extracted
- * from the object and be assigned to the member intProp.
- * <p>
- * The method handles Any arguments the same as Object arguments. That is, the <em>setVal</em> argument can
- * be a java.lang.Boolean or a com.sun.star.uno.Any containing a java.lang.Boolean. Likewise, a member
- * containing a property value can be a com.sun.star.uno.Any or an java.lang.Object.
- * Then, no conversion is necessary, since they can hold all possible values. However, if
- * the member is an Object and <em>setVal</em> is an Any then the object contained in the any is assigned to
- * the member. The extra type information which exists as Type object in the Any will get lost. If this is not
- * intended then use an Any variable rather then an Object.<br />
- * If a member is an Object or Any and the argument <em>setVal</em> is an Object, other than String or array,
- * then it is presumed to be an UNO object and queried for XInterface. If successful, the out-param <em>newVal</em>
- * returns the XInterface.<br />
- * If a member is an UNO interface, then <em>setVal</em> is queried for this interface and the result is returned.
- * If <em>setVal</em> is null then <em>newVal</em> will be null too after return.
- * <p>
- * If a property value is stored using a primitive type the the out-parameters
- * <em>curVal</em> and <em>newVal</em> contain the respective wrapper class (e.g.java.lang.Byte, etc.).
- * curVal is used in calls to the XVetoableChangeListener and XPropertyChangeListener.
- *
- * @param property - in-param property for which the data is to be converted.
- * @param newVal - out-param which contains the converted value on return.
- * @param curVal - out-param the current value of the property. It is used in calls to the
- * XVetoableChangeListener and XPropertyChangeListener.
- * @param setVal - in-param. The value that is to be converted so that it matches Property and the internally used
- * dataformat for that property.
- * @return true - Conversion was successful. <em>newVal</em> contains a valid value for the property. false -
- * conversion failed for some reason.
- * @throws com.sun.star.lang.IllegalArgumentException The value provided is unfit for the property.
- * @throws com.sun.star.lang.WrappedTargetException - An exception occurred during the conversion, that is to be made known
- * to the caller.
- */
- protected boolean convertPropertyValue(Property property, Object[] newVal, Object[]curVal, Object setVal)
- throws com.sun.star.lang.IllegalArgumentException, WrappedTargetException, UnknownPropertyException
- {
- boolean ret= true;
- try
- {
- // get the member name
- String sMember= (String) getPropertyId(property);
- if (sMember != null)
- {
- // use reflection to obtain the field that holds the property value
- // Class.getDeclaredFields does not return inherited fields. One could use Class.getFields to
- // also get inherited fields, but only those which are public.
- Field propField= getClass().getDeclaredField(sMember);
- if (propField != null)
- {
- curVal[0]= propField.get(this);
- Class memberClass= propField.getType();
-
- // MAYBEVOID: if setVal == null or it is an Any and getObject returns null, then a void value is to be set
- // This works only if there are no primitive types. For those we use the respective wrapper classes.
- // In this implementation, a null reference means void value.
- boolean bVoidValue= false;
- boolean bAnyVal= setVal instanceof Any;
- if (bAnyVal)
- bVoidValue= ((Any) setVal).getObject() == null;
- else
- bVoidValue= setVal == null;
- if (bVoidValue && memberClass.isPrimitive())
- throw new com.sun.star.lang.IllegalArgumentException("The implementation does not support the MAYBEVOID attribute for this property");
-
- Object convObj= null;
- //The member that keeps the value of the Property is an Any. It can contain all possible
- //types, therefore a conversion is not necessary.
- if (memberClass.equals(Any.class))
- {
- if (bAnyVal)
- //parameter setVal is also an Any and can be used without further processing
- convObj= setVal;
- else
- {
- // Parameter setVal is not an Any. We need to construct an Any that contains
- // the argument setVal.
- // If setVal is an interface implementation then, we cannot constuct the
- // Any with setVal.getClass(), because the Any.Type._typeClass would be TypeClass.UNKNOWN.
- // We try to get an XInterface of setVal and set an XInterface type.
- if (setVal instanceof XInterface)
- {
- XInterface xint= UnoRuntime.queryInterface(XInterface.class, setVal);
- if (xint != null)
- convObj= new Any(new Type(XInterface.class), xint);
- }
- // The member is an any, and the past in argument was null reference (MAYBEVOID is set)
- else if (setVal == null)
- {
- // if the any member is still null we create a void any
- if (curVal[0] == null)
- convObj= new Any(new Type(), null);
- else
- {
- //otherwise we create an Any with the same type as a value of null;
- convObj= new Any( ((Any)curVal[0]).getType(), null);
- }
- }
- else
- convObj= new Any(new Type(setVal.getClass()), setVal);
- }
- }
- else
- convObj= convert(memberClass, setVal);
- newVal[0]= convObj;
- }
- }
- else
- throw new UnknownPropertyException("Property " + property.Name + " is unknown");
- }
- catch (java.lang.NoSuchFieldException e)
- {
- throw new WrappedTargetException("Field does not exist", this, e);
- }
- catch (java.lang.IllegalAccessException e)
- {
- throw new WrappedTargetException("", this ,e);
- }
- return ret;
- }
-
- private boolean checkType(Object obj)
- {
- if (obj == null
- || obj instanceof Boolean
- || obj instanceof Character
- || obj instanceof Number
- || obj instanceof String
- || obj instanceof XInterface
- || obj instanceof Type
- || obj instanceof com.sun.star.uno.Enum
- || obj.getClass().isArray())
- return true;
- return false;
- }
-
- // Param object can be an Any or other object. If obj is null then the return value is null
- private Object convert( Class cl, Object obj) throws com.sun.star.lang.IllegalArgumentException
- {
- Object retVal= null;
- //The member that keeps the value of the Property is an Object.Objects are similar to Anys in that they can
- // hold all types.
- if (obj == null || (obj instanceof Any && ((Any) obj).getObject() == null))
- retVal= null;
- else if(cl.equals(Object.class))
- {
- if (obj instanceof Any)
- obj= ((Any) obj).getObject();
- retVal= obj;
- }
- else if(cl.equals(boolean.class))
- retVal= new Boolean(AnyConverter.toBoolean(obj));
- else if (cl.equals(char.class))
- retVal= new Character(AnyConverter.toChar(obj));
- else if (cl.equals(byte.class))
- retVal= new Byte(AnyConverter.toByte(obj));
- else if (cl.equals(short.class))
- retVal= new Short(AnyConverter.toShort(obj));
- else if (cl.equals(int.class))
- retVal= new Integer(AnyConverter.toInt(obj));
- else if (cl.equals(long.class))
- retVal= new Long(AnyConverter.toLong(obj));
- else if (cl.equals(float.class))
- retVal= new Float(AnyConverter.toFloat(obj));
- else if (cl.equals(double.class))
- retVal= new Double(AnyConverter.toDouble(obj));
- else if (cl.equals(String.class))
- retVal= AnyConverter.toString(obj);
- else if (cl.isArray())
- retVal= AnyConverter.toArray(obj);
- else if (cl.equals(Type.class))
- retVal= AnyConverter.toType(obj);
- else if (cl.equals(Boolean.class))
- retVal= new Boolean(AnyConverter.toBoolean(obj));
- else if (cl.equals(Character.class))
- retVal= new Character(AnyConverter.toChar(obj));
- else if (cl.equals(Byte.class))
- retVal= new Byte(AnyConverter.toByte(obj));
- else if (cl.equals(Short.class))
- retVal= new Short(AnyConverter.toShort(obj));
- else if (cl.equals(Integer.class))
- retVal= new Integer(AnyConverter.toInt(obj));
- else if (cl.equals(Long.class))
- retVal= new Long(AnyConverter.toLong(obj));
- else if (cl.equals(Float.class))
- retVal= new Float(AnyConverter.toFloat(obj));
- else if (cl.equals(Double.class))
- retVal= new Double(AnyConverter.toDouble(obj));
- else if (XInterface.class.isAssignableFrom(cl))
- retVal= AnyConverter.toObject(new Type(cl), obj);
- else if (com.sun.star.uno.Enum.class.isAssignableFrom(cl))
- retVal= AnyConverter.toObject(new Type(cl), obj);
- else
- throw new com.sun.star.lang.IllegalArgumentException("Could not convert the argument");
- return retVal;
- }
-
- /** Sets the value of a property. In this implementation property values are stored in member variables
- * (see {@link #convertPropertyValue convertPropertyValue} Notification of property listeners
- * does not occur in this method. By overriding this method one can take full control about how property values
- * are stored. But then, the {@link #convertPropertyValue convertPropertyValue} and
- * {@link #getPropertyValue(Property)} must be overridden too.
- *
- * A Property with the MAYBEVOID attribute set, is stored as null value. Therefore the member variable must be
- * an Object in order to make use of the property attribute. An exception is Any. The Any variable can be initially null, but
- * once it is set the reference will not become null again. If the value is to be set to
- * void then a new Any will be stored
- * with a valid type but without a value (i.e. Any.getObject returns null).
- * If a property has the READONLY attribute set, and one of the setter methods, such as setPropertyValue, has been
- * called, then this method is not going to be called.
- * @param property the property for which the new value is set
- * @param value the new value for the property.
- * @throws com.sun.star.lang.WrappedTargetException An exception, which has to be made known to the caller,
- * occurred during the setting of the value.
- */
- protected void setPropertyValueNoBroadcast(Property property, Object newVal)
- throws WrappedTargetException
- {
- try
- {
- // get the member name
- String sMember= (String) getPropertyId(property);
- if (sMember != null)
- {
- // use reflection to obtain the field that holds the property value
- // Class.getDeclaredFields does not return inherited fields. One could use Class.getFields to
- // also get inherited fields, but only those which are public.
- Field propField= getClass().getDeclaredField(sMember);
- if (propField != null)
- propField.set(this, newVal);
- }
- }
- catch(java.lang.Exception e)
- {
- throw new WrappedTargetException("PropertySet.setPropertyValueNoBroadcast", this, e);
- }
- }
- /** Retrieves the value of a property. This implementation presumes that the values are stored in member variables
- * of the furthest inheriting class (see {@link #convertPropertyValue convertPropertyValue}) and that the
- * variables are public. The property must have
- * been registered, for example by {@link #registerProperty(Property, Object)}. The identifyer Object argument
- * must have been a java.lang.String which was the name of the member variable holding the property value.
- * When properties are to be stored differently one has to override this method as well as
- * {@link #convertPropertyValue} and {@link #setPropertyValueNoBroadcast}. <br>
- * If a value is stored in a variable of a primitive type then this method returns an instance of the respective
- * wrapper class (e.g. java.lang.Boolean).
- * @param property The property for which the value is to be retrieved.
- * @return The value of the property.
- */
- protected Object getPropertyValue(Property property)
- {
- Object ret= null;
- try
- {
- // get the member name
- String sMember= (String) getPropertyId(property);
- if (sMember != null)
- {
- // use reflection to obtain the field that holds the property value
- // Class.getDeclaredFields does not return inherited fields. One could use Class.getFields to
- // also get inherited fields, but only those which are public.
- Field propField= getClass().getDeclaredField(sMember);
- if (propField != null)
- ret= propField.get(this);
- }
- }
- catch(java.lang.NoSuchFieldException e)
- {
- throw new java.lang.RuntimeException(e);
- }
- catch(java.lang.IllegalAccessException e)
- {
- throw new java.lang.RuntimeException(e);
- }
- return ret;
- }
-
- /**
- * This method fires events to XPropertyChangeListener,XVetoableChangeListener and
- * XPropertiesChangeListener event sinks.
- * To distinguish what listeners are to be called the argument <em>bVetoable</em> is to be set to true if
- * a XVetoableChangeListener is meant. For XPropertyChangeListener and XPropertiesChangeListener
- * it is to be set to false.
- *
- * @param properties Properties wich will be or have been affected.
- * @param newValues the new values of the properties.
- * @param oldValues the old values of the properties.
- * @param bVetoable true means fire to VetoableChangeListener, false means fire to
- * XPropertyChangedListener and XMultiPropertyChangedListener.
- */
- protected void fire(
- Property[] properties,
- Object[] newValues,
- Object[] oldValues,
- boolean bVetoable ) throws PropertyVetoException
- {
- // Only fire, if one or more properties changed
- int nNumProps= properties.length;
- if (nNumProps > 0)
- {
- PropertyChangeEvent[] arEvts= new PropertyChangeEvent[nNumProps];
- int nAffectedProps= 0;
- // Loop over all changed properties to fill the event struct
- for (int i= 0; i < nNumProps; i++)
- {
- if ((bVetoable && (properties[i].Attributes & PropertyAttribute.CONSTRAINED) > 0)
- || (!bVetoable && (properties[i].Attributes & PropertyAttribute.BOUND) > 0))
- {
- arEvts[i]= new PropertyChangeEvent(this, properties[i].Name, false,
- properties[i].Handle, oldValues[i], newValues[i]);
- nAffectedProps++;
- }
- }
- // fire the events for all changed properties
- for (int i= 0; i < nAffectedProps; i++)
- {
- // get the listener container for the property name
- InterfaceContainer lc= null;
- if (bVetoable)
- lc= aVetoableLC.getContainer(arEvts[i].PropertyName);
- else
- lc= aBoundLC.getContainer(arEvts[i].PropertyName);
- if (lc != null)
- {
- Iterator it= lc.iterator();
- while( it.hasNext())
- {
- Object listener= it.next();
- if (bVetoable)
- ((XVetoableChangeListener) listener).vetoableChange(arEvts[i]);
- else
- ((XPropertyChangeListener) listener).propertyChange(arEvts[i]);
- }
- }
- // broadcast to all listeners with "" property name
- if(bVetoable)
- lc= listenerContainer.getContainer(XVetoableChangeListener.class);
- else
- lc= listenerContainer.getContainer(XPropertyChangeListener.class);
- if(lc != null)
- {
- Iterator it= lc.iterator();
- while(it.hasNext() )
- {
- Object listener= it.next();
- if( bVetoable ) // fire change Events?
- ((XVetoableChangeListener) listener).vetoableChange(arEvts[i]);
- else
- ((XPropertyChangeListener) listener).propertyChange(arEvts[i]);
- }
- }
- }
- // fire at XPropertiesChangeListeners
- // if nAffectedProps == 0 then there are no BOUND properties
- if (!bVetoable && nAffectedProps > 0)
- {
-
- PropertyChangeEvent[] arReduced= new PropertyChangeEvent[nAffectedProps];
- System.arraycopy(arEvts, 0, arReduced, 0, nAffectedProps);
- InterfaceContainer lc= listenerContainer.getContainer(XPropertiesChangeListener.class);
- if (lc != null)
- {
- Iterator it= lc.iterator();
- while (it.hasNext())
- {
- XPropertiesChangeListener listener = (XPropertiesChangeListener) it.next();
- // fire the hole event sequence to the XPropertiesChangeListener's
- listener.propertiesChange( arEvts );
- }
- }
- }
- }
- }
- // XFastPropertySet--------------------------------------------------------------------------------
- public void setFastPropertyValue(int nHandle, Object aValue ) throws UnknownPropertyException,
- PropertyVetoException, com.sun.star.lang.IllegalArgumentException, WrappedTargetException
- {
- Property prop= getPropertyByHandle(nHandle);
- if (prop == null)
- throw new UnknownPropertyException(" The property with handle : " + nHandle +" is unknown");
- setPropertyValue(prop, aValue);
- }
-
- // XFastPropertySet --------------------------------------------------------------------------------
- public Object getFastPropertyValue(int nHandle ) throws UnknownPropertyException,
- WrappedTargetException
- {
- Property prop= getPropertyByHandle(nHandle);
- if (prop == null)
- throw new UnknownPropertyException("The property with handle : " + nHandle + " is unknown");
- return getPropertyValue(prop);
- }
-
- // XMultiPropertySet -----------------------------------------------------------------------------------
- public void addPropertiesChangeListener(String[] propNames, XPropertiesChangeListener listener)
- {
- listenerContainer.addInterface(XPropertiesChangeListener.class, listener);
- }
-
- // XMultiPropertySet -----------------------------------------------------------------------------------
- public void firePropertiesChangeEvent(String[] propNames, XPropertiesChangeListener listener)
- {
- // Build the events.
- PropertyChangeEvent[] arEvents= new PropertyChangeEvent[propNames.length];
- int eventCount= 0;
- // get a snapshot of the current property values
- synchronized (this)
- {
- for (int i= 0; i < propNames.length; i++)
- {
- Property prop= getProperty(propNames[i]);
- if (prop != null)
- {
- Object value= null;
- try
- {
- value= getPropertyValue(prop);
- }
- catch(Exception e)
- {
- continue;
- }
- arEvents[eventCount]= new PropertyChangeEvent(this, prop.Name,
- false, prop.Handle, value, value);
- eventCount++;
- }
- }
- }
-
- // fire events from unsynchronized section so as to prevent deadlocks
- if (eventCount > 0)
- {
- // Reallocate the array of the events if necessary
- if (arEvents.length != eventCount)
- {
- PropertyChangeEvent[] arPropsTmp= new PropertyChangeEvent[eventCount];
- System.arraycopy(arEvents, 0, arPropsTmp, 0, eventCount);
- arEvents= arPropsTmp;
- }
- listener.propertiesChange(arEvents);
- }
- }
- // XMultiPropertySet -----------------------------------------------------------------------------------
- /** If a value for a property could not be retrieved then the respective element in the returned
- * array has the value null.
- */
- public Object[] getPropertyValues(String[] propNames)
- {
- Object[] arValues= new Object[propNames.length];
- synchronized (this)
- {
- for (int i= 0; i < propNames.length; i++)
- {
- Object value= null;
- try
- {
- value= getPropertyValue(propNames[i]);
- }
- catch (Exception e)
- {
- }
- arValues[i]= value;
- }
- }
- return arValues;
- }
- // XMultiPropertySet -----------------------------------------------------------------------------------
- public void removePropertiesChangeListener(XPropertiesChangeListener xPropertiesChangeListener)
- {
- listenerContainer.removeInterface(XPropertiesChangeListener.class, xPropertiesChangeListener);
- }
- // XMultiPropertySet -----------------------------------------------------------------------------------
- /** If the array of property names containes an unknown property then it will be ignored.
- */
- public void setPropertyValues(String[] propNames, Object[] values) throws PropertyVetoException, com.sun.star.lang.IllegalArgumentException, com.sun.star.lang.WrappedTargetException
- {
- for (int i= 0; i < propNames.length; i++)
- {
- try
- {
- setPropertyValue(propNames[i], values[i]);
- }
- catch (UnknownPropertyException e)
- {
- continue;
- }
-
- }
- }
-
- private class PropertySetInfo implements XPropertySetInfo
- {
- public com.sun.star.beans.Property[] getProperties()
- {
- return PropertySet.this.getProperties();
- }
-
- public com.sun.star.beans.Property getPropertyByName(String name) throws UnknownPropertyException
- {
- return getProperty(name);
- }
-
- public boolean hasPropertyByName(String name)
- {
- return getProperty(name) != null;
- }
-
- }
-}
-
-
-
-
-
diff --git a/javaunohelper/com/sun/star/lib/uno/helper/PropertySetMixin.java b/javaunohelper/com/sun/star/lib/uno/helper/PropertySetMixin.java
deleted file mode 100644
index 643cd43f1..000000000
--- a/javaunohelper/com/sun/star/lib/uno/helper/PropertySetMixin.java
+++ /dev/null
@@ -1,1093 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-package com.sun.star.lib.uno.helper;
-
-import com.sun.star.beans.Property;
-import com.sun.star.beans.PropertyAttribute;
-import com.sun.star.beans.PropertyChangeEvent;
-import com.sun.star.beans.PropertyState;
-import com.sun.star.beans.PropertyValue;
-import com.sun.star.beans.PropertyVetoException;
-import com.sun.star.beans.UnknownPropertyException;
-import com.sun.star.beans.XPropertyChangeListener;
-import com.sun.star.beans.XPropertySetInfo;
-import com.sun.star.beans.XVetoableChangeListener;
-import com.sun.star.container.NoSuchElementException;
-import com.sun.star.container.XHierarchicalNameAccess;
-import com.sun.star.lang.DisposedException;
-import com.sun.star.lang.EventObject;
-import com.sun.star.lang.WrappedTargetException;
-import com.sun.star.lang.WrappedTargetRuntimeException;
-import com.sun.star.lang.XComponent;
-import com.sun.star.reflection.XCompoundTypeDescription;
-import com.sun.star.reflection.XIdlClass;
-import com.sun.star.reflection.XIdlField2;
-import com.sun.star.reflection.XIdlReflection;
-import com.sun.star.reflection.XIndirectTypeDescription;
-import com.sun.star.reflection.XInterfaceAttributeTypeDescription2;
-import com.sun.star.reflection.XInterfaceMemberTypeDescription;
-import com.sun.star.reflection.XInterfaceTypeDescription2;
-import com.sun.star.reflection.XStructTypeDescription;
-import com.sun.star.reflection.XTypeDescription;
-import com.sun.star.uno.Any;
-import com.sun.star.uno.AnyConverter;
-import com.sun.star.uno.DeploymentException;
-import com.sun.star.uno.Type;
-import com.sun.star.uno.TypeClass;
-import com.sun.star.uno.UnoRuntime;
-import com.sun.star.uno.XComponentContext;
-import com.sun.star.uno.XInterface;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Vector;
-
-/**
- A helper mixin to implement certain UNO interfaces related to property set
- handling on top of the attributes of a given UNO interface type.
-
- <p>A client will mix in this class by keeping a reference to an instance of
- this class, and forwarding all methods of (a subset of the interfaces)
- <code>com.sun.star.beans.XPropertySet</code>,
- <code>com.sun.star.beans.XFastPropertySet</code>, and
- <code>com.sun.star.beans.XPropertyAccess</code> to it.</p>
-
- <p>Client code should not use the monitors associated with instances of this
- class, as they are used for internal purposes.</p>
-
- @since UDK 3.2
-*/
-public final class PropertySetMixin {
- /**
- The constructor.
-
- @param context the component context used by this instance; must not be
- null, and must supply the service
- <code>com.sun.star.reflection.CoreReflection</code> and the singleton
- <code>com.sun.star.reflection.theTypeDescriptionManager</code>
-
- @param object the client UNO object into which this instance is mixed in;
- must not be null, and must support the given <code>type</code>
-
- @param type the UNO interface type whose attributes are mapped to
- properties; must not be null, and must represent a UNO interface type
-
- @param absentOptional a list of optional properties that are not present,
- and should thus not be visible via
- <code>com.sun.star.beans.XPropertySet.getPropertySetInfo</code>,
- <code>com.sun.star.beans.XPropertySet.addPropertyChangeListener</code>,
- <code>com.sun.star.beans.XPropertySet.removePropertyChangeListener<!--
- --></code>,
- <code>com.sun.star.beans.XPropertySet.addVetoableChangeListener</code>,
- and <code>com.sun.star.beans.XPropertySet.<!--
- -->removeVetoableChangeListener</code>; null is treated the same as an
- empty list; if non-null, the given array must not be modified after it is
- passed to this constructor. For consistency reasons, the given
- <code>absentOptional</code> should only contain the names of attributes
- that represent optional properties that are not present (that is, the
- attribute getters and setters always throw a
- <code>com.sun.star.beans.UnknownPropertyException</code>), and should
- contain each such name only once. If an optional property is not present
- (that is, the corresponding attribute getter and setter always throw a
- <code>com.sun.star.beans.UnknownPropertyException</code>) but is not
- contained in the given <code>absentOptional</code>, then it will be
- visible via
- <code>com.sun.star.beans.XPropertySet.getPropertySetInfo</code> as a
- <code>com.sun.star.beans.Property</code> with a set
- <code>com.sun.star.beans.PropertyAttribute.OPTIONAL</code>. If the given
- <code>object</code> does not implement
- <code>com.sun.star.beans.XPropertySet</code>, then the given
- <code>absentOptional</code> is effectively ignored and can be null or
- empty.
- */
- public PropertySetMixin(
- XComponentContext context, XInterface object, Type type,
- String[] absentOptional)
- {
- // assert context != null && object != null && type != null
- // && type.getTypeClass() == TypeClass.INTERFACE;
- this.context = context;
- this.object = object;
- this.type = type;
- this.absentOptional = absentOptional;
- idlClass = getReflection(type.getTypeName());
- XTypeDescription ifc;
- try {
- ifc = UnoRuntime.queryInterface(
- XTypeDescription.class,
- (UnoRuntime.queryInterface(
- XHierarchicalNameAccess.class,
- context.getValueByName(
- "/singletons/com.sun.star.reflection."
- + "theTypeDescriptionManager")).
- getByHierarchicalName(type.getTypeName())));
- } catch (NoSuchElementException e) {
- throw new RuntimeException(
- "unexpected com.sun.star.container.NoSuchElementException: "
- + e.getMessage());
- }
- HashMap map = new HashMap();
- ArrayList handleNames = new ArrayList();
- initProperties(ifc, map, handleNames, new HashSet());
- properties = map;
- handleMap = (String[]) handleNames.toArray(
- new String[handleNames.size()]);
- }
-
- /**
- A method used by clients when implementing UNO interface type attribute
- setter functions.
-
- <p>First, this method checks whether this instance has already been
- disposed (see {@link #dispose}), and throws a
- <code>com.sun.star.beans.DisposedException</code> if applicable. For a
- constrained attribute (whose setter can explicitly raise
- <code>com.sun.star.beans.PropertyVetoException</code>), this method
- notifies any <code>com.sun.star.beans.XVetoableChangeListener</code>s.
- For a bound attribute, this method modifies the passed-in
- <code>bound</code> so that it can afterwards be used to notify any
- <code>com.sun.star.beans.XPropertyChangeListener</code>s. This method
- should be called before storing the new attribute value, and
- <code>bound.notifyListeners()</code> should be called exactly once after
- storing the new attribute value (in case the attribute is bound;
- otherwise, calling <code>bound.notifyListeners()</code> is ignored).
- Furthermore, <code>bound.notifyListeners()</code> and this method have to
- be called from the same thread.</p>
-
- @param propertyName the name of the property (which is the same as the
- name of the attribute that is going to be set)
-
- @param oldValue the property value corresponding to the old attribute
- value. This is only used as
- <code>com.sun.star.beans.PropertyChangeEvent.OldValue</code>, which is
- rather useless, anyway (see &ldquo;Using the Observer Pattern&rdquo; in
- <a href="http://tools.openoffice.org/CodingGuidelines.sxw">
- <cite>OpenOffice.org Coding Guidelines</cite></a>). If the attribute
- that is going to be set is neither bound nor constrained, or if
- <code>com.sun.star.beans.PropertyChangeEvent.OldValue</code> should not
- be set, {@link Any#VOID} can be used instead.
-
- @param newValue the property value corresponding to the new
- attribute value. This is only used as
- <code>com.sun.star.beans.PropertyChangeEvent.NewValue</code>, which is
- rather useless, anyway (see &ldquo;Using the Observer Pattern&rdquo: in
- <a href="http://tools.openoffice.org/CodingGuidelines.sxw">
- <cite>OpenOffice.org Coding Guidelines</cite></a>), <em>unless</em> the
- attribute that is going to be set is constrained. If the attribute
- that is going to be set is neither bound nor constrained, or if it is
- only bound but
- <code>com.sun.star.beans.PropertyChangeEvent.NewValue</code> should not
- be set, {@link Any#VOID} can be used instead.
-
- @param bound a reference to a fresh {@link BoundListeners} instance
- (which has not been passed to this method before, and on which
- {@link BoundListeners#notifyListeners} has not yet been called); may only
- be null if the attribute that is going to be set is not bound
- */
- public void prepareSet(
- String propertyName, Object oldValue, Object newValue,
- BoundListeners bound)
- throws PropertyVetoException
- {
- // assert properties.get(propertyName) != null;
- Property p = ((PropertyData) properties.get(propertyName)).property;
- Vector specificVeto = null;
- Vector unspecificVeto = null;
- synchronized (this) {
- if (disposed) {
- throw new DisposedException("disposed", object);
- }
- if ((p.Attributes & PropertyAttribute.CONSTRAINED) != 0) {
- Object o = vetoListeners.get(propertyName);
- if (o != null) {
- specificVeto = (Vector) ((Vector) o).clone();
- }
- o = vetoListeners.get("");
- if (o != null) {
- unspecificVeto = (Vector) ((Vector) o).clone();
- }
- }
- if ((p.Attributes & PropertyAttribute.BOUND) != 0) {
- // assert bound != null;
- Object o = boundListeners.get(propertyName);
- if (o != null) {
- bound.specificListeners = (Vector) ((Vector) o).clone();
- }
- o = boundListeners.get("");
- if (o != null) {
- bound.unspecificListeners = (Vector) ((Vector) o).clone();
- }
- }
- }
- if ((p.Attributes & PropertyAttribute.CONSTRAINED) != 0) {
- PropertyChangeEvent event = new PropertyChangeEvent(
- object, propertyName, false, p.Handle, oldValue, newValue);
- if (specificVeto != null) {
- for (Iterator i = specificVeto.iterator(); i.hasNext();) {
- try {
- ((XVetoableChangeListener) i.next()).vetoableChange(
- event);
- } catch (DisposedException e) {}
- }
- }
- if (unspecificVeto != null) {
- for (Iterator i = unspecificVeto.iterator(); i.hasNext();) {
- try {
- ((XVetoableChangeListener) i.next()).vetoableChange(
- event);
- } catch (DisposedException e) {}
- }
- }
- }
- if ((p.Attributes & PropertyAttribute.BOUND) != 0) {
- // assert bound != null;
- bound.event = new PropertyChangeEvent(
- object, propertyName, false, p.Handle, oldValue, newValue);
- }
- }
-
- /**
- A simplified version of {@link #prepareSet(String, Object, Object,
- PropertySetMixin.BoundListeners)}.
-
- <p>This method is useful for attributes that are not constrained.</p>
-
- @param propertyName the name of the property (which is the same as the
- name of the attribute that is going to be set)
-
- @param bound a reference to a fresh {@link BoundListeners} instance
- (which has not been passed to this method before, and on which
- {@link BoundListeners#notifyListeners} has not yet been called); may only
- be null if the attribute that is going to be set is not bound
- */
- public void prepareSet(String propertyName, BoundListeners bound) {
- try {
- prepareSet(propertyName, Any.VOID, Any.VOID, bound);
- } catch (PropertyVetoException e) {
- throw new RuntimeException("unexpected " + e);
- }
- }
-
- /**
- Marks this instance as being disposed.
-
- <p>See <code>com.sun.star.lang.XComponent</code> for the general concept
- of disposing UNO objects. On the first call to this method, all
- registered listeners
- (<code>com.sun.star.beans.XPropertyChangeListener</code>s and
- <code>com.sun.star.beans.XVetoableChangeListener</code>s) are notified of
- the disposing source. Any subsequent calls to this method are
- ignored.</p>
- */
- public void dispose() {
- HashMap bound;
- HashMap veto;
- synchronized (this) {
- bound = boundListeners;
- boundListeners = null;
- veto = vetoListeners;
- vetoListeners = null;
- disposed = true;
- }
- EventObject event = new EventObject(object);
- if (bound != null) {
- for (Iterator i = bound.values().iterator(); i.hasNext();) {
- for (Iterator j = ((Vector) i.next()).iterator(); j.hasNext();)
- {
- ((XPropertyChangeListener) j.next()).disposing(event);
- }
- }
- }
- if (veto != null) {
- for (Iterator i = veto.values().iterator(); i.hasNext();) {
- for (Iterator j = ((Vector) i.next()).iterator(); j.hasNext();)
- {
- ((XVetoableChangeListener) j.next()).disposing(event);
- }
- }
- }
- }
-
- /**
- Implements
- <code>com.sun.star.beans.XPropertySet.getPropertySetInfo</code>.
- */
- public XPropertySetInfo getPropertySetInfo() {
- return new Info(properties);
- }
-
- /**
- Implements <code>com.sun.star.beans.XPropertySet.setPropertyValue</code>.
- */
- public void setPropertyValue(String propertyName, Object value)
- throws UnknownPropertyException, PropertyVetoException,
- com.sun.star.lang.IllegalArgumentException, WrappedTargetException
- {
- setProperty(propertyName, value, false, false, (short) 1);
- }
-
- /**
- Implements <code>com.sun.star.beans.XPropertySet.getPropertyValue</code>.
- */
- public Object getPropertyValue(String propertyName)
- throws UnknownPropertyException, WrappedTargetException
- {
- return getProperty(propertyName, null);
- }
-
- /**
- Implements
- <code>com.sun.star.beans.XPropertySet.addPropertyChangeListener</code>.
-
- <p>If a listener is added more than once, it will receive all relevant
- notifications multiple times.</p>
- */
- public void addPropertyChangeListener(
- String propertyName, XPropertyChangeListener listener)
- throws UnknownPropertyException, WrappedTargetException
- {
- // assert listener != null;
- checkUnknown(propertyName);
- boolean disp;
- synchronized (this) {
- disp = disposed;
- if (!disp) {
- Vector v = (Vector) boundListeners.get(propertyName);
- if (v == null) {
- v = new Vector();
- boundListeners.put(propertyName, v);
- }
- v.add(listener);
- }
- }
- if (disp) {
- listener.disposing(new EventObject(object));
- }
- }
-
- /**
- Implements <code>
- com.sun.star.beans.XPropertySet.removePropertyChangeListener</code>.
- */
- public void removePropertyChangeListener(
- String propertyName, XPropertyChangeListener listener)
- throws UnknownPropertyException, WrappedTargetException
- {
- // assert listener != null;
- checkUnknown(propertyName);
- synchronized (this) {
- if (boundListeners != null) {
- Vector v = (Vector) boundListeners.get(propertyName);
- if (v != null) {
- v.remove(listener);
- }
- }
- }
- }
-
- /**
- Implements
- <code>com.sun.star.beans.XPropertySet.addVetoableChangeListener</code>.
-
- <p>If a listener is added more than once, it will receive all relevant
- notifications multiple times.</p>
- */
- public void addVetoableChangeListener(
- String propertyName, XVetoableChangeListener listener)
- throws UnknownPropertyException, WrappedTargetException
- {
- // assert listener != null;
- checkUnknown(propertyName);
- boolean disp;
- synchronized (this) {
- disp = disposed;
- if (!disp) {
- Vector v = (Vector) vetoListeners.get(propertyName);
- if (v == null) {
- v = new Vector();
- vetoListeners.put(propertyName, v);
- }
- v.add(listener);
- }
- }
- if (disp) {
- listener.disposing(new EventObject(object));
- }
- }
-
- /**
- Implements <code>
- com.sun.star.beans.XPropertySet.removeVetoableChangeListener</code>.
- */
- public void removeVetoableChangeListener(
- String propertyName, XVetoableChangeListener listener)
- throws UnknownPropertyException, WrappedTargetException
- {
- // assert listener != null;
- checkUnknown(propertyName);
- synchronized (this) {
- if (vetoListeners != null) {
- Vector v = (Vector) vetoListeners.get(propertyName);
- if (v != null) {
- v.remove(listener);
- }
- }
- }
- }
-
- /**
- Implements
- <code>com.sun.star.beans.XFastPropertySet.setFastPropertyValue</code>.
- */
- public void setFastPropertyValue(int handle, Object value)
- throws UnknownPropertyException, PropertyVetoException,
- com.sun.star.lang.IllegalArgumentException, WrappedTargetException
- {
- setProperty(translateHandle(handle), value, false, false, (short) 1);
- }
-
- /**
- Implements
- <code>com.sun.star.beans.XFastPropertySet.getFastPropertyValue</code>.
- */
- public Object getFastPropertyValue(int handle)
- throws UnknownPropertyException, WrappedTargetException
- {
- return getProperty(translateHandle(handle), null);
- }
-
- /**
- Implements
- <code>com.sun.star.beans.XPropertyAccess.getPropertyValues</code>.
- */
- public PropertyValue[] getPropertyValues() {
- PropertyValue[] s = new PropertyValue[handleMap.length];
- int n = 0;
- for (int i = 0; i < handleMap.length; ++i) {
- PropertyState[] state = new PropertyState[1];
- Object value;
- try {
- value = getProperty(handleMap[i], state);
- } catch (UnknownPropertyException e) {
- continue;
- } catch (WrappedTargetException e) {
- throw new WrappedTargetRuntimeException(
- e.getMessage(), object, e.TargetException);
- }
- s[n++] = new PropertyValue(handleMap[i], i, value, state[0]);
- }
- if (n < handleMap.length) {
- PropertyValue[] s2 = new PropertyValue[n];
- System.arraycopy(s, 0, s2, 0, n);
- s = s2;
- }
- return s;
- }
-
- /**
- Implements
- <code>com.sun.star.beans.XPropertyAccess.setPropertyValues</code>.
- */
- public void setPropertyValues(PropertyValue[] props)
- throws UnknownPropertyException, PropertyVetoException,
- com.sun.star.lang.IllegalArgumentException, WrappedTargetException
- {
- for (int i = 0; i < props.length; ++i) {
- if (props[i].Handle != -1
- && !props[i].Name.equals(translateHandle(props[i].Handle)))
- {
- throw new UnknownPropertyException(
- ("name " + props[i].Name + " does not match handle "
- + props[i].Handle),
- object);
- }
- setProperty(
- props[i].Name, props[i].Value,
- props[i].State == PropertyState.AMBIGUOUS_VALUE,
- props[i].State == PropertyState.DEFAULT_VALUE, (short) 0);
- }
- }
-
- /**
- A class used by clients of {@link PropertySetMixin} when implementing UNO
- interface type attribute setter functions.
-
- @see #prepareSet(String, Object, Object, PropertySetMixin.BoundListeners)
- */
- public static final class BoundListeners {
- /**
- The constructor.
- */
- public BoundListeners() {}
-
- /**
- Notifies any
- <code>com.sun.star.beans.XPropertyChangeListener</code>s.
-
- @see #prepareSet(String, Object, Object,
- PropertySetMixin.BoundListeners)
- */
- public void notifyListeners() {
- if (specificListeners != null) {
- for (Iterator i = specificListeners.iterator(); i.hasNext();) {
- try {
- ((XPropertyChangeListener) i.next()).propertyChange(
- event);
- } catch (DisposedException e) {}
- }
- }
- if (unspecificListeners != null) {
- for (Iterator i = unspecificListeners.iterator(); i.hasNext();)
- {
- try {
- ((XPropertyChangeListener) i.next()).propertyChange(
- event);
- } catch (DisposedException e) {}
- }
- }
- }
-
- private Vector specificListeners = null;
- private Vector unspecificListeners = null;
- private PropertyChangeEvent event = null;
- }
-
- private XIdlClass getReflection(String typeName) {
- XIdlReflection refl;
- try {
- refl = UnoRuntime.queryInterface(
- XIdlReflection.class,
- context.getServiceManager().createInstanceWithContext(
- "com.sun.star.reflection.CoreReflection", context));
- } catch (com.sun.star.uno.Exception e) {
- throw new DeploymentException(
- ("component context fails to supply service"
- + " com.sun.star.reflection.CoreReflection: "
- + e.getMessage()),
- context);
- }
- try {
- return refl.forName(typeName);
- } finally {
- XComponent comp = UnoRuntime.queryInterface(XComponent.class, refl);
- if (comp != null) {
- comp.dispose();
- }
- }
- }
-
- private void initProperties(
- XTypeDescription type, HashMap map, ArrayList handleNames, HashSet seen)
- {
- XInterfaceTypeDescription2 ifc = UnoRuntime.queryInterface(
- XInterfaceTypeDescription2.class, resolveTypedefs(type));
- if (seen.add(ifc.getName())) {
- XTypeDescription[] bases = ifc.getBaseTypes();
- for (int i = 0; i < bases.length; ++i) {
- initProperties(bases[i], map, handleNames, seen);
- }
- XInterfaceMemberTypeDescription[] members = ifc.getMembers();
- for (int i = 0; i < members.length; ++i) {
- if (members[i].getTypeClass() == TypeClass.INTERFACE_ATTRIBUTE)
- {
- XInterfaceAttributeTypeDescription2 attr =
- UnoRuntime.queryInterface(
- XInterfaceAttributeTypeDescription2.class,
- members[i]);
- short attrAttribs = 0;
- if (attr.isBound()) {
- attrAttribs |= PropertyAttribute.BOUND;
- }
- boolean setUnknown = false;
- if (attr.isReadOnly()) {
- attrAttribs |= PropertyAttribute.READONLY;
- setUnknown = true;
- }
- XCompoundTypeDescription[] excs = attr.getGetExceptions();
- boolean getUnknown = false;
- //XXX Special interpretation of getter/setter exceptions
- // only works if the specified exceptions are of the exact
- // type, not of a supertype:
- for (int j = 0; j < excs.length; ++j) {
- if (excs[j].getName().equals(
- "com.sun.star.beans.UnknownPropertyException"))
- {
- getUnknown = true;
- break;
- }
- }
- excs = attr.getSetExceptions();
- for (int j = 0; j < excs.length; ++j) {
- if (excs[j].getName().equals(
- "com.sun.star.beans.UnknownPropertyException"))
- {
- setUnknown = true;
- } else if (excs[j].getName().equals(
- "com.sun.star.beans."
- + "PropertyVetoException"))
- {
- attrAttribs |= PropertyAttribute.CONSTRAINED;
- }
- }
- if (getUnknown && setUnknown) {
- attrAttribs |= PropertyAttribute.OPTIONAL;
- }
- XTypeDescription t = attr.getType();
- for (;;) {
- t = resolveTypedefs(t);
- short n;
- if (t.getName().startsWith(
- "com.sun.star.beans.Ambiguous<"))
- {
- n = PropertyAttribute.MAYBEAMBIGUOUS;
- } else if (t.getName().startsWith(
- "com.sun.star.beans.Defaulted<"))
- {
- n = PropertyAttribute.MAYBEDEFAULT;
- } else if (t.getName().startsWith(
- "com.sun.star.beans.Optional<"))
- {
- n = PropertyAttribute.MAYBEVOID;
- } else {
- break;
- }
- attrAttribs |= n;
- t = (UnoRuntime.queryInterface(
- XStructTypeDescription.class, t)).
- getTypeArguments()[0];
- }
- String name = members[i].getMemberName();
- boolean present = true;
- if (absentOptional != null) {
- for (int j = 0; j < absentOptional.length; ++j) {
- if (name.equals(absentOptional[j])) {
- present = false;
- break;
- }
- }
- }
- if (map.put(
- name,
- new PropertyData(
- new Property(
- name, handleNames.size(),
- new Type(t.getName(), t.getTypeClass()),
- attrAttribs),
- present))
- != null)
- {
- throw new RuntimeException(
- "inconsistent UNO type registry");
- }
- handleNames.add(name);
- }
- }
- }
- }
-
- private String translateHandle(int handle) throws UnknownPropertyException {
- if (handle < 0 || handle >= handleMap.length) {
- throw new UnknownPropertyException("bad handle " + handle, object);
- }
- return handleMap[handle];
- }
-
- private void setProperty(
- String name, Object value, boolean isAmbiguous, boolean isDefaulted,
- short illegalArgumentPosition)
- throws UnknownPropertyException, PropertyVetoException,
- com.sun.star.lang.IllegalArgumentException, WrappedTargetException
- {
- PropertyData p = (PropertyData) properties.get(name);
- if (p == null) {
- throw new UnknownPropertyException(name, object);
- }
- if ((isAmbiguous
- && (p.property.Attributes & PropertyAttribute.MAYBEAMBIGUOUS) == 0)
- || (isDefaulted
- && ((p.property.Attributes & PropertyAttribute.MAYBEDEFAULT)
- == 0)))
- {
- throw new com.sun.star.lang.IllegalArgumentException(
- ("flagging as ambiguous/defaulted non-ambiguous/defaulted"
- + " property " + name),
- object, illegalArgumentPosition);
-
- }
- XIdlField2 f = UnoRuntime.queryInterface(
- XIdlField2.class, idlClass.getField(name));
- Object[] o = new Object[] {
- new Any(type, UnoRuntime.queryInterface(type, object)) };
- Object v = wrapValue(
- value,
- UnoRuntime.queryInterface(
- XIdlField2.class, idlClass.getField(name)).getType(),
- (p.property.Attributes & PropertyAttribute.MAYBEAMBIGUOUS) != 0,
- isAmbiguous,
- (p.property.Attributes & PropertyAttribute.MAYBEDEFAULT) != 0,
- isDefaulted,
- (p.property.Attributes & PropertyAttribute.MAYBEVOID) != 0);
- try {
- f.set(o, v);
- } catch (com.sun.star.lang.IllegalArgumentException e) {
- if (e.ArgumentPosition == 1) {
- throw new com.sun.star.lang.IllegalArgumentException(
- e.getMessage(), object, illegalArgumentPosition);
- } else {
- throw new RuntimeException(
- "unexpected com.sun.star.lang.IllegalArgumentException: "
- + e.getMessage());
- }
- } catch (com.sun.star.lang.IllegalAccessException e) {
- //TODO Clarify whether PropertyVetoException is the correct
- // exception to throw when trying to set a read-only property:
- throw new PropertyVetoException(
- "cannot set read-only property " + name, object);
- } catch (WrappedTargetRuntimeException e) {
- //FIXME A WrappedTargetRuntimeException from XIdlField2.get is not
- // guaranteed to originate directly within XIdlField2.get (and thus
- // have the expected semantics); it might also be passed through
- // from lower layers.
- if (new Type(UnknownPropertyException.class).isSupertypeOf(
- AnyConverter.getType(e.TargetException))
- && (p.property.Attributes & PropertyAttribute.OPTIONAL) != 0)
- {
- throw new UnknownPropertyException(name, object);
- } else if (new Type(PropertyVetoException.class).isSupertypeOf(
- AnyConverter.getType(e.TargetException))
- && ((p.property.Attributes
- & PropertyAttribute.CONSTRAINED)
- != 0))
- {
- throw new PropertyVetoException(name, object);
- } else {
- throw new WrappedTargetException(
- e.getMessage(), object, e.TargetException);
- }
- }
- }
-
- Object getProperty(String name, PropertyState[] state)
- throws UnknownPropertyException, WrappedTargetException
- {
- PropertyData p = (PropertyData) properties.get(name);
- if (p == null) {
- throw new UnknownPropertyException(name, object);
- }
- XIdlField2 field = UnoRuntime.queryInterface(
- XIdlField2.class, idlClass.getField(name));
- Object value;
- try {
- value = field.get(
- new Any(type, UnoRuntime.queryInterface(type, object)));
- } catch (com.sun.star.lang.IllegalArgumentException e) {
- throw new RuntimeException(
- "unexpected com.sun.star.lang.IllegalArgumentException: "
- + e.getMessage());
- } catch (WrappedTargetRuntimeException e) {
- //FIXME A WrappedTargetRuntimeException from XIdlField2.get is not
- // guaranteed to originate directly within XIdlField2.get (and thus
- // have the expected semantics); it might also be passed through
- // from lower layers.
- if (new Type(UnknownPropertyException.class).isSupertypeOf(
- AnyConverter.getType(e.TargetException))
- && (p.property.Attributes & PropertyAttribute.OPTIONAL) != 0)
- {
- throw new UnknownPropertyException(name, object);
- } else {
- throw new WrappedTargetException(
- e.getMessage(), object, e.TargetException);
- }
- }
- boolean undoAmbiguous
- = (p.property.Attributes & PropertyAttribute.MAYBEAMBIGUOUS) != 0;
- boolean undoDefaulted
- = (p.property.Attributes & PropertyAttribute.MAYBEDEFAULT) != 0;
- boolean undoOptional
- = (p.property.Attributes & PropertyAttribute.MAYBEVOID) != 0;
- boolean isAmbiguous = false;
- boolean isDefaulted = false;
- while (undoAmbiguous || undoDefaulted || undoOptional) {
- String typeName = AnyConverter.getType(value).getTypeName();
- if (undoAmbiguous
- && typeName.startsWith("com.sun.star.beans.Ambiguous<"))
- {
- XIdlClass ambiguous = getReflection(typeName);
- try {
- isAmbiguous = AnyConverter.toBoolean(
- UnoRuntime.queryInterface(
- XIdlField2.class,
- ambiguous.getField("IsAmbiguous")).get(value));
- value = UnoRuntime.queryInterface(
- XIdlField2.class,
- ambiguous.getField("Value")).get(value);
- } catch (com.sun.star.lang.IllegalArgumentException e) {
- throw new RuntimeException(
- "unexpected"
- + " com.sun.star.lang.IllegalArgumentException: "
- + e.getMessage());
- }
- undoAmbiguous = false;
- } else if (undoDefaulted
- && typeName.startsWith("com.sun.star.beans.Defaulted<"))
- {
- XIdlClass defaulted = getReflection(typeName);
- try {
- isDefaulted = AnyConverter.toBoolean(
- UnoRuntime.queryInterface(
- XIdlField2.class,
- defaulted.getField("IsDefaulted")).get(value));
- value = UnoRuntime.queryInterface(
- XIdlField2.class,
- defaulted.getField("Value")).get(value);
- } catch (com.sun.star.lang.IllegalArgumentException e) {
- throw new RuntimeException(
- "unexpected"
- + " com.sun.star.lang.IllegalArgumentException: "
- + e.getMessage());
- }
- undoDefaulted = false;
- } else if (undoOptional
- && typeName.startsWith("com.sun.star.beans.Optional<"))
- {
- XIdlClass optional = getReflection(typeName);
- try {
- boolean present = AnyConverter.toBoolean(
- UnoRuntime.queryInterface(
- XIdlField2.class,
- optional.getField("IsPresent")).get(value));
- if (!present) {
- value = Any.VOID;
- break;
- }
- value = UnoRuntime.queryInterface(
- XIdlField2.class,
- optional.getField("Value")).get(value);
- } catch (com.sun.star.lang.IllegalArgumentException e) {
- throw new RuntimeException(
- "unexpected"
- + " com.sun.star.lang.IllegalArgumentException: "
- + e.getMessage());
- }
- undoOptional = false;
- } else {
- throw new RuntimeException(
- "unexpected type of attribute " + name);
- }
- }
- if (state != null) {
- //XXX If isAmbiguous && isDefaulted, arbitrarily choose
- // AMBIGUOUS_VALUE over DEFAULT_VALUE:
- state[0] = isAmbiguous
- ? PropertyState.AMBIGUOUS_VALUE
- : isDefaulted
- ? PropertyState.DEFAULT_VALUE : PropertyState.DIRECT_VALUE;
- }
- return value;
- }
-
- private Object wrapValue(
- Object value, XIdlClass type, boolean wrapAmbiguous,
- boolean isAmbiguous, boolean wrapDefaulted, boolean isDefaulted,
- boolean wrapOptional)
- {
- // assert (wrapAmbiguous || !isAmbiguous)
- // && (wrapDefaulted || !isDefaulted);
- if (wrapAmbiguous
- && type.getName().startsWith("com.sun.star.beans.Ambiguous<"))
- {
- Object[] strct = new Object[1];
- type.createObject(strct);
- try {
- XIdlField2 field = UnoRuntime.queryInterface(
- XIdlField2.class, type.getField("Value"));
- field.set(
- strct,
- wrapValue(
- value, field.getType(), false, false, wrapDefaulted,
- isDefaulted, wrapOptional));
- UnoRuntime.queryInterface(
- XIdlField2.class, type.getField("IsAmbiguous")).set(
- strct, new Boolean(isAmbiguous));
- } catch (com.sun.star.lang.IllegalArgumentException e) {
- throw new RuntimeException(
- "unexpected com.sun.star.lang.IllegalArgumentException: "
- + e.getMessage());
- } catch (com.sun.star.lang.IllegalAccessException e) {
- throw new RuntimeException(
- "unexpected com.sun.star.lang.IllegalAccessException: "
- + e.getMessage());
- }
- return strct[0];
- } else if (wrapDefaulted
- && type.getName().startsWith(
- "com.sun.star.beans.Defaulted<"))
- {
- Object[] strct = new Object[1];
- type.createObject(strct);
- try {
- XIdlField2 field = UnoRuntime.queryInterface(
- XIdlField2.class, type.getField("Value"));
- field.set(
- strct,
- wrapValue(
- value, field.getType(), wrapAmbiguous, isAmbiguous,
- false, false, wrapOptional));
- UnoRuntime.queryInterface(
- XIdlField2.class, type.getField("IsDefaulted")).set(
- strct, new Boolean(isDefaulted));
- } catch (com.sun.star.lang.IllegalArgumentException e) {
- throw new RuntimeException(
- "unexpected com.sun.star.lang.IllegalArgumentException: "
- + e.getMessage());
- } catch (com.sun.star.lang.IllegalAccessException e) {
- throw new RuntimeException(
- "unexpected com.sun.star.lang.IllegalAccessException: "
- + e.getMessage());
- }
- return strct[0];
- } else if (wrapOptional
- && type.getName().startsWith("com.sun.star.beans.Optional<"))
- {
- Object[] strct = new Object[1];
- type.createObject(strct);
- boolean present = !AnyConverter.isVoid(value);
- try {
- UnoRuntime.queryInterface(
- XIdlField2.class, type.getField("IsPresent")).set(
- strct, new Boolean(present));
- if (present) {
- XIdlField2 field = UnoRuntime.queryInterface(
- XIdlField2.class, type.getField("Value"));
- field.set(
- strct,
- wrapValue(
- value, field.getType(), wrapAmbiguous, isAmbiguous,
- wrapDefaulted, isDefaulted, false));
- }
- } catch (com.sun.star.lang.IllegalArgumentException e) {
- throw new RuntimeException(
- "unexpected com.sun.star.lang.IllegalArgumentException: "
- + e.getMessage());
- } catch (com.sun.star.lang.IllegalAccessException e) {
- throw new RuntimeException(
- "unexpected com.sun.star.lang.IllegalAccessException: "
- + e.getMessage());
- }
- return strct[0];
- } else {
- if (wrapAmbiguous || wrapDefaulted || wrapOptional) {
- throw new RuntimeException("unexpected type of attribute");
- }
- return value;
- }
- }
-
- private static XTypeDescription resolveTypedefs(XTypeDescription type) {
- while (type.getTypeClass() == TypeClass.TYPEDEF) {
- type = UnoRuntime.queryInterface(
- XIndirectTypeDescription.class, type).getReferencedType();
- }
- return type;
- }
-
- private PropertyData get(Object object, String propertyName)
- throws UnknownPropertyException
- {
- PropertyData p = (PropertyData) properties.get(propertyName);
- if (p == null || !p.present) {
- throw new UnknownPropertyException(propertyName, object);
- }
- return p;
- }
-
- private void checkUnknown(String propertyName)
- throws UnknownPropertyException
- {
- if (!propertyName.equals("")) {
- get(this, propertyName);
- }
- }
-
- private static final class PropertyData {
- public PropertyData(Property property, boolean present) {
- this.property = property;
- this.present = present;
- }
-
- public final Property property;
- public final boolean present;
- }
-
- private final class Info extends WeakBase implements XPropertySetInfo
- {
- public Info(Map properties) {
- this.properties = properties;
- }
-
- public Property[] getProperties() {
- ArrayList al = new ArrayList(properties.size());
- for (Iterator i = properties.values().iterator(); i.hasNext();) {
- PropertyData p = (PropertyData) i.next();
- if (p.present) {
- al.add(p.property);
- }
- }
- return (Property[]) al.toArray(new Property[al.size()]);
- }
-
- public Property getPropertyByName(String name)
- throws UnknownPropertyException
- {
- return get(this, name).property;
- }
-
- public boolean hasPropertyByName(String name) {
- PropertyData p = (PropertyData) properties.get(name);
- return p != null && p.present;
- }
-
- private final Map properties; // from String to Property
- }
-
- private final XComponentContext context;
- private final XInterface object;
- private final Type type;
- private final String[] absentOptional;
- private final XIdlClass idlClass;
- private final Map properties; // from String to Property
- private final String[] handleMap;
-
- private HashMap boundListeners = new HashMap();
- // from String to Vector of XPropertyChangeListener
- private HashMap vetoListeners = new HashMap();
- // from String to Vector of XVetoableChangeListener
- private boolean disposed = false;
-}
diff --git a/javaunohelper/com/sun/star/lib/uno/helper/UnoUrl.java b/javaunohelper/com/sun/star/lib/uno/helper/UnoUrl.java
deleted file mode 100644
index a413ab43f..000000000
--- a/javaunohelper/com/sun/star/lib/uno/helper/UnoUrl.java
+++ /dev/null
@@ -1,412 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-package com.sun.star.lib.uno.helper;
-import java.io.UnsupportedEncodingException;
-import java.util.HashMap;
-import java.util.Vector;
-
-/**
- * Object representation and parsing of Uno Urls,
- * which allow to locate a named Uno object in a
- * different process. An Uno Url consists of the
- * specification of a connection, protocol and
- * rootOid delimited with a ';'.
- * The syntax of an Uno Url is
- *
- * <code>
- * [uno:]connection-type,parameters;protocol-name,parameters;objectname";
- * </code>
- *
- * An example Uno Url will look like this:
- *
- * <code>
- * socket,host=localhost,port=2002;urp;StarOffice.ServiceManager
- * </code>
- *
- * For more information about Uno Url please consult
- * <a href="http://udk.openoffice.org/common/man/spec/uno-url.html">
- * http://udk.openoffice.org/common/man/spec/uno-url.html</a>
- *
- * Usage:
- *
- * <code>
- * UnoUrl url = UnoUrl.parseUnoUrl("socket,host=localhost,port=2002;urp;StarOffice.ServiceManager");
- * </code>
- *
- * @author Joerg Brunsmann
- */
-public class UnoUrl {
-
- private static final String FORMAT_ERROR =
- "syntax: [uno:]connection-type,parameters;protocol-name,parameters;objectname";
-
- private static final String VALUE_CHAR_SET = "!$&'()*+-./:?@_~";
- private static final String OID_CHAR_SET = VALUE_CHAR_SET + ",=";
-
- private UnoUrlPart connection;
- private UnoUrlPart protocol;
- private String rootOid;
-
- static private class UnoUrlPart {
-
- private String partTypeName;
- private HashMap partParameters;
- private String uninterpretedParameterString;
-
- public UnoUrlPart(
- String uninterpretedParameterString,
- String partTypeName,
- HashMap partParameters) {
- this.uninterpretedParameterString = uninterpretedParameterString;
- this.partTypeName = partTypeName;
- this.partParameters = partParameters;
- }
-
- public String getPartTypeName() {
- return partTypeName;
- }
-
- public HashMap getPartParameters() {
- return partParameters;
- }
-
- public String getUninterpretedParameterString() {
- return uninterpretedParameterString;
- }
-
- public String getUninterpretedString() {
- StringBuffer buf = new StringBuffer(partTypeName);
- if (uninterpretedParameterString.length() > 0) {
- buf.append(',');
- buf.append(uninterpretedParameterString);
- }
- return buf.toString();
- }
- }
-
- private UnoUrl(
- UnoUrlPart connectionPart,
- UnoUrlPart protocolPart,
- String rootOid) {
- this.connection = connectionPart;
- this.protocol = protocolPart;
- this.rootOid = rootOid;
- }
-
- /**
- * Returns the name of the connection of this
- * Uno Url. Encoded characters are not allowed.
- *
- * @return The connection name as string.
- */
- public String getConnection() {
- return connection.getPartTypeName();
- }
-
- /**
- * Returns the name of the protocol of this
- * Uno Url. Encoded characters are not allowed.
- *
- * @return The protocol name as string.
- */
- public String getProtocol() {
- return protocol.getPartTypeName();
- }
-
- /**
- * Return the object name. Encoded character are
- * not allowed.
- *
- * @return The object name as String.
- */
- public String getRootOid() {
- return rootOid;
- }
-
- /**
- * Returns the protocol parameters as
- * a Hashmap with key/value pairs. Encoded
- * characters like '%41' are decoded.
- *
- * @return a HashMap with key/value pairs for protocol parameters.
- */
- public HashMap getProtocolParameters() {
- return protocol.getPartParameters();
- }
-
- /**
- * Returns the connection parameters as
- * a Hashmap with key/value pairs. Encoded
- * characters like '%41' are decoded.
- *
- * @return a HashMap with key/value pairs for connection parameters.
- */
- public HashMap getConnectionParameters() {
- return connection.getPartParameters();
- }
-
- /**
- * Returns the raw specification of the protocol
- * parameters. Encoded characters like '%41' are
- * not decoded.
- *
- * @return The uninterpreted protocol parameters as string.
- */
- public String getProtocolParametersAsString() {
- return protocol.getUninterpretedParameterString();
- }
-
- /**
- * Returns the raw specification of the connection
- * parameters. Encoded characters like '%41' are
- * not decoded.
- *
- * @return The uninterpreted connection parameters as string.
- */
- public String getConnectionParametersAsString() {
- return connection.getUninterpretedParameterString();
- }
-
- /**
- * Returns the raw specification of the protocol
- * name and parameters. Encoded characters like '%41' are
- * not decoded.
- *
- * @return The uninterpreted protocol name and parameters as string.
- */
- public String getProtocolAndParametersAsString() {
- return protocol.getUninterpretedString();
- }
-
- /**
- * Returns the raw specification of the connection
- * name and parameters. Encoded characters like '%41' are
- * not decoded.
- *
- * @return The uninterpreted connection name and parameters as string.
- */
- public String getConnectionAndParametersAsString() {
- return connection.getUninterpretedString();
- }
-
- private static int hexToInt(int ch)
- throws com.sun.star.lang.IllegalArgumentException {
- int c = Character.toLowerCase((char) ch);
- boolean isDigit = ('0' <= c && c <= '9');
- boolean isValidChar = ('a' <= c && c <= 'f') || isDigit;
-
- if (!isValidChar)
- throw new com.sun.star.lang.IllegalArgumentException(
- "Invalid UTF-8 hex byte '" + c + "'.");
-
- return isDigit ? ch - '0' : 10 + ((char) c - 'a') & 0xF;
- }
-
- private static String decodeUTF8(String s)
- throws com.sun.star.lang.IllegalArgumentException {
- Vector v = new Vector();
-
- for (int i = 0; i < s.length(); i++) {
- int ch = s.charAt(i);
-
- if (ch == '%') {
- int hb = hexToInt(s.charAt(++i));
- int lb = hexToInt(s.charAt(++i));
- ch = (hb << 4) | lb;
- }
-
- v.addElement(new Integer(ch));
- }
-
- int size = v.size();
- byte[] bytes = new byte[size];
- for (int i = 0; i < size; i++) {
- Integer anInt = (Integer) v.elementAt(i);
- bytes[i] = (byte) (anInt.intValue() & 0xFF);
- }
-
- try {
- return new String(bytes, "UTF-8");
- } catch (UnsupportedEncodingException e) {
- throw new com.sun.star.lang.IllegalArgumentException(
- "Couldn't convert parameter string to UTF-8 string:" + e.getMessage());
- }
- }
-
- private static HashMap buildParamHashMap(String paramString)
- throws com.sun.star.lang.IllegalArgumentException {
- HashMap params = new HashMap();
-
- int pos = 0;
-
- while (true) {
- char c = ',';
- String aKey = "";
- String aValue = "";
-
- while ((pos < paramString.length())
- && ((c = paramString.charAt(pos++)) != '=')) {
- aKey += c;
- }
-
- while ((pos < paramString.length())
- && ((c = paramString.charAt(pos++)) != ',')
- && c != ';') {
- aValue += c;
- }
-
- if ((aKey.length() > 0) && (aValue.length() > 0)) {
-
- if (!isAlphaNumeric(aKey)) {
- throw new com.sun.star.lang.IllegalArgumentException(
- "The parameter key '"
- + aKey
- + "' may only consist of alpha numeric ASCII characters.");
- }
-
- if (!isValidString(aValue, VALUE_CHAR_SET + "%")) {
- throw new com.sun.star.lang.IllegalArgumentException(
- "The parameter value for key '" + aKey + "' contains illegal characters.");
- }
-
- params.put(aKey, decodeUTF8(aValue));
- }
-
- if ((pos >= paramString.length()) || (c != ','))
- break;
-
- }
-
- return params;
- }
-
- private static UnoUrlPart parseUnoUrlPart(String thePart)
- throws com.sun.star.lang.IllegalArgumentException {
- String partName = thePart;
- String theParamPart = "";
- int index = thePart.indexOf(",");
- if (index != -1) {
- partName = thePart.substring(0, index).trim();
- theParamPart = thePart.substring(index + 1).trim();
- }
-
- if (!isAlphaNumeric(partName)) {
- throw new com.sun.star.lang.IllegalArgumentException(
- "The part name '"
- + partName
- + "' may only consist of alpha numeric ASCII characters.");
- }
-
- HashMap params = buildParamHashMap(theParamPart);
-
- return new UnoUrlPart(theParamPart, partName, params);
- }
-
- private static boolean isAlphaNumeric(String s) {
- return isValidString(s, null);
- }
-
- private static boolean isValidString(String identifier, String validCharSet) {
-
- int len = identifier.length();
-
- for (int i = 0; i < len; i++) {
-
- int ch = identifier.charAt(i);
-
- boolean isValidChar =
- ('A' <= ch && ch <= 'Z')
- || ('a' <= ch && ch <= 'z')
- || ('0' <= ch && ch <= '9');
-
- if (!isValidChar && (validCharSet != null)) {
- isValidChar = (validCharSet.indexOf(ch) != -1);
- }
-
- if (!isValidChar)
- return false;
- }
-
- return true;
- }
-
- /**
- * Parses the given Uno Url and returns
- * an in memory object representation.
- *
- * @param unoUrl The given uno URl as string.
- * @return Object representation of class UnoUrl.
- * @throws IllegalArgumentException if Url cannot be parsed.
- */
- public static UnoUrl parseUnoUrl(String unoUrl)
- throws com.sun.star.lang.IllegalArgumentException {
-
- String url = unoUrl;
-
- int index = url.indexOf(':');
- if (index != -1) {
- String unoStr = url.substring(0, index).trim();
- if (!"uno".equals(unoStr)) {
- throw new com.sun.star.lang.IllegalArgumentException(
- "Uno Urls must start with 'uno:'. " + FORMAT_ERROR);
- }
- }
-
- url = url.substring(index + 1).trim();
-
- index = url.indexOf(';');
- if (index == -1) {
- throw new com.sun.star.lang.IllegalArgumentException("'"+unoUrl+"' is an invalid Uno Url. " + FORMAT_ERROR);
- }
-
- String connection = url.substring(0, index).trim();
- url = url.substring(index + 1).trim();
-
- UnoUrlPart connectionPart = parseUnoUrlPart(connection);
-
- index = url.indexOf(';');
- if (index == -1) {
- throw new com.sun.star.lang.IllegalArgumentException("'"+unoUrl+"' is an invalid Uno Url. " + FORMAT_ERROR);
- }
-
- String protocol = url.substring(0, index).trim();
- url = url.substring(index + 1).trim();
-
- UnoUrlPart protocolPart = parseUnoUrlPart(protocol);
-
- String rootOid = url.trim();
- if (!isValidString(rootOid, OID_CHAR_SET)) {
- throw new com.sun.star.lang.IllegalArgumentException(
- "Root OID '"+ rootOid + "' contains illegal characters.");
- }
-
- return new UnoUrl(connectionPart, protocolPart, rootOid);
-
- }
-
-}
diff --git a/javaunohelper/com/sun/star/lib/uno/helper/WeakAdapter.java b/javaunohelper/com/sun/star/lib/uno/helper/WeakAdapter.java
deleted file mode 100644
index bda5a081b..000000000
--- a/javaunohelper/com/sun/star/lib/uno/helper/WeakAdapter.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-package com.sun.star.lib.uno.helper;
-import java.lang.ref.WeakReference;
-import com.sun.star.uno.XAdapter;
-import com.sun.star.uno.XReference;
-import java.util.List;
-import java.util.Collections;
-import java.util.LinkedList;
-
-/** An XAdapter implementation that holds a weak reference (java.lang.ref.WeakReference)
- * to an object. Clients can register listener (com.sun.star.lang.XReference) which
- * are notified when the the object (the one which is kept weak) is being finalized. That
- * is, that object is being destroyed because there are not any hard references
- * to it.
- */
-public class WeakAdapter implements XAdapter
-{
- private final boolean DEBUG= false;
- // references the XWeak implementation
- private WeakReference m_weakRef;
- // contains XReference objects registered by addReference
- private List m_xreferenceList;
-
- /**
- *@param component the object that is to be held weak
- */
- public WeakAdapter(Object component)
- {
- m_weakRef= new WeakReference(component);
- m_xreferenceList= Collections.synchronizedList( new LinkedList());
- }
-
- /** Called by the XWeak implementation (WeakBase) when it is being finalized.
- * It is only being called once.
- * The registererd XReference listeners are notified. On notification they are
- * to unregister themselves. The notification is thread-safe. However, it is possible
- * to add a listener during the notification process, which will never receive a
- * notification. To prevent this, one would have to synchronize this method with
- * the addReference method. But this can result in deadlocks in a multithreaded
- * environment.
- */
- void referentDying()
- {
- //synchronized call
- Object[] references= m_xreferenceList.toArray();
- for (int i= references.length; i > 0; i--)
- {
- ((XReference) references[i-1]).dispose();
- }
- }
-
- /** Method of com.sun.star.uno.XAdapter. It is called to obtain a hard reference
- * to the object which is kept weak by this instance.
- * @return hard reference to the object
- */
- public Object queryAdapted()
- {
- return m_weakRef.get();
- }
- /** Method of com.sun.star.uno.XAdapter. Called by clients to register listener which
- * are notified when the weak object is dying.
- *@param xReference a listener
- */
- public void removeReference(XReference xReference)
- {
- m_xreferenceList.remove(xReference);
- }
- /** Method of com.sun.star.uno.XAdapter. Called by clients to unregister listeners.
- *@param a listener
- */
- public void addReference(XReference xReference)
- {
- m_xreferenceList.add(xReference);
- }
-}
-
diff --git a/javaunohelper/com/sun/star/lib/uno/helper/WeakBase.java b/javaunohelper/com/sun/star/lib/uno/helper/WeakBase.java
deleted file mode 100644
index ace0713cc..000000000
--- a/javaunohelper/com/sun/star/lib/uno/helper/WeakBase.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-package com.sun.star.lib.uno.helper;
-import com.sun.star.uno.XWeak;
-import com.sun.star.uno.XAdapter;
-import com.sun.star.lang.XTypeProvider;
-import com.sun.star.uno.Type;
-import java.util.Vector;
-import java.util.Map;
-import java.util.Hashtable;
-
-
-/** This class can be used as the base class for UNO components. It implements the capability
- * to be kept weak (com.sun.star.uno.XWeak) and it implements com.sun.star.lang.XTypeProvider
- * which is necessary for using the component with StarBasic.
- */
-public class WeakBase implements XWeak, XTypeProvider
-{
- private final boolean DEBUG= false;
-
- // Contains all WeakAdapter which have been created in this class
- // They have to be notified when this object dies
- private WeakAdapter m_adapter;
-
- protected static Map _mapImplementationIds= new Hashtable();
- protected static Map _mapTypes= new Hashtable();
-
- /** Method of XWeak. The returned XAdapter implementation can be used to keap
- * a weak reference to this object.
- * @return a com.sun.star.uno.XAdapter implementation.
- */
- synchronized public XAdapter queryAdapter()
- {
- if (m_adapter == null)
- m_adapter= new WeakAdapter(this);
- return m_adapter;
- }
-
- /** Override of Object.finalize. When there are no references to this object anymore
- * then the garbage collector calls this method. Thereby causing the adapter object
- * to be notified. The adapter, in turn, notifies all listeners (com.sun.star.uno.XReference)
- */
- protected void finalize() throws java.lang.Throwable
- {
- if (m_adapter != null)
- m_adapter.referentDying();
- super.finalize();
- }
-
- /** Method of XTypeProvider. It returns an array of Type objects which represent
- * all implemented UNO interfaces of this object.
- * @return Type objects of all implemented interfaces.
- */
- public Type[] getTypes()
- {
- Type[] arTypes= (Type[]) _mapTypes.get( getClass());
- if (arTypes == null)
- {
- Vector vec= new Vector();
- Class currentClass= getClass();
- do
- {
- Class interfaces[]= currentClass.getInterfaces();
- for(int i = 0; i < interfaces.length; ++ i)
- {
- // Test if it is a UNO interface
- if (com.sun.star.uno.XInterface.class.isAssignableFrom((interfaces[i])))
- vec.add(new Type(interfaces[i]));
- }
- // get the superclass the currentClass inherits from
- currentClass= currentClass.getSuperclass();
- } while (currentClass != null);
-
- Type types[]= new Type[vec.size()];
- for( int i= 0; i < types.length; i++)
- types[i]= (Type) vec.elementAt(i);
- _mapTypes.put(getClass(), types);
- arTypes= types;
- }
- return arTypes;
- }
-
- /** Method of XTypeProvider. It provides an identifier that represents the set of UNO
- * interfaces implemented by this class. All instances of this class
- * which run in the same Java Virtual Machine return the same array. (This only works as long
- * the ClassLoader preserves the class even if no instance exist.)
- *@return identifier as array of bytes
- */
- public byte[] getImplementationId()
- {
- byte[] id= null;
- synchronized (_mapImplementationIds)
- {
- id= (byte[]) _mapImplementationIds.get(getClass());
-
- if (id == null)
- {
- int hash = hashCode();
- String sName= getClass().getName();
- byte[] arName= sName.getBytes();
- int nNameLength= arName.length;
-
- id= new byte[ 4 + nNameLength];
- id[0]= (byte)(hash & 0xff);
- id[1]= (byte)((hash >>> 8) & 0xff);
- id[2]= (byte)((hash >>> 16) & 0xff);
- id[3]= (byte)((hash >>>24) & 0xff);
-
- for (int i= 0; i < nNameLength; i++)
- {
- id[4 + i]= arName[i];
- }
- _mapImplementationIds.put(getClass(), id);
- }
- }
- return id;
- }
-}
diff --git a/javaunohelper/com/sun/star/lib/uno/helper/makefile.mk b/javaunohelper/com/sun/star/lib/uno/helper/makefile.mk
deleted file mode 100644
index 3cab6f070..000000000
--- a/javaunohelper/com/sun/star/lib/uno/helper/makefile.mk
+++ /dev/null
@@ -1,49 +0,0 @@
-#*************************************************************************
-#
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# Copyright 2000, 2010 Oracle and/or its affiliates.
-#
-# OpenOffice.org - a multi-platform office productivity suite
-#
-# This file is part of OpenOffice.org.
-#
-# OpenOffice.org is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Lesser General Public License version 3
-# only, as published by the Free Software Foundation.
-#
-# OpenOffice.org is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Lesser General Public License version 3 for more details
-# (a copy is included in the LICENSE file that accompanied this code).
-#
-# You should have received a copy of the GNU Lesser General Public License
-# version 3 along with OpenOffice.org. If not, see
-# <http://www.openoffice.org/license.html>
-# for a copy of the LGPLv3 License.
-#
-#*************************************************************************
-
-PRJ=..$/..$/..$/..$/..$/..
-
-PRJNAME = juhelper
-PACKAGE = com$/sun$/star$/lib$/uno$/helper
-TARGET = com_sun_star_lib_uno_helper
-
-.INCLUDE : settings.mk
-.INCLUDE: $(PRJ)$/util$/settings.pmk
-
-JAVAFILES = \
- ComponentBase.java \
- Factory.java \
- InterfaceContainer.java \
- MultiTypeInterfaceContainer.java \
- PropertySet.java \
- PropertySetMixin.java \
- UnoUrl.java \
- WeakAdapter.java \
- WeakBase.java
-
-.INCLUDE : target.mk
-
diff --git a/javaunohelper/inc/makefile.mk b/javaunohelper/inc/makefile.mk
deleted file mode 100644
index b9f61c2e1..000000000
--- a/javaunohelper/inc/makefile.mk
+++ /dev/null
@@ -1,47 +0,0 @@
-#*************************************************************************
-#
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# Copyright 2000, 2010 Oracle and/or its affiliates.
-#
-# OpenOffice.org - a multi-platform office productivity suite
-#
-# This file is part of OpenOffice.org.
-#
-# OpenOffice.org is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Lesser General Public License version 3
-# only, as published by the Free Software Foundation.
-#
-# OpenOffice.org is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Lesser General Public License version 3 for more details
-# (a copy is included in the LICENSE file that accompanied this code).
-#
-# You should have received a copy of the GNU Lesser General Public License
-# version 3 along with OpenOffice.org. If not, see
-# <http://www.openoffice.org/license.html>
-# for a copy of the LGPLv3 License.
-#
-#*************************************************************************
-PRJ=..
-
-PRJNAME=javaunohelper
-TARGET=inc
-
-# --- Settings -----------------------------------------------------
-
-.INCLUDE : settings.mk
-
-# --- Files --------------------------------------------------------
-# --- Targets -------------------------------------------------------
-
-.INCLUDE : target.mk
-
-.IF "$(ENABLE_PCH)"!=""
-ALLTAR : \
- $(SLO)$/precompiled.pch \
- $(SLO)$/precompiled_ex.pch
-
-.ENDIF # "$(ENABLE_PCH)"!=""
-
diff --git a/javaunohelper/inc/pch/precompiled_javaunohelper.cxx b/javaunohelper/inc/pch/precompiled_javaunohelper.cxx
deleted file mode 100644
index 60393c813..000000000
--- a/javaunohelper/inc/pch/precompiled_javaunohelper.cxx
+++ /dev/null
@@ -1,31 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-#include "precompiled_javaunohelper.hxx"
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/javaunohelper/inc/pch/precompiled_javaunohelper.hxx b/javaunohelper/inc/pch/precompiled_javaunohelper.hxx
deleted file mode 100644
index a1e61803c..000000000
--- a/javaunohelper/inc/pch/precompiled_javaunohelper.hxx
+++ /dev/null
@@ -1,34 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): Generated on 2006-09-01 17:49:50.311334
-
-#ifdef PRECOMPILED_HEADERS
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/javaunohelper/prj/build.lst b/javaunohelper/prj/build.lst
deleted file mode 100644
index d97a6450d..000000000
--- a/javaunohelper/prj/build.lst
+++ /dev/null
@@ -1,10 +0,0 @@
-jh javaunohelper : LIBXSLT:libxslt bridges cppuhelper jurt ridljar unoil NULL
-jh javaunohelper usr1 - all jh_mkout NULL
-jh javaunohelper\inc nmake - all jh_inc NULL
-jh javaunohelper\com\sun\star\comp\helper nmake - all jh_helper jh_inc NULL
-jh javaunohelper\com\sun\star\comp\juhtest nmake - all jh_juhtest jh_helper jh_libhelp NULL
-jh javaunohelper\com\sun\star\comp nmake - all jh_comp jh_juhtest NULL
-jh javaunohelper\com\sun\star\lib\uno\adapter nmake - all jh_adapter jh_libhelp jh_inc NULL
-jh javaunohelper\com\sun\star\lib\uno\helper nmake - all jh_libhelp jh_inc NULL
-jh javaunohelper\source nmake - all jh_source jh_inc NULL
-jh javaunohelper\util nmake - all jh_util jh_helper jh_source jh_adapter jh_libhelp jh_comp NULL
diff --git a/javaunohelper/prj/d.lst b/javaunohelper/prj/d.lst
deleted file mode 100644
index 15e14f6c4..000000000
--- a/javaunohelper/prj/d.lst
+++ /dev/null
@@ -1,7 +0,0 @@
-..\%__SRC%\class\juh.jar %_DEST%\bin\juh.jar
-..\%__SRC%\bin\juh*.dll %_DEST%\bin\juh*.dll
-..\%__SRC%\lib\libjuh*.so %_DEST%\lib\libjuh*.so
-..\%__SRC%\lib\libjuh*.dylib %_DEST%\lib\libjuh*.dylib
-..\%__SRC%\misc\juh.component %_DEST%\xml\juh.component
-
-..\%__SRC%\bin\juh_src.zip %COMMON_DEST%\bin\juh_src.zip
diff --git a/javaunohelper/source/bootstrap.cxx b/javaunohelper/source/bootstrap.cxx
deleted file mode 100644
index e98e690fb..000000000
--- a/javaunohelper/source/bootstrap.cxx
+++ /dev/null
@@ -1,191 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_javaunohelper.hxx"
-
-#include "osl/diagnose.h"
-
-#include "rtl/alloc.h"
-#include "rtl/bootstrap.hxx"
-#include "rtl/string.hxx"
-
-#include "uno/mapping.hxx"
-#include "uno/environment.hxx"
-
-#include "cppuhelper/bootstrap.hxx"
-
-#include "com/sun/star/lang/XComponent.hpp"
-#include "com/sun/star/lang/XSingleComponentFactory.hpp"
-
-#include "jni.h"
-#include "jvmaccess/virtualmachine.hxx"
-#include "jvmaccess/unovirtualmachine.hxx"
-
-#include "vm.hxx"
-
-#define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) )
-
-
-using namespace ::com::sun::star;
-using namespace ::com::sun::star::uno;
-using ::rtl::OString;
-using ::rtl::OUString;
-
-namespace javaunohelper
-{
-
-inline ::rtl::OUString jstring_to_oustring( jstring jstr, JNIEnv * jni_env )
-{
- OSL_ASSERT( sizeof (sal_Unicode) == sizeof (jchar) );
- jsize len = jni_env->GetStringLength( jstr );
- rtl_uString * ustr =
- (rtl_uString *)rtl_allocateMemory( sizeof (rtl_uString) + (len * sizeof (sal_Unicode)) );
- jni_env->GetStringRegion( jstr, 0, len, ustr->buffer );
- OSL_ASSERT( JNI_FALSE == jni_env->ExceptionCheck() );
- ustr->refCount = 1;
- ustr->length = len;
- ustr->buffer[ len ] = '\0';
- return ::rtl::OUString( ustr, SAL_NO_ACQUIRE );
-}
-
-}
-
-//==================================================================================================
-extern "C" JNIEXPORT jobject JNICALL Java_com_sun_star_comp_helper_Bootstrap_cppuhelper_1bootstrap(
- JNIEnv * jni_env, jclass, jstring juno_rc, jobjectArray jpairs,
- jobject loader )
-{
- try
- {
- if (0 != jpairs)
- {
- jsize nPos = 0, len = jni_env->GetArrayLength( jpairs );
- while (nPos < len)
- {
- // name
- jstring jstr = (jstring)jni_env->GetObjectArrayElement( jpairs, nPos );
- if (JNI_FALSE != jni_env->ExceptionCheck())
- {
- jni_env->ExceptionClear();
- throw RuntimeException(
- OUSTR("index out of bounds?!"), Reference< XInterface >() );
- }
- if (0 != jstr)
- {
- OUString name( ::javaunohelper::jstring_to_oustring( jstr, jni_env ) );
- // value
- jstr = (jstring)jni_env->GetObjectArrayElement( jpairs, nPos +1 );
- if (JNI_FALSE != jni_env->ExceptionCheck())
- {
- jni_env->ExceptionClear();
- throw RuntimeException(
- OUSTR("index out of bounds?!"), Reference< XInterface >() );
- }
- if (0 != jstr)
- {
- OUString value( ::javaunohelper::jstring_to_oustring( jstr, jni_env ) );
-
- // set bootstrap parameter
- ::rtl::Bootstrap::set( name, value );
- }
- }
- nPos += 2;
- }
- }
-
- // bootstrap uno
- Reference< XComponentContext > xContext;
- if (0 == juno_rc)
- {
- xContext = ::cppu::defaultBootstrap_InitialComponentContext();
- }
- else
- {
- OUString uno_rc( ::javaunohelper::jstring_to_oustring( juno_rc, jni_env ) );
- xContext = ::cppu::defaultBootstrap_InitialComponentContext( uno_rc );
- }
-
- // create vm access
- ::rtl::Reference< ::jvmaccess::UnoVirtualMachine > vm_access(
- ::javaunohelper::create_vm_access( jni_env, loader ) );
- // wrap vm singleton entry
- xContext = ::javaunohelper::install_vm_singleton( xContext, vm_access );
-
- // get uno envs
- OUString cpp_env_name = OUSTR(CPPU_CURRENT_LANGUAGE_BINDING_NAME);
- OUString java_env_name = OUSTR(UNO_LB_JAVA);
- Environment java_env, cpp_env;
- uno_getEnvironment((uno_Environment **)&cpp_env, cpp_env_name.pData, NULL);
- uno_getEnvironment( (uno_Environment **)&java_env, java_env_name.pData, vm_access.get() );
-
- // map to java
- Mapping mapping( cpp_env.get(), java_env.get() );
- if (! mapping.is())
- {
- Reference< lang::XComponent > xComp( xContext, UNO_QUERY );
- if (xComp.is())
- xComp->dispose();
- throw RuntimeException(
- OUSTR("cannot get mapping C++ <-> Java!"),
- Reference< XInterface >() );
- }
-
- jobject jret = (jobject)mapping.mapInterface( xContext.get(), ::getCppuType( &xContext ) );
- jobject jlocal = jni_env->NewLocalRef( jret );
- jni_env->DeleteGlobalRef( jret );
-
- return jlocal;
- }
- catch (RuntimeException & exc)
- {
- jclass c = jni_env->FindClass( "com/sun/star/uno/RuntimeException" );
- if (0 != c)
- {
- OString cstr( ::rtl::OUStringToOString(
- exc.Message, RTL_TEXTENCODING_JAVA_UTF8 ) );
- OSL_TRACE( __FILE__": forwarding RuntimeException: %s", cstr.getStr() );
- jni_env->ThrowNew( c, cstr.getStr() );
- }
- }
- catch (Exception & exc)
- {
- jclass c = jni_env->FindClass( "com/sun/star/uno/Exception" );
- if (0 != c)
- {
- OString cstr( ::rtl::OUStringToOString(
- exc.Message, RTL_TEXTENCODING_JAVA_UTF8 ) );
- OSL_TRACE( __FILE__": forwarding Exception: %s", cstr.getStr() );
- jni_env->ThrowNew( c, cstr.getStr() );
- }
- }
-
- return 0;
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/javaunohelper/source/javaunohelper.cxx b/javaunohelper/source/javaunohelper.cxx
deleted file mode 100644
index fd170353b..000000000
--- a/javaunohelper/source/javaunohelper.cxx
+++ /dev/null
@@ -1,326 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_javaunohelper.hxx"
-
-#include <osl/diagnose.h>
-#include <osl/module.h>
-
-#include <uno/environment.hxx>
-#include <uno/mapping.hxx>
-
-#include <cppuhelper/factory.hxx>
-#include <cppuhelper/servicefactory.hxx>
-#include <cppuhelper/component_context.hxx>
-
-#include <com/sun/star/beans/XPropertySet.hpp>
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
-#include <com/sun/star/lang/XServiceInfo.hpp>
-#include <com/sun/star/registry/XRegistryKey.hpp>
-
-#include "jni.h"
-#include "jvmaccess/virtualmachine.hxx"
-#include "jvmaccess/unovirtualmachine.hxx"
-
-#include "vm.hxx"
-
-#define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) )
-
-
-using namespace ::com::sun::star;
-using namespace ::com::sun::star::uno;
-using ::rtl::OString;
-using ::rtl::OUString;
-
-/*
- * Class: com_sun_star_comp_helper_SharedLibraryLoader
- * Method: component_writeInfo
- * Signature: (Ljava/lang/String;Lcom/sun/star/lang/XMultiServiceFactory;Lcom/sun/star/registry/XRegistryKey;)Z
- */
-extern "C" JNIEXPORT jboolean JNICALL
-Java_com_sun_star_comp_helper_SharedLibraryLoader_component_1writeInfo(
- JNIEnv * pJEnv, jclass, jstring jLibName, jobject jSMgr,
- jobject jRegKey, jobject loader )
-{
- sal_Bool bRet = sal_False;
-
- const jchar* pJLibName = pJEnv->GetStringChars( jLibName, NULL );
- OUString aLibName( pJLibName );
- pJEnv->ReleaseStringChars( jLibName, pJLibName);
-
- oslModule lib = osl_loadModule( aLibName.pData, SAL_LOADMODULE_LAZY | SAL_LOADMODULE_GLOBAL );
- if (lib)
- {
- // ========================= LATEST VERSION =========================
- OUString aGetEnvName( RTL_CONSTASCII_USTRINGPARAM(COMPONENT_GETENV) );
- oslGenericFunction pSym =
- osl_getFunctionSymbol( lib, aGetEnvName.pData );
- if (pSym)
- {
- Environment java_env, loader_env;
-
- const sal_Char * pEnvTypeName = 0;
- (*((component_getImplementationEnvironmentFunc)pSym))(
- &pEnvTypeName, (uno_Environment **)&loader_env );
- if (! loader_env.is())
- {
- OUString aEnvTypeName( OUString::createFromAscii( pEnvTypeName ) );
- uno_getEnvironment( (uno_Environment **)&loader_env, aEnvTypeName.pData, 0 );
- }
-
- // create vm access
- ::rtl::Reference< ::jvmaccess::UnoVirtualMachine > vm_access(
- ::javaunohelper::create_vm_access( pJEnv, loader ) );
- OUString java_env_name = OUSTR(UNO_LB_JAVA);
- uno_getEnvironment(
- (uno_Environment **)&java_env, java_env_name.pData, vm_access.get() );
-
- OUString aWriteInfoName( RTL_CONSTASCII_USTRINGPARAM(COMPONENT_WRITEINFO) );
- pSym = osl_getFunctionSymbol( lib, aWriteInfoName.pData );
- if (pSym)
- {
- if (loader_env.is() && java_env.is())
- {
- Mapping java2dest(java_env.get(), loader_env.get());
-
- if ( java2dest.is() )
- {
- void * pSMgr =
- java2dest.mapInterface(
- jSMgr, getCppuType((Reference< lang::XMultiServiceFactory > *) 0) );
- void * pKey =
- java2dest.mapInterface(
- jRegKey, getCppuType((Reference< registry::XRegistryKey > *) 0) );
-
- uno_ExtEnvironment * env = loader_env.get()->pExtEnv;
- if (pKey)
- {
- bRet = (*((component_writeInfoFunc)pSym))( pSMgr, pKey );
-
- if (env)
- (*env->releaseInterface)( env, pKey );
- }
-
- if (pSMgr && env)
- (*env->releaseInterface)( env, pSMgr );
- }
- }
- }
- }
- }
-
- return bRet == sal_False? JNI_FALSE : JNI_TRUE;
-}
-
-/*
- * Class: com_sun_star_comp_helper_SharedLibraryLoader
- * Method: component_getFactory
- * Signature: (Ljava/lang/String;Ljava/lang/String;Lcom/sun/star/lang/XMultiServiceFactory;Lcom/sun/star/registry/XRegistryKey;)Ljava/lang/Object;
- */
-extern "C" JNIEXPORT jobject JNICALL
-Java_com_sun_star_comp_helper_SharedLibraryLoader_component_1getFactory(
- JNIEnv * pJEnv, jclass, jstring jLibName, jstring jImplName,
- jobject jSMgr, jobject jRegKey, jobject loader )
-{
- const jchar* pJLibName = pJEnv->GetStringChars(jLibName, NULL);
- OUString aLibName( pJLibName );
- pJEnv->ReleaseStringChars( jLibName, pJLibName);
-
- aLibName += OUString( RTL_CONSTASCII_USTRINGPARAM(SAL_DLLEXTENSION) );
-
- jobject joSLL_cpp = 0;
-
- oslModule lib = osl_loadModule( aLibName.pData, SAL_LOADMODULE_LAZY | SAL_LOADMODULE_GLOBAL );
- if (lib)
- {
- // ========================= LATEST VERSION =========================
- OUString aGetEnvName( RTL_CONSTASCII_USTRINGPARAM(COMPONENT_GETENV) );
- oslGenericFunction pSym =
- osl_getFunctionSymbol( lib, aGetEnvName.pData );
- if (pSym)
- {
- Environment java_env, loader_env;
-
- const sal_Char * pEnvTypeName = 0;
- (*((component_getImplementationEnvironmentFunc)pSym))(
- &pEnvTypeName, (uno_Environment **)&loader_env );
-
- if (! loader_env.is())
- {
- OUString aEnvTypeName( OUString::createFromAscii( pEnvTypeName ) );
- uno_getEnvironment( (uno_Environment **)&loader_env, aEnvTypeName.pData, 0 );
- }
-
- // create vm access
- ::rtl::Reference< ::jvmaccess::UnoVirtualMachine > vm_access(
- ::javaunohelper::create_vm_access( pJEnv, loader ) );
- OUString java_env_name = OUSTR(UNO_LB_JAVA);
- uno_getEnvironment(
- (uno_Environment **)&java_env, java_env_name.pData, vm_access.get() );
-
- OUString aGetFactoryName( RTL_CONSTASCII_USTRINGPARAM(COMPONENT_GETFACTORY) );
- pSym = osl_getFunctionSymbol( lib, aGetFactoryName.pData );
- if (pSym)
- {
- if (loader_env.is() && java_env.is())
- {
- Mapping java2dest( java_env.get(), loader_env.get() );
- Mapping dest2java( loader_env.get(), java_env.get() );
-
- if (dest2java.is() && java2dest.is())
- {
- void * pSMgr =
- java2dest.mapInterface(
- jSMgr, ::getCppuType((Reference< lang::XMultiServiceFactory > *) 0) );
- void * pKey =
- java2dest.mapInterface(
- jRegKey, ::getCppuType((Reference< registry::XRegistryKey > *) 0) );
-
- const char* pImplName = pJEnv->GetStringUTFChars( jImplName, NULL );
-
- void * pSSF = (*((component_getFactoryFunc)pSym))(
- pImplName, pSMgr, pKey );
-
- pJEnv->ReleaseStringUTFChars( jImplName, pImplName );
-
- uno_ExtEnvironment * env = loader_env.get()->pExtEnv;
-
- if (pKey && env)
- (*env->releaseInterface)( env, pKey );
- if (pSMgr && env)
- (*env->releaseInterface)( env, pSMgr );
-
- if (pSSF)
- {
- jobject jglobal = (jobject) dest2java.mapInterface(
- pSSF, getCppuType((Reference< XInterface > *) 0) );
- joSLL_cpp = pJEnv->NewLocalRef( jglobal );
- pJEnv->DeleteGlobalRef( jglobal );
- if (env)
- (*env->releaseInterface)( env, pSSF );
- }
- }
- }
- }
- }
- }
-
- return joSLL_cpp;
-}
-
-/*
- * Class: com_sun_star_comp_helper_RegistryServiceFactory
- * Method: createRegistryServiceFactory
- * Signature: (Ljava/lang/String;Ljava/lang/String;Z)Ljava/lang/Object;
- */
-extern "C" JNIEXPORT jobject JNICALL
-Java_com_sun_star_comp_helper_RegistryServiceFactory_createRegistryServiceFactory(
- JNIEnv * pJEnv, jclass, jstring jWriteRegFile,
- jstring jReadRegFile, jboolean jbReadOnly, jobject loader )
-{
- jobject joRegServiceFac = 0;
-
- try
- {
- OUString aWriteRegFile;
- OUString aReadRegFile;
-
- sal_Bool bReadOnly = jbReadOnly == JNI_FALSE ? sal_False : sal_True;
-
- if (jReadRegFile) {
- const jchar* pjReadRegFile = pJEnv->GetStringChars(jReadRegFile, NULL);
- aReadRegFile = OUString(pjReadRegFile);
- pJEnv->ReleaseStringChars(jReadRegFile, pjReadRegFile);
- }
-
- if (jWriteRegFile) {
- const jchar * pjWriteRegFile = pJEnv->GetStringChars(jWriteRegFile, NULL);
- aWriteRegFile = OUString(pjWriteRegFile);
- pJEnv->ReleaseStringChars(jWriteRegFile, pjWriteRegFile);
- }
-
- // bootstrap
- Reference< lang::XMultiServiceFactory > rMSFac;
- if (aReadRegFile.getLength() == 0)
- rMSFac = ::cppu::createRegistryServiceFactory( aWriteRegFile, bReadOnly);
- else
- rMSFac = ::cppu::createRegistryServiceFactory(aWriteRegFile, aReadRegFile, bReadOnly);
-
- Reference< beans::XPropertySet > xProps(
- rMSFac, UNO_QUERY_THROW );
- Reference< XComponentContext > xContext(
- xProps->getPropertyValue( OUSTR("DefaultContext") ), UNO_QUERY_THROW );
-
- // create vm access
- ::rtl::Reference< ::jvmaccess::UnoVirtualMachine > vm_access(
- ::javaunohelper::create_vm_access( pJEnv, loader ) );
- // wrap vm singleton entry
- xContext = ::javaunohelper::install_vm_singleton( xContext, vm_access );
- rMSFac.set( xContext->getServiceManager(), UNO_QUERY_THROW );
-
- // get uno envs
- OUString aCurrentEnv(RTL_CONSTASCII_USTRINGPARAM(CPPU_CURRENT_LANGUAGE_BINDING_NAME));
- OUString java_env_name = OUSTR(UNO_LB_JAVA);
- Environment java_env, curr_env;
- uno_getEnvironment((uno_Environment **)&curr_env, aCurrentEnv.pData, NULL);
- uno_getEnvironment( (uno_Environment **)&java_env, java_env_name.pData, vm_access.get() );
-
- Mapping curr_java(curr_env.get(), java_env.get());
- if (! curr_java.is())
- {
- throw RuntimeException(
- OUSTR("no C++ <-> Java mapping available!"), Reference< XInterface >() );
- }
-
- jobject joGlobalRegServiceFac =
- (jobject)curr_java.mapInterface(
- rMSFac.get(),
- getCppuType((Reference< lang::XMultiServiceFactory > *)0) );
- joRegServiceFac = pJEnv->NewLocalRef( joGlobalRegServiceFac );
- pJEnv->DeleteGlobalRef(joGlobalRegServiceFac);
- }
- catch (Exception & exc)
- {
- jclass c = pJEnv->FindClass( "com/sun/star/uno/RuntimeException" );
- if (0 != c)
- {
- OString cstr( ::rtl::OUStringToOString(
- exc.Message, RTL_TEXTENCODING_JAVA_UTF8 ) );
- OSL_TRACE( __FILE__": forwarding Exception: %s", cstr.getStr() );
- pJEnv->ThrowNew( c, cstr.getStr() );
- }
- return 0;
- }
-
- OSL_TRACE("javaunohelper.cxx: object %i", joRegServiceFac);
-
- return joRegServiceFac;
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/javaunohelper/source/javaunohelper.map b/javaunohelper/source/javaunohelper.map
deleted file mode 100644
index dcbe0506a..000000000
--- a/javaunohelper/source/javaunohelper.map
+++ /dev/null
@@ -1,9 +0,0 @@
-UDK_3_0_0 {
- global:
- Java_com_sun_star_comp_helper_SharedLibraryLoader_component_1writeInfo;
- Java_com_sun_star_comp_helper_SharedLibraryLoader_component_1getFactory;
- Java_com_sun_star_comp_helper_RegistryServiceFactory_createRegistryServiceFactory;
- Java_com_sun_star_comp_helper_Bootstrap_cppuhelper_1bootstrap;
- local:
- *;
-};
diff --git a/javaunohelper/source/makefile.mk b/javaunohelper/source/makefile.mk
deleted file mode 100644
index 606ddade3..000000000
--- a/javaunohelper/source/makefile.mk
+++ /dev/null
@@ -1,134 +0,0 @@
-#*************************************************************************
-#
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# Copyright 2000, 2010 Oracle and/or its affiliates.
-#
-# OpenOffice.org - a multi-platform office productivity suite
-#
-# This file is part of OpenOffice.org.
-#
-# OpenOffice.org is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Lesser General Public License version 3
-# only, as published by the Free Software Foundation.
-#
-# OpenOffice.org is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Lesser General Public License version 3 for more details
-# (a copy is included in the LICENSE file that accompanied this code).
-#
-# You should have received a copy of the GNU Lesser General Public License
-# version 3 along with OpenOffice.org. If not, see
-# <http://www.openoffice.org/license.html>
-# for a copy of the LGPLv3 License.
-#
-#*************************************************************************
-
-PRJ=..
-
-PRJNAME=javaunohelper
-TARGET=juh
-USE_DEFFILE=TRUE
-ENABLE_EXCEPTIONS=TRUE
-LIBTARGET=NO
-
-# --- Settings -----------------------------------------------------
-
-.INCLUDE : settings.mk
-
-.IF "$(SOLAR_JAVA)"==""
-nojava:
- @echo "Not building javaunohelper because Java is disabled"
-.ENDIF
-
-# ------------------------------------------------------------------
-
-UNOUCRDEP=$(SOLARBINDIR)$/udkapi.rdb
-UNOUCRRDB=$(SOLARBINDIR)$/udkapi.rdb
-
-UNOUCROUT=$(OUT)$/inc$/comprehensive
-INCPRE+=$(OUT)$/inc$/comprehensive
-NO_OFFUH=TRUE
-CPPUMAKERFLAGS+=-C
-
-UNOTYPES= \
- com.sun.star.beans.NamedValue \
- com.sun.star.container.XHierarchicalNameAccess \
- com.sun.star.loader.XImplementationLoader \
- com.sun.star.registry.XRegistryKey \
- com.sun.star.registry.XSimpleRegistry \
- com.sun.star.beans.XPropertySet \
- com.sun.star.lang.DisposedException \
- com.sun.star.lang.IllegalArgumentException \
- com.sun.star.lang.XTypeProvider \
- com.sun.star.lang.XServiceInfo \
- com.sun.star.lang.XMultiServiceFactory \
- com.sun.star.lang.XMultiComponentFactory \
- com.sun.star.lang.XSingleServiceFactory \
- com.sun.star.lang.XSingleComponentFactory \
- com.sun.star.uno.TypeClass \
- com.sun.star.uno.XWeak \
- com.sun.star.uno.XAggregation \
- com.sun.star.uno.XComponentContext \
- com.sun.star.lang.XInitialization \
- com.sun.star.lang.XComponent
-
-SLOFILES= \
- $(SLO)$/javaunohelper.obj \
- $(SLO)$/bootstrap.obj \
- $(SLO)$/preload.obj \
- $(SLO)$/vm.obj
-
-# ------------------------------------------------------------------
-
-LIB1TARGET=$(SLB)$/$(SHL1TARGET).lib
-LIB1OBJFILES=\
- $(SLO)$/javaunohelper.obj \
- $(SLO)$/bootstrap.obj \
- $(SLO)$/vm.obj
-
-SHL1TARGET=juhx
-
-SHL1STDLIBS= \
- $(JVMACCESSLIB) \
- $(SALHELPERLIB) \
- $(SALLIB) \
- $(CPPULIB) \
- $(CPPUHELPERLIB)
-
-SHL1VERSIONMAP = javaunohelper.map
-
-SHL1DEPN=
-SHL1IMPLIB=i$(SHL1TARGET)
-SHL1LIBS=$(LIB1TARGET)
-SHL1DEF=$(MISC)$/$(SHL1TARGET).def
-SHL1RPATH=URELIB
-
-DEF1NAME=$(SHL1TARGET)
-
-# ------------------------------------------------------------------
-
-LIB2TARGET=$(SLB)$/$(SHL2TARGET).lib
-LIB2OBJFILES=\
- $(SLO)$/preload.obj
-
-SHL2TARGET=juh
-
-SHL2STDLIBS= \
- $(SALLIB)
-
-SHL2VERSIONMAP = javaunohelper.map
-
-SHL2DEPN=
-SHL2IMPLIB=i$(SHL2TARGET)
-SHL2LIBS=$(LIB2TARGET)
-SHL2DEF=$(MISC)$/$(SHL2TARGET).def
-SHL2RPATH=URELIB
-
-DEF2NAME=$(SHL2TARGET)
-
-# --- Targets ------------------------------------------------------
-
-.INCLUDE : target.mk
-
diff --git a/javaunohelper/source/preload.cxx b/javaunohelper/source/preload.cxx
deleted file mode 100644
index 047f7c333..000000000
--- a/javaunohelper/source/preload.cxx
+++ /dev/null
@@ -1,161 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_javaunohelper.hxx"
-
-#include "jni.h"
-
-#include "rtl/ustring.hxx"
-#include "osl/module.h"
-
-#define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) )
-
-#if ! defined SAL_DLLPREFIX
-#define SAL_DLLPREFIX ""
-#endif
-
-using ::rtl::OUString;
-
-extern "C"
-{
-typedef jboolean (JNICALL * fptr_writeInfo)(
- JNIEnv *, jclass, jstring, jobject, jobject, jobject );
-typedef jobject (JNICALL * fptr_getFactory)(
- JNIEnv *, jclass, jstring, jstring, jobject, jobject, jobject );
-typedef jobject (JNICALL * fptr_createRegistryServiceFactory)(
- JNIEnv *, jclass, jstring, jstring, jboolean, jobject );
-typedef jobject (JNICALL * fptr_bootstrap)(
- JNIEnv *_env, jclass, jstring, jobjectArray, jobject );
-
-static fptr_writeInfo s_writeInfo;
-static fptr_getFactory s_getFactory;
-static fptr_createRegistryServiceFactory s_createRegistryServiceFactory;
-static fptr_bootstrap s_bootstrap;
-static bool s_inited = false;
-
-extern "C" { static void SAL_CALL thisModule() {} }
-
-//--------------------------------------------------------------------------------------------------
-static bool inited_juhx( JNIEnv * jni_env )
-{
- if (s_inited)
- return true;
- OUString lib_name = OUSTR(SAL_DLLPREFIX "juhx" SAL_DLLEXTENSION);
- oslModule hModule =
- osl_loadModuleRelative( &thisModule, lib_name.pData, SAL_LOADMODULE_LAZY | SAL_LOADMODULE_GLOBAL );
- if (0 == hModule)
- {
- jclass c = jni_env->FindClass( "java/lang/RuntimeException" );
- jni_env->ThrowNew(
- c, "error loading " SAL_DLLPREFIX "juhx" SAL_DLLEXTENSION "!" );
- return false;
- }
- else
- {
- OUString symbol =
- OUSTR("Java_com_sun_star_comp_helper_SharedLibraryLoader_component_1writeInfo");
- s_writeInfo = (fptr_writeInfo)osl_getFunctionSymbol(
- hModule, symbol.pData );
- symbol =
- OUSTR("Java_com_sun_star_comp_helper_SharedLibraryLoader_component_1getFactory");
- s_getFactory = (fptr_getFactory)osl_getFunctionSymbol(
- hModule, symbol.pData );
- symbol =
- OUSTR("Java_com_sun_star_comp_helper_RegistryServiceFactory_createRegistryServiceFactory");
- s_createRegistryServiceFactory =
- (fptr_createRegistryServiceFactory)osl_getFunctionSymbol(
- hModule, symbol.pData );
- symbol =
- OUSTR("Java_com_sun_star_comp_helper_Bootstrap_cppuhelper_1bootstrap");
- s_bootstrap =
- (fptr_bootstrap)osl_getFunctionSymbol( hModule, symbol.pData );
-
- if (0 == s_writeInfo ||
- 0 == s_getFactory ||
- 0 == s_createRegistryServiceFactory ||
- 0 == s_bootstrap)
- {
- jclass c = jni_env->FindClass( "java/lang/RuntimeException" );
- jni_env->ThrowNew(
- c, "error resolving symbols of " SAL_DLLPREFIX "juhx" SAL_DLLEXTENSION "!" );
- return false;
- }
- }
- s_inited = true;
- return true;
-}
-
-//==================================================================================================
-JNIEXPORT jboolean JNICALL
-Java_com_sun_star_comp_helper_SharedLibraryLoader_component_1writeInfo(
- JNIEnv * pJEnv, jclass jClass, jstring jLibName, jobject jSMgr,
- jobject jRegKey, jobject loader )
-{
- if (inited_juhx( pJEnv ))
- return (*s_writeInfo)(
- pJEnv, jClass, jLibName, jSMgr, jRegKey, loader );
- return JNI_FALSE;
-}
-//==================================================================================================
-JNIEXPORT jobject JNICALL
-Java_com_sun_star_comp_helper_SharedLibraryLoader_component_1getFactory(
- JNIEnv * pJEnv, jclass jClass, jstring jLibName, jstring jImplName,
- jobject jSMgr, jobject jRegKey, jobject loader )
-{
- if (inited_juhx( pJEnv ))
- return (*s_getFactory)(
- pJEnv, jClass, jLibName, jImplName, jSMgr, jRegKey, loader );
- return 0;
-}
-//==================================================================================================
-JNIEXPORT jobject JNICALL
-Java_com_sun_star_comp_helper_RegistryServiceFactory_createRegistryServiceFactory(
- JNIEnv * pJEnv, jclass jClass, jstring jWriteRegFile,
- jstring jReadRegFile, jboolean jbReadOnly, jobject loader )
-{
- if (inited_juhx( pJEnv ))
- {
- return (*s_createRegistryServiceFactory)(
- pJEnv, jClass, jWriteRegFile, jReadRegFile, jbReadOnly, loader );
- }
- return 0;
-}
-//==================================================================================================
-JNIEXPORT jobject JNICALL
-Java_com_sun_star_comp_helper_Bootstrap_cppuhelper_1bootstrap(
- JNIEnv * jni_env, jclass jClass, jstring juno_rc, jobjectArray jpairs,
- jobject loader )
-{
- if (inited_juhx( jni_env ))
- return (*s_bootstrap)( jni_env, jClass, juno_rc, jpairs, loader );
- return 0;
-}
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/javaunohelper/source/vm.cxx b/javaunohelper/source/vm.cxx
deleted file mode 100644
index 8555c10fb..000000000
--- a/javaunohelper/source/vm.cxx
+++ /dev/null
@@ -1,150 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_javaunohelper.hxx"
-
-#include "sal/config.h"
-
-#include "vm.hxx"
-
-#include "com/sun/star/beans/NamedValue.hpp"
-#include "com/sun/star/lang/XSingleComponentFactory.hpp"
-#include "cppuhelper/compbase1.hxx"
-#include "cppuhelper/component_context.hxx"
-#include "jvmaccess/virtualmachine.hxx"
-#include "jvmaccess/unovirtualmachine.hxx"
-#include "osl/mutex.hxx"
-
-namespace {
-
-namespace css = ::com::sun::star;
-
-struct MutexHolder
-{
- ::osl::Mutex m_mutex;
-};
-typedef ::cppu::WeakComponentImplHelper1<
- css::lang::XSingleComponentFactory > t_impl;
-
-class SingletonFactory : public MutexHolder, public t_impl
-{
- ::rtl::Reference< ::jvmaccess::UnoVirtualMachine > m_vm_access;
-
-protected:
- virtual void SAL_CALL disposing();
-
-public:
- inline SingletonFactory( ::rtl::Reference< ::jvmaccess::UnoVirtualMachine > const & vm_access )
- : t_impl( m_mutex ),
- m_vm_access( vm_access )
- {}
-
- // XSingleComponentFactory impl
- virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstanceWithContext(
- css::uno::Reference< css::uno::XComponentContext > const & xContext )
- throw (css::uno::Exception);
- virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstanceWithArgumentsAndContext(
- css::uno::Sequence< css::uno::Any > const & args, css::uno::Reference< css::uno::XComponentContext > const & xContext )
- throw (css::uno::Exception);
-};
-
-void SingletonFactory::disposing()
-{
- m_vm_access.clear();
-}
-
-css::uno::Reference< css::uno::XInterface > SingletonFactory::createInstanceWithContext(
- css::uno::Reference< css::uno::XComponentContext > const & xContext )
- throw (css::uno::Exception)
-{
- sal_Int64 handle = reinterpret_cast< sal_Int64 >( m_vm_access.get() );
- css::uno::Any arg(
- css::uno::makeAny(
- css::beans::NamedValue(
- rtl::OUString(
- RTL_CONSTASCII_USTRINGPARAM( "UnoVirtualMachine" ) ),
- css::uno::makeAny( handle ) ) ) );
- return xContext->getServiceManager()->createInstanceWithArgumentsAndContext(
- ::rtl::OUString(
- RTL_CONSTASCII_USTRINGPARAM(
- "com.sun.star.java.JavaVirtualMachine")),
- css::uno::Sequence< css::uno::Any >( &arg, 1 ), xContext );
-}
-
-css::uno::Reference< css::uno::XInterface > SingletonFactory::createInstanceWithArgumentsAndContext(
- css::uno::Sequence< css::uno::Any > const & args, css::uno::Reference< css::uno::XComponentContext > const & xContext )
- throw (css::uno::Exception)
-{
- return xContext->getServiceManager()->createInstanceWithArgumentsAndContext(
- ::rtl::OUString(
- RTL_CONSTASCII_USTRINGPARAM(
- "com.sun.star.java.JavaVirtualMachine")),
- args, xContext );
-}
-
-}
-
-namespace javaunohelper {
-
-::rtl::Reference< ::jvmaccess::UnoVirtualMachine > create_vm_access(
- JNIEnv * jni_env, jobject loader )
-{
- JavaVM * vm;
- jni_env->GetJavaVM( &vm );
- try {
- return new ::jvmaccess::UnoVirtualMachine(
- new ::jvmaccess::VirtualMachine(
- vm, JNI_VERSION_1_2, false, jni_env ),
- loader );
- } catch ( ::jvmaccess::UnoVirtualMachine::CreationException & ) {
- throw css::uno::RuntimeException(
- ::rtl::OUString(
- RTL_CONSTASCII_USTRINGPARAM(
- "jmvaccess::UnoVirtualMachine::CreationException"
- " occurred" ) ),
- css::uno::Reference< css::uno::XInterface >() );
- }
-}
-
-css::uno::Reference< css::uno::XComponentContext > install_vm_singleton(
- css::uno::Reference< ::css::uno::XComponentContext > const & xContext,
- ::rtl::Reference< ::jvmaccess::UnoVirtualMachine > const & vm_access )
-{
- css::uno::Reference< css::lang::XSingleComponentFactory > xFac( new SingletonFactory( vm_access ) );
- ::cppu::ContextEntry_Init entry(
- ::rtl::OUString(
- RTL_CONSTASCII_USTRINGPARAM(
- "/singletons/com.sun.star.java.theJavaVirtualMachine")),
- css::uno::makeAny( xFac ), true );
- return ::cppu::createComponentContext( &entry, 1, xContext );
-}
-
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/javaunohelper/source/vm.hxx b/javaunohelper/source/vm.hxx
deleted file mode 100644
index 21620fa1d..000000000
--- a/javaunohelper/source/vm.hxx
+++ /dev/null
@@ -1,58 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-#ifndef INCLUDED_JAVAUNOHELPER_SOURCE_VM_HXX
-#define INCLUDED_JAVAUNOHELPER_SOURCE_VM_HXX
-
-#include "sal/config.h"
-
-#include "jni.h"
-#include "com/sun/star/uno/Reference.hxx"
-#include "rtl/ref.hxx"
-
-namespace com { namespace sun { namespace star { namespace uno {
- class XComponentContext;
-} } } }
-namespace jvmaccess { class UnoVirtualMachine; }
-
-namespace javaunohelper {
-
-::rtl::Reference< ::jvmaccess::UnoVirtualMachine > create_vm_access(
- JNIEnv * jni_env, jobject loader );
-
-::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >
-install_vm_singleton(
- ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >
- const & xContext,
- ::rtl::Reference< ::jvmaccess::UnoVirtualMachine > const & vm_access );
-
-}
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/javaunohelper/test/com/sun/star/comp/helper/Bootstrap_Test.java b/javaunohelper/test/com/sun/star/comp/helper/Bootstrap_Test.java
deleted file mode 100644
index 3fe9bd53b..000000000
--- a/javaunohelper/test/com/sun/star/comp/helper/Bootstrap_Test.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-package com.sun.star.comp.helper;
-
-import com.sun.star.uno.UnoRuntime;
-import com.sun.star.uno.AnyConverter;
-
-import com.sun.star.uno.XComponentContext;
-import com.sun.star.lang.XComponent;
-import com.sun.star.lang.XMultiServiceFactory;
-
-
-public class Bootstrap_Test {
-
- static public boolean test( String ini_file, java.util.Hashtable bootstrap_parameters )
- throws java.lang.Exception
- {
- boolean passed = false;
- System.err.println();
- System.out.println("*******************************************************************");
- System.err.println("Bootstrap - doing tests...");
- System.err.println();
-
- try {
- XComponentContext xContext =
- com.sun.star.comp.helper.Bootstrap.defaultBootstrap_InitialComponentContext(
- ini_file, bootstrap_parameters );
-
- if (AnyConverter.isVoid(
- xContext.getValueByName(
- "/singletons/com.sun.star.reflection.theTypeDescriptionManager" ) ))
- {
- throw new Exception(
- "no /singletons/com.sun.star.reflection.theTypeDescriptionManager!" );
- }
-
- XMultiServiceFactory msf = UnoRuntime.queryInterface(
- XMultiServiceFactory.class, xContext.getServiceManager() );
- String services[] = msf.getAvailableServiceNames();
- System.out.println("Available services are:");
- System.err.println();
- if (services.length == 0)
- System.out.println("No services avialable!");
-
- else
- for ( int i=0; i<services.length; i++ )
- System.out.println(services[i]);
-
- XComponent xComp = UnoRuntime.queryInterface(
- XComponent.class, xContext );
- xComp.dispose();
-
- passed = true;
- }
- catch (Exception e) {
- e.printStackTrace();
- }
- System.err.println();
- System.err.println("Bootstrap test passed? " + passed);
- System.out.println("*******************************************************************");
- System.err.println();
- return passed;
- }
-
- private static void usage() {
- System.out.println();
- System.out.println("usage:");
- System.out.println("java com.sun.star.comp.helper.Bootstrap_Test ini-file name=value ...");
- System.out.println("example:");
- System.out.println("java com.sun.star.comp.helper.Bootstrap_Test file:///c:/ooo10/program/uno.ini SYSBINDIR=file:///c:/ooo10/program");
- System.exit( -1 );
- }
-
- static public void main(String args[]) throws java.lang.Exception {
- if ( args.length == 0 )
- usage();
-
- java.util.Hashtable bootstrap_parameters = new java.util.Hashtable();
- for ( int nPos = 1; nPos < args.length; ++nPos )
- {
- String arg = args[ nPos ];
- int n = arg.indexOf( '=' );
- if (n > 0)
- {
- bootstrap_parameters.put( arg.substring( 0, n ), arg.substring( n +1 ) );
- }
- }
-
- System.exit( test(args[0], bootstrap_parameters) == true ? 0: -1 );
- }
-}
-
diff --git a/javaunohelper/test/com/sun/star/comp/helper/ComponentContext_Test.java b/javaunohelper/test/com/sun/star/comp/helper/ComponentContext_Test.java
deleted file mode 100644
index f38ecf543..000000000
--- a/javaunohelper/test/com/sun/star/comp/helper/ComponentContext_Test.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-package com.sun.star.comp.helper;
-
-import com.sun.star.uno.XComponentContext;
-import com.sun.star.lang.XComponent;
-import com.sun.star.lang.XMultiComponentFactory;
-
-import com.sun.star.comp.helper.ComponentContext;
-import com.sun.star.comp.helper.ComponentContextEntry;
-import com.sun.star.uno.UnoRuntime;
-
-import java.util.Hashtable;
-
-
-public class ComponentContext_Test {
- public static void main(String args[]) {
- try {
- Hashtable table = new Hashtable();
- table.put( "bla1", new ComponentContextEntry( null, new Integer( 1 ) ) );
- XComponentContext xInitialContext = Bootstrap.createInitialComponentContext( table );
-
- table = new Hashtable();
- table.put( "bla2", new ComponentContextEntry( new Integer( 2 ) ) );
- table.put( "bla3", new Integer( 3 ) );
- XComponentContext xContext = new ComponentContext( table, xInitialContext );
-
- XMultiComponentFactory xSMgr = xContext.getServiceManager();
- Object o = xSMgr.createInstanceWithContext( "com.sun.star.loader.Java", xContext );
- if (o == null)
- System.err.println( "### failed raising service: 1!" );
- o = xSMgr.createInstanceWithContext( "com.sun.star.bridge.BridgeFactory", xContext );
- if (o == null)
- System.err.println( "### failed raising service: 2!" );
- o = xSMgr.createInstanceWithContext( "com.sun.star.bridge.UnoUrlResolver", xContext );
- if (o == null)
- System.err.println( "### failed raising service: 3!" );
- o = xSMgr.createInstanceWithContext( "com.sun.star.connection.Connector", xContext );
- if (o == null)
- System.err.println( "### failed raising service: 4!" );
- o = xSMgr.createInstanceWithContext( "com.sun.star.connection.Acceptor", xContext );
- if (o == null)
- System.err.println( "### failed raising service: 5!" );
- o = xSMgr.createInstanceWithContext( "com.sun.star.lang.ServiceManager", xContext );
- if (o == null)
- System.err.println( "### failed raising service: 6!" );
-
- if (xContext.getValueByName( "bla1" ) == null ||
- xContext.getValueByName( "bla2" ) == null ||
- xContext.getValueByName( "bla3" ) == null ||
- xInitialContext.getValueByName( "bla2" ) != null ||
- xInitialContext.getValueByName( "bla3" ) != null)
- {
- System.err.println( "### bootstrap context test failed: 1!" );
- }
- if (((Integer)xContext.getValueByName( "bla1" )).intValue() != 1 ||
- ((Integer)xContext.getValueByName( "bla2" )).intValue() != 2 ||
- ((Integer)xContext.getValueByName( "bla3" )).intValue() != 3 ||
- ((Integer)xInitialContext.getValueByName( "bla1" )).intValue() != 1)
- {
- System.err.println( "### bootstrap context test failed: 2!" );
- }
-
- XComponent xComp = UnoRuntime.queryInterface(
- XComponent.class, xInitialContext );
- xComp.dispose();
- }
- catch(Exception exception) {
- System.err.println("exception occurred:" + exception);
- exception.printStackTrace();
- }
- }
-}
-
-
diff --git a/javaunohelper/test/com/sun/star/comp/helper/RegistryServiceFactory_Test.java b/javaunohelper/test/com/sun/star/comp/helper/RegistryServiceFactory_Test.java
deleted file mode 100644
index 18a0cac49..000000000
--- a/javaunohelper/test/com/sun/star/comp/helper/RegistryServiceFactory_Test.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-package com.sun.star.comp.helper;
-
-import com.sun.star.comp.loader.JavaLoader;
-
-import com.sun.star.comp.servicemanager.ServiceManager;
-import com.sun.star.uno.UnoRuntime;
-
-import com.sun.star.container.XSet;
-import com.sun.star.container.XContentEnumerationAccess;
-import com.sun.star.container.XEnumeration;
-import com.sun.star.container.XEnumerationAccess;
-import com.sun.star.container.XElementAccess;
-
-import com.sun.star.lang.XComponent;
-
-import com.sun.star.lang.XServiceInfo;
-import com.sun.star.lang.XMultiServiceFactory;
-import com.sun.star.lang.XSingleServiceFactory;
-import com.sun.star.lang.XInitialization;
-
-import com.sun.star.loader.XImplementationLoader;
-
-import com.sun.star.registry.XSimpleRegistry;
-
-public class RegistryServiceFactory_Test {
-
- static public boolean test(String applicat) throws java.lang.Exception {
- boolean passed = false;
- System.err.println();
- System.out.println("*******************************************************************");
- System.err.println("RegistryServiceFactory - doing tests...");
- System.err.println();
-
- try {
- XMultiServiceFactory msf = RegistryServiceFactory.create( applicat );
- String services[] = msf.getAvailableServiceNames();
- System.out.println("Available services are:");
- System.err.println();
- if (services.length == 0)
- System.out.println("No services avialable!");
-
- else
- for ( int i=0; i<services.length; i++ )
- System.out.println(services[i]);
-
- passed = true;
- }
- catch (Exception e) {
- e.printStackTrace();
- }
- System.err.println();
- System.err.println("RegistryServiceFactory test passed? " + passed);
- System.out.println("*******************************************************************");
- System.err.println();
- return passed;
- }
-
- private static void usage() {
- System.out.println();
- System.out.println("usage:");
- System.out.println("java com.sun.star.comp.helper.RegistryServiceFactory [rdb-file]");
- System.out.println("example:");
- System.out.println("java com.sun.star.comp.helper.RegistryServiceFactory c:\\applicat.rdb");
- System.exit( -1 );
- }
-
- static public void main(String args[]) throws java.lang.Exception {
- if ( args.length != 1 )
- usage();
- System.exit( test(args[0]) == true ? 0: -1 );
- }
-}
-
diff --git a/javaunohelper/test/com/sun/star/comp/helper/SharedLibraryLoader_Test.java b/javaunohelper/test/com/sun/star/comp/helper/SharedLibraryLoader_Test.java
deleted file mode 100644
index b417c2544..000000000
--- a/javaunohelper/test/com/sun/star/comp/helper/SharedLibraryLoader_Test.java
+++ /dev/null
@@ -1,194 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-package com.sun.star.comp.helper;
-
-import com.sun.star.comp.loader.JavaLoader;
-
-import com.sun.star.comp.servicemanager.ServiceManager;
-import com.sun.star.uno.UnoRuntime;
-
-import com.sun.star.container.XSet;
-import com.sun.star.container.XContentEnumerationAccess;
-import com.sun.star.container.XEnumeration;
-import com.sun.star.container.XEnumerationAccess;
-import com.sun.star.container.XElementAccess;
-
-import com.sun.star.lang.XComponent;
-
-import com.sun.star.lang.XServiceInfo;
-import com.sun.star.lang.XMultiServiceFactory;
-import com.sun.star.lang.XSingleServiceFactory;
-import com.sun.star.lang.XInitialization;
-
-import com.sun.star.loader.XImplementationLoader;
-
-import com.sun.star.registry.XSimpleRegistry;
-
-
-public class SharedLibraryLoader_Test {
-
- private static final String NATIVE_SERVICE_MANAGER_IMP_NAME = "com.sun.star.comp.stoc.OServiceManager";
- private static final String NATIVE_SERVICE_MANAGER_LIB_NAME = "servicemgr.uno";
- private static final String NATIVE_REGISTRY_IMP_NAME = "com.sun.star.comp.stoc.SimpleRegistry";
- private static final String NATIVE_REGISTRY_LIB_NAME = "simplereg.uno";
-
- private static XMultiServiceFactory nativeServiceManager = null;
- private static XSingleServiceFactory sharedLibraryLoaderFactory = null;
- private static XImplementationLoader sharedLibraryLoader = null;
- private static XSimpleRegistry simpleRegistry = null;
-
- static public boolean test_getSharedLibraryLoaderFactory()
- throws java.lang.Exception
- {
- sharedLibraryLoaderFactory = null;
- System.out.println("*******************************************************************");
- System.out.println("Test: <<< get SharedLibraryLoader factory >>>");
- sharedLibraryLoaderFactory = SharedLibraryLoader.getServiceFactory(null, null);
-
- System.out.print("Test - ");
- System.out.println(sharedLibraryLoaderFactory == null? "failed" : "successfull");
- System.out.println("*******************************************************************");
- System.out.println();
-
- return sharedLibraryLoaderFactory != null;
- }
-
- static public boolean test_instantiateSharedLibraryLoader()
- throws java.lang.Exception
- {
- sharedLibraryLoader = null;
- System.out.println("*******************************************************************");
- System.out.println("Test: <<< instantiate SharedLibraryLoader >>>");
- if ( sharedLibraryLoaderFactory == null )
- if ( ! test_getSharedLibraryLoaderFactory() )
- return false;
-
- sharedLibraryLoader = UnoRuntime.queryInterface(
- XImplementationLoader.class, sharedLibraryLoaderFactory.createInstance() );
-
- System.out.print("Test - ");
- System.out.println(sharedLibraryLoader == null? "failed" : "successfull");
- System.out.println("*******************************************************************");
- System.out.println();
-
- return sharedLibraryLoader != null;
- }
-
- static public boolean test_loadNativeServiceManager()
- throws java.lang.Exception
- {
- nativeServiceManager = null;
-
- System.out.println("*******************************************************************");
- System.out.println("Test: <<< load native ServiceManager >>>");
- if ( sharedLibraryLoader == null )
- if ( ! test_instantiateSharedLibraryLoader() )
- return false;
-
- System.err.println("- get the native ServiceManger factory");
- XSingleServiceFactory aSMgrFac =
- UnoRuntime.queryInterface( XSingleServiceFactory.class,
- sharedLibraryLoader.activate(NATIVE_SERVICE_MANAGER_IMP_NAME, null, NATIVE_SERVICE_MANAGER_LIB_NAME, null));
-
- System.err.println("- instantiate the native ServiceManger");
- nativeServiceManager = UnoRuntime.queryInterface( XMultiServiceFactory.class, aSMgrFac.createInstance() );
-
- System.out.print("Test - ");
- System.out.println(nativeServiceManager == null? "failed" : "successfull");
-
- System.out.println("*******************************************************************");
- System.out.println();
- return nativeServiceManager != null;
- }
-
- static public boolean test_loadNativeSimpleRegistry()
- throws java.lang.Exception
- {
- boolean result = false;
- System.out.println("*******************************************************************");
- System.out.println("Test: <<< load native SimpleRegistry >>>");
- if ( sharedLibraryLoader == null )
- if ( ! test_instantiateSharedLibraryLoader() )
- return false;
-
- System.err.println("- get factory of the Registry");
- XSingleServiceFactory aRegFac =
- UnoRuntime.queryInterface( XSingleServiceFactory.class,
- sharedLibraryLoader.activate(NATIVE_REGISTRY_IMP_NAME, null, NATIVE_REGISTRY_LIB_NAME, null)
- );
- System.err.println("- instantiate the Registry");
- simpleRegistry =
- UnoRuntime.queryInterface( XSimpleRegistry.class, aRegFac.createInstance() );
- System.out.print("Test - ");
- System.out.println(simpleRegistry == null? "failed" : "successfull");
- System.out.println("*******************************************************************");
- System.err.println();
- return true;
- }
-
- static public boolean test_registerSharedLibraryLoader()
- throws java.lang.Exception
- {
- boolean result = true;
- System.out.println("*******************************************************************");
- System.out.println("Test: <<< register SharedLibraryLoader at the Registry >>>");
-
- if ( simpleRegistry == null )
- if ( ! test_loadNativeSimpleRegistry() )
- return false;
-
- com.sun.star.registry.XRegistryKey regKey = simpleRegistry.getRootKey();
- result = SharedLibraryLoader.writeRegistryServiceInfo( null, regKey );
-
- System.out.print("Test - ");
- System.out.println( result==false ? "failed" : "successfull");
- System.out.println("*******************************************************************");
- System.out.println();
- return result;
- }
-
- static public boolean test() throws java.lang.Exception {
- boolean passed = true;
-
- System.err.println("SharedLibraryLoader - doing tests...");
- passed = test_getSharedLibraryLoaderFactory() && passed;
- passed = test_instantiateSharedLibraryLoader() && passed;
- passed = test_loadNativeServiceManager() && passed;
- passed = test_loadNativeSimpleRegistry() && passed;
- //passed = test_registerSharedLibraryLoader() && passed;
-
- System.err.println("SharedLibraryLoader test passed? " + passed);
-
- return passed;
- }
-
- static public void main(String args[]) throws java.lang.Exception {
- System.exit( test() == true ? 0: -1 );
- }
-}
-
diff --git a/javaunohelper/test/com/sun/star/comp/helper/makefile.mk b/javaunohelper/test/com/sun/star/comp/helper/makefile.mk
deleted file mode 100644
index 5f00fac98..000000000
--- a/javaunohelper/test/com/sun/star/comp/helper/makefile.mk
+++ /dev/null
@@ -1,52 +0,0 @@
-#*************************************************************************
-#
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# Copyright 2000, 2010 Oracle and/or its affiliates.
-#
-# OpenOffice.org - a multi-platform office productivity suite
-#
-# This file is part of OpenOffice.org.
-#
-# OpenOffice.org is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Lesser General Public License version 3
-# only, as published by the Free Software Foundation.
-#
-# OpenOffice.org is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Lesser General Public License version 3 for more details
-# (a copy is included in the LICENSE file that accompanied this code).
-#
-# You should have received a copy of the GNU Lesser General Public License
-# version 3 along with OpenOffice.org. If not, see
-# <http://www.openoffice.org/license.html>
-# for a copy of the LGPLv3 License.
-#
-#*************************************************************************
-
-PRJ =..$/..$/..$/..$/..$/..
-PRJNAME = juhelper
-PACKAGE = com$/sun$/star$/comp$/helper
-TARGET = com_sun_star_comp_helper_test
-
-# --- Settings -----------------------------------------------------
-
-.INCLUDE : settings.mk
-
-# --- Files --------------------------------------------------------
-
-JARFILES = jurt.jar ridl.jar
-
-JAVACLASSFILES= \
- $(CLASSDIR)$/$(PACKAGE)$/ComponentContext_Test.class \
- $(CLASSDIR)$/$(PACKAGE)$/SharedLibraryLoader_Test.class \
- $(CLASSDIR)$/$(PACKAGE)$/RegistryServiceFactory_Test.class \
- $(CLASSDIR)$/$(PACKAGE)$/Bootstrap_Test.class
-
-JAVAFILES= $(subst,$(CLASSDIR)$/$(PACKAGE)$/, $(subst,.class,.java $(JAVACLASSFILES)))
-
-# --- Targets ------------------------------------------------------
-
-.INCLUDE : target.mk
-
diff --git a/javaunohelper/test/com/sun/star/lib/uno/helper/AWeakBase.java b/javaunohelper/test/com/sun/star/lib/uno/helper/AWeakBase.java
deleted file mode 100644
index 262c13dcf..000000000
--- a/javaunohelper/test/com/sun/star/lib/uno/helper/AWeakBase.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-package com.sun.star.lib.uno.helper;
-import com.sun.star.lang.XEventListener;
-
-
-public class AWeakBase extends WeakBase implements XEventListener
-{
- public int nDisposingCalled= 0;
-
- public AWeakBase(int i)
- {
- }
- public AWeakBase()
- {
- }
-
- public void disposing(com.sun.star.lang.EventObject eventObject)
- {
-// System.out.println(getClass().getName() + " .disposing called");
- nDisposingCalled++;
- }
-
-}
-
diff --git a/javaunohelper/test/com/sun/star/lib/uno/helper/ComponentBase_Test.java b/javaunohelper/test/com/sun/star/lib/uno/helper/ComponentBase_Test.java
deleted file mode 100644
index 012f98874..000000000
--- a/javaunohelper/test/com/sun/star/lib/uno/helper/ComponentBase_Test.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-package com.sun.star.lib.uno.helper;
-import com.sun.star.uno.XWeak;
-import com.sun.star.lang.XTypeProvider;
-import com.sun.star.uno.UnoRuntime;
-import com.sun.star.lang.XEventListener;
-
-public class ComponentBase_Test
-{
- AWeakBase obj1, obj2, obj3;
- Object proxyObj1Weak1;
- Object proxyObj3Weak1;
- Object proxyObj3Weak2;
- Object proxyObj3TypeProv;
- Object proxyObj2TypeProv;
-
- /** Creates a new instance of ComponentBase_Test */
- public ComponentBase_Test()
- {
- obj1= new AWeakBase();
- obj2= new AWeakBase();
- obj3= new AWeakBase();
- proxyObj1Weak1= ProxyProvider.createProxy(obj1, XWeak.class);
- proxyObj3Weak1= ProxyProvider.createProxy(obj3, XWeak.class);
- proxyObj3Weak2= ProxyProvider.createProxy(obj3, XWeak.class);
- proxyObj2TypeProv= ProxyProvider.createProxy(obj2, XTypeProvider.class);
- proxyObj3TypeProv= ProxyProvider.createProxy(obj3, XTypeProvider.class);
- }
-
- public boolean dispose()
- {
- System.out.println("Testing ComponentBase");
- ComponentBase comp= new ComponentBase();
- boolean r[]= new boolean[50];
- int i= 0;
- // addEventListener
-
- comp.addEventListener(obj1);
- comp.addEventListener(obj2);
- comp.addEventListener(obj3);
- comp.addEventListener(UnoRuntime.queryInterface(XEventListener.class, proxyObj1Weak1));
- comp.addEventListener(UnoRuntime.queryInterface(XEventListener.class, proxyObj3Weak2));
- comp.addEventListener(UnoRuntime.queryInterface(XEventListener.class, proxyObj3TypeProv));
- obj1.nDisposingCalled = 0;
- obj2.nDisposingCalled = 0;
- obj3.nDisposingCalled = 0;
-
- comp.dispose();
- r[i++]= obj1.nDisposingCalled == 1;
- r[i++]= obj2.nDisposingCalled == 1;
- r[i++]= obj3.nDisposingCalled == 1;
- // adding a listener after dispose, causes a immediate call to the listerner
- obj1.nDisposingCalled= 0;
- comp.addEventListener(obj1);
- r[i++]= obj1.nDisposingCalled == 1;
- //calling dispose again must not notify the listeners again
- obj1.nDisposingCalled= 0;
- obj2.nDisposingCalled= 0;
- obj3.nDisposingCalled= 0;
- comp.dispose(); // allready disposed;
- r[i++]= obj1.nDisposingCalled == 0;
-
- boolean bOk= true;
- for (int c= 0; c < i; c++)
- bOk= bOk && r[c];
- if (bOk == false)
- System.out.println("Failed");
- else
- System.out.println("Ok");
- return bOk;
- }
-
- public boolean test_finalize()
- {
- System.out.println("Testing ComponentBase");
- ComponentBase comp= new ComponentBase();
- boolean r[]= new boolean[50];
- int i= 0;
- obj1.nDisposingCalled = 0;
- comp.addEventListener(obj1);
-
- comp= null;
- System.out.println("Waiting 10s");
- for(int c= 0; c < 100; c++)
- {
- try
- {
- Thread.currentThread().sleep(100);
- System.gc();
- System.runFinalization();
- }catch (InterruptedException ie)
- {
- }
- }
- r[i++]= obj1.nDisposingCalled == 1;
-
- boolean bOk= true;
- for (int c= 0; c < i; c++)
- bOk= bOk && r[c];
- if (bOk == false)
- System.out.println("Failed");
- else
- System.out.println("Ok");
- return bOk;
- }
-
- public static void main(String[] args)
- {
- ComponentBase_Test test= new ComponentBase_Test();
-
- boolean r[]= new boolean[50];
- int i= 0;
- r[i++]= test.dispose();
- r[i++]= test.test_finalize();
-
- boolean bOk= true;
- for (int c= 0; c < i; c++)
- bOk= bOk && r[c];
- if (bOk == false)
- System.out.println("Errors occurred!");
- else
- System.out.println("No errors.");
-
- }
-
-}
-
diff --git a/javaunohelper/test/com/sun/star/lib/uno/helper/Factory_Test.java b/javaunohelper/test/com/sun/star/lib/uno/helper/Factory_Test.java
deleted file mode 100644
index b1268f7ed..000000000
--- a/javaunohelper/test/com/sun/star/lib/uno/helper/Factory_Test.java
+++ /dev/null
@@ -1,207 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-package com.sun.star.lib.uno.helper;
-
-import com.sun.star.uno.XComponentContext;
-import com.sun.star.uno.Type;
-import com.sun.star.uno.AnyConverter;
-import com.sun.star.lang.XServiceInfo;
-import com.sun.star.lang.XSingleComponentFactory;
-import com.sun.star.lang.XMultiServiceFactory;
-import com.sun.star.lang.XComponent;
-import com.sun.star.beans.XPropertySet;
-import com.sun.star.registry.XRegistryKey;
-import com.sun.star.registry.XSimpleRegistry;
-import com.sun.star.registry.XImplementationRegistration;
-import com.sun.star.container.XSet;
-
-import com.sun.star.lib.uno.helper.Factory;
-import com.sun.star.comp.helper.Bootstrap;
-import com.sun.star.comp.helper.RegistryServiceFactory;
-import com.sun.star.uno.UnoRuntime;
-
-
-//==================================================================================================
-public class Factory_Test
- extends WeakBase
- implements XServiceInfo
-{
- static final String m_impl_name = Factory_Test.class.getName();
- static final String m_supported_services [] = {
- "Factory_Test.Service0", "Factory_Test.Service1" };
-
- //______________________________________________________________________________________________
- public Factory_Test()
- {
- }
- //______________________________________________________________________________________________
- public Factory_Test( XComponentContext xContext )
- throws com.sun.star.uno.Exception
- {
- if (null == xContext.getValueByName( "/singletons/com.sun.star.lang.theServiceManager" ))
- {
- throw new com.sun.star.uno.RuntimeException(
- "bad component context given!", this );
- }
- }
- //______________________________________________________________________________________________
- public static Object __create( XComponentContext xContext )
- throws com.sun.star.uno.Exception
- {
- return new Factory_Test( xContext );
- }
-
- // XServiceInfo impl
- //______________________________________________________________________________________________
- public final String getImplementationName()
- {
- return m_impl_name;
- }
- //______________________________________________________________________________________________
- public final boolean supportsService( String service_name )
- {
- for ( int nPos = 0; nPos < m_supported_services.length; ++nPos )
- {
- if (m_supported_services[ nPos ].equals( service_name ))
- return true;
- }
- return false;
- }
- //______________________________________________________________________________________________
- public final String [] getSupportedServiceNames()
- {
- return m_supported_services;
- }
-
- //==============================================================================================
- public static XSingleComponentFactory __getComponentFactory( String implName )
- {
- if (implName.equals( m_impl_name ))
- {
- return Factory.createComponentFactory(
- Factory_Test.class, Factory_Test.m_supported_services );
- }
- return null;
- }
- //==============================================================================================
- public static boolean __writeRegistryServiceInfo( XRegistryKey xKey )
- {
- return Factory.writeRegistryServiceInfo(
- m_impl_name, Factory_Test.m_supported_services, xKey );
- }
-
- //==============================================================================================
- static void service_info_test( Object inst )
- {
- XServiceInfo xInfo = UnoRuntime.queryInterface( XServiceInfo.class, inst );
-
- if (! xInfo.getImplementationName().equals( m_impl_name ))
- {
- System.err.println( "Factory_Test: err -- 1" );
- System.exit( 1 );
- }
- String supported_services [] = xInfo.getSupportedServiceNames();
- if (supported_services.length != m_supported_services.length)
- {
- System.err.println( "Factory_Test: err -- 2" );
- System.exit( 1 );
- }
- for ( int nPos = 0; nPos < supported_services.length; ++nPos )
- {
- if (! supported_services[ nPos ].equals( m_supported_services[ nPos ] ))
- {
- System.err.println( "Factory_Test: err -- 3" );
- System.exit( 1 );
- }
- if (! xInfo.supportsService( m_supported_services[ nPos ] ))
- {
- System.err.println( "Factory_Test: err -- 4" );
- System.exit( 1 );
- }
- }
- }
- //==============================================================================================
- public static void main( String args [] )
- {
- try
- {
- String jar = "file://" + new java.io.File( args[ 0 ] ).toURL().getPath();
- String rdb = "file://" + new java.io.File( args[ 1 ] ).toURL().getPath();
- System.out.println( "jar file = " + jar );
- System.out.println( "rdb file = " + rdb );
-
- // bootstrap service manager
- XMultiServiceFactory xMgr = RegistryServiceFactory.create( rdb );
- XPropertySet xProps = UnoRuntime.queryInterface(
- XPropertySet.class, xMgr );
- XComponentContext xContext = (XComponentContext)AnyConverter.toObject(
- new Type( XComponentContext.class ), xProps.getPropertyValue( "DefaultContext" ) );
- // insert java loader
- XSet xSet = (XSet)AnyConverter.toObject(
- new Type( XSet.class ), xContext.getServiceManager() );
- xSet.insert( new com.sun.star.comp.loader.JavaLoaderFactory( xMgr ) );
- // get rdb of smgr
- XSimpleRegistry xRDB = (XSimpleRegistry)AnyConverter.toObject(
- new Type( XSimpleRegistry.class ), xProps.getPropertyValue( "Registry" ) );
- // register impl
- XImplementationRegistration xImpReg =
- UnoRuntime.queryInterface(
- XImplementationRegistration.class,
- xContext.getServiceManager().createInstanceWithContext(
- "com.sun.star.registry.ImplementationRegistration", xContext ) );
- xImpReg.registerImplementation( "com.sun.star.loader.Java2", jar, xRDB );
-
- // tests
- System.out.println( "testing instance" );
- service_info_test( new Factory_Test() );
- System.out.println( "testing instance" );
- service_info_test( new Factory_Test( xContext ) );
- System.out.println( "testing instance" );
- service_info_test( Factory_Test.__create( xContext ) );
- System.out.println( "testing factory __getComponentFactory()" );
- service_info_test( __getComponentFactory( m_impl_name ) );
- for ( int nPos = 0; nPos < m_supported_services.length; ++nPos )
- {
- System.out.println( "testing factory " + m_supported_services[ nPos ] );
- service_info_test(
- // create Service
- xContext.getServiceManager().createInstanceWithContext(
- m_supported_services[ nPos ], xContext ) );
- }
-
- XComponent xComp = UnoRuntime.queryInterface( XComponent.class, xContext );
- xComp.dispose();
- }
- catch (Exception exc)
- {
- System.err.println( ">>>>>>>>>> exc occurred: " + exc.toString() );
- exc.printStackTrace();
- }
- System.exit( 0 );
- }
-}
-
diff --git a/javaunohelper/test/com/sun/star/lib/uno/helper/InterfaceContainer_Test.java b/javaunohelper/test/com/sun/star/lib/uno/helper/InterfaceContainer_Test.java
deleted file mode 100644
index cd83005cb..000000000
--- a/javaunohelper/test/com/sun/star/lib/uno/helper/InterfaceContainer_Test.java
+++ /dev/null
@@ -1,992 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-package com.sun.star.lib.uno.helper;
-
-import com.sun.star.uno.XInterface;
-import java.util.Iterator;
-import java.util.ListIterator;
-import com.sun.star.uno.Type;
-import com.sun.star.uno.XWeak;
-import com.sun.star.lang.XTypeProvider;
-import com.sun.star.lang.XEventListener;
-import java.util.ArrayList;
-import com.sun.star.lang.XMultiComponentFactory;
-import com.sun.star.uno.XComponentContext;
-import com.sun.star.comp.helper.Bootstrap;
-import com.sun.star.bridge.XUnoUrlResolver;
-import com.sun.star.uno.UnoRuntime;
-import com.sun.star.lang.XMultiServiceFactory;
-import com.sun.star.lang.XSingleServiceFactory;
-import com.sun.star.uno.IQueryInterface;
-//import com.sun.star.lib.uno.environments.java.IRequester;
-import com.sun.star.bridge.XBridge;
-//import com.sun.star.lib.uno.environments.java.Proxy;
-import com.sun.star.lib.uno.environments.java.java_environment;
-import com.sun.star.lib.uno.typedesc.TypeDescription;
-import java.util.HashMap;
-import java.util.List;
-import java.util.NoSuchElementException;
-
-public class InterfaceContainer_Test
-{
- java_environment env= new java_environment(null);
- /** Creates a new instance of InterfaceContainerTest */
- AWeakBase obj1,obj2,obj3,obj4;
- Object proxyObj1Weak1;
- Object proxyObj3Weak1;
- Object proxyObj3Weak2;
- Object proxyObj3TypeProv;
- Object proxyObj2TypeProv;
- //contains original objects
- List list1;
- //contains original objects + proxies
- List list2;
- //contains original object + proxies + null value
- List list3;
-
- public InterfaceContainer_Test()
- {
- obj1= new AWeakBase();
- obj2= new AWeakBase();
- obj3= new AWeakBase();
- obj4= new AWeakBase();
- proxyObj1Weak1= ProxyProvider.createProxy(obj1, XWeak.class);
- proxyObj3Weak1= ProxyProvider.createProxy(obj3, XWeak.class);
- proxyObj3Weak2= ProxyProvider.createProxy(obj3, XWeak.class);
- proxyObj2TypeProv= ProxyProvider.createProxy(obj2, XTypeProvider.class);
- proxyObj3TypeProv= ProxyProvider.createProxy(obj3, XTypeProvider.class);
-
- list1= new ArrayList();
- list1.add(obj1);
- list1.add(obj2);
- list1.add(obj3);
- list2= new ArrayList();
- list2.add(obj1);
- list2.add(proxyObj2TypeProv);
- list2.add(proxyObj3TypeProv);
- list3= new ArrayList();
- list3.add(obj1);
- list3.add(null);
- list3.add(proxyObj2TypeProv);
- list3.add(proxyObj3Weak1);
- }
-
- /** Tests add(object), size(), clear();
- */
- public boolean add()
- {
- System.out.println("Testing List.add(Object), List.size(), List.clear(), List.isEmpty()");
- InterfaceContainer cont= new InterfaceContainer();
- boolean r[]= new boolean[50];
- int i= 0;
-
- r[i++]= cont.size() == 0;
- r[i++]= cont.add(obj1);
- r[i++]= cont.size() == 1;
- r[i++]= cont.add(obj1); // add the same object again
- r[i++]= cont.size() == 2;
- r[i++]= cont.add(proxyObj3TypeProv);
- r[i++]= cont.size() == 3;
- r[i++]= cont.isEmpty() ? false: true;
- cont.clear();
- r[i++]= cont.size() == 0;
- r[i++]= cont.isEmpty();
-
- boolean bOk= true;
- for (int c= 0; c < i; c++)
- bOk= bOk && r[c];
- if (bOk == false)
- System.out.println("Failed");
- else
- System.out.println("Ok");
- return bOk;
- }
-
- /**Tests list.addAll(Collection c), list.addAll(int index, Collection c)
- */
- public boolean listConstructors()
- {
- System.out.println("Testing Constructors of InterfaceContainer");
- boolean r[]= new boolean[50];
- int i= 0;
- InterfaceContainer cont= new InterfaceContainer(100);
-
- r[i++]= cont.elementData.length == 100;
- boolean bOk= true;
- for (int c= 0; c < i; c++)
- bOk= bOk && r[c];
- if (bOk == false)
- System.out.println("Failed");
- else
- System.out.println("Ok");
- return bOk;
- }
- public boolean trimToSize()
- {
- System.out.println("Testing InterfaceContainer.trimToSize");
- InterfaceContainer cont= new InterfaceContainer(100);
- boolean r[]= new boolean[50];
- int i= 0;
- cont.trimToSize();
- r[i++]= cont.isEmpty();
- cont= new InterfaceContainer(10);
- cont.addAll(list1);
- cont.trimToSize();
- r[i++]= cont.elementData.length == list1.size();
- boolean bOk= true;
- for (int c= 0; c < i; c++)
- bOk= bOk && r[c];
- if (bOk == false)
- System.out.println("Failed");
- else
- System.out.println("Ok");
- return bOk;
- }
- public boolean ensureCapacity()
- {
- System.out.println("Testing InterfaceContainer.ensureCapacity");
- InterfaceContainer cont= new InterfaceContainer(10);
- boolean r[]= new boolean[50];
- int i= 0;
-
- cont.ensureCapacity(9);
- r[i++]= cont.elementData.length >= 9;
- cont.ensureCapacity(11);
- r[i++]= cont.elementData.length >= 11;
- boolean bOk= true;
- for (int c= 0; c < i; c++)
- bOk= bOk && r[c];
- if (bOk == false)
- System.out.println("Failed");
- else
- System.out.println("Ok");
- return bOk;
- }
-
- public boolean addAll()
- {
- System.out.println("Testing List.addAll(Collection c), List.addAll(int index, Collection c)");
- InterfaceContainer cont= new InterfaceContainer();
- boolean r[]= new boolean[50];
- int i= 0;
-
- r[i++]= cont.addAll(list1);
- r[i++]= cont.size() == list1.size();
- for (int c= 0; c < cont.size(); c++)
- {
- r[i++]= list1.get(c) == cont.get(c);
- }
- cont.add(obj1);
- r[i++]= cont.addAll(1, list2);
- r[i++]= cont.get(0) == list1.get(0);
- r[i++]= cont.get(1) == list2.get(0);
- r[i++]= cont.get(2) == list2.get(1);
- r[i++]= cont.get(3) == list2.get(2);
- r[i++]= cont.get(4) == list1.get(1);
- r[i++]= cont.get(5) == list1.get(2);
- r[i++]= cont.get(6) == obj1;
- cont.clear();
- cont.addAll(list3);
- // the null element in list3 at index 1 is not added to cont
- r[i++]= cont.get(0) == list3.get(0);
- r[i++]= cont.get(1) == list3.get(2);
- r[i++]= cont.get(2) == list3.get(3);
-
- boolean bOk= true;
- for (int c= 0; c < i; c++)
- bOk= bOk && r[c];
- if (bOk == false)
- System.out.println("Failed");
- else
- System.out.println("Ok");
- return bOk;
- }
-
- /** Tests List.add(int index, Object element), List.get(int index)
- */
- public boolean get()
- {
- System.out.println("Testing List.add(int index, Object element), List.get(int index)");
- InterfaceContainer cont= new InterfaceContainer();
- boolean r[]= new boolean[50];
- int i= 0;
-
- cont.add(0, obj1);
- cont.add(1, obj2);
- cont.add(1, proxyObj3Weak1);
- cont.add(3, obj3);
- r[i++]= cont.get(0) == obj1;
- r[i++]= cont.get(1) == proxyObj3Weak1;
- r[i++]= cont.get(2) == obj2;
- r[i++]= cont.get(3) == obj3;
- try
- {
- cont.add(5, obj1);
- }catch( java.lang.Exception e)
- {
- r[i++]= true;
- }
-
- boolean bOk= true;
- for (int c= 0; c < i; c++)
- bOk= bOk && r[c];
- if (bOk == false)
- System.out.println("Failed");
- else
- System.out.println("Ok");
- return bOk;
- }
- /** Tests List.contains
- */
- public boolean contains()
- {
- System.out.println("Testing List.contains()");
- InterfaceContainer cont= new InterfaceContainer();
- boolean r[]= new boolean[50];
- int i= 0;
-
- r[i++]= cont.contains(obj1) ? false : true; // nothing in the list
- cont.add(obj1);
- cont.add(proxyObj2TypeProv);
- cont.add(proxyObj3TypeProv);
- r[i++]= cont.contains(obj1);
- r[i++]= cont.contains(obj2);
- r[i++]= cont.contains(proxyObj3Weak1);
- r[i++]= cont.contains(proxyObj3Weak2);
- r[i++]= cont.contains(proxyObj1Weak1);
- r[i++]= cont.contains(obj3);
- r[i++]= cont.contains(null) ? false : true;
-
- boolean bOk= true;
- for (int c= 0; c < i; c++)
- bOk= bOk && r[c];
- if ( ! bOk )
- System.out.println("Failed");
- else
- System.out.println("Ok");
- return bOk;
- }
- /** Tests List.containsAll
- */
- public boolean containsAll()
- {
- System.out.println("Testing List.containsAll");
- InterfaceContainer cont= new InterfaceContainer();
- boolean r[]= new boolean[50];
- int i= 0;
- cont.addAll(list1);
- r[i++]= cont.containsAll(list1);
- cont.clear();
- cont.addAll(list2);
- r[i++]= cont.containsAll(list2);
- cont.clear();
- cont.addAll(list3); // the null element in list3 is not added to cont
- r[i++]= cont.containsAll(list3) ? false : true;
- cont.clear();
- for( int x= 0; x < 6; x++)
- cont.add(obj4);
- r[i++]= cont.contains(list1) ? false : true;
- cont.add(1, list1.get(0));
- cont.add(3, list1.get(1));
- cont.add(5, list1.get(2));
- r[i++]= cont.contains(list1) ? false : true;
-
- boolean bOk= true;
- for (int c= 0; c < i; c++)
- bOk= bOk && r[c];
- if ( ! bOk )
- System.out.println("Failed");
- else
- System.out.println("Ok");
- return bOk;
- }
- /** Tests List.indexOf, List.lastIndexOf
- */
- public boolean indexOf()
- {
- System.out.println("Testing List.indexOf(Object element), List.lastIndexOf(Object element)");
- InterfaceContainer cont= new InterfaceContainer();
- boolean r[]= new boolean[50];
- int i= 0;
- cont.addAll(list1);
- cont.addAll(list1);
- r[i++]= cont.indexOf(obj3) == 2;
- r[i++]= cont.lastIndexOf(obj3) == 5;
- cont.clear();
- cont.addAll(list2);
- cont.addAll(list2);
- r[i++]= cont.indexOf(proxyObj3Weak1) == 2;
- r[i++]= cont.lastIndexOf(proxyObj3Weak2) == 5;
-
- boolean bOk= true;
- for (int c= 0; c < i; c++)
- bOk= bOk && r[c];
- if ( ! bOk )
- System.out.println("Failed");
- else
- System.out.println("Ok");
- return bOk;
- }
-
- /** Tests List.remove(int index), List.remove(Object element), List.removeAll(Collection c)
- */
- public boolean remove()
- {
- System.out.println("Testing List.remove(int index), List.remove(Object element), List.removeAll(Collection c)");
- InterfaceContainer cont= new InterfaceContainer();
- boolean r[]= new boolean[50];
- int i= 0;
-
- cont.addAll(list2);
- r[i++]= proxyObj2TypeProv.equals(cont.remove(1));
- r[i++]= cont.size() == 2;
- cont.clear();
- cont.addAll(list2);
- r[i++]= cont.remove(obj1);
- r[i++]= cont.remove(proxyObj2TypeProv);
- r[i++]= cont.remove(proxyObj3Weak2);
- r[i++]= cont.isEmpty();
- cont.clear();
- cont.addAll(list3);
- r[i++]= cont.removeAll(list3);
- r[i++]= cont.isEmpty();
- cont.addAll(list2);
-
- List list= new ArrayList();
- list.add(list2.get(0));
- list.add(list2.get(1));
- list.add(proxyObj3Weak2);
- r[i++]= cont.removeAll(list);
- r[i++]= cont.isEmpty();
-
- boolean bOk= true;
- for (int c= 0; c < i; c++)
- bOk= bOk && r[c];
- if ( ! bOk )
- System.out.println("Failed");
- else
- System.out.println("Ok");
- return bOk;
- }
-
- /** Tests List.retainAll
- */
- public boolean retainAll()
- {
- System.out.println("Testing List.retainAll(Collection c)");
- InterfaceContainer cont= new InterfaceContainer();
- boolean r[]= new boolean[50];
- int i= 0;
-
- cont.addAll(list1); //obj1, obj2, obj3
- cont.addAll(list2); //obj1, proxyObj2TypeProv, proxyObj3TypeProv
- List list = new ArrayList();
- list.add(obj1);
- list.add(proxyObj3Weak1);
-
- r[i++]= cont.retainAll(list);
- r[i++]= cont.get(0) == obj1;
- r[i++]= cont.get(1) == obj3;
- r[i++]= cont.get(2) == obj1;
- r[i++]= cont.get(3) == proxyObj3TypeProv;
- r[i++]= 4 == cont.size();
-
- boolean bOk= true;
- for (int c= 0; c < i; c++)
- bOk= bOk && r[c];
- if ( ! bOk )
- System.out.println("Failed");
- else
- System.out.println("Ok");
- return bOk;
- }
-
- /** Tests List.set(int index, Object element)
- **/
- public boolean set()
- {
- System.out.println("Testing List.set(int index, Object element)");
- boolean r[]= new boolean[50];
- int i= 0;
- InterfaceContainer cont= new InterfaceContainer();
- cont.addAll(list2);
- Object o1= cont.set(0, obj3);
- Object o2= cont.set(2, proxyObj3Weak1);
- r[i++]= o1 == list2.get(0);
- r[i++]= o2 == list2.get(2);
- r[i++]= cont.get(0) == obj3;
- r[i++]= cont.get(2) == proxyObj3Weak1;
-
- boolean bOk= true;
- for (int c= 0; c < i; c++)
- bOk= bOk && r[c];
- if ( ! bOk )
- System.out.println("Failed");
- else
- System.out.println("Ok");
- return bOk;
- }
-
- /** Tests List.toArray(), List.toArray(Object[] a)
- */
- public boolean toArray()
- {
- System.out.println("Testing List.toArray(), List.toArray(Object[] a)");
- InterfaceContainer cont= new InterfaceContainer();
- boolean r[]= new boolean[50];
- int i= 0;
-
- cont.addAll(list1);
- Object[] ar= cont.toArray();
- Object[] arOrig= list1.toArray();
- r[i++]= ar.length == arOrig.length;
-
- r[i]= true;
- for (int c= 0; c < ar.length; c++)
- r[i]= r[i] && ar[c] == arOrig[c];
-
- i++;
- XWeak[] arWeak= new XWeak[3];
- XWeak[] arWeak2= (XWeak[])cont.toArray(arWeak);
- r[i++]= ar.length == arWeak2.length;
- r[i]= true;
- for (int c= 0; c < ar.length; c++)
- r[i]= r[i] && ar[c] == arWeak2[c];
-
- i++;
-
- boolean bOk= true;
- for (int c= 0; c < i; c++)
- bOk= bOk && r[c];
- if ( ! bOk )
- System.out.println("Failed");
- else
- System.out.println("Ok");
- return bOk;
- }
-
- public boolean Iterator_next()
- {
- System.out.println("Testing InterfaceContainer.iterator, Iterator.next()");
- InterfaceContainer cont= new InterfaceContainer();
- boolean r[]= new boolean[50];
- int i= 0;
-
- cont.addAll(list1);
- Iterator it= cont.iterator();
- r[i++]= it.next() == list1.get(0);
- r[i++]= it.next() == list1.get(1);
- r[i++]= it.next() == list1.get(2);
- try
- {
- it.next();
- }catch(java.util.NoSuchElementException ne)
- {
- r[i++]= true;
- }catch(Exception e)
- {
- r[i++]= false;
- }
-
- boolean bOk= true;
- for (int c= 0; c < i; c++)
- bOk= bOk && r[c];
- if ( ! bOk )
- System.out.println("Failed");
- else
- System.out.println("Ok");
- return bOk;
- }
-
- public boolean Iterator_hasNext()
- {
- System.out.println("Testing, Iterator.next()");
- InterfaceContainer cont= new InterfaceContainer();
- boolean r[]= new boolean[50];
- int i= 0;
-
- Iterator it= cont.iterator();
- r[i++]= ! it.hasNext();
- cont.addAll(list1);
- it= cont.iterator();
- r[i++]= it.hasNext();
- it.next();
- r[i++]= it.hasNext();
- it.next();
- r[i++]= it.hasNext();
- it.next();
- r[i++]= ! it.hasNext();
-
- boolean bOk= true;
- for (int c= 0; c < i; c++)
- bOk= bOk && r[c];
- if ( ! bOk )
- System.out.println("Failed");
- else
- System.out.println("Ok");
- return bOk;
- }
-
- public boolean Iterator_remove()
- {
- System.out.println("Testing, Iterator.remove()");
- InterfaceContainer cont= new InterfaceContainer();
- boolean r[]= new boolean[50];
- int i= 0;
-
- Iterator it= cont.iterator();
- try
- {
- it.remove();
- }
- catch( IllegalStateException ie)
- {
- r[i++]= true;
- }
- catch(java.lang.Exception e)
- {
- r[i++]= false;
- }
- cont.add(obj1);
- it= cont.iterator();
- it.next();
- it.remove();
- r[i++]= cont.isEmpty();
- try
- {
- it.remove();
- }
- catch (IllegalStateException ie)
- {
- r[i++]= true;
- }
- catch (Exception e)
- {
- r[i++]= false;
- }
- cont.clear();
- cont.addAll(list1);
- it= cont.iterator();
- while (it.hasNext())
- {
- it.next();
- it.remove();
- }
- r[i++]= cont.isEmpty();
-
- // 2 iterators, remove must not impair the other iterator
- cont.clear();
- cont.addAll(list1);
- int size= cont.size();
- it= cont.iterator();
- Iterator it2= cont.iterator();
- while (it.hasNext())
- {
- it.next();
- it.remove();
- }
- try
- {
- for( int c= 0; c < size; c++)
- it2.next();
- r[i++]= true;
- }
- catch(Exception e)
- {
- r[i++]= false;
- }
- r[i++]= cont.size() == 0;
-
- boolean bOk= true;
- for (int c= 0; c < i; c++)
- bOk= bOk && r[c];
- if ( ! bOk )
- System.out.println("Failed");
- else
- System.out.println("Ok");
- return bOk;
- }
- public boolean ListIterator_next()
- {
- System.out.println("Testing InterfaceContainer.listIerator, ListIterator.next()");
- InterfaceContainer cont= new InterfaceContainer();
- boolean r[]= new boolean[50];
- int i= 0;
-
- cont.addAll(list1);
- Iterator it= cont.listIterator();
- r[i++]= it.next() == list1.get(0);
- r[i++]= it.next() == list1.get(1);
- r[i++]= it.next() == list1.get(2);
- try
- {
- it.next();
- }catch(java.util.NoSuchElementException ne)
- {
- r[i++]= true;
- }catch(Exception e)
- {
- r[i++]= false;
- }
-
- boolean bOk= true;
- for (int c= 0; c < i; c++)
- bOk= bOk && r[c];
- if ( ! bOk )
- System.out.println("Failed");
- else
- System.out.println("Ok");
- return bOk;
- }
-
- public boolean ListIterator_hasNext()
- {
- System.out.println("Testing ListIterator.hasNext()");
- InterfaceContainer cont= new InterfaceContainer();
- boolean r[]= new boolean[50];
- int i= 0;
-
- Iterator it= cont.listIterator();
- r[i++]= ! it.hasNext();
- cont.addAll(list1);
- it= cont.listIterator();
- r[i++]= it.hasNext();
- it.next();
- r[i++]= it.hasNext();
- it.next();
- r[i++]= it.hasNext();
- it.next();
- r[i++]= ! it.hasNext();
-
- boolean bOk= true;
- for (int c= 0; c < i; c++)
- bOk= bOk && r[c];
- if ( ! bOk )
- System.out.println("Failed");
- else
- System.out.println("Ok");
- return bOk;
- }
-
- public boolean ListIterator_remove()
- {
- System.out.println("Testing ListIterator.remove()");
- InterfaceContainer cont= new InterfaceContainer();
- boolean r[]= new boolean[50];
- int i= 0;
-
- ListIterator it= cont.listIterator();
- try
- {
- it.remove();
- }
- catch( IllegalStateException ie)
- {
- r[i++]= true;
- }
- catch(java.lang.Exception e)
- {
- r[i++]= false;
- }
- cont.add(obj1);
- it= cont.listIterator();
- it.next();
- it.remove();
- r[i++]= cont.isEmpty();
- try
- {
- it.remove();
- }
- catch (IllegalStateException ie)
- {
- r[i++]= true;
- }
- catch (Exception e)
- {
- r[i++]= false;
- }
- cont.clear();
- cont.addAll(list1);
- it= cont.listIterator();
- while (it.hasNext())
- {
- it.next();
- it.remove();
- }
- r[i++]= cont.isEmpty();
-
- // 2 iterators, remove must not impair the other iterator
- cont.clear();
- cont.addAll(list1);
- int size= cont.size();
- it= cont.listIterator();
- Iterator it2= cont.listIterator();
- while (it.hasNext())
- {
- it.next();
- it.remove();
- }
- try
- {
- for( int c= 0; c < size; c++)
- it2.next();
- r[i++]= true;
- }
- catch(Exception e)
- {
- r[i++]= false;
- }
- r[i++]= cont.size() == 0;
-
- boolean bOk= true;
- for (int c= 0; c < i; c++)
- bOk= bOk && r[c];
- if ( ! bOk )
- System.out.println("Failed");
- else
- System.out.println("Ok");
- return bOk;
- }
-
- public boolean ListIterator_hasPrevious()
- {
- System.out.println("Testing ListIterator.hasPrevious()");
- InterfaceContainer cont= new InterfaceContainer();
- boolean r[]= new boolean[50];
- int i= 0;
-
- ListIterator it= cont.listIterator();
- r[i++]= ! it.hasPrevious();
- cont.addAll(list1);
- it= cont.listIterator();
- while (it.hasNext())
- {
- it.next();
- r[i++]= it.hasPrevious();
- }
-
- boolean bOk= true;
- for (int c= 0; c < i; c++)
- bOk= bOk && r[c];
- if ( ! bOk )
- System.out.println("Failed");
- else
- System.out.println("Ok");
- return bOk;
- }
-
- public boolean ListIterator_previous()
- {
- System.out.println("Testing ListIterator.previous()");
- InterfaceContainer cont= new InterfaceContainer();
- boolean r[]= new boolean[50];
- int i= 0;
- boolean bOk= true;
-
- cont.addAll(list1);
- // go to the end of our list and list1
- ListIterator it= cont.listIterator();
- while (it.hasNext())
- it.next();
- ListIterator it_list1= list1.listIterator();
- while (it_list1.hasNext())
- it_list1.next();
-
- while (it.hasPrevious())
- {
- r[i++]= it.previous() == it_list1.previous();
- }
- try
- {
- it.previous();
- r[i++]= false;
- }
- catch (java.util.NoSuchElementException e)
- {
- r[i++]=true;
- }
-
- for (int c= 0; c < i; c++)
- bOk= bOk && r[c];
- if ( ! bOk )
- System.out.println("Failed");
- else
- System.out.println("Ok");
- return bOk;
- }
-
- public boolean ListIterator_nextIndex()
- {
- System.out.println("Testing ListIterator.nextIndex()");
- InterfaceContainer cont= new InterfaceContainer();
- boolean r[]= new boolean[50];
- int i= 0;
- boolean bOk= true;
-
- ListIterator it= cont.listIterator();
- cont.addAll(list1);
- it= cont.listIterator();
- r[i++]= it.nextIndex() == 0;
- it.next();
- r[i++]= it.nextIndex() == 1;
- it.next();
- r[i++]= it.nextIndex() == 2;
-
- for (int c= 0; c < i; c++)
- bOk= bOk && r[c];
- if ( ! bOk )
- System.out.println("Failed");
- else
- System.out.println("Ok");
- return bOk;
- }
- public boolean ListIterator_previousIndex()
- {
- System.out.println("Testing ListIterator.previousIndex()");
- InterfaceContainer cont= new InterfaceContainer();
- boolean r[]= new boolean[50];
- int i= 0;
- boolean bOk= true;
-
- ListIterator it= cont.listIterator();
- cont.addAll(list1);
- it= cont.listIterator();
- while (it.hasNext())
- it.next();
-
- r[i++]= it.previousIndex() == 2;
- it.previous();
- r[i++]= it.previousIndex() == 1;
- it.previous();
- r[i++]= it.previousIndex() == 0;
- it.previous();
-
- for (int c= 0; c < i; c++)
- bOk= bOk && r[c];
- if ( ! bOk )
- System.out.println("Failed");
- else
- System.out.println("Ok");
- return bOk;
- }
- public boolean ListIterator_add()
- {
- System.out.println("Testing ListIterator.add()");
- InterfaceContainer cont= new InterfaceContainer();
- boolean r[]= new boolean[50];
- int i= 0;
- boolean bOk= true;
-
- ListIterator it= cont.listIterator();
- it.add(obj1);
- r[i++]= cont.size() == 1;
- it.add(obj2);
- r[i++]= cont.size() == 2;
- it.add(obj3);
- r[i++]= it.previous() == obj3;
- r[i++]= it.previous() == obj2;
- r[i++]= it.previous() == obj1;
-
- for (int c= 0; c < i; c++)
- bOk= bOk && r[c];
- if ( ! bOk )
- System.out.println("Failed");
- else
- System.out.println("Ok");
- return bOk;
- }
-
- public boolean disposeAndClear()
- {
- System.out.println("Testing InterfaceContainer.disposeAndClear");
- InterfaceContainer cont= new InterfaceContainer(10);
- boolean r[]= new boolean[50];
- int i= 0;
-
- cont.add(obj1);
- cont.add(obj2);
- cont.add(obj3);
- cont.add(proxyObj1Weak1);
- cont.add(proxyObj3TypeProv);
- System.out.println("Two proxies are called. Check the output:");
- cont.disposeAndClear(new com.sun.star.lang.EventObject());
- r[i++]= obj1.nDisposingCalled == 1;
- r[i++]= obj2.nDisposingCalled == 1;
- r[i++]= obj3.nDisposingCalled == 1;
- boolean bOk= true;
- for (int c= 0; c < i; c++)
- bOk= bOk && r[c];
- if (bOk == false)
- System.out.println("Failed");
- else
- System.out.println("Ok");
- return bOk;
- }
-
-
- public static void main(String[] args)
- {
- InterfaceContainer_Test test= new InterfaceContainer_Test();
- boolean r[]= new boolean[50];
- int i= 0;
- r[i++]= test.listConstructors();
- r[i++]= test.trimToSize();
- r[i++]= test.ensureCapacity();
- r[i++]= test.add();
- r[i++]= test.indexOf();
- r[i++]= test.contains();
- r[i++]= test.containsAll();
- r[i++]= test.get();
- r[i++]= test.addAll();
- r[i++]= test.remove();
- r[i++]= test.retainAll();
- r[i++]= test.set();
- r[i++]= test.toArray();
- r[i++]= test.Iterator_next();
- r[i++]= test.Iterator_hasNext();
- r[i++]= test.Iterator_remove();
- r[i++]= test.ListIterator_next();
- r[i++]= test.ListIterator_hasNext();
- r[i++]= test.ListIterator_remove();
- r[i++]= test.ListIterator_hasPrevious();
- r[i++]= test.ListIterator_previous();
- r[i++]= test.ListIterator_nextIndex();
- r[i++]= test.ListIterator_previousIndex();
- r[i++]= test.ListIterator_add();
- r[i++]= test.disposeAndClear();
- boolean bOk= true;
- for (int c= 0; c < i; c++)
- bOk= bOk && r[c];
- if ( ! bOk )
- System.out.println("Test finished.\nErrors occurred!!!");
- else
- System.out.println("Test finished. \nNo errors.");
-
- }
-
-}
diff --git a/javaunohelper/test/com/sun/star/lib/uno/helper/MultiTypeInterfaceContainer_Test.java b/javaunohelper/test/com/sun/star/lib/uno/helper/MultiTypeInterfaceContainer_Test.java
deleted file mode 100644
index dee5b29eb..000000000
--- a/javaunohelper/test/com/sun/star/lib/uno/helper/MultiTypeInterfaceContainer_Test.java
+++ /dev/null
@@ -1,372 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-package com.sun.star.lib.uno.helper;
-import com.sun.star.lib.uno.environments.java.java_environment;
-import java.util.List;
-import com.sun.star.uno.XWeak;
-import com.sun.star.lang.XTypeProvider;
-import java.util.ArrayList;
-import com.sun.star.uno.Type;
-import com.sun.star.lib.uno.typedesc.TypeDescription;
-import com.sun.star.uno.UnoRuntime;
-//import com.sun.star.lib.uno.environments.java.Proxy;
-import com.sun.star.uno.XInterface;
-import com.sun.star.lang.XSingleComponentFactory;
-
-public class MultiTypeInterfaceContainer_Test
-{
-// java_environment env= new java_environment(null);
- /** Creates a new instance of InterfaceContainerTest */
- AWeakBase obj1,obj2,obj3,obj4;
- Object proxyObj1Weak1;
- Object proxyObj3Weak1;
- Object proxyObj3Weak2;
- Object proxyObj3TypeProv;
- Object proxyObj2TypeProv;
- //contains original objects
- List list1;
- //contains original objects + proxies
- List list2;
- //contains original object + proxies + null value
- List list3;
-
- /** Creates a new instance of MultiTypeInterfaceContainer_Test */
- public MultiTypeInterfaceContainer_Test()
- {
- obj1= new AWeakBase();
- obj2= new AWeakBase();
- obj3= new AWeakBase();
- obj4= new AWeakBase();
-
- proxyObj1Weak1= ProxyProvider.createProxy(obj1, XWeak.class);
- proxyObj3Weak1= ProxyProvider.createProxy(obj3, XWeak.class);
- proxyObj3Weak2= ProxyProvider.createProxy(obj3, XWeak.class);
- proxyObj2TypeProv= ProxyProvider.createProxy(obj2, XTypeProvider.class);
- proxyObj3TypeProv= ProxyProvider.createProxy(obj3, XTypeProvider.class);
-
- list1= new ArrayList();
- list1.add(obj1);
- list1.add(obj2);
- list1.add(obj3);
- list2= new ArrayList();
- list2.add(obj1);
- list2.add(proxyObj2TypeProv);
- list2.add(proxyObj3TypeProv);
- list3= new ArrayList();
- list3.add(obj1);
- list3.add(null);
- list3.add(proxyObj2TypeProv);
- list3.add(proxyObj3Weak1);
- }
- /** returns Holder proxy objects for the specified interface. If the method is called
- * several times with the same arguments then each time a new HolderProxy is returned.
- * Then all HolderProxy s refer to the same Proxy object.
- * The proxy can be queried for XEventListener. On the returned proxy disposing can be called
- *
- */
-// public Object getHolderProxy(Object obj, Class iface)
-// {
-// Object retVal= null;
-// if (obj == null || iface == null || iface.isInstance(obj) == false )
-// return retVal;
-//
-// Type type= new Type(TypeDescription.getTypeDescription(iface));
-// Type evtType= new Type(TypeDescription.getTypeDescription(com.sun.star.lang.XEventListener.class));
-// // find the object identifier
-// String sOid= UnoRuntime.generateOid(obj);
-// retVal= env.getRegisteredInterface(sOid, type);
-// // if retVal == null then probably not registered
-// if (retVal == null)
-// {
-// // create the XEventListener proxy
-// Requester eventRequester = new Requester(false, false, null);
-// Object aProxyEvt = Proxy.create(eventRequester, sOid, evtType, false, false);
-// String[] arOid= new String[]{sOid};
-// retVal= env.registerInterface(aProxyEvt, arOid, evtType);
-//
-// Requester requester = new Requester(false, false, aProxyEvt);
-// Object aProxy = Proxy.create(requester, sOid, type, false, false);
-// arOid= new String[] {sOid};
-// retVal= env.registerInterface(aProxy, arOid, type);
-// }
-// return retVal;
-// }
-
- public boolean addInterface()
- {
- System.out.println("Testing MultiTypeInterfaceContainer.addInterface");
- MultiTypeInterfaceContainer cont= new MultiTypeInterfaceContainer();
- boolean r[]= new boolean[200];
- int i= 0;
-
- int ci= 0;
- ci= cont.addInterface(new Type(XInterface.class), obj1);
- ci= cont.addInterface(new Type(XInterface.class), obj2);
- ci= cont.addInterface(new Type(XInterface.class), obj3);
- r[i++]= ci == 3;
- ci= cont.addInterface(new Type(XWeak.class), obj1);
- ci= cont.addInterface(new Type(XWeak.class), obj2);
- r[i++]= ci ==2;
- ci= cont.addInterface(null,obj1);
- r[i++]= ci == 1;
- ci= cont.addInterface(new Type(XTypeProvider.class), null);
- r[i++]= ci == 0;
-
- cont= new MultiTypeInterfaceContainer();
- AWeakBase[] arObj= new AWeakBase[100];
- for (int c= 0; c < 100; c++)
- {
- arObj[c]= new AWeakBase();
- ci= cont.addInterface(new Type(XInterface.class), arObj[c]);
- }
- Type[] arT= cont.getContainedTypes();
- for (int c=0; c < 100; c++)
- {
- ci= cont.removeInterface(new Type(XInterface.class), arObj[c]);
- r[i++]= ci == 100 -c -1;
-
- }
- boolean bOk= true;
- for (int c= 0; c < i; c++)
- bOk= bOk && r[c];
- if (bOk == false)
- System.out.println("Failed");
- else
- System.out.println("Ok");
- return bOk;
- }
-
- public boolean getContainedTypes()
- {
- System.out.println("Testing MultiTypeInterfaceContainer.getContainedTypes");
- MultiTypeInterfaceContainer cont= new MultiTypeInterfaceContainer();
- boolean r[]= new boolean[50];
- int i= 0;
-
- cont.addInterface(new Type(XInterface.class), obj1);
- cont.addInterface(new Type(XWeak.class), obj1);
- cont.addInterface(null, obj1);
- cont.addInterface(new Type(XTypeProvider.class), null);
- Object aObj= new Object();
- cont.addInterface(aObj, obj1);
- cont.addInterface(XSingleComponentFactory.class, obj1);
- Type[] types= cont.getContainedTypes();
- // 3 types and no XTypeProvider
- r[i++]= types.length == 5;
- for (int c= 0; c < types.length; c++)
- {
- if (types[c] == null)
- r[i++]= true;
- else if(types[c].equals( new Type(XTypeProvider.class)))
- r[i++]= false;
- else if(types[c].equals(new Type(XInterface.class)))
- r[i++]= true;
- else if (types[c].equals(new Type(XWeak.class)))
- r[i++]= true;
- else if (types[c].equals(new Type()))
- r[i++]= true;
- else if (types[c].equals(new Type( aObj.getClass())))
- r[i++]= true;
- else if (types[c].equals(new Type(XSingleComponentFactory.class)))
- r[i++]= true;
- else
- r[i++]= false;
- }
- boolean bOk= true;
- for (int c= 0; c < i; c++)
- bOk= bOk && r[c];
- if (bOk == false)
- System.out.println("Failed");
- else
- System.out.println("Ok");
- return bOk;
- }
-
- public boolean getContainer()
- {
- System.out.println("Testing MultiTypeInterfaceContainer.getContainedTypes");
- MultiTypeInterfaceContainer cont= new MultiTypeInterfaceContainer();
- boolean r[]= new boolean[50];
- int i= 0;
-
- int ci= 0;
- ci= cont.addInterface(new Type(XInterface.class), obj1);
- ci= cont.addInterface(new Type(XInterface.class), obj2);
- ci= cont.addInterface(new Type(XInterface.class), obj3);
- ci= cont.addInterface(new Type(XWeak.class), obj1);
- ci= cont.addInterface(new Type(XWeak.class), obj2);
- ci= cont.addInterface(null, obj1);
- ci= cont.addInterface(new Type(XTypeProvider.class), null);
-
- InterfaceContainer icont= null;
- icont= cont.getContainer( new Type(XTypeProvider.class));
- r[i++]= icont.size() == 0;
- icont= cont.getContainer(new Type(XWeak.class));
- r[i++]= icont.size() == 2;
- icont= cont.getContainer(null);
- r[i++]= icont.size() == 1;
-
- boolean bOk= true;
- for (int c= 0; c < i; c++)
- bOk= bOk && r[c];
- if (bOk == false)
- System.out.println("Failed");
- else
- System.out.println("Ok");
- return bOk;
- }
-
- public boolean removeInterface()
- {
- System.out.println("Testing MultiTypeInterfaceContainer.removeInterface");
- MultiTypeInterfaceContainer cont= new MultiTypeInterfaceContainer();
- boolean r[]= new boolean[50];
- int i= 0;
-
- int count= 0;
- count= cont.removeInterface( new Type(XTypeProvider.class), obj1);
- r[i++]= count == 0;
- count= cont.removeInterface( new Type(XTypeProvider.class), null);
- r[i++]= count == 0;
- count= cont.removeInterface(null, obj2);
- r[i++]= count == 0;
-
- cont.addInterface(new Type(XInterface.class), obj1);
- cont.addInterface(null, obj1);
- count= cont.removeInterface(null, obj2);
- // count must still be 1
- r[i++]= count == 1;
- count= cont.removeInterface(null, obj1);
- r[i++]= count == 0;
- count= cont.removeInterface(new Type(XInterface.class), obj1);
- r[i++]= count == 0;
-
- boolean bOk= true;
- for (int c= 0; c < i; c++)
- bOk= bOk && r[c];
- if (bOk == false)
- System.out.println("Failed");
- else
- System.out.println("Ok");
- return bOk;
- }
-
- public boolean clear()
- {
- System.out.println("Testing MultiTypeInterfaceContainer.clear");
- MultiTypeInterfaceContainer cont= new MultiTypeInterfaceContainer();
- boolean r[]= new boolean[50];
- int i= 0;
-
- int count= 0;
- cont.clear();
- Type[] types= cont.getContainedTypes();
- r[i++]= types.length == 0;
- int ci;
- ci= cont.addInterface(new Type(XInterface.class), obj1);
- ci= cont.addInterface(new Type(XInterface.class), obj2);
- ci= cont.addInterface(new Type(XInterface.class), obj3);
- ci= cont.addInterface(new Type(XWeak.class), obj1);
- ci= cont.addInterface(new Type(XWeak.class), obj2);
- ci= cont.addInterface(null, obj1);
- ci= cont.addInterface(new Type(XTypeProvider.class), null);
- types= cont.getContainedTypes();
- r[i++]= types.length == 3;
- cont.clear();
- types= cont.getContainedTypes();
- r[i++]= types.length == 0;
-
- boolean bOk= true;
- for (int c= 0; c < i; c++)
- bOk= bOk && r[c];
- if (bOk == false)
- System.out.println("Failed");
- else
- System.out.println("Ok");
- return bOk;
- }
-
- public boolean disposeAndClear()
- {
- System.out.println("Testing MultiTypeInterfaceContainer.disposeAndClear");
- MultiTypeInterfaceContainer cont= new MultiTypeInterfaceContainer();
- boolean r[]= new boolean[50];
- int i= 0;
- obj1.nDisposingCalled= 0;
- obj2.nDisposingCalled= 0;
- obj3.nDisposingCalled= 0;
- cont.addInterface(new Type(XInterface.class), null);
- cont.addInterface(new Type(XInterface.class), obj1);
- cont.addInterface(new Type(XInterface.class), obj2);
- cont.addInterface(new Type(XInterface.class), obj3);
- cont.addInterface(new Type(XWeak.class),obj1);
- cont.addInterface(new Type(XWeak.class), obj2);
- cont.addInterface(new Type(XTypeProvider.class), obj1);
- cont.disposeAndClear(new com.sun.star.lang.EventObject("blabla"));
-
- r[i++]= obj1.nDisposingCalled == 3;
- r[i++]= obj2.nDisposingCalled == 2;
- r[i++]= obj3.nDisposingCalled == 1;
- Type[] types= cont.getContainedTypes();
- r[i++]= types.length == 0;
-
- boolean bOk= true;
- for (int c= 0; c < i; c++)
- bOk= bOk && r[c];
- if (bOk == false)
- System.out.println("Failed");
- else
- System.out.println("Ok");
- return bOk;
- }
-
-
- public static void main(String[] args)
- {
- MultiTypeInterfaceContainer_Test test= new MultiTypeInterfaceContainer_Test();
- boolean r[]= new boolean[50];
- int i= 0;
- r[i++]= test.addInterface();
- r[i++]= test.getContainedTypes();
- r[i++]= test.getContainer();
- r[i++]= test.removeInterface();
- r[i++]= test.clear();
- r[i++]= test.disposeAndClear();
- boolean bOk= true;
- for (int c= 0; c < i; c++)
- bOk= bOk && r[c];
- if ( ! bOk )
- System.out.println("Test finished.\nErrors occurred!!!");
- else
- System.out.println("Test finished. \nNo errors.");
-
- }
-}
-
-
-
diff --git a/javaunohelper/test/com/sun/star/lib/uno/helper/PropertySet_Test.java b/javaunohelper/test/com/sun/star/lib/uno/helper/PropertySet_Test.java
deleted file mode 100644
index 7185bdc85..000000000
--- a/javaunohelper/test/com/sun/star/lib/uno/helper/PropertySet_Test.java
+++ /dev/null
@@ -1,1693 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-package com.sun.star.lib.uno.helper;
-import com.sun.star.lang.EventObject;
-import com.sun.star.lang.DisposedException;
-import com.sun.star.uno.Type;
-import com.sun.star.uno.TypeClass;
-import com.sun.star.uno.XInterface;
-import com.sun.star.uno.UnoRuntime;
-import com.sun.star.uno.Any;
-import com.sun.star.uno.XWeak;
-import com.sun.star.beans.XPropertySet;
-import com.sun.star.beans.UnknownPropertyException;
-import com.sun.star.beans.Property;
-import com.sun.star.beans.PropertyAttribute;
-import com.sun.star.beans.XPropertyChangeListener;
-import com.sun.star.beans.PropertyVetoException;
-import com.sun.star.beans.PropertyChangeEvent;
-import com.sun.star.beans.XVetoableChangeListener;
-import com.sun.star.beans.XPropertySetInfo;
-import com.sun.star.beans.XPropertiesChangeListener;
-
-import java.util.Arrays;
-
-public class PropertySet_Test
-{
-
- /** Creates a new instance of PropertySet_Test */
- public PropertySet_Test()
- {
- }
-
- public boolean convertPropertyValue()
- {
- System.out.println("PropertySet.convertPropertyValue");
- boolean[] r= new boolean[50];
- int i= 0;
-
- TestClass cl= new TestClass();
- try {
- r[i++]= cl.test_convertPropertyValue();
- }catch(java.lang.Exception e){
- i++;
- }
- boolean bOk= true;
- for (int c= 0; c < i; c++)
- bOk= bOk && r[c];
- if (bOk == false)
- System.out.println("Failed");
- else
- System.out.println("Ok");
- return bOk;
- }
-
- public boolean setPropertyValueNoBroadcast()
- {
- System.out.println("PropertySet.setValueNoBroadcast");
- boolean[] r= new boolean[50];
- int i= 0;
-
- TestClass cl= new TestClass();
- try {
- r[i++]= cl.test_setPropertyValueNoBroadcast();
- }catch(java.lang.Exception e){
- i++;
- }
- boolean bOk= true;
- for (int c= 0; c < i; c++)
- bOk= bOk && r[c];
- if (bOk == false)
- System.out.println("Failed");
- else
- System.out.println("Ok");
- return bOk;
- }
-
- public boolean setPropertyValue()
- {
- System.out.println("PropertySet.setPropertyValue");
- boolean[] r= new boolean[150];
- int i= 0;
-
- TestClass cl= new TestClass();
- try {
- cl.resetPropertyMembers();
- Object value;
- Object ret;
- value= new Boolean(true);
- cl.setPropertyValue("PropBoolA", value);
- ret= cl.getPropertyValue("PropBoolA");
- r[i++]= ((Boolean) ret).equals( (Boolean) value);
- value= new Character('A');
- cl.setPropertyValue("PropCharA",value);
- ret= cl.getPropertyValue("PropCharA");
- r[i++]= ((Character) ret).equals((Character) value);
- value= new Byte((byte) 111);
- cl.setPropertyValue("PropByteA",value);
- ret= cl.getPropertyValue("PropByteA");
- r[i++]= ((Byte) ret).equals((Byte) value);
- value= new Short((short)112);
- cl.setPropertyValue("PropShortA", value);
- ret= cl.getPropertyValue("PropShortA");
- r[i++]= ((Short) ret).equals((Short) value);
- value= new Integer(113);
- cl.setPropertyValue("PropIntA", value);
- ret= cl.getPropertyValue("PropIntA");
- r[i++]= ((Integer) ret).equals((Integer) value);
- value= new Long(115);
- cl.setPropertyValue("PropLongA", value);
- ret= cl.getPropertyValue("PropLongA");
- r[i++]= ((Long) ret).equals((Long) value);
- value= new Float(3.14);
- cl.setPropertyValue("PropFloatA", value);
- ret= cl.getPropertyValue("PropFloatA");
- r[i++]= ((Float) ret).equals((Float) value);
- value= new Double(3.145);
- cl.setPropertyValue("PropDoubleA",value);
- ret= cl.getPropertyValue("PropDoubleA");
- r[i++]= ((Double) ret).equals((Double) value);
- value= new String("string");
- cl.setPropertyValue("PropStringA",value);
- ret= cl.getPropertyValue("PropStringA");
- r[i++]= ((String) ret).equals((String) value);
- value= new ComponentBase();
- cl.setPropertyValue("PropXInterfaceA",value);
- ret= cl.getPropertyValue("PropXInterfaceA");
- r[i++]= ((XInterface) ret).equals((XInterface) value);
- value= new ComponentBase();
- cl.setPropertyValue("PropXWeakA",value);
- ret= cl.getPropertyValue("PropXWeakA");
- r[i++]= ((XWeak) ret).equals((XWeak) value);
- value = com.sun.star.beans.PropertyState.AMBIGUOUS_VALUE;
- cl.setPropertyValue("PropEnum",value);
- ret= cl.getPropertyValue("PropEnum");
- r[i++]= ret == value;
- value= new byte[]{1,2,3};
- cl.setPropertyValue("PropArrayByteA", value);
- ret= cl.getPropertyValue("PropArrayByteA");
- r[i++]= ((byte[]) ret).equals((byte[]) value);
- value= new Type(String.class);
- cl.setPropertyValue("PropTypeA", value);
- ret= cl.getPropertyValue("PropTypeA");
- r[i++]= ((Type) ret).equals(value);
-
- // test protected,package,private members
- value= new Boolean(true);
- cl.setPropertyValue("PropBoolB", value);
- ret= cl.getPropertyValue("PropBoolB");
- r[i++]= ((Boolean) ret).equals((Boolean) value);
- cl.setPropertyValue("PropBoolC", value);
- ret= cl.getPropertyValue("PropBoolC");
- r[i++]= ((Boolean) ret).equals((Boolean) value);
-
- try{
- cl.setPropertyValue("PropBoolD", value);
- i++;
- }catch (Exception e)
- {
- r[i++]= true;
- }
- cl.resetPropertyMembers();
-
- value= new Boolean(true);
- cl.setPropertyValue("PropObjectA", value);
- ret= cl.getPropertyValue("PropObjectA");
- r[i++]= ((Boolean) ret).equals((Boolean) value);
- value= new Character('A');
- cl.setPropertyValue("PropObjectA",value);
- ret= cl.getPropertyValue("PropObjectA");
- r[i++]= ((Character) ret).equals((Character) value);
- value= new Byte((byte) 111);
- cl.setPropertyValue("PropObjectA",value);
- ret= cl.getPropertyValue("PropObjectA");
- r[i++]= ((Byte) ret).equals((Byte) value);
- value= new Short((short)112);
- cl.setPropertyValue("PropObjectA", value);
- ret= cl.getPropertyValue("PropObjectA");
- r[i++]= ((Short) ret).equals((Short) value);
- value= new Integer(113);
- cl.setPropertyValue("PropObjectA", value);
- ret= cl.getPropertyValue("PropObjectA");
- r[i++]= ((Integer) ret).equals((Integer) value);
- value= new Long(115);
- cl.setPropertyValue("PropObjectA", value);
- ret= cl.getPropertyValue("PropObjectA");
- r[i++]= ((Long) ret).equals((Long) value);
- value= new Float(3.14);
- cl.setPropertyValue("PropObjectA", value);
- ret= cl.getPropertyValue("PropObjectA");
- r[i++]= ((Float) ret).equals((Float) value);
- value= new Double(3.145);
- cl.setPropertyValue("PropObjectA",value);
- ret= cl.getPropertyValue("PropObjectA");
- r[i++]= ((Double) ret).equals((Double) value);
- value= new String("string");
- cl.setPropertyValue("PropObjectA",value);
- ret= cl.getPropertyValue("PropObjectA");
- r[i++]= ((String) ret).equals((String) value);
- value= new ComponentBase();
- cl.setPropertyValue("PropObjectA",value);
- ret= cl.getPropertyValue("PropObjectA");
- r[i++]= ((XInterface) ret).equals((XInterface) value);
- value= new ComponentBase();
- cl.setPropertyValue("PropObjectA",value);
- ret= cl.getPropertyValue("PropObjectA");
- r[i++]= ((XWeak) ret).equals((XWeak) value);
- value= new byte[]{1,2,3};
- cl.setPropertyValue("PropObjectA", value);
- ret= cl.getPropertyValue("PropObjectA");
- r[i++]= ((byte[]) ret).equals((byte[]) value);
- value= new Type(String.class);
- cl.setPropertyValue("PropObjectA", value);
- ret= cl.getPropertyValue("PropObjectA");
- r[i++]= ((Type) ret).equals(value);
- cl.setPropertyValue("PropObjectA", new Any( new Type(byte.class), new Byte((byte)1)));
- ret= cl.getPropertyValue("PropObjectA");
- r[i++]= ((Byte) ret).byteValue() == 1;
-
- cl.resetPropertyMembers();
- value= new Boolean(true);
- cl.setPropertyValue("PropAnyA", value);
- ret= cl.getPropertyValue("PropAnyA");
- r[i++]= ret instanceof Any && util.anyEquals(value, ret);
- value= new Character('A');
- cl.setPropertyValue("PropAnyA",value);
- ret= cl.getPropertyValue("PropAnyA");
- r[i++]= ret instanceof Any && util.anyEquals(value, ret);
- value= new Byte((byte) 111);
- cl.setPropertyValue("PropAnyA",value);
- ret= cl.getPropertyValue("PropAnyA");
- r[i++]= ret instanceof Any && util.anyEquals(value, ret);
- value= new Short((short)112);
- cl.setPropertyValue("PropAnyA", value);
- ret= cl.getPropertyValue("PropAnyA");
- r[i++]= ret instanceof Any && util.anyEquals(value, ret);
- value= new Integer(113);
- cl.setPropertyValue("PropAnyA", value);
- ret= cl.getPropertyValue("PropAnyA");
- r[i++]= ret instanceof Any && util.anyEquals(value, ret);
- value= new Long(115);
- cl.setPropertyValue("PropAnyA", value);
- ret= cl.getPropertyValue("PropAnyA");
- r[i++]= ret instanceof Any && util.anyEquals(value, ret);
- value= new Float(3.14);
- cl.setPropertyValue("PropAnyA", value);
- ret= cl.getPropertyValue("PropAnyA");
- r[i++]= ret instanceof Any && util.anyEquals(value, ret);
- value= new Double(3.145);
- cl.setPropertyValue("PropAnyA",value);
- ret= cl.getPropertyValue("PropAnyA");
- r[i++]= ret instanceof Any && util.anyEquals(value, ret);
- value= new String("string");
- cl.setPropertyValue("PropAnyA",value);
- ret= cl.getPropertyValue("PropAnyA");
- r[i++]= ret instanceof Any && util.anyEquals(value, ret);
- value= new ComponentBase();
- cl.setPropertyValue("PropAnyA",value);
- ret= cl.getPropertyValue("PropAnyA");
- r[i++]= ret instanceof Any && util.anyEquals(value, ret);
- value= new ComponentBase();
- cl.setPropertyValue("PropAnyA",value);
- ret= cl.getPropertyValue("PropAnyA");
- r[i++]= ret instanceof Any && util.anyEquals(value, ret);
- value= new byte[]{1,2,3};
- cl.setPropertyValue("PropAnyA", value);
- ret= cl.getPropertyValue("PropAnyA");
- r[i++]= ret instanceof Any && util.anyEquals(value, ret);
- value= new Type(String.class);
- cl.setPropertyValue("PropAnyA", value);
- ret= cl.getPropertyValue("PropAnyA");
- r[i++]= ret instanceof Any && util.anyEquals(value, ret);
-
- cl.resetPropertyMembers();
- value= new Any(new Type(boolean.class), new Boolean(true));
- cl.setPropertyValue("PropBoolA", value);
- ret= cl.getPropertyValue("PropBoolA");
- r[i++]= ret instanceof Boolean && util.anyEquals(value, ret);
- value= new Any (new Type(char.class), new Character('A'));
- cl.setPropertyValue("PropCharA",value);
- ret= cl.getPropertyValue("PropCharA");
- r[i++]= ret instanceof Character && util.anyEquals(value, ret);
- value= new Any(new Type(byte.class), new Byte((byte) 111));
- cl.setPropertyValue("PropByteA",value);
- ret= cl.getPropertyValue("PropByteA");
- r[i++]= ret instanceof Byte && util.anyEquals(value, ret);
- value= new Any(new Type(short.class), new Short((short)112));
- cl.setPropertyValue("PropShortA", value);
- ret= cl.getPropertyValue("PropShortA");
- r[i++]= ret instanceof Short && util.anyEquals(value, ret);
- value= new Any(new Type(int.class), new Integer(113));
- cl.setPropertyValue("PropIntA", value);
- ret= cl.getPropertyValue("PropIntA");
- r[i++]= ret instanceof Integer && util.anyEquals(value, ret);
- value= new Any(new Type(long.class), new Long(115));
- cl.setPropertyValue("PropLongA", value);
- ret= cl.getPropertyValue("PropLongA");
- r[i++]= ret instanceof Long && util.anyEquals(value, ret);
- value= new Any(new Type(float.class), new Float(3.14));
- cl.setPropertyValue("PropFloatA", value);
- ret= cl.getPropertyValue("PropFloatA");
- r[i++]= ret instanceof Float && util.anyEquals(value, ret);
- value= new Any(new Type(double.class),new Double(3.145));
- cl.setPropertyValue("PropDoubleA",value);
- ret= cl.getPropertyValue("PropDoubleA");
- r[i++]= ret instanceof Double && util.anyEquals(value, ret);
- value= new Any(new Type(String.class), new String("string"));
- cl.setPropertyValue("PropStringA",value);
- ret= cl.getPropertyValue("PropStringA");
- r[i++]= ret instanceof String && util.anyEquals(value, ret);
- value= new Any(new Type(ComponentBase.class), new ComponentBase());
- cl.setPropertyValue("PropXInterfaceA",value);
- ret= cl.getPropertyValue("PropXInterfaceA");
- r[i++]= ret instanceof ComponentBase && util.anyEquals(value, ret);
- value= new Any( new Type(ComponentBase.class), new ComponentBase());
- cl.setPropertyValue("PropXWeakA",value);
- ret= cl.getPropertyValue("PropXWeakA");
- r[i++]= ret instanceof ComponentBase && util.anyEquals(value, ret);
- value= new Any(new Type(byte[].class), new byte[]{1,2,3});
- cl.setPropertyValue("PropArrayByteA", value);
- ret= cl.getPropertyValue("PropArrayByteA");
- r[i++]= ret instanceof byte[] && util.anyEquals(value, ret);
- value= new Any(new Type(Type.class), new Type(String.class));
- cl.setPropertyValue("PropTypeA", value);
- ret= cl.getPropertyValue("PropTypeA");
- r[i++]= ret instanceof Type && util.anyEquals(value, ret);
-
-
- cl.resetPropertyMembers();
- value= new Any(new Type(boolean.class), new Boolean(true));
- cl.setPropertyValue("PropAnyA", value);
- ret= cl.getPropertyValue("PropAnyA");
- r[i++]= ret instanceof Any && util.anyEquals(value, ret);
- value= new Any (new Type(char.class), new Character('A'));
- cl.setPropertyValue("PropAnyA",value);
- ret= cl.getPropertyValue("PropAnyA");
- r[i++]= ret instanceof Any && util.anyEquals(value, ret);
- value= new Any(new Type(byte.class), new Byte((byte) 111));
- cl.setPropertyValue("PropAnyA",value);
- ret= cl.getPropertyValue("PropAnyA");
- r[i++]= ret instanceof Any && util.anyEquals(value, ret);
- value= new Any(new Type(short.class), new Short((short)112));
- cl.setPropertyValue("PropAnyA", value);
- ret= cl.getPropertyValue("PropAnyA");
- r[i++]= ret instanceof Any && util.anyEquals(value, ret);
- value= new Any(new Type(int.class), new Integer(113));
- cl.setPropertyValue("PropAnyA", value);
- ret= cl.getPropertyValue("PropAnyA");
- r[i++]= ret instanceof Any && util.anyEquals(value, ret);
- value= new Any(new Type(long.class), new Long(115));
- cl.setPropertyValue("PropAnyA", value);
- ret= cl.getPropertyValue("PropAnyA");
- r[i++]= ret instanceof Any && util.anyEquals(value, ret);
- value= new Any(new Type(float.class), new Float(3.14));
- cl.setPropertyValue("PropAnyA", value);
- ret= cl.getPropertyValue("PropAnyA");
- r[i++]= ret instanceof Any && util.anyEquals(value, ret);
- value= new Any(new Type(double.class),new Double(3.145));
- cl.setPropertyValue("PropAnyA",value);
- ret= cl.getPropertyValue("PropAnyA");
- r[i++]= ret instanceof Any && util.anyEquals(value, ret);
- value= new Any(new Type(String.class), new String("string"));
- cl.setPropertyValue("PropAnyA",value);
- ret= cl.getPropertyValue("PropAnyA");
- r[i++]= ret instanceof Any && util.anyEquals(value, ret);
- value= new Any(new Type(ComponentBase.class), new ComponentBase());
- cl.setPropertyValue("PropAnyA",value);
- ret= cl.getPropertyValue("PropAnyA");
- r[i++]= ret instanceof Any && util.anyEquals(value, ret);
- value= new Any( new Type(ComponentBase.class), new ComponentBase());
- cl.setPropertyValue("PropAnyA",value);
- ret= cl.getPropertyValue("PropAnyA");
- r[i++]= ret instanceof Any && util.anyEquals(value, ret);
- value= new Any(new Type(byte[].class), new byte[]{1,2,3});
- cl.setPropertyValue("PropAnyA", value);
- ret= cl.getPropertyValue("PropAnyA");
- r[i++]= ret instanceof Any && util.anyEquals(value, ret);
- value= new Any(new Type(Type.class), new Type(String.class));
- cl.setPropertyValue("PropAnyA", value);
- ret= cl.getPropertyValue("PropAnyA");
- r[i++]= ret instanceof Any && util.anyEquals(value, ret);
-
-
- // ------------------------------------------------------------------------------
- cl.resetPropertyMembers();
- value= new Boolean(true);
- cl.setPropertyValue("PropBoolClass", value);
- ret= cl.getPropertyValue("PropBoolClass");
- r[i++]= ((Boolean) ret).equals( (Boolean) value);
- value= new Character('A');
- cl.setPropertyValue("PropCharClass",value);
- ret= cl.getPropertyValue("PropCharClass");
- r[i++]= ((Character) ret).equals((Character) value);
- value= new Byte((byte) 111);
- cl.setPropertyValue("PropByteClass",value);
- ret= cl.getPropertyValue("PropByteClass");
- r[i++]= ((Byte) ret).equals((Byte) value);
- value= new Short((short)112);
- cl.setPropertyValue("PropShortClass", value);
- ret= cl.getPropertyValue("PropShortClass");
- r[i++]= ((Short) ret).equals((Short) value);
- value= new Integer(113);
- cl.setPropertyValue("PropIntClass", value);
- ret= cl.getPropertyValue("PropIntClass");
- r[i++]= ((Integer) ret).equals((Integer) value);
- value= new Long(115);
- cl.setPropertyValue("PropLongClass", value);
- ret= cl.getPropertyValue("PropLongClass");
- r[i++]= ((Long) ret).equals((Long) value);
- value= new Float(3.14);
- cl.setPropertyValue("PropFloatClass", value);
- ret= cl.getPropertyValue("PropFloatClass");
- r[i++]= ((Float) ret).equals((Float) value);
- value= new Double(3.145);
- cl.setPropertyValue("PropDoubleClass",value);
- ret= cl.getPropertyValue("PropDoubleClass");
- r[i++]= ((Double) ret).equals((Double) value);
-
- cl.resetPropertyMembers();
-
- cl.resetPropertyMembers();
- value= new Any(new Type(boolean.class), new Boolean(true));
- cl.setPropertyValue("PropBoolClass", value);
- ret= cl.getPropertyValue("PropBoolClass");
- r[i++]= ret instanceof Boolean && util.anyEquals(value, ret);
- value= new Any (new Type(char.class), new Character('A'));
- cl.setPropertyValue("PropCharClass",value);
- ret= cl.getPropertyValue("PropCharClass");
- r[i++]= ret instanceof Character && util.anyEquals(value, ret);
- value= new Any(new Type(byte.class), new Byte((byte) 111));
- cl.setPropertyValue("PropByteClass",value);
- ret= cl.getPropertyValue("PropByteClass");
- r[i++]= ret instanceof Byte && util.anyEquals(value, ret);
- value= new Any(new Type(short.class), new Short((short)112));
- cl.setPropertyValue("PropShortClass", value);
- ret= cl.getPropertyValue("PropShortClass");
- r[i++]= ret instanceof Short && util.anyEquals(value, ret);
- value= new Any(new Type(int.class), new Integer(113));
- cl.setPropertyValue("PropIntClass", value);
- ret= cl.getPropertyValue("PropIntClass");
- r[i++]= ret instanceof Integer && util.anyEquals(value, ret);
- value= new Any(new Type(long.class), new Long(115));
- cl.setPropertyValue("PropLongClass", value);
- ret= cl.getPropertyValue("PropLongClass");
- r[i++]= ret instanceof Long && util.anyEquals(value, ret);
- value= new Any(new Type(float.class), new Float(3.14));
- cl.setPropertyValue("PropFloatClass", value);
- ret= cl.getPropertyValue("PropFloatClass");
- r[i++]= ret instanceof Float && util.anyEquals(value, ret);
- value= new Any(new Type(double.class),new Double(3.145));
- cl.setPropertyValue("PropDoubleClass",value);
- ret= cl.getPropertyValue("PropDoubleClass");
- r[i++]= ret instanceof Double && util.anyEquals(value, ret);
- value= new Any(new Type(String.class), new String("string"));
-
-
-
- // PropertyAttribute.READONLY
- cl.propBoolA.Attributes= PropertyAttribute.READONLY;
- try{
- cl.setPropertyValue("PropBoolA", new Boolean(true));
- i++;
- }catch (com.sun.star.beans.PropertyVetoException e)
- {
- r[i++]= true;
- }
- cl.propBoolA.Attributes= 0;
-
- // MAYBEVOID
- cl.resetPropertyMembers();
- // first MAYBEVOID not set
-
- //primitive members: must not work
-
- cl.boolPropA= false;
- try {
- cl.setPropertyValue("PropBoolA", null); i++;
- } catch (com.sun.star.lang.IllegalArgumentException e) {
- r[i++]= true;
- }
- try {
- cl.setPropertyValue("PropBoolA", new Any(new Type(boolean.class), null)); i++;
- } catch (com.sun.star.lang.IllegalArgumentException e) {
- r[i++]= true;
- }
- cl.propBoolA.Attributes= PropertyAttribute.MAYBEVOID;
- try{
- cl.setPropertyValue("PropBoolA", null); i++;
- } catch (com.sun.star.lang.IllegalArgumentException e) {
- r[i++]= true;
- }
- cl.propBoolA.Attributes= 0;
-
- cl.propBoolClass.Attributes= PropertyAttribute.MAYBEVOID;
- cl.boolClassProp= null;
- cl.setPropertyValue("PropBoolClass", null);
- r[i++]= cl.boolClassProp == null;
- // the returned value must be a void any
- Object objAny= cl.getPropertyValue("PropBoolClass");
- r[i++]= util.isVoidAny( objAny);
-
- cl.boolClassProp= new Boolean(true);
- cl.setPropertyValue("PropBoolClass", null);
- r[i++]= cl.boolClassProp == null;
- cl.boolClassProp= new Boolean(false);
- cl.setPropertyValue("PropBoolClass", new Any(new Type(boolean.class),null));
- r[i++]= cl.boolClassProp == null;
-
- cl.propXWeakA.Attributes= PropertyAttribute.MAYBEVOID;
- cl.setPropertyValue("PropXWeakA", null);
- r[i++]= util.isVoidAny(cl.getPropertyValue("PropXWeakA"));
- cl.propXWeakA.Attributes= 0;
-
- cl.anyPropA= null;
- try{
- cl.setPropertyValue("PropAnyA", null); i++;
- }catch (com.sun.star.lang.IllegalArgumentException e) {
- r[i++]= true;
- }
- cl.anyPropA= null;
- cl.propAnyA.Attributes= PropertyAttribute.MAYBEVOID;
-
- Type _t= new Type(Object.class);
- cl.setPropertyValue("PropAnyA", null);
- r[i++]= cl.anyPropA.getType().equals(new Type(void.class)) &&
- cl.anyPropA.getObject() == null;
-
- cl.anyPropA= new Any(new Type(byte.class),new Byte((byte) 111));
- cl.setPropertyValue("PropAnyA", null);
- r[i++]= cl.anyPropA.getType().equals(new Type(byte.class)) &&
- cl.anyPropA.getObject() == null;
-
- cl.anyPropA= null;
- try{
- cl.setPropertyValue("PropAnyA", new Object()); i++;
- }catch (com.sun.star.lang.IllegalArgumentException e)
- {
- r[i++]= true;
- }
-
- cl.propObjectA.Attributes= 0;
- try{
- cl.setPropertyValue("PropObjectA", null); i++;
- }catch (com.sun.star.lang.IllegalArgumentException e)
- {
- r[i++]= true;
- }
- try{
- cl.setPropertyValue("PropObjectA", new Any( new Type(byte.class), null)); i++;
- } catch (com.sun.star.lang.IllegalArgumentException e)
- {
- r[i++]= true;
- }
-
- cl.propObjectA.Attributes= PropertyAttribute.MAYBEVOID;
- cl.propObjectA= null;
- cl.setPropertyValue("PropObjectA", null);
- r[i++]= cl.propObjectA == null;
-
- cl.propObjectA= null;
- cl.setPropertyValue("PropObjectA", new Any( new Type(byte.class), null));
- r[i++]= cl.propObjectA == null;
-
-
- //
-
- }catch(java.lang.Exception e){
- i++;
- }
- boolean bOk= true;
- for (int c= 0; c < i; c++)
- bOk= bOk && r[c];
- if (bOk == false)
- System.out.println("Failed");
- else
- System.out.println("Ok");
- return bOk;
- }
-
- public boolean addPropertyChangeListener()
- {
- System.out.println("PropertySet.addPropertyChangeListener,\n" +
- "PropertySet.removePropertChangeListener," +
- "PropertySet.addVetoableChangeListener, \n" +
- "PropertySet.removeVetoableChangeListener" +
- "Notification of listeners");
- boolean[] r= new boolean[50];
- int i= 0;
- try {
- TestClass cl= new TestClass();
- Listener li= new Listener();
- cl.addPropertyChangeListener("PropByteA", li);
- Byte val1= new Byte((byte)115);
- cl.setPropertyValue("PropByteA", val1);
- r[i++]= li.nChangeCalled == 0 && li.nVetoCalled == 0;
- cl.propByteA.Attributes = PropertyAttribute.BOUND;
- cl.addPropertyChangeListener("PropByteA", li);
- Byte val2= new Byte((byte)116);
- cl.setPropertyValue("PropByteA", val2);
- r[i++]= li.nChangeCalled == 1 && li.nVetoCalled == 0;
- r[i++]= li.evt.OldValue.equals(val1) && li.evt.NewValue.equals(val2) && li.evt.Source == cl;
-
- li.reset();
- Listener li2= new Listener();
- cl.addPropertyChangeListener("PropByteA", li2);
- Byte val3= new Byte((byte) 117);
- cl.setPropertyValue("PropByteA", val3);
- r[i++]= li.nChangeCalled == 1 && li.nVetoCalled == 0
- && li2.nChangeCalled == 1 && li2.nVetoCalled == 0;
- r[i++]= li.evt.OldValue.equals(val2) && li.evt.NewValue.equals(val3) && li.evt.Source == cl
- && li2.evt.OldValue.equals(val2) && li2.evt.NewValue.equals(val3) && li2.evt.Source == cl ;
-
- li.reset();
- li2.reset();
- Listener li3= new Listener();
- val1= new Byte((byte)118);
- cl.addPropertyChangeListener("", li3);
- cl.setPropertyValue("PropByteA", val1);
- r[i++]= li.nChangeCalled == 1 && li.nVetoCalled == 0
- && li2.nChangeCalled == 1 && li2.nVetoCalled == 0
- && li3.nChangeCalled == 1 && li3.nVetoCalled == 0;
- r[i++]= li.evt.OldValue.equals(val3) && li.evt.NewValue.equals(val1) && li.evt.Source == cl;
- r[i++]= li2.evt.OldValue.equals(val3) && li2.evt.NewValue.equals(val1) && li2.evt.Source == cl;
- r[i++]= li3.evt.OldValue.equals(val3) && li3.evt.NewValue.equals(val1) && li3.evt.Source == cl ;
-
- li.reset();
- li2.reset();
- li3.reset();
- cl.removePropertyChangeListener("PropByteA",li);
- cl.setPropertyValue("PropByteA", val1);
- r[i++]= li.nChangeCalled == 0 && li.nVetoCalled == 0
- && li2.nChangeCalled == 1 && li2.nVetoCalled == 0
- && li3.nChangeCalled == 1 && li3.nVetoCalled == 0;
- cl.removePropertyChangeListener("PropByteA", li2);
- li.reset();
- li2.reset();
- li3.reset();
- cl.setPropertyValue("PropByteA", val1);
- r[i++]= li.nChangeCalled == 0 && li.nVetoCalled == 0
- && li2.nChangeCalled == 0 && li2.nVetoCalled == 0
- && li3.nChangeCalled == 1 && li3.nVetoCalled == 0;
-
- cl.removePropertyChangeListener("", li3);
- li.reset();
- li2.reset();
- li3.reset();
- cl.setPropertyValue("PropByteA", val2);
- r[i++]= li.nChangeCalled == 0 && li.nVetoCalled == 0
- && li2.nChangeCalled == 0 && li2.nVetoCalled == 0
- && li3.nChangeCalled == 0 && li3.nVetoCalled == 0;
-
- cl.addPropertyChangeListener("PropByteA", li);
- cl.addPropertyChangeListener("PropByteA", li2);
- cl.addPropertyChangeListener("", li3);
- cl.dispose();
- li.reset();
- li2.reset();
- li3.reset();
- try {
- cl.setPropertyValue("PropByteA", val2); i++;
- }catch (DisposedException e)
- {
- r[i++]= true;
- }
-
- //Vetoable tests
- cl= new TestClass();
- li.reset();
- li2.reset();
- li3.reset();
- cl.addVetoableChangeListener("PropByteA", li);
- val1= new Byte((byte)115);
- cl.setPropertyValue("PropByteA", val1);
- r[i++]= li.nChangeCalled == 0 && li.nVetoCalled == 0;
- cl.propByteA.Attributes = PropertyAttribute.CONSTRAINED;
- cl.addVetoableChangeListener("PropByteA", li);
- val2= new Byte((byte)116);
- li.reset();
- cl.setPropertyValue("PropByteA", val2);
- r[i++]= li.nChangeCalled == 0 && li.nVetoCalled == 1;
- r[i++]= li.evt.OldValue.equals(val1) && li.evt.NewValue.equals(val2) && li.evt.Source == cl;
-
- li.reset();
- li2.reset();
- li3.reset();
- cl.addVetoableChangeListener("PropByteA", li2);
- val3= new Byte((byte) 117);
- cl.setPropertyValue("PropByteA", val3);
- r[i++]= li.nChangeCalled == 0 && li.nVetoCalled == 1
- && li2.nChangeCalled == 0 && li2.nVetoCalled == 1;
- r[i++]= li.evt.OldValue.equals(val2) && li.evt.NewValue.equals(val3) && li.evt.Source == cl
- && li2.evt.OldValue.equals(val2) && li2.evt.NewValue.equals(val3) && li2.evt.Source == cl ;
-
- li.reset();
- li2.reset();
- li3.reset();
- val1= new Byte((byte)118);
- cl.addVetoableChangeListener("", li3);
- cl.setPropertyValue("PropByteA", val1);
- r[i++]= li.nChangeCalled == 0 && li.nVetoCalled == 1
- && li2.nChangeCalled == 0 && li2.nVetoCalled == 1
- && li3.nChangeCalled == 0 && li3.nVetoCalled == 1;
- r[i++]= li.evt.OldValue.equals(val3) && li.evt.NewValue.equals(val1) && li.evt.Source == cl;
- r[i++]= li2.evt.OldValue.equals(val3) && li2.evt.NewValue.equals(val1) && li2.evt.Source == cl;
- r[i++]= li3.evt.OldValue.equals(val3) && li3.evt.NewValue.equals(val1) && li3.evt.Source == cl ;
-
- li.reset();
- li2.reset();
- li3.reset();
- // Test Veto Exception
- cl.setPropertyValue("PropByteA", val1);
- li.bVeto= true;
- try {
- cl.setPropertyValue("PropByteA", val2);i++;
- } catch (PropertyVetoException e)
- {
- r[i++]= true;
- }
- r[i++]= cl.bytePropA == val1.byteValue();
- li.bVeto= false;
-
- li.reset();
- li2.reset();
- li3.reset();
- cl.removeVetoableChangeListener("PropByteA",li);
- cl.setPropertyValue("PropByteA", val1);
- r[i++]= li.nChangeCalled == 0 && li.nVetoCalled == 0
- && li2.nChangeCalled == 0 && li2.nVetoCalled == 1
- && li3.nChangeCalled == 0 && li3.nVetoCalled == 1;
- cl.removeVetoableChangeListener("PropByteA", li2);
- li.reset();
- li2.reset();
- li3.reset();
- cl.setPropertyValue("PropByteA", val1);
- r[i++]= li.nChangeCalled == 0 && li.nVetoCalled == 0
- && li2.nChangeCalled == 0 && li2.nVetoCalled == 0
- && li3.nChangeCalled == 0 && li3.nVetoCalled == 1;
-
- cl.removeVetoableChangeListener("", li3);
- li.reset();
- li2.reset();
- li3.reset();
- cl.setPropertyValue("PropByteA", val2);
- r[i++]= li.nChangeCalled == 0 && li.nVetoCalled == 0
- && li2.nChangeCalled == 0 && li2.nVetoCalled == 0
- && li3.nChangeCalled == 0 && li3.nVetoCalled == 0;
-
- cl.addVetoableChangeListener("PropByteA", li);
- cl.addVetoableChangeListener("PropByteA", li2);
- cl.addVetoableChangeListener("", li3);
- cl.dispose();
- li.reset();
- li2.reset();
- li3.reset();
- try {
- cl.setPropertyValue("PropByteA", val2);
- }catch (DisposedException e)
- {
- r[i++]= true;
- }
- }catch (Exception e)
- {
- i++;
- }
- boolean bOk= true;
- for (int c= 0; c < i; c++)
- bOk= bOk && r[c];
- if (bOk == false)
- System.out.println("Failed");
- else
- System.out.println("Ok");
- return bOk;
- }
-
- public boolean getPropertySetInfo()
- {
- System.out.println("PropertySet.getPropertySetInfo");
- boolean[] r= new boolean[50];
- int i= 0;
-
- TestClass cl= new TestClass();
- try {
- XPropertySetInfo info= cl.getPropertySetInfo();
- Property[] arProps= info.getProperties();
- Property[] arRegProps= cl.getRegisteredProperties();
- r[i++]= arProps.length == arRegProps.length;
- for (int j= 0; j < arProps.length; j++)
- {
- boolean bFound= false;
- for (int k= 0; k < arRegProps.length; k++)
- {
- if (arProps[j] == arRegProps[k])
- {
- bFound= true;
- break;
- }
- }
- if ( !bFound)
- r[i++]= false;
- }
-
- for (int j= 0; j < arRegProps.length; j++)
- {
- Property prop= info.getPropertyByName(arRegProps[j].Name);
- if (prop != arRegProps[j])
- r[i++]= false;
- if (! info.hasPropertyByName(arRegProps[j].Name))
- r[i++]= false;
- }
-
-
- }catch(java.lang.Exception e){
- System.out.println(e.getMessage());
- i++;
- }
-
- boolean bOk= true;
- for (int c= 0; c < i; c++)
- bOk= bOk && r[c];
- if (bOk == false)
- System.out.println("Failed");
- else
- System.out.println("Ok");
- return bOk;
- }
-
- public boolean setFastPropertyValue()
- {
- System.out.println("PropertySet.setFastPropertyValue");
- boolean[] r= new boolean[50];
- int i= 0;
-
- TestClass cl= new TestClass();
- try {
- cl.setFastPropertyValue(5, new Integer(111));
- r[i++]= cl.intPropA == 111;
- try {
- cl.setFastPropertyValue(-1, new Integer(1)); i++;
- } catch(UnknownPropertyException e)
- {
- r[i++]= true;
- }
- }catch(java.lang.Exception e){
- System.out.println(e.getMessage());
- i++;
- }
-
- boolean bOk= true;
- for (int c= 0; c < i; c++)
- bOk= bOk && r[c];
- if (bOk == false)
- System.out.println("Failed");
- else
- System.out.println("Ok");
- return bOk;
- }
-
- public boolean getFastPropertyValue()
- {
- System.out.println("PropertySet.setFastPropertyValue");
- boolean[] r= new boolean[50];
- int i= 0;
-
- TestClass cl= new TestClass();
- try {
- cl.setFastPropertyValue(5, new Integer(111));
- Integer aInt= (Integer) cl.getFastPropertyValue(5);
- r[i++]= aInt.intValue() == 111;
- }catch(java.lang.Exception e){
- System.out.println(e.getMessage());
- i++;
- }
-
- boolean bOk= true;
- for (int c= 0; c < i; c++)
- bOk= bOk && r[c];
- if (bOk == false)
- System.out.println("Failed");
- else
- System.out.println("Ok");
- return bOk;
- }
-
- public boolean setPropertyValues()
- {
- System.out.println("PropertySet.setPropertyValues");
- boolean[] r= new boolean[50];
- int i= 0;
-
- TestClass cl= new TestClass();
- try {
- cl.setPropertyValues(new String[0], new Object[0]);
- String[] arNames= new String[] {"PropCharA","PropIntClass","PropObjectA"};
- Character aChar= new Character('A');
- Integer aInt= new Integer(111);
- Byte aByte= new Byte((byte)11);
- Object[] values= new Object[]{aChar, aInt, aByte};
- cl.setPropertyValues(arNames, values);
- r[i++]= cl.charPropA == 'A' && cl.intClassProp.intValue() == 111 && ((Byte)cl.objectPropA).byteValue() == 11;
-
- arNames= new String[] {"blabla","PropIntClass","PropObjectA"};
- cl.resetPropertyMembers();
- cl.setPropertyValues(arNames, values);
- r[i++]= cl.intClassProp.intValue() == 111 && ((Byte)cl.objectPropA).byteValue() == 11;
- }catch(java.lang.Exception e){
- System.out.println(e.getMessage());
- i++;
- }
- boolean bOk= true;
- for (int c= 0; c < i; c++)
- bOk= bOk && r[c];
- if (bOk == false)
- System.out.println("Failed");
- else
- System.out.println("Ok");
- return bOk;
- }
-
- public boolean getPropertyValues()
- {
- System.out.println("PropertySet.getPropertyValues");
- boolean[] r= new boolean[50];
- int i= 0;
-
- TestClass cl= new TestClass();
- try {
- cl.charPropA= 'A';
- cl.intClassProp= new Integer(111);
- cl.objectPropA= new Byte((byte)11);
- Object[] values= cl.getPropertyValues(new String[] {"PropCharA","PropIntClass","PropObjectA"});
-
- r[i++]= ((Character) values[0]).charValue() == 'A' && ((Integer) values[1]).intValue() == 111
- && ((Byte) values[2]).byteValue() == 11;
- }catch(java.lang.Exception e){
- System.out.println(e.getMessage());
- i++;
- }
- boolean bOk= true;
- for (int c= 0; c < i; c++)
- bOk= bOk && r[c];
- if (bOk == false)
- System.out.println("Failed");
- else
- System.out.println("Ok");
- return bOk;
- }
-
- // Currently the listeners are always notified if one of properties has changed.
- // The property names in the first argument are ignored.
- public boolean addPropertiesChangeListener()
- {
- System.out.println("PropertySet.addPropertiesChangeListener\n" +
- "PropertySet.removePropertiesChangeListener\n" +
- "notification of such listeners");
- boolean[] r= new boolean[50];
- int i= 0;
-
- TestClass cl= new TestClass();
- try {
- Listener li1= new Listener();
- Listener li2= new Listener();
- cl.addPropertiesChangeListener(new String[]{"PropCharA"}, li1);
- cl.setPropertyValue("PropCharA", new Character('B'));
- r[i++]= li1.nPropertiesChange == 0;
- cl.propCharA.Attributes= PropertyAttribute.BOUND;
- cl.setPropertyValue("PropCharA", new Character('C'));
- r[i++]= li1.nPropertiesChange == 1;
-
- PropertyChangeEvent evt= li1.arEvt[0];
- r[i++]= evt.PropertyName.equals("PropCharA") && ((Character)evt.OldValue).charValue() == 'B'
- && ((Character) evt.NewValue).charValue() == 'C';
- li1.reset();
- cl.removePropertiesChangeListener(li1);
- cl.setPropertyValue("PropCharA", new Character('F'));
- r[i++]= li1.nPropertiesChange == 0;
- }catch(java.lang.Exception e){
- System.out.println(e.getMessage());
- i++;
- }
- boolean bOk= true;
- for (int c= 0; c < i; c++)
- bOk= bOk && r[c];
- if (bOk == false)
- System.out.println("Failed");
- else
- System.out.println("Ok");
- return bOk;
- }
-
- public boolean firePropertiesChangeEvent()
- {
- System.out.println("PropertySet.firePropertiesChangeEvent");
- boolean[] r= new boolean[50];
- int i= 0;
-
- TestClass cl= new TestClass();
- try {
- Listener li1= new Listener();
- cl.intClassProp= new Integer(111);
- cl.charPropA= 'A';
- cl.firePropertiesChangeEvent(new String[]{"PropCharA","PropIntClass"}, li1);
- r[i++]= li1.nPropertiesChange == 1;
- PropertyChangeEvent[] arEvt= li1.arEvt;
- r[i++]= arEvt[0].PropertyName.equals("PropCharA")
- && ((Character) arEvt[0].OldValue).charValue() == 'A'
- && ((Character) arEvt[0].NewValue).charValue() == 'A';
- r[i++]= arEvt[1].PropertyName.equals("PropIntClass")
- && ((Integer) arEvt[1].OldValue).intValue() == 111
- && ((Integer) arEvt[1].NewValue).intValue() == 111;
- }catch(java.lang.Exception e){
- System.out.println(e.getMessage());
- i++;
- }
- boolean bOk= true;
- for (int c= 0; c < i; c++)
- bOk= bOk && r[c];
- if (bOk == false)
- System.out.println("Failed");
- else
- System.out.println("Ok");
- return bOk;
- }
-
- public boolean registerProperty1()
- {
- TestClass2 cl= new TestClass2();
- return cl.test_registerProperty1();
- }
-
- public boolean registerProperty2()
- {
- TestClass2 cl= new TestClass2();
- return cl.test_registerProperty2();
- }
-
- public static boolean test()
- {
- PropertySet_Test test= new PropertySet_Test();
- boolean r[]= new boolean[50];
- int i= 0;
- r[i++]= test.convertPropertyValue();
- r[i++]= test.setPropertyValueNoBroadcast();
- r[i++]= test.setPropertyValue();
- r[i++]= test.addPropertyChangeListener();
- r[i++]= test.getPropertySetInfo();
- r[i++]= test.setFastPropertyValue();
- r[i++]= test.getFastPropertyValue();
- r[i++]= test.setPropertyValues();
- r[i++]= test.getPropertyValues();
- r[i++]= test.addPropertiesChangeListener();
- r[i++]= test.firePropertiesChangeEvent();
- r[i++]= test.registerProperty1();
- r[i++]= test.registerProperty2();
- boolean bOk= true;
- for (int c= 0; c < i; c++)
- bOk= bOk && r[c];
- if (bOk == false)
- System.out.println("Errors occurred!");
- else
- System.out.println("No errors.");
- return bOk;
- }
- public static void main(String[] args)
- {
- test();
- }
-}
-
-class TestClass extends PropertySet
-{
- public Property propBoolA= new Property("PropBoolA", 1, new Type(Boolean.TYPE), (short)0);
- public boolean boolPropA;
- public Property propCharA= new Property("PropCharA", 2, new Type(Character.TYPE), (short) 0);
- public char charPropA;
- public Property propByteA= new Property("PropByteA", 3, new Type(Byte.TYPE), (short) 0);
- public byte bytePropA;
- public Property propShortA= new Property("PropShortA", 4, new Type(Short.TYPE), (short) 0);
- public short shortPropA;
- public Property propIntA= new Property("PropIntA", 5, new Type(Integer.TYPE), (short) 0);
- public int intPropA;
- public Property propLongA= new Property("PropLongA", 6, new Type(Long.TYPE), (short) 0);
- public long longPropA;
- public Property propFloatA= new Property("PropFloatA", 7, new Type(Float.TYPE), (short) 0);
- public float floatPropA;
- public Property propDoubleA= new Property("PropDoubleA", 8, new Type(Double.TYPE), (short) 0);
- public double doublePropA;
- public Property propStringA= new Property("PropStringA", 9, new Type(String.class), (short) 0);
- public String stringPropA;
- public Property propArrayByteA= new Property("PropArrayByteA", 10, new Type(byte[].class), (short) 0);
- public byte[] arBytePropA;
- public Property propTypeA= new Property("PropTypeA", 11, new Type(Type.class), (short) 0);
- public Type typePropA;
- public Property propObjectA= new Property("PropObjectA",12, new Type(Object.class), (short) 0);
- public Object objectPropA;
- public Property propAnyA= new Property("PropAnyA", 13, new Type(Any.class), (short) 0);
- public Any anyPropA;
- public Property propXInterfaceA= new Property("PropXInterfaceA", 13, new Type(Any.class), (short) 0);
- public XInterface xInterfacePropA;
- public Property propXWeakA= new Property("PropXWeakA", 13, new Type(Any.class), (short) 0);
- public XWeak xWeakPropA;
- public Property propEnum =
- new Property("PropEnum", 14, new Type("com.sun.star.beans.PropertyState", TypeClass.ENUM), (short)0);
- public com.sun.star.beans.PropertyState enumPropertyState = com.sun.star.beans.PropertyState.DEFAULT_VALUE;
- // Test private, protected, package access, Anys as arguments and members, members whith a value
-
- public Property propBoolB= new Property("PropBoolB", 101, new Type(Boolean.TYPE), (short) 0);
- protected boolean boolPropB;
-
- public Property propBoolC= new Property("PropBoolC", 201, new Type(Boolean.TYPE), (short) 0);
- boolean boolPropC;
-
- public Property propBoolD= new Property("PropBoolD", 301, new Type(Boolean.TYPE), (short) 0);
- private boolean boolPropD;
-
- public Property propBoolClass= new Property("PropBoolClass", 1001, new Type(Boolean.class), (short) 0);
- public Boolean boolClassProp;
- public Property propCharClass= new Property("PropCharClass", 1002, new Type(Character.class), (short) 0);
- public Character charClassProp;
- public Property propByteClass= new Property("PropByteClass", 1003, new Type(Byte.class), (short) 0);
- public Byte byteClassProp;
- public Property propShortClass= new Property("PropShortClass", 1004, new Type(Short.class), (short) 0);
- public Short shortClassProp;
- public Property propIntClass= new Property("PropIntClass", 1005, new Type(Integer.class), (short) 0);
- public Integer intClassProp;
- public Property propLongClass= new Property("PropLongClass", 1006, new Type(Long.class), (short) 0);
- public Long longClassProp;
- public Property propFloatClass= new Property("PropFloatClass", 1007, new Type(Float.class), (short) 0);
- public Float floatClassProp;
- public Property propDoubleClass= new Property("PropDoubleClass", 1008, new Type(Double.class), (short) 0);
- public Double doubleClassProp;
-
-
- public TestClass()
- {
-
- super();
-// When adding properties then modify the getRegisteredProperties method
- //registerProperty(String name, int handle, Type type, short attributes, String memberName)
- registerProperty(propBoolA, "boolPropA");
- registerProperty(propCharA, "charPropA");
- registerProperty(propByteA, "bytePropA");
- registerProperty(propShortA, "shortPropA");
- registerProperty(propIntA, "intPropA");
- registerProperty(propLongA, "longPropA");
- registerProperty(propFloatA, "floatPropA");
- registerProperty(propDoubleA, "doublePropA");
- registerProperty(propStringA, "stringPropA");
- registerProperty(propArrayByteA, "arBytePropA");
- registerProperty(propTypeA, "typePropA");
- registerProperty(propObjectA, "objectPropA");
- registerProperty(propAnyA, "anyPropA");
- registerProperty(propXInterfaceA, "xInterfacePropA");
- registerProperty(propXWeakA, "xWeakPropA");
- registerProperty(propEnum,"enumPropertyState");
- registerProperty(propBoolB, "boolPropB");
- registerProperty(propBoolC, "boolPropC");
- registerProperty(propBoolD, "boolPropD");
- registerProperty(propBoolClass, "boolClassProp");
- registerProperty(propCharClass, "charClassProp");
- registerProperty(propByteClass, "byteClassProp");
- registerProperty(propShortClass, "shortClassProp");
- registerProperty(propIntClass, "intClassProp");
- registerProperty(propLongClass, "longClassProp");
- registerProperty(propFloatClass, "floatClassProp");
- registerProperty(propDoubleClass, "doubleClassProp");
- }
-
- /** When adding properties then modify the getRegisteredProperties method
- */
- public Property[] getRegisteredProperties()
- {
- return new Property[] {
- propBoolA, propCharA, propByteA, propShortA,
- propIntA, propLongA, propFloatA, propDoubleA,
- propStringA, propArrayByteA, propTypeA, propObjectA,
- propAnyA, propXInterfaceA, propXWeakA, propEnum, propBoolB,
- propBoolC, propBoolD, propBoolClass, propCharClass,
- propByteClass, propShortClass, propIntClass, propLongClass,
- propFloatClass, propDoubleClass
- };
-
- }
- public boolean test_convertPropertyValue()
- {
- boolean[] r= new boolean[150];
- int i= 0;
-
- resetPropertyMembers();
- Object[] outOldVal= new Object[1];
- Object[] outNewVal= new Object[1];
-
- Object value= new Boolean(true);
- try
- {
- r[i++]= convertPropertyValue(propBoolA, outNewVal, outOldVal, value);
- r[i++]= outNewVal[0] instanceof Boolean && outNewVal[0].equals(value) && outOldVal[0].equals(new Boolean(false));
- value= new Character('A');
- r[i++]= convertPropertyValue(propCharA, outNewVal, outOldVal, value);
- r[i++]= outNewVal[0] instanceof Character && outNewVal[0].equals(value) && outOldVal[0].equals(new Character((char)0));
- charPropA= 'B';
- r[i++]= convertPropertyValue(propCharA, outNewVal, outOldVal, value);
- r[i++]= outNewVal[0] instanceof Character && outNewVal[0].equals(value) && outOldVal[0].equals(new Character('B'));
- value= new Byte((byte) 111);
- r[i++]= convertPropertyValue(propByteA, outNewVal, outOldVal, value);
- r[i++]= outNewVal[0] instanceof Byte && outNewVal[0].equals(value);
- value= new Short((short) 112);
- r[i++]= convertPropertyValue(propShortA, outNewVal, outOldVal, value);
- r[i++]= outNewVal[0] instanceof Short && outNewVal[0].equals(value);
- value= new Integer( 113);
- r[i++]= convertPropertyValue(propIntA, outNewVal, outOldVal, value);
- r[i++]= outNewVal[0] instanceof Integer && outNewVal[0].equals(value);
- value= new Long(114);
- r[i++]= convertPropertyValue(propLongA, outNewVal, outOldVal, value);
- r[i++]= outNewVal[0] instanceof Long && outNewVal[0].equals(value);
- value= new Float(3.14);
- r[i++]= convertPropertyValue(propFloatA, outNewVal, outOldVal, value);
- r[i++]= outNewVal[0] instanceof Float && outNewVal[0].equals(value);
- value= new Double(3.145);
- r[i++]= convertPropertyValue(propDoubleA, outNewVal, outOldVal, value);
- r[i++]= outNewVal[0] instanceof Double && outNewVal[0].equals(value);
- value= "string";
- r[i++]= convertPropertyValue(propStringA, outNewVal, outOldVal, value);
- r[i++]= outNewVal[0] instanceof String && outNewVal[0].equals(value);
- value= new byte[]{1,2,3};
- arBytePropA= null;
- r[i++]= convertPropertyValue(propArrayByteA, outNewVal, outOldVal, value);
- r[i++]= outNewVal[0] instanceof byte[] && outNewVal[0].equals(value) && outOldVal[0] == null;
- r[i++]= convertPropertyValue(propArrayByteA, outNewVal, outOldVal, value);
- r[i++]= outOldVal[0] == null;
- value= new Type(XInterface.class);
- r[i++]= convertPropertyValue(propTypeA, outNewVal, outOldVal, value);
- r[i++]= outNewVal[0] instanceof Type && outNewVal[0].equals(value);
-
- value= new Object(); // TypeClass.VOID
- r[i++]= convertPropertyValue(propObjectA, outNewVal, outOldVal, value);
- r[i++]= outNewVal[0] instanceof Object && outNewVal[0].equals(value);
- value= new Integer(111);
- r[i++]= convertPropertyValue(propObjectA, outNewVal, outOldVal, value);
- r[i++]= outNewVal[0] instanceof Integer && outNewVal[0].equals(value);
- value= new ComponentBase();
- r[i++]= convertPropertyValue(propObjectA, outNewVal, outOldVal, value);
- r[i++]= outNewVal[0] instanceof Object && outNewVal[0].equals(value);
- value= new Integer(111);
- r[i++]= convertPropertyValue(propAnyA, outNewVal, outOldVal, value);
- r[i++]= outNewVal[0] instanceof Any && ((Any)outNewVal[0]).getType().equals(new Type(Integer.class))
- && ((Any)outNewVal[0]).getObject().equals(value);
- XWeak oWeak= new ComponentBase();
- value= oWeak;
- // The returned Any must contain an XInterface
- r[i++]= convertPropertyValue(propAnyA, outNewVal, outOldVal, value);
- r[i++]= ((Any) outNewVal[0]).getType().equals(new Type(XInterface.class))
- && ((Any) outNewVal[0]).getObject() == oWeak;
- value= new ComponentBase();
- r[i++]= convertPropertyValue(propXInterfaceA, outNewVal, outOldVal, value);
- r[i++]= outNewVal[0] instanceof XInterface && outNewVal[0].equals(value);
- r[i++]= convertPropertyValue(propXWeakA, outNewVal, outOldVal, value);
- r[i++]= outNewVal[0] instanceof XWeak && outNewVal[0].equals(value);
-
- value = com.sun.star.beans.PropertyState.DIRECT_VALUE;
- r[i++]= convertPropertyValue(propEnum, outNewVal, outOldVal, value);
- r[i++]= outNewVal[0] instanceof com.sun.star.uno.Enum && outNewVal[0].equals(value);
-
- // Any arguments ------------------------------------------------------------------
- value= new Any( new Type(Integer.class),new Integer(111));
- r[i++]= convertPropertyValue(propIntA, outNewVal, outOldVal, value);
- r[i++]= outNewVal[0] instanceof Integer && ((Integer)outNewVal[0]).equals( ((Any)value).getObject());
- value= new Any(new Type(Boolean.class), new Boolean(true));
- r[i++]= convertPropertyValue(propBoolA, outNewVal, outOldVal, value);
- r[i++]= outNewVal[0] instanceof Boolean && ((Boolean)outNewVal[0]).equals(((Any) value).getObject());
- //Character, Byte, Short, Long
- // must fail
- value= new Any(new Type(Object.class), new Object());
- r[i++]= convertPropertyValue(propObjectA, outNewVal, outOldVal, value);
- r[i++]= convertPropertyValue(propAnyA, outNewVal, outOldVal, value);
- value= new Any(new Type(Integer.class), new Integer(111));
- r[i++]= convertPropertyValue(propObjectA, outNewVal, outOldVal, value);
- r[i++]= outNewVal[0] instanceof Integer && outNewVal[0].equals( ((Any)value).getObject());
- r[i++]= convertPropertyValue(propAnyA, outNewVal, outOldVal, value);
- r[i++]= outNewVal[0] instanceof Any && ((Any) outNewVal[0]).getType().equals( ((Any) value).getType())
- && ((Any) outNewVal[0]).getObject().equals( ((Any) value).getObject());
- value= new Any(new Type(XInterface.class), new ComponentBase());
- r[i++]= convertPropertyValue(propObjectA, outNewVal, outOldVal, value);
- r[i++]= outNewVal[0] instanceof XInterface && outNewVal[0] == ((Any) value).getObject();
- r[i++]= convertPropertyValue(propXInterfaceA, outNewVal, outOldVal, value);
- r[i++]= outNewVal[0] == ((Any) value).getObject();
- value= new Any(new Type(byte[].class), new byte[]{1,2,3});
- r[i++]= convertPropertyValue(propArrayByteA, outNewVal, outOldVal, value);
- r[i++]= outNewVal[0] instanceof byte[];
-
-
-
- // test private, protected, package fields
- value= new Boolean(true);
- r[i++]= convertPropertyValue(propBoolB, outNewVal, outOldVal, value);
- r[i++]= ((Boolean)value).booleanValue() == ((Boolean) outNewVal[0]).booleanValue();
- r[i++]= convertPropertyValue(propBoolC, outNewVal, outOldVal, value);
- r[i++]= ((Boolean)value).booleanValue() == ((Boolean) outNewVal[0]).booleanValue();
- // must fail because the the member boolPropD is private
- try{
- convertPropertyValue(propBoolD, outNewVal, outOldVal, value);
- i++;
- }catch (Exception e)
- {
- r[i++]= true;
- }
-
- // Properties member of type Byte,Short etc.
- value= new Boolean(true);
- r[i++]= convertPropertyValue(propBoolClass, outNewVal, outOldVal, value);
- r[i++]= outNewVal[0] instanceof Boolean && outNewVal[0].equals(value);
- value= new Character('A');
- r[i++]= convertPropertyValue(propCharClass, outNewVal, outOldVal, value);
- r[i++]= outNewVal[0] instanceof Character && outNewVal[0].equals(value);
- value= new Byte((byte) 111);
- r[i++]= convertPropertyValue(propByteClass, outNewVal, outOldVal, value);
- r[i++]= outNewVal[0] instanceof Byte && outNewVal[0].equals(value);
- value= new Short((short) 112);
- r[i++]= convertPropertyValue(propShortClass, outNewVal, outOldVal, value);
- r[i++]= outNewVal[0] instanceof Short && outNewVal[0].equals(value);
- value= new Integer( 113);
- r[i++]= convertPropertyValue(propIntClass, outNewVal, outOldVal, value);
- r[i++]= outNewVal[0] instanceof Integer && outNewVal[0].equals(value);
- value= new Long(114);
- r[i++]= convertPropertyValue(propLongClass, outNewVal, outOldVal, value);
- r[i++]= outNewVal[0] instanceof Long && outNewVal[0].equals(value);
- value= new Float(3.14);
- r[i++]= convertPropertyValue(propFloatClass, outNewVal, outOldVal, value);
- r[i++]= outNewVal[0] instanceof Float && outNewVal[0].equals(value);
- value= new Double(3.145);
- r[i++]= convertPropertyValue(propDoubleA, outNewVal, outOldVal, value);
- r[i++]= outNewVal[0] instanceof Double && outNewVal[0].equals(value);
- }catch (com.sun.star.uno.Exception e)
- {
- i++;
- }
- boolean bOk= true;
- for (int c= 0; c < i; c++)
- bOk= bOk && r[c];
-
- return bOk;
- }
-
- public boolean test_setPropertyValueNoBroadcast()
- {
- boolean[] r= new boolean[150];
- int i= 0;
- resetPropertyMembers();
- try {
- Object value= new Boolean(true);
- setPropertyValueNoBroadcast(propBoolA, value);
- r[i++]= boolPropA == ((Boolean) value).booleanValue();
- value= new Character('A');
- setPropertyValueNoBroadcast(propCharA, value);
- r[i++]= charPropA == ((Character) value).charValue();
- value= new Byte((byte) 111);
- setPropertyValueNoBroadcast(propByteA, value);
- r[i++]= bytePropA == ((Byte)value).byteValue();
- value= new Short((short) 112);
- setPropertyValueNoBroadcast(propShortA, value);
- r[i++]= shortPropA == ((Short) value).shortValue();
- value= new Integer( 113);
- setPropertyValueNoBroadcast(propIntA, value);
- r[i++]= intPropA == ((Integer) value).intValue();
- value= new Long(114);
- setPropertyValueNoBroadcast(propLongA, value);
- r[i++]= longPropA == ((Long) value).longValue();
- value= new Float(3.14);
- setPropertyValueNoBroadcast(propFloatA, value);
- r[i++]= floatPropA == ((Float) value).floatValue();
- value= new Double(3.145);
- setPropertyValueNoBroadcast(propDoubleA, value);
- r[i++]= doublePropA == ((Double) value).doubleValue();
- value= "string";
- setPropertyValueNoBroadcast(propStringA, value);
- r[i++]= stringPropA.equals(value);
- value= new byte[]{1,2,3};
- setPropertyValueNoBroadcast(propArrayByteA, value);
- r[i++]= arBytePropA.equals(value);
- value= new Type(XInterface.class);
- setPropertyValueNoBroadcast(propTypeA, value);
- r[i++]= typePropA.equals(value);
- value= new Integer(111);
- setPropertyValueNoBroadcast(propObjectA, value);
- r[i++]= objectPropA.equals(value);
- value= (XInterface) new ComponentBase();
- setPropertyValueNoBroadcast(propObjectA, value);
- r[i++]= objectPropA.equals(value);
- value= new Any( new Type(Integer.TYPE), new Integer(111));
- setPropertyValueNoBroadcast(propAnyA, value);
- r[i++]= util.anyEquals(anyPropA, value);
- value= new ComponentBase();
- setPropertyValueNoBroadcast(propXInterfaceA, value);
- r[i++]= xInterfacePropA instanceof XInterface && xInterfacePropA.equals(value);
- setPropertyValueNoBroadcast(propXWeakA, value);
- r[i++]= xInterfacePropA instanceof XWeak && xInterfacePropA.equals(value);
- value = com.sun.star.beans.PropertyState.AMBIGUOUS_VALUE;
- setPropertyValueNoBroadcast(propEnum, value);
- r[i++]= enumPropertyState == value;
- value= new Boolean(true);
- setPropertyValueNoBroadcast(propBoolB, value);
- r[i++]= boolPropB == ((Boolean) value).booleanValue();
- setPropertyValueNoBroadcast(propBoolC, value);
- r[i++]= boolPropC == ((Boolean) value).booleanValue();
- // must fail because the the member boolPropD is private
- try{
- setPropertyValueNoBroadcast(propBoolD, value);
- }catch(com.sun.star.lang.WrappedTargetException e)
- {
- r[i++]= true;
- }
- }catch (java.lang.Exception e)
- {
- i++;
- }
- boolean bOk= true;
- for (int c= 0; c < i; c++)
- bOk= bOk && r[c];
- return bOk;
- }
-
- void resetPropertyMembers()
- {
- boolPropA= false;
- charPropA= (char) 0;
- bytePropA= 0;
- shortPropA= 0;
- intPropA= 0;
- longPropA= 0;
- floatPropA= 0;
- doublePropA= 0.;
- stringPropA= null;
- arBytePropA= null;
- typePropA= null;
- objectPropA= null;
- anyPropA= null;
- xInterfacePropA= null;
- xWeakPropA= null;
- enumPropertyState = com.sun.star.beans.PropertyState.DEFAULT_VALUE;
- boolPropB= false;
- boolPropC= false;
- boolPropD= false;
- boolClassProp= null;
- charClassProp= null;
- byteClassProp= null;
- shortClassProp= null;
- intClassProp= null;
- longClassProp= null;
- floatClassProp= null;
- doubleClassProp= null;
- }
-}
-
-class TestClass2 extends PropertySet
-{
-
- public char charA;
- protected char charB;
- char charC;
-
- int intMemberA;
-
- public Character charClassA;
- protected Character charClassB;
- Character charClassC;
-
- boolean test_registerProperty1()
- {
- System.out.println("registerProperty Test 1");
- boolean r[]= new boolean[50];
- int i= 0;
-
- registerProperty("PropChar", new Type(char.class), (short) 0, "PropChar");
- registerProperty("PropInt", new Type(int.class), (short) 0, "PropInt");
- registerProperty("PropString", new Type(String.class), (short) 0, "PropString");
-
- XPropertySetInfo info= getPropertySetInfo();
- Property[] props= info.getProperties();
- for (int j= 0; j < props.length; j++)
- {
- Property aProp= props[j];
- if (aProp.Name.equals("PropChar") && aProp.Type.equals(new Type(char.class)) &&
- aProp.Attributes == 0)
- r[i++]= true;
- else if (aProp.Name.equals("PropInt") && aProp.Type.equals(new Type(int.class)) &&
- aProp.Attributes == 0)
- r[i++]= true;
- else if (aProp.Name.equals("PropString") && aProp.Type.equals(new Type(String.class)) &&
- aProp.Attributes == 0)
- r[i++]= true;
- else
- r[i++]= false;
- }
-
- boolean bOk= true;
- for (int c= 0; c < i; c++)
- bOk= bOk && r[c];
- if (bOk == false)
- System.out.println("Failed");
- else
- System.out.println("Ok");
- return bOk;
- }
-
- boolean test_registerProperty2()
- {
- System.out.println("registerProperty Test 2");
- boolean r[]= new boolean[50];
- int i= 0;
-
- registerProperty("charA", "charA", (short) 0);
- registerProperty("charB", "charB", (short) 0);
- registerProperty("charC", "charC", (short) 0);
- registerProperty("charClassB", "charClassB", PropertyAttribute.MAYBEVOID);
- registerProperty("IntProp", "intMemberA", (short) 0);
-
- XPropertySetInfo info= getPropertySetInfo();
- Property[] props= info.getProperties();
- for (int j= 0; j < props.length; j++)
- {
- Property aProp= props[j];
- if (aProp.Name.equals("charA") && aProp.Type.equals(new Type(char.class)) &&
- aProp.Attributes == 0)
- r[i++]= true;
- else if (aProp.Name.equals("charB") && aProp.Type.equals(new Type(char.class)) &&
- aProp.Attributes == 0)
- r[i++]= true;
- else if (aProp.Name.equals("charC") && aProp.Type.equals(new Type(char.class)) &&
- aProp.Attributes == 0)
- r[i++]= true;
- else if (aProp.Name.equals("charClassB") && aProp.Type.equals(new Type(char.class)) &&
- aProp.Attributes == PropertyAttribute.MAYBEVOID)
- r[i++]= true;
- else if (aProp.Name.equals("IntProp") && aProp.Type.equals(new Type(int.class)) &&
- aProp.Attributes == 0)
- r[i++]= true;
- else
- r[i++]= false;
- }
- Object ret;
- Object val= new Character('A');
- try{
- setPropertyValue("charA", val);
- ret= getPropertyValue("charA");
- r[i++]= val.equals(ret);
- setPropertyValue("charClassB",val);
- ret= getPropertyValue("charClassB");
- r[i++]= val.equals(ret);
- val= new Integer(111);
- setPropertyValue("IntProp",val);
- ret= getPropertyValue("IntProp");
- r[i++]= val.equals(ret);
- }
- catch(Exception e)
- {
- r[i++]=false;
- }
- boolean bOk= true;
- for (int c= 0; c < i; c++)
- bOk= bOk && r[c];
- if (bOk == false)
- System.out.println("Failed");
- else
- System.out.println("Ok");
- return bOk;
- }
-
-}
-
-class util
-{
- // An Object is considered an Any with TypeClass.VOID and no value.
- static boolean anyEquals(Object val1, Object val2)
- {
- Object obj1= null;
- Object obj2= null;
- Type t1= null;
- Type t2= null;
- if (val1 instanceof Any)
- {
- obj1= ((Any) val1).getObject();
- t1= ((Any) val1).getType();
- }
- else
- obj1= val1;
-
- if (val2 instanceof Any)
- {
- obj2= ((Any) val2).getObject();
- t2= ((Any) val2).getType();
- }
- else
- obj2= val2;
-
- if (obj1 != null && obj1.equals(obj2))
- return true;
- else if ((obj1 == null && obj2 == null) && t1 != null && t1.equals(t2))
- return true;
- return false;
- }
-
- // returns true if obj is an any that contains a void or interface type and the
- // object is null
- static boolean isVoidAny(Object obj)
- {
- boolean ret= false;
- if( obj != null && obj instanceof Any)
- {
- Any a= (Any) obj;
- if( a.getType().getTypeClass().equals( TypeClass.INTERFACE)
- && a.getObject() == null) {
- ret= true;
- }
- else if( a.getType().equals( new Type(void.class)) && a.getObject() == null) {
- ret= true;
- }
- }
- return ret;
- }
-}
-
-class Listener implements XPropertyChangeListener, XVetoableChangeListener,
-XPropertiesChangeListener
-{
- int nChangeCalled;
- int nPropertiesChange;
- int nVetoCalled;
- int nDisposingCalled;
- boolean bVeto= false;
- PropertyChangeEvent evt;
- PropertyChangeEvent[] arEvt;
- // XPropertyChangeListener
- public void propertyChange(PropertyChangeEvent evt )
- {
- nChangeCalled++;
- this.evt= evt;
- }
-
- //VetoableChangeListener
- public void vetoableChange(PropertyChangeEvent evt ) throws PropertyVetoException
- {
- nVetoCalled++;
- this.evt= evt;
- if (bVeto)
- throw new PropertyVetoException();
- }
-
- public void disposing( /*IN*/EventObject Source )
- {
- nDisposingCalled++;
- }
-
- public void reset()
- {
- nChangeCalled= 0;
- nPropertiesChange= 0;
- nVetoCalled= 0;
- nDisposingCalled= 0;
- evt= null;
- arEvt= null;
- bVeto= false;
- }
- // XPropertiesChangeListener
- public void propertiesChange(PropertyChangeEvent[] propertyChangeEvent)
- {
- nPropertiesChange++;
- arEvt= propertyChangeEvent;
- }
-
-}
diff --git a/javaunohelper/test/com/sun/star/lib/uno/helper/ProxyProvider.java b/javaunohelper/test/com/sun/star/lib/uno/helper/ProxyProvider.java
deleted file mode 100644
index ba25567fd..000000000
--- a/javaunohelper/test/com/sun/star/lib/uno/helper/ProxyProvider.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-package com.sun.star.lib.uno.helper;
-import com.sun.star.uno.Type;
-import com.sun.star.lib.uno.typedesc.TypeDescription;
-import com.sun.star.uno.UnoRuntime;
-import com.sun.star.lang.XEventListener;
-import com.sun.star.uno.IQueryInterface;
-//import com.sun.star.lib.uno.environments.java.Proxy;
-import com.sun.star.lib.uno.environments.java.java_environment;
-//import com.sun.star.lib.uno.environments.java.IRequester;
-
-
-public class ProxyProvider
-{
- static java_environment env= new java_environment(null);
-
- /** Creates a new instance of ProxyProvider */
- public ProxyProvider()
- {
- }
- /** returns Holder proxy objects for the specified interface. If the method is called
- * several times with the same arguments then each time a new HolderProxy is returned.
- * Then all HolderProxy s refer to the same Proxy object.
- * The proxy can be queried for XEventListener. On the returned proxy disposing can be called
- *
- */
- public static Object createProxy(Object obj, Class iface)
- {
-
- Object retVal= null;
- if (obj == null || iface == null || iface.isInstance(obj) == false )
- return retVal;
-
- Type type= new Type(TypeDescription.getTypeDescription(iface));
- Type evtType= new Type(TypeDescription.getTypeDescription(com.sun.star.lang.XEventListener.class));
- // find the object identifier
- String sOid= UnoRuntime.generateOid(obj);
- retVal= env.getRegisteredInterface(sOid, type);
- // if retVal == null then probably not registered
- if (retVal == null)
- {
- Object aProxy = new Proxy(sOid, type);
- String[] arOid = new String[]
- {sOid};
- retVal= env.registerInterface(aProxy, arOid, type);
- }
- return retVal;
- }
-}
-
-class Proxy implements IQueryInterface, XEventListener
-{
- String oid;
- Type type;
- Proxy(String oid, Type t) {
- this.oid = oid;
- this.type = t;
- }
-
- public String getOid() {
- return oid;
- }
-
- public boolean isSame(Object object) {
- if (object instanceof IQueryInterface)
- {
- IQueryInterface iquery = (IQueryInterface) object;
- if (iquery != null)
- {
- if (iquery.getOid().equals(oid))
- return true;
- else
- return false;
- }
- }
-
- String oidObj = UnoRuntime.generateOid(object);
- if (oidObj.equals(oid))
- return true;
- else
- return false;
- }
-
- public Object queryInterface(Type type) {
- return null;
- }
-
- public void disposing(com.sun.star.lang.EventObject eventObject) {
- }
-
-}
-
-
-//class Requester //implements IRequester
-//{
-// int _modus;
-// boolean _virtual;
-// boolean _forceSynchronous;
-// boolean _passed = true;
-//
-// Object _xEventListenerProxy;
-// int nDisposingCalled= 0;
-//
-// Requester(boolean virtual, boolean forceSynchronous, Object evtListener)
-// {
-// _virtual = virtual;
-// _forceSynchronous = forceSynchronous;
-// _xEventListenerProxy= evtListener;
-//
-// }
-//
-// public Object sendRequest(Object object,
-// Type type,
-// String operation,
-// Object params[],
-// Boolean synchron[],
-// Boolean mustReply[]) throws Throwable
-// {
-//
-// Object result = null;
-// if (operation.equals("disposing"))
-// {
-// System.out.println("Disposing called on XEventListener proxy");
-// nDisposingCalled++;
-// }
-// else if (operation.equals("queryInterface"))
-// {
-// if (params[0] instanceof Type)
-// {
-// Type t= (Type) params[0];
-// if (t.equals( new Type("com.sun.star.lang.XEventListener")))
-// result= _xEventListenerProxy;
-// }
-// }
-// return result;
-// }
-//}
-
-
diff --git a/javaunohelper/test/com/sun/star/lib/uno/helper/UnoUrlTest.java b/javaunohelper/test/com/sun/star/lib/uno/helper/UnoUrlTest.java
deleted file mode 100644
index 371e3d838..000000000
--- a/javaunohelper/test/com/sun/star/lib/uno/helper/UnoUrlTest.java
+++ /dev/null
@@ -1,261 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-package com.sun.star.lib.uno.helper;
-public class UnoUrlTest {
-
- private UnoUrlTest() {
- }
-
-
- private void fail(String msg) {
- System.err.println(msg);
- System.exit(1);
- }
-
- private static void log(String msg) {
- System.out.println(msg);
- }
-
- private void assertTrue(boolean b) {
- if (!b)
- fail("boolean assertion failed");
- }
-
- private void assertEquals(String expected, String actual) {
- if (!expected.equals(actual)) {
- fail("Expected: '"+ expected + "' but was: '"+actual+"'");
- }
- }
-
- private void assertEquals(int expected, int actual) {
- if (expected != actual) {
- fail("Expected: "+ expected + " but was: "+actual);
- }
- }
-
- public void testStart1() {
- try {
- UnoUrl url = UnoUrl.parseUnoUrl("uno:x;y;z");
- assertTrue((url != null));
- assertEquals("x", url.getConnection());
- } catch (com.sun.star.lang.IllegalArgumentException e) {
- fail("Caught exception:" + e.getMessage());
- }
- }
-
- public void testStart2() {
- try {
- UnoUrl url = UnoUrl.parseUnoUrl("uno1:x;y;z");
- fail("Should throw an exception");
- } catch (com.sun.star.lang.IllegalArgumentException e) {
- }
- }
-
- public void testStart3() {
- try {
- UnoUrl url = UnoUrl.parseUnoUrl("un:x;y;z");
- fail("Should throw an exception");
- } catch (com.sun.star.lang.IllegalArgumentException e) {
- }
- }
-
- public void testStart4() {
- try {
- UnoUrl url = UnoUrl.parseUnoUrl("x;y;z");
- assertTrue((url != null));
- assertEquals("y", url.getProtocol());
- } catch (com.sun.star.lang.IllegalArgumentException e) {
- fail("Caught exception:" + e.getMessage());
- }
- }
-
- public void testParam1() {
- try {
- UnoUrl url = UnoUrl.parseUnoUrl("uno:");
- fail("Should throw an exception");
- } catch (com.sun.star.lang.IllegalArgumentException e) {
- }
- }
-
- public void testParam2() {
- try {
- UnoUrl url = UnoUrl.parseUnoUrl("uno:a;");
- fail("Should throw an exception");
- } catch (com.sun.star.lang.IllegalArgumentException e) {
- }
- }
-
- public void testPartName1() {
- try {
- UnoUrl url = UnoUrl.parseUnoUrl("uno:abc!abc;b;c");
- fail("Should throw an exception");
- } catch (com.sun.star.lang.IllegalArgumentException e) {
- }
- }
-
- public void testOID1() {
- try {
- UnoUrl url = UnoUrl.parseUnoUrl("uno:x;y;ABC<ABC");
- fail("Should throw an exception");
- } catch (com.sun.star.lang.IllegalArgumentException e) {
- }
- }
-
- public void testOIDandParams1() {
- try {
- UnoUrl url = UnoUrl.parseUnoUrl("uno:x,key9=val9;y;ABC");
- assertTrue((url != null));
- assertEquals("ABC", url.getRootOid());
- assertEquals(1, url.getConnectionParameters().size());
- assertEquals("val9", (String)url.getConnectionParameters().get("key9"));
- } catch (com.sun.star.lang.IllegalArgumentException e) {
- fail(e.getMessage());
- }
- }
-
- public void testOIDandParams2() {
- try {
- UnoUrl url = UnoUrl.parseUnoUrl("uno:x,key1=val1,k2=v2;y,k3=v3;ABC()!/");
- assertTrue((url != null));
- assertEquals("ABC()!/", url.getRootOid());
- assertEquals(2, url.getConnectionParameters().size());
- assertEquals(1, url.getProtocolParameters().size());
- } catch (com.sun.star.lang.IllegalArgumentException e) {
- fail("Caught exception:" + e.getMessage());
- }
- }
-
- public void testParams1() {
- try {
- UnoUrl url = UnoUrl.parseUnoUrl("uno:x,abc!abc=val;y;ABC");
- fail("Should throw an exception");
- } catch (com.sun.star.lang.IllegalArgumentException e) {
- }
- }
-
- public void testParams2() {
- try {
- UnoUrl url = UnoUrl.parseUnoUrl("uno:x,abc=val<val;y;ABC");
- fail("Should throw an exception");
- } catch (com.sun.star.lang.IllegalArgumentException e) {
- }
- }
-
- public void testParams3() {
- try {
- UnoUrl url = UnoUrl.parseUnoUrl("uno:x,abc=val!()val;y;ABC");
- assertTrue((url != null));
- assertEquals(1, url.getConnectionParameters().size());
- } catch (com.sun.star.lang.IllegalArgumentException e) {
- fail("Caught exception:" + e.getMessage());
- }
- }
-
- public void testCommon() {
- try {
- UnoUrl url =
- UnoUrl.parseUnoUrl(
- "socket,host=localhost,port=2002;urp;StarOffice.ServiceManager");
- assertTrue((url != null));
- assertEquals("StarOffice.ServiceManager", url.getRootOid());
- assertEquals("socket", url.getConnection());
- assertEquals("urp", url.getProtocol());
- assertEquals("2002", (String)url.getConnectionParameters().get("port"));
- } catch (com.sun.star.lang.IllegalArgumentException e) {
- fail("Caught exception:" + e.getMessage());
- }
- }
-
- public void testUTF() {
- try {
- UnoUrl url =
- UnoUrl.parseUnoUrl(
- "socket,host=localhost,horst=abc%c3%9c%c3%a4ABC%41%2c%2C,port=2002;urp;StarOffice.ServiceManager");
- assertEquals("abcÜäABCA,,", (String)url.getConnectionParameters().get("horst"));
- assertEquals(
- "host=localhost,horst=abc%c3%9c%c3%a4ABC%41%2c%2C,port=2002",
- url.getConnectionParametersAsString());
- } catch (com.sun.star.lang.IllegalArgumentException e) {
- fail("Caught exception:" + e.getMessage());
- }
-
- }
-
- public void testUTF1() {
- try {
- UnoUrl url = UnoUrl.parseUnoUrl("uno:x,abc=val%4t;y;ABC");
- fail("Should throw an exception");
- } catch (com.sun.star.lang.IllegalArgumentException e) {
- }
- }
-
-
- public static void main(String args[]) {
- UnoUrlTest t = new UnoUrlTest();
-
- log("Running test case 1");
- t.testStart1();
- log("Running test case 2");
- t.testStart2();
- log("Running test case 3");
- t.testStart3();
- log("Running test case 4");
- t.testStart4();
-
- log("Running test case 5");
- t.testParam1();
- log("Running test case 6");
- t.testParam2();
-
- log("Running test case 7");
- t.testPartName1();
-
- log("Running test case 8");
- t.testOID1();
-
- log("Running test case 9");
- t.testOIDandParams1();
- log("Running test case 10");
- t.testOIDandParams2();
-
- log("Running test case 11");
- t.testParams1();
- log("Running test case 12");
- t.testParams2();
- log("Running test case 13");
- t.testParams3();
-
- log("Running test case 14");
- t.testCommon();
-
- log("Running test case 15");
- t.testUTF();
- log("Running test case 16");
- t.testUTF1();
- }
-}
diff --git a/javaunohelper/test/com/sun/star/lib/uno/helper/WeakBase_Test.java b/javaunohelper/test/com/sun/star/lib/uno/helper/WeakBase_Test.java
deleted file mode 100644
index c51c5273b..000000000
--- a/javaunohelper/test/com/sun/star/lib/uno/helper/WeakBase_Test.java
+++ /dev/null
@@ -1,251 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-package com.sun.star.lib.uno.helper;
-import com.sun.star.uno.Type;
-import com.sun.star.bridge.XBridgeSupplier2;
-import com.sun.star.uno.XReference;
-import com.sun.star.uno.XWeak;
-import com.sun.star.lang.XTypeProvider;
-import com.sun.star.uno.XAdapter;
-
-public class WeakBase_Test
-{
-
- /** Creates a new instance of WeakBase_Test */
- public WeakBase_Test()
- {
- }
-
- public boolean getTypes()
- {
- System.out.println("Testing WeakBase.getTypes");
- boolean[] r= new boolean[50];
- int i= 0;
-
- SomeClass comp= new SomeClass();
- Type[] types= comp.getTypes(); //XWeak,XTypeProvider,XReference,XBridgeSupplier2
- r[i++]= types.length == 4;
- for (int c= 0; c < types.length; c++)
- {
- if (types[c].equals( new Type( XWeak.class)))
- r[i++]= true;
- else if (types[c].equals(new Type(XTypeProvider.class)))
- r[i++]= true;
- else if (types[c].equals(new Type(XReference.class)))
- r[i++]= true;
- else if (types[c].equals(new Type(XBridgeSupplier2.class)))
- r[i++]= true;
- else
- r[i++]= false;
-
- }
-
- Foo1 f1= new Foo1();
- Foo1 f2= new Foo1();
- Type[] t1= f1.getTypes();
- Type[] t2= f2.getTypes();
- r[i++]= t1.equals(t2);
- Foo2 f3= new Foo2();
- boolean bOk= true;
- for (int c= 0; c < i; c++)
- bOk= bOk && r[c];
- if (bOk == false)
- System.out.println("Failed");
- else
- System.out.println("Ok");
- return bOk;
- }
-
- public boolean getImplementationId()
- {
- System.out.println("Testing WeakBase.getImplementationId");
- boolean[] r= new boolean[50];
- int i= 0;
-
- SomeClass comp= new SomeClass();
- // byte 0 - 3 contain hashcode and the remaining bytes represent the classname
- byte [] ar= comp.getImplementationId();
-
- StringBuffer buff= new StringBuffer();
- for (int c= 0; c < ar.length - 4; c++){
- buff.append((char) ar[4 + c]);
-// buff.append(" ");
- }
- String retStr= buff.toString();
- r[i++]= retStr.equals("com.sun.star.lib.uno.helper.SomeClass");
-// System.out.println(buff.toString());
-
- Foo1 f1= new Foo1();
- Foo1 f2= new Foo1();
- r[i++]= f1.getImplementationId().equals(f2.getImplementationId());
- Foo2 f3= new Foo2();
- r[i++]= ! f1.getImplementationId().equals(f3.getImplementationId());
- Foo3 f4= new Foo3();
- r[i++]= ! f1.getImplementationId().equals(f4.getImplementationId());
- boolean bOk= true;
- for (int c= 0; c < i; c++)
- bOk= bOk && r[c];
- if (bOk == false)
- System.out.println("Failed");
- else
- System.out.println("Ok");
- return bOk;
- }
-
- public boolean queryAdapter()
- {
- System.out.println("Testing WeakBase.queryAdapter, XAdapter tests");
- boolean[] r= new boolean[50];
- int i= 0;
-
- SomeClass comp= new SomeClass();
- XAdapter adapter= comp.queryAdapter();
- MyRef aRef1= new MyRef();
- MyRef aRef2= new MyRef();
- adapter.addReference(aRef1);
- adapter.addReference(aRef2);
-
- r[i++]= adapter.queryAdapted() == comp;
- comp= null;
- System.out.println("Wait 5 sec");
- for(int c= 0; c < 50; c++)
- {
- try
- {
- Thread.currentThread().sleep(100);
- System.gc();
- System.runFinalization();
- }catch (InterruptedException ie)
- {
- }
- }
-
- r[i++]= aRef1.nDisposeCalled == 1;
- r[i++]= aRef2.nDisposeCalled == 1;
- r[i++]= adapter.queryAdapted() == null;
- adapter.removeReference(aRef1); // should not do any harm
- adapter.removeReference(aRef2);
-
- comp= new SomeClass();
- adapter= comp.queryAdapter();
- aRef1.nDisposeCalled= 0;
- aRef2.nDisposeCalled= 0;
-
- adapter.addReference(aRef1);
- adapter.addReference(aRef2);
-
- adapter.removeReference(aRef1);
- System.out.println("Wait 5 sec");
- comp= null;
- for(int c= 0; c < 50; c++)
- {
- try
- {
- Thread.currentThread().sleep(100);
- System.gc();
- System.runFinalization();
- }catch (InterruptedException ie)
- {
- }
- }
- r[i++]= aRef1.nDisposeCalled == 0;
- r[i++]= aRef2.nDisposeCalled == 1;
-
- boolean bOk= true;
- for (int c= 0; c < i; c++)
- bOk= bOk && r[c];
- if (bOk == false)
- System.out.println("Failed");
- else
- System.out.println("Ok");
- return bOk;
- }
-
- public static void main(String[] args)
- {
- WeakBase_Test test= new WeakBase_Test();
- boolean r[]= new boolean[50];
- int i= 0;
- r[i++]= test.getTypes();
- r[i++]= test.getImplementationId();
- r[i++]= test.queryAdapter();
-
- boolean bOk= true;
- for (int c= 0; c < i; c++)
- bOk= bOk && r[c];
- if (bOk == false)
- System.out.println("Errors occurred!");
- else
- System.out.println("No errors.");
-
- }
-
-}
-
-interface Aint
-{
-}
-class OtherClass extends WeakBase implements XBridgeSupplier2
-{
-
- public Object createBridge(Object obj, byte[] values, short param, short param3) throws com.sun.star.lang.IllegalArgumentException
- {
- return null;
- }
-}
-
-class SomeClass extends OtherClass implements Aint,XReference
-{
-
- public void dispose()
- {
- }
-
-}
-
-class MyRef implements XReference
-{
- int nDisposeCalled;
-
- public void dispose()
- {
- nDisposeCalled++;
- }
-}
-
-class Foo1 extends WeakBase
-{
-}
-
-class Foo2 extends WeakBase
-{
-}
-
-class Foo3 extends Foo1
-{
-}
diff --git a/javaunohelper/test/com/sun/star/lib/uno/helper/makefile.mk b/javaunohelper/test/com/sun/star/lib/uno/helper/makefile.mk
deleted file mode 100644
index d3de3df10..000000000
--- a/javaunohelper/test/com/sun/star/lib/uno/helper/makefile.mk
+++ /dev/null
@@ -1,68 +0,0 @@
-#*************************************************************************
-#
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# Copyright 2000, 2010 Oracle and/or its affiliates.
-#
-# OpenOffice.org - a multi-platform office productivity suite
-#
-# This file is part of OpenOffice.org.
-#
-# OpenOffice.org is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Lesser General Public License version 3
-# only, as published by the Free Software Foundation.
-#
-# OpenOffice.org is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Lesser General Public License version 3 for more details
-# (a copy is included in the LICENSE file that accompanied this code).
-#
-# You should have received a copy of the GNU Lesser General Public License
-# version 3 along with OpenOffice.org. If not, see
-# <http://www.openoffice.org/license.html>
-# for a copy of the LGPLv3 License.
-#
-#*************************************************************************
-
-PRJ=..$/..$/..$/..$/..$/..$/..
-PRJNAME = juhelper
-PACKAGE = com$/sun$/star$/lib$/uno$/helper
-TARGET = com_sun_star_lib_uno_helper_test
-
-# --- Settings -----------------------------------------------------
-
-.INCLUDE : settings.mk
-
-# --- Files --------------------------------------------------------
-
-JARFILES = jurt.jar ridl.jar juh.jar
-
-JAVACLASSFILES= \
- $(CLASSDIR)$/$(PACKAGE)$/WeakBase_Test.class \
- $(CLASSDIR)$/$(PACKAGE)$/ComponentBase_Test.class \
- $(CLASSDIR)$/$(PACKAGE)$/InterfaceContainer_Test.class \
- $(CLASSDIR)$/$(PACKAGE)$/MultiTypeInterfaceContainer_Test.class \
- $(CLASSDIR)$/$(PACKAGE)$/ProxyProvider.class \
- $(CLASSDIR)$/$(PACKAGE)$/AWeakBase.class \
- $(CLASSDIR)$/$(PACKAGE)$/PropertySet_Test.class \
- $(CLASSDIR)$/$(PACKAGE)$/UnoUrlTest.class \
- $(CLASSDIR)$/$(PACKAGE)$/Factory_Test.class
-
-# --- Targets ------------------------------------------------------
-
-.INCLUDE : target.mk
-
-CPATH_JARS = java_uno.jar $(JARFILES)
-CPATH_TMP1 = $(foreach,j,$(CPATH_JARS) $(SOLARBINDIR)$/$j)
-CPATH_TMP2 = $(strip $(subst,!,$(PATH_SEPERATOR) $(CPATH_TMP1:s/ /!/)))
-CPATH = $(CPATH_TMP2)$(PATH_SEPERATOR)$(OUT)$/bin$/factory_test.jar$(PATH_SEPERATOR)$(XCLASSPATH)
-
-$(OUT)$/bin$/factory_test.jar : $(CLASSDIR)$/$(PACKAGE)$/Factory_Test.class
- -rm -f $@
- @echo RegistrationClassName: com.sun.star.lib.uno.helper.Factory_Test > $(OUT)$/bin$/manifest.mf
- -jar cvfm $@ $(OUT)$/bin$/manifest.mf -C $(CLASSDIR) $(PACKAGE)$/Factory_Test.class
-
-run_factory_test : $(OUT)$/bin$/factory_test.jar
- -$(GNUCOPY) $(SOLARBINDIR)$/udkapi.rdb $(OUT)$/bin$/factory_test.rdb
- -java -classpath $(CPATH) com.sun.star.lib.uno.helper.Factory_Test $(OUT)$/bin$/factory_test.jar $(OUT)$/bin$/factory_test.rdb
diff --git a/javaunohelper/util/delzip b/javaunohelper/util/delzip
deleted file mode 100644
index e69de29bb..000000000
--- a/javaunohelper/util/delzip
+++ /dev/null
diff --git a/javaunohelper/util/juh.component b/javaunohelper/util/juh.component
deleted file mode 100644
index 790a2a2b1..000000000
--- a/javaunohelper/util/juh.component
+++ /dev/null
@@ -1,34 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--**********************************************************************
-*
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* Copyright 2000, 2010 Oracle and/or its affiliates.
-*
-* OpenOffice.org - a multi-platform office productivity suite
-*
-* This file is part of OpenOffice.org.
-*
-* OpenOffice.org is free software: you can redistribute it and/or modify
-* it under the terms of the GNU Lesser General Public License version 3
-* only, as published by the Free Software Foundation.
-*
-* OpenOffice.org is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU Lesser General Public License version 3 for more details
-* (a copy is included in the LICENSE file that accompanied this code).
-*
-* You should have received a copy of the GNU Lesser General Public License
-* version 3 along with OpenOffice.org. If not, see
-* <http://www.openoffice.org/license.html>
-* for a copy of the LGPLv3 License.
-*
-**********************************************************************-->
-
-<component loader="com.sun.star.loader.Java2"
- xmlns="http://openoffice.org/2010/uno-components">
- <implementation name="com.sun.star.comp.juhtest.SmoketestCommandEnvironment">
- <service name="com.sun.star.deployment.test.SmoketestCommandEnvironment"/>
- </implementation>
-</component>
diff --git a/javaunohelper/util/makefile.mk b/javaunohelper/util/makefile.mk
deleted file mode 100644
index 796280eb3..000000000
--- a/javaunohelper/util/makefile.mk
+++ /dev/null
@@ -1,58 +0,0 @@
-#*************************************************************************
-#
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# Copyright 2000, 2010 Oracle and/or its affiliates.
-#
-# OpenOffice.org - a multi-platform office productivity suite
-#
-# This file is part of OpenOffice.org.
-#
-# OpenOffice.org is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Lesser General Public License version 3
-# only, as published by the Free Software Foundation.
-#
-# OpenOffice.org is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Lesser General Public License version 3 for more details
-# (a copy is included in the LICENSE file that accompanied this code).
-#
-# You should have received a copy of the GNU Lesser General Public License
-# version 3 along with OpenOffice.org. If not, see
-# <http://www.openoffice.org/license.html>
-# for a copy of the LGPLv3 License.
-#
-#*************************************************************************
-
-PRJ = ..
-PRJNAME = juhelper
-TARGET = juh
-
-.INCLUDE : settings.mk
-.INCLUDE: settings.pmk
-
-JARCLASSDIRS = com
-JARTARGET = $(TARGET).jar
-JARCOMPRESS = TRUE
-JARCLASSPATH = $(JARFILES) ../../lib/ ../bin/
-CUSTOMMANIFESTFILE = manifest
-
-# Special work necessary for building java reference with javadoc.
-# The source of puplic APIs must be delivered and used later in the
-# odk module.
-ZIP1TARGET=$(TARGET)_src
-ZIP1FLAGS=-u -r
-ZIP1DIR=$(PRJ)
-ZIP1LIST=com -x "*makefile.mk"
-
-# --- Targets ------------------------------------------------------
-
-.INCLUDE : target.mk
-
-ALLTAR : $(MISC)/juh.component
-
-$(MISC)/juh.component .ERRREMOVE : $(SOLARENV)/bin/createcomponent.xslt \
- juh.component
- $(XSLTPROC) --nonet --stringparam uri '$(COMPONENTPREFIX_URE_JAVA)juh.jar' \
- -o $@ $(SOLARENV)/bin/createcomponent.xslt juh.component
diff --git a/javaunohelper/util/manifest b/javaunohelper/util/manifest
deleted file mode 100644
index 2620d3330..000000000
--- a/javaunohelper/util/manifest
+++ /dev/null
@@ -1,3 +0,0 @@
-Sealed: true
-RegistrationClassName: com.sun.star.comp.JavaUNOHelperServices
-UNO-Type-Path:
diff --git a/javaunohelper/util/settings.pmk b/javaunohelper/util/settings.pmk
deleted file mode 100644
index 28b262183..000000000
--- a/javaunohelper/util/settings.pmk
+++ /dev/null
@@ -1,28 +0,0 @@
-#*************************************************************************
-#
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# Copyright 2000, 2010 Oracle and/or its affiliates.
-#
-# OpenOffice.org - a multi-platform office productivity suite
-#
-# This file is part of OpenOffice.org.
-#
-# OpenOffice.org is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Lesser General Public License version 3
-# only, as published by the Free Software Foundation.
-#
-# OpenOffice.org is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Lesser General Public License version 3 for more details
-# (a copy is included in the LICENSE file that accompanied this code).
-#
-# You should have received a copy of the GNU Lesser General Public License
-# version 3 along with OpenOffice.org. If not, see
-# <http://www.openoffice.org/license.html>
-# for a copy of the LGPLv3 License.
-#
-#*************************************************************************
-
-JARFILES = ridl.jar jurt.jar