fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / scripting / java / org / openoffice / idesupport / LocalOffice.java
blobf28e36ad3c9e12c853b83c9250b020d099324c0c
1 /*
2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 package org.openoffice.idesupport;
21 import java.io.File;
22 import java.net.ConnectException;
23 import java.util.ArrayList;
25 /**
26 * LocalOffice represents a connection to the local office.
28 * This class allows to get access to some scripting framework
29 * releated functionality of the locally running office. The
30 * office has to be started with options appropriate for establishing
31 * local connection.
33 public class LocalOffice
35 /**
36 * Creates an instance of the local office connection.
38 * @param parent is an application specific class loader.
39 * @param officePath is a platform specific path string
40 * to the office distribution.
41 * @param port is a communication port.
43 public static final LocalOffice create(
44 ClassLoader parent, String officePath, int port)
46 ArrayList<String> path = new ArrayList<String>();
47 path.add(officePath + "/program/classes/ridl.jar");
48 path.add(officePath + "/program/classes/jurt.jar");
49 path.add(officePath + "/program/classes/unoil.jar");
50 path.add(officePath + "/program/classes/juh.jar");
51 path.add(System.getProperties().getProperty("netbeans.home") +
52 File.separator + "modules" +
53 File.separator + "ext" +
54 File.separator + "localoffice.jar");
55 // commented out so code will compile
56 // ClassLoader appcl = new DefaultScriptClassLoader(parent, path);
57 ClassLoader appcl = path.getClass().getClassLoader();
58 Class clazz = null;
59 LocalOffice office = null;
60 try {
61 clazz = appcl.loadClass(
62 "org.openoffice.idesupport.localoffice.LocalOfficeImpl");
63 office = (LocalOffice)clazz.newInstance();
64 office.connect(officePath, port);
65 } catch (java.lang.Exception exp) {
66 office = null;
68 return office;
71 /**
72 * Connects to the running office.
74 * @param officePath is a platform specific path string
75 * to the office distribution.
76 * @param port is a communication port.
78 protected void connect(String officePath, int port)
79 throws ConnectException
83 /**
84 * Closes the connection to the running office.
86 public void disconnect()
90 /**
91 * Refresh the script storage.
93 * @param uri is an identifier of storage has to be refreshed.
95 public void refreshStorage(String uri)