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 package mod._svx;
24 
25 import com.sun.star.container.XIndexAccess;
26 import com.sun.star.lang.XComponent;
27 import com.sun.star.lang.XMultiServiceFactory;
28 import com.sun.star.uno.Exception;
29 import com.sun.star.uno.UnoRuntime;
30 import com.sun.star.uno.XInterface;
31 
32 import java.io.PrintWriter;
33 
34 import lib.StatusException;
35 import lib.TestCase;
36 import lib.TestEnvironment;
37 import lib.TestParameters;
38 
39 import util.DrawTools;
40 
41 
42 public class SvxUnoNumberingRules extends TestCase {
43     static XComponent xDrawDoc;
44 
initialize(TestParameters tParam, PrintWriter log)45     protected void initialize(TestParameters tParam, PrintWriter log) {
46         log.println("creating a drawdoc");
47         xDrawDoc = DrawTools.createDrawDoc(
48                            (XMultiServiceFactory) tParam.getMSF());
49     }
50 
createTestEnvironment(TestParameters tParam, PrintWriter log)51     protected TestEnvironment createTestEnvironment(TestParameters tParam,
52                                                     PrintWriter log) {
53         XMultiServiceFactory docMSF = (XMultiServiceFactory) UnoRuntime.queryInterface(
54                                               XMultiServiceFactory.class,
55                                               xDrawDoc);
56         XInterface oObj = null;
57 
58         try {
59             oObj = (XInterface) docMSF.createInstance(
60                            "com.sun.star.text.NumberingRules");
61         } catch (Exception e) {
62             e.printStackTrace(log);
63             throw new StatusException("Unexpected exception", e);
64         }
65 
66         TestEnvironment tEnv = new TestEnvironment(oObj);
67 
68         log.println("Implementationname: " + util.utils.getImplName(oObj));
69 
70         Object NewRules=null;
71 
72         try{
73         XIndexAccess xIA = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, oObj);
74         NewRules = xIA.getByIndex(2);
75         } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
76             log.println("Couldn't get new Rules for XIndexReplace");
77         } catch (com.sun.star.lang.WrappedTargetException e) {
78             log.println("Couldn't get new Rules for XIndexReplace");
79         }
80 
81         tEnv.addObjRelation("INSTANCE1",NewRules);
82 
83         return tEnv;
84     }
85 
cleanup(TestParameters tParam, PrintWriter log)86     protected void cleanup(TestParameters tParam, PrintWriter log) {
87         log.println("    disposing xDrawDoc ");
88         util.DesktopTools.closeDoc(xDrawDoc);
89     }
90 }
91