From ed5640d8b587fbcfed7dd7967f3de04b37a76f26 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 11:06:44 +0200 Subject: Adding upstream version 4:7.4.7. Signed-off-by: Daniel Baumann --- .../DesktopEnvironment/nativelib/unix/Makefile | 72 ++++++++ .../DesktopEnvironment/nativelib/unix/nativeview.c | 112 +++++++++++++ .../DesktopEnvironment/nativelib/unix/nativeview.h | 64 ++++++++ .../DesktopEnvironment/nativelib/windows/Makefile | 77 +++++++++ .../nativelib/windows/nativeview.c | 181 +++++++++++++++++++++ .../nativelib/windows/nativeview.def | 3 + .../nativelib/windows/nativeview.h | 64 ++++++++ 7 files changed, 573 insertions(+) create mode 100644 odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/nativelib/unix/Makefile create mode 100644 odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/nativelib/unix/nativeview.c create mode 100644 odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/nativelib/unix/nativeview.h create mode 100644 odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/nativelib/windows/Makefile create mode 100644 odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/nativelib/windows/nativeview.c create mode 100644 odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/nativelib/windows/nativeview.def create mode 100644 odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/nativelib/windows/nativeview.h (limited to 'odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/nativelib') diff --git a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/nativelib/unix/Makefile b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/nativelib/unix/Makefile new file mode 100644 index 000000000..aa7a158b8 --- /dev/null +++ b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/nativelib/unix/Makefile @@ -0,0 +1,72 @@ +#************************************************************************* +# +# The Contents of this file are made available subject to the terms of +# the BSD license. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. Neither the name of Sun Microsystems, Inc. nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR +# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE +# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +#************************************************************************** + +# Builds the OfficeDevDesktopEnvironment native library of the Developers Guide. + +PRJ=../../../../../.. +SETTINGS=$(PRJ)/settings + +include $(SETTINGS)/settings.mk +include $(SETTINGS)/std.mk + +# Define non-platform/compiler specific settings +SHL_NAME=nativeview +SHL_LIBRARY=$(SHAREDLIB_OUT)/$(SHAREDLIB_PRE)$(SHL_NAME).$(SHAREDLIB_EXT) + +OUT_SHL_SLO=$(OUT_SLO)/nativeview + +CFILES = nativeview.c + +SLOFILES = $(patsubst %.c,$(OUT_SHL_SLO)/%.$(OBJ_EXT),$(CFILES)) + + +# Targets +.PHONY: ALL +ALL : $(SHL_LIBRARY) + +include $(SETTINGS)/stdtarget.mk + +$(OUT_SHL_SLO)/%.$(OBJ_EXT) : %.c + -$(MKDIR) $(subst /,$(PS),$(@D)) + $(CC) $(CC_FLAGS_JNI) $(CC_INCLUDES) $(SDK_JAVA_INCLUDES) $(CC_DEFINES_JNI) $(CC_OUTPUT_SWITCH)$(subst /,$(PS),$@) $< + +$(SHAREDLIB_OUT)/$(SHAREDLIB_PRE)$(SHL_NAME).$(SHAREDLIB_EXT) : $(SLOFILES) + -$(MKDIR) $(subst /,$(PS),$(@D)) + $(LINK) $(LIBRARY_LINK_FLAGS) $(LINK_LIBS) $(LINK_JAVA_LIBS) -o $@ $< \ + -ljawt $(CPPUHELPERLIB) $(CPPULIB) $(SALLIB) $(STDC++LIB) + +.PHONY: clean +clean : + -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_SHL_SLO)) + -$(DEL) $(subst /,$(PS),$(SHAREDLIB_OUT))$(PS)*$(SHL_NAME)*.* diff --git a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/nativelib/unix/nativeview.c b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/nativelib/unix/nativeview.c new file mode 100644 index 000000000..5343f85e9 --- /dev/null +++ b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/nativelib/unix/nativeview.c @@ -0,0 +1,112 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * The Contents of this file are made available subject to the terms of + * the BSD license. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Sun Microsystems, Inc. nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + *************************************************************************/ + +#include +#include +#include + +#include "jawt.h" +#include "jawt_md.h" +#include "nativeview.h" + +#define MY_ASSERT(X,S) if (!X) { fprintf(stderr,S); return 0;} + +#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: NativeView + * Method: getNativeWindowSystemType + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_NativeView_getNativeWindowSystemType + (JNIEnv * env, jobject obj_this) +{ + return SYSTEM_XWINDOW; +} + +/*****************************************************************************/ +/* + * Class: NativeView + * Method: getNativeWindow + * Signature: ()J + */ +JNIEXPORT jlong JNICALL Java_NativeView_getNativeWindow + (JNIEnv * env, jobject obj_this) +{ + jboolean result ; + jint lock ; + JAWT awt ; + JAWT_DrawingSurface* ds ; + JAWT_DrawingSurfaceInfo* dsi ; + JAWT_X11DrawingSurfaceInfo* dsi_x11 ; + Drawable drawable; + + /* Get the AWT */ + awt.version = JAWT_VERSION_1_3; + result = JAWT_GetAWT(env, &awt); + MY_ASSERT(result != JNI_FALSE,"wrong jawt version"); + + /* Get the drawing surface */ + if ((ds = awt.GetDrawingSurface(env, obj_this)) == NULL) + return 0; + + /* Lock the drawing surface */ + lock = ds->Lock(ds); + MY_ASSERT((lock & JAWT_LOCK_ERROR)==0,"can't lock the drawing surface"); + + /* 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; + + /* 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; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/nativelib/unix/nativeview.h b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/nativelib/unix/nativeview.h new file mode 100644 index 000000000..99207192f --- /dev/null +++ b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/nativelib/unix/nativeview.h @@ -0,0 +1,64 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * The Contents of this file are made available subject to the terms of + * the BSD license. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Sun Microsystems, Inc. nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + *************************************************************************/ + +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include +/* Header for class org_openoffice_OpenOffice */ + +#ifndef _Included_NativeView +#define _Included_NativeView +#ifdef __cplusplus +extern "C" { +#endif +/* + * Class: org_openoffice_OpenOffice + * Method: getNativeWindowSystemType + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_NativeView_getNativeWindowSystemType(JNIEnv*, jobject); + +/* + * Class: org_openoffice_OpenOffice + * Method: getNativeWindow + * Signature: ()J + */ +JNIEXPORT jlong JNICALL Java_NativeView_getNativeWindow(JNIEnv*, jobject); + +#ifdef __cplusplus +} +#endif +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/nativelib/windows/Makefile b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/nativelib/windows/Makefile new file mode 100644 index 000000000..62980a2ee --- /dev/null +++ b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/nativelib/windows/Makefile @@ -0,0 +1,77 @@ +#************************************************************************* +# +# The Contents of this file are made available subject to the terms of +# the BSD license. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. Neither the name of Sun Microsystems, Inc. nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR +# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE +# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +#************************************************************************** + +# Builds the OfficeDevDesktopEnvironment native library of the Developers Guide. + +PRJ=../../../../../.. +SETTINGS=$(PRJ)/settings + +include $(SETTINGS)/settings.mk +include $(SETTINGS)/std.mk + +# Define non-platform/compiler specific settings +SHL_NAME=nativeview +SHL_LIBRARY=$(SHAREDLIB_OUT)/$(SHAREDLIB_PRE)$(SHL_NAME).$(SHAREDLIB_EXT) + +OUT_SHL_SLO=$(OUT_SLO)/nativeview +OUT_SHL_MISC=$(OUT_MISC)/nativeview + +CFILES = nativeview.c + +SLOFILES = $(patsubst %.c,$(OUT_SHL_SLO)/%.$(OBJ_EXT),$(CFILES)) + +# Targets +.PHONY: ALL +ALL : \ + $(SHL_LIBRARY) + +include $(SETTINGS)/stdtarget.mk + +$(OUT_SHL_SLO)/%.$(OBJ_EXT) : %.c + -$(MKDIR) $(subst /,$(PS),$(@D)) + $(CC) $(CC_FLAGS_JNI) $(CC_INCLUDES) $(SDK_JAVA_INCLUDES) $(CC_DEFINES_JNI) $(CC_OUTPUT_SWITCH)$(subst /,$(PS),$@) $< + +$(SHAREDLIB_OUT)/$(SHAREDLIB_PRE)$(SHL_NAME).$(SHAREDLIB_EXT) : $(SLOFILES) $(SHL_NAME).def + -$(MKDIR) $(subst /,$(PS),$(@D)) + -$(MKDIR) $(subst /,$(PS),$(OUT_SHL_MISC)) + $(LINK) $(LIBRARY_LINK_FLAGS) /DEF:$(SHL_NAME).def /OUT:$@ \ + /MAP:$(OUT_SHL_MISC)/$(SHL_NAME).map $(LINK_JAVA_LIBS) \ + $(SLOFILES) jawt.lib $(LIBO_SDK_LDFLAGS_STDLIBS) user32.lib + $(LINK_MANIFEST) + +.PHONY: clean +clean : + -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_SHL_SLO)) + -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_SHL_MISC)) + -$(DEL) $(subst \\,\,$(subst /,$(PS),$(SHAREDLIB_OUT))$(PS)*$(SHL_NAME)*.*) diff --git a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/nativelib/windows/nativeview.c b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/nativelib/windows/nativeview.c new file mode 100644 index 000000000..2de998c69 --- /dev/null +++ b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/nativelib/windows/nativeview.c @@ -0,0 +1,181 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * The Contents of this file are made available subject to the terms of + * the BSD license. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Sun Microsystems, Inc. nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + *************************************************************************/ + +#include + +#include "jawt.h" +#include "jawt_md.h" +#include "NativeView.h" + +#define MY_ASSERT(X,S) if (!X) { fprintf(stderr,"%s\n",S); return 0;} + +#define SYSTEM_WIN32 1 +#define SYSTEM_WIN16 2 +#define SYSTEM_JAVA 3 +#define SYSTEM_OS2 4 +#define SYSTEM_MAC 5 +#define SYSTEM_XWINDOW 6 + +// property name to register own window procedure on hwnd +#define OLD_PROC_KEY "oldwindowproc" +// signature of this window procedure +static LRESULT APIENTRY NativeViewWndProc( HWND , UINT , WPARAM , LPARAM ); + +/***************************************************************************** + * + * Class : NativeView + * Method : getNativeWindowSystemType + * Signature : ()I + * Description: returns an identifier for the current operating system + */ +JNIEXPORT jint JNICALL Java_NativeView_getNativeWindowSystemType + (JNIEnv * env, jobject obj_this) +{ + return SYSTEM_WIN32; +} + +/***************************************************************************** + * + * Class : NativeView + * Method : getNativeWindow + * Signature : ()J + * Description: returns the native systemw window handle of this object + */ +JNIEXPORT jlong JNICALL Java_NativeView_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); + MY_ASSERT(result!=JNI_FALSE,"wrong jawt version"); + + /* Get the drawing surface */ + if ((ds = awt.GetDrawingSurface(env, obj_this)) == NULL) + return 0; + + /* Lock the drawing surface */ + lock = ds->Lock(ds); + MY_ASSERT((lock & JAWT_LOCK_ERROR)==0,"can't lock the drawing surface"); + + /* 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! Otherwise + multiple instances will be registered + and calls on such construct produce + a stack overflow. + */ + if (GetProp( hWnd, OLD_PROC_KEY )==0) + { + hFuncPtr = SetWindowLongPtr( hWnd, GWLP_WNDPROC, (LONG_PTR)NativeViewWndProc ); + SetProp( hWnd, OLD_PROC_KEY, (HANDLE)hFuncPtr ); + } + + return (jlong)hWnd; +} + +/***************************************************************************** + * + * Class : - + * Method : NativeViewWndProc + * Signature : - + * Description: registered window handler to intercept window messages between + * java and office process + */ +static LRESULT APIENTRY NativeViewWndProc( + HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + HANDLE hFuncPtr; + + /* resize new created child window to fill out the java window complete */ + if (uMsg==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); + } + } + /* handle normal resize events */ + else if(uMsg==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); + } + + /* forward request to original handler which is intercepted by this window procedure */ + hFuncPtr = GetProp(hWnd, OLD_PROC_KEY); + MY_ASSERT(hFuncPtr,"lost original window proc handler"); + return CallWindowProc( hFuncPtr, hWnd, uMsg, wParam, lParam); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/nativelib/windows/nativeview.def b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/nativelib/windows/nativeview.def new file mode 100644 index 000000000..f9ba2a78b --- /dev/null +++ b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/nativelib/windows/nativeview.def @@ -0,0 +1,3 @@ +EXPORTS +Java_NativeView_getNativeWindowSystemType +Java_NativeView_getNativeWindow diff --git a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/nativelib/windows/nativeview.h b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/nativelib/windows/nativeview.h new file mode 100644 index 000000000..99207192f --- /dev/null +++ b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/nativelib/windows/nativeview.h @@ -0,0 +1,64 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * The Contents of this file are made available subject to the terms of + * the BSD license. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Sun Microsystems, Inc. nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + *************************************************************************/ + +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include +/* Header for class org_openoffice_OpenOffice */ + +#ifndef _Included_NativeView +#define _Included_NativeView +#ifdef __cplusplus +extern "C" { +#endif +/* + * Class: org_openoffice_OpenOffice + * Method: getNativeWindowSystemType + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_NativeView_getNativeWindowSystemType(JNIEnv*, jobject); + +/* + * Class: org_openoffice_OpenOffice + * Method: getNativeWindow + * Signature: ()J + */ +JNIEXPORT jlong JNICALL Java_NativeView_getNativeWindow(JNIEnv*, jobject); + +#ifdef __cplusplus +} +#endif +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit v1.2.3