LCOV - code coverage report
Current view: top level - usr/local/src/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: 2013-07-09 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_XWINDOW 6
      39             : 
      40             : 
      41             : /* type must be something like java/lang/RuntimeException
      42             :  */
      43           0 : static void ThrowException(JNIEnv * env, char const * type, char const * msg) {
      44             :     jclass c;
      45           0 :     (*env)->ExceptionClear(env);
      46           0 :     c = (*env)->FindClass(env, type);
      47           0 :     if (c == NULL) {
      48           0 :         (*env)->ExceptionClear(env);
      49           0 :         (*env)->FatalError(
      50             :             env, "JNI FindClass failed");
      51             :     }
      52           0 :     if ((*env)->ThrowNew(env, c, msg) != 0) {
      53           0 :         (*env)->ExceptionClear(env);
      54           0 :         (*env)->FatalError(env, "JNI ThrowNew failed");
      55             :     }
      56           0 : }
      57             : 
      58             : /*****************************************************************************/
      59             : /*
      60             :  * Class:     com_sun_star_comp_beans_LocalOfficeWindow
      61             :  * Method:    getNativeWindowSystemType
      62             :  * Signature: ()I
      63             :  */
      64           0 : SAL_DLLPUBLIC_EXPORT jint JNICALL Java_com_sun_star_comp_beans_LocalOfficeWindow_getNativeWindowSystemType
      65             :   (JNIEnv * env, jobject obj_this)
      66             : {
      67             :     (void) env; /* avoid warning about unused parameter */
      68             :     (void) obj_this; /* avoid warning about unused parameter */
      69           0 :     return (SYSTEM_XWINDOW);
      70             : }
      71             : 
      72             : 
      73             : /*****************************************************************************/
      74             : /*
      75             :  * Class:     com_sun_star_beans_LocalOfficeWindow
      76             :  * Method:    getNativeWindow
      77             :  * Signature: ()J
      78             :  */
      79           0 : SAL_DLLPUBLIC_EXPORT jlong JNICALL Java_com_sun_star_comp_beans_LocalOfficeWindow_getNativeWindow
      80             :   (JNIEnv * env, jobject obj_this)
      81             : {
      82             :     jboolean result;
      83             :     jint lock;
      84             : 
      85             :     JAWT awt;
      86             :     JAWT_DrawingSurface* ds;
      87             :     JAWT_DrawingSurfaceInfo* dsi;
      88             :     JAWT_X11DrawingSurfaceInfo* dsi_x11;
      89             : 
      90             :     Drawable drawable;
      91             : 
      92             :     /* Get the AWT */
      93           0 :     awt.version = JAWT_VERSION_1_3;
      94           0 :     result = JAWT_GetAWT(env, &awt);
      95           0 :     if (result == JNI_FALSE)
      96           0 :         ThrowException(env, "java/lang/RuntimeException", "JAWT_GetAWT failed");
      97             : 
      98             :                                 /* Get the drawing surface */
      99           0 :     if ((ds = awt.GetDrawingSurface(env, obj_this)) == NULL)
     100           0 :         return 0L;
     101             : 
     102             :     /* Lock the drawing surface */
     103           0 :     lock = ds->Lock(ds);
     104           0 :     if ( (lock & JAWT_LOCK_ERROR) != 0)
     105           0 :         ThrowException(env, "java/lang/RuntimeException",
     106             :                        "Could not get AWT drawing surface.");
     107             : 
     108             :     /* Get the drawing surface info */
     109           0 :     dsi = ds->GetDrawingSurfaceInfo(ds);
     110             : 
     111             :     /* Get the platform-specific drawing info */
     112           0 :     dsi_x11 = (JAWT_X11DrawingSurfaceInfo*)dsi->platformInfo;
     113             : 
     114           0 :     drawable = dsi_x11->drawable;
     115             : 
     116             :     /* Free the drawing surface info */
     117           0 :     ds->FreeDrawingSurfaceInfo(dsi);
     118             :     /* Unlock the drawing surface */
     119           0 :     ds->Unlock(ds);
     120             :     /* Free the drawing surface */
     121           0 :     awt.FreeDrawingSurface(ds);
     122             : 
     123           0 :     return ((jlong)drawable);
     124             : }
     125             : 
     126             : 
     127             : 
     128             : 
     129             : 
     130             : 
     131             : 
     132             : 
     133             : 
     134             : 
     135             : 
     136             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10