Kaydet (Commit) f3071b04 authored tarafından Tor Lillqvist's avatar Tor Lillqvist Kaydeden (comit) Tomaž Vajngerl

Remove more obsolete Android code: The 'AppSupport' stuff

(cherry picked from commit 72a688db)
üst e77fb2cc
// -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
//
// This file is part of the LibreOffice project.
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
// Native functions that are used by "desktop" approach apps. That means apps
// that have a "real" LibreOffice "main loop" running (headless).
package org.libreoffice.android;
import android.graphics.Bitmap;
public final class AppSupport
{
/* In desktop */
public static native void runMain();
/* In vcl */
public static native void renderVCL(Bitmap bitmap);
public static native void registerForDamageCallback(Class destinationClass);
public static native void setViewSize(int width, int height);
public static native void key(char c);
public static native void touch(int action, int x, int y);
public static native void zoom(float scale, int x, int y);
public static native void scroll(int x, int y);
}
// vim:set shiftwidth=4 softtabstop=4 expandtab:
......@@ -105,21 +105,6 @@ extern "C" int DESKTOP_DLLPUBLIC soffice_main()
#if defined(ANDROID) || defined(IOS)
#ifdef ANDROID
extern "C" SAL_JNI_EXPORT void JNICALL
Java_org_libreoffice_android_AppSupport_runMain(JNIEnv* /* env */,
jobject /* clazz */)
{
int nRet;
do {
nRet = soffice_main();
LOGI("soffice_main returned %d", nRet);
} while (nRet == EXITHELPER_NORMAL_RESTART ||
nRet == EXITHELPER_CRASH_WITH_RESTART); // pretend to re-start.
}
#endif
extern "C" void PtylTestEncryptionAndExport(const char *pathname)
{
OUString sUri(pathname, strlen(pathname), RTL_TEXTENCODING_UTF8);
......
......@@ -464,15 +464,6 @@ print ("""
if options.java:
print ("""
// Guard against possible function-level link-time pruning of
// "unused" code. We need to pull these in, too, as they aren't in
// any of the libs we link with -Wl,--whole-archive. Is this necessary?
extern void Java_org_libreoffice_android_AppSupport_runMain();
volatile void *p = (void *) Java_org_libreoffice_android_AppSupport_runMain;
extern void Java_org_libreoffice_android_AppSupport_renderVCL();
p = (void *) Java_org_libreoffice_android_AppSupport_renderVCL;
extern void Java_org_libreoffice_kit_LibreOfficeKit_initializeNative();
p = (void *) Java_org_libreoffice_kit_LibreOfficeKit_initializeNative;
......
......@@ -382,165 +382,4 @@ int AndroidSalSystem::ShowNativeDialog( const OUString& rTitle,
return 0;
}
// public static native void renderVCL(Bitmap bitmap);
extern "C" SAL_JNI_EXPORT void JNICALL
Java_org_libreoffice_android_AppSupport_renderVCL(JNIEnv *env,
jobject /* clazz */,
jobject bitmap)
{
AndroidBitmapInfo info;
void* pixels;
int ret;
if ((ret = AndroidBitmap_getInfo(env, bitmap, &info)) < 0) {
LOGI("AndroidBitmap_getInfo() failed ! error=%d", ret);
return;
}
if ((ret = AndroidBitmap_lockPixels(env, bitmap, &pixels)) < 0) {
LOGI("AndroidBitmap_lockPixels() failed ! error=%d", ret);
}
/*
typedef struct ANativeWindow_Buffer {
// The number of pixels that are show horizontally.
int32_t width;
// The number of pixels that are shown vertically.
int32_t height;
// The number of *pixels* that a line in the buffer takes in
// memory. This may be >= width.
int32_t stride;
// The format of the buffer. One of WINDOW_FORMAT_*
int32_t format;
// The actual bits.
void* bits;
// Do not touch.
uint32_t reserved[6];
} ANativeWindow_Buffer;
*/
ANativeWindow_Buffer dummyOut; // look like a window for now ...
dummyOut.width = info.width;
dummyOut.height = info.height;
dummyOut.stride = info.stride / 4; // sigh !
dummyOut.format = info.format;
dummyOut.bits = pixels;
AndroidSalInstance::getInstance()->RedrawWindows (&dummyOut);
AndroidBitmap_unlockPixels(env, bitmap);
}
// public static native void registerForDamageCallback(Class destinationClass);
extern "C" SAL_JNI_EXPORT void JNICALL
Java_org_libreoffice_android_AppSupport_registerForDamageCallback(JNIEnv * env,
jobject /* clazz */,
jclass destinationClass)
{
appClass = (jclass) env->NewGlobalRef(destinationClass);
}
// public static native void setViewSize(int width, int height);
extern "C" SAL_JNI_EXPORT void JNICALL
Java_org_libreoffice_android_AppSupport_setViewSize(JNIEnv * /* env */,
jobject /* clazz */,
jint width,
jint height)
{
// Horrible
viewWidth = width;
viewHeight = height;
}
// public static native void key(char c);
extern "C" SAL_JNI_EXPORT void JNICALL
Java_org_libreoffice_android_AppSupport_key(JNIEnv * /* env */,
jobject /* clazz */,
jchar c)
{
SalFrame *pFocus = AndroidSalInstance::getInstance()->getFocusFrame();
if (pFocus) {
KeyEvent aEvent(c, c, 0);
Application::PostKeyEvent(VCLEVENT_WINDOW_KEYINPUT, pFocus->GetWindow(), &aEvent);
Application::PostKeyEvent(VCLEVENT_WINDOW_KEYUP, pFocus->GetWindow(), &aEvent);
}
else
LOGW("No focused frame to emit event on");
}
// public static native void touch(int action, int x, int y);
extern "C" SAL_JNI_EXPORT void JNICALL
Java_org_libreoffice_android_AppSupport_touch(JNIEnv * /* env */,
jobject /* clazz */,
jint action,
jint x,
jint y)
{
SalFrame *pFocus = AndroidSalInstance::getInstance()->getFocusFrame();
if (pFocus) {
MouseEvent aEvent;
sal_uLong nEvent;
switch (action) {
case AMOTION_EVENT_ACTION_DOWN:
aEvent = MouseEvent(Point(x, y), 1, MouseEventModifiers::SIMPLECLICK, MOUSE_LEFT);
nEvent = VCLEVENT_WINDOW_MOUSEBUTTONDOWN;
break;
case AMOTION_EVENT_ACTION_UP:
aEvent = MouseEvent(Point(x, y), 1, MouseEventModifiers::SIMPLECLICK, MOUSE_LEFT);
nEvent = VCLEVENT_WINDOW_MOUSEBUTTONUP;
break;
case AMOTION_EVENT_ACTION_MOVE:
aEvent = MouseEvent(Point(x, y), 1, MouseEventModifiers::SIMPLEMOVE, MOUSE_LEFT);
nEvent = VCLEVENT_WINDOW_MOUSEMOVE;
break;
default:
LOGE("AppSupport.touch: Invalid action %d", action);
return;
}
Application::PostMouseEvent(nEvent, pFocus->GetWindow(), &aEvent);
}
else
LOGW("No focused frame to emit event on");
}
// public static native void zoom(float scale, int x, int y);
extern "C" SAL_JNI_EXPORT void JNICALL
Java_org_libreoffice_android_AppSupport_zoom(JNIEnv * /* env */,
jobject /* clazz */,
jfloat scale,
jint x,
jint y)
{
SalFrame *pFocus = AndroidSalInstance::getInstance()->getFocusFrame();
if (pFocus) {
SAL_INFO( "vcl.androidinst", "zoom: " << scale << "@(" << x << "," << y << ")" );
ZoomEvent aEvent( Point( x, y ), scale);
Application::PostZoomEvent(VCLEVENT_WINDOW_ZOOM, pFocus->GetWindow(), &aEvent);
}
else
LOGW("No focused frame to emit event on");
}
// public static native void scroll(int x, int y);
extern "C" SAL_JNI_EXPORT void JNICALL
Java_org_libreoffice_android_AppSupport_scroll(JNIEnv * /* env */,
jobject /* clazz */,
jint x,
jint y)
{
SalFrame *pFocus = AndroidSalInstance::getInstance()->getFocusFrame();
if (pFocus) {
SAL_INFO( "vcl.androidinst", "scroll: " << "(" << x << "," << y << ")" );
ScrollEvent aEvent( x, y );
Application::PostScrollEvent(VCLEVENT_WINDOW_SCROLL, pFocus->GetWindow(), &aEvent);
}
else
LOGW("No focused frame to emit event on");
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment