1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 package mod._lng; 25 26 import java.io.PrintWriter; 27 28 import lib.StatusException; 29 import lib.TestCase; 30 import lib.TestEnvironment; 31 import lib.TestParameters; 32 33 import com.sun.star.lang.Locale; 34 import com.sun.star.lang.XMultiServiceFactory; 35 import com.sun.star.linguistic2.XDictionary; 36 import com.sun.star.linguistic2.XDictionaryList; 37 import com.sun.star.uno.UnoRuntime; 38 import com.sun.star.uno.XInterface; 39 40 /** 41 * Test for object which is represented by service 42 * <code>com.sun.star.lingu2.DicList</code>. <p> 43 * Object implements the following interfaces : 44 * <ul> 45 * <li> <code>com::sun::star::linguistic2::XSearchableDictionaryList</code></li> 46 * <li> <code>com::sun::star::lang::XComponent</code></li> 47 * <li> <code>com::sun::star::lang::XServiceInfo</code></li> 48 * <li> <code>com::sun::star::linguistic2::XDictionaryList</code></li> 49 * </ul> <p> 50 * 51 * This object test <b> is NOT </b> designed to be run in several 52 * threads concurently. 53 * 54 * @see com.sun.star.linguistic2.XSearchableDictionaryList 55 * @see com.sun.star.lang.XComponent 56 * @see com.sun.star.lang.XServiceInfo 57 * @see com.sun.star.linguistic2.XDictionaryList 58 * @see ifc.linguistic2._XSearchableDictionaryList 59 * @see ifc.lang._XComponent 60 * @see ifc.lang._XServiceInfo 61 * @see ifc.linguistic2._XDictionaryList 62 */ 63 public class DicList extends TestCase { 64 65 /** 66 * Creating a Testenvironment for the interfaces to be tested. 67 * Creates an instance of the service 68 * <code>com.sun.star.lingu2.DicList</code>. Then two dictionaries 69 * are created (positive and negative) and added to the list, one 70 * entry is added to each of dictionaries and they both are activated. 71 * The distionary list is retruned as a component for testing. 72 */ createTestEnvironment( TestParameters Param, PrintWriter log )73 public synchronized TestEnvironment createTestEnvironment( TestParameters Param, PrintWriter log ) 74 throws StatusException { 75 76 XMultiServiceFactory xMSF = (XMultiServiceFactory)Param.getMSF(); 77 XInterface oObj = null; 78 79 try { 80 oObj = (XInterface)xMSF.createInstance("com.sun.star.lingu2.DicList"); 81 } catch (com.sun.star.uno.Exception e) { 82 e.printStackTrace(log); 83 throw new StatusException("Unexpected exception", e); 84 } 85 86 String Iname = util.utils.getImplName(oObj); 87 log.println("Implementation Name: "+Iname); 88 TestEnvironment tEnv = new TestEnvironment(oObj); 89 90 //creating a user defined dictionary for XSearchableDictionaryList 91 XDictionaryList xDicList = (XDictionaryList) UnoRuntime.queryInterface( 92 XDictionaryList.class, oObj); 93 xDicList.removeDictionary(xDicList.getDictionaryByName("MyDictionary")); 94 XDictionary xDic = xDicList.createDictionary("NegativDic",new Locale( 95 "en","US","WIN"),com.sun.star.linguistic2.DictionaryType.NEGATIVE,""); 96 XDictionary xDic2 = xDicList.createDictionary("PositivDic",new Locale( 97 "en","US","WIN"),com.sun.star.linguistic2.DictionaryType.POSITIVE,""); 98 xDic2.add("Positiv",false,""); 99 xDic.add("Negativ",true,""); 100 xDicList.addDictionary(xDic); 101 xDicList.addDictionary(xDic2); 102 xDic.setActive(true); 103 xDic2.setActive(true); 104 105 return tEnv; 106 } 107 108 } // finish class DicList 109 110