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 complex.tdoc; 29 30 import lib.MultiMethodTest; 31 import lib.Status; 32 33 import com.sun.star.container.XChild; 34 import com.sun.star.container.XNamed; 35 import com.sun.star.uno.UnoRuntime; 36 import share.LogWriter; 37 38 /* 39 * Testing <code>com.sun.star.container.XChild</code> 40 * interface methods : 41 * <ul> 42 * <li><code> getParent()</code></li> 43 * <li><code> setParent()</code></li> 44 * </ul> 45 * @see com.sun.star.container.XChild 46 */ 47 public class _XChild { 48 49 public XChild oObj = null; 50 public Object gotten = null; 51 public LogWriter log = null; 52 53 54 /** 55 * Test calls the method and checks return value and that 56 * no exceptions were thrown. Parent returned is stored.<p> 57 * Has <b> OK </b> status if the method returns not null value 58 * and no exceptions were thrown. <p> 59 */ 60 public boolean _getParent(boolean hasParent) { 61 gotten = oObj.getParent(); 62 if (!hasParent) 63 return gotten == null; 64 XNamed the_name = (XNamed) UnoRuntime.queryInterface(XNamed.class,gotten); 65 if (the_name != null) 66 log.println("Parent:"+the_name.getName()); 67 return gotten != null; 68 } 69 70 /** 71 * Sets existing parent and checks that 72 * no exceptions were thrown. <p> 73 * Has <b> OK </b> status if no exceptions were thrown. <p> 74 * The following method tests are to be completed successfully before : 75 * <ul> 76 * <li> <code> getParent() </code> : to get the parent. </li> 77 * </ul> 78 */ 79 public boolean _setParent(boolean supported) { 80 // requiredMethod("getParent()") ; 81 82 String parentComment = null;//String) tEnv.getObjRelation("cannotSwitchParent"); 83 84 if (parentComment != null) { 85 log.println(parentComment); 86 return true; 87 } 88 89 try { 90 oObj.setParent(gotten); 91 } 92 catch (com.sun.star.lang.NoSupportException ex) { 93 log.println("Exception occured during setParent() - " + (supported?"FAILED":"OK")); 94 if (supported) { 95 ex.printStackTrace((java.io.PrintWriter)log); 96 return false; 97 } 98 } 99 return true; 100 } 101 102 } // finish class _XChild 103 104 105