summaryrefslogtreecommitdiff
path: root/bean
diff options
context:
space:
mode:
Diffstat (limited to 'bean')
-rw-r--r--bean/com/sun/star/beans/ContainerFactory.java47
-rw-r--r--bean/com/sun/star/beans/JavaWindowPeerFake.java122
-rw-r--r--bean/com/sun/star/beans/LocalOfficeConnection.java617
-rw-r--r--bean/com/sun/star/beans/LocalOfficeWindow.java309
-rw-r--r--bean/com/sun/star/beans/NativeConnection.java59
-rw-r--r--bean/com/sun/star/beans/NativeService.java36
-rw-r--r--bean/com/sun/star/beans/OfficeConnection.java79
-rw-r--r--bean/com/sun/star/beans/OfficeWindow.java55
-rw-r--r--bean/com/sun/star/beans/makefile.mk64
-rw-r--r--bean/com/sun/star/comp/beans/CallWatchThread.java128
-rw-r--r--bean/com/sun/star/comp/beans/ContainerFactory.java47
-rw-r--r--bean/com/sun/star/comp/beans/Controller.java110
-rw-r--r--bean/com/sun/star/comp/beans/Frame.java182
-rw-r--r--bean/com/sun/star/comp/beans/HasConnectionException.java40
-rw-r--r--bean/com/sun/star/comp/beans/InvalidArgumentException.java38
-rw-r--r--bean/com/sun/star/comp/beans/JavaWindowPeerFake.java122
-rw-r--r--bean/com/sun/star/comp/beans/LocalOfficeConnection.java823
-rw-r--r--bean/com/sun/star/comp/beans/LocalOfficeWindow.java288
-rw-r--r--bean/com/sun/star/comp/beans/NativeConnection.java62
-rw-r--r--bean/com/sun/star/comp/beans/NativeService.java37
-rw-r--r--bean/com/sun/star/comp/beans/NoConnectionException.java40
-rw-r--r--bean/com/sun/star/comp/beans/NoDocumentException.java38
-rw-r--r--bean/com/sun/star/comp/beans/OOoBean.java1511
-rw-r--r--bean/com/sun/star/comp/beans/OfficeConnection.java80
-rw-r--r--bean/com/sun/star/comp/beans/OfficeDocument.java226
-rw-r--r--bean/com/sun/star/comp/beans/OfficeWindow.java56
-rw-r--r--bean/com/sun/star/comp/beans/SystemWindowException.java41
-rw-r--r--bean/com/sun/star/comp/beans/Wrapper.java108
-rw-r--r--bean/com/sun/star/comp/beans/makefile.mk75
-rw-r--r--bean/native/unix/com_sun_star_beans_LocalOfficeWindow.c99
-rw-r--r--bean/native/unix/com_sun_star_comp_beans_LocalOfficeWindow.c147
-rw-r--r--bean/native/unix/makefile.mk39
-rw-r--r--bean/native/win32/com_sun_star_beans_LocalOfficeWindow.c102
-rw-r--r--bean/native/win32/com_sun_star_comp_beans_LocalOfficeWindow.c217
-rw-r--r--bean/native/win32/makefile.mk34
-rw-r--r--bean/native/win32/officebean.dxp4
-rw-r--r--bean/prj/build.lst6
-rw-r--r--bean/prj/d.lst5
-rw-r--r--bean/qa/complex/OOoBeanTest.java656
-rw-r--r--bean/qa/complex/ScreenComparer.java233
-rw-r--r--bean/qa/complex/WriterFrame.java209
-rw-r--r--bean/qa/complex/makefile.mk95
-rw-r--r--bean/test/Test.java68
-rw-r--r--bean/test/applet/oooapplet/OOoViewer.java208
-rw-r--r--bean/test/applet/oooapplet/bean.policy16
-rw-r--r--bean/test/applet/oooapplet/example.html22
-rw-r--r--bean/test/applet/oooapplet/makefile.mk88
-rw-r--r--bean/test/makefile.mk95
-rw-r--r--bean/util/delzip0
-rw-r--r--bean/util/makefile.mk56
50 files changed, 7839 insertions, 0 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..493ea1cbc338
--- /dev/null
+++ b/bean/com/sun/star/beans/ContainerFactory.java
@@ -0,0 +1,47 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.beans;
+
+import java.awt.Container;
+
+/**
+ * This interface reprecents an AWT container factory.
+ *
+ * @see OfficeBean
+ * @deprecated
+ */
+
+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..c89978c894c5
--- /dev/null
+++ b/bean/com/sun/star/beans/JavaWindowPeerFake.java
@@ -0,0 +1,122 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.beans;
+
+import com.sun.star.awt.*;
+
+/** <p>Class to pass the system window handle to the OpenOffice.org toolkit.</p>
+ * @deprecated
+ */
+/* 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
new file mode 100644
index 000000000000..11283066cc34
--- /dev/null
+++ b/bean/com/sun/star/beans/LocalOfficeConnection.java
@@ -0,0 +1,617 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.beans;
+
+import java.awt.Container;
+import java.io.File;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Vector;
+
+import com.sun.star.lang.XMultiComponentFactory;
+import com.sun.star.lang.XEventListener;
+import com.sun.star.bridge.XUnoUrlResolver;
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.uno.UnoRuntime;
+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.
+ * @deprecated
+ */
+public class 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.
+ * @deprecated
+ */
+ 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
new file mode 100644
index 000000000000..7d4470415856
--- /dev/null
+++ b/bean/com/sun/star/beans/LocalOfficeWindow.java
@@ -0,0 +1,309 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.beans;
+
+import java.awt.Component;
+
+import com.sun.star.lang.EventObject;
+import com.sun.star.lang.SystemDependent;
+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;
+
+/**
+ * This class represents a local office window.
+ * @deprecated
+ */
+public class 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)
+ {
+ 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
+ //@deprecated
+ 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.
+ * @deprecated
+ */
+ 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..7cf2bcb581a5
--- /dev/null
+++ b/bean/com/sun/star/beans/NativeConnection.java
@@ -0,0 +1,59 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.beans;
+
+import com.sun.star.connection.XConnection;
+/* @deprecated
+ */
+/* 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..ad7f73c29a0f
--- /dev/null
+++ b/bean/com/sun/star/beans/NativeService.java
@@ -0,0 +1,36 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.beans;
+
+/* @deprecated
+ */
+/* 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
new file mode 100644
index 000000000000..6d25015e87f1
--- /dev/null
+++ b/bean/com/sun/star/beans/OfficeConnection.java
@@ -0,0 +1,79 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.beans;
+
+import java.awt.Container;
+
+import com.sun.star.lang.XComponent;
+import com.sun.star.uno.XComponentContext;
+
+/**
+ * This abstract class reprecents a connection to the office
+ * application.
+ * @deprecated
+ */
+public interface 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
new file mode 100644
index 000000000000..0e7232bab617
--- /dev/null
+++ b/bean/com/sun/star/beans/OfficeWindow.java
@@ -0,0 +1,55 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.beans;
+
+import java.awt.Component;
+
+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).
+ * @deprecated
+ */
+public interface 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
new file mode 100644
index 000000000000..9fd82df5117d
--- /dev/null
+++ b/bean/com/sun/star/beans/makefile.mk
@@ -0,0 +1,64 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org 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 version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ = ..$/..$/..$/..
+PRJNAME = beans
+TARGET = com_sun_star_beans
+PACKAGE = com$/sun$/star$/beans
+
+# --- Settings -----------------------------------------------------
+.INCLUDE: settings.mk
+.IF "$(L10N_framework)"==""
+.IF "$(OS)"=="MACOSX"
+
+dummy:
+ @echo "Nothing to build for OS $(OS)"
+
+.ELSE # "$(OS)"=="MACOSX"
+
+JARFILES = ridl.jar unoil.jar jurt.jar juh.jar
+
+# --- Sources --------------------------------------------------------
+
+JAVAFILES= \
+ ContainerFactory.java \
+ JavaWindowPeerFake.java \
+ LocalOfficeConnection.java \
+ LocalOfficeWindow.java \
+ NativeConnection.java \
+ NativeService.java \
+ OfficeConnection.java \
+ OfficeWindow.java
+
+JAVACLASSFILES= $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
+
+.ENDIF
+
+# --- Targets ------------------------------------------------------
+.ENDIF # L10N_framework
+
+.INCLUDE : target.mk
diff --git a/bean/com/sun/star/comp/beans/CallWatchThread.java b/bean/com/sun/star/comp/beans/CallWatchThread.java
new file mode 100644
index 000000000000..1ab89337c74e
--- /dev/null
+++ b/bean/com/sun/star/comp/beans/CallWatchThread.java
@@ -0,0 +1,128 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.comp.beans;
+
+
+//---------------------------------------------------------------------------
+/** Helper class to watch calls into OOo with a timeout.
+ */
+//Do not add the thread instances to a threadgroup. When testing the bean in
+//an applet it turned out the the ThreadGroup was in an inconsistent state
+//after navigating off the site that contains the applet and back to it.
+//That was tested with a Sun JRE 1.4.2_06
+public class CallWatchThread extends Thread
+{
+ private static boolean DEBUG = false;
+
+ private Thread aWatchedThread;
+ private String aTag;
+ private boolean bAlive;
+ private long nTimeout;
+
+ public CallWatchThread(long nTimeout)
+ {
+ this(nTimeout, "");
+ }
+
+ public CallWatchThread( long nTimeout, String aTag )
+ {
+ super(aTag);
+ this.aWatchedThread = Thread.currentThread();
+ this.nTimeout = nTimeout;
+
+ this.aTag = aTag;
+ setDaemon( true );
+ dbgPrint( "CallWatchThread(" + this + ").start(" + aTag + ")" );
+ start();
+ }
+
+ public void cancel()
+ throws java.lang.InterruptedException
+ {
+ dbgPrint( "CallWatchThread(" + this + ".cancel(" + aTag + ")" );
+ if ( aWatchedThread != null && aWatchedThread != Thread.currentThread() )
+ throw new RuntimeException( "wrong thread" );
+ aWatchedThread = null;
+ if ( interrupted() )
+ throw new InterruptedException();
+ }
+
+ public synchronized void restart()
+ throws java.lang.InterruptedException
+ {
+ dbgPrint( "CallWatchThread(" + this + ".restart(" + aTag + ")" );
+ if ( aWatchedThread != null && aWatchedThread != Thread.currentThread() )
+ throw new RuntimeException( "wrong thread" );
+ bAlive = true;
+ if ( interrupted() )
+ throw new InterruptedException();
+ notify();
+ }
+
+ public void run()
+ {
+ dbgPrint( "CallWatchThread(" + this + ".run(" + aTag + ") ***** STARTED *****" );
+ long n = 0;
+ while ( aWatchedThread != null )
+ {
+ dbgPrint( "CallWatchThread(" + this + ").run(" + aTag + ") running #" + ++n );
+ synchronized(this)
+ {
+ bAlive = false;
+ try
+ {
+ wait( nTimeout );
+ }
+ catch ( java.lang.InterruptedException aExc )
+ {
+ bAlive = false;
+ }
+
+ // watched thread seems to be dead (not answering)?
+ if ( !bAlive && aWatchedThread != null )
+ {
+ dbgPrint( "CallWatchThread(" + this + ").run(" + aTag + ") interrupting" );
+ aWatchedThread.interrupt();
+ aWatchedThread = null;
+ }
+ }
+ }
+
+ dbgPrint( "CallWatchThread(" + this + ").run(" + aTag + ") terminated" );
+ }
+
+ private void dbgPrint( String aMessage )
+ {
+ if (DEBUG)
+ System.err.println( "OOoBean: " + aMessage );
+ }
+}
+
+
+
+
diff --git a/bean/com/sun/star/comp/beans/ContainerFactory.java b/bean/com/sun/star/comp/beans/ContainerFactory.java
new file mode 100644
index 000000000000..c7f084df5d8c
--- /dev/null
+++ b/bean/com/sun/star/comp/beans/ContainerFactory.java
@@ -0,0 +1,47 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.comp.beans;
+
+import java.awt.Container;
+
+/**
+ * This interface reprecents an AWT container factory.
+ *
+ * @deprecated
+ *
+ */
+
+public interface ContainerFactory
+{
+ /**
+ * Creates an AWT container.
+ *
+ * @return An AWT container.
+ */
+ Container createContainer();
+}
diff --git a/bean/com/sun/star/comp/beans/Controller.java b/bean/com/sun/star/comp/beans/Controller.java
new file mode 100644
index 000000000000..db99de7a5d5f
--- /dev/null
+++ b/bean/com/sun/star/comp/beans/Controller.java
@@ -0,0 +1,110 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.comp.beans;
+
+import com.sun.star.uno.UnoRuntime;
+
+/** Wrapper class for a com.sun.star.frame.XController.
+ *
+ * @since OOo 2.0.0
+ */
+public class Controller
+ extends Wrapper
+ implements
+ com.sun.star.frame.XController
+{
+ private com.sun.star.frame.XController xController;
+ private com.sun.star.frame.XDispatchProvider xDispatchProvider;
+
+ Controller( com.sun.star.frame.XController xController )
+ {
+ super( xController );
+ this.xController = xController;
+ xDispatchProvider = (com.sun.star.frame.XDispatchProvider)
+ UnoRuntime.queryInterface( com.sun.star.frame.XDispatchProvider.class,
+ xController );
+ }
+
+ //==============================================================
+ // com.sun.star.frame.XController
+ //--------------------------------------------------------------
+
+ public void attachFrame( /*IN*/ com.sun.star.frame.XFrame xFrame )
+ {
+ xController.attachFrame( xFrame );
+ }
+
+ public boolean attachModel( /*IN*/ com.sun.star.frame.XModel xModel )
+ {
+ return xController.attachModel( xModel );
+ }
+
+ public boolean suspend( /*IN*/boolean bSuspend )
+ {
+ return xController.suspend( bSuspend );
+ }
+
+ public java.lang.Object getViewData( )
+ {
+ return xController.getViewData();
+ }
+
+ public void restoreViewData( /*IN*/java.lang.Object aData )
+ {
+ xController.restoreViewData( aData );
+ }
+
+ public com.sun.star.frame.XModel getModel( )
+ {
+ return xController.getModel();
+ }
+
+ public com.sun.star.frame.XFrame getFrame( )
+ {
+ return xController.getFrame();
+ }
+
+ //==============================================================
+ // com.sun.star.frame.XDispatchProvider
+ //--------------------------------------------------------------
+
+ public com.sun.star.frame.XDispatch queryDispatch(
+ /*IN*/ com.sun.star.util.URL aURL,
+ /*IN*/ String aTargetFrameName,
+ /*IN*/ int nSearchFlags )
+ {
+ return xDispatchProvider.queryDispatch( aURL, aTargetFrameName, nSearchFlags );
+ }
+
+ public com.sun.star.frame.XDispatch[] queryDispatches(
+ /*IN*/ com.sun.star.frame.DispatchDescriptor[] aRequests )
+ {
+ return xDispatchProvider.queryDispatches( aRequests );
+ }
+}
+
diff --git a/bean/com/sun/star/comp/beans/Frame.java b/bean/com/sun/star/comp/beans/Frame.java
new file mode 100644
index 000000000000..59382eeaebb9
--- /dev/null
+++ b/bean/com/sun/star/comp/beans/Frame.java
@@ -0,0 +1,182 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.comp.beans;
+
+import com.sun.star.uno.UnoRuntime;
+
+/** Wrapper class for a com.sun.star.frame.XFrame.
+ *
+ * @since OOo 2.0.0
+ */
+public class Frame
+ extends Wrapper
+ implements
+ com.sun.star.frame.XFrame,
+ com.sun.star.frame.XDispatchProvider,
+ com.sun.star.frame.XDispatchProviderInterception
+{
+ private com.sun.star.frame.XFrame xFrame;
+ private com.sun.star.frame.XDispatchProvider xDispatchProvider;
+ private com.sun.star.frame.XDispatchProviderInterception xDispatchProviderInterception;
+
+ public Frame( com.sun.star.frame.XFrame xFrame )
+ {
+ super( xFrame );
+ this.xFrame = xFrame;
+ xDispatchProvider = (com.sun.star.frame.XDispatchProvider)
+ UnoRuntime.queryInterface( com.sun.star.frame.XDispatchProvider.class,
+ xFrame );
+ xDispatchProviderInterception = (com.sun.star.frame.XDispatchProviderInterception)
+ UnoRuntime.queryInterface( com.sun.star.frame.XDispatchProviderInterception.class,
+ xFrame );
+ }
+
+ //==============================================================
+ // com.sun.star.frame.XFrame
+ //--------------------------------------------------------------
+
+ public void initialize( /*IN*/com.sun.star.awt.XWindow xWindow )
+ {
+ xFrame.initialize( xWindow );
+ }
+
+ public com.sun.star.awt.XWindow getContainerWindow( )
+ {
+ return xFrame.getContainerWindow();
+ }
+
+ public void setCreator( /*IN*/ com.sun.star.frame.XFramesSupplier xCreator )
+ {
+ xFrame.setCreator( xCreator );
+ }
+
+ public com.sun.star.frame.XFramesSupplier getCreator( )
+ {
+ return xFrame.getCreator();
+ }
+
+ public String getName( )
+ {
+ return xFrame.getName();
+ }
+
+ public void setName( /*IN*/ String aName )
+ {
+ xFrame.setName( aName );
+ }
+
+ public com.sun.star.frame.XFrame findFrame( /*IN*/String aTargetFrameName, /*IN*/int nSearchFlags )
+ {
+ return xFrame.findFrame( aTargetFrameName, nSearchFlags );
+ }
+
+ public boolean isTop( )
+ {
+ return xFrame.isTop();
+ }
+
+ public void activate( )
+ {
+ xFrame.activate();
+ }
+
+ public void deactivate( )
+ {
+ xFrame.deactivate();
+ }
+
+ public boolean isActive( )
+ {
+ return xFrame.isActive();
+ }
+
+ public boolean setComponent( /*IN*/com.sun.star.awt.XWindow xComponentWindow, /*IN*/ com.sun.star.frame.XController xController )
+ {
+ return xFrame.setComponent( xComponentWindow, xController );
+ }
+
+ public com.sun.star.awt.XWindow getComponentWindow( )
+ {
+ return xFrame.getComponentWindow();
+ }
+
+ public com.sun.star.frame.XController getController( )
+ {
+ return xFrame.getController();
+ }
+
+ public void contextChanged( )
+ {
+ xFrame.contextChanged();
+ }
+
+ public void addFrameActionListener( /*IN*/ com.sun.star.frame.XFrameActionListener xListener )
+ {
+ xFrame.addFrameActionListener( xListener );
+ }
+
+ public void removeFrameActionListener( /*IN*/ com.sun.star.frame.XFrameActionListener xListener )
+ {
+ xFrame.removeFrameActionListener( xListener );
+ }
+
+ //==============================================================
+ // com.sun.star.frame.XDispatchProvider
+ //--------------------------------------------------------------
+
+ public com.sun.star.frame.XDispatch queryDispatch(
+ /*IN*/ com.sun.star.util.URL aURL,
+ /*IN*/ String aTargetFrameName,
+ /*IN*/ int nSearchFlags )
+ {
+ return xDispatchProvider.queryDispatch( aURL, aTargetFrameName, nSearchFlags );
+ }
+
+ public com.sun.star.frame.XDispatch[] queryDispatches(
+ /*IN*/ com.sun.star.frame.DispatchDescriptor[] aRequests )
+ {
+ return xDispatchProvider.queryDispatches( aRequests );
+ }
+
+ //==============================================================
+ // com.sun.star.frame.XDispatchProviderInterception
+ //--------------------------------------------------------------
+
+ public void registerDispatchProviderInterceptor(
+ /*IN*/ com.sun.star.frame.XDispatchProviderInterceptor xInterceptor )
+ {
+ xDispatchProviderInterception.registerDispatchProviderInterceptor( xInterceptor );
+ }
+
+ public void releaseDispatchProviderInterceptor(
+ /*IN*/ com.sun.star.frame.XDispatchProviderInterceptor xInterceptor )
+ {
+ xDispatchProviderInterception.releaseDispatchProviderInterceptor( xInterceptor );
+ }
+};
+
diff --git a/bean/com/sun/star/comp/beans/HasConnectionException.java b/bean/com/sun/star/comp/beans/HasConnectionException.java
new file mode 100644
index 000000000000..fcebebf9334f
--- /dev/null
+++ b/bean/com/sun/star/comp/beans/HasConnectionException.java
@@ -0,0 +1,40 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.comp.beans;
+
+/** This expception is thrown when a method is called which
+ is only defined for not already having an established
+ connection.
+
+ @since OOo 2.0.0
+ */
+public class HasConnectionException extends Exception
+{
+};
+
+
diff --git a/bean/com/sun/star/comp/beans/InvalidArgumentException.java b/bean/com/sun/star/comp/beans/InvalidArgumentException.java
new file mode 100644
index 000000000000..b9e0690a86f4
--- /dev/null
+++ b/bean/com/sun/star/comp/beans/InvalidArgumentException.java
@@ -0,0 +1,38 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.comp.beans;
+
+/** indicates an invalid argument in a function call.
+ *
+ * @deprecated
+ */
+public class InvalidArgumentException extends Exception
+{
+};
+
+
diff --git a/bean/com/sun/star/comp/beans/JavaWindowPeerFake.java b/bean/com/sun/star/comp/beans/JavaWindowPeerFake.java
new file mode 100644
index 000000000000..75069385dd32
--- /dev/null
+++ b/bean/com/sun/star/comp/beans/JavaWindowPeerFake.java
@@ -0,0 +1,122 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.comp.beans;
+
+import com.sun.star.uno.*;
+import com.sun.star.awt.*;
+
+/** <p>Class to pass the system window handle to the OpenOffice.org toolkit.</p>
+ *
+ * @since OOo 2.0.0
+ */
+/* package */ class JavaWindowPeerFake
+ implements XSystemDependentWindowPeer, XWindowPeer
+{
+ protected int localSystemType;
+ protected Any wrappedHandle;
+
+ /** Create the faked window peer.
+ * @param _hWindow the system handle to the window.
+ * @param _systemType specifies the system type.
+ */
+ public JavaWindowPeerFake(Any _hWindow, int _systemType)
+ {
+ localSystemType = _systemType;
+ wrappedHandle = _hWindow;
+ }
+
+ /** <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 wrappedHandle;
+ }
+ 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/comp/beans/LocalOfficeConnection.java b/bean/com/sun/star/comp/beans/LocalOfficeConnection.java
new file mode 100644
index 000000000000..8467f1b75812
--- /dev/null
+++ b/bean/com/sun/star/comp/beans/LocalOfficeConnection.java
@@ -0,0 +1,823 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.comp.beans;
+
+import java.awt.Container;
+import java.io.File;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Vector;
+
+import com.sun.star.lang.XMultiComponentFactory;
+import com.sun.star.lang.XComponent;
+import com.sun.star.lang.XEventListener;
+import com.sun.star.connection.XConnection;
+import com.sun.star.connection.XConnector;
+import com.sun.star.bridge.XBridge;
+import com.sun.star.bridge.XBridgeFactory;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.uno.XComponentContext;
+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.
+ *
+ * @since OOo 2.0.0
+ */
+public class 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 static String mProgramPath;
+
+ private Process mProcess;
+ private ContainerFactory mContainerFactory;
+ private XComponentContext mContext;
+ private XBridge mBridge;
+
+ private String mURL;
+ private String mConnType;
+ private String mPipe;
+ private String mPort;
+ private String mProtocol;
+ private String mInitialObject;
+
+ private List mComponents = new Vector();
+
+ private static long m_nBridgeCounter = 0;
+ //-------------------------------------------------------------------------
+ static
+ {
+ // preload shared libraries whichs import lips are linked to officebean
+ if ( System.getProperty( "os.name" ).startsWith( "Windows" ) )
+ {
+ try
+ {
+ NativeLibraryLoader.loadLibrary(LocalOfficeConnection.class.getClassLoader(), "msvcr70");
+ }
+ catch (Throwable e)
+ {
+ // loading twice would fail
+ System.err.println( "cannot find msvcr70" );
+ }
+
+ try
+ {
+ NativeLibraryLoader.loadLibrary(LocalOfficeConnection.class.getClassLoader(), "msvcr71");
+ }
+ catch (Throwable e)
+ {
+ // loading twice would fail
+ System.err.println( "cannot find msvcr71" );
+ }
+
+ try
+ {
+ NativeLibraryLoader.loadLibrary(LocalOfficeConnection.class.getClassLoader(), "uwinapi");
+ }
+ catch (Throwable e)
+ {
+ // loading twice would fail
+ System.err.println( "cannot find uwinapi" );
+ }
+
+ try
+ {
+ NativeLibraryLoader.loadLibrary(LocalOfficeConnection.class.getClassLoader(), "jawt");
+ }
+ catch (Throwable e)
+ {
+ // loading twice would fail
+ System.err.println( "cannot find jawt" );
+ }
+ }
+
+ // load shared library for JNI code
+ NativeLibraryLoader.loadLibrary( LocalOfficeConnection.class.getClassLoader(), "officebean" );
+ }
+
+ //-------------------------------------------------------------------------
+ // debugging method
+ private void dbgPrint( String aMessage )
+ {
+ System.err.println( aMessage );
+ }
+
+ /**
+ * 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 )
+ {}
+ }
+
+ /**
+ * 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.
+ */
+ synchronized 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();
+
+ //Terminate the bridge. It turned out that this is necessary for the bean
+ //to work properly when displayed in an applet within Internet Explorer.
+ //When navigating off the page which is showing the applet and then going
+ //back to it, then the Java remote bridge is damaged. That is the Java threads
+ //do not work properly anymore. Therefore when Applet.stop is called the connection
+ //to the office including the bridge needs to be terminated.
+ if (mBridge != null)
+ {
+ XComponent comp = (XComponent)UnoRuntime.queryInterface(
+ XComponent.class, mBridge);
+ if (comp != null)
+ comp.dispose();
+ else
+ System.err.println("LocalOfficeConnection: could not dispose bridge!");
+
+ mBridge = null;
+ }
+
+ 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();
+
+ // try to connect to soffice
+ Object aInitialObject = null;
+ try
+ {
+ aInitialObject = resolve(xLocalContext, 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 = resolve(xLocalContext, 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;
+ }
+
+
+ //The function is copied and adapted from the UrlResolver.resolve.
+ //We cannot use the URLResolver because we need access to the bridge which has
+ //to be disposed when Applet.stop is called.
+ private Object resolve(XComponentContext xLocalContext, String dcp)
+ throws com.sun.star.connection.NoConnectException,
+ com.sun.star.connection.ConnectionSetupException,
+ com.sun.star.lang.IllegalArgumentException
+ {
+ String conDcp = null;
+ String protDcp = null;
+ String rootOid = null;
+
+ if(dcp.indexOf(';') == -1) {// use old style
+ conDcp = dcp;
+ protDcp = "iiop";
+ rootOid = "classic_uno";
+ }
+ else { // new style
+ int index = dcp.indexOf(':');
+ String url = dcp.substring(0, index).trim();
+ dcp = dcp.substring(index + 1).trim();
+
+ index = dcp.indexOf(';');
+ conDcp = dcp.substring(0, index).trim();
+ dcp = dcp.substring(index + 1).trim();
+
+ index = dcp.indexOf(';');
+ protDcp = dcp.substring(0, index).trim();
+ dcp = dcp.substring(index + 1).trim();
+
+ rootOid = dcp.trim().trim();
+ }
+
+ Object rootObject = null;
+ XBridgeFactory xBridgeFactory= null;
+
+ XMultiComponentFactory xLocalServiceManager = xLocalContext.getServiceManager();
+ try {
+ xBridgeFactory = (XBridgeFactory)UnoRuntime.queryInterface(
+ XBridgeFactory.class,
+ xLocalServiceManager.createInstanceWithContext(
+ "com.sun.star.bridge.BridgeFactory", xLocalContext));
+ } catch (com.sun.star.uno.Exception e) {
+ throw new com.sun.star.uno.RuntimeException(e.getMessage());
+ }
+ synchronized(this) {
+ if(mBridge == null) {
+ Object connector= null;
+ try {
+ connector = xLocalServiceManager.createInstanceWithContext(
+ "com.sun.star.connection.Connector", xLocalContext);
+ } catch (com.sun.star.uno.Exception e) {
+ throw new com.sun.star.uno.RuntimeException(e.getMessage());
+ }
+ XConnector connector_xConnector = (XConnector)UnoRuntime.queryInterface(XConnector.class, connector);
+ // connect to the server
+ XConnection xConnection = connector_xConnector.connect(conDcp);
+ // create the bridge name. This should not be necessary if we pass an
+ //empty string as bridge name into createBridge. Then we should always get
+ //a new bridge. This does not work because of (i51323). Therefore we
+ //create unique bridge names for the current process.
+ String sBridgeName = "OOoBean_private_bridge_" + String.valueOf(m_nBridgeCounter++);
+ try {
+ mBridge = xBridgeFactory.createBridge(sBridgeName, protDcp, xConnection, null);
+ } catch (com.sun.star.bridge.BridgeExistsException e) {
+ throw new com.sun.star.uno.RuntimeException(e.getMessage());
+ }
+ }
+ rootObject = mBridge.getInstance(rootOid);
+ return rootObject;
+ }
+ }
+
+
+ /**
+ * Retrives a path to the office program folder.
+ *
+ * @return The path to the office program folder.
+ */
+ static 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(
+ LocalOfficeConnection.class.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
+ {
+ int nSizeCmdArray = 4;
+ String sOption = null;
+ //examine if user specified command-line options in system properties.
+ //We may offer later a more sophisticated way of providing options if
+ //the need arises. Currently this is intended to ease the pain during
+ //development with pre-release builds of OOo where one wants to start
+ //OOo with the -norestore options. The value of the property is simple
+ //passed on to the Runtime.exec call.
+ try {
+ sOption = System.getProperty("com.sun.star.officebean.Options");
+ if (sOption != null)
+ nSizeCmdArray ++;
+ } catch (java.lang.SecurityException e)
+ {
+ e.printStackTrace();
+ }
+ // create call with arguments
+ String[] cmdArray = new String[nSizeCmdArray];
+
+ // read UNO_PATH environment variable to get path to soffice binary
+ String unoPath = System.getenv("UNO_PATH");
+ if (unoPath == null)
+ throw new java.io.IOException( "UNO_PATH environment variable is not set (required system path to the office program directory)" );
+
+// cmdArray[0] = (new File(getProgramPath(), OFFICE_APP_NAME)).getPath();
+ cmdArray[0] = (new File(unoPath, 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" );
+
+ if (sOption != null)
+ cmdArray[4] = sOption;
+
+ // start process
+ mProcess = Runtime.getRuntime().exec(cmdArray);
+ if ( mProcess == null )
+ throw new RuntimeException( "cannot start soffice: " + cmdArray );
+ new StreamProcessor(mProcess.getInputStream(), System.out);
+ new StreamProcessor(mProcess.getErrorStream(), System.err);
+ }
+
+ /**
+ * Retrives the ammount of time to wait for the startup.
+ *
+ * @return The ammount of time to wait in seconds(?).
+ */
+ public int getStartupTime()
+ {
+ return 60;
+ }
+ }
+
+
+
+ class StreamProcessor extends Thread
+ {
+ java.io.InputStream m_in;
+ java.io.PrintStream m_print;
+
+ public StreamProcessor(final java.io.InputStream in, final java.io.PrintStream out)
+ {
+ m_in = in;
+ m_print = out;
+ start();
+ }
+
+ public void run() {
+ java.io.BufferedReader r = new java.io.BufferedReader(
+ new java.io.InputStreamReader(m_in) );
+ try {
+ for ( ; ; ) {
+ String s = r.readLine();
+ if ( s == null ) {
+ break;
+ }
+ m_print.println(s);
+ }
+ } catch ( java.io.IOException e ) {
+ e.printStackTrace( System.err );
+ }
+ }
+ }
+
+}
diff --git a/bean/com/sun/star/comp/beans/LocalOfficeWindow.java b/bean/com/sun/star/comp/beans/LocalOfficeWindow.java
new file mode 100644
index 000000000000..b7c7ccd16f41
--- /dev/null
+++ b/bean/com/sun/star/comp/beans/LocalOfficeWindow.java
@@ -0,0 +1,288 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.comp.beans;
+
+import java.awt.Component;
+
+import com.sun.star.lang.EventObject;
+import com.sun.star.lang.SystemDependent;
+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.Any;
+import com.sun.star.uno.Type;
+import com.sun.star.beans.NamedValue;
+
+/**
+ * This class represents a local office window.
+ *
+ * @since OOo 2.0.0
+ */
+public class 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.
+ */
+ protected LocalOfficeWindow(OfficeConnection 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 synchronized void aquireSystemWindow()
+ {
+ if ( !bPeer )
+ {
+ // set real parent
+ XVclWindowPeer xVclWindowPeer = (XVclWindowPeer)UnoRuntime.queryInterface(
+ XVclWindowPeer.class, mWindow);
+
+ xVclWindowPeer.setProperty( "PluginParent", getWrappedWindowHandle());
+ 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 synchronized 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;
+ }
+ }
+
+
+ /// 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 synchronized 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(getWrappedWindowHandle(), 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);
+
+
+ // set initial visibility
+ XWindow aWindow = (XWindow)UnoRuntime.queryInterface(XWindow.class, mWindow);
+ aWindow.setVisible( bPeer );
+ }
+ catch (com.sun.star.uno.Exception exp) {
+ }
+
+ return mWindow;
+ }
+ /** We make sure that the office window is notified that the parent
+ * will be removed.
+ */
+ public void removeNotify()
+ {
+ try {
+ releaseSystemWindow();
+ } catch (java.lang.Exception e) {
+ System.err.println("LocaleOfficeWindow.removeNotify: Exception in releaseSystemWindow.");
+ System.err.println(e.getMessage());
+ e.printStackTrace(System.err);
+ }
+ super.removeNotify();
+ }
+
+ /**
+ * 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();
+
+ /**
+ Returns an Any containing a sequences of com.sun.star.beans.NamedValue. One NamedValue
+ contains the name "WINDOW" and the value is a Long representing the window handle.
+ The second NamedValue has the name "XEMBED" and the value is true, when the XEmbed
+ protocol shall be used fore embedding the native Window.
+ */
+ protected Any getWrappedWindowHandle()
+ {
+
+ NamedValue window = new NamedValue(
+ "WINDOW", new Any(new Type(Long.class), new Long(getNativeWindow())));
+ NamedValue xembed = new NamedValue(
+ "XEMBED", new Any(new Type(Boolean.class), new Boolean(false)));
+
+ if (getNativeWindowSystemType() == SystemDependent.SYSTEM_XWINDOW )
+ {
+ String vendor = System.getProperty("java.vendor");
+ if (vendor.equals("Sun Microsystems Inc.")
+ && Boolean.valueOf(System.getProperty("sun.awt.xembedserver")).booleanValue())
+ {
+ xembed = new NamedValue(
+ "XEMBED",
+ new Any(new Type(Boolean.class), new Boolean(true)));
+ }
+ }
+ return new Any(
+ new Type("[]com.sun.star.beans.NamedValue"),
+ new NamedValue[] {window, xembed});
+ }
+
+}
diff --git a/bean/com/sun/star/comp/beans/NativeConnection.java b/bean/com/sun/star/comp/beans/NativeConnection.java
new file mode 100644
index 000000000000..ab8bd7b7bf01
--- /dev/null
+++ b/bean/com/sun/star/comp/beans/NativeConnection.java
@@ -0,0 +1,62 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.comp.beans;
+
+import com.sun.star.connection.XConnection;
+
+/* Connection to a locally running OOo instance.
+ *
+ * @deprecated.
+ */
+/* 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/comp/beans/NativeService.java b/bean/com/sun/star/comp/beans/NativeService.java
new file mode 100644
index 000000000000..c28ca10a1901
--- /dev/null
+++ b/bean/com/sun/star/comp/beans/NativeService.java
@@ -0,0 +1,37 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.comp.beans;
+
+/*
+ * @deprecated
+ */
+/* package */ interface NativeService {
+ public String getIdentifier();
+ public void startupService() throws java.io.IOException;
+ public int getStartupTime();
+}
diff --git a/bean/com/sun/star/comp/beans/NoConnectionException.java b/bean/com/sun/star/comp/beans/NoConnectionException.java
new file mode 100644
index 000000000000..a351983a7aad
--- /dev/null
+++ b/bean/com/sun/star/comp/beans/NoConnectionException.java
@@ -0,0 +1,40 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.comp.beans;
+
+/** This exception is called when a method is called which
+ needs an established connection but no connection is
+ established yet or anymore.
+
+ @since OOo 2.0.0
+ */
+public class NoConnectionException extends Exception
+{
+};
+
+
diff --git a/bean/com/sun/star/comp/beans/NoDocumentException.java b/bean/com/sun/star/comp/beans/NoDocumentException.java
new file mode 100644
index 000000000000..d9aa3b162bdd
--- /dev/null
+++ b/bean/com/sun/star/comp/beans/NoDocumentException.java
@@ -0,0 +1,38 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.comp.beans;
+
+/** indicates that an operation needed a document, but no document was loaded.
+
+ @since OOo 2.0.0
+ */
+public class NoDocumentException extends Exception
+{
+};
+
+
diff --git a/bean/com/sun/star/comp/beans/OOoBean.java b/bean/com/sun/star/comp/beans/OOoBean.java
new file mode 100644
index 000000000000..b10becb3ce9a
--- /dev/null
+++ b/bean/com/sun/star/comp/beans/OOoBean.java
@@ -0,0 +1,1511 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.comp.beans;
+
+import com.sun.star.uno.UnoRuntime;
+
+// @requirement FUNC.PERF.LRN/0.6
+// @requirement FUNC.PERF.LOC/0.6
+// @requirement FUNC.PERF.FIX/0.6
+/** This is the basic JavaBean for all OOo application modules.
+
+ @requirement FUNC.RES.OTH/0.2
+ No other resources are needed yet.
+
+ @since OOo 2.0.0
+ */
+public class OOoBean
+
+ // @requirement FUNC.BEAN.VIEW/0.4
+ extends java.awt.Container
+
+ implements
+ // @requirement FUNC.PER/0.2
+ java.io.Externalizable
+{
+ // timeout values (milli secs)
+ int nOOoStartTimeOut = 60000;
+ int nOOoCallTimeOut = 3000;
+ int nOOoCheckCycle = 1000;
+
+ // This member contains the connection to an OOo instance if established.
+ private transient OfficeConnection iConnection;
+ private transient EventListener xConnectionListener;
+
+ // @requirement FUNC.BEAN.VIEW/0.4
+ // @requirement FUNC.BEAN.EDIT/0.4
+ // This member contains the OOo window
+ // if a connection is established.
+ // It is a child of the OOoBean canvas.
+ private OfficeWindow xFrameWindow;
+
+ // application environment
+ private transient com.sun.star.lang.XMultiServiceFactory xServiceFactory;
+ private transient com.sun.star.frame.XDesktop xDesktop;
+
+ // document and frame
+ private transient Frame aFrame;
+ private transient Controller aController;
+ private transient OfficeDocument aDocument;
+
+ // slot command execution environment
+ private transient com.sun.star.frame.XDispatchProvider xDispatcher;
+ private transient com.sun.star.util.XURLTransformer xURLTransformer;
+
+ // properties
+ private boolean bIgnoreVisibility = false; // to show even if already visible
+ private boolean bMenuBarVisible = true;
+ private boolean bStandardBarVisible = true;
+ private boolean bToolBarVisible = true;
+ private boolean bStatusBarVisible = true;
+
+
+ // debugging method
+ private void dbgPrint( String aMessage )
+ {
+ // System.err.println( "OOoBean: " + aMessage );
+ }
+
+ // @requirement FUNC.PER/0.2
+ /** @internal
+ * @deprecated
+ */
+ public void writeExternal( java.io.ObjectOutput aObjOut )
+ {
+ // TBD
+ }
+
+ // @requirement FUNC.PER/0.2
+ /** @internal
+ * @deprecated
+ */
+ public void readExternal( java.io.ObjectInput aObjIn )
+ {
+ // TBD
+ }
+
+ /** Generic constructor of the OOoBean.
+
+ Neither a connection is established nor any document loaded.
+ */
+ public OOoBean()
+ {}
+
+ // @requirement FUNC.CON.MULT/0.3
+ /** Constructor for an OOoBean which uses a specific office connection.
+
+ The connection must be established but no document is loaded.
+
+ @throws NoConnectionException
+ if the connection is not established.
+
+ @deprecated Clients could use the getOOoConnection to obtain an OfficeConnection
+ and use it as argument in a constructor for another OOoBean instance. Calling
+ the dispose method of the OfficeConnection or the OOoBean's stopOOoConnection
+ method would make all instances of OOoBean stop working.
+ */
+ public OOoBean( OfficeConnection iConnection )
+ throws NoConnectionException
+ {
+ try { setOOoConnection( iConnection ); }
+ catch ( HasConnectionException aExc )
+ { /* impossible here */ }
+ }
+
+ /** Sets the timeout for methods which launch OOo in milli seconds.
+
+ This method does not need a connection to an OOo instance.
+ */
+ public void setOOoStartTimeOut( int nMilliSecs )
+ {
+ nOOoStartTimeOut = nMilliSecs;
+ }
+
+ /** Sets the timeout for normal OOO methods calls in milli seconds.
+
+ This method does not need a connection to an OOo instance.
+ */
+ public void setOOoCallTimeOut( int nMilliSecs )
+ {
+ nOOoCallTimeOut = nMilliSecs;
+ }
+
+ /** Sets the period length in milli seconds to check the OOo connection.
+
+ This method does not need a connection to an OOo instance.
+ */
+ public void setOOoCheckCycle( int nMilliSecs )
+ {
+ nOOoCheckCycle = nMilliSecs;
+ }
+
+ /** Sets the a connection to an OOo instance.
+
+ @internal
+ */
+ private synchronized void setOOoConnection( OfficeConnection iNewConnection )
+ throws HasConnectionException, NoConnectionException
+ {
+ // the connection cannot be exchanged
+ if ( iConnection != null )
+ throw new HasConnectionException();
+
+ // is there a real connection, not just the proxy?
+ com.sun.star.uno.XComponentContext xComponentContext = null;
+ try { xComponentContext = iNewConnection.getComponentContext(); }
+ catch ( java.lang.Throwable aExc )
+ { throw new NoConnectionException(); }
+ if ( xComponentContext == null )
+ throw new NoConnectionException();
+
+ // set the connection
+ iConnection = iNewConnection;
+
+ // get notified when connection dies
+ if ( xConnectionListener != null )
+ xConnectionListener.end();
+ xConnectionListener = this.new EventListener("setOOoConnection");
+ }
+
+ // @requirement FUNC.CON.STRT/0.4
+ /** Starts a connection to an OOo instance which is lauched if not running.
+
+ @throws HasConnectionException
+ if a connection was already established.
+
+ @throws NoConnectionException
+ if the specified connection cannot be established
+ */
+ public void startOOoConnection( String aConnectionURL )
+ throws java.net.MalformedURLException,
+ HasConnectionException,
+ NoConnectionException
+ {
+ // create a new connection from the given connection URL
+ LocalOfficeConnection aConnection = new LocalOfficeConnection();
+ aConnection.setUnoUrl( aConnectionURL );
+ setOOoConnection( aConnection );
+ }
+
+ // @requirement FUNC.CON.CHK/0.7
+ /** Returns true if this OOoBean is connected to an OOo instance,
+ false otherwise.
+
+ @deprecated This method is not useful in a multithreaded environment. Then
+ all threads accessing the instance would have to be synchronized in order to
+ make is method work. It is better
+ to call OOoBean's methods and be prepared to catch a NoConnectionException.
+ */
+ public boolean isOOoConnected()
+ {
+ return iConnection != null;
+ }
+
+ // @requirement FUNC.CON.STOP/0.4
+ /** Disconnects from the connected OOo instance.
+
+ If there was no connection yet or anymore, this method can be called
+ anyway.
+
+ When the OOoBean is displayed in an applet by a web browser, then this
+ method must be called from within java.applet.Applet.stop.
+ */
+ public synchronized void stopOOoConnection()
+ {
+ // clear OOo document, frame etc.
+ clear();
+
+ // cut the connection
+ OfficeConnection iExConnection = iConnection;
+ if ( iConnection != null )
+ {
+ if ( xConnectionListener != null )
+ {
+ xConnectionListener.end();
+ }
+ iConnection = null;
+ iExConnection.dispose();
+ }
+
+ }
+
+ // @requirement FUNC.CON.STOP/0.4 (via XComponent.dispose())
+ // @requirement FUNC.CON.NTFY/0.4 (via XComponent.addEventListener())
+ /** Returns the a connection to an OOo instance.
+
+ If no connection exists, a default connection will be created. An OfficeConnection
+ can be used to register listeners of type com.sun.star.lang.EventListener,
+ which are notified when the connection to the
+ office dies. One should not call the dispose method, because this may result
+ in receiving com.sun.star.lang.DisposedExceptions when calling
+ {@link #stopOOoConnection stopOOoConnection} or other API methods. If other instances share the
+ same connection then they will stop function properly, because they loose their
+ connection as well. The recommended way to end the connection is
+ calling {@link #stopOOoConnection stopOOoConnection}.
+
+ @throws NoConnectionException
+ if no connection can be established
+
+ */
+ public synchronized OfficeConnection getOOoConnection()
+ throws NoConnectionException
+ {
+ if ( iConnection == null )
+ {
+ try { setOOoConnection( new LocalOfficeConnection() ); }
+ catch ( HasConnectionException aExc )
+ { /* impossible here */ }
+ }
+ if ( iConnection.getComponentContext() == null )
+ throw new NoConnectionException();
+ return iConnection;
+ }
+
+ /** Returns the service factory used by this OOoBean instance.
+
+ @throws NoConnectionException
+ if no connection is established and no default connection can be established.
+ */
+ public synchronized com.sun.star.lang.XMultiServiceFactory getMultiServiceFactory()
+ throws NoConnectionException
+ {
+ if ( xServiceFactory == null )
+ {
+ // avoid concurrent access from multiple threads
+ final OfficeConnection iConn = getOOoConnection();
+
+ Thread aConnectorThread = new Thread() {
+ public void run()
+ {
+ com.sun.star.lang.XMultiComponentFactory aFactory =
+ iConn.getComponentContext().getServiceManager();
+ xServiceFactory = (com.sun.star.lang.XMultiServiceFactory)
+ UnoRuntime.queryInterface(
+ com.sun.star.lang.XMultiServiceFactory.class, aFactory );
+ }
+ };
+ aConnectorThread.start();
+ try { aConnectorThread.join(nOOoStartTimeOut); }
+ catch ( java.lang.InterruptedException aExc )
+ { throw new NoConnectionException(); }
+ if ( xServiceFactory == null )
+ throw new NoConnectionException();
+ }
+
+ return xServiceFactory;
+ }
+
+ /** Returns the XDesktop interface of the OOo instance used by this OOoBean.
+
+ @throws NoConnectionException
+ if no connection is established and no default connection can be established.
+ */
+ public synchronized com.sun.star.frame.XDesktop getOOoDesktop()
+ throws NoConnectionException
+ {
+ if ( xDesktop == null )
+ {
+ try
+ {
+ Object aObject = getMultiServiceFactory().createInstance( "com.sun.star.frame.Desktop");
+ xDesktop = (com.sun.star.frame.XDesktop) UnoRuntime.queryInterface(
+ com.sun.star.frame.XDesktop.class, aObject );
+ }
+ catch ( com.sun.star.uno.Exception aExc )
+ {} // TBD: what if no connection exists?
+ }
+
+ return xDesktop;
+ }
+
+ /** Resets this bean to an empty document.
+
+ If a document is loaded and the content modified,
+ the changes are dismissed. Otherwise nothing happens.
+
+ This method is intended to be overridden in derived classes.
+ This implementation simply calls clear.
+
+ @param bClearStateToo
+ Not only the document content but also the state of the bean,
+ like visibility of child components is cleared.
+
+ @deprecated There is currently no way to dismiss changes, except for loading
+ of the unchanged initial document. Furthermore it is unclear how derived classes
+ handle this and what exactly their state is (e.g. what members make up their state).
+ Calling this method on a derived class requires knowledge about their implementation.
+ Therefore a deriving class should declare their own clearDocument if needed. Clients
+ should call the clearDocument of the deriving class or {@link #clear} which discards
+ the currently displayed document.
+ */
+ public synchronized void clearDocument( boolean bClearStateToo )
+ throws
+ com.sun.star.util.CloseVetoException,
+ NoConnectionException
+ {
+ // TBD
+ clear();
+ }
+
+ /** Resets the OOoBean to an empty status.
+
+ Any loaded document is unloaded, no matter whether it is modified or not.
+ After calling this method, the OOoBean has no office document and no frame
+ anymore. The connection will stay, though.
+
+ This method works with or without an established connection.
+ */
+ public synchronized void clear()
+ {
+ dbgPrint( "clear()" );
+
+ try
+ {
+ CallWatchThread aCallWatchThread =
+ new CallWatchThread( nOOoCallTimeOut, "clear" );
+ //By closing the frame we avoid that dialogs are displayed, for example when
+ //the document is modified.
+ com.sun.star.util.XCloseable xCloseable = (com.sun.star.util.XCloseable)
+ UnoRuntime.queryInterface( com.sun.star.util.XCloseable.class, aFrame );
+ if ( xCloseable != null )
+ {
+ try
+ {
+ xCloseable.close(true);
+ }
+ catch (com.sun.star.util.CloseVetoException exc)
+ { // a print job may be running
+ }
+ }
+
+ aDocument = null;
+ xDispatcher = null;
+ aFrame = null;
+
+ // clear xFrameWindow
+ if ( xFrameWindow != null )
+ {
+ try { releaseSystemWindow(); }
+ catch ( NoConnectionException aExc )
+ {} // ignore
+ catch ( SystemWindowException aExc )
+ {} // ignore
+ remove( xFrameWindow.getAWTComponent() );
+ xFrameWindow = null;
+ }
+
+ // clear xURTTransformer
+ if ( xURLTransformer != null )
+ {
+ try
+ {
+ com.sun.star.lang.XComponent xComp = (com.sun.star.lang.XComponent)
+ UnoRuntime.queryInterface(
+ com.sun.star.lang.XComponent.class, xURLTransformer );
+ if ( xComp != null )
+ xComp.dispose();
+ }
+ catch ( java.lang.Throwable aExc )
+ {} // ignore
+ xURLTransformer = null;
+ }
+
+ xDesktop = null;
+ xServiceFactory = null;
+
+ aCallWatchThread.cancel();
+ }
+ catch ( java.lang.InterruptedException aExc )
+ { /* can be ignored */ }
+ }
+
+ // @requirement FUNC.PAR.LWP/0.4
+ /** This method causes the office window to be displayed.
+
+ If no document is loaded and the instance is added to a Java container that
+ is showing, then this method needs not to be called. If later one of the methods
+ {@link #loadFromURL loadFromURL}, {@link #loadFromStream loadFromStream1},
+ or {@link #loadFromByteArray loadFromByteArray}
+ is called, then the document is automatically displayed.
+
+ Should one of the load methods have been called before the Java container
+ was showing, then this method needs to be called after the container window
+ was made visible (java.lang.Component.setVisible(true)).
+ <p>
+ Another scenario is that a OOoBean contains a document and is removed
+ from a Java container and later added again. Then aquireSystemWindow needs
+ to be called after the container window is displayed.
+
+ @throws SystemWindowException
+ if no system window can be aquired.
+
+ @throws NoConnectionException
+ if the connection is not established.
+ */
+ public synchronized void aquireSystemWindow()
+ throws
+ SystemWindowException,
+
+ // @requirement FUNC.CON.LOST/0.2
+ NoConnectionException
+ {
+ if ( iConnection == null )
+ throw new NoConnectionException();
+ if ( !isShowing() )
+ throw new SystemWindowException();
+
+ if ( xFrameWindow != null )
+ xFrameWindow.getAWTComponent().setVisible(true);
+ doLayout();
+ }
+
+ // @requirement FUNC.PAR.RWL/0.4
+ // @estimation 16h
+ /** This method must be called when the OOoBean before the
+ sytem window may be released by it's parent AWT/Swing component.
+
+ This is the case when java.awt.Component.isDisplayable() returns
+ true. This is definitely the case when the OOoBean is removed
+ from it's parent container.
+
+ @throws SystemWindowException
+ if system window is not aquired.
+
+ @throws NoConnectionException
+ if the connection is not established.
+
+ @deprecated When Component.removeNotify of the parent window of the actual
+ office window is called, then the actions are performed for which this method
+ needed to be called previously.
+ */
+ public synchronized void releaseSystemWindow()
+ throws
+ SystemWindowException,
+
+ // @requirement FUNC.CON.LOST/0.2
+ NoConnectionException
+ {
+ if ( iConnection == null )
+ throw new NoConnectionException();
+
+ try { xFrameWindow.getAWTComponent().setVisible(false); }
+ catch ( com.sun.star.lang.DisposedException aExc )
+ { throw new NoConnectionException(); }
+ }
+
+ // @requirement FUNC.BEAN.LOAD/0.4
+ // @requirement FUNC.CON.AUTO/0.3
+ /** Loads the bean from the given URL.
+
+ If a document is already loaded and the content modified,
+ the changes are dismissed.
+
+ If no connection exists, a default connection is established.
+
+ @throws IllegalArgumentException
+ if either of the arguments is out of the specified range.
+
+ @throws java.io.IOException
+ if an IO error occurs reading the ressource specified by the URL.
+
+ @throws com.sun.star.lang.NoConnectionException
+ if no connection can be established.
+
+ @throws com.sun.star.util.CloseVetoException
+ if the currently displayed document cannot be closed because it is
+ still be used, for example it is printed.
+ */
+ public void loadFromURL(
+ final String aURL,
+ final com.sun.star.beans.PropertyValue aArguments[] )
+ throws
+ // @requirement FUNC.CON.LOST/0.2
+ NoConnectionException,
+ java.io.IOException,
+ com.sun.star.lang.IllegalArgumentException,
+ com.sun.star.util.CloseVetoException
+ {
+ dbgPrint( "loadFromURL()" );
+ // try loading
+ try
+ {
+ boolean bLoaded = false;
+ while ( !bLoaded )
+ {
+ // watch loading in a thread with a timeout (if OOo hangs)
+ CallWatchThread aCallWatchThread =
+ new CallWatchThread( nOOoStartTimeOut, "loadFromURL" );
+
+ try
+ {
+ // get window from OOo on demand
+ if ( xFrameWindow == null )
+ {
+ // Establish the connection by request of the ServiceFactory.
+ getMultiServiceFactory();
+
+ // remove existing child windows
+ removeAll();
+
+ // Create the OfficeWindow.
+ xFrameWindow = getOOoConnection().createOfficeWindow(OOoBean.this);
+ add( xFrameWindow.getAWTComponent() );
+ }
+
+ // create the document frame from UNO window.
+ if ( aFrame == null )
+ {
+ // create the frame
+ com.sun.star.awt.XWindow xWindow =
+ (com.sun.star.awt.XWindow) UnoRuntime.queryInterface(
+ com.sun.star.awt.XWindow.class, xFrameWindow.getUNOWindowPeer());
+ Object xFrame = xServiceFactory.createInstance( "com.sun.star.frame.Frame");
+ aFrame = new Frame( (com.sun.star.frame.XFrame)UnoRuntime.queryInterface(
+ com.sun.star.frame.XFrame.class, xFrame ) );
+ aFrame.initialize( xWindow );
+ aFrame.setName( aFrame.toString() );
+
+ // register the frame at the desktop
+ com.sun.star.frame.XFrames xFrames =
+ ( (com.sun.star.frame.XFramesSupplier)UnoRuntime.queryInterface(
+ com.sun.star.frame.XFramesSupplier.class, getOOoDesktop() ) ).getFrames();
+ xFrames.append( aFrame );
+ }
+
+ // Initializes the slot command execution environment.
+ xURLTransformer = (com.sun.star.util.XURLTransformer) UnoRuntime.queryInterface(
+ com.sun.star.util.XURLTransformer.class,
+ xServiceFactory.createInstance( "com.sun.star.util.URLTransformer") );
+ xDispatcher = (com.sun.star.frame.XDispatchProvider)UnoRuntime.queryInterface(
+ com.sun.star.frame.XDispatchProvider.class, aFrame );
+
+ // get XComponentLoader from frame
+ com.sun.star.frame.XComponentLoader xLoader = (com.sun.star.frame.XComponentLoader)
+ UnoRuntime.queryInterface( com.sun.star.frame.XComponentLoader.class, aFrame );
+ if ( xLoader == null )
+ {
+ throw new java.lang.RuntimeException(
+ "com.sun.star.frame.Frame(" + aFrame +
+ ") without com.sun.star.frame.XComponentLoader" );
+ }
+
+ // Avoid Dialog 'Document changed' while reloading
+ if ( aDocument != null )
+ {
+ try {
+ aDocument.setModified(false);
+ } catch (com.sun.star.beans.PropertyVetoException ep) {
+ //it dosn't make sense to throw the exception here. The interface does not
+ //offer a way to add/remove respective listeners.
+ } catch (com.sun.star.lang.DisposedException ed) {
+ // can be disposed if user closed document via UI
+ }
+
+ com.sun.star.frame.XController xOldController = null;
+ if ( aFrame != null )
+ xOldController = aFrame.getController();
+
+ try
+ {
+
+ if ( aFrame != null && xOldController != null )
+ if (xOldController.suspend(true) == false)
+ throw new com.sun.star.util.CloseVetoException(
+ "Dokument is still being used and cannot be closed.", this);
+
+ }
+ catch (java.lang.IllegalStateException exp)
+ {}
+ }
+
+ // load the document.
+ com.sun.star.beans.PropertyValue aArgs[] =
+ addArgument( aArguments, new com.sun.star.beans.PropertyValue(
+ "MacroExecutionMode", -1,
+ new Short( com.sun.star.document.MacroExecMode.USE_CONFIG ),
+ com.sun.star.beans.PropertyState.DIRECT_VALUE ) );
+ //String fn = aFRame.getName();
+
+ com.sun.star.lang.XComponent xComponent = xLoader.loadComponentFromURL(
+ aURL, /*aFrame.getName()*/"_self", 0, aArgs );
+
+ // nothing loaded?
+ if ( xComponent == null && aDocument != null )
+ {
+ // reactivate old document
+ if ( aFrame != null && aFrame.getController() != null )
+ aFrame.getController().suspend(false);
+ aDocument.setModified(true);
+
+ // throw exception
+ throw new java.io.IOException(
+ "Can not load a document: \"" + aURL + "\"");
+ }
+ // mDocumentURL = aURL; TBD: still needed?
+
+ // Get document's XModifiable interface if any.
+ aDocument = new OfficeDocument(
+ (com.sun.star.frame.XModel) UnoRuntime.queryInterface(
+ com.sun.star.frame.XModel.class, xComponent ) );
+ bLoaded = true;
+ }
+ catch ( NoConnectionException aExc )
+ {
+ // stop, clear and retry
+ stopOOoConnection();
+ }
+ catch ( com.sun.star.lang.DisposedException aExc )
+ {
+ // stop, clear and retry
+ stopOOoConnection();
+ }
+ catch ( com.sun.star.uno.Exception aExc )
+ {
+ // TDB: handling failure in createInstance
+ aExc.printStackTrace();
+ throw new java.io.IOException();
+ }
+
+ aCallWatchThread.cancel();
+ if ( xServiceFactory == null )
+ throw new NoConnectionException();
+ }
+ if ( iConnection == null )
+ {
+ throw new NoConnectionException();
+ }
+
+ applyToolVisibilities();
+ }
+ catch ( java.lang.InterruptedException aExc )
+ {
+ throw new NoConnectionException();
+ }
+ }
+
+ /** Loads a document from a Java stream.
+
+ See loadFromURL() for further information.
+ */
+ public void loadFromStream(
+ final java.io.InputStream iInStream,
+ final com.sun.star.beans.PropertyValue aArguments[] )
+ throws
+ // @requirement FUNC.CON.LOST/0.2
+ NoConnectionException,
+ java.io.IOException,
+ com.sun.star.lang.IllegalArgumentException,
+ com.sun.star.util.CloseVetoException
+ {
+ // wrap Java stream into UNO stream
+ /*
+ com.sun.star.io.XInputStream xStream =
+ new com.sun.star.lib.uno.adapter.InputStreamToXInputStreamAdapter(
+ iInStream );
+ */
+ // copy stream....
+
+ int s = 4096;
+ int r=0 ,n = 0;
+ byte[] buffer = new byte[s];
+ byte[] newBuffer = null;
+ while ((r = iInStream.read(buffer, n, buffer.length-n))>0) {
+ n += r;
+ if (iInStream.available() > buffer.length - n) {
+ newBuffer = new byte[buffer.length*2];
+ System.arraycopy(buffer, 0, newBuffer, 0, n);
+ buffer = newBuffer;
+ }
+ }
+ if (buffer.length != n) {
+ newBuffer = new byte[n];
+ System.arraycopy(buffer, 0, newBuffer, 0, n);
+ buffer = newBuffer;
+ }
+ com.sun.star.io.XInputStream xStream =
+ new com.sun.star.lib.uno.adapter.ByteArrayToXInputStreamAdapter(buffer);
+
+ // add stream to arguments
+ com.sun.star.beans.PropertyValue[] aExtendedArguments =
+ addArgument( aArguments, new com.sun.star.beans.PropertyValue(
+ "InputStream", -1, xStream, com.sun.star.beans.PropertyState.DIRECT_VALUE ) );
+
+ // call normal load method
+ loadFromURL( "private:stream", aExtendedArguments );
+ }
+
+ /** Loads a document from a byte array.
+
+ See loadFromURL() for further information.
+ */
+ public void loadFromByteArray(
+ final byte aInBuffer[],
+ final com.sun.star.beans.PropertyValue aArguments[] )
+ throws
+ // @requirement FUNC.CON.LOST/0.2
+ NoConnectionException,
+ java.io.IOException,
+ com.sun.star.lang.IllegalArgumentException,
+ com.sun.star.util.CloseVetoException
+ {
+ // wrap byte arrray into UNO stream
+ com.sun.star.io.XInputStream xStream =
+ new com.sun.star.lib.uno.adapter.ByteArrayToXInputStreamAdapter(
+ aInBuffer );
+
+ // add stream to arguments
+ com.sun.star.beans.PropertyValue[] aExtendedArguments =
+ addArgument( aArguments, new com.sun.star.beans.PropertyValue(
+ "InputStream", -1, xStream, com.sun.star.beans.PropertyState.DIRECT_VALUE ) );
+
+ // call normal load method
+ loadFromURL( "private:stream", aExtendedArguments );
+ }
+
+ /** Stores a document to the given URL.
+ <p>
+ Due due a bug (50651) calling this method may cause the office to crash,
+ when at the same time the office writes a backup of the document. This bug
+ also affects {@link #storeToByteArray storeToByteArray} and
+ {@link #storeToStream storeToStream}. The workaround
+ is to start the office with the option -norestore, which disables the automatic
+ backup and recovery mechanism. OOoBean offers currently no supported way of providing
+ startup options for OOo. But it is possible to set a Java property when starting
+ Java, which is examined by OOoBean:
+ <pre>
+ java -Dcom.sun.star.officebean.Options=-norestore ...
+ </pre>
+ It is planned to offer a way of specifying startup options in a future version.
+ The property can be used until then. When using this property only one option
+ can be provided.
+
+ @throws IllegalArgumentException
+ if either of the arguments is out of the specified range.
+
+ @throws java.io.IOException
+ if an IO error occurs reading the ressource specified by the URL.
+
+ @throws com.sun.star.lang.NoConnectionException
+ if no connection is established.
+
+ @throws NoDocumentException
+ if no document is loaded
+ */
+ public void storeToURL(
+ final String aURL,
+ final com.sun.star.beans.PropertyValue aArguments[] )
+ throws
+ // @requirement FUNC.CON.LOST/0.2
+ NoConnectionException,
+ java.io.IOException,
+ com.sun.star.lang.IllegalArgumentException,
+ NoDocumentException
+ {
+ // no document available?
+ if ( aDocument == null )
+ throw new NoDocumentException();
+
+ try
+ {
+ // start runtime timeout
+ CallWatchThread aCallWatchThread =
+ new CallWatchThread( nOOoCallTimeOut, "storeToURL" );
+
+ // store the document
+ try { aDocument.storeToURL( aURL, aArguments ); }
+ catch ( com.sun.star.io.IOException aExc )
+ { throw new java.io.IOException(); }
+
+ // end runtime timeout
+ aCallWatchThread.cancel();
+ }
+ catch ( java.lang.InterruptedException aExc )
+ { throw new NoConnectionException(); }
+ }
+
+ /** Stores a document to a stream.
+
+ See {@link #storeToURL storeToURL} for further information.
+ @see #storeToURL storeToURL
+ */
+ public java.io.OutputStream storeToStream(
+ java.io.OutputStream aOutStream,
+ final com.sun.star.beans.PropertyValue aArguments[] )
+ throws
+ // @requirement FUNC.CON.LOST/0.2
+ NoConnectionException,
+ NoDocumentException,
+ java.io.IOException,
+ com.sun.star.lang.IllegalArgumentException
+
+ {
+ // wrap Java stream into UNO stream
+ com.sun.star.lib.uno.adapter.OutputStreamToXOutputStreamAdapter aStream =
+ new com.sun.star.lib.uno.adapter.OutputStreamToXOutputStreamAdapter(
+ aOutStream );
+
+ // add stream to arguments
+ com.sun.star.beans.PropertyValue[] aExtendedArguments =
+ addArgument( aArguments, new com.sun.star.beans.PropertyValue(
+ "OutputStream", -1, aStream, com.sun.star.beans.PropertyState.DIRECT_VALUE ) );
+
+ // call normal store method
+ storeToURL( "private:stream", aExtendedArguments );
+
+ // get byte array from document stream
+ try { aStream.closeOutput(); }
+ catch ( com.sun.star.io.NotConnectedException aExc )
+ { /* TDB */ }
+ catch ( com.sun.star.io.BufferSizeExceededException aExc )
+ { /* TDB */ }
+ catch ( com.sun.star.io.IOException aExc )
+ { throw new java.io.IOException(); }
+ return aOutStream;
+ }
+
+ /** Stores a document to a byte array.
+
+ See {@link #storeToURL storeToURL} for further information.
+ @see #storeToURL storeToURL
+ */
+ public byte[] storeToByteArray(
+ byte aOutBuffer[],
+ final com.sun.star.beans.PropertyValue aArguments[] )
+ throws
+ // @requirement FUNC.CON.LOST/0.2
+ NoConnectionException,
+ NoDocumentException,
+ java.io.IOException,
+ com.sun.star.lang.IllegalArgumentException
+ {
+ // wrap byte arrray into UNO stream
+ com.sun.star.lib.uno.adapter.XOutputStreamToByteArrayAdapter aStream =
+ new com.sun.star.lib.uno.adapter.XOutputStreamToByteArrayAdapter(
+ aOutBuffer );
+
+ // add stream to arguments
+ com.sun.star.beans.PropertyValue[] aExtendedArguments =
+ addArgument( aArguments, new com.sun.star.beans.PropertyValue(
+ "OutputStream", -1, aStream, com.sun.star.beans.PropertyState.DIRECT_VALUE ) );
+
+ // call normal store method
+ storeToURL( "private:stream", aExtendedArguments );
+
+ // get byte array from document stream
+ try { aStream.closeOutput(); }
+ catch ( com.sun.star.io.NotConnectedException aExc )
+ { /* TDB */ }
+ catch ( com.sun.star.io.BufferSizeExceededException aExc )
+ { /* TDB */ }
+ catch ( com.sun.star.io.IOException aExc )
+ { throw new java.io.IOException(); }
+ return aStream.getBuffer();
+ }
+
+ // @requirement FUNC.BEAN.PROG/0.5
+ // @requirement API.SIM.SEAP/0.2
+ /** returns the <type scope="com::sun::star::frame">Frame</a>
+ of the bean.
+
+ @returns
+ a Java class which implements all interfaces which the service
+ <type scope="com::sun::star::frame">Frame</a> implements.
+ Thus, methods can be called directly without queryInterface.
+ This feature might be implemented by UNO or explicitely coded.
+
+ @throws NoConnectionException
+ if the connection is not established.
+
+ @throws NotDocumentException
+ if no document is loaded an thus no frame is available.
+ */
+ public Frame getFrame()
+
+ throws
+ NoConnectionException // @requirement FUNC.CON.LOST/0.2
+ {
+ if ( iConnection == null )
+ throw new NoConnectionException();
+ return aFrame;
+ }
+
+ // @requirement FUNC.BEAN.PROG/0.5
+ // @requirement API.SIM.SEAP/0.2
+ /** returns the <type scope="com::sun::star::frame::Controller"> of the bean.
+
+ @returns
+ a Java class which implements all interfaces which the service
+ <type scope="com::sun::star::frame">Controller</a> implements.
+ Thus, methods can be called directly without queryInterface.
+ This feature might be implemented by UNO or explicitely coded.
+
+ @throws NoConnectionException
+ if the connection is not established.
+ */
+ public Controller getController()
+
+ // @requirement FUNC.CON.LOST/0.2
+ throws NoConnectionException
+ {
+ if ( iConnection == null )
+ throw new NoConnectionException();
+ if ( aController == null )
+ aController = new Controller( aFrame.getController() );
+ return aController;
+ }
+
+ // @requirement FUNC.BEAN.PROG/0.5
+ // @requirement FUNC.BEAN.STOR/0.4
+ // @requirement FUNC.BEAN.PRNT/0.4
+ // @requirement API.SIM.SEAP/0.2
+ /** returns the <type scope="com::sun::star::document::OfficeDocument">
+ of the bean.
+
+ @returns
+ a Java class which implements all interfaces which the service
+ <type scope="com::sun::star::document">OfficeDocument</a>
+ implements.
+ Thus, methods can be called directly without queryInterface.
+ This feature might be implemented by UNO or explicitely coded.
+
+ @throws NoConnectionException
+ if the connection is not established.
+ */
+ public OfficeDocument getDocument()
+
+ // @requirement FUNC.CON.LOST/0.2
+ throws NoConnectionException
+ {
+ if ( iConnection == null )
+ throw new NoConnectionException();
+ return aDocument;
+ }
+
+ /** Sets visibility of all tool bars known by this OOoBean version.
+
+ Initially all tool bars are visible. By hiding all tool bars
+ utilizing this method, it is possible to turn just a subset of
+ tool bars on afterwards, no matter whether all available tool
+ bars are known or not.
+ <p>
+ If an older OOoBean instance is used with a newer OOo instance,
+ some tool bars might not be affected by this method.
+ <p>
+ If no connection is established or no document is loaded,
+ the setting is memorized until a document is loaded. Same
+ is valid when the connection dies within this function call.
+
+ @deprecated Clients should use the service com.sun.star.frame.LayoutManager,
+ which can be obtained from a frame, to control toolbars. For example:
+ <pre>
+com.sun.star.beans.XPropertySet xPropSet =
+ (com.sun.star.beans.XPropertySet) UnoRuntime.queryInterface(
+ com.sun.star.beans.XPropertySet.class, aFrame );
+com.sun.star.frame.XLayoutManager xLayoutManager =
+ (com.sun.star.frame.XLayoutManager) UnoRuntime.queryInterface(
+ com.sun.star.frame.XLayoutManager.class,
+ xPropSet.getPropertyValue( "LayoutManager" ) );
+xLayoutManager.showElement("private:resource/menubar/menubar");
+ </pre>
+ */
+ public void setAllBarsVisible( boolean bVisible )
+ {
+ bIgnoreVisibility = true;
+ setMenuBarVisible( bVisible );
+ setStandardBarVisible( bVisible );
+ setToolBarVisible( bVisible );
+ setStatusBarVisible( bVisible );
+ bIgnoreVisibility = false;
+ }
+
+ //--------------------------------------------------------------------------
+ /** Applies all tool visiblities to the real thing.
+
+ @deprecated Clients should use the service com.sun.star.frame.LayoutManager,
+ which can be obtained from a frame, to control toolbars. See also
+ {@link #setAllBarsVisible setAllBarsVisible}.
+ */
+ protected void applyToolVisibilities()
+ throws
+ java.lang.InterruptedException
+ {
+ bIgnoreVisibility = true;
+ setMenuBarVisible( bMenuBarVisible );
+ setStandardBarVisible( bStandardBarVisible );
+ setToolBarVisible( bToolBarVisible );
+ setStatusBarVisible( bStatusBarVisible );
+ bIgnoreVisibility = false;
+ }
+
+ /** Helper method to set tool bar visibilty.
+
+ @param bnewValue
+ If false, the tool bar is disabled,
+ If true, the tool bar is visible.
+
+ @deprecated Clients should use the service com.sun.star.frame.LayoutManager,
+ which can be obtained from a frame, to control toolbars. See also
+ {@link #setAllBarsVisible}.
+ */
+ protected boolean setToolVisible( String aProperty, String aResourceURL,
+ boolean bOldValue, boolean bNewValue )
+
+ throws
+ java.lang.InterruptedException
+ {
+ // start runtime timeout
+ CallWatchThread aCallWatchThread =
+ new CallWatchThread( nOOoCallTimeOut, "setToolVisible" );
+
+ // Does a frame exist?
+ if ( aFrame != null )
+ {
+ if ( bIgnoreVisibility || bOldValue != bNewValue )
+ {
+ try
+ {
+ com.sun.star.beans.XPropertySet xPropSet =
+ (com.sun.star.beans.XPropertySet) UnoRuntime.queryInterface(
+ com.sun.star.beans.XPropertySet.class, aFrame );
+ com.sun.star.frame.XLayoutManager xLayoutManager =
+ (com.sun.star.frame.XLayoutManager) UnoRuntime.queryInterface(
+ com.sun.star.frame.XLayoutManager.class,
+ xPropSet.getPropertyValue( "LayoutManager" ) );
+ if ( bNewValue )
+ xLayoutManager.showElement( aResourceURL );
+ else
+ xLayoutManager.hideElement( aResourceURL );
+ }
+ catch ( com.sun.star.beans.UnknownPropertyException aExc )
+ {
+ throw new RuntimeException( "not layout manager found" );
+ }
+ catch ( com.sun.star.lang.WrappedTargetException aExc )
+ {
+ throw new RuntimeException( "not layout manager found" );
+ }
+
+ // notify change
+ firePropertyChange( aProperty, new Boolean(bOldValue), new Boolean(bNewValue) );
+ }
+ }
+
+ // end runtime timeout
+ aCallWatchThread.cancel();
+
+ // the new value will be stored by caller
+ return bNewValue;
+ }
+
+ /** Sets the visibility of the menu bar.
+
+ Initially the menu bar is visible.
+ <p>
+ If not connected or no document loaded, the value is stored
+ and automatically applied to the document after it is loaded.
+ Same is valid when the connection dies within this function call.
+
+ @param bVisible
+ If false, the menu bar is disabled,
+ If true, the menu bar is visible.
+
+ @deprecated Clients should use the service com.sun.star.frame.LayoutManager,
+ which can be obtained from a frame, to control toolbars. See also
+ {@link #setAllBarsVisible}.
+ */
+ public void setMenuBarVisible(boolean bVisible)
+ {
+ try
+ {
+ bMenuBarVisible = setToolVisible( "MenuBarVisible",
+ "private:resource/menubar/menubar", bMenuBarVisible, bVisible );
+ }
+ catch ( java.lang.InterruptedException aExc )
+ {
+ bMenuBarVisible = bVisible;
+ }
+ }
+
+ /** Returns the visibility of the menu bar.
+
+ This method works independently from a connetion or loaded document.
+ If no connection is established or no document is loaded,
+ this method just returns a memorized status.
+
+ @return
+ True if the menu bar is visible,
+ false if the menu bar is hidden.
+
+ @deprecated Clients should use the service com.sun.star.frame.LayoutManager,
+ which can be obtained from a frame, to control toolbars. See also
+ {@link #setAllBarsVisible}.
+ */
+ public boolean isMenuBarVisible()
+ {
+ return bMenuBarVisible;
+ }
+
+ /** Sets the main function bar visibilty.
+
+ Initially the standard bar is visible.
+
+ If not connected or no document loaded, the value is stored
+ and automatically applied to the document after it is loaded.
+ Same is valid when the connection dies within this function call.
+
+ @param bVisible
+ If false, the main function bar is disabled,
+ If true, the main function bar is visible.
+
+ @deprecated Clients should use the service com.sun.star.frame.LayoutManager,
+ which can be obtained from a frame, to control toolbars. See also
+ {@link #setAllBarsVisible}.
+ */
+ public void setStandardBarVisible(boolean bVisible)
+ {
+ try
+ {
+ bStandardBarVisible = setToolVisible( "StandardBarVisible",
+ "private:resource/toolbar/standardbar", bStandardBarVisible, bVisible );
+ }
+ catch ( java.lang.InterruptedException aExc )
+ {
+ bMenuBarVisible = bVisible;
+ }
+ }
+
+ /** Returns the visibility of the main function bar.
+
+ This method works independently from a connetion or loaded document.
+ If no connection is established or no document is loaded,
+ this method just returns a memorized status.
+
+ @return
+ True if the main function bar is visible,
+ false if the main function bar is hidden.
+
+ @deprecated Clients should use the service com.sun.star.frame.LayoutManager,
+ which can be obtained from a frame, to control toolbars. See also
+ {@link #setAllBarsVisible}.
+ */
+ public boolean isStandardBarVisible()
+ {
+ return bStandardBarVisible;
+ }
+
+ /** Sets the tool function bar visibilty.
+
+ Initially the tool bar is visible.
+
+ If not connected or no document loaded, the value is stored
+ and automatically applied to the document after it is loaded.
+ Same is valid when the connection dies within this function call.
+
+ @param bVisible
+ If false, the tool function bar is disabled,
+ If true, the tool function bar is visible.
+
+ @deprecated Clients should use the service com.sun.star.frame.LayoutManager,
+ which can be obtained from a frame, to control toolbars. See also
+ {@link #setAllBarsVisible}.
+ */
+ public void setToolBarVisible(boolean bVisible)
+ {
+ try
+ {
+ bToolBarVisible = setToolVisible( "ToolBarVisible",
+ "private:resource/toolbar/toolbar", bToolBarVisible, bVisible );
+ }
+ catch ( java.lang.InterruptedException aExc )
+ {
+ bMenuBarVisible = bVisible;
+ }
+ }
+
+ /** Returns the visibility of the tool function bar.
+
+ This method works independently from a connetion or loaded document.
+ If no connection is established or no document is loaded,
+ this method just returns a memorized status.
+
+ @return
+ True if the tool function bar is visible,
+ false if the tool function bar is hidden.
+
+ @deprecated Clients should use the service com.sun.star.frame.LayoutManager,
+ which can be obtained from a frame, to control toolbars. See also
+ {@link #setAllBarsVisible}.
+ */
+ public boolean isToolBarVisible()
+ {
+ return bToolBarVisible;
+ }
+
+ /** Sets the status function bar visibilty.
+
+ Initially the status bar is visible.
+
+ If not connected or no document loaded, the value is stored
+ and automatically applied to the document after it is loaded.
+ Same is valid when the connection dies within this function call.
+
+ @param bVisible
+ If false, the status function bar is disabled,
+ If true, the status function bar is visible.
+
+ @deprecated Clients should use the service com.sun.star.frame.LayoutManager,
+ which can be obtained from a frame, to control toolbars. See also
+ {@link #setAllBarsVisible}.
+ */
+ public void setStatusBarVisible(boolean bVisible)
+ {
+ try
+ {
+ bStatusBarVisible = setToolVisible( "StatusBarVisible",
+ "private:resource/statusbar/statusbar", bStatusBarVisible, bVisible );
+ }
+ catch ( java.lang.InterruptedException aExc )
+ {
+ bMenuBarVisible = bVisible;
+ }
+ }
+
+ /** Returns the visibility of the status function bar.
+
+ This method works independently from a connetion or loaded document.
+ If no connection is established or no document is loaded,
+ this method just returns a memorized status.
+
+ @return
+ True if the status function bar is visible,
+ false if the status function bar is hidden.
+
+ @deprecated Clients should use the service com.sun.star.frame.LayoutManager,
+ which can be obtained from a frame, to control toolbars. See also
+ {@link #setAllBarsVisible}.
+ */
+ public boolean isStatusBarVisible()
+ {
+ return bStatusBarVisible;
+ }
+
+ //===========================================================================
+ // Helper Methods / Internal Methods
+ //---------------------------------------------------------------------------
+
+ // general instance intializer
+ {
+ setLayout(new java.awt.BorderLayout());
+ }
+
+ /**
+ @deprecated
+ */
+ public void paint( java.awt.Graphics aGraphics )
+ {
+ }
+
+ /** Adds a single argument to an array of arguments.
+
+ If the argument by its name is already in aArguments
+ it is exchanged and aArguments is returned.
+ <p>
+ If the argument by its name is not yet in aArguments,
+ a new array is created, aArgument added and the new
+ array returned.
+ */
+ protected com.sun.star.beans.PropertyValue[] addArgument(
+ com.sun.star.beans.PropertyValue aArguments[],
+ final com.sun.star.beans.PropertyValue aArgument )
+ {
+ // get number of current arguments
+ int nNumArgs = 0;
+ if ( aArguments != null )
+ nNumArgs = aArguments.length;
+
+ // is new argument already set?
+ for ( int n = 0; n < nNumArgs; ++n )
+ {
+ if ( aArguments[n].Name == aArgument.Name )
+ {
+ // substitute this argument
+ aArguments[n] = aArgument;
+
+ // return current array
+ return aArguments;
+ }
+ }
+
+ // create extended arguments
+ com.sun.star.beans.PropertyValue[] aExtendedArguments =
+ new com.sun.star.beans.PropertyValue[ nNumArgs + 1 ];
+
+ // copy current arguments
+ for ( int n = 0; n < nNumArgs; ++n )
+ aExtendedArguments[n] = aArguments[n];
+
+ // add new argument
+ aExtendedArguments[ nNumArgs ] = aArgument;
+
+ // return new arguments
+ return aExtendedArguments;
+ }
+
+ //===========================================================================
+ // Helper Classes
+ //---------------------------------------------------------------------------
+
+ /** Helper class to listen on the connection to learn when it dies.
+
+ @internal
+ */
+ private class EventListener
+ extends Thread
+ implements
+ com.sun.star.lang.XEventListener,
+ com.sun.star.frame.XTerminateListener
+ {
+ String aTag;
+
+ EventListener( String aTag )
+ throws NoConnectionException
+ {
+ // init members
+ this.aTag = aTag;
+
+ // listen on a dying connection
+ iConnection.addEventListener( this );
+
+ // listen on a terminating OOo
+ getOOoDesktop().addTerminateListener( this );
+
+ // start this thread as a daemon
+ setDaemon( true );
+ start();
+ }
+
+ public void end()
+ {
+ // do not listen on a dying connection anymore
+ try {
+ iConnection.removeEventListener( this );
+ }
+ catch ( Throwable aExc ) {};
+
+ // do not listen on a terminating OOo anymore
+ try {
+ getOOoDesktop().removeTerminateListener( this );
+ }
+ catch ( Throwable aExc ) {};
+
+ // stop thread
+ this.interrupt();
+ }
+
+ /// gets called when the connection dies
+ public void disposing( /*IN*/ com.sun.star.lang.EventObject Source )
+ {
+ // empty the OOoBean and cut the connection
+ stopOOoConnection();
+ }
+
+ /// gets called when the user wants to terminate OOo
+ public void queryTermination( /*IN*/ com.sun.star.lang.EventObject Event )
+ throws com.sun.star.frame.TerminationVetoException
+ {
+ // disallow termination of OOo while a OOoBean exists
+ throw new com.sun.star.frame.TerminationVetoException();
+ }
+
+ /// gets called when OOo terminates
+ public void notifyTermination( /*IN*/ com.sun.star.lang.EventObject Event )
+ {
+ // empty the OOoBean and cut the connection
+ stopOOoConnection();
+ }
+
+ /// watching the connection
+ public void run()
+ {
+ dbgPrint( "EventListener(" + aTag + ").run()" );
+
+ // remote call might hang => watch try
+ CallWatchThread aCallWatchThread =
+ new CallWatchThread( nOOoCallTimeOut, "EventListener(" + aTag + ")" );
+
+ // continue to trying to connect the OOo instance
+ long n = 0;
+ while ( isInterrupted() == false
+ && iConnection != null
+ && iConnection.getComponentContext() != null )
+ {
+ dbgPrint( "EventListener(" + aTag + ").running() #" + ++n );
+
+ // still alive?
+ com.sun.star.lang.XMultiComponentFactory xServiceManager = null;
+ try
+ {
+ // an arbitrary (but cheap) call into OOo
+ xServiceManager = iConnection.getComponentContext().getServiceManager();
+
+ // call successfully performed, restart watch for next loop
+ try
+ {
+ aCallWatchThread.restart();
+ }
+ catch ( java.lang.InterruptedException aExc )
+ {
+ // ignore late interrupt
+ }
+ }
+ catch ( java.lang.RuntimeException aExc )
+ {
+ // hung
+ OfficeConnection iDeadConn = iConnection;
+ iConnection = null;
+ iDeadConn.dispose();
+ }
+
+ // sleep
+ try {
+ sleep(nOOoCheckCycle);
+ }
+ catch ( java.lang.InterruptedException aExc )
+ {
+ dbgPrint("EventListener(" + aTag + ") interupted.");
+ //thread can be ended by EvendListener.end();
+ break;
+ }
+ }
+ }
+ }
+
+}
+
+
+
diff --git a/bean/com/sun/star/comp/beans/OfficeConnection.java b/bean/com/sun/star/comp/beans/OfficeConnection.java
new file mode 100644
index 000000000000..9087b34fae47
--- /dev/null
+++ b/bean/com/sun/star/comp/beans/OfficeConnection.java
@@ -0,0 +1,80 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.comp.beans;
+
+import java.awt.Container;
+
+import com.sun.star.lang.XComponent;
+import com.sun.star.uno.XComponentContext;
+
+/**
+ * This abstract class reprecents a connection to the office
+ * application.
+
+ @deprecated
+ */
+public interface 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/comp/beans/OfficeDocument.java b/bean/com/sun/star/comp/beans/OfficeDocument.java
new file mode 100644
index 000000000000..8e3a970bd03c
--- /dev/null
+++ b/bean/com/sun/star/comp/beans/OfficeDocument.java
@@ -0,0 +1,226 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.comp.beans;
+
+import com.sun.star.uno.UnoRuntime;
+
+//==========================================================================
+/** Wrapper class for service OfficeDocument which emulates the upcoming
+ mode of automatic runtime Java classes to get rid of the need for
+ queryInterface.
+
+ See further information on the wrapping and compatibility limitations
+ in the base class Wrapper.
+
+ @since OOo 2.0.0
+ */
+public class OfficeDocument extends Wrapper
+ implements
+ com.sun.star.frame.XModel,
+ com.sun.star.util.XModifiable,
+ com.sun.star.frame.XStorable,
+ com.sun.star.view.XPrintable
+{
+ private com.sun.star.frame.XModel xModel;
+ private com.sun.star.util.XModifiable xModifiable;
+ private com.sun.star.view.XPrintable xPrintable;
+ private com.sun.star.frame.XStorable xStorable;
+
+ public OfficeDocument( com.sun.star.frame.XModel xModel )
+ {
+ super( xModel );
+
+ this.xModel = xModel;
+ this.xModifiable = (com.sun.star.util.XModifiable)
+ UnoRuntime.queryInterface(
+ com.sun.star.util.XModifiable.class, xModel );
+ this.xPrintable = (com.sun.star.view.XPrintable)
+ UnoRuntime.queryInterface(
+ com.sun.star.view.XPrintable.class, xModel );
+ this.xStorable = (com.sun.star.frame.XStorable)
+ UnoRuntime.queryInterface(
+ com.sun.star.frame.XStorable.class, xModel );
+ }
+
+ //==========================================================
+ // com.sun.star.frame.XModel
+ //----------------------------------------------------------
+
+ public boolean attachResource( /*IN*/String aURL,
+ /*IN*/com.sun.star.beans.PropertyValue[] aArguments )
+ {
+ return xModel.attachResource( aURL, aArguments );
+ }
+
+ public String getURL( )
+ {
+ return xModel.getURL();
+ }
+
+ public com.sun.star.beans.PropertyValue[] getArgs( )
+ {
+ return xModel.getArgs();
+ }
+
+ public void connectController(
+ /*IN*/ com.sun.star.frame.XController xController )
+ {
+ xModel.connectController( xController );
+ }
+
+ public void disconnectController(
+ /*IN*/ com.sun.star.frame.XController xController )
+ {
+ xModel.disconnectController( xController );
+ }
+
+ public void lockControllers( )
+ {
+ xModel.lockControllers();
+ }
+
+ public void unlockControllers( )
+ {
+ xModel.unlockControllers();
+ }
+
+ public boolean hasControllersLocked( )
+ {
+ return xModel.hasControllersLocked();
+ }
+
+ public com.sun.star.frame.XController getCurrentController( )
+ {
+ return xModel.getCurrentController();
+ }
+
+ public void setCurrentController(
+ /*IN*/ com.sun.star.frame.XController xController )
+ throws com.sun.star.container.NoSuchElementException
+ {
+ xModel.setCurrentController( xController );
+ }
+
+ public java.lang.Object getCurrentSelection( )
+ {
+ return xModel.getCurrentSelection();
+ }
+
+ //==========================================================
+ // com.sun.star.util.XModifyBroadcaster
+ //----------------------------------------------------------
+
+ public void addModifyListener(
+ /*IN*/ com.sun.star.util.XModifyListener xListener )
+ {
+ xModifiable.addModifyListener( xListener );
+ }
+
+ public void removeModifyListener(
+ /*IN*/ com.sun.star.util.XModifyListener xListener )
+ {
+ xModifiable.removeModifyListener( xListener );
+ }
+
+ //==========================================================
+ // com.sun.star.util.XModifiable
+ //----------------------------------------------------------
+
+ public boolean isModified( )
+ {
+ return xModifiable.isModified();
+ }
+
+ public void setModified( /*IN*/boolean bModified )
+ throws com.sun.star.beans.PropertyVetoException
+ {
+ xModifiable.setModified( bModified );
+ }
+
+ //==========================================================
+ // com.sun.star.view.XPrintable
+ //----------------------------------------------------------
+
+ public com.sun.star.beans.PropertyValue[] getPrinter( )
+ {
+ return xPrintable.getPrinter();
+ }
+
+ public void setPrinter( /*IN*/ com.sun.star.beans.PropertyValue[] aPrinter )
+ throws com.sun.star.lang.IllegalArgumentException
+ {
+ xPrintable.setPrinter( aPrinter );
+ }
+
+ public void print( /*IN*/ com.sun.star.beans.PropertyValue[] xOptions )
+ throws com.sun.star.lang.IllegalArgumentException
+ {
+ xPrintable.print( xOptions );
+ }
+
+ //==========================================================
+ // com.sun.star.frame.XStorable
+ //----------------------------------------------------------
+
+ public boolean hasLocation( )
+ {
+ return xStorable.hasLocation();
+ }
+
+ public String getLocation( )
+ {
+ return xStorable.getLocation();
+ }
+
+ public boolean isReadonly( )
+ {
+ return xStorable.isReadonly();
+ }
+
+ public void store( )
+ throws com.sun.star.io.IOException
+ {
+ xStorable.store();
+ }
+
+ public void storeAsURL( /*IN*/ String aURL, /*IN*/ com.sun.star.beans.PropertyValue[] aArguments )
+ throws com.sun.star.io.IOException
+ {
+ xStorable.storeAsURL( aURL, aArguments );
+ }
+
+ public void storeToURL( /*IN*/ String aURL, /*IN*/ com.sun.star.beans.PropertyValue[] aArguments )
+ throws com.sun.star.io.IOException
+ {
+ xStorable.storeToURL( aURL, aArguments );
+ }
+
+};
+
+
+
diff --git a/bean/com/sun/star/comp/beans/OfficeWindow.java b/bean/com/sun/star/comp/beans/OfficeWindow.java
new file mode 100644
index 000000000000..0b755ce58cc0
--- /dev/null
+++ b/bean/com/sun/star/comp/beans/OfficeWindow.java
@@ -0,0 +1,56 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.comp.beans;
+
+import java.awt.Component;
+
+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).
+
+ @deprecated
+ */
+public interface 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/comp/beans/SystemWindowException.java b/bean/com/sun/star/comp/beans/SystemWindowException.java
new file mode 100644
index 000000000000..2742eac8c837
--- /dev/null
+++ b/bean/com/sun/star/comp/beans/SystemWindowException.java
@@ -0,0 +1,41 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.comp.beans;
+
+/** indicates that an operation needed a system window,
+ but no system window was aquired yet.
+
+ @see com.sun.star.comp.beans.OOoBean.aquireSystemWindow
+
+ @since OOo 2.0.0
+*/
+public class SystemWindowException extends Exception
+{
+};
+
+
diff --git a/bean/com/sun/star/comp/beans/Wrapper.java b/bean/com/sun/star/comp/beans/Wrapper.java
new file mode 100644
index 000000000000..b5b259752e5f
--- /dev/null
+++ b/bean/com/sun/star/comp/beans/Wrapper.java
@@ -0,0 +1,108 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.comp.beans;
+
+import com.sun.star.uno.UnoRuntime;
+
+//==========================================================================
+/** Wrapper base class for UNO services which emulates the upcoming
+ mode of automatic runtime Java classes to get rid of the need for
+ queryInterface.
+
+ Because its not worth the efford to create a runtime generated wrapper
+ for this purpose, as it might be for OOo 2.0, you still have to use
+ UnoRuntime.queryInterface() for interfaces which are optional or come
+ from a subclass. But for non optional interfaces you can already
+ directly call their methods.
+
+ This wrapper will only work for UNO objects via a bridge, not for
+ direct Java objects.
+
+ @since OOo 2.0.0
+ */
+class Wrapper
+ implements
+ com.sun.star.lib.uno.Proxy,
+ // see the comment in com.sun.star.lib.uno.bridges.java_remote
+ // .java_remote_bridge.mapInterfaceTo for the consequences of this
+ // hack
+ com.sun.star.uno.IQueryInterface,
+ com.sun.star.lang.XComponent
+{
+ private com.sun.star.uno.IQueryInterface xQueryInterface;
+ private com.sun.star.lang.XComponent xComponent;
+
+ public Wrapper( com.sun.star.uno.XInterface xProxy )
+ {
+ xQueryInterface = (com.sun.star.uno.IQueryInterface) xProxy;
+ xComponent = (com.sun.star.lang.XComponent)
+ UnoRuntime.queryInterface(
+ com.sun.star.lang.XComponent.class, xProxy );
+ }
+
+ //==============================================================
+ // com.sun.star.uno.IQueryInterface
+ //--------------------------------------------------------------
+
+ public String getOid()
+ {
+ return xQueryInterface.getOid();
+ }
+
+ public boolean isSame( Object aObject )
+ {
+ return xQueryInterface.isSame( aObject );
+ }
+
+ public Object queryInterface( com.sun.star.uno.Type aType )
+ {
+//System.err.println( "Wrapper::queryInterface(" + aType + ")" );
+ return xQueryInterface.queryInterface( aType );
+ }
+
+ //==============================================================
+ // com.sun.star.lang.XComponent
+ //--------------------------------------------------------------
+
+ public void dispose( )
+ {
+ xComponent.dispose();
+ }
+
+ public void addEventListener( /*IN*/ com.sun.star.lang.XEventListener xListener )
+ {
+ xComponent.addEventListener( xListener );
+ }
+
+ public void removeEventListener( /*IN*/ com.sun.star.lang.XEventListener xListener )
+ {
+ xComponent.removeEventListener( xListener );
+ }
+};
+
+
diff --git a/bean/com/sun/star/comp/beans/makefile.mk b/bean/com/sun/star/comp/beans/makefile.mk
new file mode 100644
index 000000000000..31781d6f0cb3
--- /dev/null
+++ b/bean/com/sun/star/comp/beans/makefile.mk
@@ -0,0 +1,75 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org 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 version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ = ..$/..$/..$/..$/..
+PRJNAME = beans
+TARGET = com_sun_star_comp_beans
+PACKAGE = com$/sun$/star$/comp$/beans
+
+# --- Settings -----------------------------------------------------
+.INCLUDE: settings.mk
+.IF "$(L10N_framework)"==""
+.IF "$(OS)"=="MACOSX"
+
+dummy:
+ @echo "Nothing to build for OS $(OS)"
+
+.ELSE # "$(OS)"=="MACOSX"
+
+JARFILES = ridl.jar unoil.jar jurt.jar juh.jar
+
+# --- Sources --------------------------------------------------------
+
+JAVAFILES= \
+ ContainerFactory.java \
+ Controller.java \
+ Frame.java \
+ HasConnectionException.java \
+ InvalidArgumentException.java \
+ JavaWindowPeerFake.java \
+ LocalOfficeConnection.java \
+ LocalOfficeWindow.java \
+ NativeConnection.java \
+ NativeService.java \
+ NoConnectionException.java \
+ NoDocumentException.java \
+ OfficeConnection.java \
+ OfficeDocument.java \
+ OfficeWindow.java \
+ OOoBean.java \
+ SystemWindowException.java \
+ Wrapper.java \
+ CallWatchThread.java
+
+JAVACLASSFILES= $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
+
+.ENDIF
+
+# --- Targets ------------------------------------------------------
+.ENDIF # L10N_framework
+
+.INCLUDE : target.mk
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..ef39ea6d7ccc
--- /dev/null
+++ b/bean/native/unix/com_sun_star_beans_LocalOfficeWindow.c
@@ -0,0 +1,99 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/Intrinsic.h>
+
+#include "jni.h"
+
+// Workaround for problematic IBM JDK 1.6.0 on ppc
+#ifndef _JNI_IMPORT_OR_EXPORT_
+#define _JNI_IMPORT_OR_EXPORT_
+#endif
+
+#include "jawt_md.h"
+#include "jawt.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
+
+JNIEXPORT jlong JNICALL Java_com_sun_star_comp_beans_LocalOfficeWindow_getNativeWindow
+ (JNIEnv * env, jobject obj_this);
+
+/*****************************************************************************/
+/*
+ * 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)
+{
+ (void) env; /* avoid warning about unused parameter */
+ (void) obj_this; /* avoid warning about unused parameter */
+ 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)
+{
+ (void) env; /* avoid warning about unused parameter */
+ (void) obj_this; /* avoid warning about unused parameter */
+ return Java_com_sun_star_comp_beans_LocalOfficeWindow_getNativeWindow(env, obj_this);
+}
+
+
+
+
+
+
+
+
+
+
+
diff --git a/bean/native/unix/com_sun_star_comp_beans_LocalOfficeWindow.c b/bean/native/unix/com_sun_star_comp_beans_LocalOfficeWindow.c
new file mode 100644
index 000000000000..2e6670befd70
--- /dev/null
+++ b/bean/native/unix/com_sun_star_comp_beans_LocalOfficeWindow.c
@@ -0,0 +1,147 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/Intrinsic.h>
+
+#include "jni.h"
+
+// Workaround for problematic IBM JDK 1.6.0 on ppc
+#ifndef _JNI_IMPORT_OR_EXPORT_
+#define _JNI_IMPORT_OR_EXPORT_
+#endif
+
+#include "jawt_md.h"
+#include "jawt.h"
+
+
+#define SYSTEM_WIN32 1
+#define SYSTEM_WIN16 2
+#define SYSTEM_JAVA 3
+#define SYSTEM_OS2 4
+#define SYSTEM_MAC 5
+#define SYSTEM_XWINDOW 6
+
+
+/* type must be something like java/lang/RuntimeException
+ */
+static void ThrowException(JNIEnv * env, char const * type, char const * msg) {
+ jclass c;
+ (*env)->ExceptionClear(env);
+ c = (*env)->FindClass(env, type);
+ if (c == NULL) {
+ (*env)->ExceptionClear(env);
+ (*env)->FatalError(
+ env, "JNI FindClass failed");
+ }
+ if ((*env)->ThrowNew(env, c, msg) != 0) {
+ (*env)->ExceptionClear(env);
+ (*env)->FatalError(env, "JNI ThrowNew failed");
+ }
+}
+
+/*****************************************************************************/
+/*
+ * Class: com_sun_star_comp_beans_LocalOfficeWindow
+ * Method: getNativeWindowSystemType
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_sun_star_comp_beans_LocalOfficeWindow_getNativeWindowSystemType
+ (JNIEnv * env, jobject obj_this)
+{
+ (void) env; /* avoid warning about unused parameter */
+ (void) obj_this; /* avoid warning about unused parameter */
+ return (SYSTEM_XWINDOW);
+}
+
+
+/*****************************************************************************/
+/*
+ * Class: com_sun_star_beans_LocalOfficeWindow
+ * Method: getNativeWindow
+ * Signature: ()J
+ */
+JNIEXPORT jlong JNICALL Java_com_sun_star_comp_beans_LocalOfficeWindow_getNativeWindow
+ (JNIEnv * env, jobject obj_this)
+{
+ jboolean result;
+ jint lock;
+
+ JAWT awt;
+ JAWT_DrawingSurface* ds;
+ JAWT_DrawingSurfaceInfo* dsi;
+ JAWT_X11DrawingSurfaceInfo* dsi_x11;
+
+ Drawable drawable;
+ Display* display;
+
+ /* Get the AWT */
+ awt.version = JAWT_VERSION_1_3;
+ result = JAWT_GetAWT(env, &awt);
+ if (result == JNI_FALSE)
+ ThrowException(env, "java/lang/RuntimeException", "JAWT_GetAWT failed");
+
+ /* Get the drawing surface */
+ if ((ds = awt.GetDrawingSurface(env, obj_this)) == NULL)
+ return 0L;
+
+ /* Lock the drawing surface */
+ lock = ds->Lock(ds);
+ if ( (lock & JAWT_LOCK_ERROR) != 0)
+ ThrowException(env, "java/lang/RuntimeException",
+ "Could not get AWT drawing surface.");
+
+ /* Get the drawing surface info */
+ dsi = ds->GetDrawingSurfaceInfo(ds);
+
+ /* Get the platform-specific drawing info */
+ dsi_x11 = (JAWT_X11DrawingSurfaceInfo*)dsi->platformInfo;
+
+ drawable = dsi_x11->drawable;
+ display = dsi_x11->display;
+
+ /* Free the drawing surface info */
+ ds->FreeDrawingSurfaceInfo(dsi);
+ /* Unlock the drawing surface */
+ ds->Unlock(ds);
+ /* Free the drawing surface */
+ awt.FreeDrawingSurface(ds);
+
+ return ((jlong)drawable);
+}
+
+
+
+
+
+
+
+
+
+
+
diff --git a/bean/native/unix/makefile.mk b/bean/native/unix/makefile.mk
new file mode 100644
index 000000000000..c2d4ecfcbc85
--- /dev/null
+++ b/bean/native/unix/makefile.mk
@@ -0,0 +1,39 @@
+PRJ=..$/..
+
+PRJNAME=beans
+TARGET=officebean
+ENABLE_EXCEPTIONS=TRUE
+NO_DEFAULT_STL=TRUE
+NO_BSYMBOLIC=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files --------------------------------------------------------
+
+.IF "$(SOLAR_JAVA)"=="" || "$(OS)"=="MACOSX"
+nojava:
+ @echo "Not building odk/source/OOSupport because Java has been disabled"
+.ENDIF
+.IF "$(OS)"=="MACOSX"
+dummy:
+ @echo "Nothing to build for OS $(OS)"
+.ENDIF
+
+SLOFILES = \
+ $(SLO)$/com_sun_star_comp_beans_LocalOfficeWindow.obj \
+ $(SLO)$/com_sun_star_beans_LocalOfficeWindow.obj
+
+SHL1TARGET=$(TARGET)
+SHL1LIBS= $(SLB)$/$(TARGET).lib
+SHL1STDLIBS=$(AWTLIB)
+SHL1NOCHECK=TRUE
+
+.IF "$(OS)" == "LINUX"
+SHL1STDLIBS+=-lstdc++
+.ENDIF
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
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..288cf80401df
--- /dev/null
+++ b/bean/native/win32/com_sun_star_beans_LocalOfficeWindow.c
@@ -0,0 +1,102 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#if defined _MSC_VER
+#pragma warning(push, 1)
+#endif
+#include <windows.h>
+#if defined _MSC_VER
+#pragma warning(pop)
+#endif
+
+#include "jawt.h"
+
+#if defined _MSC_VER
+#pragma warning(push, 1)
+#endif
+#include "jawt_md.h"
+#if defined _MSC_VER
+#pragma warning(pop)
+#endif
+
+#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 );
+
+JNIEXPORT jlong JNICALL Java_com_sun_star_comp_beans_LocalOfficeWindow_getNativeWindow
+ (JNIEnv * env, jobject obj_this);
+
+/*****************************************************************************/
+/*
+ * 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)
+{
+ (void) env; // unused
+ (void) obj_this; // unused
+ 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/com_sun_star_comp_beans_LocalOfficeWindow.c b/bean/native/win32/com_sun_star_comp_beans_LocalOfficeWindow.c
new file mode 100644
index 000000000000..bf01745f9886
--- /dev/null
+++ b/bean/native/win32/com_sun_star_comp_beans_LocalOfficeWindow.c
@@ -0,0 +1,217 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#if defined _MSC_VER
+#pragma warning(push, 1)
+#endif
+#include <windows.h>
+#if defined _MSC_VER
+#pragma warning(pop)
+#endif
+
+#include "jawt.h"
+
+#if defined _MSC_VER
+#pragma warning(push, 1)
+#endif
+#include "jawt_md.h"
+#if defined _MSC_VER
+#pragma warning(pop)
+#endif
+
+#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 );
+
+
+
+/* type must be something like java/lang/RuntimeException
+ */
+static void ThrowException(JNIEnv * env, char const * type, char const * msg) {
+ jclass c;
+ (*env)->ExceptionClear(env);
+ c = (*env)->FindClass(env, type);
+ if (c == NULL) {
+ (*env)->ExceptionClear(env);
+ (*env)->FatalError(
+ env, "JNI FindClass failed");
+ }
+ if ((*env)->ThrowNew(env, c, msg) != 0) {
+ (*env)->ExceptionClear(env);
+ (*env)->FatalError(env, "JNI ThrowNew failed");
+ }
+}
+
+
+/*****************************************************************************/
+/*
+ * Class: com_sun_star_comp_beans_LocalOfficeWindow
+ * Method: getNativeWindowSystemType
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_sun_star_comp_beans_LocalOfficeWindow_getNativeWindowSystemType
+ (JNIEnv * env, jobject obj_this)
+{
+ (void) env; // unused
+ (void) obj_this; // unused
+ return (SYSTEM_WIN32);
+}
+
+
+/*****************************************************************************/
+/*
+ * Class: com_sun_star_comp_beans_LocalOfficeWindow
+ * Method: getNativeWindow
+ * Signature: ()J
+ */
+JNIEXPORT jlong JNICALL Java_com_sun_star_comp_beans_LocalOfficeWindow_getNativeWindow
+ (JNIEnv * env, jobject obj_this)
+{
+ jboolean result;
+ jint lock;
+
+ JAWT awt;
+ JAWT_DrawingSurface* ds;
+ JAWT_DrawingSurfaceInfo* dsi;
+ JAWT_Win32DrawingSurfaceInfo* dsi_win;
+ HDC hdc;
+ HWND hWnd;
+ LONG hFuncPtr;
+
+ /* Get the AWT */
+ awt.version = JAWT_VERSION_1_3;
+ result = JAWT_GetAWT(env, &awt);
+ if (result == JNI_FALSE)
+ ThrowException(env, "java/lang/RuntimeException", "JAWT_GetAWT failed");
+
+ /* Get the drawing surface */
+ if ((ds = awt.GetDrawingSurface(env, obj_this)) == NULL)
+ return 0L;
+
+ /* Lock the drawing surface */
+ lock = ds->Lock(ds);
+ if ( (lock & JAWT_LOCK_ERROR) != 0)
+ ThrowException(env, "java/lang/RuntimeException",
+ "Could not get AWT drawing surface.");
+
+ /* Get the drawing surface info */
+ dsi = ds->GetDrawingSurfaceInfo(ds);
+
+ /* Get the platform-specific drawing info */
+ dsi_win = (JAWT_Win32DrawingSurfaceInfo*)dsi->platformInfo;
+
+ hdc = dsi_win->hdc;
+
+ hWnd = dsi_win->hwnd;
+
+ /* Free the drawing surface info */
+ ds->FreeDrawingSurfaceInfo(dsi);
+ /* Unlock the drawing surface */
+ ds->Unlock(ds);
+ /* Free the drawing surface */
+ awt.FreeDrawingSurface(ds);
+
+ /* Register own window procedure
+ Do it one times only! Otherwhise
+ multiple instances will be registered
+ and calls on such construct produce
+ a stack overflow.
+ */
+ if (GetProp( hWnd, OLD_PROC_KEY )==0)
+ {
+ hFuncPtr = SetWindowLong( hWnd, GWL_WNDPROC, (DWORD)OpenOfficeWndProc );
+ SetProp( hWnd, OLD_PROC_KEY, (HANDLE)hFuncPtr );
+ }
+
+ return ((jlong)hWnd);
+}
+
+
+static LRESULT APIENTRY OpenOfficeWndProc(
+ HWND hWnd,
+ UINT uMsg,
+ WPARAM wParam,
+ LPARAM lParam)
+{
+ switch(uMsg)
+ {
+ case WM_PARENTNOTIFY: {
+ if (wParam == WM_CREATE) {
+ RECT rect;
+ HWND hChild = (HWND) lParam;
+
+ GetClientRect(hWnd, &rect);
+
+ SetWindowPos(hChild,
+ NULL,
+ rect.left,
+ rect.top,
+ rect.right - rect.left,
+ rect.bottom - rect.top,
+ SWP_NOZORDER);
+ }
+ break;
+ }
+ case WM_SIZE: {
+ WORD newHeight = HIWORD(lParam);
+ WORD newWidth = LOWORD(lParam);
+ HWND hChild = GetWindow(hWnd, GW_CHILD);
+
+ if (hChild != NULL) {
+ SetWindowPos(hChild, NULL, 0, 0, newWidth, newHeight, SWP_NOZORDER);
+ }
+ break;
+ }
+ }
+
+#if defined _MSC_VER
+#pragma warning(push)
+#pragma warning(disable: 4152) /* function/data pointer conversion: */
+#endif
+ return CallWindowProc(GetProp(hWnd, OLD_PROC_KEY),
+ hWnd, uMsg, wParam, lParam);
+#if defined _MSC_VER
+#pragma warning(pop)
+#endif
+}
+
+
+
+
+
+
+
+
+
+
diff --git a/bean/native/win32/makefile.mk b/bean/native/win32/makefile.mk
new file mode 100644
index 000000000000..9ccd0a0f3ccd
--- /dev/null
+++ b/bean/native/win32/makefile.mk
@@ -0,0 +1,34 @@
+PRJ=..$/..
+
+PRJNAME=odk
+TARGET=officebean
+ENABLE_EXCEPTIONS=TRUE
+NO_DEFAULT_STL=TRUE
+NO_BSYMBOLIC=TRUE
+USE_DEFFILE=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files --------------------------------------------------------
+
+SLOFILES = \
+ $(SLO)$/com_sun_star_comp_beans_LocalOfficeWindow.obj \
+ $(SLO)$/com_sun_star_beans_LocalOfficeWindow.obj
+
+SHL1TARGET=$(TARGET)
+SHL1LIBS= $(SLB)$/$(TARGET).lib
+#SHL1IMPLIB= i$(TARGET)
+SHL1STDLIBS=$(AWTLIB) $(SALLIB)
+
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+
+DEF1NAME= $(SHL1TARGET)
+DEF1EXPORTFILE= $(TARGET).dxp
+DEF1DES=officebean
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/bean/native/win32/officebean.dxp b/bean/native/win32/officebean.dxp
new file mode 100644
index 000000000000..9a01b090f2ad
--- /dev/null
+++ b/bean/native/win32/officebean.dxp
@@ -0,0 +1,4 @@
+Java_com_sun_star_comp_beans_LocalOfficeWindow_getNativeWindowSystemType
+Java_com_sun_star_comp_beans_LocalOfficeWindow_getNativeWindow
+Java_com_sun_star_beans_LocalOfficeWindow_getNativeWindowSystemType
+Java_com_sun_star_beans_LocalOfficeWindow_getNativeWindow \ No newline at end of file
diff --git a/bean/prj/build.lst b/bean/prj/build.lst
new file mode 100644
index 000000000000..3767e8fff387
--- /dev/null
+++ b/bean/prj/build.lst
@@ -0,0 +1,6 @@
+ob bean : javaunohelper jurt ridljar unoil offapi udkapi NULL
+ob bean\com\sun\star\comp\beans nmake - all ob_beanjava NULL
+ob bean\com\sun\star\beans nmake - all ob_legacybeanjava ob_beanjava NULL
+ob bean\native\win32 nmake - n ob_beanwin32 NULL
+ob bean\native\unix nmake - u ob_beanunix NULL
+ob bean\util nmake - all ob_util ob_beanjava ob_legacybeanjava ob_beanwin32.n ob_beanunix.u NULL
diff --git a/bean/prj/d.lst b/bean/prj/d.lst
new file mode 100644
index 000000000000..b0478b3d4cd4
--- /dev/null
+++ b/bean/prj/d.lst
@@ -0,0 +1,5 @@
+..\%__SRC%\class\officebean.jar %_DEST%\bin%_EXT%\officebean.jar
+
+..\%__SRC%\bin\officebean.dll %_DEST%\bin%_EXT%\officebean.dll
+..\%__SRC%\lib\libofficebean.so %_DEST%\lib%_EXT%\libofficebean.so
+..\%__SRC%\lib\*officebean.dylib %_DEST%\lib%_EXT%\*officebean.dylib
diff --git a/bean/qa/complex/OOoBeanTest.java b/bean/qa/complex/OOoBeanTest.java
new file mode 100644
index 000000000000..2d038e8b37af
--- /dev/null
+++ b/bean/qa/complex/OOoBeanTest.java
@@ -0,0 +1,656 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package complex;
+
+
+import complexlib.ComplexTestCase;
+import java.io.*;
+import java.awt.Rectangle;
+import java.awt.Insets;
+import java.awt.BorderLayout;
+import java.awt.Dimension;
+import java.awt.image.BufferedImage;
+import java.awt.image.PixelGrabber;
+import java.awt.GridBagLayout;
+import java.awt.GridBagConstraints;
+import java.awt.event.*;
+import java.awt.Frame;
+import java.awt.Toolkit;
+import java.awt.Robot;
+import java.awt.event.KeyEvent;
+import java.awt.Button;
+import javax.imageio.ImageIO;
+import javax.imageio.stream.FileImageOutputStream;
+import com.sun.star.comp.beans.OOoBean;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.text.XTextDocument;
+
+import java.awt.*;
+
+public class OOoBeanTest extends ComplexTestCase
+{
+
+ public String[] getTestMethodNames()
+ {
+ // TODO think about trigger of sub-tests from outside
+ return new String[]
+ {
+ "test1",
+ "test2",
+ "test3",
+ "test4",
+ "test5",
+ "test6",
+ "test6a",
+ "test7",
+ "test8"
+ };
+ }
+
+ /** For X-Windows we need to prolong the time between painting windows. Because
+ it takes longer than on Windows.
+ */
+ int getSleepTime(int time)
+ {
+ int ret = time;
+ if (isWindows() == false)
+ return time * 5;
+ return time;
+ }
+
+ /** If it cannot be determined if we run on Windows then we assume
+ that we do not.
+ */
+ boolean isWindows()
+ {
+ boolean ret = false;
+ String os = System.getProperty("os.name");
+ if (os != null)
+ {
+ os = os.trim();
+ if (os.indexOf("Win") == 0)
+ ret = true;
+ }
+ return ret;
+ }
+
+ public String getText(OOoBean bean) throws Exception
+ {
+ com.sun.star.frame.XModel model = (com.sun.star.frame.XModel)bean.getDocument();
+ com.sun.star.text.XTextDocument myDoc =
+ (XTextDocument) UnoRuntime.queryInterface(com.sun.star.text.XTextDocument.class,
+ model);
+ com.sun.star.text.XText xText = myDoc.getText();
+ return xText.getString();
+ }
+
+ /** 1.Create a Java frame
+ * 2.Add OOoBean (no document loaded yet)
+ * 3.Show frame
+ * 4.Load document
+ */
+ public void test1() throws Exception
+ {
+ WriterFrame f = null;
+ try
+ {
+ f = new WriterFrame(100 ,100, 500 ,400, false);
+ f.setText("OOoBean test.");
+ Thread.sleep(1000);
+ }
+ finally
+ {
+ if (f != null)
+ f.dispose();
+ }
+ }
+
+ /** Sizing, painting
+ */
+ public void test2() throws Exception
+ {
+ WriterFrame f = null;
+ ScreenComparer capturer = null;
+ try
+ {
+ f = new WriterFrame(100, 100, 500,500, false);
+ if (f.checkUnoFramePosition() == false)
+ failed("Sizing error: Client are of Java frame does not match the UNO window.", true);
+ capturer = new ScreenComparer(100, 100, 500, 500);
+
+ //Minimize Window and back
+ f.goToStart();
+ f.pageDown();
+ Thread.sleep(1000);
+ for (int i = 0; i < 3; i++)
+ {
+ capturer.reset();
+ capturer.grabOne(f.getClientArea());
+ f.setExtendedState(Frame.ICONIFIED);
+ Thread.sleep(getSleepTime(200));
+ if (f.checkUnoFramePosition() == false)
+ failed("Sizing error: Frame was iconified.", true);
+ f.setExtendedState(Frame.NORMAL);
+ Thread.sleep(getSleepTime(200));
+ if (f.checkUnoFramePosition() == false)
+ failed("Sizing error: Frame size set back to normal after it was iconified.", true);
+ capturer.grabTwo(f.getClientArea());
+ if (capturer.compare() == false)
+ {
+ failed("Painting error: Minimize (iconify) frame and back to normal size.", true);
+ capturer.writeImages();
+ }
+ }
+
+ //Maximize Window and back to normal
+ for (int i = 0; i < 3; i++)
+ {
+ capturer.reset();
+ capturer.grabOne(f.getClientArea());
+ f.setExtendedState(Frame.MAXIMIZED_BOTH);
+ Thread.sleep(getSleepTime(200));
+ if (f.checkUnoFramePosition() == false)
+ failed("Sizing error: Frame maximized.", true);
+ f.setExtendedState(Frame.NORMAL);
+ Thread.sleep(getSleepTime(200));
+ if (f.checkUnoFramePosition() == false)
+ failed("Sizing error: Frame set from maximized to normal.", true);
+ capturer.grabTwo(f.getClientArea());
+ if (capturer.compare() == false)
+ {
+ failed("Painting error: Maximize frame and back to normal size", true);
+ capturer.writeImages();
+ }
+ }
+
+ //move Window top left
+ capturer.reset();
+ capturer.grabOne(f.getClientArea());
+ Rectangle oldPosition = f.getBounds();
+ f.setBounds(0, 0, oldPosition.width, oldPosition.height);
+ Thread.sleep(getSleepTime(200));
+ if (f.checkUnoFramePosition() == false)
+ failed("Sizing error: Frame moved.", true);
+
+ capturer.grabTwo(f.getClientArea());
+ if (capturer.compare() == false)
+ {
+ failed("Painting error: Move frame to a different position.", true);
+ capturer.writeImages();
+ }
+
+ //move Window down
+ Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
+ int maxY = dim.height - f.getBounds().height;
+
+ int curY = 0;
+ while (curY < maxY)
+ {
+ capturer.reset();
+ capturer.grabOne(f.getClientArea());
+ oldPosition = f.getBounds();
+ f.setBounds(0, curY, oldPosition.width, oldPosition.height);
+ capturer.grabTwo(f.getClientArea());
+ if (capturer.compare() == false)
+ {
+ failed("Painting error: Move frame to a different position.", true);
+ capturer.writeImages();
+ }
+ curY+= 50;
+ Thread.sleep(getSleepTime(200));
+ }
+
+ //obscure the window and make it visible again
+
+ oldPosition = f.getBounds();
+
+ Rectangle pos = new Rectangle(oldPosition.x - 50, oldPosition.y - 50,
+ oldPosition.width, oldPosition.height);
+ Frame coverFrame = new Frame();
+ coverFrame.setBounds(pos);
+ capturer.reset();
+ capturer.grabOne(f.getClientArea());
+
+ for (int i = 0; i < 3; i++)
+ {
+ coverFrame.setVisible(true);
+ Thread.sleep(getSleepTime(200));
+ f.toFront();
+ Thread.sleep(getSleepTime(200));
+ if (f.checkUnoFramePosition() == false)
+ failed("Sizing error: Frame moved from back to front.", true);
+
+ capturer.grabTwo(f.getClientArea());
+ if (capturer.compare() == false)
+ {
+ failed("Painting error: Move frame to back and to front.", true);
+ capturer.writeImages();
+ }
+ }
+
+ coverFrame.dispose();
+ }
+ finally
+ {
+ if (f != null)
+ f.dispose();
+ }
+ }
+
+ /**
+ 1. Create a OOoBean
+ 2. Load a document
+ 3. Create Frame (do not show yet)
+ 4. Add OOoBean to Frame
+ 5. Show Frame
+ */
+ public void test3() throws Exception
+ {
+ WriterFrame f = null;
+ try
+ {
+ f = new WriterFrame(100, 100, 500, 300, true);
+ if (f.checkUnoFramePosition() == false)
+ failed("Sizing error.", true);
+
+ }
+ finally
+ {
+ if (f != null)
+ f.dispose();
+ }
+ }
+
+ /** Test repeated OOoBean.aquireSystemWindow and OOoBean.releaseSystemWindow
+ * calls.
+ */
+ public void test4() throws Exception
+ {
+ WriterFrame f = null;
+ try
+ {
+ f = new WriterFrame(100, 100, 500, 300, false);
+ OOoBean b = f.getBean();
+ for (int i = 0; i < 100; i++)
+ {
+ b.releaseSystemWindow();
+ b.aquireSystemWindow();
+ }
+ if (f.checkUnoFramePosition() == false)
+ failed("Sizing error.", true);
+ }
+ finally
+ {
+ if (f != null)
+ f.dispose();
+ if (isWindows() == false)
+ Thread.sleep(10000);
+ }
+ }
+
+ /** Adding and removing the bean to a Java frame multiple times.
+ * Test painting and sizing.
+ */
+ public void test5() throws Exception
+ {
+ WriterFrame f = null;
+ try
+ {
+ f = new WriterFrame(100, 100, 500, 400, false);
+ f.goToStart();
+ f.pageDown();
+ Thread.sleep(1000);
+
+ ScreenComparer capturer = new ScreenComparer(100,100,500,400);
+ capturer.grabOne();
+ for (int i = 0; i < 100; i++)
+ {
+ f.removeOOoBean();
+ f.addOOoBean();
+ }
+
+ f.goToStart();
+ f.pageDown();
+ Thread.sleep(getSleepTime(200));
+ capturer.grabTwo();
+
+ if (capturer.compare() == false)
+ {
+ failed("Painting error: adding and removing OOoBean " +
+ "repeatedly to java.lang.Frame.", true);
+ capturer.writeImages();
+ }
+
+ if (f.checkUnoFramePosition() == false)
+ failed("Sizing error.", true);
+
+ }
+ finally
+ {
+ if (f != null)
+ f.dispose();
+ if (isWindows() == false)
+ Thread.sleep(10000);
+ }
+ }
+
+
+ /** Test focus (i49454). After repeatedly adding and removing the bean to a window
+ * it should still be possible to enter text in the window. This does not
+ * work all the time on Windows. This is probably a timing problem. When using
+ * Thread.sleep (position #1) then it should work.
+ */
+ public void test6() throws Exception
+ {
+ for (int j = 0; j < 10; j++)
+ {
+ final OOoBean bean = new OOoBean();
+ java.awt.Frame frame = null;
+ bean.setOOoCallTimeOut(10000);
+ try {
+ frame = new java.awt.Frame("OpenOffice.org Demo");
+ frame.add(bean, BorderLayout.CENTER);
+ frame.pack();
+ frame.setSize(600,300);
+ frame.show();
+ bean.loadFromURL("private:factory/swriter", null);
+ // #1
+ Thread.sleep(1000);
+
+ StringBuffer buf = new StringBuffer(1000);
+ for (int i = 0; i < 1; i++)
+ {
+// Thread.sleep(1000);
+ bean.releaseSystemWindow();
+ frame.remove(bean);
+// frame.validate();
+// Thread.sleep(1000);
+ frame.add(bean, BorderLayout.CENTER);
+ bean.aquireSystemWindow();
+// frame.validate();
+ }
+
+ if (isWindows() == false)
+ Thread.sleep(5000);
+
+ Robot roby = new Robot();
+ roby.keyPress(KeyEvent.VK_H);
+ roby.keyRelease(KeyEvent.VK_H);
+ buf.append("h");
+
+ String s = getText(bean);
+ if ( ! s.equals(buf.toString()))
+ {
+ failed("Focus error: After removing and adding the bean, the" +
+ "office window does not receive keyboard input.\n" +
+ "Try typing in the window, you've got 30s!!! This " +
+ "test may not work with Linux/Solaris", true);
+ Thread.sleep(30000);
+ break;
+ }
+ else
+ {
+ Thread.sleep(2000);
+ }
+
+ } finally {
+ bean.stopOOoConnection();
+ frame.dispose();
+ }
+ }
+ }
+
+ /** Tests focus problem just like test6, but the implementation is a little
+ * different. The bean is added and removed from withing the event dispatch
+ * thread. Using Thread.sleep at various points (#1, #2, #3) seems to workaround
+ * the problem.
+ */
+ public void test6a() throws Exception
+ {
+ for (int j = 0; j < 50; j++)
+ {
+ final OOoBean bean = new OOoBean();
+ final java.awt.Frame frame = new Frame("Openoffice.org");
+ bean.setOOoCallTimeOut(10000);
+
+ try {
+ frame.add(bean, BorderLayout.CENTER);
+ frame.pack();
+ frame.setSize(600,400);
+ frame.show();
+ bean.loadFromURL("private:factory/swriter", null);
+ frame.validate();
+ // #1
+ Thread.sleep(1000);
+ StringBuffer buf = new StringBuffer(1000);
+ int i = 0;
+
+ for (; i < 1; i++)
+ {
+ EventQueue q = Toolkit.getDefaultToolkit().getSystemEventQueue();
+ q.invokeAndWait( new Runnable() {
+ public void run() {
+ try {
+
+ bean.releaseSystemWindow();
+ frame.remove(bean);
+ frame.validate();
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ }
+ });
+ // #2
+ Thread.sleep(1000);
+ q.invokeAndWait( new Runnable() {
+ public void run() {
+ try {
+
+ frame.add(bean, BorderLayout.CENTER);
+ bean.aquireSystemWindow();
+ frame.validate();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ });
+
+ // #3
+ Thread.sleep(1000);
+ }
+
+ if (isWindows() == false)
+ Thread.sleep(5000);
+
+ Robot roby = new Robot();
+ roby.mouseMove(300, 200);
+ roby.waitForIdle();
+ roby.mousePress(InputEvent.BUTTON1_MASK);
+ roby.waitForIdle();
+ roby.mouseRelease(InputEvent.BUTTON1_MASK);
+ roby.waitForIdle();
+ roby.keyPress(KeyEvent.VK_H);
+ roby.waitForIdle();
+ roby.keyRelease(KeyEvent.VK_H);
+ roby.waitForIdle();
+
+ buf.append("h");
+ Thread.sleep(1000);
+ String s = getText(bean);
+ System.out.println(" getText: " + s);
+ if ( ! s.equals(buf.toString()))
+ {
+ roby.mousePress(InputEvent.BUTTON1_MASK);
+ roby.waitForIdle();
+ roby.mouseRelease(InputEvent.BUTTON1_MASK);
+ roby.waitForIdle();
+ roby.keyPress(KeyEvent.VK_H);
+ roby.waitForIdle();
+ roby.keyRelease(KeyEvent.VK_H);
+ roby.waitForIdle();
+
+ String sH = "h";
+ Thread.sleep(1000);
+ String s2 = getText(bean);
+
+ if ( ! sH.equals(s2))
+ {
+ failed("Focus error: After removing and adding the bean, the" +
+ "office window does not receive keyboard input.\n" +
+ "Try typing in the window, you've got 30s!!! This " +
+ "test may not work with Linux/Solaris", true);
+ System.out.println("j: " + j + " i: " + i);
+ Thread.sleep(30000);
+ break;
+ }
+ }
+ else
+ {
+ // Thread.sleep(2000);
+ }
+
+ } finally {
+ bean.stopOOoConnection();
+ frame.dispose();
+ }
+ }
+ }
+
+ /** Repeatedly loading a document in one and the same OOoBean instance.
+ */
+ public void test7() throws Exception
+ {
+ WriterFrame f = null;
+ try
+ {
+ f = new WriterFrame(100 ,100, 500 ,400, false);
+ String text = "OOoBean test.";
+
+ for (int i = 0; i < 10; i++)
+ {
+ f.getBean().clear();
+ f.getBean().loadFromURL("private:factory/swriter", null);
+ f.setText(text);
+ f.goToStart();
+ f.validate();
+
+ if (text.equals(f.getText()) == false)
+ failed("Repeated loading of a document failed.");
+ Thread.sleep(1000);
+ }
+ }
+ finally
+ {
+ if (f != null)
+ f.dispose();
+ }
+ }
+
+ /** Using multiple instances of OOoBean at the same time
+ */
+ public void test8() throws Exception
+ {
+ OOoBean bean1 = new OOoBean();
+ BeanPanel bp1 = new BeanPanel(bean1);
+ OOoBean bean2 = new OOoBean();
+ BeanPanel bp2 = new BeanPanel(bean2);
+ OOoBean bean3 = new OOoBean();
+ BeanPanel bp3 = new BeanPanel(bean3);
+ OOoBean bean4 = new OOoBean();
+ BeanPanel bp4 = new BeanPanel(bean4);
+
+ try
+ {
+ Frame f = new Frame("OOoBean example with several instances");
+ f.setLayout(new GridBagLayout());
+ GridBagConstraints c = new GridBagConstraints();
+ c.fill = GridBagConstraints.HORIZONTAL;
+ c.weightx = 0.5;
+
+ c.insets = new Insets(0, 0, 0, 10);
+ c.gridx = 0;
+ c.gridy = 0;
+ f.add(bp1, c);
+
+ c.gridx = 1;
+ c.insets = new Insets(0, 0, 0, 0);
+ f.add(bp2, c);
+
+ c.gridx = 0;
+ c.gridy = 1;
+ c.insets = new Insets(10, 0, 0, 10);
+ f.add(bp3, c);
+
+ c.gridx = 1;
+ c.gridy = 1;
+ c.insets = new Insets(10, 0, 0, 0);
+ f.add(bp4, c);
+
+ f.pack();
+ f.setBounds(0, 0, 1000, 600);
+ f.setVisible(true);
+ try {
+ bean1.loadFromURL("private:factory/swriter", null);
+ bean2.loadFromURL("private:factory/swriter", null);
+ bean3.loadFromURL("private:factory/swriter", null);
+ bean4.loadFromURL("private:factory/swriter", null);
+ } catch( Exception e)
+ {
+ e.printStackTrace();
+ }
+ f.validate();
+
+ Thread.sleep(10000);
+ }
+ finally
+ {
+ bean1.stopOOoConnection();
+ bean2.stopOOoConnection();
+ bean3.stopOOoConnection();
+ bean4.stopOOoConnection();
+ }
+ }
+
+ class BeanPanel extends Panel
+ {
+ public BeanPanel(OOoBean b)
+ {
+ setLayout(new BorderLayout());
+ add(b, BorderLayout.CENTER);
+ }
+ public Dimension getPreferredSize()
+ {
+ Container c = getParent();
+ return new Dimension(200, 200);
+ }
+ }
+
+}
+
+
diff --git a/bean/qa/complex/ScreenComparer.java b/bean/qa/complex/ScreenComparer.java
new file mode 100644
index 000000000000..a2547a763c58
--- /dev/null
+++ b/bean/qa/complex/ScreenComparer.java
@@ -0,0 +1,233 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package complex;
+
+
+import complexlib.ComplexTestCase;
+import java.io.File;
+import java.awt.Rectangle;
+import java.awt.BorderLayout;
+import java.awt.image.BufferedImage;
+import java.awt.image.PixelGrabber;
+import java.awt.event.*;
+import java.awt.Frame;
+import javax.imageio.ImageIO;
+import javax.imageio.stream.FileImageOutputStream;
+
+
+
+class ScreenComparer
+{
+ Rectangle m_rect;
+ BufferedImage m_img1;
+ BufferedImage m_img2;
+ BufferedImage m_imgDiff;
+
+ int m_diffColor;
+ public ScreenComparer(int x, int y, int width, int height)
+ {
+ this(new Rectangle(x, y, width, height));
+ }
+
+ public ScreenComparer(Rectangle location)
+ {
+ m_rect = location;
+ int red = 0xff;
+ int alpha = 0xff;
+ m_diffColor = (alpha << 24);
+ m_diffColor = m_diffColor | (red << 16);
+ }
+
+ public ScreenComparer()
+ {
+ this(new Rectangle(0, 0, 0, 0));
+ }
+
+ public void reset()
+ {
+ m_rect = null;
+ m_img1 = null;
+ m_img2 = null;
+ m_imgDiff = null;
+ }
+
+ public Rectangle getLocation()
+ {
+ return m_rect;
+ }
+ public void grabOne() throws Exception
+ {
+ grabOne(m_rect);
+ }
+
+ public void grabOne(Rectangle r) throws Exception
+ {
+ java.awt.Robot robot = new java.awt.Robot();
+ m_img1 = robot.createScreenCapture(r);
+ }
+
+ public void grabTwo() throws Exception
+ {
+ grabTwo(m_rect);
+ }
+
+ public void grabTwo(Rectangle r) throws Exception
+ {
+ java.awt.Robot robot = new java.awt.Robot();
+ m_img2 = robot.createScreenCapture(r);
+ }
+
+ public boolean compare() throws Exception
+ {
+ if (m_img1 == null || m_img2 == null)
+ throw new Exception("Only one image captured!");
+ boolean ret = true;
+ int w1 = m_img1.getWidth();
+ int h1 = m_img1.getHeight();
+ int w2 = m_img2.getWidth();
+ int h2 = m_img2.getHeight();
+
+ if (w1 != w2 || h1 != h2)
+ {
+ System.out.println("### 1\n");
+ //Different size. Create an image that holds both images.
+ int w = w1 > w2 ? w1 : w2;
+ int h = h1 > h2 ? h1 : h2;
+ m_imgDiff = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
+ for (int y = 0; y < h; y ++)
+ {
+ for (int x = 0; x < w; x++)
+ {
+ boolean bOutOfRange = false;
+ int pixel1 = 0;
+ int pixel2 = 0;
+ //get the pixel for m_img1
+ if (x < w1 && y < h1)
+ pixel1 = m_img1.getRGB(x, y);
+ else
+ bOutOfRange = true;
+
+ if (x < w2 && y < h2)
+ pixel2 = m_img2.getRGB(x, y);
+ else
+ bOutOfRange = true;
+
+ if (bOutOfRange || pixel1 != pixel2)
+ m_imgDiff.setRGB(x, y, m_diffColor);
+ else
+ m_imgDiff.setRGB(x, y, pixel1);
+
+ }
+ }
+ return false;
+ }
+
+ //Images have same dimension
+ int[] pixels1 = new int[w1 * h1];
+ PixelGrabber pg = new PixelGrabber(
+ m_img1.getSource(), 0, 0, w1, h1, pixels1, 0, w1);
+ pg.grabPixels();
+
+ int[] pixels2 = new int[w2 * h2];
+ PixelGrabber pg2 = new PixelGrabber(
+ m_img2.getSource(), 0, 0, w2, h2, pixels2, 0, w2);
+ pg2.grabPixels();
+
+ m_imgDiff = new BufferedImage(w1, h1, BufferedImage.TYPE_INT_ARGB);
+
+ //First check if the the images differ.
+ int lenAr = pixels1.length;
+ int index = 0;
+ for (index = 0; index < lenAr; index++)
+ {
+ if (pixels1[index] != pixels2[index])
+ break;
+ }
+
+ //If the images are different, then create the diff image
+ if (index < lenAr)
+ {
+ for (int y = 0; y < h1; y++)
+ {
+ for (int x = 0; x < w1; x++)
+ {
+ int offset = y * w1 + x;
+ if (pixels1[offset] != pixels2[offset])
+ {
+ ret = ret && false;
+ m_imgDiff.setRGB(x, y, m_diffColor);
+ }
+ else
+ {
+ m_imgDiff.setRGB(x, y, pixels1[offset]);
+ }
+ }
+ }
+ }
+ return ret;
+ }
+
+ /** Writes Images to a location. The
+ * directory is determined by the java property OOoBean.Images
+ *
+ */
+ public void writeImages() throws Exception
+ {
+ String imgLocation = System.getProperty("OOoBean.Images", "");
+ File file_tmp = File.createTempFile("OOoBean", "", new File(imgLocation));
+ File file1 = new File(file_tmp.getPath()+".png");
+ file_tmp.delete();
+ if (m_img1 != null)
+ {
+ ImageIO.write(m_img1, "png", file1);
+ System.out.println("\nCompared images:");
+ System.out.println("1. " + file1.getPath());
+ }
+ file1= null;
+ file_tmp= null;
+ file_tmp = File.createTempFile("OOoBean", "", new File(imgLocation));
+ file1 = new File(file_tmp.getPath()+".png");
+ file_tmp.delete();
+ if (m_img2 != null)
+ {
+ ImageIO.write(m_img2, "png", file1);
+ System.out.println("2. " + file1.getPath());
+ }
+ file1= null;
+ file_tmp= null;
+ file_tmp = File.createTempFile("OOoBean", "_diff", new File(imgLocation));
+ file1 = new File(file_tmp.getPath()+".png");
+ file_tmp.delete();
+ if (m_imgDiff != null)
+ {
+ ImageIO.write(m_imgDiff, "png", file1);
+ System.out.println("Diff image: " + file1.getPath() + "\n");
+ }
+ }
+
+}
+
diff --git a/bean/qa/complex/WriterFrame.java b/bean/qa/complex/WriterFrame.java
new file mode 100644
index 000000000000..b2aff726ad05
--- /dev/null
+++ b/bean/qa/complex/WriterFrame.java
@@ -0,0 +1,209 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package complex;
+
+
+import complexlib.ComplexTestCase;
+import java.awt.Rectangle;
+import java.awt.Insets;
+import java.awt.BorderLayout;
+import java.awt.event.*;
+import java.awt.Frame;
+import java.awt.Dimension;
+import com.sun.star.comp.beans.OOoBean;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.text.XTextDocument;
+
+
+class WriterFrame extends java.awt.Frame
+{
+ com.sun.star.comp.beans.OOoBean m_bean;
+ String m_sDocURL = "private:factory/swriter";
+
+ /**
+ @param loadBeforeVisible
+ the OOoBean is added to the frame before it is displayable. Then the Java Frame does
+ not have a native window peer yet.
+ */
+ public WriterFrame(int x, int y, int width, int height, boolean loadBeforeVisible) throws Exception
+ {
+
+ if (loadBeforeVisible == false)
+ {
+ m_bean = new com.sun.star.comp.beans.OOoBean();
+ add(m_bean, BorderLayout.CENTER);
+ pack();
+ setBounds(x, y, width, height);
+ setVisible(true);
+ m_bean.loadFromURL(m_sDocURL, null);
+ validate();
+ }
+ else
+ {
+ m_bean = new com.sun.star.comp.beans.OOoBean();
+ m_bean.loadFromURL(m_sDocURL, null);
+ add(m_bean, BorderLayout.CENTER);
+ pack();
+ setBounds(x, y, width, height);
+ setVisible(true);
+ m_bean.aquireSystemWindow();
+ }
+ }
+
+ public WriterFrame() throws Exception
+ {
+ this(0, 0, 800, 400, false);
+ }
+
+ public void setText(String s) throws Exception
+ {
+ com.sun.star.frame.XModel model = (com.sun.star.frame.XModel)m_bean.getDocument();
+ com.sun.star.text.XTextDocument myDoc =
+ (XTextDocument) UnoRuntime.queryInterface(com.sun.star.text.XTextDocument.class,
+ model);
+ com.sun.star.text.XText xText = myDoc.getText();
+ com.sun.star.text.XTextCursor xTCursor = xText.createTextCursor();
+ //inserting some Text
+ xText.insertString( xTCursor, s, false );
+ }
+
+ public String getText() throws Exception
+ {
+ com.sun.star.frame.XModel model = (com.sun.star.frame.XModel)m_bean.getDocument();
+ com.sun.star.text.XTextDocument myDoc =
+ (XTextDocument) UnoRuntime.queryInterface(com.sun.star.text.XTextDocument.class,
+ model);
+ com.sun.star.text.XText xText = myDoc.getText();
+ return xText.getString();
+ }
+
+ public void dispose() {
+ m_bean.stopOOoConnection();
+ setVisible(false);
+ super.dispose();
+ }
+
+ OOoBean getBean()
+ {
+ return m_bean;
+ }
+
+ /** Makes sure the document is displayed at the beginning.
+ * This is important for comparing screenshots.
+ */
+ public void goToStart() throws Exception
+ {
+ com.sun.star.frame.XModel xModel = (com.sun.star.frame.XModel)m_bean.getDocument();
+ com.sun.star.frame.XController xController = xModel.getCurrentController();
+
+ com.sun.star.text.XTextViewCursorSupplier xVCSupplier =
+ (com.sun.star.text.XTextViewCursorSupplier) UnoRuntime.queryInterface (
+ com.sun.star.text.XTextViewCursorSupplier.class, xController );
+
+ com.sun.star.text.XTextViewCursor xTViewCursor = xVCSupplier.getViewCursor ( );
+ xTViewCursor.gotoStart(false);
+ }
+
+
+ public void pageDown() throws Exception
+ {
+ com.sun.star.frame.XModel xModel = (com.sun.star.frame.XModel)m_bean.getDocument();
+ com.sun.star.frame.XController xController = xModel.getCurrentController();
+
+ com.sun.star.text.XTextViewCursorSupplier xVCSupplier =
+ (com.sun.star.text.XTextViewCursorSupplier) UnoRuntime.queryInterface (
+ com.sun.star.text.XTextViewCursorSupplier.class, xController );
+ com.sun.star.text.XTextViewCursor xTViewCursor = xVCSupplier.getViewCursor ( );
+ com.sun.star.view.XScreenCursor xScreenCursor =
+ (com.sun.star.view.XScreenCursor) UnoRuntime.queryInterface (
+ com.sun.star.view.XScreenCursor.class, xTViewCursor );
+ xScreenCursor.screenDown();
+ }
+
+ public Rectangle getClientArea()
+ {
+
+ Insets i = getInsets();
+ Rectangle r = getBounds();
+ Rectangle rc = new Rectangle(r.x + i.left, r.y + i.top,
+ r.width - i.left - i.right,
+ r.height - i.top - i.bottom);
+ return rc;
+ }
+
+ public Rectangle getUnoFramePosition() throws Exception
+ {
+ com.sun.star.awt.XWindow win = m_bean.getFrame().getContainerWindow();
+ com.sun.star.awt.Rectangle rect = win.getPosSize();
+ return new Rectangle(rect.X, rect.Y, rect.Width, rect.Height);
+ }
+
+ /** After resizing the Java frame, the UNO window shall be resized
+ * as well, which is checked by this method.
+ */
+ public boolean checkUnoFramePosition() throws Exception
+ {
+ Rectangle client = getClientArea();
+ Rectangle unoWin = getUnoFramePosition();
+
+ if (client.x != unoWin.x
+ || client.y != unoWin.y
+ || client.width != unoWin.width
+ || client.height != unoWin.height)
+ {
+ System.out.println("\nPosition of client are of Java frame does not match the postion" +
+ "of the UNO window. These are the values of Java frame, followed by" +
+ "the UNO window: ");
+ System.out.println(client);
+ System.out.println(unoWin);
+ System.out.println("");
+ return false;
+ }
+
+ return true;
+ }
+
+ public void removeOOoBean() throws Exception
+ {
+ //OOoBean.releaseSystemWindow need not be called because
+ //LocalOfficeWindow overrides removeNotify.
+ //However because of bt4745222 which was fixed in 1.4.2_04,
+ //this is very very slow. The workaround is use releaseSystemWindow
+ //beforehand.
+ m_bean.releaseSystemWindow();
+ remove(m_bean);
+ }
+
+ public void addOOoBean() throws Exception
+ {
+ add(m_bean, BorderLayout.CENTER);
+ m_bean.aquireSystemWindow();
+ validate();
+ }
+
+}
+
diff --git a/bean/qa/complex/makefile.mk b/bean/qa/complex/makefile.mk
new file mode 100644
index 000000000000..e7b88ce3400c
--- /dev/null
+++ b/bean/qa/complex/makefile.mk
@@ -0,0 +1,95 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org 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 version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ := ..$/..
+PRJNAME := bean
+TARGET := test_bean
+PACKAGE = complex
+
+.INCLUDE: settings.mk
+
+#----- compile .java files -----------------------------------------
+
+JARFILES = officebean.jar ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunner.jar
+JAVAFILES = OOoBeanTest.java ScreenComparer.java WriterFrame.java
+JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
+
+#----- make a jar from compiled files ------------------------------
+
+MAXLINELENGTH = 100000
+
+JARCLASSDIRS = $(PACKAGE)
+JARTARGET = $(TARGET).jar
+JARCOMPRESS = TRUE
+
+# --- Parameters for the test --------------------------------------
+
+# test base is java complex
+CT_TESTBASE = -TestBase java_complex
+
+# test looks something like the.full.package.TestName
+CT_TEST = -o $(PACKAGE:s\$/\.\).$(JAVAFILES:b)
+
+# start the runner application
+CT_APP = org.openoffice.Runner
+
+CT_NOOFFICE = -NoOffice
+
+
+OFFICE_CLASSPATH_TMP:=$(foreach,i,$(JARFILES) $(office)$/program$/classes$/$(i)$(PATH_SEPERATOR))
+
+OFFICE_CLASSPATH=$(OFFICE_CLASSPATH_TMP:t"")$(SOLARBINDIR)$/OOoRunner.jar$(PATH_SEPERATOR)$(CLASSDIR)
+
+OOOBEAN_OPTIONS=-Dcom.sun.star.officebean.Options=-norestore -DOOoBean.Images=$(MISC)
+
+
+.INCLUDE: target.mk
+
+ALLTAR : RUNINSTRUCTIONS
+
+# --- Targets ------------------------------------------------------
+
+#The OOoBean uses the classpath to find the office installation.
+#Therefore we must use the jar files from the office.
+RUN:
+ java -cp $(OFFICE_CLASSPATH) $(OOOBEAN_OPTIONS) $(CT_APP) $(CT_NOOFFICE) $(CT_TESTBASE) $(CT_TEST)
+run: RUN
+
+rund:
+ java -Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=8100 -cp $(OFFICE_CLASSPATH) $(OOOBEAN_OPTIONS) $(CT_APP) $(CT_NOOFFICE) $(CT_TESTBASE) $(CT_TEST)
+
+
+
+RUNINSTRUCTIONS :
+ @echo .
+ @echo ########################### N O T E ######################################
+ @echo .
+ @echo "To run the test you have to provide the office location."
+ @echo Example:
+ @echo dmake run office="d:/myOffice"
+ @echo .
+
diff --git a/bean/test/Test.java b/bean/test/Test.java
new file mode 100644
index 000000000000..04f3a42132f9
--- /dev/null
+++ b/bean/test/Test.java
@@ -0,0 +1,68 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package test;
+
+
+import java.io.*;
+import java.awt.*;
+import java.awt.event.*;
+import com.sun.star.comp.beans.OOoBean;
+import com.sun.star.uno.UnoRuntime;
+
+
+import java.awt.*;
+
+public class Test
+{
+
+ public static void main(String [] args)
+ {
+ try {
+ Frame f = new Frame();
+ final OOoBean b = new OOoBean();
+ f.add(b, BorderLayout.CENTER);
+ f.pack();
+ f.setSize(500, 400);
+ f.setVisible(true);
+ b.loadFromURL("private:factory/swriter", null);
+ f.validate();
+
+ f.addWindowListener(new WindowAdapter() {
+ public void windowClosing( java.awt.event.WindowEvent e){
+ b.stopOOoConnection();
+ System.exit(0);
+
+ }});
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+}
+
+
diff --git a/bean/test/applet/oooapplet/OOoViewer.java b/bean/test/applet/oooapplet/OOoViewer.java
new file mode 100644
index 000000000000..c7c96b6a0ab8
--- /dev/null
+++ b/bean/test/applet/oooapplet/OOoViewer.java
@@ -0,0 +1,208 @@
+//*************************************************************************
+//
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+//*************************************************************************
+package oooapplet;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Array;
+import java.net.*;
+import java.io.*;
+import java.awt.*;
+import java.awt.event.*;
+import com.sun.star.comp.beans.*;
+import java.applet.Applet;
+import java.awt.Graphics;
+import java.util.*;
+
+public class OOoViewer extends Applet {
+
+ private OOoBean oBean;
+
+ static private CustomURLClassLoader m_loader;
+
+ Object m_objBean;
+
+ public void init() {
+ try {
+ if (m_loader == null) {
+ String s = getParameter("office");
+ System.out.println("sun.awt.noxembed: " + System.getProperty("sun.awt.noxembed"));
+ System.setProperty("sun.awt.xembedserver", "true");
+
+ File f = new File(s);
+ URL url = f.toURL();
+ String officeURL = url.toString();
+ URL[] arURL = new URL[] {
+ new URL(officeURL + "/program/classes/officebean.jar"),
+ new URL(officeURL + "/program/classes/jurt.jar"),
+ new URL(officeURL + "/program/classes/ridl.jar"),
+ new URL(officeURL + "/program/classes/unoil.jar"),
+ new URL(officeURL + "/program/classes/java_uno.jar"),
+ new URL(officeURL + "/program/classes/juh.jar")
+ };
+ m_loader = new CustomURLClassLoader(arURL);
+ File fileProg = new File(s + "/program");
+ m_loader.addResourcePath(fileProg.toURL());
+ }
+ } catch (MalformedURLException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void start() {
+ try {
+ Class beanClass = m_loader.loadClass("com.sun.star.comp.beans.OOoBean");
+ m_objBean = beanClass.newInstance();
+ setLayout(new BorderLayout());
+ add((java.awt.Container)m_objBean, BorderLayout.CENTER);
+ setVisible(true);
+ //this does not work here. Why?
+// Class arPropValClass = m_loader.loadClass("[Lcom.sun.star.beans.PropertyValue;");
+ Object arProp = Array.newInstance(
+ m_loader.loadClass("com.sun.star.beans.PropertyValue"), 1);
+ Class clazz = arProp.getClass();
+
+ Method methLoad = beanClass.getMethod(
+ "loadFromURL", new Class[] {
+ String.class, arProp.getClass() });
+
+ methLoad.invoke(m_objBean, new Object[] {"private:factory/swriter", null});
+ } catch (ClassNotFoundException e) {
+ e.printStackTrace();
+ } catch (InstantiationException e) {
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ } catch (ClassCastException e) {
+ e.printStackTrace();
+ } catch (java.lang.reflect.InvocationTargetException e) {
+ e.printStackTrace();
+ } catch (java.lang.NoSuchMethodException e) {
+ e.printStackTrace(); }
+
+
+
+ validate();
+ }
+
+ public void stop() {
+ try {
+ Method methStop = m_objBean.getClass().getMethod(
+ "stopOOoConnection", new Class[0]);
+ methStop.invoke(m_objBean, null);
+ } catch (java.lang.NoSuchMethodException e) {
+ e.printStackTrace();
+ } catch (java.lang.IllegalAccessException e) {
+ e.printStackTrace();
+ }
+ catch (java.lang.reflect.InvocationTargetException e) {
+ e.printStackTrace();
+ }
+
+ }
+
+ public void destroy() {
+ }
+
+ public void paint(Graphics g) {
+ }
+}
+
+
+final class CustomURLClassLoader extends URLClassLoader {
+
+ private Vector resourcePaths;
+
+ public CustomURLClassLoader( URL[] urls ) {
+ super( urls );
+ }
+
+ protected Class findClass( String name ) throws ClassNotFoundException {
+ // This is only called via this.loadClass -> super.loadClass ->
+ // this.findClass, after this.loadClass has already called
+ // super.findClass, so no need to call super.findClass again:
+ throw new ClassNotFoundException( name );
+// return super.findClass(name);
+ }
+
+
+
+ protected Class loadClass( String name, boolean resolve )
+ throws ClassNotFoundException
+ {
+ Class c = findLoadedClass( name );
+ if ( c == null ) {
+ try {
+ c = super.findClass( name );
+ } catch ( ClassNotFoundException e ) {
+ return super.loadClass( name, resolve );
+ } catch ( SecurityException e ) {
+ // A SecurityException "Prohibited package name: java.lang"
+ // may occur when the user added the JVM's rt.jar to the
+ // java.class.path:
+ return super.loadClass( name, resolve );
+ }
+ }
+ if ( resolve ) {
+ resolveClass( c );
+ }
+ return c;
+ }
+
+ public void addResourcePath(URL rurl) {
+ if (resourcePaths == null) resourcePaths = new Vector();
+ resourcePaths.add(rurl);
+ }
+
+ public URL getResource(String name) {
+ if (resourcePaths == null) return null;
+
+ URL result = super.getResource(name);
+ if (result != null) {
+ return result;
+ }
+
+ URL u = null;
+ URI uri = null;
+ for (Enumeration e = resourcePaths.elements(); e.hasMoreElements();) {
+ u = (URL)e.nextElement();
+ if (u.getProtocol().startsWith("file")){
+ try {
+ File f1 = new File(u.getPath());
+ File f2 = new File(f1, name);
+ if (f2.exists()) {
+ return new URL(f2.toURI().toASCIIString());
+ }
+ } catch (MalformedURLException e1) {
+ System.err.println("malformed url: "+e1.getMessage());
+ continue;
+ }
+ }
+ }
+ return null;
+ }
+
+}
diff --git a/bean/test/applet/oooapplet/bean.policy b/bean/test/applet/oooapplet/bean.policy
new file mode 100644
index 000000000000..5eb633d12779
--- /dev/null
+++ b/bean/test/applet/oooapplet/bean.policy
@@ -0,0 +1,16 @@
+/* AUTOMATICALLY GENERATED ON Fri Aug 04 13:38:37 CEST 2006*/
+/* DO NOT EDIT */
+/*We could also use more accurate permissions here, but then we would need */
+/*to generate this file because of the paths here. */
+/*grant { */
+/* permission java.lang.RuntimePermission "loadLibrary.*"; */
+/* permission java.io.FilePermission "C:\\Program Files\\OpenOffice.org 2.0\\program\\*", "read"; */
+/* permission java.io.FilePermission "C:\\Program Files\\OpenOffice.org 2.0\\program\\classes\\*", "read"; */
+/* permission java.util.PropertyPermission "*", "read"; */
+/*}; */
+
+grant {
+ permission java.security.AllPermission;
+ permission java.lang.RuntimePermission "queuePrintJob";
+};
+
diff --git a/bean/test/applet/oooapplet/example.html b/bean/test/applet/oooapplet/example.html
new file mode 100644
index 000000000000..036684e24f8c
--- /dev/null
+++ b/bean/test/applet/oooapplet/example.html
@@ -0,0 +1,22 @@
+<html>
+ <head>
+ <title></title>
+ </head>
+ <body>
+ <h1>OOoBean used by applet</h1>
+ <hr>
+<script type="text/javascript">
+function writeApplet() {
+ var office = window.location.search.substring(1);
+ document.write("<applet code=\"oooapplet/OOoViewer.class\" archive=\"oooapplet.jar\" width=800 height=600>");
+ document.write("<param name=\"office\" value=\"" + office + "\" >" );
+ document.write("</applet>");
+}
+writeApplet();
+</script>
+ <hr>
+
+ </body>
+</html>
+
+ \ No newline at end of file
diff --git a/bean/test/applet/oooapplet/makefile.mk b/bean/test/applet/oooapplet/makefile.mk
new file mode 100644
index 000000000000..79a58cd3a6e1
--- /dev/null
+++ b/bean/test/applet/oooapplet/makefile.mk
@@ -0,0 +1,88 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org 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 version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ := ..$/..$/..
+PRJNAME := bean
+TARGET := oooapplet
+PACKAGE = oooapplet
+
+.INCLUDE: settings.mk
+
+#----- compile .java files -----------------------------------------
+
+JARFILES = officebean.jar ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar
+JAVAFILES = OOoViewer.java
+JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
+
+
+JARCLASSDIRS = \
+ oooapplet
+
+JARTARGET = $(TARGET).jar
+JARCOMPRESS = TRUE
+
+#----- make a jar from compiled files ------------------------------
+
+
+.INCLUDE: target.mk
+
+
+ALLTAR : \
+ COPY_FILES \
+ RUNINSTRUCTIONS
+
+
+COPY_FILES: example.html
+ $(GNUCOPY) -p $< $(CLASSDIR)
+# --- Targets ------------------------------------------------------
+
+
+.IF "$(GUI)"=="WNT"
+RUN:
+ firefox "$(CLASSDIR)$/example.html?$(office)"
+.ELSE
+TESTURL="file:///$(PWD)$/$(CLASSDIR)$/example.html?$(office)"
+RUN:
+ firefox ${TESTURL:s/\///}
+.ENDIF
+
+run: RUN
+
+
+
+RUNINSTRUCTIONS :
+ @echo .
+ @echo ########################### N O T E ######################################
+ @echo .
+ @echo "Add to the java runtime settings for applets in the control panel these lines:"
+ @echo "-Djava.security.policy=$(PWD)$/bean.policy"
+ @echo "To run the test you have to provide the office location."
+ @echo Example:
+ @echo dmake run office="d:\\myOffice"
+ @echo .
+
+
diff --git a/bean/test/makefile.mk b/bean/test/makefile.mk
new file mode 100644
index 000000000000..1032566dd36e
--- /dev/null
+++ b/bean/test/makefile.mk
@@ -0,0 +1,95 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org 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 version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ := ..
+PRJNAME := bean
+TARGET := test
+PACKAGE = test
+
+.INCLUDE: settings.mk
+
+#----- compile .java files -----------------------------------------
+
+JARFILES = officebean.jar ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar
+JAVAFILES = Test.java
+JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
+
+#----- make a jar from compiled files ------------------------------
+
+MAXLINELENGTH = 100000
+
+#JARCLASSDIRS = $(PACKAGE)
+#JARTARGET = $(TARGET).jar
+#JARCOMPRESS = TRUE
+
+# --- Parameters for the test --------------------------------------
+
+# test base is java complex
+#CT_TESTBASE = -TestBase java_complex
+
+# test looks something like the.full.package.TestName
+#CT_TEST = -o $(PACKAGE:s\$/\.\).$(JAVAFILES:b)
+
+# start the runner application
+#CT_APP = org.openoffice.Runner
+
+#CT_NOOFFICE = -NoOffice
+
+
+OFFICE_CLASSPATH_TMP:=$(foreach,i,$(JARFILES) $(office)$/program$/classes$/$(i)$(PATH_SEPERATOR))
+
+OFFICE_CLASSPATH=$(OFFICE_CLASSPATH_TMP:t"")$(PATH_SEPERATOR)$(CLASSDIR)
+
+OOOBEAN_OPTIONS=-Dcom.sun.star.officebean.Options=-norestore
+
+
+.INCLUDE: target.mk
+
+ALLTAR : RUNINSTRUCTIONS
+
+# --- Targets ------------------------------------------------------
+
+#The OOoBean uses the classpath to find the office installation.
+#Therefore we must use the jar files from the office.
+RUN:
+ java -cp $(OFFICE_CLASSPATH) $(OOOBEAN_OPTIONS) $(PACKAGE).Test
+run: RUN
+
+rund:
+ java -Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=8100 -cp $(OFFICE_CLASSPATH) $(OOOBEAN_OPTIONS) $(PACKAGE).Test
+
+
+
+RUNINSTRUCTIONS :
+ @echo .
+ @echo ########################### N O T E ######################################
+ @echo .
+ @echo "To run the test you have to provide the office location."
+ @echo Example:
+ @echo dmake run office="d:/myOffice"
+ @echo .
+
diff --git a/bean/util/delzip b/bean/util/delzip
new file mode 100644
index 000000000000..e69de29bb2d1
--- /dev/null
+++ b/bean/util/delzip
diff --git a/bean/util/makefile.mk b/bean/util/makefile.mk
new file mode 100644
index 000000000000..b463b3461819
--- /dev/null
+++ b/bean/util/makefile.mk
@@ -0,0 +1,56 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org 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 version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ = ..
+PRJNAME = bean
+TARGET = officebean
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.IF "$(L10N_framework)"==""
+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 ------------------------------------------------------
+.ENDIF # L10N_framework
+
+.INCLUDE : target.mk
+
+