1*cd519653SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*cd519653SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*cd519653SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*cd519653SAndrew Rist * distributed with this work for additional information 6*cd519653SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*cd519653SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*cd519653SAndrew Rist * "License"); you may not use this file except in compliance 9*cd519653SAndrew Rist * with the License. You may obtain a copy of the License at 10*cd519653SAndrew Rist * 11*cd519653SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*cd519653SAndrew Rist * 13*cd519653SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*cd519653SAndrew Rist * software distributed under the License is distributed on an 15*cd519653SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*cd519653SAndrew Rist * KIND, either express or implied. See the License for the 17*cd519653SAndrew Rist * specific language governing permissions and limitations 18*cd519653SAndrew Rist * under the License. 19*cd519653SAndrew Rist * 20*cd519653SAndrew Rist *************************************************************/ 21*cd519653SAndrew Rist 22*cd519653SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir package org.openoffice.idesupport; 25cdf0e10cSrcweir 26cdf0e10cSrcweir import java.io.File; 27cdf0e10cSrcweir import java.net.ConnectException; 28cdf0e10cSrcweir import java.util.Vector; 29cdf0e10cSrcweir 30cdf0e10cSrcweir /** 31cdf0e10cSrcweir * LocalOffice represents a connection to the local office. 32cdf0e10cSrcweir * 33cdf0e10cSrcweir * This class allows to get access to some scripting framework 34cdf0e10cSrcweir * releated functionality of the locally running office. The 35cdf0e10cSrcweir * office has to be started with options appropriate for establishing 36cdf0e10cSrcweir * local connection. 37cdf0e10cSrcweir * 38cdf0e10cSrcweir * @author misha <misha@openoffice.org> 39cdf0e10cSrcweir */ 40cdf0e10cSrcweir public class LocalOffice 41cdf0e10cSrcweir { 42cdf0e10cSrcweir /** 43cdf0e10cSrcweir * Creates an instance of the local office connection. 44cdf0e10cSrcweir * 45cdf0e10cSrcweir * @param parent is an application specific class loader. 46cdf0e10cSrcweir * @param officePath is a platform specific path string 47cdf0e10cSrcweir * to the office distribution. 48cdf0e10cSrcweir * @param port is a communication port. 49cdf0e10cSrcweir */ create( ClassLoader parent, String officePath, int port)50cdf0e10cSrcweir public static final LocalOffice create( 51cdf0e10cSrcweir ClassLoader parent, String officePath, int port) 52cdf0e10cSrcweir { 53cdf0e10cSrcweir Vector path = new Vector(); 54cdf0e10cSrcweir path.addElement(officePath + "/program/classes/ridl.jar"); 55cdf0e10cSrcweir path.addElement(officePath + "/program/classes/jurt.jar"); 56cdf0e10cSrcweir path.addElement(officePath + "/program/classes/unoil.jar"); 57cdf0e10cSrcweir path.addElement(officePath + "/program/classes/juh.jar"); 58cdf0e10cSrcweir path.addElement(System.getProperties().getProperty("netbeans.home") + 59cdf0e10cSrcweir File.separator + "modules" + 60cdf0e10cSrcweir File.separator + "ext" + 61cdf0e10cSrcweir File.separator + "localoffice.jar"); 62cdf0e10cSrcweir // commented out so code will compile 63cdf0e10cSrcweir // ClassLoader appcl = new DefaultScriptClassLoader(parent, path); 64cdf0e10cSrcweir ClassLoader appcl = path.getClass().getClassLoader(); 65cdf0e10cSrcweir Class clazz = null; 66cdf0e10cSrcweir LocalOffice office = null; 67cdf0e10cSrcweir try { 68cdf0e10cSrcweir clazz = appcl.loadClass( 69cdf0e10cSrcweir "org.openoffice.idesupport.localoffice.LocalOfficeImpl"); 70cdf0e10cSrcweir office = (LocalOffice)clazz.newInstance(); 71cdf0e10cSrcweir office.connect(officePath, port); 72cdf0e10cSrcweir } catch (java.lang.Exception exp) { 73cdf0e10cSrcweir office = null; 74cdf0e10cSrcweir } 75cdf0e10cSrcweir return office; 76cdf0e10cSrcweir } 77cdf0e10cSrcweir 78cdf0e10cSrcweir /** 79cdf0e10cSrcweir * Connects to the running office. 80cdf0e10cSrcweir * 81cdf0e10cSrcweir * @param officePath is a platform specific path string 82cdf0e10cSrcweir * to the office distribution. 83cdf0e10cSrcweir * @param port is a communication port. 84cdf0e10cSrcweir */ connect(String officePath, int port)85cdf0e10cSrcweir protected void connect(String officePath, int port) 86cdf0e10cSrcweir throws ConnectException 87cdf0e10cSrcweir { 88cdf0e10cSrcweir } 89cdf0e10cSrcweir 90cdf0e10cSrcweir /** 91cdf0e10cSrcweir * Closes the connection to the running office. 92cdf0e10cSrcweir */ disconnect()93cdf0e10cSrcweir public void disconnect() 94cdf0e10cSrcweir { 95cdf0e10cSrcweir } 96cdf0e10cSrcweir 97cdf0e10cSrcweir /** 98cdf0e10cSrcweir * Refresh the script storage. 99cdf0e10cSrcweir * 100cdf0e10cSrcweir * @param uri is an identifier of storage has to be refreshed. 101cdf0e10cSrcweir */ refreshStorage(String uri)102cdf0e10cSrcweir public void refreshStorage(String uri) 103cdf0e10cSrcweir { 104cdf0e10cSrcweir } 105cdf0e10cSrcweir } 106