summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bean/com/sun/star/beans/ContainerFactory.java80
-rw-r--r--bean/com/sun/star/beans/JavaWindowPeerFake.java162
-rw-r--r--bean/com/sun/star/beans/LocalOfficeConnection.java613
-rw-r--r--bean/com/sun/star/beans/LocalOfficeWindow.java287
-rw-r--r--bean/com/sun/star/beans/NativeConnection.java92
-rw-r--r--bean/com/sun/star/beans/NativeService.java69
-rw-r--r--bean/com/sun/star/beans/OfficeConnection.java60
-rw-r--r--bean/com/sun/star/beans/OfficeWindow.java36
-rw-r--r--bean/com/sun/star/beans/makefile.mk14
-rw-r--r--bean/com/sun/star/comp/beans/LocalOfficeConnection.java11
-rw-r--r--bean/native/unix/com_sun_star_beans_LocalOfficeWindow.c123
-rw-r--r--bean/native/unix/makefile.mk3
-rw-r--r--bean/native/win32/com_sun_star_beans_LocalOfficeWindow.c122
-rw-r--r--bean/native/win32/makefile.mk3
-rw-r--r--bean/util/makefile.mk92
15 files changed, 1710 insertions, 57 deletions
diff --git a/bean/com/sun/star/beans/ContainerFactory.java b/bean/com/sun/star/beans/ContainerFactory.java
new file mode 100644
index 000000000000..0feea76a1fc2
--- /dev/null
+++ b/bean/com/sun/star/beans/ContainerFactory.java
@@ -0,0 +1,80 @@
+/*************************************************************************
+ *
+ * $RCSfile: ContainerFactory.java,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: mi $ $Date: 2004-10-18 07:14:39 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+package com.sun.star.beans;
+
+import java.awt.Container;
+
+/**
+ * This interface reprecents an AWT container factory.
+ *
+ * @see OfficeBean
+ */
+
+public interface ContainerFactory
+{
+ /**
+ * Creates an AWT container.
+ *
+ * @return An AWT container.
+ */
+ Container createContainer();
+}
diff --git a/bean/com/sun/star/beans/JavaWindowPeerFake.java b/bean/com/sun/star/beans/JavaWindowPeerFake.java
new file mode 100644
index 000000000000..5b7ae1a5c918
--- /dev/null
+++ b/bean/com/sun/star/beans/JavaWindowPeerFake.java
@@ -0,0 +1,162 @@
+/*************************************************************************
+ *
+ * $RCSfile: JavaWindowPeerFake.java,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: mi $ $Date: 2004-10-18 07:14:49 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+package com.sun.star.beans;
+
+import java.awt.*;
+
+import com.sun.star.uno.*;
+import com.sun.star.lang.*;
+import com.sun.star.awt.*;
+import com.sun.star.util.*;
+import com.sun.star.beans.*;
+import com.sun.star.container.*;
+
+/** <p>Class to pass the system window handle to the OpenOffice.org toolkit.</p>
+ */
+/* package */ class JavaWindowPeerFake
+ implements XSystemDependentWindowPeer, XWindowPeer
+{
+
+ protected long hWindow;
+ protected int localSystemType;
+
+ /** Create the faked window peer.
+ * @param _hWindow the system handle to the window.
+ * @param _systemType specifies the system type.
+ */
+ public JavaWindowPeerFake(long _hWindow, int _systemType)
+ {
+ hWindow = _hWindow;
+ localSystemType = _systemType;
+ }
+
+ /** <p>Implementation of XSystemDependentWindowPeer (that's all we really need)</p>
+ * This method is called back from the OpenOffice.org toolkit to retrieve the system data.
+ */
+ public Object getWindowHandle(/*IN*/byte[] ProcessId, /*IN*/short SystemType)
+ throws com.sun.star.uno.RuntimeException
+ {
+
+ if (SystemType == localSystemType) {
+ return new Integer((int)hWindow);
+ }
+ else return null;
+ }
+
+ /** not really neaded.
+ */
+ public XToolkit getToolkit()
+ throws com.sun.star.uno.RuntimeException
+ {
+ return null;
+ }
+
+ /** not really neaded.
+ */
+ public void setPointer(/*IN*/XPointer Pointer)
+ throws com.sun.star.uno.RuntimeException
+ {
+ }
+
+ /** not really neaded.
+ */
+ public void setBackground(/*IN*/int Color)
+ throws com.sun.star.uno.RuntimeException
+ {
+ }
+
+ /** not really neaded.
+ */
+ public void invalidate(/*IN*/short Flags)
+ throws com.sun.star.uno.RuntimeException
+ {
+ }
+
+ /** not really neaded.
+ */
+ public void invalidateRect(/*IN*/com.sun.star.awt.Rectangle Rect, /*IN*/short Flags)
+ throws com.sun.star.uno.RuntimeException
+ {
+ }
+
+ /** not really neaded.
+ */
+ public void dispose()
+ throws com.sun.star.uno.RuntimeException
+ {
+ }
+
+ /** not really neaded.
+ */
+ public void addEventListener(/*IN*/com.sun.star.lang.XEventListener xListener)
+ throws com.sun.star.uno.RuntimeException
+ {
+ }
+
+ /** not really neaded.
+ */
+ public void removeEventListener(/*IN*/com.sun.star.lang.XEventListener aListener)
+ throws com.sun.star.uno.RuntimeException
+ {
+ }
+}
+
diff --git a/bean/com/sun/star/beans/LocalOfficeConnection.java b/bean/com/sun/star/beans/LocalOfficeConnection.java
index ad06efe843e1..d84cbae246c7 100644
--- a/bean/com/sun/star/beans/LocalOfficeConnection.java
+++ b/bean/com/sun/star/beans/LocalOfficeConnection.java
@@ -2,9 +2,9 @@
*
* $RCSfile: LocalOfficeConnection.java,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: mi $ $Date: 2004-10-14 10:34:18 $
+ * last change: $Author: mi $ $Date: 2004-10-18 07:15:35 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -12,11 +12,11 @@
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
- * Sun Microsystems Inc., September, 2004
+ * Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
- * Copyright 2004 by Sun Microsystems, Inc.
+ * Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
@@ -50,7 +50,7 @@
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
- * Copyright: 2004 by Sun Microsystems, Inc.
+ * Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
@@ -61,14 +61,607 @@
package com.sun.star.beans;
-/**
- This class reprecents a connection to the local office application.
+import java.awt.Component;
+import java.awt.Container;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Vector;
+import java.util.Properties;
+import java.util.Enumeration;
+
+import com.sun.star.comp.helper.Bootstrap;
- @deprecated
- use com.sun.star.comp.beans.LocalOfficeConnection
+import com.sun.star.lang.XMultiComponentFactory;
+import com.sun.star.lang.XComponent;
+import com.sun.star.lang.XEventListener;
+import com.sun.star.lang.XInitialization;
+import com.sun.star.container.XSet;
+import com.sun.star.connection.XConnection;
+import com.sun.star.bridge.XBridge;
+import com.sun.star.bridge.XBridgeFactory;
+import com.sun.star.bridge.XUnoUrlResolver;
+import com.sun.star.comp.loader.JavaLoader;
+import com.sun.star.loader.XImplementationLoader;
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.uno.Type;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.Exception;
+import com.sun.star.lib.uno.helper.UnoUrl;
+import com.sun.star.lib.util.NativeLibraryLoader;
+/**
+ * This class reprecents a connection to the local office application.
*/
public class LocalOfficeConnection
- extends com.sun.star.comp.beans.LocalOfficeConnection
+ implements OfficeConnection
{
+ public static final String OFFICE_APP_NAME = "soffice";
+ public static final String OFFICE_LIB_NAME = "officebean";
+ public static final String OFFICE_ID_SUFFIX = "_Office";
+
+ private Process mProcess;
+ private ContainerFactory mContainerFactory;
+ private XComponentContext mContext;
+
+ private String mURL;
+ private String mProgramPath;
+ private String mConnType;
+ private String mPipe;
+ private String mPort;
+ private String mProtocol;
+ private String mInitialObject;
+
+ private List mComponents = new Vector();
+
+ /**
+ * Constructor.
+ * Sets up paths to the office application and native libraries if
+ * values are available in <code>OFFICE_PROP_FILE</code> in the user
+ * home directory.<br />
+ * "com.sun.star.beans.path" - the office application directory;<br/>
+ * "com.sun.star.beans.libpath" - native libraries directory.
+ */
+ public LocalOfficeConnection()
+ {
+ // init member vars
+ try
+ {
+ setUnoUrl( "uno:pipe,name=" + getPipeName() + ";urp;StarOffice.ServiceManager" );
+ }
+ catch ( java.net.MalformedURLException e )
+ {}
+
+ // load libofficebean.so/officebean.dll
+ String aSharedLibName = getProgramPath() + java.io.File.separator +
+ System.mapLibraryName(OFFICE_LIB_NAME);
+ System.load( aSharedLibName );
+ }
+
+ /**
+ * Sets a connection URL.
+ * This implementation accepts a UNO URL with following format:<br />
+ * <pre>
+ * url := uno:localoffice[,&lt;params&gt;];urp;StarOffice.ServiceManager
+ * params := &lt;path&gt;[,&lt;pipe&gt;]
+ * path := path=&lt;pathv&gt;
+ * pipe := pipe=&lt;pipev&gt;
+ * pathv := platform_specific_path_to_the_local_office_distribution
+ * pipev := local_office_connection_pipe_name
+ * </pre>
+ *
+ * @param url This is UNO URL which discribes the type of a connection.
+ */
+ public void setUnoUrl(String url)
+ throws java.net.MalformedURLException
+ {
+ mURL = null;
+
+ String prefix = "uno:localoffice";
+ if ( url.startsWith(prefix) )
+ parseUnoUrlWithOfficePath( url, prefix );
+ else
+ {
+ try
+ {
+ UnoUrl aURL = UnoUrl.parseUnoUrl( url );
+ mProgramPath = null;
+ mConnType = aURL.getConnection();
+ mPipe = (String) aURL.getConnectionParameters().get( "pipe" );
+ mPort = (String) aURL.getConnectionParameters().get( "port" );
+ mProtocol = aURL.getProtocol();
+ mInitialObject = aURL.getRootOid();
+ }
+ catch ( com.sun.star.lang.IllegalArgumentException eIll )
+ {
+ throw new java.net.MalformedURLException(
+ "Invalid UNO connection URL.");
+ }
+ }
+ mURL = url;
+ }
+
+ /**
+ * Sets an AWT container catory.
+ *
+ * @param containerFactory This is a application provided AWT container
+ * factory.
+ */
+ public void setContainerFactory(ContainerFactory containerFactory)
+ {
+ mContainerFactory = containerFactory;
+ }
+
+ /**
+ * Retrives the UNO component context.
+ * Establishes a connection if necessary and initialises the
+ * UNO service manager if it has not already been initialised.
+ * This method can return <code>null</code> if it fails to connect
+ * to the office application.
+ *
+ * @return The office UNO component context.
+ */
+ public XComponentContext getComponentContext()
+ {
+ if ( mContext == null )
+ mContext = connect();
+ return mContext;
+ }
+
+ /**
+ * Creates an office window.
+ * The window is either a sub-class of java.awt.Canvas (local) or
+ * java.awt.Container (RVP).
+ *
+ * @param container This is an AWT container.
+ * @return The office window instance.
+ */
+ public OfficeWindow createOfficeWindow(Container container)
+ {
+ return new LocalOfficeWindow(this);
+ }
+
+ /**
+ * Closes the connection.
+ */
+ public void dispose()
+ {
+ Iterator itr = mComponents.iterator();
+ while (itr.hasNext() == true) {
+ // ignore runtime exceptions in dispose
+ try { ((XEventListener)itr.next()).disposing(null); }
+ catch ( RuntimeException aExc ) {}
+ }
+ mComponents.clear();
+
+ mContainerFactory = null;
+ mContext = null;
+ }
+
+ /**
+ * Adds an event listener to the object.
+ *
+ * @param listener is a listener object.
+ */
+ public void addEventListener(XEventListener listener)
+ {
+ mComponents.add(listener);
+ }
+
+ /**
+ * Removes an event listener from the listener list.
+ *
+ * @param listener is a listener object.
+ */
+ public void removeEventListener(XEventListener listener)
+ {
+ mComponents.remove(listener);
+ }
+
+ /**
+ * Establishes the connection to the office.
+ */
+ private XComponentContext connect()
+ {
+ try
+ {
+ // create default local component context
+ XComponentContext xLocalContext =
+ com.sun.star.comp.helper.Bootstrap.createInitialComponentContext(null);
+
+ // initial serviceManager
+ XMultiComponentFactory xLocalServiceManager = xLocalContext.getServiceManager();
+
+ // create a urlresolver
+ Object urlResolver = xLocalServiceManager.createInstanceWithContext(
+ "com.sun.star.bridge.UnoUrlResolver", xLocalContext );
+
+ // query for the XUnoUrlResolver interface
+ XUnoUrlResolver xUrlResolver =
+ (XUnoUrlResolver) UnoRuntime.queryInterface( XUnoUrlResolver.class, urlResolver );
+
+ // try to connect to soffice
+ Object aInitialObject = null;
+ try
+ {
+ aInitialObject = xUrlResolver.resolve( mURL );
+ }
+ catch( com.sun.star.connection.NoConnectException e )
+ {
+ // launch soffice
+ OfficeService aSOffice = new OfficeService();
+ aSOffice.startupService();
+
+ // wait until soffice is started
+ long nMaxMillis = System.currentTimeMillis() + 1000*aSOffice.getStartupTime();
+ while ( aInitialObject == null )
+ {
+ try
+ {
+ // try to connect to soffice
+ Thread.currentThread().sleep( 500 );
+ aInitialObject = xUrlResolver.resolve( mURL );
+ }
+ catch( com.sun.star.connection.NoConnectException aEx )
+ {
+ // soffice did not start in time
+ if ( System.currentTimeMillis() > nMaxMillis )
+ throw aEx;
+
+ }
+ }
+ }
+ finally
+ {
+ }
+
+ // XComponentContext
+ if( null != aInitialObject )
+ {
+ XPropertySet xPropertySet = (XPropertySet)
+ UnoRuntime.queryInterface( XPropertySet.class, aInitialObject);
+ Object xContext = xPropertySet.getPropertyValue("DefaultContext");
+ XComponentContext xComponentContext = (XComponentContext) UnoRuntime.queryInterface(
+ XComponentContext.class, xContext);
+ return xComponentContext;
+ }
+ }
+ catch( com.sun.star.connection.NoConnectException e )
+ {
+ System.out.println( "Couldn't connect to remote server" );
+ System.out.println( e.getMessage() );
+ }
+ catch( com.sun.star.connection.ConnectionSetupException e )
+ {
+ System.out.println( "Couldn't access necessary local resource to establish the interprocess connection" );
+ System.out.println( e.getMessage() );
+ }
+ catch( com.sun.star.lang.IllegalArgumentException e )
+ {
+ System.out.println( "uno-url is syntactical illegal ( " + mURL + " )" );
+ System.out.println( e.getMessage() );
+ }
+ catch( com.sun.star.uno.RuntimeException e )
+ {
+ System.out.println( "--- RuntimeException:" );
+ System.out.println( e.getMessage() );
+ e.printStackTrace();
+ System.out.println( "--- end." );
+ throw e;
+ }
+ catch( java.lang.Exception e )
+ {
+ System.out.println( "java.lang.Exception: " );
+ System.out.println( e );
+ e.printStackTrace();
+ System.out.println( "--- end." );
+ throw new com.sun.star.uno.RuntimeException( e.toString() );
+ }
+
+ return null;
+ }
+
+ /**
+ * Retrives a path to the office program folder.
+ *
+ * @return The path to the office program folder.
+ */
+ private String getProgramPath()
+ {
+ if (mProgramPath == null)
+ {
+ // determine name of executable soffice
+ String aExec = OFFICE_APP_NAME; // default for UNIX
+ String aOS = System.getProperty("os.name");
+
+ // running on Windows?
+ if (aOS.startsWith("Windows"))
+ aExec = OFFICE_APP_NAME + ".exe";
+
+ // add other non-UNIX operating systems here
+ // ...
+
+ // find soffice executable relative to this class's class loader:
+ File path = NativeLibraryLoader.getResource(
+ this.getClass().getClassLoader(), aExec);
+ if (path != null) {
+ mProgramPath = path.getParent();
+ }
+
+ // default is ""
+ if ( mProgramPath == null )
+ mProgramPath = "";
+ }
+ return mProgramPath;
+ }
+
+ /**
+ * Parses a connection URL.
+ * This method accepts a UNO URL with following format:<br />
+ * <pre>
+ * url := uno:localoffice[,&lt;params&gt;];urp;StarOffice.NamingService
+ * params := &lt;path&gt;[,&lt;pipe&gt;]
+ * path := path=&lt;pathv&gt;
+ * pipe := pipe=&lt;pipev&gt;
+ * pathv := platform_specific_path_to_the_local_office_distribution
+ * pipev := local_office_connection_pipe_name
+ * </pre>
+ *
+ * <h4>Examples</h4>
+ * <ul>
+ * <li>"uno:localoffice,pipe=xyz_Office,path=/opt/openoffice11/program;urp;StarOffice.ServiceManager";
+ * <li>"uno:socket,host=localhost,port=8100;urp;StarOffice.ServiceManager";
+ * </ul>
+ *
+ * @param url This is UNO URL which describes the type of a connection.
+ * @exception java.net.MalformedURLException when inappropreate URL was
+ * provided.
+ */
+ private void parseUnoUrlWithOfficePath(String url, String prefix)
+ throws java.net.MalformedURLException
+ {
+ // Extruct parameters.
+ int idx = url.indexOf(";urp;StarOffice.NamingService");
+ if (idx < 0)
+ throw new java.net.MalformedURLException(
+ "Invalid UNO connection URL.");
+ String params = url.substring(prefix.length(), idx + 1);
+
+ // Parse parameters.
+ String name = null;
+ String path = null;
+ String pipe = null;
+ char ch;
+ int state = 0;
+ StringBuffer buffer = new StringBuffer();
+ for(idx = 0; idx < params.length(); idx += 1) {
+ ch = params.charAt(idx);
+ switch (state) {
+ case 0: // initial state
+ switch(ch) {
+ case ',':
+ buffer.delete(0, buffer.length());
+ state = 1;
+ break;
+
+ case ';':
+ state = 7;
+ break;
+
+ default:
+ buffer.delete(0, buffer.length());
+ buffer.append(ch);
+ state = 1;
+ break;
+ }
+ break;
+
+ case 1: // parameter name
+ switch(ch) {
+ case ' ':
+ case '=':
+ name = buffer.toString();
+ state = (ch == ' ')? 2: 3;
+ break;
+
+ case ',':
+ case ';':
+ state = -6; // error: invalid name
+ break;
+
+ default:
+ buffer.append(ch);
+ break;
+ }
+ break;
+
+ case 2: // equal between the name and the value
+ switch(ch) {
+ case '=':
+ state = 3;
+ break;
+
+ case ' ':
+ break;
+
+ default:
+ state = -1; // error: missing '='
+ break;
+ }
+ break;
+
+ case 3: // value leading spaces
+ switch(ch) {
+ case ' ':
+ break;
+
+ default:
+ buffer.delete(0, buffer.length());
+ buffer.append(ch);
+ state = 4;
+ break;
+ }
+ break;
+
+ case 4: // value
+ switch(ch) {
+ case ' ':
+ case ',':
+ case ';':
+ idx -= 1; // put back the last read character
+ state = 5;
+ if (name.equals("path")) {
+ if (path == null)
+ path = buffer.toString();
+ else
+ state = -3; // error: more then one 'path'
+ } else if (name.equals("pipe")) {
+ if (pipe == null)
+ pipe = buffer.toString();
+ else
+ state = -4; // error: more then one 'pipe'
+ } else
+ state = -2; // error: unknown parameter
+ buffer.delete(0, buffer.length());
+ break;
+
+ default:
+ buffer.append(ch);
+ break;
+ }
+ break;
+
+ case 5: // a delimeter after the value
+ switch(ch) {
+ case ' ':
+ break;
+
+ case ',':
+ state = 6;
+ break;
+
+ case ';':
+ state = 7;
+ break;
+
+ default:
+ state = -5; // error: ' ' inside the value
+ break;
+ }
+ break;
+
+ case 6: // leading spaces before next parameter name
+ switch(ch) {
+ case ' ':
+ break;
+
+ default:
+ buffer.delete(0, buffer.length());
+ buffer.append(ch);
+ state = 1;
+ break;
+ }
+ break;
+
+ default:
+ throw new java.net.MalformedURLException(
+ "Invalid UNO connection URL.");
+ }
+ }
+ if (state != 7)
+ throw new java.net.MalformedURLException(
+ "Invalid UNO connection URL.");
+
+ // Set up the connection parameters.
+ if (path != null)
+ mProgramPath = path;
+ if (pipe != null)
+ mPipe = pipe;
+ }
+
+ /* replaces each substring aSearch in aString by aReplace.
+
+ StringBuffer.replaceAll() is not avaialable in Java 1.3.x.
+ */
+ private static String replaceAll(String aString, String aSearch, String aReplace )
+ {
+ StringBuffer aBuffer = new StringBuffer(aString);
+
+ int nPos = aString.length();
+ int nOfs = aSearch.length();
+
+ while ( ( nPos = aString.lastIndexOf( aSearch, nPos - 1 ) ) > -1 )
+ aBuffer.replace( nPos, nPos+nOfs, aReplace );
+
+ return aBuffer.toString();
+ }
+
+
+ /** creates a unique pipe name.
+ */
+ static String getPipeName()
+ {
+ // turn user name into a URL and file system safe name (% chars will not work)
+ String aPipeName = System.getProperty("user.name") + OFFICE_ID_SUFFIX;
+ aPipeName = replaceAll( aPipeName, "_", "%B7" );
+ return replaceAll( replaceAll( java.net.URLEncoder.encode(aPipeName), "\\+", "%20" ), "%", "_" );
+ }
+
+ /**
+ * @para This is an implementation of the native office service.
+ */
+ private class OfficeService
+ implements NativeService
+ {
+ /**
+ * Retrive the office service identifier.
+ *
+ * @return The identifier of the office service.
+ */
+ public String getIdentifier()
+ {
+ if ( mPipe == null)
+ return getPipeName();
+ else
+ return mPipe;
+ }
+
+ /**
+ * Starts the office process.
+ */
+ public void startupService()
+ throws java.io.IOException
+ {
+ // create call with arguments
+ String[] cmdArray = new String[4];
+ cmdArray[0] = (new File(getProgramPath(), OFFICE_APP_NAME)).getPath();
+ cmdArray[1] = "-nologo";
+ cmdArray[2] = "-nodefault";
+ if ( mConnType.equals( "pipe" ) )
+ cmdArray[3] = "-accept=pipe,name=" + getIdentifier() + ";" +
+ mProtocol + ";" + mInitialObject;
+ else if ( mConnType.equals( "socket" ) )
+ cmdArray[3] = "-accept=socket,port=" + mPort + ";urp";
+ else
+ throw new java.io.IOException( "not connection specified" );
+
+ // start process
+ mProcess = Runtime.getRuntime().exec(cmdArray);
+ if ( mProcess == null )
+ throw new RuntimeException( "cannot start soffice: " + cmdArray );
+ }
+
+ /**
+ * Retrives the ammount of time to wait for the startup.
+ *
+ * @return The ammount of time to wait in seconds(?).
+ */
+ public int getStartupTime()
+ {
+ return 60;
+ }
+ }
}
diff --git a/bean/com/sun/star/beans/LocalOfficeWindow.java b/bean/com/sun/star/beans/LocalOfficeWindow.java
index 832b1e3030f7..60bf52c7e433 100644
--- a/bean/com/sun/star/beans/LocalOfficeWindow.java
+++ b/bean/com/sun/star/beans/LocalOfficeWindow.java
@@ -2,9 +2,9 @@
*
* $RCSfile: LocalOfficeWindow.java,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: mi $ $Date: 2004-10-14 10:34:39 $
+ * last change: $Author: mi $ $Date: 2004-10-18 07:15:35 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -12,11 +12,11 @@
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
- * Sun Microsystems Inc., September, 2004
+ * Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
- * Copyright 2004 by Sun Microsystems, Inc.
+ * Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
@@ -50,7 +50,7 @@
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
- * Copyright: 2004 by Sun Microsystems, Inc.
+ * Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
@@ -61,16 +61,283 @@
package com.sun.star.beans;
-/** This class represents a local office window.
+import java.awt.Component;
+import java.awt.Canvas;
- @deprecated
- use com.sun.star.comp.beans.LocalOfficeWindow instead
+import com.sun.star.lang.EventObject;
+import com.sun.star.lang.SystemDependent;
+import com.sun.star.lang.XComponent;
+import com.sun.star.lang.XEventListener;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XMultiComponentFactory;
+import com.sun.star.awt.Rectangle;
+import com.sun.star.awt.XWindow;
+import com.sun.star.awt.XWindowPeer;
+import com.sun.star.awt.XVclWindowPeer;
+import com.sun.star.awt.XToolkit;
+import com.sun.star.awt.WindowDescriptor;
+import com.sun.star.awt.WindowAttribute;
+import com.sun.star.awt.WindowClass;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.uno.Exception;
+
+/**
+ * This class represents a local office window.
*/
public class LocalOfficeWindow
- extends com.sun.star.comp.beans.LocalOfficeWindow
+ extends java.awt.Canvas
+ implements OfficeWindow, XEventListener
{
+ private transient OfficeConnection mConnection;
+ private transient XWindowPeer mParentProxy;
+ private transient XWindowPeer mWindow;
+ private boolean bPeer = false;
+
+ /**
+ * Construnctor.
+ *
+ * @param connection The office connection object the window
+ * belongs to.
+ */
/* package */ LocalOfficeWindow(OfficeConnection connection)
{
- super( connection );
+ mConnection = connection;
+ mConnection.addEventListener((XEventListener)this);
+ }
+
+ /**
+ * Retrives an AWT component object associated with the OfficeWindow.
+ *
+ * @return The AWT component object associated with the OfficeWindow.
+ */
+ public Component getAWTComponent()
+ {
+ return this;
+ }
+
+ /**
+ * Retrives an UNO XWindowPeer object associated with the OfficeWindow.
+ *
+ * @return The UNO XWindowPeer object associated with the OfficeWindow.
+ */
+ public XWindowPeer getUNOWindowPeer()
+ {
+ if (mWindow == null)
+ createUNOWindowPeer();
+ return mWindow;
+ }
+
+ /**
+ * Receives a notification about the connection has been closed.
+ * This method has to set the connection to <code>null</code>.
+ *
+ * @source The event object.
+ */
+ public void disposing(EventObject source)
+ {
+ // the window will be disposed by the framework
+ mWindow = null;
+ mConnection = null;
}
+
+ /**
+ * Returns an AWT toolkit.
+ */
+ private XToolkit queryAWTToolkit()
+ throws com.sun.star.uno.Exception
+ {
+ // Create a UNO toolkit.
+ XMultiComponentFactory compfactory;
+ XComponentContext xContext = mConnection.getComponentContext();
+ if ( xContext != null )
+ {
+ compfactory = mConnection.getComponentContext().getServiceManager();
+ XMultiServiceFactory factory;
+ factory = (XMultiServiceFactory)UnoRuntime.queryInterface(
+ XMultiServiceFactory.class, compfactory);
+ Object object = factory.createInstance( "com.sun.star.awt.Toolkit");
+ return (XToolkit)UnoRuntime.queryInterface(XToolkit.class, object);
+ }
+ else
+ return null;
+ }
+
+ /// called when system parent is available, reparents the bean window
+ private void aquireSystemWindow()
+ {
+ if ( !bPeer )
+ {
+ // set real parent
+ XVclWindowPeer xVclWindowPeer = (XVclWindowPeer)UnoRuntime.queryInterface(
+ XVclWindowPeer.class, mWindow);
+ xVclWindowPeer.setProperty( "PluginParent", new Long(getNativeWindow()) );
+ bPeer = true;
+
+ // show document window
+ XWindow aWindow = (XWindow)UnoRuntime.queryInterface(XWindow.class, mWindow);
+ aWindow.setVisible( true );
+ }
+ }
+
+ /// called when system parent is about to die, reparents the bean window
+ private void releaseSystemWindow()
+ {
+ if ( bPeer )
+ {
+ // hide document window
+ XWindow aWindow = (XWindow)UnoRuntime.queryInterface(XWindow.class, mWindow);
+ aWindow.setVisible( false );
+
+ // set null parent
+ XVclWindowPeer xVclWindowPeer = (XVclWindowPeer)UnoRuntime.queryInterface(
+ XVclWindowPeer.class, mWindow);
+ xVclWindowPeer.setProperty( "PluginParent", new Long(0) );
+ bPeer = false;
+ }
+ }
+
+ /// callback handler to get to know when we become visible
+ class ComponentEventHandler
+ extends java.awt.event.ComponentAdapter
+ {
+ public void componentHidden( java.awt.event.ComponentEvent e)
+ {
+ // only when we become invisible, we might lose our system window
+ CallWatchThread aCallWatchThread = new CallWatchThread( 500 );
+ setVisible(false);
+ try { aCallWatchThread.cancel(); }
+ catch ( java.lang.InterruptedException aExc )
+ {} // ignore
+ }
+
+ public void componentShown( java.awt.event.ComponentEvent e)
+ {
+ // only when we become visible, we get a system window
+ aquireSystemWindow();
+ }
+ }
+
+ /// Overriding java.awt.Component.setVisible() due to Java bug (no showing event).
+ public void setVisible( boolean b )
+ {
+ super.setVisible(b);
+
+ // Java-Bug: componentShown() is never called :-(
+ // is still at least in Java 1.4.1_02
+ if ( b )
+ aquireSystemWindow();
+ else
+ releaseSystemWindow();
+ }
+
+ /** Factory method for a UNO AWT toolkit window as a child of this Java window.
+ *
+ */
+ private XWindowPeer createUNOWindowPeer()
+ {
+ try
+ {
+ // get this windows native window type
+ int type = getNativeWindowSystemType();
+
+ // Java AWT windows only have a system window when showing.
+ XWindowPeer parentPeer;
+ if ( isShowing() )
+ {
+ // create direct parent relationship
+ //setVisible( true );
+ parentPeer = new JavaWindowPeerFake( getNativeWindow(), type);
+ bPeer = true;
+ }
+ else
+ {
+ // no parent yet
+ parentPeer = null;
+ bPeer = false;
+ }
+
+ // create native window (mWindow)
+ Rectangle aRect = new Rectangle( 0, 0, 20, 20 );
+ WindowDescriptor desc = new WindowDescriptor();
+ desc.Type = WindowClass.TOP;
+ desc.Parent = parentPeer;
+ desc.Bounds = aRect;
+ desc.WindowServiceName = "workwindow";
+ desc.WindowAttributes = (type == SystemDependent.SYSTEM_WIN32)
+ ? WindowAttribute.SHOW : 0;
+ mWindow = queryAWTToolkit().createWindow(desc);
+
+ // to get notified when we become visible
+ addComponentListener( new ComponentEventHandler() );
+
+ // set initial visibility
+ XWindow aWindow = (XWindow)UnoRuntime.queryInterface(XWindow.class, mWindow);
+ aWindow.setVisible( bPeer );
+ }
+ catch (com.sun.star.uno.Exception exp) {
+ }
+
+ return mWindow;
+ }
+
+ /**
+ * Retrives a platform dependant system window identifier.
+ *
+ * @return The system window identifier.
+ */
+ private native long getNativeWindow();
+
+ /**
+ * Retrives a platform dependant system window type.
+ *
+ * @return The system window type.
+ */
+ private native int getNativeWindowSystemType();
+
+ //---------------------------------------------------------------------------
+ /** Helper class to watch calls into OOo with a timeout.
+ */
+ class CallWatchThread extends Thread
+ {
+ Thread aWatchedThread;
+ long nTimeout;
+
+ CallWatchThread( long nTimeout )
+ {
+ this.aWatchedThread = Thread.currentThread();
+ this.nTimeout = nTimeout;
+ start();
+ }
+
+ void cancel()
+ throws java.lang.InterruptedException
+ {
+ Thread aThread = aWatchedThread;
+ aWatchedThread = null;
+ stop();
+
+ if ( aThread.interrupted() )
+ throw new InterruptedException();
+ }
+
+ public void run()
+ {
+ while ( aWatchedThread != null )
+ {
+ try { sleep( nTimeout ); }
+ catch ( java.lang.InterruptedException aExc )
+ {}
+
+ //synchronized
+ {
+ if ( aWatchedThread != null )
+ {
+ aWatchedThread.interrupt();
+ }
+ }
+ }
+ }
+ };
+
}
diff --git a/bean/com/sun/star/beans/NativeConnection.java b/bean/com/sun/star/beans/NativeConnection.java
new file mode 100644
index 000000000000..2d2e97779667
--- /dev/null
+++ b/bean/com/sun/star/beans/NativeConnection.java
@@ -0,0 +1,92 @@
+/*************************************************************************
+ *
+ * $RCSfile: NativeConnection.java,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: mi $ $Date: 2004-10-18 07:14:59 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+package com.sun.star.beans;
+
+import com.sun.star.connection.XConnection;
+
+/* package */ class NativeConnection
+ implements XConnection
+{
+ public native void connect(NativeService aNativeService)
+ throws com.sun.star.io.IOException;
+
+ public native int read(/*OUT*/byte[][] aReadBytes, /*IN*/int nBytesToRead)
+ throws com.sun.star.io.IOException, com.sun.star.uno.RuntimeException;
+
+ public native void write(/*IN*/byte[] aData)
+ throws com.sun.star.io.IOException, com.sun.star.uno.RuntimeException;
+
+ public native void flush()
+ throws com.sun.star.io.IOException, com.sun.star.uno.RuntimeException;
+
+ public native void close()
+ throws com.sun.star.io.IOException, com.sun.star.uno.RuntimeException;
+
+ public synchronized String getDescription()
+ throws com.sun.star.uno.RuntimeException
+ {
+ return Description;
+ }
+
+ private long NativeHandle;
+ private String Description;
+}
diff --git a/bean/com/sun/star/beans/NativeService.java b/bean/com/sun/star/beans/NativeService.java
new file mode 100644
index 000000000000..a86e356007d1
--- /dev/null
+++ b/bean/com/sun/star/beans/NativeService.java
@@ -0,0 +1,69 @@
+/*************************************************************************
+ *
+ * $RCSfile: NativeService.java,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: mi $ $Date: 2004-10-18 07:15:08 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+package com.sun.star.beans;
+
+
+/* package */ interface NativeService {
+ public String getIdentifier();
+ public void startupService() throws java.io.IOException;
+ public int getStartupTime();
+}
diff --git a/bean/com/sun/star/beans/OfficeConnection.java b/bean/com/sun/star/beans/OfficeConnection.java
index 1b3d8a401740..375551fb6fdd 100644
--- a/bean/com/sun/star/beans/OfficeConnection.java
+++ b/bean/com/sun/star/beans/OfficeConnection.java
@@ -2,9 +2,9 @@
*
* $RCSfile: OfficeConnection.java,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: mi $ $Date: 2004-10-14 10:35:07 $
+ * last change: $Author: mi $ $Date: 2004-10-18 07:15:35 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -12,11 +12,11 @@
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
- * Sun Microsystems Inc., September, 2004
+ * Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
- * Copyright 2004 by Sun Microsystems, Inc.
+ * Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
@@ -50,7 +50,7 @@
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
- * Copyright: 2004 by Sun Microsystems, Inc.
+ * Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
@@ -61,13 +61,53 @@
package com.sun.star.beans;
-/** reprecents a connection to the office application.
+import java.awt.Container;
+import java.net.MalformedURLException;
- @deprecated
- use com.sun.star.comp.beans.OfficeConnection instead
+import com.sun.star.lang.XComponent;
+import com.sun.star.uno.XComponentContext;
+
+/**
+ * This abstract class reprecents a connection to the office
+ * application.
*/
public interface OfficeConnection
- extends com.sun.star.comp.beans.OfficeConnection
+ extends XComponent
{
-}
+ /**
+ * Sets a connection URL.
+ *
+ * @param url This is UNO URL which describes the type of a connection.
+ */
+ void setUnoUrl(String url)
+ throws java.net.MalformedURLException;
+
+ /**
+ * Sets an AWT container catory.
+ *
+ * @param containerFactory This is a application provided AWT container
+ * factory.
+ */
+ void setContainerFactory(ContainerFactory containerFactory);
+ /**
+ * Retrives the UNO component context.
+ * Establishes a connection if necessary and initialises the
+ * UNO service manager if it has not already been initialised.
+ *
+ * @return The office UNO component context.
+ */
+ XComponentContext getComponentContext();
+
+ /**
+ * Creates an office window.
+ * The window is either a sub-class of java.awt.Canvas (local) or
+ * java.awt.Container (RVP).
+ *
+ * This method does not add add the office window to its container.
+ *
+ * @param container This is an AWT container.
+ * @return The office window instance.
+ */
+ OfficeWindow createOfficeWindow(Container container);
+}
diff --git a/bean/com/sun/star/beans/OfficeWindow.java b/bean/com/sun/star/beans/OfficeWindow.java
index e2443b2f3943..35d08e7dafd3 100644
--- a/bean/com/sun/star/beans/OfficeWindow.java
+++ b/bean/com/sun/star/beans/OfficeWindow.java
@@ -2,9 +2,9 @@
*
* $RCSfile: OfficeWindow.java,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: mi $ $Date: 2004-10-14 10:35:23 $
+ * last change: $Author: mi $ $Date: 2004-10-18 07:15:35 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -12,11 +12,11 @@
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
- * Sun Microsystems Inc., September, 2004
+ * Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
- * Copyright 2004 by Sun Microsystems, Inc.
+ * Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
@@ -50,7 +50,7 @@
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
- * Copyright: 2004 by Sun Microsystems, Inc.
+ * Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
@@ -61,14 +61,28 @@
package com.sun.star.beans;
-/** The concreate implementation of the OfficeWindow extends an
- approperate type of visual component (java.awt.Canvas for local
- i and java.awt.Container for remote).
+import java.awt.Component;
- @deprecated
- use com.sun.star.comp.beans.OfficeWindow instead
+import com.sun.star.awt.XWindowPeer;
+
+/**
+ * The concreate implementation of the OfficeWindow extends an
+ * approperate type of visual component (java.awt.Canvas for local
+ * and java.awt.Container for remote).
*/
public interface OfficeWindow
- extends com.sun.star.comp.beans.OfficeWindow
{
+ /**
+ * Retrives an AWT component object associated with the OfficeWindow.
+ *
+ * @return The AWT component object associated with the OfficeWindow.
+ */
+ Component getAWTComponent();
+
+ /**
+ * Retrives an UNO XWindowPeer object associated with the OfficeWindow.
+ *
+ * @return The UNO XWindowPeer object associated with the OfficeWindow.
+ */
+ XWindowPeer getUNOWindowPeer();
}
diff --git a/bean/com/sun/star/beans/makefile.mk b/bean/com/sun/star/beans/makefile.mk
index 90824845d49a..30f1ea6a7742 100644
--- a/bean/com/sun/star/beans/makefile.mk
+++ b/bean/com/sun/star/beans/makefile.mk
@@ -2,9 +2,9 @@
#
# $RCSfile: makefile.mk,v $
#
-# $Revision: 1.1 $
+# $Revision: 1.2 $
#
-# last change: $Author: mi $ $Date: 2004-10-14 10:34:53 $
+# last change: $Author: mi $ $Date: 2004-10-18 07:15:35 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
@@ -80,10 +80,14 @@ JARFILES = sandbox.jar ridl.jar unoil.jar jurt.jar juh.jar
# --- Sources --------------------------------------------------------
JAVAFILES= \
- OfficeConnection.java \
- OfficeWindow.java \
+ ContainerFactory.java \
+ JavaWindowPeerFake.java \
LocalOfficeConnection.java \
- LocalOfficeWindow.java
+ LocalOfficeWindow.java \
+ NativeConnection.java \
+ NativeService.java \
+ OfficeConnection.java \
+ OfficeWindow.java
JAVACLASSFILES= $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
diff --git a/bean/com/sun/star/comp/beans/LocalOfficeConnection.java b/bean/com/sun/star/comp/beans/LocalOfficeConnection.java
index 926caf34069f..e7d2934847ae 100644
--- a/bean/com/sun/star/comp/beans/LocalOfficeConnection.java
+++ b/bean/com/sun/star/comp/beans/LocalOfficeConnection.java
@@ -2,9 +2,9 @@
*
* $RCSfile: LocalOfficeConnection.java,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: mi $ $Date: 2004-10-14 10:37:12 $
+ * last change: $Author: mi $ $Date: 2004-10-18 07:15:36 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -148,7 +148,6 @@ public class LocalOfficeConnection
// load libofficebean.so/officebean.dll
String aSharedLibName = getProgramPath() + java.io.File.separator +
System.mapLibraryName(OFFICE_LIB_NAME);
-dbgPrint( "System.load( libofficebean.so )" );
System.load( aSharedLibName );
}
@@ -280,16 +279,13 @@ dbgPrint( "System.load( libofficebean.so )" );
try
{
// create default local component context
-dbgPrint( "create initial component context" );
XComponentContext xLocalContext =
com.sun.star.comp.helper.Bootstrap.createInitialComponentContext(null);
// initial serviceManager
-dbgPrint( "get local service manager" );
XMultiComponentFactory xLocalServiceManager = xLocalContext.getServiceManager();
// create a urlresolver
-dbgPrint( "get local service manager" );
Object urlResolver = xLocalServiceManager.createInstanceWithContext(
"com.sun.star.bridge.UnoUrlResolver", xLocalContext );
@@ -301,9 +297,7 @@ dbgPrint( "get local service manager" );
Object aInitialObject = null;
try
{
-dbgPrint( "xUrlResolver.resolve( " + mURL + " )" );
aInitialObject = xUrlResolver.resolve( mURL );
-dbgPrint( "xUrlResolver.resolve() - done" );
}
catch( com.sun.star.connection.NoConnectException e )
{
@@ -664,7 +658,6 @@ dbgPrint( "xUrlResolver.resolve() - done" );
throw new java.io.IOException( "not connection specified" );
// start process
-dbgPrint( "exec" + cmdArray[0] + " " + cmdArray[1] + " " + cmdArray[2] + " " + cmdArray[3] );
mProcess = Runtime.getRuntime().exec(cmdArray);
if ( mProcess == null )
throw new RuntimeException( "cannot start soffice: " + cmdArray );
diff --git a/bean/native/unix/com_sun_star_beans_LocalOfficeWindow.c b/bean/native/unix/com_sun_star_beans_LocalOfficeWindow.c
new file mode 100644
index 000000000000..b55c9c1f557b
--- /dev/null
+++ b/bean/native/unix/com_sun_star_beans_LocalOfficeWindow.c
@@ -0,0 +1,123 @@
+/*************************************************************************
+ *
+ * $RCSfile: com_sun_star_beans_LocalOfficeWindow.c,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: mi $ $Date: 2004-10-18 07:16:18 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/Intrinsic.h>
+
+#include "jawt.h"
+#include "jawt_md.h"
+
+//#include "../inc/com_sun_star_comp_beans_LocalOfficeWindow.h"
+
+#if defined assert
+#undef assert
+#endif
+
+#define assert(X) if (!X) { (*env)->ThrowNew(env, (*env)->FindClass(env, "java/lang/RuntimeException"), "assertion failed"); return;}
+
+
+#define SYSTEM_WIN32 1
+#define SYSTEM_WIN16 2
+#define SYSTEM_JAVA 3
+#define SYSTEM_OS2 4
+#define SYSTEM_MAC 5
+#define SYSTEM_XWINDOW 6
+
+/*****************************************************************************/
+/*
+ * Class: com_sun_star_comp_beans_LocalOfficeWindow
+ * Method: getNativeWindowSystemType
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_sun_star_beans_LocalOfficeWindow_getNativeWindowSystemType
+ (JNIEnv * env, jobject obj_this)
+{
+ return (SYSTEM_XWINDOW);
+}
+
+
+/*****************************************************************************/
+/*
+ * Class: com_sun_star_beans_LocalOfficeWindow
+ * Method: getNativeWindow
+ * Signature: ()J
+ */
+JNIEXPORT jlong JNICALL Java_com_sun_star_beans_LocalOfficeWindow_getNativeWindow
+ (JNIEnv * env, jobject obj_this)
+{
+ return Java_com_sun_star_comp_beans_LocalOfficeWindow_getNativeWindow(env, obj_this);
+}
+
+
+
+
+
+
+
+
+
+
+
diff --git a/bean/native/unix/makefile.mk b/bean/native/unix/makefile.mk
index 08c39e3783cf..464eb4293c5c 100644
--- a/bean/native/unix/makefile.mk
+++ b/bean/native/unix/makefile.mk
@@ -22,7 +22,8 @@ dummy:
.ENDIF
SLOFILES = \
- $(SLO)$/com_sun_star_comp_beans_LocalOfficeWindow.obj
+ $(SLO)$/com_sun_star_comp_beans_LocalOfficeWindow.obj \
+ $(SLO)$/com_sun_star_beans_LocalOfficeWindow.obj
SHL1TARGET=$(TARGET)
SHL1LIBS= $(SLB)$/$(TARGET).lib
diff --git a/bean/native/win32/com_sun_star_beans_LocalOfficeWindow.c b/bean/native/win32/com_sun_star_beans_LocalOfficeWindow.c
new file mode 100644
index 000000000000..f36bbb7a1147
--- /dev/null
+++ b/bean/native/win32/com_sun_star_beans_LocalOfficeWindow.c
@@ -0,0 +1,122 @@
+/*************************************************************************
+ *
+ * $RCSfile: com_sun_star_beans_LocalOfficeWindow.c,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: mi $ $Date: 2004-10-18 07:16:33 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <windows.h>
+
+#include "jawt.h"
+#include "jawt_md.h"
+
+#if defined assert
+#undef assert
+#endif
+
+#define assert(X) if (!X) { (*env)->ThrowNew(env, (*env)->FindClass(env, "java/lang/RuntimeException"), "assertion failed"); return 0L;}
+
+
+#define SYSTEM_WIN32 1
+#define SYSTEM_WIN16 2
+#define SYSTEM_JAVA 3
+#define SYSTEM_OS2 4
+#define SYSTEM_MAC 5
+#define SYSTEM_XWINDOW 6
+
+#define OLD_PROC_KEY "oldwindowproc"
+
+static LRESULT APIENTRY OpenOfficeWndProc( HWND , UINT , WPARAM , LPARAM );
+
+/*****************************************************************************/
+/*
+ * Class: com_sun_star_beans_LocalOfficeWindow
+ * Method: getNativeWindowSystemType
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_sun_star_beans_LocalOfficeWindow_getNativeWindowSystemType
+ (JNIEnv * env, jobject obj_this)
+{
+ return (SYSTEM_WIN32);
+}
+
+
+/*****************************************************************************/
+/*
+ * Class: com_sun_star_beans_LocalOfficeWindow
+ * Method: getNativeWindow
+ * Signature: ()J
+ */
+JNIEXPORT jlong JNICALL Java_com_sun_star_beans_LocalOfficeWindow_getNativeWindow
+ (JNIEnv * env, jobject obj_this)
+{
+ return Java_com_sun_star_comp_beans_LocalOfficeWindow_getNativeWindow( env, obj_this );
+}
+
+
+
+
+
+
+
+
+
+
diff --git a/bean/native/win32/makefile.mk b/bean/native/win32/makefile.mk
index d1209bff16e5..058d2c7fc1f2 100644
--- a/bean/native/win32/makefile.mk
+++ b/bean/native/win32/makefile.mk
@@ -14,7 +14,8 @@ USE_DEFFILE=TRUE
# --- Files --------------------------------------------------------
SLOFILES = \
- $(SLO)$/com_sun_star_comp_beans_LocalOfficeWindow.obj
+ $(SLO)$/com_sun_star_comp_beans_LocalOfficeWindow.obj \
+ $(SLO)$/com_sun_star_beans_LocalOfficeWindow.obj
SHL1TARGET=$(TARGET)
SHL1LIBS= $(SLB)$/$(TARGET).lib
diff --git a/bean/util/makefile.mk b/bean/util/makefile.mk
new file mode 100644
index 000000000000..6586047ca6d7
--- /dev/null
+++ b/bean/util/makefile.mk
@@ -0,0 +1,92 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1 $
+#
+# last change: $Author: mi $ $Date: 2004-10-18 07:17:06 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., September, 2004
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2004 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2004 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ = ..
+PRJNAME = bean
+TARGET = officebean
+
+# --- Settings -----------------------------------------------------
+USE_EXTENDED_MANIFESTFILE=TRUE
+USE_UDK_EXTENDED_MANIFESTFILE=TRUE
+
+.INCLUDE : settings.mk
+
+JARCLASSDIRS = \
+ com$/sun$/star$/comp$/beans \
+ com$/sun$/star$/beans
+
+JARTARGET = $(TARGET).jar
+JARCOMPRESS = TRUE
+
+# Special work necessary for building java reference with javadoc.
+# The source of puplic APIs must be delivered and used later in the
+# odk module.
+ZIP1TARGET=$(TARGET)_src
+ZIP1FLAGS=-u -r
+ZIP1DIR=$(PRJ)
+ZIP1LIST=com -x "*makefile.mk"
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
+