tdf#162563 Remove Java applet code and references from embeddedobj

Change-Id: If3e7ab1cb45c988f3f39fc2f73377c77dc9972f4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178873
Tested-by: Jenkins
Reviewed-by: Ilmari Lauhakangas <ilmari.lauhakangas@libreoffice.org>
This commit is contained in:
Manish Bera
2024-12-26 12:14:07 +01:00
committed by Ilmari Lauhakangas
parent b6a9cc00c4
commit 117d31400c
4 changed files with 0 additions and 2258 deletions
@@ -1,281 +0,0 @@
/*
* 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/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
package embeddedobj.test;
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
import java.net.*;
import java.io.*;
import com.sun.star.awt.XBitmap;
import com.sun.star.awt.XDevice;
import com.sun.star.awt.XDisplayBitmap;
import com.sun.star.awt.XGraphics;
import com.sun.star.awt.XWindow;
import com.sun.star.awt.XWindowPeer;
import com.sun.star.awt.XToolkit;
import com.sun.star.awt.XSystemChildFactory;
import com.sun.star.awt.WindowDescriptor;
import com.sun.star.awt.WindowClass;
import com.sun.star.awt.WindowAttribute;
import com.sun.star.awt.XPaintListener;
import com.sun.star.awt.PaintEvent;
import com.sun.star.awt.XMouseListener;
import com.sun.star.awt.XMouseMotionListener;
import com.sun.star.awt.MouseEvent;
import com.sun.star.awt.Point;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.Any;
import com.sun.star.lang.XMultiServiceFactory;
import com.sun.star.task.XJob;
import com.sun.star.beans.NamedValue;
class BitmapPainter implements XPaintListener, XMouseListener, XMouseMotionListener, XJob
{
private XWindow m_xWindow;
private XBitmap m_xBitmap;
private com.sun.star.awt.Rectangle m_aDrawRect;
private Object m_oImageLock;
private PaintThread m_aPaintThread;
private boolean m_bFree = true;
private boolean m_bProceedWithPainting = true;
// Methods
public BitmapPainter( XJob xJob, XWindow xWindow, XBitmap xBitmap, com.sun.star.awt.Rectangle aDrawRect )
{
if ( xJob == null )
{
System.out.println( "No mainthreadexecutor is provided to BitmapPainter on init!" );
throw new com.sun.star.uno.RuntimeException();
}
if ( xWindow == null )
{
System.out.println( "No window is provided to BitmapPainter on init!" );
throw new com.sun.star.uno.RuntimeException();
}
m_xWindow = xWindow;
m_xBitmap = xBitmap;
m_aDrawRect = aDrawRect;
m_oImageLock = new Object();
m_aPaintThread = new PaintThread( m_xWindow );
m_aPaintThread.start();
m_xWindow.addPaintListener( this );
m_xWindow.addMouseListener( this );
m_xWindow.addMouseMotionListener( this );
}
public void disconnectListener()
{
m_aPaintThread.disposeThread();
m_xWindow.removePaintListener( this );
m_xWindow.removeMouseListener( this );
m_xWindow.removeMouseMotionListener( this );
}
public void setBitmap( XBitmap xBitmap )
{
synchronized( m_oImageLock )
{
m_xBitmap = xBitmap;
}
}
public void setPos( com.sun.star.awt.Point aPoint )
{
synchronized( m_oImageLock )
{
m_aDrawRect.X = aPoint.X;
m_aDrawRect.Y = aPoint.Y;
}
}
public void setRect( com.sun.star.awt.Rectangle aRect )
{
synchronized( m_oImageLock )
{
m_aDrawRect = aRect;
}
}
public void setSize( com.sun.star.awt.Size aSize )
{
synchronized( m_oImageLock )
{
m_aDrawRect.Width = aSize.Width;
m_aDrawRect.Height = aSize.Height;
}
}
public void stopPainting()
{
m_bProceedWithPainting = false;
}
public void startPainting()
{
m_bProceedWithPainting = true;
}
// XPaintListener
public void windowPaint( PaintEvent e )
{
if ( !m_bProceedWithPainting )
return;
XBitmap xBitmap = null;
com.sun.star.awt.Rectangle aRect = null;
synchronized( m_oImageLock )
{
xBitmap = m_xBitmap;
aRect = m_aDrawRect;
}
m_aPaintThread.setPaintRequest( xBitmap, aRect, e.UpdateRect );
System.out.println( "VCL window paint event!" );
}
// XMouseListener
public void mousePressed( MouseEvent e )
{
}
public void mouseReleased( MouseEvent e )
{
}
public void mouseEntered( MouseEvent e )
{
}
public void mouseExited( MouseEvent e )
{
}
// XMouseMotionListener
public void mouseDragged( MouseEvent e )
{
// TODO: react to resizing of object bitmap
// if the object is inplace active the object must control resizing
}
public void mouseMoved( MouseEvent e )
{
}
// XEventListener
public void disposing( com.sun.star.lang.EventObject e )
{
// do nothing, the window can die only when the application is closed
}
// XJob
public Object execute( NamedValue[] pValues )
{
/*
// means request for painting
XBitmap xBitmap = null;
com.sun.star.awt.Rectangle aRect = null;
synchronized( m_oImageLock )
{
xBitmap = m_xBitmap;
aRect = m_aDrawRect;
}
System.out.println( "The bitmap is going to be painted!" );
try {
XDevice xDevice = (XDevice)UnoRuntime.queryInterface( XDevice.class, m_xWindow );
if ( xDevice != null )
{
System.out.println( "Step1" );
XGraphics xGraphics = xDevice.createGraphics();
if ( xBitmap != null )
{
System.out.println( "Step2" );
XDisplayBitmap xDisplayBitmap = xDevice.createDisplayBitmap( xBitmap );
com.sun.star.awt.Size aSize = xBitmap.getSize();
xGraphics.draw( xDisplayBitmap, 0, 0, aSize.Width, aSize.Height,
aRect.X, aRect.Y, aRect.Width, aRect.Height );
}
System.out.println( "Step3" );
xGraphics.drawRect( aRect.X - 1, aRect.Y - 1, aRect.Width + 2, aRect.Height + 2 );
// draw resize squares
System.out.println( "Step4" );
xGraphics.drawRect( aRect.X - 2, aRect.Y - 2, 4, 4 );
xGraphics.drawRect( aRect.X + aRect.Width - 2, aRect.Y - 2, 4, 4 );
xGraphics.drawRect( aRect.X - 2, aRect.Y + aRect.Height - 2, 4, 4 );
xGraphics.drawRect( aRect.X + aRect.Width - 2, aRect.Y + aRect.Height - 2, 4, 4 );
System.out.println( "Step5" );
System.out.println( "The bitmap is painted by BitmapPainter!" );
}
}
catch ( Exception e )
{
}
m_bFree = true;
*/
return Any.VOID;
}
};
File diff suppressed because it is too large Load Diff
@@ -1,141 +0,0 @@
/*
* 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/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
package embeddedobj.test;
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
import java.net.*;
import java.io.*;
import java.lang.Thread;
import com.sun.star.awt.XBitmap;
import com.sun.star.awt.XDevice;
import com.sun.star.awt.XDisplayBitmap;
import com.sun.star.awt.XGraphics;
import com.sun.star.awt.XWindow;
import com.sun.star.awt.XWindowPeer;
import com.sun.star.awt.XToolkit;
import com.sun.star.awt.XSystemChildFactory;
import com.sun.star.awt.WindowDescriptor;
import com.sun.star.awt.WindowClass;
import com.sun.star.awt.WindowAttribute;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.lang.XMultiServiceFactory;
class PaintThread extends java.lang.Thread
{
private XWindow m_xWindow;
private XBitmap m_xBitmap;
private com.sun.star.awt.Rectangle m_aRect;
private Object m_oRequestsLock;
private boolean m_bToPaint = false;
private boolean m_bDisposed = false;
public static boolean interceptedRects( com.sun.star.awt.Rectangle aRect1, com.sun.star.awt.Rectangle aRect2 )
{
return ( ( aRect1.X <= aRect2.X && aRect2.X <= aRect1.X + aRect1.Width
|| aRect1.X <= aRect2.X + aRect2.Width && aRect2.X + aRect2.Width <= aRect1.X + aRect1.Width
|| aRect2.X <= aRect1.X && aRect1.X <= aRect2.X + aRect2.Width
|| aRect2.X <= aRect1.X + aRect1.Width && aRect1.X + aRect1.Width <= aRect2.X + aRect2.Width )
&& ( aRect1.Y <= aRect2.Y && aRect2.Y <= aRect1.Y + aRect1.Height
|| aRect1.Y <= aRect2.Y + aRect2.Height && aRect2.Y + aRect2.Height <= aRect1.Y + aRect1.Height
|| aRect2.Y <= aRect1.Y && aRect1.Y <= aRect2.Y + aRect2.Height
|| aRect2.Y <= aRect1.Y + aRect1.Height && aRect1.Y + aRect1.Height <= aRect2.Y + aRect2.Height ) );
}
public PaintThread( XWindow xWindow )
{
m_oRequestsLock = new Object();
m_xWindow = xWindow;
}
public void setPaintRequest( XBitmap xBitmap, com.sun.star.awt.Rectangle aRect, com.sun.star.awt.Rectangle aClip )
{
synchronized( m_oRequestsLock )
{
if ( PaintThread.interceptedRects( aRect, aClip ) )
{
m_xBitmap = xBitmap;
m_aRect = aRect;
m_bToPaint = true;
}
}
}
public void disposeThread()
{
m_bDisposed = true;
}
public void run()
{
while( !m_bDisposed )
{
try {
Thread.sleep( 200 );
} catch( Exception e ) {}
XBitmap xBitmap = null;
com.sun.star.awt.Rectangle aRect = null;
boolean bPaint = false;
synchronized( m_oRequestsLock )
{
if ( m_bToPaint )
{
xBitmap = m_xBitmap;
aRect = m_aRect;
m_bToPaint = false;
bPaint = true;
}
}
if ( bPaint )
{
XDevice xDevice = (XDevice)UnoRuntime.queryInterface( XDevice.class, m_xWindow );
if ( xDevice != null )
{
XGraphics xGraphics = xDevice.createGraphics();
if ( xBitmap != null )
{
XDisplayBitmap xDisplayBitmap = xDevice.createDisplayBitmap( xBitmap );
com.sun.star.awt.Size aSize = xBitmap.getSize();
xGraphics.draw( xDisplayBitmap, 0, 0, aSize.Width, aSize.Height,
aRect.X, aRect.Y, aRect.Width, aRect.Height );
}
xGraphics.drawLine( aRect.X - 1, aRect.Y - 1,
aRect.X + aRect.Width + 1, aRect.Y - 1 );
xGraphics.drawLine( aRect.X + aRect.Width + 1, aRect.Y - 1,
aRect.X + aRect.Width + 1, aRect.Y + aRect.Height + 1 );
xGraphics.drawLine( aRect.X + aRect.Width + 1, aRect.Y + aRect.Height + 1,
aRect.X - 1, aRect.Y + aRect.Height + 1 );
xGraphics.drawLine( aRect.X - 1, aRect.Y + aRect.Height + 1,
aRect.X - 1, aRect.Y - 1 );
}
}
}
}
};
@@ -1,155 +0,0 @@
/*
* 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/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
package embeddedobj.test;
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
import java.net.*;
import java.io.*;
import com.sun.star.awt.XBitmap;
import com.sun.star.awt.XWindow;
import com.sun.star.awt.XWindowPeer;
import com.sun.star.awt.XToolkit;
import com.sun.star.awt.XSystemChildFactory;
import com.sun.star.awt.WindowDescriptor;
import com.sun.star.awt.WindowClass;
import com.sun.star.awt.WindowAttribute;
import com.sun.star.awt.VclWindowPeerAttribute;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.AnyConverter;
import com.sun.star.uno.Any;
import com.sun.star.lang.XMultiServiceFactory;
import com.sun.star.lang.XSingleServiceFactory;
class WindowHelper {
public static XWindow createWindow( XMultiServiceFactory xFactory, NativeView aParent, java.awt.Rectangle aBounds )
{
XWindow xWindow = null;
XToolkit xToolkit = null;
// get access to toolkit of remote office to create the container window of new target frame
try{
xToolkit = (XToolkit)UnoRuntime.queryInterface( XToolkit.class,
xFactory.createInstance("com.sun.star.awt.Toolkit") );
}
catch( Exception ex )
{
return null;
}
XSystemChildFactory xChildFactory = (XSystemChildFactory)UnoRuntime.queryInterface(
XSystemChildFactory.class,
xToolkit);
try
{
XWindowPeer xPeer = null;
Integer nHandle = aParent.getHWND();
short nSystem = (short)aParent.getNativeWindowSystemType();
byte[] lProcID = new byte[0];
/*
try {
xPeer = xChildFactory.createSystemChild((Object)nHandle, lProcID, nSystem);
}
catch( Exception e )
{}
*/
if (xPeer==null)
{
JavaWindowPeerFake aWrapper = new JavaWindowPeerFake(aParent);
XWindowPeer xParentPeer = (XWindowPeer)UnoRuntime.queryInterface(
XWindowPeer.class,
aWrapper);
WindowDescriptor aDescriptor = new WindowDescriptor();
aDescriptor.Type = WindowClass.TOP;
aDescriptor.WindowServiceName = "workwindow";
aDescriptor.ParentIndex = 1;
aDescriptor.Parent = xParentPeer;
aDescriptor.Bounds = new com.sun.star.awt.Rectangle( (int)aBounds.getX(),
(int)aBounds.getY(),
(int)aBounds.getWidth(),
(int)aBounds.getHeight() );
System.out.println( "The rectangle for vcl window is:\nx = " + (int)aBounds.getX()
+ "; y = " + (int)aBounds.getY()
+ "; width = " + (int)aBounds.getWidth()
+ "; height = " + (int)aBounds.getHeight() );
if (nSystem == com.sun.star.lang.SystemDependent.SYSTEM_WIN32)
aDescriptor.WindowAttributes = WindowAttribute.SHOW;
else
aDescriptor.WindowAttributes = WindowAttribute.SYSTEMDEPENDENT;
aDescriptor.WindowAttributes |= VclWindowPeerAttribute.CLIPCHILDREN;
xPeer = xToolkit.createWindow( aDescriptor );
}
xWindow = (XWindow)UnoRuntime.queryInterface( XWindow.class, xPeer);
if ( xWindow != null )
xWindow.setPosSize( (int)aBounds.getX(),
(int)aBounds.getY(),
(int)aBounds.getWidth(),
(int)aBounds.getHeight(),
com.sun.star.awt.PosSize.POSSIZE );
}
catch( Exception ex1 )
{
System.out.println( "Exception on VCL window creation: " + ex1 );
xWindow = null;
}
return xWindow;
}
public static XBitmap getVCLBitmapFromBytes( XMultiServiceFactory xFactory, Object aAny )
{
if ( !AnyConverter.isArray( aAny ) )
throw new com.sun.star.uno.RuntimeException();
Object[] aArgs = new Object[1];
aArgs[0] = aAny;
XBitmap xResult = null;
try {
XSingleServiceFactory xBitmapFactory = (XSingleServiceFactory)UnoRuntime.queryInterface(
XSingleServiceFactory.class,
xFactory.createInstance( "com.sun.star.embed.BitmapCreator" ) );
xResult = (XBitmap)UnoRuntime.queryInterface(
XBitmap.class,
xBitmapFactory.createInstanceWithArguments( aArgs ) );
}
catch( Exception e )
{
System.out.println( "Could not create VCL bitmap based on sequence," );
System.out.println( "exception: " + e );
}
return xResult;
}
};