1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 package org.openoffice.idesupport; 29 30 import java.io.File; 31 import java.net.ConnectException; 32 import java.util.Vector; 33 34 /** 35 * LocalOffice represents a connection to the local office. 36 * 37 * This class allows to get access to some scripting framework 38 * releated functionality of the locally running office. The 39 * office has to be started with options appropriate for establishing 40 * local connection. 41 * 42 * @author misha <misha@openoffice.org> 43 */ 44 public class LocalOffice 45 { 46 /** 47 * Creates an instance of the local office connection. 48 * 49 * @param parent is an application specific class loader. 50 * @param officePath is a platform specific path string 51 * to the office distribution. 52 * @param port is a communication port. 53 */ 54 public static final LocalOffice create( 55 ClassLoader parent, String officePath, int port) 56 { 57 Vector path = new Vector(); 58 path.addElement(officePath + "/program/classes/ridl.jar"); 59 path.addElement(officePath + "/program/classes/jurt.jar"); 60 path.addElement(officePath + "/program/classes/unoil.jar"); 61 path.addElement(officePath + "/program/classes/juh.jar"); 62 path.addElement(System.getProperties().getProperty("netbeans.home") + 63 File.separator + "modules" + 64 File.separator + "ext" + 65 File.separator + "localoffice.jar"); 66 // commented out so code will compile 67 // ClassLoader appcl = new DefaultScriptClassLoader(parent, path); 68 ClassLoader appcl = path.getClass().getClassLoader(); 69 Class clazz = null; 70 LocalOffice office = null; 71 try { 72 clazz = appcl.loadClass( 73 "org.openoffice.idesupport.localoffice.LocalOfficeImpl"); 74 office = (LocalOffice)clazz.newInstance(); 75 office.connect(officePath, port); 76 } catch (java.lang.Exception exp) { 77 office = null; 78 } 79 return office; 80 } 81 82 /** 83 * Connects to the running office. 84 * 85 * @param officePath is a platform specific path string 86 * to the office distribution. 87 * @param port is a communication port. 88 */ 89 protected void connect(String officePath, int port) 90 throws ConnectException 91 { 92 } 93 94 /** 95 * Closes the connection to the running office. 96 */ 97 public void disconnect() 98 { 99 } 100 101 /** 102 * Refresh the script storage. 103 * 104 * @param uri is an identifier of storage has to be refreshed. 105 */ 106 public void refreshStorage(String uri) 107 { 108 } 109 } 110