2003-01-27 17:20:08 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 13:56:52 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2003-01-27 17:20:08 +00:00
|
|
|
*
|
2010-02-12 15:01:35 +01:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2003-01-27 17:20:08 +00:00
|
|
|
*
|
2008-04-10 13:56:52 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2003-01-27 17:20:08 +00:00
|
|
|
*
|
2008-04-10 13:56:52 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2003-01-27 17:20:08 +00:00
|
|
|
*
|
2008-04-10 13:56:52 +00:00
|
|
|
* 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.
|
2003-01-27 17:20:08 +00:00
|
|
|
*
|
2008-04-10 13:56:52 +00:00
|
|
|
* 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).
|
2003-01-27 17:20:08 +00:00
|
|
|
*
|
2008-04-10 13:56:52 +00:00
|
|
|
* 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.
|
2003-01-27 17:20:08 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
package ifc.script;
|
|
|
|
|
2003-09-08 09:50:20 +00:00
|
|
|
import lib.MultiMethodTest;
|
|
|
|
import lib.StatusException;
|
|
|
|
|
2003-01-27 17:20:08 +00:00
|
|
|
import com.sun.star.io.XInputStream;
|
2003-05-27 11:27:54 +00:00
|
|
|
import com.sun.star.lang.XMultiServiceFactory;
|
2003-09-08 09:50:20 +00:00
|
|
|
import com.sun.star.lang.XSingleServiceFactory;
|
2003-01-27 17:20:08 +00:00
|
|
|
import com.sun.star.script.XInvocation;
|
|
|
|
import com.sun.star.script.XInvocationAdapterFactory2;
|
|
|
|
import com.sun.star.uno.Type;
|
|
|
|
import com.sun.star.uno.UnoRuntime;
|
|
|
|
import com.sun.star.uno.XInterface;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Testing <code>com.sun.star.script.XInvocationAdapterFactory</code>
|
|
|
|
* interface methods :
|
|
|
|
* <ul>
|
|
|
|
* <li><code> createAdapter()</code></li>
|
|
|
|
* </ul> <p>
|
|
|
|
* Test is <b> NOT </b> multithread compilant. <p>
|
|
|
|
* @see com.sun.star.script.XInvocationAdapterFactory
|
|
|
|
*/
|
|
|
|
public class _XInvocationAdapterFactory2 extends MultiMethodTest {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* oObj filled by MultiMethodTest
|
|
|
|
*/
|
|
|
|
public XInvocationAdapterFactory2 oObj = null;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* First an invocation object of <code>com.sun.star.io.Pipe</code>
|
|
|
|
* instance is created using <code>com.sun.star.script.Invocation
|
|
|
|
* </code> service. Then trying to create an adapter of this
|
|
|
|
* invocation for <code>com.sun.star.io.XInputStream</code>
|
|
|
|
* interface. <p>
|
|
|
|
* Has <b>OK</b> status if the adapter returned is successfully
|
|
|
|
* queried for <code>com.sun.star.io.XInputStream</code>
|
|
|
|
* interface.
|
|
|
|
* @see com.sun.star.script.Invocation
|
|
|
|
* @see com.sun.star.script.XInvocation
|
|
|
|
* @see com.sun.star.io.Pipe
|
|
|
|
*/
|
|
|
|
public void _createAdapter() {
|
|
|
|
XInvocation xInv = null ;
|
2003-05-27 11:27:54 +00:00
|
|
|
XMultiServiceFactory xMSF = null;
|
2003-01-27 17:20:08 +00:00
|
|
|
try {
|
2003-05-27 11:27:54 +00:00
|
|
|
xMSF = (XMultiServiceFactory)tParam.getMSF();
|
|
|
|
Object[] args = {xMSF.createInstance
|
2003-01-27 17:20:08 +00:00
|
|
|
("com.sun.star.io.Pipe")};
|
|
|
|
|
2003-05-27 11:27:54 +00:00
|
|
|
Object oInvFac = xMSF.createInstance
|
2003-01-27 17:20:08 +00:00
|
|
|
("com.sun.star.script.Invocation") ;
|
|
|
|
|
|
|
|
XSingleServiceFactory xInvFac = (XSingleServiceFactory) UnoRuntime.
|
|
|
|
queryInterface(XSingleServiceFactory.class, oInvFac) ;
|
|
|
|
|
|
|
|
Object oInv = xInvFac.createInstanceWithArguments(args) ;
|
|
|
|
|
|
|
|
xInv = (XInvocation) UnoRuntime.queryInterface
|
|
|
|
(XInvocation.class, oInv) ;
|
|
|
|
|
|
|
|
} catch (com.sun.star.uno.Exception e) {
|
|
|
|
e.printStackTrace(log) ;
|
|
|
|
throw new StatusException("Cann't create invocation for object", e) ;
|
|
|
|
}
|
|
|
|
|
|
|
|
XInterface xInStr = null ;
|
|
|
|
|
|
|
|
Type[] types = new Type[1];
|
|
|
|
types[0] = new Type(XInputStream.class);
|
|
|
|
|
|
|
|
Object adp = oObj.createAdapter(xInv,types);
|
|
|
|
|
|
|
|
xInStr = (XInterface) UnoRuntime.queryInterface
|
|
|
|
(XInputStream.class, adp) ;
|
|
|
|
|
|
|
|
|
|
|
|
if (xInStr != null)
|
|
|
|
tRes.tested("createAdapter()", true) ;
|
|
|
|
else {
|
|
|
|
log.println("Adapter created doesn't implement required interface") ;
|
|
|
|
tRes.tested("createAdapter()", false) ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|