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.frame; 29 30 import lib.MultiMethodTest; 31 32 import com.sun.star.beans.PropertyState; 33 import com.sun.star.beans.PropertyValue; 34 import com.sun.star.frame.XComponentLoader; 35 import com.sun.star.lang.XComponent; 36 37 38 /** 39 * Testing <code>com.sun.star.frame.XComponentLoader</code> 40 * interface methods: 41 * <ul> 42 * <li><code> loadComponentFromURL() </code></li> 43 * </ul><p> 44 * Test is <b> NOT </b> multithread compilant. <p> 45 * @see com.sun.star.frame.XComponentLoader 46 */ 47 public class _XComponentLoader extends MultiMethodTest { 48 public XComponentLoader oObj = null; // oObj filled by MultiMethodTest 49 50 /** 51 * Method which tests the objects ability to load a 52 * component from URL. All available components are loaded by turns. <p> 53 * Has <b> OK </b> status if the method successfully returns 54 * and no exceptions were thrown. <p> 55 * @see XComponent 56 */ 57 public void _loadComponentFromURL() { 58 boolean result = true; 59 60 log.println("testing loadComponentFromURL() ... "); 61 try { 62 PropertyValue [] szEmptyArgs = new PropertyValue [0]; 63 String frameName = "_blank"; 64 XComponent oDoc = null; 65 66 log.println("load writer doc that contains links"); 67 PropertyValue [] szArgs = new PropertyValue [1]; 68 PropertyValue Arg = new PropertyValue(); 69 Arg.Name = "UpdateDocMode"; 70 Arg.Value = new Short(com.sun.star.document.UpdateDocMode.NO_UPDATE); 71 szArgs[0]=Arg; 72 String url = util.utils.getFullTestURL("Writer_link.sxw"); 73 log.println("try to load '" + url + "'"); 74 oDoc = oObj.loadComponentFromURL( 75 url, frameName, 0, szArgs); 76 77 try { 78 Thread.sleep(500); 79 } 80 catch (InterruptedException ex) { 81 } 82 83 oDoc.dispose(); 84 85 url = util.utils.getFullTestURL("Calc_Link.sxc"); 86 log.println("try to load '" + url + "'"); 87 oDoc = oObj.loadComponentFromURL( 88 url, frameName, 0, szArgs); 89 90 try { 91 Thread.sleep(500); 92 } 93 catch (InterruptedException ex) { 94 } 95 96 oDoc.dispose(); 97 98 99 100 log.println("load a blank impress doc"); 101 Arg.Name = "OpenFlags"; 102 Arg.Value = "S"; 103 Arg.Handle = -1; 104 Arg.State = PropertyState.DEFAULT_VALUE; 105 szArgs[0]=Arg; 106 oDoc = oObj.loadComponentFromURL( 107 "private:factory/simpress", frameName, 0, szArgs ); 108 109 log.println("disposing impress doc"); 110 oDoc.dispose(); 111 112 log.println("load a blank writer doc"); 113 oDoc = oObj.loadComponentFromURL( 114 "private:factory/swriter", frameName, 0, szEmptyArgs ); 115 116 log.println("disposing writer doc"); 117 oDoc.dispose(); 118 119 log.println("load a blank calc doc"); 120 oDoc = oObj.loadComponentFromURL( 121 "private:factory/scalc", frameName, 0, szEmptyArgs ); 122 123 log.println("disposing calc doc"); 124 oDoc.dispose(); 125 126 log.println("load a blank draw doc"); 127 oDoc = oObj.loadComponentFromURL( 128 "private:factory/sdraw", frameName, 0, szEmptyArgs ); 129 130 log.println("disposing draw doc"); 131 oDoc.dispose(); 132 133 log.println("load a blank math doc"); 134 oDoc = oObj.loadComponentFromURL( 135 "private:factory/smath", frameName, 0, szEmptyArgs ); 136 137 log.println("disposing math doc"); 138 oDoc.dispose(); 139 140 } 141 catch (com.sun.star.lang.IllegalArgumentException e) { 142 log.println("Exception occured while loading"); 143 e.printStackTrace(log); 144 result=false; 145 } 146 catch (com.sun.star.io.IOException e) { 147 log.println("Exception occured while loading"); 148 e.printStackTrace(log); 149 result=false; 150 } 151 152 tRes.tested("loadComponentFromURL()", result); 153 return; 154 } 155 156 } 157 158