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