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 import com.sun.star.beans.PropertyValue;
25 import com.sun.star.bridge.XUnoUrlResolver;
26 import com.sun.star.frame.XComponentLoader;
27 import com.sun.star.uno.UnoRuntime;
28 import com.sun.star.uno.XComponentContext;
29 import com.sun.star.lang.XMultiComponentFactory;
30 import com.sun.star.beans.XPropertySet;
31 
32 public class SimpleBootstrap_java {
33 
main(String[] args)34     public static void main(String[] args) {
35 
36         try {
37             // get the remote office component context
38             XComponentContext xContext =
39                 com.sun.star.comp.helper.Bootstrap.bootstrap();
40 
41             // get the remote office service manager
42             XMultiComponentFactory xServiceManager =
43                 xContext.getServiceManager();
44 
45             // get an instance of the remote office desktop UNO service
46             Object desktop = xServiceManager.createInstanceWithContext(
47                 "com.sun.star.frame.Desktop", xContext );
48 
49             // query the XComponentLoader interface from the desktop
50             XComponentLoader xComponentLoader =
51                 (XComponentLoader)UnoRuntime.queryInterface(
52                     XComponentLoader.class, desktop );
53 
54             // load a spreadsheet document
55             String loadURL = "private:factory/scalc";
56             PropertyValue[] loadProps = new PropertyValue[0];
57             xComponentLoader.loadComponentFromURL(
58                 loadURL, "_blank", 0, loadProps);
59         }
60         catch (java.lang.Exception e){
61             e.printStackTrace();
62         }
63         System.exit( 0 );
64     }
65 }
66