diff options
author | Michael Hönnig <mi@openoffice.org> | 2004-09-14 14:10:24 +0000 |
---|---|---|
committer | Michael Hönnig <mi@openoffice.org> | 2004-09-14 14:10:24 +0000 |
commit | 9023fc61265a086a292c9dbc9ab3a7e8f06a33e6 (patch) | |
tree | 141825d71af3f9e4eb48e6c9f8827d52e3ccd788 /bean | |
parent | 6296f7635bdad582694349adf4c515158cf05870 (diff) |
namespace now com.sun.star.comp.beans
Diffstat (limited to 'bean')
-rw-r--r-- | bean/com/sun/star/comp/beans/LocalOfficeConnection.java | 19 | ||||
-rw-r--r-- | bean/com/sun/star/comp/beans/OOoBean.java | 110 | ||||
-rw-r--r-- | bean/com/sun/star/comp/beans/makefile.mk | 7 | ||||
-rw-r--r-- | bean/native/unix/com_sun_star_comp_beans_LocalOfficeWindow.c | 163 | ||||
-rw-r--r-- | bean/native/unix/makefile.mk | 42 | ||||
-rw-r--r-- | bean/native/win32/com_sun_star_comp_beans_LocalOfficeWindow.c | 217 | ||||
-rw-r--r-- | bean/native/win32/makefile.mk | 35 | ||||
-rw-r--r-- | bean/native/win32/officebean.dxp | 2 |
8 files changed, 539 insertions, 56 deletions
diff --git a/bean/com/sun/star/comp/beans/LocalOfficeConnection.java b/bean/com/sun/star/comp/beans/LocalOfficeConnection.java index af6631a8d8ba..3054ad3da756 100644 --- a/bean/com/sun/star/comp/beans/LocalOfficeConnection.java +++ b/bean/com/sun/star/comp/beans/LocalOfficeConnection.java @@ -2,9 +2,9 @@ * * $RCSfile: LocalOfficeConnection.java,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: mi $ $Date: 2004-09-06 15:11:32 $ + * last change: $Author: mi $ $Date: 2004-09-14 15:07:23 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -118,6 +118,13 @@ public class LocalOfficeConnection private List mComponents = new Vector(); + //------------------------------------------------------------------------- + // debugging method + private void dbgPrint( String aMessage ) + { + System.err.println( aMessage ); + } + /** * Constructor. * Sets up paths to the office application and native libraries if @@ -139,6 +146,7 @@ public class LocalOfficeConnection // load libofficebean.so/officebean.dll String aSharedLibName = getProgramPath() + java.io.File.separator + System.mapLibraryName(OFFICE_LIB_NAME); +dbgPrint( "System.load( libofficebean.so )" ); System.load( aSharedLibName ); } @@ -270,13 +278,16 @@ public class LocalOfficeConnection try { // create default local component context +dbgPrint( "create initial component context" ); XComponentContext xLocalContext = com.sun.star.comp.helper.Bootstrap.createInitialComponentContext(null); // initial serviceManager +dbgPrint( "get local service manager" ); XMultiComponentFactory xLocalServiceManager = xLocalContext.getServiceManager(); // create a urlresolver +dbgPrint( "get local service manager" ); Object urlResolver = xLocalServiceManager.createInstanceWithContext( "com.sun.star.bridge.UnoUrlResolver", xLocalContext ); @@ -288,7 +299,9 @@ public class LocalOfficeConnection Object aInitialObject = null; try { +dbgPrint( "xUrlResolver.resolve( " + mURL + " )" ); aInitialObject = xUrlResolver.resolve( mURL ); +dbgPrint( "xUrlResolver.resolve() - done" ); } catch( com.sun.star.connection.NoConnectException e ) { @@ -631,7 +644,7 @@ public class LocalOfficeConnection throw new java.io.IOException( "not connection specified" ); // start process -System.err.println( "exec" + cmdArray[0] + " " + cmdArray[1] + " " + cmdArray[2] + " " + cmdArray[3] ); +dbgPrint( "exec" + cmdArray[0] + " " + cmdArray[1] + " " + cmdArray[2] + " " + cmdArray[3] ); mProcess = Runtime.getRuntime().exec(cmdArray); if ( mProcess == null ) throw new RuntimeException( "cannot start soffice: " + cmdArray ); diff --git a/bean/com/sun/star/comp/beans/OOoBean.java b/bean/com/sun/star/comp/beans/OOoBean.java index 447cdcfcc685..13e39aa0fc35 100644 --- a/bean/com/sun/star/comp/beans/OOoBean.java +++ b/bean/com/sun/star/comp/beans/OOoBean.java @@ -2,9 +2,9 @@ * * $RCSfile: OOoBean.java,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: mi $ $Date: 2004-09-06 15:11:34 $ + * last change: $Author: mi $ $Date: 2004-09-14 15:07:23 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -78,9 +78,7 @@ public class OOoBean implements // @requirement FUNC.PER/0.2 - java.io.Externalizable, - - com.sun.star.comp.beans.OOoBeanInterface + java.io.Externalizable { // timeout values (milli secs) int nOOoStartTimeOut = 60000; @@ -222,7 +220,7 @@ public class OOoBean // get notified when connection dies if ( xConnectionListener != null ) xConnectionListener.stop(); - xConnectionListener = this.new EventListener(); + xConnectionListener = this.new EventListener("setOOoConnection"); dbgPrint( "new EventListener()" ); } @@ -383,7 +381,7 @@ public class OOoBean throws java.lang.InterruptedException { CallWatchThread aCallWatchThread = - new CallWatchThread( nOOoCallTimeOut ); + new CallWatchThread( nOOoCallTimeOut, "clear" ); aDocument = null; xDispatcher = null; aFrame = null; @@ -526,7 +524,7 @@ public class OOoBean { // watch loading in a thread with a timeout (if OOo hangs) CallWatchThread aCallWatchThread = - new CallWatchThread( nOOoStartTimeOut ); + new CallWatchThread( nOOoStartTimeOut, "loadFromURL" ); try { @@ -736,7 +734,7 @@ public class OOoBean { // start runtime timeout CallWatchThread aCallWatchThread = - new CallWatchThread( nOOoCallTimeOut ); + new CallWatchThread( nOOoCallTimeOut, "storeToURL" ); // store the document try { aDocument.storeToURL( aURL, aArguments ); } @@ -765,8 +763,8 @@ public class OOoBean { // wrap byte arrray into UNO stream - com.sun.star.beans.XOutputStreamToByteArrayAdapter aStream = - new com.sun.star.beans.XOutputStreamToByteArrayAdapter( + com.sun.star.comp.beans.XOutputStreamToByteArrayAdapter aStream = + new com.sun.star.comp.beans.XOutputStreamToByteArrayAdapter( aOutBuffer ); // add stream to arguments @@ -934,7 +932,7 @@ public class OOoBean { // start runtime timeout CallWatchThread aCallWatchThread = - new CallWatchThread( nOOoCallTimeOut ); + new CallWatchThread( nOOoCallTimeOut, "setToolVisible" ); // Does a frame exist? if ( aFrame != null ) @@ -954,7 +952,7 @@ public class OOoBean xLayoutManager.showElement( aResourceURL ); else xLayoutManager.hideElement( aResourceURL ); - +/* System.err.println( "ResourceURLs:" ); for ( int n = 0; n < xLayoutManager.getElements().length; ++n ) { @@ -965,6 +963,7 @@ public class OOoBean System.err.println( xElementPropSet.getPropertyValue("ResourceURL") ); } System.err.println( "" ); +*/ } catch ( com.sun.star.beans.UnknownPropertyException aExc ) { @@ -1202,9 +1201,14 @@ public class OOoBean com.sun.star.lang.XEventListener, com.sun.star.frame.XTerminateListener { - EventListener() + String aTag; + + EventListener( String aTag ) throws NoConnectionException { + // init members + this.aTag = aTag; + // listen on a dying connection iConnection.addEventListener( this ); @@ -1241,46 +1245,41 @@ public class OOoBean /// watching the connection public void run() { - dbgPrint( "EventListener.run()" ); + dbgPrint( "EventListener(" + aTag + ").run()" ); // remote call might hang => watch try CallWatchThread aCallWatchThread = - new CallWatchThread( nOOoCallTimeOut ); + new CallWatchThread( nOOoCallTimeOut, "EventListener(" + aTag + ")" ); // continue to trying to connect the OOo instance + long n = 0; while ( iConnection != null && iConnection.getComponentContext() != null ) { - dbgPrint( "EventListener.running()" ); + 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 { - iConnection.getComponentContext().getServiceManager(); - aCallWatchThread.cancel(); - } - catch ( com.sun.star.lang.DisposedException aExc ) - { - // dead - OfficeConnection iDeadConn = iConnection; - iConnection = null; - iDeadConn.dispose(); + aCallWatchThread.restart(); } catch ( java.lang.InterruptedException aExc ) { - // hung - OfficeConnection iDeadConn = iConnection; - iConnection = null; - iDeadConn.dispose(); + // ignore late interrupt } } - catch ( java.lang.NullPointerException aExc ) - {} // ignore - catch ( com.sun.star.lang.DisposedException aExc ) + catch ( java.lang.RuntimeException aExc ) { - // not alive => dispose the dead connection - iConnection.dispose(); + // hung + OfficeConnection iDeadConn = iConnection; + iConnection = null; + iDeadConn.dispose(); } // sleep @@ -1292,9 +1291,6 @@ public class OOoBean // empty the OOoBean and cut the connection stopOOoConnection(); } - - // this loop successvully performed, restart watch for next loop - aCallWatchThread.restart(); } } } @@ -1305,20 +1301,24 @@ public class OOoBean protected class CallWatchThread extends Thread { Thread aWatchedThread; + String aTag; boolean bAlive; long nTimeout; - CallWatchThread( long nTimeout ) + CallWatchThread( long nTimeout, String aTag ) { this.aWatchedThread = Thread.currentThread(); this.nTimeout = nTimeout; - dbgPrint( "CallWatchThread.start()" ); + this.aTag = aTag; + setDaemon( true ); + dbgPrint( "CallWatchThread(" + this + ").start(" + aTag + ")" ); start(); } void cancel() throws java.lang.InterruptedException { + dbgPrint( "CallWatchThread(" + this + ".cancel(" + aTag + ")" ); if ( aWatchedThread != null && aWatchedThread != Thread.currentThread() ) throw new RuntimeException( "wrong thread" ); aWatchedThread = null; @@ -1327,34 +1327,46 @@ public class OOoBean } synchronized void restart() + throws java.lang.InterruptedException { - dbgPrint( "CallWatchThread.restart()" ); + 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.run() running" ); - bAlive = false; + dbgPrint( "CallWatchThread(" + this + ").run(" + aTag + ") running #" + ++n ); + synchronized(this) + { + bAlive = false; - try { wait( 10*nTimeout ); } - catch ( java.lang.InterruptedException aExc ) - {} + // wait a while + try { wait( nTimeout ); } + catch ( java.lang.InterruptedException aExc ) + { + bAlive = false; + } - // synchronized - { + // watched thread seems to be dead (not answering)? if ( !bAlive && aWatchedThread != null ) { + dbgPrint( "CallWatchThread(" + this + ").run(" + aTag + ") interrupting" ); aWatchedThread.interrupt(); aWatchedThread = null; } } } - dbgPrint( "CallWatchThread.run() terminated" ); + dbgPrint( "CallWatchThread(" + this + ").run(" + aTag + ") terminated" ); } }; diff --git a/bean/com/sun/star/comp/beans/makefile.mk b/bean/com/sun/star/comp/beans/makefile.mk index 06fa1925860f..40bdfbfa4e13 100644 --- a/bean/com/sun/star/comp/beans/makefile.mk +++ b/bean/com/sun/star/comp/beans/makefile.mk @@ -2,9 +2,9 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.1 $ +# $Revision: 1.2 $ # -# last change: $Author: mi $ $Date: 2004-09-06 15:11:38 $ +# last change: $Author: mi $ $Date: 2004-09-14 15:07:23 $ # # The Contents of this file are made available subject to the terms of # either of the following licenses @@ -63,7 +63,7 @@ PRJ = ..$/..$/..$/..$/.. PRJNAME = beans TARGET = officebean -PACKAGE = com$/sun$/star$/comc$/beans +PACKAGE = com$/sun$/star$/comp$/beans # --- Settings ----------------------------------------------------- .INCLUDE: settings.mk @@ -106,7 +106,6 @@ JAVACLASSFILES=\ $(CLASSDIR)$/$(PACKAGE)$/Controller.class \ $(CLASSDIR)$/$(PACKAGE)$/Frame.class \ $(CLASSDIR)$/$(PACKAGE)$/Wrapper.class \ - $(CLASSDIR)$/$(PACKAGE)$/OOoBeanInterface.class \ $(CLASSDIR)$/$(PACKAGE)$/OOoBean.class .ENDIF 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..badf56c13fca --- /dev/null +++ b/bean/native/unix/com_sun_star_comp_beans_LocalOfficeWindow.c @@ -0,0 +1,163 @@ +/************************************************************************* + * + * $RCSfile: com_sun_star_comp_beans_LocalOfficeWindow.c,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: mi $ $Date: 2004-09-14 15:10:23 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#if HAVE_CONFIG_H +#include <config.h> +#endif + +#include <X11/Xlib.h> +#include <X11/Xutil.h> +#include <X11/Intrinsic.h> + +#include "jawt.h" +#include "jawt_md.h" + +//#include "../inc/com_sun_star_comp_beans_LocalOfficeWindow.h" + +#if defined assert +#undef assert +#endif + +#define assert(X) if (!X) { (*env)->ThrowNew(env, (*env)->FindClass(env, "java/lang/RuntimeException"), "assertion failed"); return;} + + +#define SYSTEM_WIN32 1 +#define SYSTEM_WIN16 2 +#define SYSTEM_JAVA 3 +#define SYSTEM_OS2 4 +#define SYSTEM_MAC 5 +#define SYSTEM_XWINDOW 6 + +/*****************************************************************************/ +/* + * Class: com_sun_star_comp_beans_LocalOfficeWindow + * Method: getNativeWindowSystemType + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_com_sun_star_comp_beans_LocalOfficeWindow_getNativeWindowSystemType + (JNIEnv * env, jobject obj_this) +{ + return (SYSTEM_XWINDOW); +} + + +/*****************************************************************************/ +/* + * Class: com_sun_star_beans_LocalOfficeWindow + * Method: getNativeWindow + * Signature: ()J + */ +JNIEXPORT jlong JNICALL Java_com_sun_star_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); + assert(result != JNI_FALSE); + + /* Get the drawing surface */ + if ((ds = awt.GetDrawingSurface(env, obj_this)) == NULL) + return 0L; + + /* Lock the drawing surface */ + lock = ds->Lock(ds); + assert((lock & JAWT_LOCK_ERROR) == 0); + + /* 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..08c39e3783cf --- /dev/null +++ b/bean/native/unix/makefile.mk @@ -0,0 +1,42 @@ +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 + +SHL1TARGET=$(TARGET) +SHL1LIBS= $(SLB)$/$(TARGET).lib +SHL1STDLIBS=-ljawt -lsal + +.IF "$(OS)" == "LINUX" +.IF "$(CPUNAME)" == "S390" +SHL1STDLIBS+=-lzip -lawt +.ENDIF +SHL1STDLIBS+=-lstdc++ +.ENDIF + +NO_SHL1DESCRIPTION=TRUE + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk 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..517a35359ef8 --- /dev/null +++ b/bean/native/win32/com_sun_star_comp_beans_LocalOfficeWindow.c @@ -0,0 +1,217 @@ +/************************************************************************* + * + * $RCSfile: com_sun_star_comp_beans_LocalOfficeWindow.c,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: mi $ $Date: 2004-09-14 15:10:23 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#if HAVE_CONFIG_H +#include <config.h> +#endif + +#include <windows.h> + +#include "jawt.h" +#include "jawt_md.h" + +#if defined assert +#undef assert +#endif + +#define assert(X) if (!X) { (*env)->ThrowNew(env, (*env)->FindClass(env, "java/lang/RuntimeException"), "assertion failed"); return 0L;} + + +#define SYSTEM_WIN32 1 +#define SYSTEM_WIN16 2 +#define SYSTEM_JAVA 3 +#define SYSTEM_OS2 4 +#define SYSTEM_MAC 5 +#define SYSTEM_XWINDOW 6 + +#define OLD_PROC_KEY "oldwindowproc" + +static LRESULT APIENTRY OpenOfficeWndProc( HWND , UINT , WPARAM , LPARAM ); + +/*****************************************************************************/ +/* + * Class: com_sun_star_comp_beans_LocalOfficeWindow + * Method: getNativeWindowSystemType + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_com_sun_star_comp_beans_LocalOfficeWindow_getNativeWindowSystemType + (JNIEnv * env, jobject obj_this) +{ + 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); + assert(result != JNI_FALSE); + + /* Get the drawing surface */ + if ((ds = awt.GetDrawingSurface(env, obj_this)) == NULL) + return 0L; + + /* Lock the drawing surface */ + lock = ds->Lock(ds); + assert((lock & JAWT_LOCK_ERROR) == 0); + + /* 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; + } + } + + return CallWindowProc(GetProp(hWnd, OLD_PROC_KEY), + hWnd, uMsg, wParam, lParam); +} + + + + + + + + + + diff --git a/bean/native/win32/makefile.mk b/bean/native/win32/makefile.mk new file mode 100644 index 000000000000..d1209bff16e5 --- /dev/null +++ b/bean/native/win32/makefile.mk @@ -0,0 +1,35 @@ +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 + +SHL1TARGET=$(TARGET) +SHL1LIBS= $(SLB)$/$(TARGET).lib +#SHL1IMPLIB= i$(TARGET) +SHL1STDLIBS=jawt.lib $(SALLIB) + +SHL1DEF= $(MISC)$/$(SHL1TARGET).def + +DEF1NAME= $(SHL1TARGET) +DEF1EXPORTFILE= $(TARGET).dxp +DEF1DES=officebean + +NO_SHL1DESCRIPTION=TRUE + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk + diff --git a/bean/native/win32/officebean.dxp b/bean/native/win32/officebean.dxp new file mode 100644 index 000000000000..7162e5452daa --- /dev/null +++ b/bean/native/win32/officebean.dxp @@ -0,0 +1,2 @@ +Java_com_sun_star_beans_LocalOfficeWindow_getNativeWindowSystemType +Java_com_sun_star_beans_LocalOfficeWindow_getNativeWindow |