LCOV - code coverage report
Current view: top level - libreoffice/bean/native/unix - com_sun_star_comp_beans_LocalOfficeWindow.c (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 29 0.0 %
Date: 2012-12-27 Functions: 0 3 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "sal/config.h"
      21             : 
      22             : #include <X11/Xlib.h>
      23             : #include <X11/Xutil.h>
      24             : #include <X11/Intrinsic.h>
      25             : 
      26             : #include "jni.h"
      27             : 
      28             : // Workaround for problematic IBM JDK 1.6.0 on ppc
      29             : #ifndef _JNI_IMPORT_OR_EXPORT_
      30             : #define _JNI_IMPORT_OR_EXPORT_
      31             : #endif
      32             : 
      33             : #include "jawt_md.h"
      34             : #include "jawt.h"
      35             : 
      36             : #include "sal/types.h"
      37             : 
      38             : #define SYSTEM_WIN32   1
      39             : #define SYSTEM_WIN16   2
      40             : #define SYSTEM_JAVA    3
      41             : #define SYSTEM_MAC     5
      42             : #define SYSTEM_XWINDOW 6
      43             : 
      44             : 
      45             : /* type must be something like java/lang/RuntimeException
      46             :  */
      47           0 : static void ThrowException(JNIEnv * env, char const * type, char const * msg) {
      48             :     jclass c;
      49           0 :     (*env)->ExceptionClear(env);
      50           0 :     c = (*env)->FindClass(env, type);
      51           0 :     if (c == NULL) {
      52           0 :         (*env)->ExceptionClear(env);
      53           0 :         (*env)->FatalError(
      54             :             env, "JNI FindClass failed");
      55             :     }
      56           0 :     if ((*env)->ThrowNew(env, c, msg) != 0) {
      57           0 :         (*env)->ExceptionClear(env);
      58           0 :         (*env)->FatalError(env, "JNI ThrowNew failed");
      59             :     }
      60           0 : }
      61             : 
      62             : /*****************************************************************************/
      63             : /*
      64             :  * Class:     com_sun_star_comp_beans_LocalOfficeWindow
      65             :  * Method:    getNativeWindowSystemType
      66             :  * Signature: ()I
      67             :  */
      68           0 : SAL_DLLPUBLIC_EXPORT jint JNICALL Java_com_sun_star_comp_beans_LocalOfficeWindow_getNativeWindowSystemType
      69             :   (JNIEnv * env, jobject obj_this)
      70             : {
      71             :     (void) env; /* avoid warning about unused parameter */
      72             :     (void) obj_this; /* avoid warning about unused parameter */
      73           0 :     return (SYSTEM_XWINDOW);
      74             : }
      75             : 
      76             : 
      77             : /*****************************************************************************/
      78             : /*
      79             :  * Class:     com_sun_star_beans_LocalOfficeWindow
      80             :  * Method:    getNativeWindow
      81             :  * Signature: ()J
      82             :  */
      83           0 : SAL_DLLPUBLIC_EXPORT jlong JNICALL Java_com_sun_star_comp_beans_LocalOfficeWindow_getNativeWindow
      84             :   (JNIEnv * env, jobject obj_this)
      85             : {
      86             :     jboolean result;
      87             :     jint lock;
      88             : 
      89             :     JAWT awt;
      90             :     JAWT_DrawingSurface* ds;
      91             :     JAWT_DrawingSurfaceInfo* dsi;
      92             :     JAWT_X11DrawingSurfaceInfo* dsi_x11;
      93             : 
      94             :     Drawable drawable;
      95             : 
      96             :     /* Get the AWT */
      97           0 :     awt.version = JAWT_VERSION_1_3;
      98           0 :     result = JAWT_GetAWT(env, &awt);
      99           0 :     if (result == JNI_FALSE)
     100           0 :         ThrowException(env, "java/lang/RuntimeException", "JAWT_GetAWT failed");
     101             : 
     102             :                                 /* Get the drawing surface */
     103           0 :     if ((ds = awt.GetDrawingSurface(env, obj_this)) == NULL)
     104           0 :         return 0L;
     105             : 
     106             :     /* Lock the drawing surface */
     107           0 :     lock = ds->Lock(ds);
     108           0 :     if ( (lock & JAWT_LOCK_ERROR) != 0)
     109           0 :         ThrowException(env, "java/lang/RuntimeException",
     110             :                        "Could not get AWT drawing surface.");
     111             : 
     112             :     /* Get the drawing surface info */
     113           0 :     dsi = ds->GetDrawingSurfaceInfo(ds);
     114             : 
     115             :     /* Get the platform-specific drawing info */
     116           0 :     dsi_x11 = (JAWT_X11DrawingSurfaceInfo*)dsi->platformInfo;
     117             : 
     118           0 :     drawable = dsi_x11->drawable;
     119             : 
     120             :     /* Free the drawing surface info */
     121           0 :     ds->FreeDrawingSurfaceInfo(dsi);
     122             :     /* Unlock the drawing surface */
     123           0 :     ds->Unlock(ds);
     124             :     /* Free the drawing surface */
     125           0 :     awt.FreeDrawingSurface(ds);
     126             : 
     127           0 :     return ((jlong)drawable);
     128             : }
     129             : 
     130             : 
     131             : 
     132             : 
     133             : 
     134             : 
     135             : 
     136             : 
     137             : 
     138             : 
     139             : 
     140             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10