summaryrefslogtreecommitdiff
path: root/bean
diff options
context:
space:
mode:
authorOliver Bolte <obo@openoffice.org>2005-07-07 12:17:33 +0000
committerOliver Bolte <obo@openoffice.org>2005-07-07 12:17:33 +0000
commit64188a68363ee70409c80d68a71eb4d53f6e90ff (patch)
treefc2ce60d5821ebc58536bb3a7d819560f0745459 /bean
parenteb99e74c6248c4bc60f4191154ea18319550b28d (diff)
INTEGRATION: CWS jl22 (1.2.16); FILE MERGED
2005/06/20 14:32:24 jl 1.2.16.1: #i48392# replace assert macro by function ThrowException
Diffstat (limited to 'bean')
-rw-r--r--bean/native/unix/com_sun_star_comp_beans_LocalOfficeWindow.c37
1 files changed, 25 insertions, 12 deletions
diff --git a/bean/native/unix/com_sun_star_comp_beans_LocalOfficeWindow.c b/bean/native/unix/com_sun_star_comp_beans_LocalOfficeWindow.c
index 3ff7c48f3db2..1cfe22249847 100644
--- a/bean/native/unix/com_sun_star_comp_beans_LocalOfficeWindow.c
+++ b/bean/native/unix/com_sun_star_comp_beans_LocalOfficeWindow.c
@@ -2,9 +2,9 @@
*
* $RCSfile: com_sun_star_comp_beans_LocalOfficeWindow.c,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: obo $ $Date: 2005-03-15 09:07:33 $
+ * last change: $Author: obo $ $Date: 2005-07-07 13:17:33 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -71,14 +71,6 @@
#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
@@ -87,6 +79,24 @@
#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
@@ -123,7 +133,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)
@@ -131,7 +142,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);