summaryrefslogtreecommitdiff
path: root/embeddedobj/test/Container1
diff options
context:
space:
mode:
authorKurt Zenker <kz@openoffice.org>2004-10-04 18:57:31 +0000
committerKurt Zenker <kz@openoffice.org>2004-10-04 18:57:31 +0000
commit40f032525ceec6ed28b47a5fe042fb6059af8d4d (patch)
tree58923380efee6c8fe29c887e02d6dda06e97aa91 /embeddedobj/test/Container1
parentfe1993c51cdb9926bfd321ed40b4df932f8318b6 (diff)
INTEGRATION: CWS mav09 (1.1.2); FILE ADDED
2004/02/23 09:43:36 mav 1.1.2.5: #115011# improve object painting 2004/02/19 10:31:38 mav 1.1.2.4: #115011# embedded object representation 2004/01/30 08:43:57 mav 1.1.2.3: #115011# create bitmap 2004/01/28 08:58:09 mav 1.1.2.2: #115011# bitmap painting 2004/01/27 15:56:03 mav 1.1.2.1: #115011# VCL window for container
Diffstat (limited to 'embeddedobj/test/Container1')
-rw-r--r--embeddedobj/test/Container1/WindowHelper.java137
1 files changed, 137 insertions, 0 deletions
diff --git a/embeddedobj/test/Container1/WindowHelper.java b/embeddedobj/test/Container1/WindowHelper.java
new file mode 100644
index 000000000000..289542b833ac
--- /dev/null
+++ b/embeddedobj/test/Container1/WindowHelper.java
@@ -0,0 +1,137 @@
+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;
+ }
+};
+