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 package integration.forms;
23 
24 import com.sun.star.uno.*;
25 import com.sun.star.lang.*;
26 import com.sun.star.beans.*;
27 import com.sun.star.container.*;
28 
29 /** provides global helpers
30 */
31 class dbfTools
32 {
33     /* ------------------------------------------------------------------ */
34     /** disposes the component given
35     */
disposeComponent( Object xComp )36     static public void disposeComponent( Object xComp ) throws java.lang.RuntimeException
37     {
38         XComponent xComponent = queryComponent( xComp );
39         if ( null != xComponent )
40             xComponent.dispose();
41     }
42 
43     /* ------------------------------------------------------------------ */
44     /** queries an object for the XPropertySet interface
45     */
queryPropertySet( Object aComp )46     static public XPropertySet queryPropertySet( Object aComp )
47     {
48         return UnoRuntime.queryInterface( XPropertySet.class, aComp );
49     }
50 
51     /* ------------------------------------------------------------------ */
52     /** queries an object for the XIndexContainer interface
53     */
queryIndexContainer( Object aComp )54     static public XIndexContainer queryIndexContainer( Object aComp )
55     {
56         return UnoRuntime.queryInterface( XIndexContainer.class, aComp );
57     }
58 
59     /* ------------------------------------------------------------------ */
60     /** queries an object for the XComponent interface
61     */
queryComponent( Object aComp )62     static public XComponent queryComponent( Object aComp )
63     {
64         return UnoRuntime.queryInterface( XComponent.class, aComp );
65     }
66 
67     /* ------------------------------------------------------------------ */
68     /** retrieves the parent of the given object
69     */
70     @SuppressWarnings("unchecked")
getParent( Object aComponent, Class aInterfaceClass )71     static Object getParent( Object aComponent, Class aInterfaceClass )
72     {
73         XChild xAsChild = UnoRuntime.queryInterface( XChild.class, aComponent );
74         return UnoRuntime.queryInterface( aInterfaceClass, xAsChild.getParent() );
75     }
76 };
77