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 org.openoffice.idesupport;
25 
26 import java.io.File;
27 import java.net.ConnectException;
28 import java.util.Vector;
29 
30 /**
31  * LocalOffice represents a connection to the local office.
32  *
33  * This class allows to get access to some scripting framework
34  * releated functionality of the locally running office. The
35  * office has to be started with options appropriate for establishing
36  * local connection.
37  *
38  * @author misha <misha@openoffice.org>
39  */
40 public class LocalOffice
41 {
42     /**
43      * Creates an instance of the local office connection.
44      *
45      * @param parent is an application specific class loader.
46      * @param officePath is a platform specific path string
47      *   to the office distribution.
48      * @param port is a communication port.
49      */
create( ClassLoader parent, String officePath, int port)50     public static final LocalOffice create(
51         ClassLoader parent, String officePath, int port)
52     {
53         Vector      path    = new Vector();
54         path.addElement(officePath + "/program/classes/ridl.jar");
55         path.addElement(officePath + "/program/classes/jurt.jar");
56         path.addElement(officePath + "/program/classes/unoil.jar");
57         path.addElement(officePath + "/program/classes/juh.jar");
58         path.addElement(System.getProperties().getProperty("netbeans.home") +
59             File.separator + "modules" +
60             File.separator + "ext" +
61             File.separator + "localoffice.jar");
62         // commented out so code will compile
63         // ClassLoader appcl   = new DefaultScriptClassLoader(parent, path);
64         ClassLoader appcl = path.getClass().getClassLoader();
65         Class       clazz   = null;
66         LocalOffice office  = null;
67         try {
68             clazz   = appcl.loadClass(
69                 "org.openoffice.idesupport.localoffice.LocalOfficeImpl");
70             office  = (LocalOffice)clazz.newInstance();
71             office.connect(officePath, port);
72         } catch (java.lang.Exception exp) {
73             office  = null;
74         }
75         return office;
76     }
77 
78     /**
79      * Connects to the running office.
80      *
81      * @param officePath is a platform specific path string
82      *   to the office distribution.
83      * @param port is a communication port.
84      */
connect(String officePath, int port)85     protected void connect(String officePath, int port)
86         throws ConnectException
87     {
88     }
89 
90     /**
91      * Closes the connection to the running office.
92      */
disconnect()93     public void disconnect()
94     {
95     }
96 
97     /**
98      * Refresh the script storage.
99      *
100      * @param uri is an identifier of storage has to be refreshed.
101      */
refreshStorage(String uri)102     public void refreshStorage(String uri)
103     {
104     }
105 }
106