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.ui;
29 
30 import com.sun.star.beans.PropertyValue;
31 import com.sun.star.ui.XUIElementFactory;
32 import com.sun.star.ui.XUIElementFactoryRegistration;
33 import lib.MultiMethodTest;
34 
35 public class _XUIElementFactoryRegistration extends MultiMethodTest {
36 
37     public XUIElementFactoryRegistration oObj;
38 
39     public void _registerFactory() {
40         boolean result = true;
41         try {
42             oObj.registerFactory("private:resource/menubar/menubar", "MyOwnMenubar", "", "com.sun.star.comp.framework.MenuBarFactory");
43         }
44         catch(com.sun.star.container.ElementExistException e) {
45             result = false;
46             e.printStackTrace(log);
47         }
48         tRes.tested("registerFactory()", result);
49     }
50 
51     public void _getRegisteredFactories() {
52         requiredMethod("registerFactory()");
53         PropertyValue[][]props = oObj.getRegisteredFactories();
54         if (props == null) {
55             log.println("Null was returned as PropertyValue[][]");
56             props = new PropertyValue[0][0];
57         }
58         for(int i=0; i<props.length; i++)
59             for(int j=0; j<props[i].length; j++)
60                 log.println("Factory: " + props[i][j].Name + "    -    " + props[i][j].Value);
61         tRes.tested("getRegisteredFactories()", props.length != 0);
62     }
63 
64     public void _getFactory() {
65         requiredMethod("registerFactory()");
66         XUIElementFactory xFactory = oObj.getFactory("private:resource/menubar/menubar", "");
67         tRes.tested("getFactory()", xFactory != null);
68     }
69 
70     public void _deregisterFactory() {
71         executeMethod("getRegisteredFactory()");
72         executeMethod("getFactory()");
73         boolean result = true;
74         try {
75             oObj.deregisterFactory("private:resource/menubar/menubar", "MyOwnMenubar", "");
76         }
77         catch(com.sun.star.container.NoSuchElementException e) {
78             result = false;
79             e.printStackTrace(log);
80         }
81         tRes.tested("deregisterFactory()", true);
82     }
83 }
84