1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 package ifc.task; 29 30 31 32 /** 33 * <code>com.sun.star.task.XInteractionHandler</code> interface testing. 34 * This test needs the following object relations : 35 * <ul> 36 * <li> <code>'XInteractionHandler.Request'</code> 37 * (of type <code>com.sun.star.task.XInteractionRequest</code>): 38 * this interface implementation is handler specific and is 39 * passed as argument to method <code>handle</code>. </li> 40 * <ul> <p> 41 * Test is <b> NOT </b> multithread compilant. <p> 42 * @see com.sun.star.task.XInteractionHandler 43 */ 44 import lib.MultiMethodTest; 45 import lib.Status; 46 47 import com.sun.star.task.XInteractionHandler; 48 import com.sun.star.task.XInteractionRequest; 49 50 /** 51 * <code>com.sun.star.task.XInteractionHandler</code> interface testing. 52 * This test needs the following object relations : 53 * <ul> 54 * <li> <code>'XInteractionHandler.Request'</code> 55 * (of type <code>com.sun.star.task.XInteractionRequest</code>): 56 * this interface implementation is handler specific and is 57 * passed as argument to method <code>handle</code>. </li> 58 * <ul> <p> 59 * Test is <b> NOT </b> multithread compilant. <p> 60 * @see com.sun.star.task.XInteractionHandler 61 */ 62 public class _XInteractionHandler extends MultiMethodTest { 63 64 // oObj filled by MultiMethodTest 65 public XInteractionHandler oObj = null ; 66 67 private XInteractionRequest request = null ; 68 69 /** 70 * Retrieves an object relation. <p> 71 * @throws StatusException If the relation is not found. 72 */ 73 public void before() { 74 request = (XInteractionRequest) 75 tEnv.getObjRelation("XInteractionHandler.Request") ; 76 77 //if (request == null) 78 // throw new StatusException(Status.failed("Reelation not found")) ; 79 } 80 81 /** 82 * Sinse this test is interactive (dialog window can't be 83 * disposed using API) it is skipped. <p> 84 * Always has <b>SKIPPED.OK</b> status . 85 */ 86 public void _handle() { 87 88 /* 89 90 final XMultiServiceFactory msf = (XMultiServiceFactory)tParam.getMSF() ; 91 SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); 92 XComponent textDoc = null ; 93 try { 94 textDoc = SOF.createTextDoc( null ); 95 } catch (com.sun.star.uno.Exception e) { 96 log.println("Can't create Document") ; 97 tRes.tested("handle()", false) ; 98 return ; 99 } 100 final XComponent fTextDoc = textDoc ; 101 final XModel xModelDoc = (XModel) 102 UnoRuntime.queryInterface(XModel.class, textDoc); 103 104 Thread thr = new Thread( new Runnable() { 105 public void run() { 106 try { 107 Thread.sleep(1000) ; 108 } catch (InterruptedException e ) {} 109 110 //fTextDoc.dispose() ; 111 112 XFrame docFr = xModelDoc.getCurrentController().getFrame() ; 113 docFr.dispose() ; 114 115 ///* 116 try { 117 118 Object dsk = msf.createInstance 119 ("com.sun.star.frame.Desktop"); 120 121 XFrame xDsk = (XFrame) 122 UnoRuntime.queryInterface(XFrame.class, dsk) ; 123 124 XFrame fr = xDsk.findFrame("_top", 55) ; 125 126 XWindow win = fr.getContainerWindow() ; 127 128 String name = null ; 129 if (fr != null) { 130 name = fr.getName() ; 131 docFr.dispose() ; 132 } 133 134 } catch (com.sun.star.uno.Exception e) { 135 e.printStackTrace(); 136 } // 137 } 138 }) ; 139 thr.start() ; 140 141 oObj.handle(request) ; 142 try { 143 thr.join(500) ; 144 } catch (InterruptedException e ) {} 145 */ 146 147 tRes.tested("handle()", Status.skipped(true)) ; 148 } 149 } 150 151 152