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 util;
25 
26 import com.sun.star.lang.XMultiServiceFactory;
27 import com.sun.star.uno.XInterface;
28 import com.sun.star.uno.UnoRuntime;
29 import com.sun.star.text.XTextTable;
30 /**
31  * the class TableDsc
32  */
33 public class TableDsc extends InstDescr {
34 
35 	private int rows = 0;
36 	private int columns = 0;
37 	private String name = null;
38 	final String ifcName = "com.sun.star.text.XTextTable";
39 	final String service = "com.sun.star.text.TextTable";
40 
TableDsc()41 	public TableDsc() {
42 		initTable();
43 	}
44 
TableDsc( int nRows, int nColumns )45 	public TableDsc( int nRows, int nColumns ) {
46 		rows = nRows;
47 		columns = nColumns;
48 		initTable();
49 	}
50 
TableDsc( String TableName, int nRows, int nColumns )51 	public TableDsc( String TableName, int nRows, int nColumns ) {
52 		name = TableName;
53 		rows = nRows;
54 		columns = nColumns;
55 		initTable();
56 	}
getName()57 	public String getName() {
58 		return name;
59 	}
getIfcName()60 	public String getIfcName() {
61 		return ifcName;
62 	}
getService()63 	public String getService() {
64 		return service;
65 	}
66 
initTable()67 	private void initTable() {
68 		try {
69 	       	ifcClass = Class.forName( ifcName );
70 	    }
71 	    catch( ClassNotFoundException cnfE ) {
72 	    }
73 	}
createInstance( XMultiServiceFactory docMSF )74 	public XInterface createInstance( XMultiServiceFactory docMSF ) {
75 		Object SrvObj = null;
76 		try {
77 			SrvObj = docMSF.createInstance( service );
78 		}
79 		catch( com.sun.star.uno.Exception cssuE ){
80 		}
81 
82 		XTextTable TT = (XTextTable)UnoRuntime.queryInterface(
83 														ifcClass, SrvObj );
84 
85 		if ( rows > 0 && columns > 0 )	{
86 			TT.initialize( rows, columns );
87 		}
88 
89 		return TT;
90 
91 	}
92 }
93