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 com.sun.star.wizards.table;
24 
25 import com.sun.star.container.XNameAccess;
26 import com.sun.star.lang.XMultiServiceFactory;
27 import com.sun.star.uno.Exception;
28 import com.sun.star.uno.UnoRuntime;
29 import com.sun.star.wizards.common.Configuration;
30 
31 /**
32  * @author Administrator
33  *
34  * To change the template for this generated type comment go to
35  * Window>Preferences>Java>Code Generation>Code and Comments
36  */
37 // import com.sun.star.wizards.common.ConfigGroup;
38 public class CGCategory
39 {
40 
41     public String Name;
42     public int Index;
43     private String[] Tables;
44     private final String CGROOTPATH = "/org.openoffice.Office.TableWizard/TableWizard/";
45     XMultiServiceFactory xMSF;
46     XNameAccess xNameAccessTablesNode;
47     XNameAccess xNameAccessCurBusinessNode;
48     Object oconfigView;
49 
CGCategory(XMultiServiceFactory _xMSF)50     public CGCategory(XMultiServiceFactory _xMSF)
51     {
52         xMSF = _xMSF;
53     }
54 
initialize(String category)55     public void initialize(String category)
56     {
57         try
58         {
59             oconfigView = Configuration.getConfigurationRoot(xMSF, CGROOTPATH, false);  //business/Tables
60             xNameAccessCurBusinessNode = Configuration.getChildNodebyName(
61                 UnoRuntime.queryInterface(XNameAccess.class, oconfigView),
62                 category);
63         }
64         catch (Exception e)
65         {
66             e.printStackTrace(System.out);
67         }
68     }
69 
getTableNames()70     public String[] getTableNames()
71     {
72         try
73         {
74             xNameAccessTablesNode = UnoRuntime.queryInterface(XNameAccess.class, xNameAccessCurBusinessNode.getByName("Tables"));
75             return Configuration.getNodeDisplayNames(xNameAccessTablesNode);
76         }
77         catch (Exception e)
78         {
79             e.printStackTrace(System.out);
80             return null;
81         }
82     }
83 }
84