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 package ifc.uno; 28 29 import lib.MultiMethodTest; 30 import util.ValueComparer; 31 32 import com.sun.star.lang.XMultiComponentFactory; 33 import com.sun.star.uno.UnoRuntime; 34 import com.sun.star.uno.XComponentContext; 35 36 37 public class _XComponentContext extends MultiMethodTest { 38 public XComponentContext oObj; 39 protected XMultiComponentFactory byValue = null; 40 protected XMultiComponentFactory directly = null; 41 42 public void _getServiceManager() { 43 log.println("getting manager"); 44 45 directly = oObj.getServiceManager(); 46 String[] names = directly.getAvailableServiceNames(); 47 boolean res = true; 48 49 for (int i = 0; i < names.length; i++) { 50 try { 51 if (names[i].equals("com.sun.star.i18n.ConversionDictionary_ko")) continue; 52 if (names[i].equals("com.sun.star.i18n.TextConversion_ko")) continue; 53 log.println("try to instanciate found servicename " + 54 names[i]); 55 directly.createInstanceWithContext(names[i], oObj); 56 log.println("worked .... ok"); 57 res &= true; 58 } catch (com.sun.star.uno.Exception e) { 59 log.println("Exception occured " + e.getMessage()); 60 res &= false; 61 } 62 } 63 64 tRes.tested("getServiceManager()", res); 65 } 66 67 public void _getValueByName() { 68 requiredMethod("getServiceManager()"); 69 70 Object value = oObj.getValueByName( 71 "/singletons/com.sun.star.lang.theServiceManager"); 72 byValue = (XMultiComponentFactory) UnoRuntime.queryInterface( 73 XMultiComponentFactory.class, value); 74 75 String[] vNames = byValue.getAvailableServiceNames(); 76 String[] dNames = directly.getAvailableServiceNames(); 77 78 boolean res = ValueComparer.equalValue(byValue, directly); 79 tRes.tested("getValueByName()", res); 80 } 81 }