From 5dce6e1a08e5a7b48b59d733e232c58a9a9bf207 Mon Sep 17 00:00:00 2001 From: Oliver Bolte Date: Thu, 7 Jul 2005 12:17:46 +0000 Subject: INTEGRATION: CWS jl22 (1.1.26); FILE MERGED 2005/06/20 14:32:25 jl 1.1.26.1: #i48392# replace assert macro by function ThrowException --- .../com_sun_star_comp_beans_LocalOfficeWindow.c | 38 +++++++++++++++------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/bean/native/win32/com_sun_star_comp_beans_LocalOfficeWindow.c b/bean/native/win32/com_sun_star_comp_beans_LocalOfficeWindow.c index 517a35359ef8..5fb19cc4081c 100644 --- a/bean/native/win32/com_sun_star_comp_beans_LocalOfficeWindow.c +++ b/bean/native/win32/com_sun_star_comp_beans_LocalOfficeWindow.c @@ -2,9 +2,9 @@ * * $RCSfile: com_sun_star_comp_beans_LocalOfficeWindow.c,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: mi $ $Date: 2004-09-14 15:10:23 $ + * last change: $Author: obo $ $Date: 2005-07-07 13:17:46 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -68,13 +68,6 @@ #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 @@ -86,6 +79,26 @@ 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 @@ -122,7 +135,8 @@ JNIEXPORT jlong JNICALL Java_com_sun_star_comp_beans_LocalOfficeWindow_getNative /* Get the AWT */ awt.version = JAWT_VERSION_1_3; result = JAWT_GetAWT(env, &awt); - assert(result != JNI_FALSE); + if (result == JNI_FALSE) + ThrowException(env, "java/lang/RuntimeException", "JAWT_GetAWT failed"); /* Get the drawing surface */ if ((ds = awt.GetDrawingSurface(env, obj_this)) == NULL) @@ -130,7 +144,9 @@ JNIEXPORT jlong JNICALL Java_com_sun_star_comp_beans_LocalOfficeWindow_getNative /* Lock the drawing surface */ lock = ds->Lock(ds); - assert((lock & JAWT_LOCK_ERROR) == 0); + 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); -- cgit v1.2.3