1*b9b79128SAndrew Rist /**************************************************************
2*b9b79128SAndrew Rist  *
3*b9b79128SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*b9b79128SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*b9b79128SAndrew Rist  * distributed with this work for additional information
6*b9b79128SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*b9b79128SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*b9b79128SAndrew Rist  * "License"); you may not use this file except in compliance
9*b9b79128SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*b9b79128SAndrew Rist  *
11*b9b79128SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*b9b79128SAndrew Rist  *
13*b9b79128SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*b9b79128SAndrew Rist  * software distributed under the License is distributed on an
15*b9b79128SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*b9b79128SAndrew Rist  * KIND, either express or implied.  See the License for the
17*b9b79128SAndrew Rist  * specific language governing permissions and limitations
18*b9b79128SAndrew Rist  * under the License.
19*b9b79128SAndrew Rist  *
20*b9b79128SAndrew Rist  *************************************************************/
21*b9b79128SAndrew Rist 
22cdf0e10cSrcweir package integration.forms;
23cdf0e10cSrcweir 
24cdf0e10cSrcweir import com.sun.star.uno.*;
25cdf0e10cSrcweir import com.sun.star.lang.*;
26cdf0e10cSrcweir import com.sun.star.beans.*;
27cdf0e10cSrcweir import com.sun.star.container.*;
28cdf0e10cSrcweir 
29cdf0e10cSrcweir /** provides global helpers
30cdf0e10cSrcweir */
31cdf0e10cSrcweir class dbfTools
32cdf0e10cSrcweir {
33cdf0e10cSrcweir     /* ------------------------------------------------------------------ */
34cdf0e10cSrcweir     /** disposes the component given
35cdf0e10cSrcweir     */
disposeComponent( Object xComp )36cdf0e10cSrcweir     static public void disposeComponent( Object xComp ) throws java.lang.RuntimeException
37cdf0e10cSrcweir     {
38cdf0e10cSrcweir         XComponent xComponent = queryComponent( xComp );
39cdf0e10cSrcweir         if ( null != xComponent )
40cdf0e10cSrcweir             xComponent.dispose();
41cdf0e10cSrcweir     }
42cdf0e10cSrcweir 
43cdf0e10cSrcweir     /* ------------------------------------------------------------------ */
44cdf0e10cSrcweir     /** queries an object for the XPropertySet interface
45cdf0e10cSrcweir     */
queryPropertySet( Object aComp )46cdf0e10cSrcweir     static public XPropertySet queryPropertySet( Object aComp )
47cdf0e10cSrcweir     {
48cdf0e10cSrcweir         return UnoRuntime.queryInterface( XPropertySet.class, aComp );
49cdf0e10cSrcweir     }
50cdf0e10cSrcweir 
51cdf0e10cSrcweir     /* ------------------------------------------------------------------ */
52cdf0e10cSrcweir     /** queries an object for the XIndexContainer interface
53cdf0e10cSrcweir     */
queryIndexContainer( Object aComp )54cdf0e10cSrcweir     static public XIndexContainer queryIndexContainer( Object aComp )
55cdf0e10cSrcweir     {
56cdf0e10cSrcweir         return UnoRuntime.queryInterface( XIndexContainer.class, aComp );
57cdf0e10cSrcweir     }
58cdf0e10cSrcweir 
59cdf0e10cSrcweir     /* ------------------------------------------------------------------ */
60cdf0e10cSrcweir     /** queries an object for the XComponent interface
61cdf0e10cSrcweir     */
queryComponent( Object aComp )62cdf0e10cSrcweir     static public XComponent queryComponent( Object aComp )
63cdf0e10cSrcweir     {
64cdf0e10cSrcweir         return UnoRuntime.queryInterface( XComponent.class, aComp );
65cdf0e10cSrcweir     }
66cdf0e10cSrcweir 
67cdf0e10cSrcweir     /* ------------------------------------------------------------------ */
68cdf0e10cSrcweir     /** retrieves the parent of the given object
69cdf0e10cSrcweir     */
70cdf0e10cSrcweir     @SuppressWarnings("unchecked")
getParent( Object aComponent, Class aInterfaceClass )71cdf0e10cSrcweir     static Object getParent( Object aComponent, Class aInterfaceClass )
72cdf0e10cSrcweir     {
73cdf0e10cSrcweir         XChild xAsChild = UnoRuntime.queryInterface( XChild.class, aComponent );
74cdf0e10cSrcweir         return UnoRuntime.queryInterface( aInterfaceClass, xAsChild.getParent() );
75cdf0e10cSrcweir     }
76cdf0e10cSrcweir };
77