diff options
author | Rüdiger Timm <rt@openoffice.org> | 2004-08-02 08:45:07 +0000 |
---|---|---|
committer | Rüdiger Timm <rt@openoffice.org> | 2004-08-02 08:45:07 +0000 |
commit | b898ed532e389f04b41f37e88af13e71585990b2 (patch) | |
tree | 38bd95ddd638f90d4f3c852cd826198fd0a1a8b1 /javaunohelper/test | |
parent | 07fdf4bd60d6a0e24f3581c22669f758b85c0e54 (diff) |
INTEGRATION: CWS jl10 (1.1.118); FILE MERGED
2004/07/22 12:52:01 jl 1.1.118.1: #115688#
Diffstat (limited to 'javaunohelper/test')
-rw-r--r-- | javaunohelper/test/com/sun/star/lib/uno/helper/MultiTypeInterfaceContainer_Test.java | 73 | ||||
-rw-r--r-- | javaunohelper/test/com/sun/star/lib/uno/helper/ProxyProvider.java | 136 |
2 files changed, 123 insertions, 86 deletions
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 index 5e92b3003370..4097319f1a05 100644 --- a/javaunohelper/test/com/sun/star/lib/uno/helper/MultiTypeInterfaceContainer_Test.java +++ b/javaunohelper/test/com/sun/star/lib/uno/helper/MultiTypeInterfaceContainer_Test.java @@ -2,9 +2,9 @@ * * $RCSfile: MultiTypeInterfaceContainer_Test.java,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: jl $ $Date: 2002-04-11 13:43:14 $ + * last change: $Author: rt $ $Date: 2004-08-02 09:44:39 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -68,13 +68,13 @@ 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.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); +// java_environment env= new java_environment(null); /** Creates a new instance of InterfaceContainerTest */ AWeakBase obj1,obj2,obj3,obj4; Object proxyObj1Weak1; @@ -96,11 +96,12 @@ public class MultiTypeInterfaceContainer_Test obj2= new AWeakBase(); obj3= new AWeakBase(); obj4= new AWeakBase(); - proxyObj1Weak1= ProxyProvider.getHolderProxy(obj1, XWeak.class); - proxyObj3Weak1= ProxyProvider.getHolderProxy(obj3, XWeak.class); - proxyObj3Weak2= ProxyProvider.getHolderProxy(obj3, XWeak.class); - proxyObj2TypeProv= ProxyProvider.getHolderProxy(obj2, XTypeProvider.class); - proxyObj3TypeProv= ProxyProvider.getHolderProxy(obj3, XTypeProvider.class); + + 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); @@ -122,33 +123,33 @@ public class MultiTypeInterfaceContainer_Test * 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 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() { diff --git a/javaunohelper/test/com/sun/star/lib/uno/helper/ProxyProvider.java b/javaunohelper/test/com/sun/star/lib/uno/helper/ProxyProvider.java index 2e086f48cfd4..8bd5ea405142 100644 --- a/javaunohelper/test/com/sun/star/lib/uno/helper/ProxyProvider.java +++ b/javaunohelper/test/com/sun/star/lib/uno/helper/ProxyProvider.java @@ -2,9 +2,9 @@ * * $RCSfile: ProxyProvider.java,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: jl $ $Date: 2002-04-11 13:43:14 $ + * last change: $Author: rt $ $Date: 2004-08-02 09:45:07 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -63,9 +63,11 @@ 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.lib.uno.environments.java.Proxy; +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; +//import com.sun.star.lib.uno.environments.java.IRequester; public class ProxyProvider @@ -82,7 +84,7 @@ public class ProxyProvider * The proxy can be queried for XEventListener. On the returned proxy disposing can be called * */ - public static Object getHolderProxy(Object obj, Class iface) + public static Object createProxy(Object obj, Class iface) { Object retVal= null; @@ -97,17 +99,8 @@ public class ProxyProvider // 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); - eventRequester._xEventListenerProxy= aProxyEvt; - 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[] + Object aProxy = new Proxy(sOid, type); + String[] arOid = new String[] {sOid}; retVal= env.registerInterface(aProxy, arOid, type); } @@ -115,49 +108,92 @@ public class ProxyProvider } } -class Requester implements IRequester +class Proxy implements IQueryInterface, XEventListener { - 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; - + String oid; + Type type; + Proxy(String oid, Type t) { + this.oid = oid; + this.type = t; } - public Object sendRequest(Object object, - Type type, - String operation, - Object params[], - Boolean synchron[], - Boolean mustReply[]) throws Throwable - { + public String getOid() { + return oid; + } - Object result = null; - if (operation.equals("disposing")) - { - System.out.println("Disposing called on XEventListener proxy"); - nDisposingCalled++; - } - else if (operation.equals("queryInterface")) + public boolean isSame(Object object) { + if (object instanceof IQueryInterface) { - if (params[0] instanceof Type) + IQueryInterface iquery = (IQueryInterface) object; + if (iquery != null) { - Type t= (Type) params[0]; - if (t.equals( new Type("com.sun.star.lang.XEventListener"))) - result= _xEventListenerProxy; + if (iquery.getOid().equals(oid)) + return true; + else + return false; } } - return result; + + 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; +// } +//} + + |