1*34dd1e25SAndrew Rist /**************************************************************
2*34dd1e25SAndrew Rist  *
3*34dd1e25SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*34dd1e25SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*34dd1e25SAndrew Rist  * distributed with this work for additional information
6*34dd1e25SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*34dd1e25SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*34dd1e25SAndrew Rist  * "License"); you may not use this file except in compliance
9*34dd1e25SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*34dd1e25SAndrew Rist  *
11*34dd1e25SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*34dd1e25SAndrew Rist  *
13*34dd1e25SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*34dd1e25SAndrew Rist  * software distributed under the License is distributed on an
15*34dd1e25SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*34dd1e25SAndrew Rist  * KIND, either express or implied.  See the License for the
17*34dd1e25SAndrew Rist  * specific language governing permissions and limitations
18*34dd1e25SAndrew Rist  * under the License.
19*34dd1e25SAndrew Rist  *
20*34dd1e25SAndrew Rist  *************************************************************/
21*34dd1e25SAndrew Rist 
22*34dd1e25SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir import com.sun.star.beans.PropertyValue;
25cdf0e10cSrcweir import com.sun.star.bridge.XUnoUrlResolver;
26cdf0e10cSrcweir import com.sun.star.frame.XComponentLoader;
27cdf0e10cSrcweir import com.sun.star.uno.UnoRuntime;
28cdf0e10cSrcweir import com.sun.star.uno.XComponentContext;
29cdf0e10cSrcweir import com.sun.star.lang.XMultiComponentFactory;
30cdf0e10cSrcweir import com.sun.star.beans.XPropertySet;
31cdf0e10cSrcweir 
32cdf0e10cSrcweir public class SimpleBootstrap_java {
33cdf0e10cSrcweir 
main(String[] args)34cdf0e10cSrcweir     public static void main(String[] args) {
35cdf0e10cSrcweir 
36cdf0e10cSrcweir         try {
37cdf0e10cSrcweir             // get the remote office component context
38cdf0e10cSrcweir             XComponentContext xContext =
39cdf0e10cSrcweir                 com.sun.star.comp.helper.Bootstrap.bootstrap();
40cdf0e10cSrcweir 
41cdf0e10cSrcweir             // get the remote office service manager
42cdf0e10cSrcweir             XMultiComponentFactory xServiceManager =
43cdf0e10cSrcweir                 xContext.getServiceManager();
44cdf0e10cSrcweir 
45cdf0e10cSrcweir             // get an instance of the remote office desktop UNO service
46cdf0e10cSrcweir             Object desktop = xServiceManager.createInstanceWithContext(
47cdf0e10cSrcweir                 "com.sun.star.frame.Desktop", xContext );
48cdf0e10cSrcweir 
49cdf0e10cSrcweir             // query the XComponentLoader interface from the desktop
50cdf0e10cSrcweir             XComponentLoader xComponentLoader =
51cdf0e10cSrcweir                 (XComponentLoader)UnoRuntime.queryInterface(
52cdf0e10cSrcweir                     XComponentLoader.class, desktop );
53cdf0e10cSrcweir 
54cdf0e10cSrcweir             // load a spreadsheet document
55cdf0e10cSrcweir             String loadURL = "private:factory/scalc";
56cdf0e10cSrcweir             PropertyValue[] loadProps = new PropertyValue[0];
57cdf0e10cSrcweir             xComponentLoader.loadComponentFromURL(
58cdf0e10cSrcweir                 loadURL, "_blank", 0, loadProps);
59cdf0e10cSrcweir         }
60cdf0e10cSrcweir         catch (java.lang.Exception e){
61cdf0e10cSrcweir             e.printStackTrace();
62cdf0e10cSrcweir         }
63cdf0e10cSrcweir         System.exit( 0 );
64cdf0e10cSrcweir     }
65cdf0e10cSrcweir }
66