summaryrefslogtreecommitdiffstats
path: root/bundles/org.eclipse.swt/Eclipse SWT OLE Win32
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT OLE Win32')
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/COMObject.java1034
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OLE.java439
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleAutomation.java656
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleClientSite.java1494
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleControlSite.java982
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleEvent.java22
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleEventSink.java180
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleEventTable.java75
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleFrame.java805
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleFunctionDescription.java28
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleListener.java37
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleParameterDescription.java18
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OlePropertyChangeSink.java173
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OlePropertyDescription.java22
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/Variant.java1057
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/package.html20
16 files changed, 0 insertions, 7042 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/COMObject.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/COMObject.java
deleted file mode 100755
index 943cb3318e..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/COMObject.java
+++ /dev/null
@@ -1,1034 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.internal.ole.win32;
-
-import java.util.Hashtable;
-import org.eclipse.swt.*;
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.win32.*;
-
-
-public class COMObject {
-
- public int /*long*/ ppVtable;
-
- static private final int MAX_ARG_COUNT = 12;
- static private final int MAX_VTABLE_LENGTH = 80;
- static private Callback[][] Callbacks = new Callback[MAX_VTABLE_LENGTH][MAX_ARG_COUNT];
- static private Hashtable ObjectMap = new Hashtable();
-
-public COMObject(int[] argCounts) {
- int /*long*/[] callbackAddresses = new int /*long*/[argCounts.length];
- synchronized (Callbacks) {
- for (int i = 0, length = argCounts.length; i < length; i++){
- if ((Callbacks[i][argCounts[i]]) == null) {
- Callbacks[i][argCounts[i]] = new Callback(this.getClass(), "callback"+i, argCounts[i] + 1, true, COM.E_FAIL); //$NON-NLS-1$
- if (Callbacks[i][argCounts[i]].getAddress() == 0) SWT.error(SWT.ERROR_NO_MORE_CALLBACKS);
- }
- callbackAddresses[i] = Callbacks[i][argCounts[i]].getAddress();
- }
- }
-
- int /*long*/ pVtable = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, OS.PTR_SIZEOF * argCounts.length);
- COM.MoveMemory(pVtable, callbackAddresses, OS.PTR_SIZEOF * argCounts.length);
- ppVtable = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, OS.PTR_SIZEOF);
- COM.MoveMemory(ppVtable, new int /*long*/[] {pVtable}, OS.PTR_SIZEOF);
- ObjectMap.put(new LONG(ppVtable), this);
-}
-
-public static GUID IIDFromString(String lpsz) {
- // create a null terminated array of char
- char[] buffer = (lpsz +"\0").toCharArray();
-
- // invoke system method
- GUID lpiid = new GUID();
- if (COM.IIDFromString(buffer, lpiid) == COM.S_OK)
- return lpiid;
- return null;
-}
-
-static int /*long*/ callback0(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method0(args);
-}
-static int /*long*/ callback1(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method1(args);
-}
-static int /*long*/ callback2(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method2(args);
-}
-static int /*long*/ callback3(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method3(args);
-}
-static int /*long*/ callback4(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method4(args);
-}
-static int /*long*/ callback5(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method5(args);
-}
-static int /*long*/ callback6(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method6(args);
-}
-static int /*long*/ callback7(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method7(args);
-}
-static int /*long*/ callback8(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method8(args);
-}
-static int /*long*/ callback9(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method9(args);
-}
-static int /*long*/ callback10(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method10(args);
-}
-static int /*long*/ callback11(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method11(args);
-}
-static int /*long*/ callback12(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method12(args);
-}
-static int /*long*/ callback13(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method13(args);
-}
-static int /*long*/ callback14(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method14(args);
-}
-static int /*long*/ callback15(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method15(args);
-}
-static int /*long*/ callback16(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method16(args);
-}
-static int /*long*/ callback17(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method17(args);
-}
-static int /*long*/ callback18(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method18(args);
-}
-static int /*long*/ callback19(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method19(args);
-}
-static int /*long*/ callback20(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method20(args);
-}
-static int /*long*/ callback21(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method21(args);
-}
-static int /*long*/ callback22(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method22(args);
-}
-static int /*long*/ callback23(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method23(args);
-}
-static int /*long*/ callback24(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method24(args);
-}
-static int /*long*/ callback25(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method25(args);
-}
-static int /*long*/ callback26(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method26(args);
-}
-static int /*long*/ callback27(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method27(args);
-}
-static int /*long*/ callback28(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method28(args);
-}
-static int /*long*/ callback29(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method29(args);
-}
-static int /*long*/ callback30(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method30(args);
-}
-static int /*long*/ callback31(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method31(args);
-}
-static int /*long*/ callback32(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method32(args);
-}
-static int /*long*/ callback33(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method33(args);
-}
-static int /*long*/ callback34(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method34(args);
-}
-static int /*long*/ callback35(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method35(args);
-}
-static int /*long*/ callback36(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method36(args);
-}
-static int /*long*/ callback37(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method37(args);
-}
-static int /*long*/ callback38(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method38(args);
-}
-static int /*long*/ callback39(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method39(args);
-}
-static int /*long*/ callback40(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method40(args);
-}
-static int /*long*/ callback41(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method41(args);
-}
-static int /*long*/ callback42(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method42(args);
-}
-static int /*long*/ callback43(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method43(args);
-}
-static int /*long*/ callback44(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method44(args);
-}
-static int /*long*/ callback45(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method45(args);
-}
-static int /*long*/ callback46(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method46(args);
-}
-static int /*long*/ callback47(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method47(args);
-}
-static int /*long*/ callback48(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method48(args);
-}
-static int /*long*/ callback49(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method49(args);
-}
-static int /*long*/ callback50(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method50(args);
-}
-static int /*long*/ callback51(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method51(args);
-}
-static int /*long*/ callback52(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method52(args);
-}
-static int /*long*/ callback53(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method53(args);
-}
-static int /*long*/ callback54(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method54(args);
-}
-static int /*long*/ callback55(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method55(args);
-}
-static int /*long*/ callback56(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method56(args);
-}
-static int /*long*/ callback57(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method57(args);
-}
-static int /*long*/ callback58(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method58(args);
-}
-static int /*long*/ callback59(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method59(args);
-}
-static int /*long*/ callback60(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method60(args);
-}
-static int /*long*/ callback61(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method61(args);
-}
-static int /*long*/ callback62(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method62(args);
-}
-static int /*long*/ callback63(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method63(args);
-}
-static int /*long*/ callback64(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method64(args);
-}
-static int /*long*/ callback65(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method65(args);
-}
-static int /*long*/ callback66(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method66(args);
-}
-static int /*long*/ callback67(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method67(args);
-}
-static int /*long*/ callback68(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method68(args);
-}
-static int /*long*/ callback69(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method69(args);
-}
-static int /*long*/ callback70(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method70(args);
-}
-static int /*long*/ callback71(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method71(args);
-}
-static int /*long*/ callback72(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method72(args);
-}
-static int /*long*/ callback73(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method73(args);
-}
-static int /*long*/ callback74(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method74(args);
-}
-static int /*long*/ callback75(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method75(args);
-}
-static int /*long*/ callback76(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method76(args);
-}
-static int /*long*/ callback77(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method77(args);
-}
-static int /*long*/ callback78(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method78(args);
-}
-static int /*long*/ callback79(int /*long*/[] callbackArgs) {
- // find the object on which this call was invoked
- int /*long*/ address = callbackArgs[0];
- Object object = ObjectMap.get(new LONG(address));
- if (object == null) return COM.E_FAIL;
- int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
- System.arraycopy(callbackArgs, 1, args, 0, args.length);
- return ((COMObject) object).method79(args);
-}
-public void dispose() {
- // free the memory for this reference
- int /*long*/[] pVtable = new int /*long*/[1];
- OS.MoveMemory(pVtable, ppVtable, OS.PTR_SIZEOF);
- OS.GlobalFree(pVtable[0]);
- OS.GlobalFree(ppVtable);
-
- // remove this ppVtable from the list
- ObjectMap.remove(new LONG(ppVtable));
-
- ppVtable = 0;
-}
-public int /*long*/ getAddress () {
- return ppVtable;
-}
-public int /*long*/ method0(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method1(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method2(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method3(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method4(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method5(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method6(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method7(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method8(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method9(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method10(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method11(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method12(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method13(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method14(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method15(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method16(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method17(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method18(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method19(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method20(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method21(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method22(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method23(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method24(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method25(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method26(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method27(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method28(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method29(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method30(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method31(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method32(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method33(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method34(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method35(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method36(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method37(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method38(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method39(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method40(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method41(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method42(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method43(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method44(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method45(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method46(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method47(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method48(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method49(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method50(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method51(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method52(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method53(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method54(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method55(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method56(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method57(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method58(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method59(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method60(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method61(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method62(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method63(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method64(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method65(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method66(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method67(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method68(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method69(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method70(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method71(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method72(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method73(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method74(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method75(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method76(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method77(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method78(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-public int /*long*/ method79(int /*long*/[] args) {
- return COM.E_NOTIMPL;
-}
-
-}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OLE.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OLE.java
deleted file mode 100755
index bb29d26cd3..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OLE.java
+++ /dev/null
@@ -1,439 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.ole.win32;
-
-import org.eclipse.swt.*;
-import java.io.File;
-import org.eclipse.swt.internal.ole.win32.COM;
-import org.eclipse.swt.internal.win32.OS;
-import org.eclipse.swt.internal.win32.TCHAR;
-
-
-/**
- *
- * OLE contains all the constants used to create an ActiveX Control or an OLE Document.
- *
- * <p>Definitions for these constants can be found in MSDN.
- *
- */
-public class OLE extends SWT {
-
- public static final int S_FALSE = 1; // Used for functions that semantically return a Boolean FALSE result to indicate that the function succeeded.
- public static final int S_OK = 0; // Function succeeded.
- public static final int E_FAIL = -2147467259; // Unspecified failure.
- public static final int E_INVALIDARG = -2147024809; // Invalid argument
- public static final int E_NOINTERFACE = -2147467262; // QueryInterface did not recognize the requested interface.
- public static final int E_NOTIMPL = -2147467263; // Not implemented
-
- public static final String IID_IUNKNOWN = "{00000000-0000-0000-C000-000000000046}"; //$NON-NLS-1$
- public static final String IID_IDISPATCH = "{00020400-0000-0000-C000-000000000046}"; //$NON-NLS-1$
-
- // Verbs that can be invoked on this client
- public static final int OLEIVERB_DISCARDUNDOSTATE = -6; // close the OLE object and discard the undo state
- public static final int OLEIVERB_HIDE = -3; // hide the OLE object
- public static final int OLEIVERB_INPLACEACTIVATE = -5; // open the OLE for editing in-place
- public static final int OLEIVERB_OPEN = -2; // open the OLE object for editing in a separate window
- public static final int OLEIVERB_PRIMARY = 0; // opens the OLE object for editing
- public static final int OLEIVERB_PROPERTIES = -7; // request the OLE object properties dialog
- public static final int OLEIVERB_SHOW = -1; // show the OLE object
- public static final int OLEIVERB_UIACTIVATE = -4; // activate the UI for the OLE object
-
- public static final int PROPERTY_CHANGING = 0;
- public static final int PROPERTY_CHANGED = 1;
-
- /**
- * Error code for OleError - No specific error information available
- */
- public static final int HRESULT_UNSPECIFIED = 0;
- /**
- * Error code for OleError - Failed to create file
- */
- public static final int ERROR_CANNOT_CREATE_FILE = 1000;
- /**
- * Error code for OleError - Failed to create Ole Client
- */
- public static final int ERROR_CANNOT_CREATE_OBJECT = 1001;
- /**
- * Error code for OleError - File does not exist, is not accessible to user or does not have the correct format
- */
- public static final int ERROR_CANNOT_OPEN_FILE = 1002;
- /**
- * Error code for OleError - Failed to find requested interface on OLE Object
- */
- public static final int ERROR_INTERFACE_NOT_FOUND = 1003;
- /**
- * Error code for OleError - Class ID not found in registry
- */
- public static final int ERROR_INVALID_CLASSID = 1004;
- /**
- * Error code for OleError - Failed to get the class factory for the specified classID
- */
- public static final int ERROR_CANNOT_ACCESS_CLASSFACTORY = 1005;
- /**
- * Error code for OleError - Failed to create Licensed instance
- */
- public static final int ERROR_CANNOT_CREATE_LICENSED_OBJECT = 1006;
- /**
- * Error code for OleError - Out of Memory
- */
- public static final int ERROR_OUT_OF_MEMORY = 1007;
- /**
- * Error code for OleError - Failed to change Variant type
- */
- public static final int ERROR_CANNOT_CHANGE_VARIANT_TYPE = 1010;
- /**
- * Error code for OleError - Invalid address received for Ole Interface
- */
- public static final int ERROR_INVALID_INTERFACE_ADDRESS = 1011;
- /**
- * Error code for OleError - Unable to find Application
- */
- public static final int ERROR_APPLICATION_NOT_FOUND = 1013;
- /**
- * Error code for OleError - Action can not be performed
- */
- public static final int ERROR_ACTION_NOT_PERFORMED = 1014;
-
- public static final int OLECMDF_SUPPORTED = 1;
- public static final int OLECMDF_ENABLED = 2;
- public static final int OLECMDF_LATCHED = 4;
- public static final int OLECMDF_NINCHED = 8;
-
- public static final int OLECMDTEXTF_NONE = 0;
- public static final int OLECMDTEXTF_NAME = 1;
- public static final int OLECMDTEXTF_STATUS = 2;
-
- public static final int OLECMDEXECOPT_DODEFAULT = 0;
- public static final int OLECMDEXECOPT_PROMPTUSER = 1;
- public static final int OLECMDEXECOPT_DONTPROMPTUSER = 2;
- public static final int OLECMDEXECOPT_SHOWHELP = 3;
-
- public static final int OLECMDID_OPEN = 1;
- public static final int OLECMDID_NEW = 2;
- public static final int OLECMDID_SAVE = 3;
- public static final int OLECMDID_SAVEAS = 4;
- public static final int OLECMDID_SAVECOPYAS = 5;
- public static final int OLECMDID_PRINT = 6;
- public static final int OLECMDID_PRINTPREVIEW = 7;
- public static final int OLECMDID_PAGESETUP = 8;
- public static final int OLECMDID_SPELL = 9;
- public static final int OLECMDID_PROPERTIES = 10;
- public static final int OLECMDID_CUT = 11;
- public static final int OLECMDID_COPY = 12;
- public static final int OLECMDID_PASTE = 13;
- public static final int OLECMDID_PASTESPECIAL = 14;
- public static final int OLECMDID_UNDO = 15;
- public static final int OLECMDID_REDO = 16;
- public static final int OLECMDID_SELECTALL = 17;
- public static final int OLECMDID_CLEARSELECTION = 18;
- public static final int OLECMDID_ZOOM = 19;
- public static final int OLECMDID_GETZOOMRANGE = 20;
- public static final int OLECMDID_UPDATECOMMANDS = 21;
- public static final int OLECMDID_REFRESH = 22;
- public static final int OLECMDID_STOP = 23;
- public static final int OLECMDID_HIDETOOLBARS = 24;
- public static final int OLECMDID_SETPROGRESSMAX = 25;
- public static final int OLECMDID_SETPROGRESSPOS = 26;
- public static final int OLECMDID_SETPROGRESSTEXT = 27;
- public static final int OLECMDID_SETTITLE = 28;
- public static final int OLECMDID_SETDOWNLOADSTATE = 29;
- public static final int OLECMDID_STOPDOWNLOAD = 30;
-
- /* Ole Property Description flags */
- public static int VARFLAG_FREADONLY = 0x1;
- public static int VARFLAG_FSOURCE = 0x2;
- public static int VARFLAG_FBINDABLE = 0x4;
- public static int VARFLAG_FREQUESTEDIT = 0x8;
- public static int VARFLAG_FDISPLAYBIND = 0x10;
- public static int VARFLAG_FDEFAULTBIND = 0x20;
- public static int VARFLAG_FHIDDEN = 0x40;
- public static int VARFLAG_FRESTRICTED = 0x80;
- public static int VARFLAG_FDEFAULTCOLLELEM = 0x100;
- public static int VARFLAG_FUIDEFAULT = 0x200;
- public static int VARFLAG_FNONBROWSABLE = 0x400;
- public static int VARFLAG_FREPLACEABLE = 0x800;
- public static int VARFLAG_FIMMEDIATEBIND = 0x1000;
-
- /* Ole Property Description kind */
- public static int VAR_PERINSTANCE = 0;
- public static int VAR_STATIC = 1;
- public static int VAR_CONST = 2;
- public static int VAR_DISPATCH = 3;
-
- /* Ole Parameter Description flags */
- public static short IDLFLAG_NONE = 0;
- public static short IDLFLAG_FIN = 1;
- public static short IDLFLAG_FOUT = 2;
- public static short IDLFLAG_FLCID = 4;
- public static short IDLFLAG_FRETVAL = 8;
-
- /* Ole Description types */
- public static final short VT_BOOL = 11; // Boolean; True=-1, False=0.
- public static final short VT_BSTR = 8; // Binary String.
- public static final short VT_BYREF = 16384; // By reference - must be combined with one of the other VT values
- public static final short VT_CY = 6; // Currency.
- public static final short VT_DATE = 7; // Date.
- public static final short VT_DISPATCH = 9; // IDispatch
- public static final short VT_EMPTY = 0; // Not specified.
- public static final short VT_ERROR = 10; // Scodes.
- public static final short VT_I2 = 2; // 2-byte signed int.
- public static final short VT_I4 = 3; // 4-byte signed int.
- public static final short VT_NULL = 1; // Null.
- public static final short VT_R4 = 4; // 4-byte real.
- public static final short VT_R8 = 5; // 8-byte real.
- public static final short VT_UI1 = 17; // Unsigned char.
- public static final short VT_UI4 = 19; // Unsigned int.
- public static final short VT_UNKNOWN = 13; // IUnknown FAR*.
- public static final short VT_VARIANT = 12; // VARIANT FAR*.
- public static final short VT_PTR = 26;
- public static final short VT_USERDEFINED = 29;
- public static final short VT_HRESULT = 25;
- public static final short VT_DECIMAL = 14;
- public static final short VT_I1 = 16;
- public static final short VT_UI2 = 18;
- public static final short VT_I8 = 20;
- public static final short VT_UI8 = 21;
- public static final short VT_INT = 22;
- public static final short VT_UINT = 23;
- public static final short VT_VOID = 24;
- public static final short VT_SAFEARRAY = 27;
- public static final short VT_CARRAY = 28;
- public static final short VT_LPSTR = 30;
- public static final short VT_LPWSTR = 31;
- public static final short VT_RECORD = 36;
- public static final short VT_FILETIME = 64;
- public static final short VT_BLOB = 65;
- public static final short VT_STREAM = 66;
- public static final short VT_STORAGE = 67;
- public static final short VT_STREAMED_OBJECT = 68;
- public static final short VT_STORED_OBJECT = 69;
- public static final short VT_BLOB_OBJECT = 70;
- public static final short VT_CF = 71;
- public static final short VT_CLSID = 72;
- public static final short VT_VERSIONED_STREAM = 73;
- public static final short VT_BSTR_BLOB = 0xfff;
- public static final short VT_VECTOR = 0x1000;
- public static final short VT_ARRAY = 0x2000;
-
- /* Ole Function Description Invoke Kind values */
- public static final int INVOKE_FUNC = 1;
- public static final int INVOKE_PROPERTYGET = 2;
- public static final int INVOKE_PROPERTYPUT = 4;
- public static final int INVOKE_PROPERTYPUTREF = 8;
-
- /* Ole Function Description function kind */
- public static final int FUNC_VIRTUAL = 0;
- public static final int FUNC_PUREVIRTUAL = 1;
- public static final int FUNC_NONVIRTUAL = 2;
- public static final int FUNC_STATIC = 3;
- public static final int FUNC_DISPATCH = 4;
-
- /* Ole Function Description function flags */
- public static final short FUNCFLAG_FRESTRICTED = 1;
- public static final short FUNCFLAG_FSOURCE = 0x2;
- public static final short FUNCFLAG_FBINDABLE = 0x4;
- public static final short FUNCFLAG_FREQUESTEDIT = 0x8;
- public static final short FUNCFLAG_FDISPLAYBIND = 0x10;
- public static final short FUNCFLAG_FDEFAULTBIND = 0x20;
- public static final short FUNCFLAG_FHIDDEN = 0x40;
- public static final short FUNCFLAG_FUSESGETLASTERROR = 0x80;
- public static final short FUNCFLAG_FDEFAULTCOLLELEM = 0x100;
- public static final short FUNCFLAG_FUIDEFAULT = 0x200;
- public static final short FUNCFLAG_FNONBROWSABLE = 0x400;
- public static final short FUNCFLAG_FREPLACEABLE = 0x800;
- public static final short FUNCFLAG_FIMMEDIATEBIND = 0x1000;
-
- /* Ole Function Description calling convention */
- public static final int CC_FASTCALL = 0;
- public static final int CC_CDECL = 1;
- public static final int CC_MSCPASCAL = 2;
- public static final int CC_PASCAL = 2;
- public static final int CC_MACPASCAL = 3;
- public static final int CC_STDCALL = 4;
- public static final int CC_FPFASTCALL = 5;
- public static final int CC_SYSCALL = 6;
- public static final int CC_MPWCDECL = 7;
- public static final int CC_MPWPASCAL = 8;
- public static final int CC_MAX = 9;
-
- static final String ERROR_NOT_IMPLEMENTED_MSG = "Required functionality not currently supported.";//$NON-NLS-1$
- static final String ERROR_CANNOT_CREATE_FILE_MSG = "Failed to create file.";//$NON-NLS-1$
- static final String ERROR_CANNOT_CREATE_OBJECT_MSG = "Failed to create Ole Client.";//$NON-NLS-1$
- static final String ERROR_CANNOT_OPEN_FILE_MSG = "File does not exist, is not accessible to user or does not have the correct format.";//$NON-NLS-1$
- static final String ERROR_INTERFACE_NOT_FOUND_MSG = "Failed to find requested interface on OLE Object.";//$NON-NLS-1$
- static final String ERROR_INVALID_CLASSID_MSG = "Class ID not found in registry";//$NON-NLS-1$
- static final String ERROR_CANNOT_ACCESS_CLASSFACTORY_MSG = "Failed to get the class factory for the specified classID";//$NON-NLS-1$
- static final String ERROR_CANNOT_CREATE_LICENSED_OBJECT_MSG = "Failed to create Licensed instance";//$NON-NLS-1$
- static final String ERROR_OUT_OF_MEMORY_MSG = "Out of Memory";//$NON-NLS-1$
- static final String ERROR_CANNOT_CHANGE_VARIANT_TYPE_MSG = "Failed to change Variant type";//$NON-NLS-1$
- static final String ERROR_INVALID_INTERFACE_ADDRESS_MSG = "Invalid address received for Ole Interface.";//$NON-NLS-1$
- static final String ERROR_APPLICATION_NOT_FOUND_MSG = "Unable to find Application.";//$NON-NLS-1$
- static final String ERROR_ACTION_NOT_PERFORMED_MSG = "Action can not be performed.";//$NON-NLS-1$
-
-
-public static void error (int code) {
- error (code, 0);
-}
-public static void error (int code, int hresult) {
-
- switch (code) {
- /* Illegal Arguments (non-fatal) */
- case ERROR_INVALID_INTERFACE_ADDRESS :{
- throw new IllegalArgumentException (ERROR_INVALID_INTERFACE_ADDRESS_MSG);
- }
-
- /* SWT Errors (non-fatal) */
- case ERROR_CANNOT_CREATE_FILE : {
- String msg = ERROR_CANNOT_CREATE_FILE_MSG;
- if (hresult != 0) msg += " result = "+hresult;//$NON-NLS-1$
- throw new SWTException (code, msg);
- }
- case ERROR_CANNOT_CREATE_OBJECT : {
- String msg = ERROR_CANNOT_CREATE_OBJECT_MSG;
- if (hresult != 0) msg += " result = "+hresult;//$NON-NLS-1$
- throw new SWTException (code, msg);//$NON-NLS-1$
- }
- case ERROR_CANNOT_OPEN_FILE : {
- String msg = ERROR_CANNOT_OPEN_FILE_MSG;
- if (hresult != 0) msg += " result = "+hresult;//$NON-NLS-1$
- throw new SWTException (code, msg);
- }
- case ERROR_INTERFACE_NOT_FOUND : {
- String msg = ERROR_INTERFACE_NOT_FOUND_MSG;
- if (hresult != 0) msg += " result = "+hresult;//$NON-NLS-1$
- throw new SWTException (code, msg);
- }
- case ERROR_INVALID_CLASSID : {
- String msg = ERROR_INVALID_CLASSID_MSG;
- if (hresult != 0) msg += " result = "+hresult;//$NON-NLS-1$
- throw new SWTException (code, msg);
- }
- case ERROR_CANNOT_ACCESS_CLASSFACTORY : {
- String msg = ERROR_CANNOT_ACCESS_CLASSFACTORY_MSG;
- if (hresult != 0) msg += " result = "+hresult;//$NON-NLS-1$
- throw new SWTException (code, msg);
- }
- case ERROR_CANNOT_CREATE_LICENSED_OBJECT : {
- String msg = ERROR_CANNOT_CREATE_LICENSED_OBJECT_MSG;
- if (hresult != 0) msg += " result = "+hresult;//$NON-NLS-1$
- throw new SWTException (code, msg);
- }
- case ERROR_CANNOT_CHANGE_VARIANT_TYPE : {
- String msg = ERROR_CANNOT_CHANGE_VARIANT_TYPE_MSG;
- if (hresult != 0) msg += " result = "+hresult;//$NON-NLS-1$
- throw new SWTException (code, msg);
- }
- case ERROR_APPLICATION_NOT_FOUND : {
- String msg = ERROR_APPLICATION_NOT_FOUND_MSG;
- if (hresult != 0) msg += " result = "+hresult;//$NON-NLS-1$
- throw new SWTException (code, msg);
- }
- case ERROR_ACTION_NOT_PERFORMED : {
- String msg = ERROR_ACTION_NOT_PERFORMED_MSG;
- if (hresult != 0) msg += " result = "+hresult;//$NON-NLS-1$
- throw new SWTException (code, msg);
- }
-
- /* OS Failure/Limit (fatal, may occur only on some platforms) */
- case ERROR_OUT_OF_MEMORY : {
- String msg = ERROR_ACTION_NOT_PERFORMED_MSG;
- if (hresult != 0) msg += " result = "+hresult; //$NON-NLS-1$
- throw new SWTError (code, msg);
- }
- }
-
- /* Unknown/Undefined Error */
- SWT.error(code);
-}
-
-/*
- * Finds the OLE program id that is associated with an extension.
- * The extension may or may not begin with a '.'. On platforms
- * that do not support OLE, an empty string is returned.
- *
- * @param extension the program extension
- * @return a string that is the OLE program id or an empty string
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT when extension is null</li>
- * </ul>
- */
-public static String findProgramID (String extension) {
- if (extension == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- if (extension.length () == 0) return ""; //$NON-NLS-1$
-
- if (extension.charAt (0) != '.') extension = "." + extension; //$NON-NLS-1$
-
- /* Use the character encoding for the default locale */
- TCHAR extensionKey = new TCHAR(0, extension, true);
- String result = getKeyValue(extensionKey);
- if (result != null) {
- // look for "<programID>\NotInsertable"
- TCHAR notInsertableKey = new TCHAR(0, result+"\\NotInsertable", true); //$NON-NLS-1$
- if (getKeyExists(notInsertableKey)) return ""; //$NON-NLS-1$
- // look for "<programID>\Insertable"
- TCHAR insertableKey = new TCHAR(0, result+"\\Insertable", true); //$NON-NLS-1$
- if (getKeyExists(insertableKey)) return result;
- // look for "<programID>\protocol\StdFileEditing\server"
- TCHAR serverKey = new TCHAR(0, result+"\\protocol\\StdFileEditing\\server", true); //$NON-NLS-1$
- if (getKeyExists(serverKey)) return result;
- }
-
- return ""; //$NON-NLS-1$
-}
-static String getKeyValue (TCHAR key) {
- int /*long*/ [] phkResult = new int /*long*/ [1];
- if (OS.RegOpenKeyEx (OS.HKEY_CLASSES_ROOT, key, 0, OS.KEY_READ, phkResult) != 0) {
- return null;
- }
- String result = null;
- int [] lpcbData = new int [1];
- if (OS.RegQueryValueEx (phkResult [0], (TCHAR) null, 0, null, (TCHAR) null, lpcbData) == 0) {
- int length = lpcbData [0] / TCHAR.sizeof;
- if (length == 0) {
- result = "";
- } else {
- /* Use the character encoding for the default locale */
- TCHAR lpData = new TCHAR (0, length);
- if (OS.RegQueryValueEx (phkResult [0], null, 0, null, lpData, lpcbData) == 0) {
- length = Math.max(0, lpData.length () - 1);
- result = lpData.toString (0, length);
- }
- }
- }
- if (phkResult [0] != 0) OS.RegCloseKey (phkResult [0]);
- return result;
-}
-private static boolean getKeyExists (TCHAR key) {
- int /*long*/ [] phkResult = new int /*long*/ [1];
- if (OS.RegOpenKeyEx (OS.HKEY_CLASSES_ROOT, key, 0, OS.KEY_READ, phkResult) != 0) {
- return false;
- }
- if (phkResult [0] != 0) OS.RegCloseKey (phkResult [0]);
- return true;
-}
-/**
- * Returns true if the specified file has an OLE Storage format.
- *
- * Note all empty files (regardless of extension) will return false.
- *
- * @param file the file to be checked
- *
- * @return true if this file has an OLE Storage format
- */
-public static boolean isOleFile(File file) {
- if (file == null || !file.exists() || file.isDirectory())
- return false;
-
- return (COM.StgIsStorageFile((file.getAbsolutePath()+"\0").toCharArray()) == COM.S_OK);
-}
-
-}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleAutomation.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleAutomation.java
deleted file mode 100755
index 9199b4ad8d..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleAutomation.java
+++ /dev/null
@@ -1,656 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.ole.win32;
-
-
-import org.eclipse.swt.internal.ole.win32.*;
-import org.eclipse.swt.internal.win32.*;
-
-/**
- * OleAutomation provides a generic mechanism for accessing functionality that is
- * specific to a particular ActiveX Control or OLE Document.
- *
- * <p>The OLE Document or ActiveX Control must support the IDispatch interface in order to provide
- * OleAutomation support. The additional functionality provided by the OLE Object is specified in
- * its IDL file. The additional methods can either be to get property values (<code>getProperty</code>),
- * to set property values (<code>setProperty</code>) or to invoke a method (<code>invoke</code> or
- * <code>invokeNoReply</code>). Arguments are passed around in the form of <code>Variant</code>
- * objects.
- *
- * <p>Here is a sample IDL fragment:
- *
- * <pre>
- * interface IMyControl : IDispatch
- * {
- * [propget, id(0)] HRESULT maxFileCount([retval, out] int *c);
- * [propput, id(0)] HRESULT maxFileCount([in] int c);
- * [id(1)] HRESULT AddFile([in] BSTR fileName);
- * };
- * </pre>
- *
- * <p>An example of how to interact with this extended functionality is shown below:
- *
- * <code><pre>
- * OleAutomation automation = new OleAutomation(myControlSite);
- *
- * // Look up the ID of the maxFileCount parameter
- * int[] rgdispid = automation.getIDsOfNames(new String[]{"maxFileCount"});
- * int maxFileCountID = rgdispid[0];
- *
- * // Set the property maxFileCount to 100:
- * if (automation.setProperty(maxFileCountID, new Variant(100))) {
- * System.out.println("Max File Count was successfully set.");
- * }
- *
- * // Get the new value of the maxFileCount parameter:
- * Variant pVarResult = automation.getProperty(maxFileCountID);
- * if (pVarResult != null) {
- * System.out.println("Max File Count is "+pVarResult.getInt());
- * }
- *
- * // Invoke the AddFile method
- * // Look up the IDs of the AddFile method and its parameter
- * rgdispid = automation.getIDsOfNames(new String[]{"AddFile", "fileName"});
- * int dispIdMember = rgdispid[0];
- * int[] rgdispidNamedArgs = new int[] {rgdispid[1]};
- *
- * // Convert arguments to Variant objects
- * Variant[] rgvarg = new Variant[1];
- * String fileName = "C:\\testfile";
- * rgvarg[0] = new Variant(fileName);
- *
- * // Call the method
- * Variant pVarResult = automation.invoke(dispIdMember, rgvarg, rgdispidNamedArgs);
- *
- * // Check the return value
- * if (pVarResult == null || pVarResult.getInt() != OLE.S_OK){
- * System.out.println("Failed to add file "+fileName);
- * }
- *
- * automation.dispose();
- *
- * </pre></code>
- *
- * @see <a href="http://www.eclipse.org/swt/snippets/#ole">OLE and ActiveX snippets</a>
- * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Examples: OLEExample, OleWebBrowser</a>
- */
-public final class OleAutomation {
- private IDispatch objIDispatch;
- private String exceptionDescription;
- private ITypeInfo objITypeInfo;
-
-OleAutomation(IDispatch idispatch) {
- if (idispatch == null) OLE.error(OLE.ERROR_INVALID_INTERFACE_ADDRESS);
- objIDispatch = idispatch;
- objIDispatch.AddRef();
-
- int /*long*/[] ppv = new int /*long*/[1];
- /* GetTypeInfo([in] iTInfo, [in] lcid, [out] ppTInfo)
- * AddRef has already been called on ppTInfo by the callee and must be released by the caller.
- */
- int result = objIDispatch.GetTypeInfo(0, COM.LOCALE_USER_DEFAULT, ppv);
- if (result == OLE.S_OK) {
- objITypeInfo = new ITypeInfo(ppv[0]);
- }
-}
-/**
- * Creates an OleAutomation object for the specified client.
- *
- * @param clientSite the site for the OLE Document or ActiveX Control whose additional functionality
- * you need to access
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_INTERFACE_ADDRESS when called with an invalid client site
- * </ul>
- */
- public OleAutomation(OleClientSite clientSite) {
- if (clientSite == null) OLE.error(OLE.ERROR_INVALID_INTERFACE_ADDRESS);
- objIDispatch = clientSite.getAutomationObject();
-
- int /*long*/[] ppv = new int /*long*/[1];
- /* GetTypeInfo([in] iTInfo, [in] lcid, [out] ppTInfo)
- * AddRef has already been called on ppTInfo by the callee and must be released by the caller.
- */
- int result = objIDispatch.GetTypeInfo(0, COM.LOCALE_USER_DEFAULT, ppv);
- if (result == OLE.S_OK) {
- objITypeInfo = new ITypeInfo(ppv[0]);
- }
- }
-/**
- * Disposes the automation object.
- * <p>
- * This method releases the IDispatch interface on the OLE Document or ActiveX Control.
- * Do not use the OleAutomation object after it has been disposed.
- */
-public void dispose() {
-
- if (objIDispatch != null){
- objIDispatch.Release();
- }
- objIDispatch = null;
-
- if (objITypeInfo != null){
- objITypeInfo.Release();
- }
- objITypeInfo = null;
-
-}
-int /*long*/ getAddress() {
- return objIDispatch.getAddress();
-}
-/**
- * Returns the fully qualified name of the Help file for the given member ID.
- *
- * @param dispId the member ID whose Help file is being retrieved.
- * @return a string representing the fully qualified name of a Help
- * file or null.
- */
-public String getHelpFile(int dispId) {
- if (objITypeInfo == null) return null;
- String[] file = new String[1];
- int rc = objITypeInfo.GetDocumentation(dispId, null, null, null, file );
- if (rc == OLE.S_OK) return file[0];
- return null;
-}
-/**
- * Returns the documentation string for the given member ID.
- *
- * @param dispId the member ID in which the documentation is being retrieved.
- * @return the documentation string if it exists; otherwise return null.
- */
-public String getDocumentation(int dispId) {
- if (objITypeInfo == null) return null;
- String[] doc = new String[1];
- int rc = objITypeInfo.GetDocumentation(dispId, null, doc, null, null );
- if (rc == OLE.S_OK) return doc[0];
- return null;
-}
-/**
- * Returns the property description of a variable at the given index.
- *
- * @param index the index of a variable whose property is being retrieved.
- * @return an OlePropertyDescription for a variable at the given index.
- */
-public OlePropertyDescription getPropertyDescription(int index) {
- if (objITypeInfo == null) return null;
- int /*long*/[] ppVarDesc = new int /*long*/[1];
- int rc = objITypeInfo.GetVarDesc(index, ppVarDesc);
- if (rc != OLE.S_OK) return null;
- VARDESC vardesc = new VARDESC();
- COM.MoveMemory(vardesc, ppVarDesc[0], VARDESC.sizeof);
-
- OlePropertyDescription data = new OlePropertyDescription();
- data.id = vardesc.memid;
- data.name = getName(vardesc.memid);
- data.type = vardesc.elemdescVar_tdesc_vt;
- if (data.type == OLE.VT_PTR) {
- short[] vt = new short[1];
- COM.MoveMemory(vt, vardesc.elemdescVar_tdesc_union + OS.PTR_SIZEOF, 2);
- data.type = vt[0];
- }
- data.flags = vardesc.wVarFlags;
- data.kind = vardesc.varkind;
- data.description = getDocumentation(vardesc.memid);
- data.helpFile = getHelpFile(vardesc.memid);
-
- objITypeInfo.ReleaseVarDesc(ppVarDesc[0]);
- return data;
-}
-/**
- * Returns the description of a function at the given index.
- *
- * @param index the index of a function whose property is being retrieved.
- * @return an OleFunctionDescription for a function at the given index.
- */
-public OleFunctionDescription getFunctionDescription(int index) {
- if (objITypeInfo == null) return null;
- int /*long*/[] ppFuncDesc = new int /*long*/[1];
- int rc = objITypeInfo.GetFuncDesc(index, ppFuncDesc);
- if (rc != OLE.S_OK) return null;
- FUNCDESC funcdesc = new FUNCDESC();
- COM.MoveMemory(funcdesc, ppFuncDesc[0], FUNCDESC.sizeof);
-
- OleFunctionDescription data = new OleFunctionDescription();
-
- data.id = funcdesc.memid;
- data.optionalArgCount = funcdesc.cParamsOpt;
- data.invokeKind = funcdesc.invkind;
- data.funcKind = funcdesc.funckind;
- data.flags = funcdesc.wFuncFlags;
- data.callingConvention = funcdesc.callconv;
- data.documentation = getDocumentation(funcdesc.memid);
- data.helpFile = getHelpFile(funcdesc.memid);
-
- String[] names = getNames(funcdesc.memid, funcdesc.cParams + 1);
- if (names.length > 0) {
- data.name = names[0];
- }
- data.args = new OleParameterDescription[funcdesc.cParams];
- for (int i = 0; i < data.args.length; i++) {
- data.args[i] = new OleParameterDescription();
- if (names.length > i + 1) {
- data.args[i].name = names[i + 1];
- }
- //TODO 0- use structures
- short[] vt = new short[1];
- COM.MoveMemory(vt, funcdesc.lprgelemdescParam + i * COM.ELEMDESC_sizeof() + OS.PTR_SIZEOF, 2);
- if (vt[0] == OLE.VT_PTR) {
- int /*long*/ [] pTypedesc = new int /*long*/ [1];
- COM.MoveMemory(pTypedesc, funcdesc.lprgelemdescParam + i * COM.ELEMDESC_sizeof(), OS.PTR_SIZEOF);
- short[] vt2 = new short[1];
- COM.MoveMemory(vt2, pTypedesc[0] + OS.PTR_SIZEOF, 2);
- vt[0] = (short)(vt2[0] | COM.VT_BYREF);
- }
- data.args[i].type = vt[0];
- short[] wParamFlags = new short[1];
- COM.MoveMemory(wParamFlags, funcdesc.lprgelemdescParam + i * COM.ELEMDESC_sizeof() + COM.TYPEDESC_sizeof () + OS.PTR_SIZEOF, 2);
- data.args[i].flags = wParamFlags[0];
- }
-
- data.returnType = funcdesc.elemdescFunc_tdesc_vt;
- if (data.returnType == OLE.VT_PTR) {
- short[] vt = new short[1];
- COM.MoveMemory(vt, funcdesc.elemdescFunc_tdesc_union + OS.PTR_SIZEOF, 2);
- data.returnType = vt[0];
- }
-
- objITypeInfo.ReleaseFuncDesc(ppFuncDesc[0]);
- return data;
-}
-/**
- * Returns the type info of the current object referenced by the automation.
- * The type info contains information about the object such as the function descriptions,
- * the member descriptions and attributes of the type.
- *
- * @return the type info of the receiver
- */
-public TYPEATTR getTypeInfoAttributes() {
- if (objITypeInfo == null) return null;
- int /*long*/ [] ppTypeAttr = new int /*long*/ [1];
- int rc = objITypeInfo.GetTypeAttr(ppTypeAttr);
- if (rc != OLE.S_OK) return null;
- TYPEATTR typeattr = new TYPEATTR();
- COM.MoveMemory(typeattr, ppTypeAttr[0], TYPEATTR.sizeof);
- objITypeInfo.ReleaseTypeAttr(ppTypeAttr[0]);
- return typeattr;
-}
-/**
- * Returns the name of the given member ID.
- *
- * @param dispId the member ID in which the name is being retrieved.
- * @return the name if it exists; otherwise return null.
- */
-public String getName(int dispId) {
- if (objITypeInfo == null) return null;
- String[] name = new String[1];
- int rc = objITypeInfo.GetDocumentation(dispId, name, null, null, null );
- if (rc == OLE.S_OK) return name[0];
- return null;
-}
-/**
- * Returns the name of a function and parameter names for the specified function ID.
- *
- * @param dispId the function ID in which the name and parameters are being retrieved.
- * @param maxSize the maximum number of names to retrieve.
- * @return an array of name containing the function name and the parameter names
- */
-public String[] getNames(int dispId, int maxSize) {
- if (objITypeInfo == null) return new String[0];
- String[] names = new String[maxSize];
- int[] count = new int[1];
- int rc = objITypeInfo.GetNames(dispId, names, maxSize, count);
- if (rc == OLE.S_OK) {
- String[] newNames = new String[count[0]];
- System.arraycopy(names, 0, newNames, 0, count[0]);
- return newNames;
- }
- return new String[0];
-}
-/**
- * Returns the positive integer values (IDs) that are associated with the specified names by the
- * IDispatch implementor. If you are trying to get the names of the parameters in a method, the first
- * String in the names array must be the name of the method followed by the names of the parameters.
- *
- * @param names an array of names for which you require the identifiers
- *
- * @return positive integer values that are associated with the specified names in the same
- * order as the names where provided; or null if the names are unknown
- */
-public int[] getIDsOfNames(String[] names) {
-
- int[] rgdispid = new int[names.length];
- int result = objIDispatch.GetIDsOfNames(new GUID(), names, names.length, COM.LOCALE_USER_DEFAULT, rgdispid);
- if (result != COM.S_OK) return null;
-
- return rgdispid;
-}
-/**
- * Returns a description of the last error encountered.
- *
- * @return a description of the last error encountered
- */
-public String getLastError() {
-
- return exceptionDescription;
-
-}
-/**
- * Returns the value of the property specified by the dispIdMember.
- *
- * @param dispIdMember the ID of the property as specified by the IDL of the ActiveX Control; the
- * value for the ID can be obtained using OleAutomation.getIDsOfNames
- *
- * @return the value of the property specified by the dispIdMember or null
- */
-public Variant getProperty(int dispIdMember) {
- Variant pVarResult = new Variant();
- int result = invoke(dispIdMember, COM.DISPATCH_PROPERTYGET, null, null, pVarResult);
- return (result == OLE.S_OK) ? pVarResult : null;
-}
-/**
- * Returns the value of the property specified by the dispIdMember.
- *
- * @param dispIdMember the ID of the property as specified by the IDL of the ActiveX Control; the
- * value for the ID can be obtained using OleAutomation.getIDsOfNames
- *
- * @param rgvarg an array of arguments for the method. All arguments are considered to be
- * read only unless the Variant is a By Reference Variant type.
- *
- * @return the value of the property specified by the dispIdMember or null
- *
- * @since 2.0
- */
-public Variant getProperty(int dispIdMember, Variant[] rgvarg) {
- Variant pVarResult = new Variant();
- int result = invoke(dispIdMember, COM.DISPATCH_PROPERTYGET, rgvarg, null, pVarResult);
- return (result == OLE.S_OK) ? pVarResult : null;
-
-}
-/**
- * Returns the value of the property specified by the dispIdMember.
- *
- * @param dispIdMember the ID of the property as specified by the IDL of the ActiveX Control; the
- * value for the ID can be obtained using OleAutomation.getIDsOfNames
- *
- * @param rgvarg an array of arguments for the method. All arguments are considered to be
- * read only unless the Variant is a By Reference Variant type.
- *
- * @param rgdispidNamedArgs an array of identifiers for the arguments specified in rgvarg; the
- * parameter IDs must be in the same order as their corresponding values;
- * all arguments must have an identifier - identifiers can be obtained using
- * OleAutomation.getIDsOfNames
- *
- * @return the value of the property specified by the dispIdMember or null
- *
- * @since 2.0
- */
-public Variant getProperty(int dispIdMember, Variant[] rgvarg, int[] rgdispidNamedArgs) {
- Variant pVarResult = new Variant();
- int result = invoke(dispIdMember, COM.DISPATCH_PROPERTYGET, rgvarg, rgdispidNamedArgs, pVarResult);
- return (result == OLE.S_OK) ? pVarResult : null;
-}
-
-/**
- * Invokes a method on the OLE Object; the method has no parameters.
- *
- * @param dispIdMember the ID of the method as specified by the IDL of the ActiveX Control; the
- * value for the ID can be obtained using OleAutomation.getIDsOfNames
- *
- * @return the result of the method or null if the method failed to give result information
- */
-public Variant invoke(int dispIdMember) {
- Variant pVarResult = new Variant();
- int result = invoke(dispIdMember, COM.DISPATCH_METHOD, null, null, pVarResult);
- return (result == COM.S_OK) ? pVarResult : null;
-}
-/**
- * Invokes a method on the OLE Object; the method has no optional parameters.
- *
- * @param dispIdMember the ID of the method as specified by the IDL of the ActiveX Control; the
- * value for the ID can be obtained using OleAutomation.getIDsOfNames
- *
- * @param rgvarg an array of arguments for the method. All arguments are considered to be
- * read only unless the Variant is a By Reference Variant type.
- *
- * @return the result of the method or null if the method failed to give result information
- */
-public Variant invoke(int dispIdMember, Variant[] rgvarg) {
- Variant pVarResult = new Variant();
- int result = invoke(dispIdMember, COM.DISPATCH_METHOD, rgvarg, null, pVarResult);
- return (result == COM.S_OK) ? pVarResult : null;
-}
-/**
- * Invokes a method on the OLE Object; the method has optional parameters. It is not
- * necessary to specify all the optional parameters, only include the parameters for which
- * you are providing values.
- *
- * @param dispIdMember the ID of the method as specified by the IDL of the ActiveX Control; the
- * value for the ID can be obtained using OleAutomation.getIDsOfNames
- *
- * @param rgvarg an array of arguments for the method. All arguments are considered to be
- * read only unless the Variant is a By Reference Variant type.
- *
- * @param rgdispidNamedArgs an array of identifiers for the arguments specified in rgvarg; the
- * parameter IDs must be in the same order as their corresponding values;
- * all arguments must have an identifier - identifiers can be obtained using
- * OleAutomation.getIDsOfNames
- *
- * @return the result of the method or null if the method failed to give result information
- */
-public Variant invoke(int dispIdMember, Variant[] rgvarg, int[] rgdispidNamedArgs) {
- Variant pVarResult = new Variant();
- int result = invoke(dispIdMember, COM.DISPATCH_METHOD, rgvarg, rgdispidNamedArgs, pVarResult);
- return (result == COM.S_OK) ? pVarResult : null;
-}
-private int invoke(int dispIdMember, int wFlags, Variant[] rgvarg, int[] rgdispidNamedArgs, Variant pVarResult) {
-
- // get the IDispatch interface for the control
- if (objIDispatch == null) return COM.E_FAIL;
-
- // create a DISPPARAMS structure for the input parameters
- DISPPARAMS pDispParams = new DISPPARAMS();
- // store arguments in rgvarg
- if (rgvarg != null && rgvarg.length > 0) {
- pDispParams.cArgs = rgvarg.length;
- pDispParams.rgvarg = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, VARIANT.sizeof * rgvarg.length);
- int offset = 0;
- for (int i = rgvarg.length - 1; i >= 0 ; i--) {
- rgvarg[i].getData(pDispParams.rgvarg + offset);
- offset += VARIANT.sizeof;
- }
- }
-
- // if arguments have ids, store the ids in rgdispidNamedArgs
- if (rgdispidNamedArgs != null && rgdispidNamedArgs.length > 0) {
- pDispParams.cNamedArgs = rgdispidNamedArgs.length;
- pDispParams.rgdispidNamedArgs = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, 4 * rgdispidNamedArgs.length);
- int offset = 0;
- for (int i = rgdispidNamedArgs.length; i > 0; i--) {
- COM.MoveMemory(pDispParams.rgdispidNamedArgs + offset, new int[] {rgdispidNamedArgs[i-1]}, 4);
- offset += 4;
- }
- }
-
- // invoke the method
- EXCEPINFO excepInfo = new EXCEPINFO();
- int[] pArgErr = new int[1];
- int /*long*/ pVarResultAddress = 0;
- if (pVarResult != null) pVarResultAddress = OS.GlobalAlloc(OS.GMEM_FIXED | OS.GMEM_ZEROINIT, VARIANT.sizeof);
- int result = objIDispatch.Invoke(dispIdMember, new GUID(), COM.LOCALE_USER_DEFAULT, wFlags, pDispParams, pVarResultAddress, excepInfo, pArgErr);
-
- if (pVarResultAddress != 0){
- pVarResult.setData(pVarResultAddress);
- COM.VariantClear(pVarResultAddress);
- OS.GlobalFree(pVarResultAddress);
- }
-
- // free the Dispparams resources
- if (pDispParams.rgdispidNamedArgs != 0){
- OS.GlobalFree(pDispParams.rgdispidNamedArgs);
- }
- if (pDispParams.rgvarg != 0) {
- int offset = 0;
- for (int i = 0, length = rgvarg.length; i < length; i++){
- COM.VariantClear(pDispParams.rgvarg + offset);
- offset += VARIANT.sizeof;
- }
- OS.GlobalFree(pDispParams.rgvarg);
- }
-
- // save error string and cleanup EXCEPINFO
- manageExcepinfo(result, excepInfo);
-
- return result;
-}
-/**
- * Invokes a method on the OLE Object; the method has no parameters. In the early days of OLE,
- * the IDispatch interface was not well defined and some applications (mainly Word) did not support
- * a return value. For these applications, call this method instead of calling
- * <code>public void invoke(int dispIdMember)</code>.
- *
- * @param dispIdMember the ID of the method as specified by the IDL of the ActiveX Control; the
- * value for the ID can be obtained using OleAutomation.getIDsOfNames
- *
- * @exception org.eclipse.swt.SWTException <ul>
- * <li>ERROR_ACTION_NOT_PERFORMED when method invocation fails
- * </ul>
- */
-public void invokeNoReply(int dispIdMember) {
- int result = invoke(dispIdMember, COM.DISPATCH_METHOD, null, null, null);
- if (result != COM.S_OK)
- OLE.error(OLE.ERROR_ACTION_NOT_PERFORMED, result);
-}
-/**
- * Invokes a method on the OLE Object; the method has no optional parameters. In the early days of OLE,
- * the IDispatch interface was not well defined and some applications (mainly Word) did not support
- * a return value. For these applications, call this method instead of calling
- * <code>public void invoke(int dispIdMember, Variant[] rgvarg)</code>.
- *
- * @param dispIdMember the ID of the method as specified by the IDL of the ActiveX Control; the
- * value for the ID can be obtained using OleAutomation.getIDsOfNames
- *
- * @param rgvarg an array of arguments for the method. All arguments are considered to be
- * read only unless the Variant is a By Reference Variant type.
- *
- * @exception org.eclipse.swt.SWTException <ul>
- * <li>ERROR_ACTION_NOT_PERFORMED when method invocation fails
- * </ul>
- */
-public void invokeNoReply(int dispIdMember, Variant[] rgvarg) {
- int result = invoke(dispIdMember, COM.DISPATCH_METHOD, rgvarg, null, null);
- if (result != COM.S_OK)
- OLE.error(OLE.ERROR_ACTION_NOT_PERFORMED, result);
-}
-/**
- * Invokes a method on the OLE Object; the method has optional parameters. It is not
- * necessary to specify all the optional parameters, only include the parameters for which
- * you are providing values. In the early days of OLE, the IDispatch interface was not well
- * defined and some applications (mainly Word) did not support a return value. For these
- * applications, call this method instead of calling
- * <code>public void invoke(int dispIdMember, Variant[] rgvarg, int[] rgdispidNamedArgs)</code>.
- *
- * @param dispIdMember the ID of the method as specified by the IDL of the ActiveX Control; the
- * value for the ID can be obtained using OleAutomation.getIDsOfNames
- *
- * @param rgvarg an array of arguments for the method. All arguments are considered to be
- * read only unless the Variant is a By Reference Variant type.
- *
- * @param rgdispidNamedArgs an array of identifiers for the arguments specified in rgvarg; the
- * parameter IDs must be in the same order as their corresponding values;
- * all arguments must have an identifier - identifiers can be obtained using
- * OleAutomation.getIDsOfNames
- *
- * @exception org.eclipse.swt.SWTException <ul>
- * <li>ERROR_ACTION_NOT_PERFORMED when method invocation fails
- * </ul>
- */
-public void invokeNoReply(int dispIdMember, Variant[] rgvarg, int[] rgdispidNamedArgs) {
- int result = invoke(dispIdMember, COM.DISPATCH_METHOD, rgvarg, rgdispidNamedArgs, null);
- if (result != COM.S_OK)
- OLE.error(OLE.ERROR_ACTION_NOT_PERFORMED, result);
-}
-private void manageExcepinfo(int hResult, EXCEPINFO excepInfo) {
-
- if (hResult == COM.S_OK){
- exceptionDescription = "No Error"; //$NON-NLS-1$
- return;
- }
-
- // extract exception info
- if (hResult == COM.DISP_E_EXCEPTION) {
- if (excepInfo.bstrDescription != 0){
- int size = COM.SysStringByteLen(excepInfo.bstrDescription);
- char[] buffer = new char[(size + 1) /2];
- COM.MoveMemory(buffer, excepInfo.bstrDescription, size);
- exceptionDescription = new String(buffer);
- } else {
- exceptionDescription = "OLE Automation Error Exception "; //$NON-NLS-1$
- if (excepInfo.wCode != 0){
- exceptionDescription += "code = "+excepInfo.wCode; //$NON-NLS-1$
- } else if (excepInfo.scode != 0){
- exceptionDescription += "code = "+excepInfo.scode; //$NON-NLS-1$
- }
- }
- } else {
- exceptionDescription = "OLE Automation Error HResult : " + hResult; //$NON-NLS-1$
- }
-
- // cleanup EXCEPINFO struct
- if (excepInfo.bstrDescription != 0)
- COM.SysFreeString(excepInfo.bstrDescription);
- if (excepInfo.bstrHelpFile != 0)
- COM.SysFreeString(excepInfo.bstrHelpFile);
- if (excepInfo.bstrSource != 0)
- COM.SysFreeString(excepInfo.bstrSource);
-}
-/**
- * Sets the property specified by the dispIdMember to a new value.
- *
- * @param dispIdMember the ID of the property as specified by the IDL of the ActiveX Control; the
- * value for the ID can be obtained using OleAutomation.getIDsOfNames
- * @param rgvarg the new value of the property
- *
- * @return true if the operation was successful
- */
-public boolean setProperty(int dispIdMember, Variant rgvarg) {
- Variant[] rgvarg2 = new Variant[] {rgvarg};
- int[] rgdispidNamedArgs = new int[] {COM.DISPID_PROPERTYPUT};
- int dwFlags = COM.DISPATCH_PROPERTYPUT;
- if ((rgvarg.getType() & COM.VT_BYREF) == COM.VT_BYREF)
- dwFlags = COM.DISPATCH_PROPERTYPUTREF;
- Variant pVarResult = new Variant();
- int result = invoke(dispIdMember, dwFlags, rgvarg2, rgdispidNamedArgs, pVarResult);
- return (result == COM.S_OK);
-}
-/**
- * Sets the property specified by the dispIdMember to a new value.
- *
- * @param dispIdMember the ID of the property as specified by the IDL of the ActiveX Control; the
- * value for the ID can be obtained using OleAutomation.getIDsOfNames
- * @param rgvarg an array of arguments for the method. All arguments are considered to be
- * read only unless the Variant is a By Reference Variant type.
- *
- * @return true if the operation was successful
- *
- * @since 2.0
- */
-public boolean setProperty(int dispIdMember, Variant[] rgvarg) {
- int[] rgdispidNamedArgs = new int[] {COM.DISPID_PROPERTYPUT};
- int dwFlags = COM.DISPATCH_PROPERTYPUT;
- for (int i = 0; i < rgvarg.length; i++) {
- if ((rgvarg[i].getType() & COM.VT_BYREF) == COM.VT_BYREF)
- dwFlags = COM.DISPATCH_PROPERTYPUTREF;
- }
- Variant pVarResult = new Variant();
- int result = invoke(dispIdMember, dwFlags, rgvarg, rgdispidNamedArgs, pVarResult);
- return (result == COM.S_OK);
-}
-}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleClientSite.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleClientSite.java
deleted file mode 100755
index 90ed46e62c..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleClientSite.java
+++ /dev/null
@@ -1,1494 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.ole.win32;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.FileInputStream;
-import java.io.IOException;
-import org.eclipse.swt.*;
-import org.eclipse.swt.internal.C;
-import org.eclipse.swt.internal.Compatibility;
-import org.eclipse.swt.internal.ole.win32.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.swt.internal.win32.*;
-/**
- * OleClientSite provides a site to manage an embedded OLE Document within a container.
- *
- * <p>The OleClientSite provides the following capabilities:
- * <ul>
- * <li>creates the in-place editor for a blank document or opening an existing OLE Document
- * <li>lays the editor out
- * <li>provides a mechanism for activating and deactivating the Document
- * <li>provides a mechanism for saving changes made to the document
- * </ul>
- *
- * <p>This object implements the OLE Interfaces IUnknown, IOleClientSite, IAdviseSink,
- * IOleInPlaceSite
- *
- * <p>Note that although this class is a subclass of <code>Composite</code>,
- * it does not make sense to add <code>Control</code> children to it,
- * or set a layout on it.
- * </p><p>
- * <dl>
- * <dt><b>Styles</b> <dd>BORDER
- * <dt><b>Events</b> <dd>Dispose, Move, Resize
- * </dl>
- *
- * @see <a href="http://www.eclipse.org/swt/snippets/#ole">OLE and ActiveX snippets</a>
- * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Examples: OLEExample, OleWebBrowser</a>
- */
-public class OleClientSite extends Composite {
-
- // Interfaces for this Ole Client Container
- private COMObject iUnknown;
- COMObject iOleClientSite;
- private COMObject iAdviseSink;
- private COMObject iOleInPlaceSite;
- private COMObject iOleDocumentSite;
-
- protected GUID appClsid;
- private GUID objClsid;
- private int refCount;
-
- // References to the associated Frame.
- protected OleFrame frame;
-
- // Access to the embedded/linked Ole Object
- protected IUnknown objIUnknown;
- protected IOleObject objIOleObject;
- protected IViewObject2 objIViewObject2;
- protected IOleInPlaceObject objIOleInPlaceObject;
- protected IOleCommandTarget objIOleCommandTarget;
- protected IOleDocumentView objDocumentView;
-
- // Related storage information
- protected IStorage tempStorage; // IStorage interface of the receiver
-
- // Internal state and style information
- private int aspect; // the display aspect of the embedded object, e.g., DvaspectContent or DvaspectIcon
- private int type; // Indicates the type of client that can be supported inside this container
- private boolean isStatic; // Indicates item's display is static, i.e., a bitmap, metafile, etc.
-
- private RECT borderWidths = new RECT();
- private RECT indent = new RECT();
- private boolean inUpdate = false;
- private boolean inInit = true;
- private boolean inDispose = false;
-
- private static final String WORDPROGID = "Word.Document"; //$NON-NLS-1$
-
- private Listener listener;
-
- static final int STATE_NONE = 0;
- static final int STATE_RUNNING = 1;
- static final int STATE_INPLACEACTIVE = 2;
- static final int STATE_UIACTIVE = 3;
- static final int STATE_ACTIVE = 4;
- int state = STATE_NONE;
-
-protected OleClientSite(Composite parent, int style) {
- /*
- * NOTE: this constructor should never be used by itself because it does
- * not create an Ole Object
- */
- super(parent, style);
-
- createCOMInterfaces();
-
- // install the Ole Frame for this Client Site
- while (parent != null) {
- if (parent instanceof OleFrame){
- frame = (OleFrame)parent;
- break;
- }
- parent = parent.getParent();
- }
- if (frame == null) OLE.error(SWT.ERROR_INVALID_ARGUMENT);
- frame.AddRef();
-
- aspect = COM.DVASPECT_CONTENT;
- type = COM.OLEEMBEDDED;
- isStatic = false;
-
- listener = new Listener() {
- public void handleEvent(Event e) {
- switch (e.type) {
- case SWT.Resize :
- case SWT.Move : onResize(e); break;
- case SWT.Dispose : onDispose(e); break;
- case SWT.FocusIn: onFocusIn(e); break;
- case SWT.FocusOut: onFocusOut(e); break;
- case SWT.Paint: onPaint(e); break;
- case SWT.Traverse: onTraverse(e); break;
- case SWT.KeyDown: /* required for traversal */ break;
- default :
- OLE.error(SWT.ERROR_NOT_IMPLEMENTED);
- }
- }
- };
-
- frame.addListener(SWT.Resize, listener);
- frame.addListener(SWT.Move, listener);
- addListener(SWT.Dispose, listener);
- addListener(SWT.FocusIn, listener);
- addListener(SWT.FocusOut, listener);
- addListener(SWT.Paint, listener);
- addListener(SWT.Traverse, listener);
- addListener(SWT.KeyDown, listener);
-}
-/**
- * Create an OleClientSite child widget using the OLE Document type associated with the
- * specified file. The OLE Document type is determined either through header information in the file
- * or through a Registry entry for the file extension. Use style bits to select a particular look
- * or set of properties.
- *
- * @param parent a composite widget; must be an OleFrame
- * @param style the bitwise OR'ing of widget styles
- * @param file the file that is to be opened in this OLE Document
- *
- * @exception IllegalArgumentException
- * <ul><li>ERROR_NULL_ARGUMENT when the parent is null
- * <li>ERROR_INVALID_ARGUMENT when the parent is not an OleFrame</ul>
- * @exception SWTException
- * <ul><li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
- * <li>ERROR_CANNOT_CREATE_OBJECT when failed to create OLE Object
- * <li>ERROR_CANNOT_OPEN_FILE when failed to open file
- * <li>ERROR_INTERFACE_NOT_FOUND when unable to create callbacks for OLE Interfaces
- * <li>ERROR_INVALID_CLASSID
- * </ul>
- */
-public OleClientSite(Composite parent, int style, File file) {
- this(parent, style);
- try {
-
- if (file == null || file.isDirectory() || !file.exists())
- OLE.error(OLE.ERROR_INVALID_ARGUMENT);
-
- // Is there an associated CLSID?
- appClsid = new GUID();
- char[] fileName = (file.getAbsolutePath()+"\0").toCharArray();
- int result = COM.GetClassFile(fileName, appClsid);
- if (result != COM.S_OK)
- OLE.error(OLE.ERROR_INVALID_CLASSID, result);
- // associated CLSID may not be installed on this machine
- if (getProgramID() == null)
- OLE.error(OLE.ERROR_INVALID_CLASSID, result);
-
- // Open a temporary storage object
- tempStorage = createTempStorage();
-
- // Create ole object with storage object
- int /*long*/[] address = new int /*long*/[1];
- result = COM.OleCreateFromFile(appClsid, fileName, COM.IIDIUnknown, COM.OLERENDER_DRAW, null, iOleClientSite.getAddress(), tempStorage.getAddress(), address);
- if (result != COM.S_OK)
- OLE.error(OLE.ERROR_CANNOT_CREATE_OBJECT, result);
-
- objIUnknown = new IUnknown(address[0]);
-
- // Init sinks
- addObjectReferences();
-
- if (COM.OleRun(objIUnknown.getAddress()) == OLE.S_OK) state = STATE_RUNNING;
- } catch (SWTException e) {
- dispose();
- disposeCOMInterfaces();
- throw e;
- }
-}
-/**
- * Create an OleClientSite child widget to edit a blank document using the specified OLE Document
- * application. Use style bits to select a particular look or set of properties.
- *
- * @param parent a composite widget; must be an OleFrame
- * @param style the bitwise OR'ing of widget styles
- * @param progId the unique program identifier of am OLE Document application;
- * the value of the ProgID key or the value of the VersionIndependentProgID key specified
- * in the registry for the desired OLE Document (for example, the VersionIndependentProgID
- * for Word is Word.Document)
- *
- * @exception IllegalArgumentException
- *<ul>
- * <li>ERROR_NULL_ARGUMENT when the parent is null
- * <li>ERROR_INVALID_ARGUMENT when the parent is not an OleFrame
- *</ul>
- * @exception SWTException
- * <ul><li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
- * <li>ERROR_INVALID_CLASSID when the progId does not map to a registered CLSID
- * <li>ERROR_CANNOT_CREATE_OBJECT when failed to create OLE Object
- * </ul>
- */
-public OleClientSite(Composite parent, int style, String progId) {
- this(parent, style);
- try {
- appClsid = getClassID(progId);
- if (appClsid == null)
- OLE.error(OLE.ERROR_INVALID_CLASSID);
-
- // Open a temporary storage object
- tempStorage = createTempStorage();
-
- // Create ole object with storage object
- int /*long*/[] address = new int /*long*/[1];
- int result = COM.OleCreate(appClsid, COM.IIDIUnknown, COM.OLERENDER_DRAW, null, iOleClientSite.getAddress(), tempStorage.getAddress(), address);
- if (result != COM.S_OK)
- OLE.error(OLE.ERROR_CANNOT_CREATE_OBJECT, result);
-
- objIUnknown = new IUnknown(address[0]);
-
- // Init sinks
- addObjectReferences();
-
- if (COM.OleRun(objIUnknown.getAddress()) == OLE.S_OK) state = STATE_RUNNING;
-
- } catch (SWTException e) {
- dispose();
- disposeCOMInterfaces();
- throw e;
- }
-}
-/**
- * Create an OleClientSite child widget to edit the specified file using the specified OLE Document
- * application. Use style bits to select a particular look or set of properties.
- * <p>
- * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
- * API for <code>OleClientSite</code>. It is marked public only so that it
- * can be shared within the packages provided by SWT. It is not
- * available on all platforms, and should never be called from
- * application code.
- * </p>
- * @param parent a composite widget; must be an OleFrame
- * @param style the bitwise OR'ing of widget styles
- * @param progId the unique program identifier of am OLE Document application;
- * the value of the ProgID key or the value of the VersionIndependentProgID key specified
- * in the registry for the desired OLE Document (for example, the VersionIndependentProgID
- * for Word is Word.Document)
- * @param file the file that is to be opened in this OLE Document
- *
- * @exception IllegalArgumentException
- * <ul><li>ERROR_NULL_ARGUMENT when the parent is null
- * <li>ERROR_INVALID_ARGUMENT when the parent is not an OleFrame</ul>
- * @exception SWTException
- * <ul><li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
- * <li>ERROR_INVALID_CLASSID when the progId does not map to a registered CLSID
- * <li>ERROR_CANNOT_CREATE_OBJECT when failed to create OLE Object
- * <li>ERROR_CANNOT_OPEN_FILE when failed to open file
- * </ul>
- */
-public OleClientSite(Composite parent, int style, String progId, File file) {
- this(parent, style);
- try {
- if (file == null || file.isDirectory() || !file.exists()) OLE.error(OLE.ERROR_INVALID_ARGUMENT);
- appClsid = getClassID(progId);
- if (appClsid == null) OLE.error(OLE.ERROR_INVALID_CLASSID);
-
- // Are we opening this file with the preferred OLE object?
- char[] fileName = (file.getAbsolutePath()+"\0").toCharArray();
- GUID fileClsid = new GUID();
- COM.GetClassFile(fileName, fileClsid);
-
- if (COM.IsEqualGUID(appClsid, fileClsid)){
- // Using the same application that created file, therefore, use default mechanism.
- tempStorage = createTempStorage();
- // Create ole object with storage object
- int /*long*/[] address = new int /*long*/[1];
- int result = COM.OleCreateFromFile(appClsid, fileName, COM.IIDIUnknown, COM.OLERENDER_DRAW, null, iOleClientSite.getAddress(), tempStorage.getAddress(), address);
- if (result != COM.S_OK) OLE.error(OLE.ERROR_CANNOT_CREATE_OBJECT, result);
- objIUnknown = new IUnknown(address[0]);
- } else {
- // Not using the same application that created file, therefore, copy from original file to a new storage file
- IStorage storage = null;
- if (COM.StgIsStorageFile(fileName) == COM.S_OK) {
- int /*long*/[] address = new int /*long*/[1];
- int mode = COM.STGM_READ | COM.STGM_TRANSACTED | COM.STGM_SHARE_EXCLUSIVE;
- int result = COM.StgOpenStorage(fileName, 0, mode, 0, 0, address); //Does an AddRef if successful
- if (result != COM.S_OK) OLE.error(OLE.ERROR_CANNOT_OPEN_FILE, result);
- storage = new IStorage(address[0]);
- } else {
- // Original file is not a Storage file so copy contents to a stream in a new storage file
- int /*long*/[] address = new int /*long*/[1];
- int mode = COM.STGM_READWRITE | COM.STGM_DIRECT | COM.STGM_SHARE_EXCLUSIVE | COM.STGM_CREATE;
- int result = COM.StgCreateDocfile(null, mode | COM.STGM_DELETEONRELEASE, 0, address); // Increments ref count if successful
- if (result != COM.S_OK) OLE.error(OLE.ERROR_CANNOT_OPEN_FILE, result);
- storage = new IStorage(address[0]);
- // Create a stream on the storage object.
- // Word does not follow the standard and does not use "CONTENTS" as the name of
- // its primary stream
- String streamName = "CONTENTS"; //$NON-NLS-1$
- GUID wordGUID = getClassID(WORDPROGID);
- if (wordGUID != null && COM.IsEqualGUID(appClsid, wordGUID)) streamName = "WordDocument"; //$NON-NLS-1$
- address = new int /*long*/[1];
- result = storage.CreateStream(streamName, mode, 0, 0, address); // Increments ref count if successful
- if (result != COM.S_OK) {
- storage.Release();
- OLE.error(OLE.ERROR_CANNOT_OPEN_FILE, result);
- }
- IStream stream = new IStream(address[0]);
- try {
- // Copy over data in file to named stream
- FileInputStream fileInput = new FileInputStream(file);
- int increment = 1024*4;
- byte[] buffer = new byte[increment];
- int count = 0;
- while((count = fileInput.read(buffer)) > 0){
- int /*long*/ pv = COM.CoTaskMemAlloc(count);
- OS.MoveMemory(pv, buffer, count);
- result = stream.Write(pv, count, null) ;
- COM.CoTaskMemFree(pv);
- if (result != COM.S_OK) {
- fileInput.close();
- stream.Release();
- storage.Release();
- OLE.error(OLE.ERROR_CANNOT_OPEN_FILE, result);
- }
- }
- fileInput.close();
- stream.Commit(COM.STGC_DEFAULT);
- stream.Release();
- } catch (IOException err) {
- stream.Release();
- storage.Release();
- OLE.error(OLE.ERROR_CANNOT_OPEN_FILE);
- }
- }
-
- // Open a temporary storage object
- tempStorage = createTempStorage();
- // Copy over contents of file
- int result = storage.CopyTo(0, null, null, tempStorage.getAddress());
- storage.Release();
- if (result != COM.S_OK) OLE.error(OLE.ERROR_CANNOT_OPEN_FILE, result);
-
- // create ole client
- int /*long*/[] ppv = new int /*long*/[1];
- result = COM.CoCreateInstance(appClsid, 0, COM.CLSCTX_INPROC_HANDLER | COM.CLSCTX_INPROC_SERVER, COM.IIDIUnknown, ppv);
- if (result != COM.S_OK) OLE.error(OLE.ERROR_CANNOT_CREATE_OBJECT, result);
- objIUnknown = new IUnknown(ppv[0]);
- // get the persistent storage of the ole client
- ppv = new int /*long*/[1];
- result = objIUnknown.QueryInterface(COM.IIDIPersistStorage, ppv);
- if (result != COM.S_OK) OLE.error(OLE.ERROR_CANNOT_CREATE_OBJECT, result);
- IPersistStorage iPersistStorage = new IPersistStorage(ppv[0]);
- // load the contents of the file into the ole client site
- result = iPersistStorage.Load(tempStorage.getAddress());
- iPersistStorage.Release();
- if (result != COM.S_OK)OLE.error(OLE.ERROR_CANNOT_CREATE_OBJECT, result);
- }
-
- // Init sinks
- addObjectReferences();
-
- if (COM.OleRun(objIUnknown.getAddress()) == OLE.S_OK) state = STATE_RUNNING;
-
- } catch (SWTException e) {
- dispose();
- disposeCOMInterfaces();
- throw e;
- }
-}
-protected void addObjectReferences() {
- //
- int /*long*/[] ppvObject = new int /*long*/[1];
- if (objIUnknown.QueryInterface(COM.IIDIPersist, ppvObject) == COM.S_OK) {
- IPersist objIPersist = new IPersist(ppvObject[0]);
- GUID tempid = new GUID();
- if (objIPersist.GetClassID(tempid) == COM.S_OK)
- objClsid = tempid;
- objIPersist.Release();
- }
-
- //
- ppvObject = new int /*long*/[1];
- int result = objIUnknown.QueryInterface(COM.IIDIViewObject2, ppvObject);
- if (result != COM.S_OK)
- OLE.error(OLE.ERROR_INTERFACE_NOT_FOUND, result);
- objIViewObject2 = new IViewObject2(ppvObject[0]);
- objIViewObject2.SetAdvise(aspect, 0, iAdviseSink.getAddress());
-
- //
- ppvObject = new int /*long*/[1];
- result = objIUnknown.QueryInterface(COM.IIDIOleObject, ppvObject);
- if (result != COM.S_OK)
- OLE.error(OLE.ERROR_INTERFACE_NOT_FOUND, result);
- objIOleObject = new IOleObject(ppvObject[0]);
- /*
- * Feature in Windows. Despite the fact that the clientSite was provided during the
- * creation of the OleObject (which is required by WMP11 - see bug 173556),
- * some applications choose to ignore this optional parameter (see bug 211663)
- * during OleCreate. The fix is to check whether the clientSite has already been set
- * and set it. Note that setting it twice can result in assert failures.
- */
- int /*long*/[] ppvClientSite = new int /*long*/[1];
- result = objIOleObject.GetClientSite(ppvClientSite);
- if (ppvClientSite[0] == 0) {
- objIOleObject.SetClientSite(iOleClientSite.getAddress());
- } else {
- Release(); // GetClientSite performs an AddRef so we must release it.
- }
- int[] pdwConnection = new int[1];
- objIOleObject.Advise(iAdviseSink.getAddress(), pdwConnection);
- objIOleObject.SetHostNames("main", "main"); //$NON-NLS-1$ //$NON-NLS-2$
-
- // Notify the control object that it is embedded in an OLE container
- COM.OleSetContainedObject(objIUnknown.getAddress(), true);
-
- // Is OLE object linked or embedded?
- ppvObject = new int /*long*/[1];
- if (objIUnknown.QueryInterface(COM.IIDIOleLink, ppvObject) == COM.S_OK) {
- IOleLink objIOleLink = new IOleLink(ppvObject[0]);
- int /*long*/[] ppmk = new int /*long*/[1];
- if (objIOleLink.GetSourceMoniker(ppmk) == COM.S_OK) {
- IMoniker objIMoniker = new IMoniker(ppmk[0]);
- objIMoniker.Release();
- type = COM.OLELINKED;
- objIOleLink.BindIfRunning();
- } else {
- isStatic = true;
- }
- objIOleLink.Release();
- }
-}
-protected int AddRef() {
- refCount++;
- return refCount;
-}
-private int CanInPlaceActivate() {
- if (aspect == COM.DVASPECT_CONTENT && type == COM.OLEEMBEDDED)
- return COM.S_OK;
-
- return COM.S_FALSE;
-}
-private int ContextSensitiveHelp(int fEnterMode) {
- return COM.S_OK;
-}
-protected void createCOMInterfaces() {
-
- iUnknown = new COMObject(new int[]{2, 0, 0}){
- public int /*long*/ method0(int /*long*/[] args) {return QueryInterface(args[0], args[1]);}
- public int /*long*/ method1(int /*long*/[] args) {return AddRef();}
- public int /*long*/ method2(int /*long*/[] args) {return Release();}
- };
-
- iOleClientSite = new COMObject(new int[]{2, 0, 0, 0, 3, 1, 0, 1, 0}){
- public int /*long*/ method0(int /*long*/[] args) {return QueryInterface(args[0], args[1]);}
- public int /*long*/ method1(int /*long*/[] args) {return AddRef();}
- public int /*long*/ method2(int /*long*/[] args) {return Release();}
- public int /*long*/ method3(int /*long*/[] args) {return SaveObject();}
- // method4 GetMoniker - not implemented
- public int /*long*/ method5(int /*long*/[] args) {return GetContainer(args[0]);}
- public int /*long*/ method6(int /*long*/[] args) {return ShowObject();}
- public int /*long*/ method7(int /*long*/[] args) {return OnShowWindow((int)/*64*/args[0]);}
- // method8 RequestNewObjectLayout - not implemented
- };
-
- iAdviseSink = new COMObject(new int[]{2, 0, 0, 2, 2, 1, 0, 0}){
- public int /*long*/ method0(int /*long*/[] args) {return QueryInterface(args[0], args[1]);}
- public int /*long*/ method1(int /*long*/[] args) {return AddRef();}
- public int /*long*/ method2(int /*long*/[] args) {return Release();}
- public int /*long*/ method3(int /*long*/[] args) {return OnDataChange(args[0], args[1]);}
- public int /*long*/ method4(int /*long*/[] args) {return OnViewChange((int)/*64*/args[0], (int)/*64*/args[1]);}
- //method5 OnRename - not implemented
- public int /*long*/ method6(int /*long*/[] args) {OnSave();return 0;}
- public int /*long*/ method7(int /*long*/[] args) {return OnClose();}
- };
-
- iOleInPlaceSite = new COMObject(new int[]{2, 0, 0, 1, 1, 0, 0, 0, 5, C.PTR_SIZEOF == 4 ? 2 : 1, 1, 0, 0, 0, 1}){
- public int /*long*/ method0(int /*long*/[] args) {return QueryInterface(args[0], args[1]);}
- public int /*long*/ method1(int /*long*/[] args) {return AddRef();}
- public int /*long*/ method2(int /*long*/[] args) {return Release();}
- public int /*long*/ method3(int /*long*/[] args) {return GetWindow(args[0]);}
- public int /*long*/ method4(int /*long*/[] args) {return ContextSensitiveHelp((int)/*64*/args[0]);}
- public int /*long*/ method5(int /*long*/[] args) {return CanInPlaceActivate();}
- public int /*long*/ method6(int /*long*/[] args) {return OnInPlaceActivate();}
- public int /*long*/ method7(int /*long*/[] args) {return OnUIActivate();}
- public int /*long*/ method8(int /*long*/[] args) {return GetWindowContext(args[0], args[1], args[2], args[3], args[4]);}
- public int /*long*/ method9(int /*long*/[] args) {
- if (args.length == 2) {
- return Scroll((int)/*64*/args[0], (int)/*64*/args[1]);
- } else {
- return Scroll_64(args[0]);
- }
- }
- public int /*long*/ method10(int /*long*/[] args) {return OnUIDeactivate((int)/*64*/args[0]);}
- public int /*long*/ method11(int /*long*/[] args) {return OnInPlaceDeactivate();}
- // method12 DiscardUndoState - not implemented
- // method13 DeactivateAndUndoChange - not implemented
- public int /*long*/ method14(int /*long*/[] args) {return OnPosRectChange(args[0]);}
- };
-
- iOleDocumentSite = new COMObject(new int[]{2, 0, 0, 1}){
- public int /*long*/ method0(int /*long*/[] args) {return QueryInterface(args[0], args[1]);}
- public int /*long*/ method1(int /*long*/[] args) {return AddRef();}
- public int /*long*/ method2(int /*long*/[] args) {return Release();}
- public int /*long*/ method3(int /*long*/[] args) {return ActivateMe(args[0]);}
- };
-}
-protected IStorage createTempStorage() {
- int /*long*/[] tempStorage = new int /*long*/[1];
- int grfMode = COM.STGM_READWRITE | COM.STGM_SHARE_EXCLUSIVE | COM.STGM_DELETEONRELEASE;
- int result = COM.StgCreateDocfile(null, grfMode, 0, tempStorage);
- if (result != COM.S_OK) OLE.error(OLE.ERROR_CANNOT_CREATE_FILE, result);
- return new IStorage(tempStorage[0]);
-}
-/**
- * Deactivates an active in-place object and discards the object's undo state.
- */
-public void deactivateInPlaceClient() {
- if (objIOleInPlaceObject != null) {
- objIOleInPlaceObject.InPlaceDeactivate();
- }
-}
-private void deleteTempStorage() {
- //Destroy this item's contents in the temp root IStorage.
- if (tempStorage != null){
- tempStorage.Release();
- }
- tempStorage = null;
-}
-protected void disposeCOMInterfaces() {
- if (iUnknown != null)
- iUnknown.dispose();
- iUnknown = null;
-
- if (iOleClientSite != null)
- iOleClientSite.dispose();
- iOleClientSite = null;
-
- if (iAdviseSink != null)
- iAdviseSink.dispose();
- iAdviseSink = null;
-
- if (iOleInPlaceSite != null)
- iOleInPlaceSite.dispose();
- iOleInPlaceSite = null;
-
- if (iOleDocumentSite != null)
- iOleDocumentSite.dispose();
- iOleDocumentSite = null;
-}
-/**
- * Requests that the OLE Document or ActiveX Control perform an action; actions are almost always
- * changes to the activation state.
- *
- * @param verb the operation that is requested. This is one of the OLE.OLEIVERB_ values
- *
- * @return an HRESULT value indicating the success of the operation request; OLE.S_OK indicates
- * success
- */
-public int doVerb(int verb) {
- // Not all OLE clients (for example PowerPoint) can be set into the running state in the constructor.
- // The fix is to ensure that the client is in the running state before invoking any verb on it.
- if (state == STATE_NONE) {
- if (COM.OleRun(objIUnknown.getAddress()) == OLE.S_OK) state = STATE_RUNNING;
- }
- if (state == STATE_NONE || isStatic)
- return COM.E_FAIL;
-
- // See PR: 1FV9RZW
- RECT rect = new RECT();
- OS.GetClientRect(handle, rect);
- int result = objIOleObject.DoVerb(verb, null, iOleClientSite.getAddress(), 0, handle, rect);
-
- if (state != STATE_RUNNING && inInit) {
- updateStorage();
- inInit = false;
- }
- return result;
-}
-/**
- * Asks the OLE Document or ActiveX Control to execute a command from a standard
- * list of commands. The OLE Document or ActiveX Control must support the IOleCommandTarget
- * interface. The OLE Document or ActiveX Control does not have to support all the commands
- * in the standard list. To check if a command is supported, you can call queryStatus with
- * the cmdID.
- *
- * @param cmdID the ID of a command; these are the OLE.OLECMDID_ values - a small set of common
- * commands
- * @param options the optional flags; these are the OLE.OLECMDEXECOPT_ values
- * @param in the argument for the command
- * @param out the return value of the command
- *
- * @return an HRESULT value; OLE.S_OK is returned if successful
- *
- */
-public int exec(int cmdID, int options, Variant in, Variant out) {
-
- if (objIOleCommandTarget == null) {
- int /*long*/[] address = new int /*long*/[1];
- if (objIUnknown.QueryInterface(COM.IIDIOleCommandTarget, address) != COM.S_OK)
- return OLE.ERROR_INTERFACE_NOT_FOUND;
- objIOleCommandTarget = new IOleCommandTarget(address[0]);
- }
-
- int /*long*/ inAddress = 0;
- if (in != null){
- inAddress = OS.GlobalAlloc(OS.GMEM_FIXED | OS.GMEM_ZEROINIT, VARIANT.sizeof);
- in.getData(inAddress);
- }
- int /*long*/ outAddress = 0;
- if (out != null){
- outAddress = OS.GlobalAlloc(OS.GMEM_FIXED | OS.GMEM_ZEROINIT, VARIANT.sizeof);
- out.getData(outAddress);
- }
-
- int result = objIOleCommandTarget.Exec(null, cmdID, options, inAddress, outAddress);
-
- if (inAddress != 0){
- COM.VariantClear(inAddress);
- OS.GlobalFree(inAddress);
- }
- if (outAddress != 0) {
- out.setData(outAddress);
- COM.VariantClear(outAddress);
- OS.GlobalFree(outAddress);
- }
-
- return result;
-}
-IDispatch getAutomationObject() {
- int /*long*/[] ppvObject = new int /*long*/[1];
- if (objIUnknown.QueryInterface(COM.IIDIDispatch, ppvObject) != COM.S_OK)
- return null;
- return new IDispatch(ppvObject[0]);
-}
-protected GUID getClassID(String clientName) {
- // create a GUID struct to hold the result
- GUID guid = new GUID();
-
- // create a null terminated array of char
- char[] buffer = null;
- if (clientName != null) {
- int count = clientName.length();
- buffer = new char[count + 1];
- clientName.getChars(0, count, buffer, 0);
- }
- if (COM.CLSIDFromProgID(buffer, guid) != COM.S_OK){
- int result = COM.CLSIDFromString(buffer, guid);
- if (result != COM.S_OK) return null;
- }
- return guid;
-}
-private int GetContainer(int /*long*/ ppContainer) {
- /* Simple containers that do not support links to their embedded
- * objects probably do not need to implement this method. Instead,
- * they can return E_NOINTERFACE and set ppContainer to NULL.
- */
- if (ppContainer != 0)
- COM.MoveMemory(ppContainer, new int /*long*/[]{0}, OS.PTR_SIZEOF);
- return COM.E_NOINTERFACE;
-}
-private SIZE getExtent() {
- SIZE sizel = new SIZE();
- // get the current size of the embedded OLENatives object
- if (objIOleObject != null) {
- if ( objIViewObject2 != null && !COM.OleIsRunning(objIOleObject.getAddress())) {
- objIViewObject2.GetExtent(aspect, -1, null, sizel);
- } else {
- objIOleObject.GetExtent(aspect, sizel);
- }
- }
- return xFormHimetricToPixels(sizel);
-}
-/**
- * Returns the indent value that would be used to compute the clipping area
- * of the active X object.
- *
- * NOTE: The indent value is no longer being used by the client site.
- *
- * @return the rectangle representing the indent
- */
-public Rectangle getIndent() {
- return new Rectangle(indent.left, indent.right, indent.top, indent.bottom);
-}
-/**
- * Returns the program ID of the OLE Document or ActiveX Control.
- *
- * @return the program ID of the OLE Document or ActiveX Control
- */
-public String getProgramID(){
- if (appClsid != null){
- int /*long*/[] lplpszProgID = new int /*long*/[1];
- if (COM.ProgIDFromCLSID(appClsid, lplpszProgID) == COM.S_OK) {
- int /*long*/ hMem = lplpszProgID[0];
- int length = OS.GlobalSize(hMem);
- int /*long*/ ptr = OS.GlobalLock(hMem);
- char[] buffer = new char[length];
- COM.MoveMemory(buffer, ptr, length);
- OS.GlobalUnlock(hMem);
- OS.GlobalFree(hMem);
-
- String result = new String(buffer);
- // remove null terminator
- int index = result.indexOf("\0");
- return result.substring(0, index);
- }
- }
- return null;
-}
-int ActivateMe(int /*long*/ pViewToActivate) {
- if (pViewToActivate == 0) {
- int /*long*/[] ppvObject = new int /*long*/[1];
- if (objIUnknown.QueryInterface(COM.IIDIOleDocument, ppvObject) != COM.S_OK) return COM.E_FAIL;
- IOleDocument objOleDocument = new IOleDocument(ppvObject[0]);
- if (objOleDocument.CreateView(iOleInPlaceSite.getAddress(), 0, 0, ppvObject) != COM.S_OK) return COM.E_FAIL;
- objOleDocument.Release();
- objDocumentView = new IOleDocumentView(ppvObject[0]);
- } else {
- objDocumentView = new IOleDocumentView(pViewToActivate);
- objDocumentView.AddRef();
- objDocumentView.SetInPlaceSite(iOleInPlaceSite.getAddress());
- }
- objDocumentView.UIActivate(1);//TRUE
- RECT rect = getRect();
- objDocumentView.SetRect(rect);
- objDocumentView.Show(1);//TRUE
- return COM.S_OK;
-}
-protected int GetWindow(int /*long*/ phwnd) {
- if (phwnd == 0)
- return COM.E_INVALIDARG;
- if (frame == null) {
- COM.MoveMemory(phwnd, new int /*long*/[] {0}, OS.PTR_SIZEOF);
- return COM.E_NOTIMPL;
- }
-
- // Copy the Window's handle into the memory passed in
- COM.MoveMemory(phwnd, new int /*long*/[] {handle}, OS.PTR_SIZEOF);
- return COM.S_OK;
-}
-RECT getRect() {
- Rectangle area = getClientArea();
- RECT rect = new RECT();
- rect.left = area.x;
- rect.top = area.y;
- rect.right = area.x + area.width;
- rect.bottom = area.y + area.height;
- return rect;
-}
-private int GetWindowContext(int /*long*/ ppFrame, int /*long*/ ppDoc, int /*long*/ lprcPosRect, int /*long*/ lprcClipRect, int /*long*/ lpFrameInfo) {
- if (frame == null || ppFrame == 0)
- return COM.E_NOTIMPL;
-
- // fill in frame handle
- int /*long*/ iOleInPlaceFrame = frame.getIOleInPlaceFrame();
- COM.MoveMemory(ppFrame, new int /*long*/[] {iOleInPlaceFrame}, OS.PTR_SIZEOF);
- frame.AddRef();
-
- // null out document handle
- if (ppDoc != 0) COM.MoveMemory(ppDoc, new int /*long*/[] {0}, OS.PTR_SIZEOF);
-
- // fill in position and clipping info
- RECT rect = getRect();
- if (lprcPosRect != 0) OS.MoveMemory(lprcPosRect, rect, RECT.sizeof);
- if (lprcClipRect != 0) OS.MoveMemory(lprcClipRect, rect, RECT.sizeof);
-
- // get frame info
- OLEINPLACEFRAMEINFO frameInfo = new OLEINPLACEFRAMEINFO();
- frameInfo.cb = OLEINPLACEFRAMEINFO.sizeof;
- frameInfo.fMDIApp = 0;
- frameInfo.hwndFrame = frame.handle;
- Shell shell = getShell();
- Menu menubar = shell.getMenuBar();
- if (menubar != null && !menubar.isDisposed()) {
- int /*long*/ hwnd = shell.handle;
- int cAccel = (int)/*64*/OS.SendMessage(hwnd, OS.WM_APP, 0, 0);
- if (cAccel != 0) {
- int /*long*/ hAccel = OS.SendMessage(hwnd, OS.WM_APP+1, 0, 0);
- if (hAccel != 0) {
- frameInfo.cAccelEntries = cAccel;
- frameInfo.haccel = hAccel;
- }
- }
- }
- COM.MoveMemory(lpFrameInfo, frameInfo, OLEINPLACEFRAMEINFO.sizeof);
-
- return COM.S_OK;
-}
-/**
- * Returns whether ole document is dirty by checking whether the content
- * of the file representing the document is dirty.
- *
- * @return <code>true</code> if the document has been modified,
- * <code>false</code> otherwise.
- * @since 3.1
- */
-public boolean isDirty() {
- /*
- * Note: this method must return true unless it is absolutely clear that the
- * contents of the Ole Document do not differ from the contents in the file
- * on the file system.
- */
-
- // Get access to the persistent storage mechanism
- int /*long*/[] address = new int /*long*/[1];
- if (objIOleObject.QueryInterface(COM.IIDIPersistFile, address) != COM.S_OK)
- return true;
- IPersistFile permStorage = new IPersistFile(address[0]);
- // Are the contents of the permanent storage different from the file?
- int result = permStorage.IsDirty();
- permStorage.Release();
- if (result == COM.S_FALSE) return false;
- return true;
-}
-public boolean isFocusControl () {
- checkWidget ();
- int /*long*/ focusHwnd = OS.GetFocus();
- if (objIOleInPlaceObject == null) return (handle == focusHwnd);
- int /*long*/[] phwnd = new int /*long*/[1];
- objIOleInPlaceObject.GetWindow(phwnd);
- while (focusHwnd != 0) {
- if (phwnd[0] == focusHwnd) return true;
- focusHwnd = OS.GetParent(focusHwnd);
- }
- return false;
-}
-private boolean isOffice2007() {
- String programID = getProgramID();
- if (programID == null) return false;
- if (programID.equals("Word.Document.12")) return true; //$NON-NLS-1$
- if (programID.equals("Excel.Sheet.12")) return true; //$NON-NLS-1$
- if (programID.equals("PowerPoint.Show.12")) return true; //$NON-NLS-1$
- return false;
-}
-private int OnClose() {
- return COM.S_OK;
-}
-private int OnDataChange(int /*long*/ pFormatetc, int /*long*/ pStgmed) {
- return COM.S_OK;
-}
-private void onDispose(Event e) {
- inDispose = true;
-
- // remove listeners
- removeListener(SWT.Dispose, listener);
- removeListener(SWT.FocusIn, listener);
- removeListener(SWT.FocusOut, listener);
- removeListener(SWT.Paint, listener);
- removeListener(SWT.Traverse, listener);
- removeListener(SWT.KeyDown, listener);
-
- if (state != STATE_NONE)
- doVerb(OLE.OLEIVERB_DISCARDUNDOSTATE);
- deactivateInPlaceClient();
- releaseObjectInterfaces(); // Note, must release object interfaces before releasing frame
- deleteTempStorage();
-
- frame.removeListener(SWT.Resize, listener);
- frame.removeListener(SWT.Move, listener);
-
- frame.Release();
- frame = null;
-}
-void onFocusIn(Event e) {
- if (inDispose) return;
- if (state != STATE_UIACTIVE) {
- int /*long*/[] ppvObject = new int /*long*/[1];
- if (objIUnknown.QueryInterface(COM.IIDIOleInPlaceObject, ppvObject) == COM.S_OK) {
- IOleInPlaceObject objIOleInPlaceObject = new IOleInPlaceObject(ppvObject[0]);
- objIOleInPlaceObject.Release();
- doVerb(OLE.OLEIVERB_SHOW);
- }
- }
- if (objIOleInPlaceObject == null) return;
- if (isFocusControl()) return;
- int /*long*/[] phwnd = new int /*long*/[1];
- objIOleInPlaceObject.GetWindow(phwnd);
- if (phwnd[0] == 0) return;
- OS.SetFocus(phwnd[0]);
-}
-void onFocusOut(Event e) {
-}
-private int OnInPlaceActivate() {
- state = STATE_INPLACEACTIVE;
- frame.setCurrentDocument(this);
- if (objIOleObject == null)
- return COM.S_OK;
- int /*long*/[] ppvObject = new int /*long*/[1];
- if (objIOleObject.QueryInterface(COM.IIDIOleInPlaceObject, ppvObject) == COM.S_OK) {
- objIOleInPlaceObject = new IOleInPlaceObject(ppvObject[0]);
- }
- return COM.S_OK;
-}
-private int OnInPlaceDeactivate() {
- if (objIOleInPlaceObject != null) objIOleInPlaceObject.Release();
- objIOleInPlaceObject = null;
- state = STATE_RUNNING;
- redraw();
- Shell shell = getShell();
- if (isFocusControl() || frame.isFocusControl()) {
- shell.traverse(SWT.TRAVERSE_TAB_NEXT);
- }
- return COM.S_OK;
-}
-private int OnPosRectChange(int /*long*/ lprcPosRect) {
- Point size = getSize();
- setExtent(size.x, size.y);
- return COM.S_OK;
-}
-private void onPaint(Event e) {
- if (state == STATE_RUNNING || state == STATE_INPLACEACTIVE) {
- SIZE size = getExtent();
- Rectangle area = getClientArea();
- RECT rect = new RECT();
- if (getProgramID().startsWith("Excel.Sheet")) { //$NON-NLS-1$
- rect.left = area.x; rect.right = area.x + (area.height * size.cx / size.cy);
- rect.top = area.y; rect.bottom = area.y + area.height;
- } else {
- rect.left = area.x; rect.right = area.x + size.cx;
- rect.top = area.y; rect.bottom = area.y + size.cy;
- }
-
- int /*long*/ pArea = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, RECT.sizeof);
- OS.MoveMemory(pArea, rect, RECT.sizeof);
- COM.OleDraw(objIUnknown.getAddress(), aspect, e.gc.handle, pArea);
- OS.GlobalFree(pArea);
- }
-}
-private void onResize(Event e) {
- setBounds();
-}
-private void OnSave() {
-}
-private int OnShowWindow(int fShow) {
- return COM.S_OK;
-}
-private int OnUIActivate() {
- if (objIOleInPlaceObject == null) return COM.E_FAIL;
- state = STATE_UIACTIVE;
- int /*long*/[] phwnd = new int /*long*/[1];
- if (objIOleInPlaceObject.GetWindow(phwnd) == COM.S_OK) {
- OS.SetWindowPos(phwnd[0], OS.HWND_TOP, 0, 0, 0, 0, OS.SWP_NOSIZE | OS.SWP_NOMOVE);
- }
- return COM.S_OK;
-}
-int OnUIDeactivate(int fUndoable) {
- // currently, we are ignoring the fUndoable flag
- if (frame == null || frame.isDisposed()) return COM.S_OK;
- state = STATE_INPLACEACTIVE;
- frame.SetActiveObject(0,0);
- redraw();
- Shell shell = getShell();
- if (isFocusControl() || frame.isFocusControl()) {
- shell.traverse(SWT.TRAVERSE_TAB_NEXT);
- }
- Menu menubar = shell.getMenuBar();
- if (menubar == null || menubar.isDisposed())
- return COM.S_OK;
-
- int /*long*/ shellHandle = shell.handle;
- OS.SetMenu(shellHandle, menubar.handle);
- return COM.OleSetMenuDescriptor(0, shellHandle, 0, 0, 0);
-}
-private void onTraverse(Event event) {
- switch (event.detail) {
- case SWT.TRAVERSE_ESCAPE:
- case SWT.TRAVERSE_RETURN:
- case SWT.TRAVERSE_TAB_NEXT:
- case SWT.TRAVERSE_TAB_PREVIOUS:
- case SWT.TRAVERSE_PAGE_NEXT:
- case SWT.TRAVERSE_PAGE_PREVIOUS:
- case SWT.TRAVERSE_MNEMONIC:
- event.doit = true;
- break;
- }
-}
-private int OnViewChange(int dwAspect, int lindex) {
- return COM.S_OK;
-}
-protected int QueryInterface(int /*long*/ riid, int /*long*/ ppvObject) {
-
- if (riid == 0 || ppvObject == 0)
- return COM.E_NOINTERFACE;
- GUID guid = new GUID();
- COM.MoveMemory(guid, riid, GUID.sizeof);
-
- if (COM.IsEqualGUID(guid, COM.IIDIUnknown)) {
- COM.MoveMemory(ppvObject, new int /*long*/[] {iUnknown.getAddress()}, OS.PTR_SIZEOF);
- AddRef();
- return COM.S_OK;
- }
- if (COM.IsEqualGUID(guid, COM.IIDIAdviseSink)) {
- COM.MoveMemory(ppvObject, new int /*long*/[] {iAdviseSink.getAddress()}, OS.PTR_SIZEOF);
- AddRef();
- return COM.S_OK;
- }
- if (COM.IsEqualGUID(guid, COM.IIDIOleClientSite)) {
- COM.MoveMemory(ppvObject, new int /*long*/[] {iOleClientSite.getAddress()}, OS.PTR_SIZEOF);
- AddRef();
- return COM.S_OK;
- }
- if (COM.IsEqualGUID(guid, COM.IIDIOleInPlaceSite)) {
- COM.MoveMemory(ppvObject, new int /*long*/[] {iOleInPlaceSite.getAddress()}, OS.PTR_SIZEOF);
- AddRef();
- return COM.S_OK;
- }
- if (COM.IsEqualGUID(guid, COM.IIDIOleDocumentSite )) {
- String progID = getProgramID();
- if (!progID.startsWith("PowerPoint")) { //$NON-NLS-1$
- COM.MoveMemory(ppvObject, new int /*long*/[] {iOleDocumentSite.getAddress()}, OS.PTR_SIZEOF);
- AddRef();
- return COM.S_OK;
- }
- }
- COM.MoveMemory(ppvObject, new int /*long*/[] {0}, OS.PTR_SIZEOF);
- return COM.E_NOINTERFACE;
-}
-/**
- * Returns the status of the specified command. The status is any bitwise OR'd combination of
- * SWTOLE.OLECMDF_SUPPORTED, SWTOLE.OLECMDF_ENABLED, SWTOLE.OLECMDF_LATCHED, SWTOLE.OLECMDF_NINCHED.
- * You can query the status of a command before invoking it with OleClientSite.exec. The
- * OLE Document or ActiveX Control must support the IOleCommandTarget to make use of this method.
- *
- * @param cmd the ID of a command; these are the OLE.OLECMDID_ values - a small set of common
- * commands
- *
- * @return the status of the specified command or 0 if unable to query the OLE Object; these are the
- * OLE.OLECMDF_ values
- */
-public int queryStatus(int cmd) {
-
- if (objIOleCommandTarget == null) {
- int /*long*/[] address = new int /*long*/[1];
- if (objIUnknown.QueryInterface(COM.IIDIOleCommandTarget, address) != COM.S_OK)
- return 0;
- objIOleCommandTarget = new IOleCommandTarget(address[0]);
- }
-
- OLECMD olecmd = new OLECMD();
- olecmd.cmdID = cmd;
-
- int result = objIOleCommandTarget.QueryStatus(null, 1, olecmd, null);
-
- if (result != COM.S_OK) return 0;
-
- return olecmd.cmdf;
-}
-protected int Release() {
- refCount--;
-
- if (refCount == 0) {
- disposeCOMInterfaces();
- }
- return refCount;
-}
-protected void releaseObjectInterfaces() {
-
- if (objIOleInPlaceObject!= null)
- objIOleInPlaceObject.Release();
- objIOleInPlaceObject = null;
-
- if (objIOleObject != null) {
- objIOleObject.Close(COM.OLECLOSE_NOSAVE);
- objIOleObject.Release();
- }
- objIOleObject = null;
-
- if (objDocumentView != null){
- objDocumentView.Release();
- }
- objDocumentView = null;
-
- if (objIViewObject2 != null) {
- objIViewObject2.SetAdvise(aspect, 0, 0);
- objIViewObject2.Release();
- }
- objIViewObject2 = null;
-
- if (objIOleCommandTarget != null)
- objIOleCommandTarget.Release();
- objIOleCommandTarget = null;
-
- if (objIUnknown != null){
- objIUnknown.Release();
- }
- objIUnknown = null;
-
- COM.CoFreeUnusedLibraries();
-}
-/**
- * Saves the document to the specified file and includes OLE specific information if specified.
- * This method must <b>only</b> be used for files that have an OLE Storage format. For example,
- * a word file edited with Word.Document should be saved using this method because there is
- * formating information that should be stored in the OLE specific Storage format.
- *
- * @param file the file to which the changes are to be saved
- * @param includeOleInfo the flag to indicate whether OLE specific information should be saved.
- *
- * @return true if the save was successful
- */
-public boolean save(File file, boolean includeOleInfo) {
- if (includeOleInfo)
- return saveToStorageFile(file);
- return saveToTraditionalFile(file);
-}
-private boolean saveFromContents(int /*long*/ address, File file) {
-
- boolean success = false;
-
- IStream tempContents = new IStream(address);
- tempContents.AddRef();
-
- try {
- FileOutputStream writer = new FileOutputStream(file);
-
- int increment = 1024 * 4;
- int /*long*/ pv = COM.CoTaskMemAlloc(increment);
- int[] pcbWritten = new int[1];
- while (tempContents.Read(pv, increment, pcbWritten) == COM.S_OK && pcbWritten[0] > 0) {
- byte[] buffer = new byte[ pcbWritten[0]];
- OS.MoveMemory(buffer, pv, pcbWritten[0]);
- writer.write(buffer); // Note: if file does not exist, this will create the file the
- // first time it is called
- success = true;
- }
- COM.CoTaskMemFree(pv);
-
- writer.close();
-
- } catch (IOException err) {
- }
-
- tempContents.Release();
-
- return success;
-}
-private boolean saveFromOle10Native(int /*long*/ address, File file) {
-
- boolean success = false;
-
- IStream tempContents = new IStream(address);
- tempContents.AddRef();
-
- // The "\1Ole10Native" stream contains a DWORD header whose value is the length
- // of the native data that follows.
- int /*long*/ pv = COM.CoTaskMemAlloc(4);
- int[] size = new int[1];
- int rc = tempContents.Read(pv, 4, null);
- OS.MoveMemory(size, pv, 4);
- COM.CoTaskMemFree(pv);
- if (rc == COM.S_OK && size[0] > 0) {
-
- // Read the data
- byte[] buffer = new byte[size[0]];
- pv = COM.CoTaskMemAlloc(size[0]);
- rc = tempContents.Read(pv, size[0], null);
- OS.MoveMemory(buffer, pv, size[0]);
- COM.CoTaskMemFree(pv);
-
- // open the file and write data into it
- try {
- FileOutputStream writer = new FileOutputStream(file);
- writer.write(buffer); // Note: if file does not exist, this will create the file
- writer.close();
-
- success = true;
- } catch (IOException err) {
- }
- }
- tempContents.Release();
-
- return success;
-}
-private int SaveObject() {
-
- updateStorage();
-
- return COM.S_OK;
-}
-/**
- * Saves the document to the specified file and includes OLE specific information. This method
- * must <b>only</b> be used for files that have an OLE Storage format. For example, a word file
- * edited with Word.Document should be saved using this method because there is formating information
- * that should be stored in the OLE specific Storage format.
- *
- * @param file the file to which the changes are to be saved
- *
- * @return true if the save was successful
- */
-private boolean saveToStorageFile(File file) {
- // The file will be saved using the formating of the current application - this
- // may not be the format of the application that was originally used to create the file
- // e.g. if an Excel file is opened in Word, the Word application will save the file in the
- // Word format
- // Note: if the file already exists, some applications will not overwrite the file
- // In these cases, you should delete the file first (probably save the contents of the file in case the
- // save fails)
- if (file == null || file.isDirectory()) return false;
- if (!updateStorage()) return false;
-
- int /*long*/[] address = new int /*long*/[1];
- if (objIOleObject.QueryInterface(COM.IIDIPersistFile, address) == COM.S_OK) {
- String fileName = null;
- IPersistFile persistFile = new IPersistFile(address[0]);
- int /*long*/[] ppszFileName = new int /*long*/[1];
- if (persistFile.GetCurFile(ppszFileName) == COM.S_OK) {
- int /*long*/ pszFileName = ppszFileName [0];
- int length = OS.wcslen(pszFileName);
- char[] buffer = new char[length];
- OS.MoveMemory(buffer, pszFileName, length * 2);
- fileName = new String(buffer, 0, length);
- // Doc says to use IMalloc::Free, but CoTaskMemFree() does the same
- COM.CoTaskMemFree(pszFileName);
- }
- int result;
- String newFile = file.getAbsolutePath();
- if (fileName != null && fileName.equalsIgnoreCase(newFile)) {
- result = persistFile.Save(0, false);
- } else {
- int length = newFile.length();
- char[] buffer = new char[length + 1];
- newFile.getChars(0, length, buffer, 0);
- int /*long*/ lpszNewFile = COM.CoTaskMemAlloc(buffer.length * 2);
- COM.MoveMemory(lpszNewFile, buffer, buffer.length * 2);
- result = persistFile.Save(lpszNewFile, false);
- COM.CoTaskMemFree(lpszNewFile);
- }
- persistFile.Release();
- if (result == COM.S_OK) return true;
- }
-
- // get access to the persistent storage mechanism
- if (objIOleObject.QueryInterface(COM.IIDIPersistStorage, address) != COM.S_OK) return false;
- IPersistStorage permStorage = new IPersistStorage(address[0]);
- try {
- address = new int /*long*/[1];
- char[] path = (file.getAbsolutePath()+"\0").toCharArray();
- int mode = COM.STGM_TRANSACTED | COM.STGM_READWRITE | COM.STGM_SHARE_EXCLUSIVE | COM.STGM_CREATE;
- int result = COM.StgCreateDocfile(path, mode, 0, address); //Does an AddRef if successful
- if (result != COM.S_OK) return false;
- IStorage storage = new IStorage(address[0]);
- try {
- if (COM.OleSave(permStorage.getAddress(), storage.getAddress(), false) == COM.S_OK) {
- if (storage.Commit(COM.STGC_DEFAULT) == COM.S_OK) {
- return true;
- }
- }
- } finally {
- storage.Release();
- }
- } finally {
- permStorage.Release();
- }
- return false;
-}
-/**
- * Saves the document to the specified file. This method must be used for
- * files that do not have an OLE Storage format. For example, a bitmap file edited with MSPaint
- * should be saved using this method because bitmap is a standard format that does not include any
- * OLE specific data.
- *
- * @param file the file to which the changes are to be saved
- *
- * @return true if the save was successful
- */
-private boolean saveToTraditionalFile(File file) {
- // Note: if the file already exists, some applications will not overwrite the file
- // In these cases, you should delete the file first (probably save the contents of the file in case the
- // save fails)
- if (file == null || file.isDirectory())
- return false;
- if (!updateStorage())
- return false;
-
- /*
- * Bug in Office 2007. Saving Office 2007 documents to compound file storage object
- * causes the output file to be corrupted. The fix is to detect Office 2007 documents
- * using the program ID and save only the content of the 'Package' stream.
- */
- if (isOffice2007()) {
- /* Excel fails to open the package stream when the PersistStorage is not in hands off mode */
- int /*long*/[] ppv = new int /*long*/[1];
- IPersistStorage iPersistStorage = null;
- if (objIUnknown.QueryInterface(COM.IIDIPersistStorage, ppv) == COM.S_OK) {
- iPersistStorage = new IPersistStorage(ppv[0]);
- tempStorage.AddRef();
- iPersistStorage.HandsOffStorage();
- }
- boolean result = false;
- int /*long*/[] address = new int /*long*/[1];
- int grfMode = COM.STGM_DIRECT | COM.STGM_READ | COM.STGM_SHARE_EXCLUSIVE;
- if (tempStorage.OpenStream("Package", 0, grfMode, 0, address) == COM.S_OK) { //$NON-NLS-1$
- result = saveFromContents(address[0], file);
- }
- if (iPersistStorage != null) {
- iPersistStorage.SaveCompleted(tempStorage.getAddress());
- tempStorage.Release();
- iPersistStorage.Release();
- }
- return result;
- }
-
- int /*long*/[] address = new int /*long*/[1];
- // Look for a CONTENTS stream
- if (tempStorage.OpenStream("CONTENTS", 0, COM.STGM_DIRECT | COM.STGM_READ | COM.STGM_SHARE_EXCLUSIVE, 0, address) == COM.S_OK) //$NON-NLS-1$
- return saveFromContents(address[0], file);
-
- // Look for Ole 1.0 object stream
- if (tempStorage.OpenStream("\1Ole10Native", 0, COM.STGM_DIRECT | COM.STGM_READ | COM.STGM_SHARE_EXCLUSIVE, 0, address) == COM.S_OK) //$NON-NLS-1$
- return saveFromOle10Native(address[0], file);
-
- return false;
-}
-private int Scroll_64(int /*long*/ scrollExtent) {
- return COM.S_OK;
-}
-private int Scroll(int scrollExtent_cx, int scrollExtent_cy) {
- return COM.S_OK;
-}
-void setBorderSpace(RECT newBorderwidth) {
- borderWidths = newBorderwidth;
- // readjust size and location of client site
- setBounds();
-}
-void setBounds() {
- Rectangle area = frame.getClientArea();
- setBounds(borderWidths.left,
- borderWidths.top,
- area.width - borderWidths.left - borderWidths.right,
- area.height - borderWidths.top - borderWidths.bottom);
- setObjectRects();
-}
-private void setExtent(int width, int height){
- // Resize the width and height of the embedded/linked OLENatives object
- // to the specified values.
-
- if (objIOleObject == null || isStatic || inUpdate) return;
- SIZE currentExtent = getExtent();
- if (width == currentExtent.cx && height == currentExtent.cy) return;
-
- SIZE newExtent = new SIZE();
- newExtent.cx = width; newExtent.cy = height;
- newExtent = xFormPixelsToHimetric(newExtent);
-
- // Get the server running first, then do a SetExtent, then show it
- boolean alreadyRunning = COM.OleIsRunning(objIOleObject.getAddress());
- if (!alreadyRunning)
- COM.OleRun(objIOleObject.getAddress());
-
- if (objIOleObject.SetExtent(aspect, newExtent) == COM.S_OK){
- inUpdate = true;
- objIOleObject.Update();
- inUpdate = false;
- if (!alreadyRunning)
- // Close server if it wasn't already running upon entering this method.
- objIOleObject.Close(COM.OLECLOSE_SAVEIFDIRTY);
- }
-}
-/**
- * The indent value is no longer being used by the client site.
- *
- * @param newIndent the rectangle representing the indent amount
- */
-public void setIndent(Rectangle newIndent) {
- indent = new RECT();
- indent.left = newIndent.x;
- indent.right = newIndent.width;
- indent.top = newIndent.y;
- indent.bottom = newIndent.height;
-}
-private void setObjectRects() {
- if (objIOleInPlaceObject == null) return;
- // size the object to fill the available space
- // leave a border
- RECT rect = getRect();
- objIOleInPlaceObject.SetObjectRects(rect, rect);
-}
-
-private int ShowObject() {
- /* Tells the container to position the object so it is visible to
- * the user. This method ensures that the container itself is
- * visible and not minimized.
- */
- setBounds();
- return COM.S_OK;
-}
-/**
- * Displays a dialog with the property information for this OLE Object. The OLE Document or
- * ActiveX Control must support the ISpecifyPropertyPages interface.
- *
- * @param title the name that will appear in the titlebar of the dialog
- */
-public void showProperties(String title) {
-
- // Get the Property Page information from the OLE Object
- int /*long*/[] ppvObject = new int /*long*/[1];
- if (objIUnknown.QueryInterface(COM.IIDISpecifyPropertyPages, ppvObject) != COM.S_OK) return;
- ISpecifyPropertyPages objISPP = new ISpecifyPropertyPages(ppvObject[0]);
- CAUUID caGUID = new CAUUID();
- int result = objISPP.GetPages(caGUID);
- objISPP.Release();
- if (result != COM.S_OK) return;
-
- // create a frame in which to display the pages
- char[] chTitle = null;
- if (title != null) {
- chTitle = new char[title.length()];
- title.getChars(0, title.length(), chTitle, 0);
- }
- result = COM.OleCreatePropertyFrame(frame.handle, 10, 10, chTitle, 1, new int /*long*/[] {objIUnknown.getAddress()}, caGUID.cElems, caGUID.pElems, COM.LOCALE_USER_DEFAULT, 0, 0);
-
- // free the property page information
- COM.CoTaskMemFree(caGUID.pElems);
-}
-private boolean updateStorage() {
-
- if (tempStorage == null) return false;
-
- int /*long*/[] ppv = new int /*long*/[1];
- if (objIUnknown.QueryInterface(COM.IIDIPersistStorage, ppv) != COM.S_OK) return false;
- IPersistStorage iPersistStorage = new IPersistStorage(ppv[0]);
-
- int result = COM.OleSave(iPersistStorage.getAddress(), tempStorage.getAddress(), true);
-
- if (result != COM.S_OK){
- // OleSave will fail for static objects, so do what OleSave does.
- COM.WriteClassStg(tempStorage.getAddress(), objClsid);
- result = iPersistStorage.Save(tempStorage.getAddress(), true);
- }
-
- tempStorage.Commit(COM.STGC_DEFAULT);
- result = iPersistStorage.SaveCompleted(0);
- iPersistStorage.Release();
-
- return true;
-}
-private SIZE xFormHimetricToPixels(SIZE aSize) {
- // Return a new Size which is the pixel transformation of a
- // size in HIMETRIC units.
-
- int /*long*/ hDC = OS.GetDC(0);
- int xppi = OS.GetDeviceCaps(hDC, 88); // logical pixels/inch in x
- int yppi = OS.GetDeviceCaps(hDC, 90); // logical pixels/inch in y
- OS.ReleaseDC(0, hDC);
- int cx = Compatibility.round(aSize.cx * xppi, 2540); // 2540 HIMETRIC units per inch
- int cy = Compatibility.round(aSize.cy * yppi, 2540);
- SIZE size = new SIZE();
- size.cx = cx;
- size.cy = cy;
- return size;
-}
-private SIZE xFormPixelsToHimetric(SIZE aSize) {
- // Return a new size which is the HIMETRIC transformation of a
- // size in pixel units.
-
- int /*long*/ hDC = OS.GetDC(0);
- int xppi = OS.GetDeviceCaps(hDC, 88); // logical pixels/inch in x
- int yppi = OS.GetDeviceCaps(hDC, 90); // logical pixels/inch in y
- OS.ReleaseDC(0, hDC);
- int cx = Compatibility.round(aSize.cx * 2540, xppi); // 2540 HIMETRIC units per inch
- int cy = Compatibility.round(aSize.cy * 2540, yppi);
- SIZE size = new SIZE();
- size.cx = cx;
- size.cy = cy;
- return size;
-}
-}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleControlSite.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleControlSite.java
deleted file mode 100755
index 3290cdb0f3..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleControlSite.java
+++ /dev/null
@@ -1,982 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.ole.win32;
-
-import java.io.*;
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.internal.ole.win32.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.swt.internal.win32.*;
-
-/**
- * OleControlSite provides a site to manage an embedded ActiveX Control within a container.
- *
- * <p>In addition to the behaviour provided by OleClientSite, this object provides the following:
- * <ul>
- * <li>events from the ActiveX control
- * <li>notification of property changes from the ActiveX control
- * <li>simplified access to well known properties of the ActiveX Control (e.g. font, background color)
- * <li>expose ambient properties of the container to the ActiveX Control
- * </ul>
- *
- * <p>This object implements the OLE Interfaces IOleControlSite, IDispatch, and IPropertyNotifySink.
- *
- * <p>Note that although this class is a subclass of <code>Composite</code>,
- * it does not make sense to add <code>Control</code> children to it,
- * or set a layout on it.
- * </p><p>
- * <dl>
- * <dt><b>Styles</b> <dd>BORDER
- * <dt><b>Events</b> <dd>Dispose, Move, Resize
- * </dl>
- *
- * @see <a href="http://www.eclipse.org/swt/snippets/#ole">OLE and ActiveX snippets</a>
- * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Examples: OLEExample, OleWebBrowser</a>
- */
-public class OleControlSite extends OleClientSite
-{
- // interfaces for this container
- private COMObject iOleControlSite;
- private COMObject iDispatch;
-
- // supporting Property Change attributes
- private OlePropertyChangeSink olePropertyChangeSink;
-
- // supporting Event Sink attributes
- private OleEventSink[] oleEventSink = new OleEventSink[0];
- private GUID[] oleEventSinkGUID = new GUID[0];
- private int /*long*/[] oleEventSinkIUnknown = new int /*long*/[0];
-
- // supporting information for the Control COM object
- private CONTROLINFO currentControlInfo;
- private int[] sitePropertyIds = new int[0];
- private Variant[] sitePropertyValues = new Variant[0];
-
- private Font font;
-
-
-/**
- * Create an OleControlSite child widget using the OLE Document type associated with the
- * specified file. The OLE Document type is determined either through header information in the file
- * or through a Registry entry for the file extension. Use style bits to select a particular look
- * or set of properties.
- *
- * @param parent a composite widget; must be an OleFrame
- * @param style the bitwise OR'ing of widget styles
- * @param file the file that is to be opened in this OLE Document
- *
- * @exception IllegalArgumentException
- * <ul><li>ERROR_NULL_ARGUMENT when the parent is null
- * <li>ERROR_INVALID_ARGUMENT when the parent is not an OleFrame</ul>
- * @exception SWTException
- * <ul><li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
- * <li>ERROR_CANNOT_CREATE_OBJECT when failed to create OLE Object
- * <li>ERROR_CANNOT_OPEN_FILE when failed to open file
- * <li>ERROR_INTERFACE_NOT_FOUND when unable to create callbacks for OLE Interfaces
- * <li>ERROR_INVALID_CLASSID
- * </ul>
- *
- * @since 3.5
- */
-public OleControlSite(Composite parent, int style, File file) {
- super(parent, style, file);
-
- // Init site properties
- setSiteProperty(COM.DISPID_AMBIENT_USERMODE, new Variant(true));
- setSiteProperty(COM.DISPID_AMBIENT_UIDEAD, new Variant(false));
-}
-/**
- * Create an OleControlSite child widget using style bits
- * to select a particular look or set of properties.
- *
- * @param parent a composite widget; must be an OleFrame
- * @param style the bitwise OR'ing of widget styles
- * @param progId the unique program identifier which has been registered for this ActiveX Control;
- * the value of the ProgID key or the value of the VersionIndependentProgID key specified
- * in the registry for this Control (for example, the VersionIndependentProgID for
- * Internet Explorer is Shell.Explorer)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT when the parent is null
- *</ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
- * <li>ERROR_INVALID_CLASSID when the progId does not map to a registered CLSID
- * <li>ERROR_CANNOT_CREATE_OBJECT when failed to create OLE Object
- * <li>ERROR_CANNOT_ACCESS_CLASSFACTORY when Class Factory could not be found
- * <li>ERROR_CANNOT_CREATE_LICENSED_OBJECT when failed to create a licensed OLE Object
- * </ul>
- */
-public OleControlSite(Composite parent, int style, String progId) {
- super(parent, style);
- try {
-
- // check for licensing
- appClsid = getClassID(progId);
- if (appClsid == null) OLE.error(OLE.ERROR_INVALID_CLASSID);
-
- int /*long*/ licinfo = getLicenseInfo(appClsid);
- if (licinfo == 0) {
-
- // Open a storage object
- tempStorage = createTempStorage();
-
- // Create ole object with storage object
- int /*long*/[] address = new int /*long*/[1];
- int result = COM.OleCreate(appClsid, COM.IIDIUnknown, COM.OLERENDER_DRAW, null, iOleClientSite.getAddress(), tempStorage.getAddress(), address);
- if (result != COM.S_OK)
- OLE.error(OLE.ERROR_CANNOT_CREATE_OBJECT, result);
-
- objIUnknown = new IUnknown(address[0]);
-
- } else {
- // Prepare the ClassFactory
- int /*long*/[] ppvObject = new int /*long*/[1];
- try {
- int result = COM.CoGetClassObject(appClsid, COM.CLSCTX_INPROC_HANDLER | COM.CLSCTX_INPROC_SERVER, 0, COM.IIDIClassFactory2, ppvObject);
- if (result != COM.S_OK) {
- OLE.error(OLE.ERROR_CANNOT_ACCESS_CLASSFACTORY, result);
- }
- IClassFactory2 classFactory = new IClassFactory2(ppvObject[0]);
- // Create Com Object
- ppvObject = new int /*long*/[1];
- result = classFactory.CreateInstanceLic(0, 0, COM.IIDIUnknown, licinfo, ppvObject);
- classFactory.Release();
- if (result != COM.S_OK)
- OLE.error(OLE.ERROR_CANNOT_CREATE_LICENSED_OBJECT, result);
- } finally {
- COM.SysFreeString(licinfo);
- }
-
- objIUnknown = new IUnknown(ppvObject[0]);
-
- // Prepare a storage medium
- ppvObject = new int /*long*/[1];
- if (objIUnknown.QueryInterface(COM.IIDIPersistStorage, ppvObject) == COM.S_OK) {
- IPersistStorage persist = new IPersistStorage(ppvObject[0]);
- tempStorage = createTempStorage();
- persist.InitNew(tempStorage.getAddress());
- persist.Release();
- }
- }
-
- // Init sinks
- addObjectReferences();
-
- // Init site properties
- setSiteProperty(COM.DISPID_AMBIENT_USERMODE, new Variant(true));
- setSiteProperty(COM.DISPID_AMBIENT_UIDEAD, new Variant(false));
-
- if (COM.OleRun(objIUnknown.getAddress()) == OLE.S_OK) state= STATE_RUNNING;
-
- } catch (SWTError e) {
- dispose();
- disposeCOMInterfaces();
- throw e;
- }
-}
-/**
- * Create an OleClientSite child widget to edit the specified file using the specified OLE Document
- * application. Use style bits to select a particular look or set of properties.
- * <p>
- * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
- * API for <code>OleClientSite</code>. It is marked public only so that it
- * can be shared within the packages provided by SWT. It is not
- * available on all platforms, and should never be called from
- * application code.
- * </p>
- * @param parent a composite widget; must be an OleFrame
- * @param style the bitwise OR'ing of widget styles
- * @param progId the unique program identifier of am OLE Document application;
- * the value of the ProgID key or the value of the VersionIndependentProgID key specified
- * in the registry for the desired OLE Document (for example, the VersionIndependentProgID
- * for Word is Word.Document)
- * @param file the file that is to be opened in this OLE Document
- *
- * @exception IllegalArgumentException
- * <ul><li>ERROR_NULL_ARGUMENT when the parent is null
- * <li>ERROR_INVALID_ARGUMENT when the parent is not an OleFrame</ul>
- * @exception SWTException
- * <ul><li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
- * <li>ERROR_INVALID_CLASSID when the progId does not map to a registered CLSID
- * <li>ERROR_CANNOT_CREATE_OBJECT when failed to create OLE Object
- * <li>ERROR_CANNOT_OPEN_FILE when failed to open file
- * </ul>
- *
- * @since 3.5
- */
-public OleControlSite(Composite parent, int style, String progId, File file) {
- super(parent, style, progId, file);
-
- // Init site properties
- setSiteProperty(COM.DISPID_AMBIENT_USERMODE, new Variant(true));
- setSiteProperty(COM.DISPID_AMBIENT_UIDEAD, new Variant(false));
-}
-/**
- * Adds the listener to receive events.
- *
- * @param eventID the id of the event
- *
- * @param listener the listener
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT when listener is null</li>
- * </ul>
- */
-public void addEventListener(int eventID, OleListener listener) {
- if (listener == null) OLE.error (SWT.ERROR_NULL_ARGUMENT);
- GUID riid = getDefaultEventSinkGUID(objIUnknown);
- if (riid != null) {
- addEventListener(objIUnknown.getAddress(), riid, eventID, listener);
- }
-
-}
-static GUID getDefaultEventSinkGUID(IUnknown unknown) {
- // get Event Sink I/F from IProvideClassInfo2
- int /*long*/[] ppvObject = new int /*long*/[1];
- if (unknown.QueryInterface(COM.IIDIProvideClassInfo2, ppvObject) == COM.S_OK) {
- IProvideClassInfo2 pci2 = new IProvideClassInfo2(ppvObject[0]);
- GUID riid = new GUID();
- int result = pci2.GetGUID(COM.GUIDKIND_DEFAULT_SOURCE_DISP_IID, riid);
- pci2.Release();
- if (result == COM.S_OK) return riid;
- }
-
- // get Event Sink I/F from IProvideClassInfo
- if (unknown.QueryInterface(COM.IIDIProvideClassInfo, ppvObject) == COM.S_OK) {
- IProvideClassInfo pci = new IProvideClassInfo(ppvObject[0]);
- int /*long*/[] ppTI = new int /*long*/[1];
- int /*long*/[] ppEI = new int /*long*/[1];
- int result = pci.GetClassInfo(ppTI);
- pci.Release();
-
- if (result == COM.S_OK && ppTI[0] != 0) {
- ITypeInfo classInfo = new ITypeInfo(ppTI[0]);
- int /*long*/[] ppTypeAttr = new int /*long*/[1];
- result = classInfo.GetTypeAttr(ppTypeAttr);
- if (result == COM.S_OK && ppTypeAttr[0] != 0) {
- TYPEATTR typeAttribute = new TYPEATTR();
- COM.MoveMemory(typeAttribute, ppTypeAttr[0], TYPEATTR.sizeof);
- classInfo.ReleaseTypeAttr(ppTypeAttr[0]);
- int implMask = COM.IMPLTYPEFLAG_FDEFAULT | COM.IMPLTYPEFLAG_FSOURCE | COM.IMPLTYPEFLAG_FRESTRICTED;
- int implBits = COM.IMPLTYPEFLAG_FDEFAULT | COM.IMPLTYPEFLAG_FSOURCE;
-
- for (int i = 0; i < typeAttribute.cImplTypes; i++) {
- int[] pImplTypeFlags = new int[1];
- if (classInfo.GetImplTypeFlags(i, pImplTypeFlags) == COM.S_OK) {
- if ((pImplTypeFlags[0] & implMask) == implBits) {
- int[] pRefType = new int[1];
- if (classInfo.GetRefTypeOfImplType(i, pRefType) == COM.S_OK) {
- classInfo.GetRefTypeInfo(pRefType[0], ppEI);
- }
- }
- }
- }
- }
- classInfo.Release();
-
- if (ppEI[0] != 0) {
- ITypeInfo eventInfo = new ITypeInfo(ppEI[0]);
- ppTypeAttr = new int /*long*/[1];
- result = eventInfo.GetTypeAttr(ppTypeAttr);
- GUID riid = null;
- if (result == COM.S_OK && ppTypeAttr[0] != 0) {
- riid = new GUID();
- COM.MoveMemory(riid, ppTypeAttr[0], GUID.sizeof);
- eventInfo.ReleaseTypeAttr(ppTypeAttr[0]);
- }
- eventInfo.Release();
- return riid;
- }
- }
- }
- return null;
-}
-
-/**
- * Adds the listener to receive events.
- *
- * @since 2.0
- *
- * @param automation the automation object that provides the event notification
- * @param eventID the id of the event
- * @param listener the listener
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT when listener is null</li>
- * </ul>
- */
-public void addEventListener(OleAutomation automation, int eventID, OleListener listener) {
- if (listener == null || automation == null) OLE.error (SWT.ERROR_NULL_ARGUMENT);
- int /*long*/ address = automation.getAddress();
- IUnknown unknown = new IUnknown(address);
- GUID riid = getDefaultEventSinkGUID(unknown);
- if (riid != null) {
- addEventListener(address, riid, eventID, listener);
- }
-
-}
-/**
- * Adds the listener to receive events.
- *
- * @since 3.2
- *
- * @param automation the automation object that provides the event notification
- * @param eventSinkId the GUID of the event sink
- * @param eventID the id of the event
- * @param listener the listener
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT when listener is null</li>
- * </ul>
- */
-public void addEventListener(OleAutomation automation, String eventSinkId, int eventID, OleListener listener) {
- if (listener == null || automation == null || eventSinkId == null) OLE.error (SWT.ERROR_NULL_ARGUMENT);
- int /*long*/ address = automation.getAddress();
- if (address == 0) return;
- char[] buffer = (eventSinkId +"\0").toCharArray();
- GUID guid = new GUID();
- if (COM.IIDFromString(buffer, guid) != COM.S_OK) return;
- addEventListener(address, guid, eventID, listener);
-}
-
-void addEventListener(int /*long*/ iunknown, GUID guid, int eventID, OleListener listener) {
- if (listener == null || iunknown == 0 || guid == null) OLE.error (SWT.ERROR_NULL_ARGUMENT);
- // have we connected to this kind of event sink before?
- int index = -1;
- for (int i = 0; i < oleEventSinkGUID.length; i++) {
- if (COM.IsEqualGUID(oleEventSinkGUID[i], guid)) {
- if (iunknown == oleEventSinkIUnknown[i]) {
- index = i;
- break;
- }
- }
- }
- if (index != -1) {
- oleEventSink[index].addListener(eventID, listener);
- } else {
- int oldLength = oleEventSink.length;
- OleEventSink[] newOleEventSink = new OleEventSink[oldLength + 1];
- GUID[] newOleEventSinkGUID = new GUID[oldLength + 1];
- int /*long*/[] newOleEventSinkIUnknown = new int /*long*/[oldLength + 1];
- System.arraycopy(oleEventSink, 0, newOleEventSink, 0, oldLength);
- System.arraycopy(oleEventSinkGUID, 0, newOleEventSinkGUID, 0, oldLength);
- System.arraycopy(oleEventSinkIUnknown, 0, newOleEventSinkIUnknown, 0, oldLength);
- oleEventSink = newOleEventSink;
- oleEventSinkGUID = newOleEventSinkGUID;
- oleEventSinkIUnknown = newOleEventSinkIUnknown;
-
- oleEventSink[oldLength] = new OleEventSink(this, iunknown, guid);
- oleEventSinkGUID[oldLength] = guid;
- oleEventSinkIUnknown[oldLength] = iunknown;
- oleEventSink[oldLength].AddRef();
- oleEventSink[oldLength].connect();
- oleEventSink[oldLength].addListener(eventID, listener);
-
- }
-}
-protected void addObjectReferences() {
-
- super.addObjectReferences();
-
- // Get property change notification from control
- connectPropertyChangeSink();
-
- // Get access to the Control object
- int /*long*/[] ppvObject = new int /*long*/[1];
- if (objIUnknown.QueryInterface(COM.IIDIOleControl, ppvObject) == COM.S_OK) {
- IOleControl objIOleControl = new IOleControl(ppvObject[0]);
- // ask the control for its info in case users
- // need to act on it
- currentControlInfo = new CONTROLINFO();
- objIOleControl.GetControlInfo(currentControlInfo);
- objIOleControl.Release();
- }
-}
-/**
- * Adds the listener to receive events.
- *
- * @param propertyID the identifier of the property
- * @param listener the listener
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT when listener is null</li>
- * </ul>
- */
-public void addPropertyListener(int propertyID, OleListener listener) {
- if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- olePropertyChangeSink.addListener(propertyID, listener);
-}
-
-private void connectPropertyChangeSink() {
- olePropertyChangeSink = new OlePropertyChangeSink(this);
- olePropertyChangeSink.AddRef();
- olePropertyChangeSink.connect(objIUnknown);
-}
-protected void createCOMInterfaces () {
- super.createCOMInterfaces();
-
- // register each of the interfaces that this object implements
- iOleControlSite = new COMObject(new int[]{2, 0, 0, 0, 1, 1, 3, 2, 1, 0}){
- public int /*long*/ method0(int /*long*/[] args) {return QueryInterface(args[0], args[1]);}
- public int /*long*/ method1(int /*long*/[] args) {return AddRef();}
- public int /*long*/ method2(int /*long*/[] args) {return Release();}
- public int /*long*/ method3(int /*long*/[] args) {return OnControlInfoChanged();}
- // method4 LockInPlaceActive - not implemented
- // method5 GetExtendedControl - not implemented
- // method6 TransformCoords - not implemented
- // method7 Translate Accelerator - not implemented
- public int /*long*/ method8(int /*long*/[] args) {return OnFocus((int)/*64*/args[0]);}
- // method9 ShowPropertyFrame - not implemented
- };
-
- iDispatch = new COMObject(new int[]{2, 0, 0, 1, 3, 5, 8}){
- public int /*long*/ method0(int /*long*/[] args) {return QueryInterface(args[0], args[1]);}
- public int /*long*/ method1(int /*long*/[] args) {return AddRef();}
- public int /*long*/ method2(int /*long*/[] args) {return Release();}
- // method3 GetTypeInfoCount - not implemented
- // method4 GetTypeInfo - not implemented
- // method5 GetIDsOfNames - not implemented
- public int /*long*/ method6(int /*long*/[] args) {return Invoke((int)/*64*/args[0], args[1], (int)/*64*/args[2], (int)/*64*/args[3], args[4], args[5], args[6], args[7]);}
- };
-}
-private void disconnectEventSinks() {
-
- for (int i = 0; i < oleEventSink.length; i++) {
- OleEventSink sink = oleEventSink[i];
- sink.disconnect();
- sink.Release();
- }
- oleEventSink = new OleEventSink[0];
- oleEventSinkGUID = new GUID[0];
- oleEventSinkIUnknown = new int /*long*/[0];
-}
-private void disconnectPropertyChangeSink() {
-
- if (olePropertyChangeSink != null) {
- olePropertyChangeSink.disconnect(objIUnknown);
- olePropertyChangeSink.Release();
- }
- olePropertyChangeSink = null;
-}
-protected void disposeCOMInterfaces() {
- super.disposeCOMInterfaces();
-
- if (iOleControlSite != null)
- iOleControlSite.dispose();
- iOleControlSite = null;
-
- if (iDispatch != null)
- iDispatch.dispose();
- iDispatch = null;
-}
-public Color getBackground () {
-
- if (objIUnknown != null) {
- // !! We are getting the OLE_COLOR - should we change this to the COLORREF value?
- OleAutomation oleObject= new OleAutomation(this);
- Variant varBackColor = oleObject.getProperty(COM.DISPID_BACKCOLOR);
- oleObject.dispose();
-
- if (varBackColor != null){
- int[] colorRef = new int[1];
- if (COM.OleTranslateColor(varBackColor.getInt(), getDisplay().hPalette, colorRef) == COM.S_OK)
- return Color.win32_new(getDisplay(), colorRef[0]);
- }
- }
-
- return super.getBackground();
-}
-public Font getFont () {
- if (font != null && !font.isDisposed()) return font;
- if (objIUnknown != null) {
- OleAutomation oleObject= new OleAutomation(this);
- Variant varDispFont = oleObject.getProperty(COM.DISPID_FONT);
- oleObject.dispose();
-
- if (varDispFont != null){
- OleAutomation iDispFont = varDispFont.getAutomation();
- Variant lfFaceName = iDispFont.getProperty(COM.DISPID_FONT_NAME);
- Variant lfHeight = iDispFont.getProperty(COM.DISPID_FONT_SIZE);
- Variant lfItalic = iDispFont.getProperty(COM.DISPID_FONT_ITALIC);
- //Variant lfCharSet = iDispFont.getProperty(COM.DISPID_FONT_CHARSET);
- Variant lfBold = iDispFont.getProperty(COM.DISPID_FONT_BOLD);
- iDispFont.dispose();
-
- if (lfFaceName != null &&
- lfHeight != null &&
- lfItalic != null &&
- lfBold != null){
- int style = 3 * lfBold.getInt() + 2 * lfItalic.getInt();
- font = new Font(getShell().getDisplay(), lfFaceName.getString(), lfHeight.getInt(), style);
- return font;
- }
- }
- }
-
- return super.getFont();
-}
-public Color getForeground () {
-
- if (objIUnknown != null) {
- // !! We are getting the OLE_COLOR - should we change this to the COLORREF value?
- OleAutomation oleObject= new OleAutomation(this);
- Variant varForeColor = oleObject.getProperty(COM.DISPID_FORECOLOR);
- oleObject.dispose();
-
- if (varForeColor != null){
- int[] colorRef = new int[1];
- if (COM.OleTranslateColor(varForeColor.getInt(), getDisplay().hPalette, colorRef) == COM.S_OK)
- return Color.win32_new(getDisplay(), colorRef[0]);
- }
- }
-
- return super.getForeground();
-}
-protected int /*long*/ getLicenseInfo(GUID clsid) {
- int /*long*/[] ppvObject = new int /*long*/[1];
- if (COM.CoGetClassObject(clsid, COM.CLSCTX_INPROC_HANDLER
- | COM.CLSCTX_INPROC_SERVER, 0, COM.IIDIClassFactory, ppvObject) != COM.S_OK) {
- return 0;
- }
- int /*long*/ result = 0;
- IUnknown unknown = new IUnknown(ppvObject[0]);
- if (unknown.QueryInterface(COM.IIDIClassFactory2, ppvObject) == COM.S_OK) {
- IClassFactory2 classFactory = new IClassFactory2(ppvObject[0]);
- LICINFO licinfo = new LICINFO();
- if (classFactory.GetLicInfo(licinfo) == COM.S_OK) {
- int /*long*/[] pBstrKey = new int /*long*/[1];
- if (licinfo != null && licinfo.fRuntimeKeyAvail) {
- if (classFactory.RequestLicKey(0, pBstrKey) == COM.S_OK) {
- result = pBstrKey[0];
- }
- }
- }
- classFactory.Release();
- }
- unknown.Release();
- return result;
-}
-/**
- *
- * Get the control site property specified by the dispIdMember, or
- * <code>null</code> if the dispId is not recognised.
- *
- * @param dispId the dispId
- *
- * @return the property value or <code>null</code>
- *
- * @since 2.1
- */
-public Variant getSiteProperty(int dispId){
- for (int i = 0; i < sitePropertyIds.length; i++) {
- if (sitePropertyIds[i] == dispId) {
- return sitePropertyValues[i];
- }
- }
- return null;
-}
-protected int GetWindow(int /*long*/ phwnd) {
-
- if (phwnd == 0)
- return COM.E_INVALIDARG;
- if (frame == null) {
- COM.MoveMemory(phwnd, new int /*long*/[] {0}, OS.PTR_SIZEOF);
- return COM.E_NOTIMPL;
- }
-
- // Copy the Window's handle into the memory passed in
- COM.MoveMemory(phwnd, new int /*long*/[] {handle}, OS.PTR_SIZEOF);
- return COM.S_OK;
-}
-private int Invoke(int dispIdMember, int /*long*/ riid, int lcid, int dwFlags, int /*long*/ pDispParams, int /*long*/ pVarResult, int /*long*/ pExcepInfo, int /*long*/ pArgErr) {
- if (pVarResult == 0 || dwFlags != COM.DISPATCH_PROPERTYGET) {
- if (pExcepInfo != 0) COM.MoveMemory(pExcepInfo, new int /*long*/ [] {0}, OS.PTR_SIZEOF);
- if (pArgErr != 0) COM.MoveMemory(pArgErr, new int[] {0}, 4);
- return COM.DISP_E_MEMBERNOTFOUND;
- }
- Variant result = getSiteProperty(dispIdMember);
- if (result != null) {
- if (pVarResult != 0) result.getData(pVarResult);
- return COM.S_OK;
- }
- switch (dispIdMember) {
- // indicate a false result
- case COM.DISPID_AMBIENT_SUPPORTSMNEMONICS :
- case COM.DISPID_AMBIENT_SHOWGRABHANDLES :
- case COM.DISPID_AMBIENT_SHOWHATCHING :
- if (pVarResult != 0) COM.MoveMemory(pVarResult, new int /*long*/ [] {0}, OS.PTR_SIZEOF);
- if (pExcepInfo != 0) COM.MoveMemory(pExcepInfo, new int /*long*/ [] {0}, OS.PTR_SIZEOF);
- if (pArgErr != 0) COM.MoveMemory(pArgErr, new int[] {0}, 4);
- return COM.S_FALSE;
-
- // not implemented
- case COM.DISPID_AMBIENT_OFFLINEIFNOTCONNECTED :
- case COM.DISPID_AMBIENT_BACKCOLOR :
- case COM.DISPID_AMBIENT_FORECOLOR :
- case COM.DISPID_AMBIENT_FONT :
- case COM.DISPID_AMBIENT_LOCALEID :
- case COM.DISPID_AMBIENT_SILENT :
- case COM.DISPID_AMBIENT_MESSAGEREFLECT :
- if (pVarResult != 0) COM.MoveMemory(pVarResult, new int /*long*/ [] {0}, OS.PTR_SIZEOF);
- if (pExcepInfo != 0) COM.MoveMemory(pExcepInfo, new int /*long*/ [] {0}, OS.PTR_SIZEOF);
- if (pArgErr != 0) COM.MoveMemory(pArgErr, new int[] {0}, 4);
- return COM.E_NOTIMPL;
-
- default :
- if (pVarResult != 0) COM.MoveMemory(pVarResult, new int /*long*/ [] {0}, OS.PTR_SIZEOF);
- if (pExcepInfo != 0) COM.MoveMemory(pExcepInfo,new int /*long*/ [] {0}, OS.PTR_SIZEOF);
- if (pArgErr != 0) COM.MoveMemory(pArgErr, new int[] {0}, 4);
- return COM.DISP_E_MEMBERNOTFOUND;
- }
-}
-private int OnControlInfoChanged() {
- int /*long*/[] ppvObject = new int /*long*/[1];
- if (objIUnknown.QueryInterface(COM.IIDIOleControl, ppvObject) == COM.S_OK) {
- IOleControl objIOleControl = new IOleControl(ppvObject[0]);
- // ask the control for its info in case users
- // need to act on it
- currentControlInfo = new CONTROLINFO();
- objIOleControl.GetControlInfo(currentControlInfo);
- objIOleControl.Release();
- }
- return COM.S_OK;
-}
-
-// The following is intentionally commented, it's not believed that
-// OLEIVERB_UIACTIVATE and UIDeactivate should be invoked for every
-// received focusIn and focusOut, respectively.
-//
-//void onFocusIn(Event e) {
-// String progID = getProgramID();
-// if (progID == null) return;
-// if (!progID.startsWith("Shell.Explorer")) {
-// super.onFocusIn(e);
-// return;
-// }
-// if (objIOleInPlaceObject == null) return;
-// doVerb(OLE.OLEIVERB_UIACTIVATE);
-// if (isFocusControl()) return;
-// int /*long*/[] phwnd = new int /*long*/[1];
-// objIOleInPlaceObject.GetWindow(phwnd);
-// if (phwnd[0] == 0) return;
-// OS.SetFocus(phwnd[0]);
-//}
-//void onFocusOut(Event e) {
-// if (objIOleInPlaceObject == null) return;
-// String progID = getProgramID();
-// if (progID == null) return;
-// if (!progID.startsWith("Shell.Explorer")) {
-// super.onFocusOut(e);
-// return;
-// }
-// /*
-// * Bug in Windows. When IE7 loses focus and UIDeactivate()
-// * is called, IE destroys the caret even though it is
-// * no longer owned by IE. If focus has moved to a control
-// * that shows a caret then the caret disappears. The fix
-// * is to detect this case and restore the caret.
-// */
-// int threadId = OS.GetCurrentThreadId();
-// GUITHREADINFO lpgui1 = new GUITHREADINFO();
-// lpgui1.cbSize = GUITHREADINFO.sizeof;
-// OS.GetGUIThreadInfo(threadId, lpgui1);
-// objIOleInPlaceObject.UIDeactivate();
-// if (lpgui1.hwndCaret != 0) {
-// GUITHREADINFO lpgui2 = new GUITHREADINFO();
-// lpgui2.cbSize = GUITHREADINFO.sizeof;
-// OS.GetGUIThreadInfo(threadId, lpgui2);
-// if (lpgui2.hwndCaret == 0 && lpgui1.hwndCaret == OS.GetFocus()) {
-// if (SWT_RESTORECARET == 0) {
-// SWT_RESTORECARET = OS.RegisterWindowMessage (new TCHAR (0, "SWT_RESTORECARET", true));
-// }
-// /*
-// * If the caret was not restored by SWT, put it back using
-// * the information from GUITHREADINFO. Note that this will
-// * not be correct when the caret has a bitmap. There is no
-// * API to query the bitmap that the caret is using.
-// */
-// if (OS.SendMessage (lpgui1.hwndCaret, SWT_RESTORECARET, 0, 0) == 0) {
-// int width = lpgui1.right - lpgui1.left;
-// int height = lpgui1.bottom - lpgui1.top;
-// OS.CreateCaret (lpgui1.hwndCaret, 0, width, height);
-// OS.SetCaretPos (lpgui1.left, lpgui1.top);
-// OS.ShowCaret (lpgui1.hwndCaret);
-// }
-// }
-// }
-//}
-
-private int OnFocus(int fGotFocus) {
- return COM.S_OK;
-}
-protected int OnUIDeactivate(int fUndoable) {
- // controls don't need to do anything for
- // border space or menubars
- if (frame == null || frame.isDisposed()) return COM.S_OK;
- state = STATE_INPLACEACTIVE;
- frame.SetActiveObject(0,0);
- redraw();
- Shell shell = getShell();
- if (isFocusControl() || frame.isFocusControl()) {
- shell.traverse(SWT.TRAVERSE_TAB_NEXT);
- }
- return COM.S_OK;
-}
-protected int QueryInterface(int /*long*/ riid, int /*long*/ ppvObject) {
- int result = super.QueryInterface(riid, ppvObject);
- if (result == COM.S_OK)
- return result;
- if (riid == 0 || ppvObject == 0)
- return COM.E_INVALIDARG;
- GUID guid = new GUID();
- COM.MoveMemory(guid, riid, GUID.sizeof);
- if (COM.IsEqualGUID(guid, COM.IIDIOleControlSite)) {
- COM.MoveMemory(ppvObject, new int /*long*/[] {iOleControlSite.getAddress()}, OS.PTR_SIZEOF);
- AddRef();
- return COM.S_OK;
- }
- if (COM.IsEqualGUID(guid, COM.IIDIDispatch)) {
- COM.MoveMemory(ppvObject, new int /*long*/[] {iDispatch.getAddress()}, OS.PTR_SIZEOF);
- AddRef();
- return COM.S_OK;
- }
- COM.MoveMemory(ppvObject, new int /*long*/[] {0}, OS.PTR_SIZEOF);
- return COM.E_NOINTERFACE;
-}
-protected int Release() {
- int result = super.Release();
- if (result == 0) {
- for (int i = 0; i < sitePropertyIds.length; i++) {
- sitePropertyValues[i].dispose();
- }
- sitePropertyIds = new int[0];
- sitePropertyValues = new Variant[0];
- }
- return result;
-}
-protected void releaseObjectInterfaces() {
-
- disconnectEventSinks();
-
- disconnectPropertyChangeSink();
-
- super.releaseObjectInterfaces();
-}
-/**
- * Removes the listener.
- *
- * @param eventID the event identifier
- *
- * @param listener the listener which should no longer be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT when listener is null</li>
- * </ul>
- */
-public void removeEventListener(int eventID, OleListener listener) {
- checkWidget();
- if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
-
- GUID riid = getDefaultEventSinkGUID(objIUnknown);
- if (riid != null) {
- removeEventListener(objIUnknown.getAddress(), riid, eventID, listener);
- }
-}
-/**
- * Removes the listener.
- *
- * @since 2.0
- * @deprecated - use OleControlSite.removeEventListener(OleAutomation, int, OleListener)
- *
- * @param automation the automation object that provides the event notification
- *
- * @param guid the identifier of the events COM interface
- *
- * @param eventID the event identifier
- *
- * @param listener the listener
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT when listener is null</li>
- * </ul>
- */
-public void removeEventListener(OleAutomation automation, GUID guid, int eventID, OleListener listener) {
- checkWidget();
- if (automation == null || listener == null || guid == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- removeEventListener(automation.getAddress(), guid, eventID, listener);
-}
-/**
- * Removes the listener.
- *
- * @param automation the automation object that provides the event notification
- * @param eventID the event identifier
- * @param listener the listener which should no longer be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT when listener is null</li>
- * </ul>
- *
- * @since 2.0
- */
-public void removeEventListener(OleAutomation automation, int eventID, OleListener listener) {
- checkWidget();
- if (automation == null || listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- int /*long*/ address = automation.getAddress();
- IUnknown unknown = new IUnknown(address);
- GUID riid = getDefaultEventSinkGUID(unknown);
- if (riid != null) {
- removeEventListener(address, riid, eventID, listener);
- }
-}
-void removeEventListener(int /*long*/ iunknown, GUID guid, int eventID, OleListener listener) {
- if (listener == null || guid == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- for (int i = 0; i < oleEventSink.length; i++) {
- if (COM.IsEqualGUID(oleEventSinkGUID[i], guid)) {
- if (iunknown == oleEventSinkIUnknown[i]) {
- oleEventSink[i].removeListener(eventID, listener);
- if (!oleEventSink[i].hasListeners()) {
- //free resources associated with event sink
- oleEventSink[i].disconnect();
- oleEventSink[i].Release();
- int oldLength = oleEventSink.length;
- if (oldLength == 1) {
- oleEventSink = new OleEventSink[0];
- oleEventSinkGUID = new GUID[0];
- oleEventSinkIUnknown = new int /*long*/[0];
- } else {
- OleEventSink[] newOleEventSink = new OleEventSink[oldLength - 1];
- System.arraycopy(oleEventSink, 0, newOleEventSink, 0, i);
- System.arraycopy(oleEventSink, i + 1, newOleEventSink, i, oldLength - i - 1);
- oleEventSink = newOleEventSink;
-
- GUID[] newOleEventSinkGUID = new GUID[oldLength - 1];
- System.arraycopy(oleEventSinkGUID, 0, newOleEventSinkGUID, 0, i);
- System.arraycopy(oleEventSinkGUID, i + 1, newOleEventSinkGUID, i, oldLength - i - 1);
- oleEventSinkGUID = newOleEventSinkGUID;
-
- int /*long*/[] newOleEventSinkIUnknown = new int /*long*/[oldLength - 1];
- System.arraycopy(oleEventSinkIUnknown, 0, newOleEventSinkIUnknown, 0, i);
- System.arraycopy(oleEventSinkIUnknown, i + 1, newOleEventSinkIUnknown, i, oldLength - i - 1);
- oleEventSinkIUnknown = newOleEventSinkIUnknown;
- }
- }
- return;
- }
- }
- }
-}
-/**
- * Removes the listener.
- *
- * @param propertyID the identifier of the property
- * @param listener the listener which should no longer be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT when listener is null</li>
- * </ul>
- */
-public void removePropertyListener(int propertyID, OleListener listener) {
- if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- olePropertyChangeSink.removeListener(propertyID, listener);
-}
-public void setBackground (Color color) {
-
- super.setBackground(color);
-
- //set the background of the ActiveX Control
- if (objIUnknown != null) {
- OleAutomation oleObject= new OleAutomation(this);
- oleObject.setProperty(COM.DISPID_BACKCOLOR, new Variant(color.handle));
- oleObject.dispose();
- }
-}
-public void setFont (Font font) {
-
- super.setFont(font);
-
- //set the font of the ActiveX Control
- if (objIUnknown != null) {
-
- OleAutomation oleObject= new OleAutomation(this);
- Variant varDispFont = oleObject.getProperty(COM.DISPID_FONT);
- oleObject.dispose();
-
- if (varDispFont != null){
- OleAutomation iDispFont = varDispFont.getAutomation();
- FontData[] fdata = font.getFontData();
- iDispFont.setProperty(COM.DISPID_FONT_NAME, new Variant(fdata[0].getName()));
- iDispFont.setProperty(COM.DISPID_FONT_SIZE, new Variant(fdata[0].getHeight()));
- iDispFont.setProperty(COM.DISPID_FONT_ITALIC, new Variant(fdata[0].getStyle() & SWT.ITALIC));
- //iDispFont.setProperty(COM.DISPID_FONT_CHARSET, new Variant(fdata[0].getCharset));
- iDispFont.setProperty(COM.DISPID_FONT_BOLD, new Variant((fdata[0].getStyle() & SWT.BOLD)));
- iDispFont.dispose();
- }
- }
- this.font = font;
- return;
-}
-public void setForeground (Color color) {
-
- super.setForeground(color);
-
- //set the foreground of the ActiveX Control
- if (objIUnknown != null) {
- OleAutomation oleObject= new OleAutomation(this);
- oleObject.setProperty(COM.DISPID_FORECOLOR, new Variant(color.handle));
- oleObject.dispose();
- }
-}
-/**
- * Sets the control site property specified by the dispIdMember to a new value.
- * The value will be disposed by the control site when it is no longer required
- * using Variant.dispose. Passing a value of null will clear the dispId value.
- *
- * @param dispId the ID of the property as specified by the IDL of the ActiveX Control
- * @param value The new value for the property as expressed in a Variant.
- *
- * @since 2.1
- */
-public void setSiteProperty(int dispId, Variant value){
- for (int i = 0; i < sitePropertyIds.length; i++) {
- if (sitePropertyIds[i] == dispId) {
- if (sitePropertyValues[i] != null) {
- sitePropertyValues[i].dispose();
- }
- if (value != null) {
- sitePropertyValues[i] = value;
- } else {
- int oldLength = sitePropertyIds.length;
- int[] newSitePropertyIds = new int[oldLength - 1];
- Variant[] newSitePropertyValues = new Variant[oldLength - 1];
- System.arraycopy(sitePropertyIds, 0, newSitePropertyIds, 0, i);
- System.arraycopy(sitePropertyIds, i + 1, newSitePropertyIds, i, oldLength - i - 1);
- System.arraycopy(sitePropertyValues, 0, newSitePropertyValues, 0, i);
- System.arraycopy(sitePropertyValues, i + 1, newSitePropertyValues, i, oldLength - i - 1);
- sitePropertyIds = newSitePropertyIds;
- sitePropertyValues = newSitePropertyValues;
- }
- return;
- }
- }
- int oldLength = sitePropertyIds.length;
- int[] newSitePropertyIds = new int[oldLength + 1];
- Variant[] newSitePropertyValues = new Variant[oldLength + 1];
- System.arraycopy(sitePropertyIds, 0, newSitePropertyIds, 0, oldLength);
- System.arraycopy(sitePropertyValues, 0, newSitePropertyValues, 0, oldLength);
- newSitePropertyIds[oldLength] = dispId;
- newSitePropertyValues[oldLength] = value;
- sitePropertyIds = newSitePropertyIds;
- sitePropertyValues = newSitePropertyValues;
-}
-}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleEvent.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleEvent.java
deleted file mode 100755
index 41010afc33..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleEvent.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.ole.win32;
-
-
-import org.eclipse.swt.widgets.Widget;
-
-public class OleEvent {
- public int type;
- public Widget widget;
- public int detail;
- public boolean doit = true;
- public Variant[] arguments;
-}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleEventSink.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleEventSink.java
deleted file mode 100755
index ae94cf4103..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleEventSink.java
+++ /dev/null
@@ -1,180 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.ole.win32;
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.internal.win32.*;
-import org.eclipse.swt.internal.ole.win32.*;
-
-final class OleEventSink
-{
- private OleControlSite widget;
-
- private COMObject iDispatch;
- private int refCount;
-
- private IUnknown objIUnknown;
- private int eventCookie;
- private GUID eventGuid;
-
- private OleEventTable eventTable;
-
-OleEventSink(OleControlSite widget, int /*long*/ iUnknown, GUID riid) {
-
- this.widget = widget;
- this.eventGuid = riid;
- this.objIUnknown = new IUnknown(iUnknown);
-
- createCOMInterfaces();
-}
-
-void connect () {
- int /*long*/[] ppvObject = new int /*long*/[1];
- if (objIUnknown.QueryInterface(COM.IIDIConnectionPointContainer, ppvObject) == COM.S_OK) {
- IConnectionPointContainer cpc = new IConnectionPointContainer(ppvObject[0]);
- int /*long*/[] ppCP = new int /*long*/[1];
- if (cpc.FindConnectionPoint(eventGuid, ppCP) == COM.S_OK) {
- IConnectionPoint cp = new IConnectionPoint(ppCP[0]);
- int[] pCookie = new int[1];
- if (cp.Advise(iDispatch.getAddress(), pCookie) == COM.S_OK)
- eventCookie = pCookie[0];
- cp.Release();
- }
- cpc.Release();
- }
-}
-void addListener(int eventID, OleListener listener) {
- if (listener == null) OLE.error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) eventTable = new OleEventTable ();
- eventTable.hook(eventID, listener);
-}
-int AddRef() {
- refCount++;
- return refCount;
-}
-private void createCOMInterfaces() {
- iDispatch = new COMObject(new int[]{2, 0, 0, 1, 3, 4, 8}){
- public int /*long*/ method0(int /*long*/[] args) {return QueryInterface(args[0], args[1]);}
- public int /*long*/ method1(int /*long*/[] args) {return AddRef();}
- public int /*long*/ method2(int /*long*/[] args) {return Release();}
- // method3 GetTypeInfoCount - not implemented
- // method4 GetTypeInfo - not implemented
- // method5 GetIDsOfNames - not implemented
- public int /*long*/ method6(int /*long*/[] args) {return Invoke((int)/*64*/args[0], args[1], (int)/*64*/args[2], (int)/*64*/args[3], args[4], args[5], args[6], args[7]);}
- };
-}
-void disconnect() {
- // disconnect event sink
- if (eventCookie != 0 && objIUnknown != null) {
- int /*long*/[] ppvObject = new int /*long*/[1];
- if (objIUnknown.QueryInterface(COM.IIDIConnectionPointContainer, ppvObject) == COM.S_OK) {
- IConnectionPointContainer cpc = new IConnectionPointContainer(ppvObject[0]);
- if (cpc.FindConnectionPoint(eventGuid, ppvObject) == COM.S_OK) {
- IConnectionPoint cp = new IConnectionPoint(ppvObject[0]);
- if (cp.Unadvise(eventCookie) == COM.S_OK) {
- eventCookie = 0;
- }
- cp.Release();
- }
- cpc.Release();
- }
- }
-}
-private void disposeCOMInterfaces() {
- if (iDispatch != null)
- iDispatch.dispose();
- iDispatch = null;
-
-}
-private int Invoke(int dispIdMember, int /*long*/ riid, int lcid, int dwFlags, int /*long*/ pDispParams, int /*long*/ pVarResult, int /*long*/ pExcepInfo, int /*long*/ pArgErr)
-{
- if (eventTable == null || !eventTable.hooks(dispIdMember)) return COM.S_OK;
-
- // Construct an array of the parameters that are passed in
- // Note: parameters are passed in reverse order - here we will correct the order
- Variant[] eventInfo = null;
- if (pDispParams != 0) {
- DISPPARAMS dispParams = new DISPPARAMS();
- COM.MoveMemory(dispParams, pDispParams, DISPPARAMS.sizeof);
- eventInfo = new Variant[dispParams.cArgs];
- int size = VARIANT.sizeof;
- int /*long*/ offset = (dispParams.cArgs - 1) * size;
-
- for (int j = 0; j < dispParams.cArgs; j++){
- eventInfo[j] = new Variant();
- eventInfo[j].setData(dispParams.rgvarg + offset);
- offset = offset - size;
- }
- }
-
- OleEvent event = new OleEvent();
- event.arguments = eventInfo;
- notifyListener(dispIdMember,event);
- return COM.S_OK;
-}
-/**
-* Notify listeners of an event.
-* <p>
-* This method notifies all listeners that an event
-* has occurred.
-*
-* @param eventType the desired SWT event
-* @param event the event data
-*
-* @exception IllegalArgumentException <ul>
-* <li>ERROR_NULL_ARGUMENT when handler is null</li>
-* </ul>
-* @exception SWTException <ul>
-* <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
-* <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
-* </ul>
-*/
-private void notifyListener (int eventType, OleEvent event) {
- if (event == null) OLE.error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) return;
- event.type = eventType;
- event.widget = widget;
- eventTable.sendEvent (event);
-}
-private int QueryInterface(int /*long*/ riid, int /*long*/ ppvObject) {
-
- if (riid == 0 || ppvObject == 0)
- return COM.E_INVALIDARG;
- GUID guid = new GUID();
- COM.MoveMemory(guid, riid, GUID.sizeof);
-
- if ( COM.IsEqualGUID(guid, COM.IIDIUnknown) || COM.IsEqualGUID(guid, COM.IIDIDispatch) ||
- COM.IsEqualGUID(guid, eventGuid)) {
- COM.MoveMemory(ppvObject, new int /*long*/[] {iDispatch.getAddress()}, OS.PTR_SIZEOF);
- AddRef();
- return OLE.S_OK;
- }
-
- COM.MoveMemory(ppvObject, new int /*long*/[] {0}, OS.PTR_SIZEOF);
- return COM.E_NOINTERFACE;
-}
-int Release() {
- refCount--;
- if (refCount == 0) {
- disposeCOMInterfaces();
- }
-
- return refCount;
-}
-void removeListener(int eventID, OleListener listener) {
- if (listener == null) OLE.error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) return;
- eventTable.unhook (eventID, listener);
-}
-boolean hasListeners() {
- return eventTable.hasEntries();
-}
-}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleEventTable.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleEventTable.java
deleted file mode 100755
index 1676b2f66d..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleEventTable.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.ole.win32;
-
-
-/**
-* The OleEventTable class implements a simple
-* look up mechanism that maps an event type
-* to a listener. Multiple listeners for the
-* same event type are supported.
-*
-*/
-
-class OleEventTable {
- int [] types;
- OleListener [] handlers;
-void hook (int eventType, OleListener handler) {
- if (types == null) types = new int [4];
- if (handlers == null) handlers = new OleListener [4];
- for (int i=0; i<types.length; i++) {
- if (types [i] == 0) {
- types [i] = eventType;
- handlers [i] = handler;
- return;
- }
- }
- int size = types.length;
- int [] newTypes = new int [size + 4];
- OleListener [] newHandlers = new OleListener [size + 4];
- System.arraycopy (types, 0, newTypes, 0, size);
- System.arraycopy (handlers, 0, newHandlers, 0, size);
- types = newTypes; handlers = newHandlers;
- types [size] = eventType; handlers [size] = handler;
-}
-boolean hooks (int eventType) {
- if (handlers == null) return false;
- for (int i=0; i<types.length; i++) {
- if (types [i] == eventType) return true;
- }
- return false;
-}
-void sendEvent (OleEvent event) {
- if (handlers == null) return;
- for (int i=0; i<types.length; i++) {
- if (types [i] == event.type) {
- OleListener listener = handlers [i];
- if (listener != null) listener.handleEvent (event);
- }
- }
-}
-void unhook (int eventType, OleListener handler) {
- if (handlers == null) return;
- for (int i=0; i<types.length; i++) {
- if ((types [i] == eventType) && (handlers [i] == handler)) {
- types [i] = 0;
- handlers [i] = null;
- return;
- }
- }
-}
-boolean hasEntries() {
- for (int i=0; i<types.length; i++) {
- if (types[i] != 0) return true;
- }
- return false;
-}
-}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleFrame.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleFrame.java
deleted file mode 100755
index 2677f94545..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleFrame.java
+++ /dev/null
@@ -1,805 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.ole.win32;
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.internal.ole.win32.*;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.swt.internal.win32.*;
-import org.eclipse.swt.internal.*;
-import java.util.Vector;
-
-/**
- *
- * OleFrame is an OLE Container's top level frame.
- *
- * <p>This object implements the OLE Interfaces IUnknown and IOleInPlaceFrame
- *
- * <p>OleFrame allows the container to do the following: <ul>
- * <li>position and size the ActiveX Control or OLE Document within the application
- * <li>insert menu items from the application into the OLE Document's menu
- * <li>activate and deactivate the OLE Document's menus
- * <li>position the OLE Document's menu in the application
- * <li>translate accelerator keystrokes intended for the container's frame</ul>
- *
- * <dl>
- * <dt><b>Styles</b> <dd>BORDER
- * <dt><b>Events</b> <dd>Dispose, Move, Resize
- * </dl>
- *
- * @see <a href="http://www.eclipse.org/swt/snippets/#ole">OLE and ActiveX snippets</a>
- * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Examples: OLEExample, OleWebBrowser</a>
- */
-final public class OleFrame extends Composite
-{
- // Interfaces for this Ole Client Container
- private COMObject iUnknown;
- private COMObject iOleInPlaceFrame;
-
- // Access to the embedded/linked Ole Object
- private IOleInPlaceActiveObject objIOleInPlaceActiveObject;
-
- private OleClientSite currentdoc;
-
- private int refCount = 0;
-
- private MenuItem[] fileMenuItems;
- private MenuItem[] containerMenuItems;
- private MenuItem[] windowMenuItems;
-
- private Listener listener;
-
- private static String CHECK_FOCUS = "OLE_CHECK_FOCUS"; //$NON-NLS-1$
- private static String HHOOK = "OLE_HHOOK"; //$NON-NLS-1$
- private static String HHOOKMSG = "OLE_HHOOK_MSG"; //$NON-NLS-1$
-
- private static boolean ignoreNextKey;
- private static final short [] ACCENTS = new short [] {'~', '`', '\'', '^', '"'};
-
- private static final String CONSUME_KEY = "org.eclipse.swt.OleFrame.ConsumeKey"; //$NON-NLS-1$
-
-/**
- * Create an OleFrame child widget using style bits
- * to select a particular look or set of properties.
- *
- * @param parent a composite widget (cannot be null)
- * @param style the bitwise OR'ing of widget styles
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT when the parent is null
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
- * </ul>
- *
- */
-public OleFrame(Composite parent, int style) {
- super(parent, style);
-
- createCOMInterfaces();
-
- // setup cleanup proc
- listener = new Listener() {
- public void handleEvent(Event e) {
- switch (e.type) {
- case SWT.Activate : onActivate(e); break;
- case SWT.Deactivate : onDeactivate(e); break;
- case SWT.Dispose : onDispose(e); break;
- case SWT.Resize :
- case SWT.Move : onResize(e); break;
- default :
- OLE.error(SWT.ERROR_NOT_IMPLEMENTED);
- }
- }
- };
-
-
- addListener(SWT.Activate, listener);
- addListener(SWT.Deactivate, listener);
- addListener(SWT.Dispose, listener);
-
- // inform inplaceactiveobject whenever frame resizes
- addListener(SWT.Resize, listener);
-
- // inform inplaceactiveobject whenever frame moves
- addListener(SWT.Move, listener);
-
- // Maintain a reference to yourself so that when
- // ClientSites close, they don't take the frame away
- // with them.
- this.AddRef();
-
- // Check for focus change
- Display display = getDisplay();
- initCheckFocus(display);
- initMsgHook(display);
-}
-private static void initCheckFocus (final Display display) {
- if (display.getData(CHECK_FOCUS) != null) return;
- display.setData(CHECK_FOCUS, CHECK_FOCUS);
- final int time = 50;
- final Runnable[] timer = new Runnable[1];
- final Control[] lastFocus = new Control[1];
- timer[0] = new Runnable() {
- public void run() {
- if (lastFocus[0] instanceof OleClientSite && !lastFocus[0].isDisposed()) {
- // ignore popup menus and dialogs
- int /*long*/ hwnd = OS.GetFocus();
- while (hwnd != 0) {
- int /*long*/ ownerHwnd = OS.GetWindow(hwnd, OS.GW_OWNER);
- if (ownerHwnd != 0) {
- display.timerExec(time, timer[0]);
- return;
- }
- hwnd = OS.GetParent(hwnd);
- }
- }
- if (lastFocus[0] == null || lastFocus[0].isDisposed() || !lastFocus[0].isFocusControl()) {
- Control currentFocus = display.getFocusControl();
- if (currentFocus instanceof OleFrame) {
- OleFrame frame = (OleFrame) currentFocus;
- currentFocus = frame.getCurrentDocument();
- }
- if (lastFocus[0] != currentFocus) {
- Event event = new Event();
- if (lastFocus[0] instanceof OleClientSite && !lastFocus[0].isDisposed()) {
- lastFocus[0].notifyListeners (SWT.FocusOut, event);
- }
- if (currentFocus instanceof OleClientSite && !currentFocus.isDisposed()) {
- currentFocus.notifyListeners(SWT.FocusIn, event);
- }
- }
- lastFocus[0] = currentFocus;
- }
- display.timerExec(time, timer[0]);
- }
- };
- display.timerExec(time, timer[0]);
-}
-private static void initMsgHook(Display display) {
- if (display.getData(HHOOK) != null) return;
- final Callback callback = new Callback(OleFrame.class, "getMsgProc", 3); //$NON-NLS-1$
- int /*long*/ address = callback.getAddress();
- if (address == 0) SWT.error(SWT.ERROR_NO_MORE_CALLBACKS);
- int threadId = OS.GetCurrentThreadId();
- final int /*long*/ hHook = OS.SetWindowsHookEx(OS.WH_GETMESSAGE, address, 0, threadId);
- if (hHook == 0) {
- callback.dispose();
- return;
- }
- display.setData(HHOOK, new LONG(hHook));
- display.setData(HHOOKMSG, new MSG());
- display.disposeExec(new Runnable() {
- public void run() {
- if (hHook != 0) OS.UnhookWindowsHookEx(hHook);
- if (callback != null) callback.dispose();
- }
- });
-}
-static int /*long*/ getMsgProc(int /*long*/ code, int /*long*/ wParam, int /*long*/ lParam) {
- Display display = Display.getCurrent();
- if (display == null) return 0;
- LONG hHook = (LONG)display.getData(HHOOK);
- if (hHook == null) return 0;
- if (code < 0 || (wParam & OS.PM_REMOVE) == 0) {
- return OS.CallNextHookEx(hHook.value, (int)/*64*/code, wParam, lParam);
- }
- MSG msg = (MSG)display.getData(HHOOKMSG);
- OS.MoveMemory(msg, lParam, MSG.sizeof);
- int message = msg.message;
- if (OS.WM_KEYFIRST <= message && message <= OS.WM_KEYLAST) {
- if (display != null) {
- Widget widget = null;
- int /*long*/ hwnd = msg.hwnd;
- while (hwnd != 0) {
- widget = display.findWidget (hwnd);
- if (widget != null) break;
- hwnd = OS.GetParent (hwnd);
- }
- if (widget != null && widget instanceof OleClientSite) {
- OleClientSite site = (OleClientSite)widget;
- if (site.handle == hwnd) {
- boolean consumed = false;
- /* Allow activeX control to translate accelerators except when a menu is active. */
- int thread = OS.GetWindowThreadProcessId(msg.hwnd, null);
- GUITHREADINFO lpgui = new GUITHREADINFO();
- lpgui.cbSize = GUITHREADINFO.sizeof;
- boolean rc = OS.GetGUIThreadInfo(thread, lpgui);
- int mask = OS.GUI_INMENUMODE | OS.GUI_INMOVESIZE | OS.GUI_POPUPMENUMODE | OS.GUI_SYSTEMMENUMODE;
- if (!rc || (lpgui.flags & mask) == 0) {
- OleFrame frame = site.frame;
- frame.setData(CONSUME_KEY, null);
- consumed = frame.translateOleAccelerator(msg);
- String value = (String)frame.getData(CONSUME_KEY);
- if (value != null) consumed = value.equals("true"); //$NON-NLS-1$
- frame.setData(CONSUME_KEY, null);
- }
- boolean accentKey = false;
- switch (msg.message) {
- case OS.WM_KEYDOWN:
- case OS.WM_SYSKEYDOWN: {
- if (!OS.IsWinCE) {
- switch ((int)/*64*/msg.wParam) {
- case OS.VK_SHIFT:
- case OS.VK_MENU:
- case OS.VK_CONTROL:
- case OS.VK_CAPITAL:
- case OS.VK_NUMLOCK:
- case OS.VK_SCROLL:
- break;
- default: {
- /*
- * Bug in Windows. The high bit in the result of MapVirtualKey() on
- * Windows NT is bit 32 while the high bit on Windows 95 is bit 16.
- * They should both be bit 32. The fix is to test the right bit.
- */
- int mapKey = OS.MapVirtualKey ((int)/*64*/msg.wParam, 2);
- if (mapKey != 0) {
- accentKey = (mapKey & (OS.IsWinNT ? 0x80000000 : 0x8000)) != 0;
- if (!accentKey) {
- for (int i=0; i<ACCENTS.length; i++) {
- int value = OS.VkKeyScan (ACCENTS [i]);
- if (value != -1 && (value & 0xFF) == msg.wParam) {
- int state = value >> 8;
- if ((OS.GetKeyState (OS.VK_SHIFT) < 0) == ((state & 0x1) != 0) &&
- (OS.GetKeyState (OS.VK_CONTROL) < 0) == ((state & 0x2) != 0) &&
- (OS.GetKeyState (OS.VK_MENU) < 0) == ((state & 0x4) != 0)) {
- if ((state & 0x7) != 0) accentKey = true;
- break;
- }
- }
- }
- }
- }
- break;
- }
- }
- }
- break;
- }
- }
- /* Allow OleClientSite to process key events before activeX control */
- if (!consumed && !accentKey && !ignoreNextKey) {
- int /*long*/ hwndOld = msg.hwnd;
- msg.hwnd = site.handle;
- consumed = OS.DispatchMessage (msg) == 1;
- msg.hwnd = hwndOld;
- }
- switch (msg.message) {
- case OS.WM_KEYDOWN:
- case OS.WM_SYSKEYDOWN: {
- switch ((int)/*64*/msg.wParam) {
- case OS.VK_SHIFT:
- case OS.VK_MENU:
- case OS.VK_CONTROL:
- case OS.VK_CAPITAL:
- case OS.VK_NUMLOCK:
- case OS.VK_SCROLL:
- break;
- default: {
- ignoreNextKey = accentKey;
- break;
- }
- }
- }
- }
-
- if (consumed) {
- // In order to prevent this message from also being processed
- // by the application, zero out message, wParam and lParam
- msg.message = OS.WM_NULL;
- msg.wParam = msg.lParam = 0;
- OS.MoveMemory(lParam, msg, MSG.sizeof);
- return 0;
- }
- }
- }
- }
- }
- return OS.CallNextHookEx(hHook.value, (int)/*64*/code, wParam, lParam);
-}
-/**
- * Increment the count of references to this instance
- *
- * @return the current reference count
- */
-int AddRef() {
- refCount++;
- return refCount;
-}
-private int ContextSensitiveHelp(int fEnterMode) {
- return COM.S_OK;
-}
-private void createCOMInterfaces() {
- // Create each of the interfaces that this object implements
- iUnknown = new COMObject(new int[]{2, 0, 0}){
- public int /*long*/ method0(int /*long*/[] args) {return QueryInterface(args[0], args[1]);}
- public int /*long*/ method1(int /*long*/[] args) {return AddRef();}
- public int /*long*/ method2(int /*long*/[] args) {return Release();}
- };
-
- iOleInPlaceFrame = new COMObject(new int[]{2, 0, 0, 1, 1, 1, 1, 1, 2, 2, 3, 1, 1, 1, 2}){
- public int /*long*/ method0(int /*long*/[] args) {return QueryInterface(args[0], args[1]);}
- public int /*long*/ method1(int /*long*/[] args) {return AddRef();}
- public int /*long*/ method2(int /*long*/[] args) {return Release();}
- public int /*long*/ method3(int /*long*/[] args) {return GetWindow(args[0]);}
- public int /*long*/ method4(int /*long*/[] args) {return ContextSensitiveHelp((int)/*64*/args[0]);}
- public int /*long*/ method5(int /*long*/[] args) {return GetBorder(args[0]);}
- public int /*long*/ method6(int /*long*/[] args) {return RequestBorderSpace(args[0]);}
- public int /*long*/ method7(int /*long*/[] args) {return SetBorderSpace(args[0]);}
- public int /*long*/ method8(int /*long*/[] args) {return SetActiveObject(args[0], args[1]);}
- public int /*long*/ method9(int /*long*/[] args) {return InsertMenus(args[0], args[1]);}
- public int /*long*/ method10(int /*long*/[] args) {return SetMenu(args[0], args[1], args[2]);}
- public int /*long*/ method11(int /*long*/[] args) {return RemoveMenus(args[0]);}
- // method12 SetStatusText - not implemented
- // method13 EnableModeless - not implemented
- public int /*long*/ method14(int /*long*/[] args) {return TranslateAccelerator(args[0], (int)/*64*/args[1]);}
- };
-}
-private void disposeCOMInterfaces () {
-
- if (iUnknown != null)
- iUnknown.dispose();
- iUnknown = null;
-
- if (iOleInPlaceFrame != null)
- iOleInPlaceFrame.dispose();
- iOleInPlaceFrame = null;
-}
-private int GetBorder(int /*long*/ lprectBorder) {
- /*
- The IOleInPlaceUIWindow::GetBorder function, when called on a document or frame window
- object, returns the outer rectangle (relative to the window) where the object can put
- toolbars or similar controls.
- */
- if (lprectBorder == 0) return COM.E_INVALIDARG;
- RECT rectBorder = new RECT();
- // Coordinates must be relative to the window
- OS.GetClientRect(handle, rectBorder);
- OS.MoveMemory(lprectBorder, rectBorder, RECT.sizeof);
- return COM.S_OK;
-}
-/**
- *
- * Returns the application menu items that will appear in the Container location when an OLE Document
- * is in-place activated.
- *
- * <p>When an OLE Document is in-place active, the Document provides its own menus but the application
- * is given the opportunity to merge some of its menus into the menubar. The application
- * is allowed to insert its menus in three locations: File (far left), Container(middle) and Window
- * (far right just before Help). The OLE Document retains control of the Edit, Object and Help
- * menu locations. Note that an application can insert more than one menu into a single location.
- *
- * @return the application menu items that will appear in the Container location when an OLE Document
- * is in-place activated.
- *
- */
-public MenuItem[] getContainerMenus(){
- return containerMenuItems;
-}
-/**
- *
- * Returns the application menu items that will appear in the File location when an OLE Document
- * is in-place activated.
- *
- * <p>When an OLE Document is in-place active, the Document provides its own menus but the application
- * is given the opportunity to merge some of its menus into the menubar. The application
- * is allowed to insert its menus in three locations: File (far left), Container(middle) and Window
- * (far right just before Help). The OLE Document retains control of the Edit, Object and Help
- * menu locations. Note that an application can insert more than one menu into a single location.
- *
- * @return the application menu items that will appear in the File location when an OLE Document
- * is in-place activated.
- *
- */
-public MenuItem[] getFileMenus(){
- return fileMenuItems;
-}
-int /*long*/ getIOleInPlaceFrame() {
- return iOleInPlaceFrame.getAddress();
-}
-private int /*long*/ getMenuItemID(int /*long*/ hMenu, int index) {
- int /*long*/ id = 0;
- MENUITEMINFO lpmii = new MENUITEMINFO();
- lpmii.cbSize = MENUITEMINFO.sizeof;
- lpmii.fMask = OS.MIIM_STATE | OS.MIIM_SUBMENU | OS.MIIM_ID;
- OS.GetMenuItemInfo(hMenu, index, true, lpmii);
- if ((lpmii.fState & OS.MF_POPUP) == OS.MF_POPUP) {
- id = lpmii.hSubMenu;
- } else {
- id = lpmii.wID;
- }
- return id;
-}
-private int GetWindow(int /*long*/ phwnd) {
- if (phwnd != 0) {
- COM.MoveMemory(phwnd, new int /*long*/[] {handle}, OS.PTR_SIZEOF);
- }
- return COM.S_OK;
-}
-/**
- *
- * Returns the application menu items that will appear in the Window location when an OLE Document
- * is in-place activated.
- *
- * <p>When an OLE Document is in-place active, the Document provides its own menus but the application
- * is given the opportunity to merge some of its menus into the menubar. The application
- * is allowed to insert its menus in three locations: File (far left), Container(middle) and Window
- * (far right just before Help). The OLE Document retains control of the Edit, Object and Help
- * menu locations. Note that an application can insert more than one menu into a single location.
- *
- * @return the application menu items that will appear in the Window location when an OLE Document
- * is in-place activated.
- *
- */
-public MenuItem[] getWindowMenus(){
- return windowMenuItems;
-}
-private int InsertMenus(int /*long*/ hmenuShared, int /*long*/ lpMenuWidths) {
- // locate menu bar
- Menu menubar = getShell().getMenuBar();
- if (menubar == null || menubar.isDisposed()) {
- COM.MoveMemory(lpMenuWidths, new int[] {0}, 4);
- return COM.S_OK;
- }
- int /*long*/ hMenu = menubar.handle;
-
- // Create a holder for menu information. This will be passed down to
- // the OS and the OS will fill in the requested information for each menu.
- MENUITEMINFO lpmii = new MENUITEMINFO();
- int /*long*/ hHeap = OS.GetProcessHeap();
- int cch = 128;
- int byteCount = cch * TCHAR.sizeof;
- int /*long*/ pszText = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
- lpmii.cbSize = MENUITEMINFO.sizeof;
- lpmii.fMask = OS.MIIM_STATE | OS.MIIM_ID | OS.MIIM_TYPE | OS.MIIM_SUBMENU | OS.MIIM_DATA;
- lpmii.dwTypeData = pszText;
- lpmii.cch = cch;
-
- // Loop over all "File-like" menus in the menubar and get information about the
- // item from the OS.
- int fileMenuCount = 0;
- int newindex = 0;
- if (this.fileMenuItems != null) {
- for (int i = 0; i < this.fileMenuItems.length; i++) {
- MenuItem item = this.fileMenuItems[i];
- if (item != null) {
- int index = item.getParent().indexOf(item);
- lpmii.cch = cch; // lpmii.cch gets updated by GetMenuItemInfo to indicate the
- // exact number of characters in name. Reset it to our max size
- // before each call.
- if (OS.GetMenuItemInfo(hMenu, index, true, lpmii)) {
- if (OS.InsertMenuItem(hmenuShared, newindex, true, lpmii)) {
- // keep track of the number of items
- fileMenuCount++;
- newindex++;
- }
- }
- }
- }
- }
-
- // copy the menu item count information to the pointer
- COM.MoveMemory(lpMenuWidths, new int[] {fileMenuCount}, 4);
-
- // Loop over all "Container-like" menus in the menubar and get information about the
- // item from the OS.
- int containerMenuCount = 0;
- if (this.containerMenuItems != null) {
- for (int i = 0; i < this.containerMenuItems.length; i++) {
- MenuItem item = this.containerMenuItems[i];
- if (item != null) {
- int index = item.getParent().indexOf(item);
- lpmii.cch = cch; // lpmii.cch gets updated by GetMenuItemInfo to indicate the
- // exact number of characters in name. Reset it to a large number
- // before each call.
- if (OS.GetMenuItemInfo(hMenu, index, true, lpmii)) {
- if (OS.InsertMenuItem(hmenuShared, newindex, true, lpmii)) {
- // keep track of the number of items
- containerMenuCount++;
- newindex++;
- }
- }
- }
- }
- }
-
- // copy the menu item count information to the pointer
- COM.MoveMemory(lpMenuWidths + 8, new int[] {containerMenuCount}, 4);
-
- // Loop over all "Window-like" menus in the menubar and get information about the
- // item from the OS.
- int windowMenuCount = 0;
- if (this.windowMenuItems != null) {
- for (int i = 0; i < this.windowMenuItems.length; i++) {
- MenuItem item = this.windowMenuItems[i];
- if (item != null) {
- int index = item.getParent().indexOf(item);
- lpmii.cch = cch; // lpmii.cch gets updated by GetMenuItemInfo to indicate the
- // exact number of characters in name. Reset it to a large number
- // before each call.
- if (OS.GetMenuItemInfo(hMenu, index, true, lpmii)) {
- if (OS.InsertMenuItem(hmenuShared, newindex, true, lpmii)) {
- // keep track of the number of items
- windowMenuCount++;
- newindex++;
- }
- }
- }
- }
- }
-
- // copy the menu item count information to the pointer
- COM.MoveMemory(lpMenuWidths + 16, new int[] {windowMenuCount}, 4);
-
- // free resources used in querying the OS
- if (pszText != 0)
- OS.HeapFree(hHeap, 0, pszText);
- return COM.S_OK;
-}
-void onActivate(Event e) {
- if (objIOleInPlaceActiveObject != null) {
- objIOleInPlaceActiveObject.OnFrameWindowActivate(true);
- }
-}
-void onDeactivate(Event e) {
- if (objIOleInPlaceActiveObject != null) {
- objIOleInPlaceActiveObject.OnFrameWindowActivate(false);
- }
-}
-private void onDispose(Event e) {
-
- releaseObjectInterfaces();
- currentdoc = null;
-
- this.Release();
- removeListener(SWT.Activate, listener);
- removeListener(SWT.Deactivate, listener);
- removeListener(SWT.Dispose, listener);
- removeListener(SWT.Resize, listener);
- removeListener(SWT.Move, listener);
-}
-private void onResize(Event e) {
- if (objIOleInPlaceActiveObject != null) {
- RECT lpRect = new RECT();
- OS.GetClientRect(handle, lpRect);
- objIOleInPlaceActiveObject.ResizeBorder(lpRect, iOleInPlaceFrame.getAddress(), true);
- }
-}
-private int QueryInterface(int /*long*/ riid, int /*long*/ ppvObject) {
-// implements IUnknown, IOleInPlaceFrame, IOleContainer, IOleInPlaceUIWindow
- if (riid == 0 || ppvObject == 0)
- return COM.E_INVALIDARG;
- GUID guid = new GUID();
- COM.MoveMemory(guid, riid, GUID.sizeof);
- if (COM.IsEqualGUID(guid, COM.IIDIUnknown) || COM.IsEqualGUID(guid, COM.IIDIOleInPlaceFrame) ) {
- COM.MoveMemory(ppvObject, new int /*long*/ [] {iOleInPlaceFrame.getAddress()}, OS.PTR_SIZEOF);
- AddRef();
- return COM.S_OK;
- }
-
- COM.MoveMemory(ppvObject, new int /*long*/ [] {0}, OS.PTR_SIZEOF);
- return COM.E_NOINTERFACE;
-}
-/**
- * Decrement the count of references to this instance
- *
- * @return the current reference count
- */
-int Release() {
- refCount--;
- if (refCount == 0){
- disposeCOMInterfaces();
- COM.CoFreeUnusedLibraries();
- }
- return refCount;
-}
-private void releaseObjectInterfaces() {
- if (objIOleInPlaceActiveObject != null) {
- objIOleInPlaceActiveObject.Release();
- }
- objIOleInPlaceActiveObject = null;
-}
-private int RemoveMenus(int /*long*/ hmenuShared) {
-
- Menu menubar = getShell().getMenuBar();
- if (menubar == null || menubar.isDisposed()) return COM.S_FALSE;
-
- int /*long*/ hMenu = menubar.handle;
-
- Vector ids = new Vector();
- if (this.fileMenuItems != null) {
- for (int i = 0; i < this.fileMenuItems.length; i++) {
- MenuItem item = this.fileMenuItems[i];
- if (item != null && !item.isDisposed()) {
- int index = item.getParent().indexOf(item);
- // get Id from original menubar
- int /*long*/ id = getMenuItemID(hMenu, index);
- ids.addElement(new LONG(id));
- }
- }
- }
- if (this.containerMenuItems != null) {
- for (int i = 0; i < this.containerMenuItems.length; i++) {
- MenuItem item = this.containerMenuItems[i];
- if (item != null && !item.isDisposed()) {
- int index = item.getParent().indexOf(item);
- int /*long*/ id = getMenuItemID(hMenu, index);
- ids.addElement(new LONG(id));
- }
- }
- }
- if (this.windowMenuItems != null) {
- for (int i = 0; i < this.windowMenuItems.length; i++) {
- MenuItem item = this.windowMenuItems[i];
- if (item != null && !item.isDisposed()) {
- int index = item.getParent().indexOf(item);
- int /*long*/ id = getMenuItemID(hMenu, index);
- ids.addElement(new LONG(id));
- }
- }
- }
- int index = OS.GetMenuItemCount(hmenuShared) - 1;
- for (int i = index; i >= 0; i--) {
- int /*long*/ id = getMenuItemID(hmenuShared, i);
- if (ids.contains(new LONG(id))){
- OS.RemoveMenu(hmenuShared, i, OS.MF_BYPOSITION);
- }
- }
- return COM.S_OK;
-}
-private int RequestBorderSpace(int /*long*/ pborderwidths) {
- return COM.S_OK;
-}
-int SetActiveObject(int /*long*/ pActiveObject, int /*long*/ pszObjName) {
- if (objIOleInPlaceActiveObject != null) {
- objIOleInPlaceActiveObject.Release();
- objIOleInPlaceActiveObject = null;
- }
- if (pActiveObject != 0) {
- objIOleInPlaceActiveObject = new IOleInPlaceActiveObject(pActiveObject);
- objIOleInPlaceActiveObject.AddRef();
- }
-
- return COM.S_OK;
-}
-private int SetBorderSpace(int /*long*/ pborderwidths) {
- // A Control/Document can :
- // Use its own toolbars, requesting border space of a specific size, or,
- // Use no toolbars, but force the container to remove its toolbars by passing a
- // valid BORDERWIDTHS structure containing nothing but zeros in the pborderwidths parameter, or,
- // Use no toolbars but allow the in-place container to leave its toolbars up by
- // passing NULL as the pborderwidths parameter.
- if (objIOleInPlaceActiveObject == null) return COM.S_OK;
- RECT borderwidth = new RECT();
- if (pborderwidths == 0 || currentdoc == null ) return COM.S_OK;
-
- COM.MoveMemory(borderwidth, pborderwidths, RECT.sizeof);
- currentdoc.setBorderSpace(borderwidth);
-
- return COM.S_OK;
-}
-/**
- *
- * Specify the menu items that should appear in the Container location when an OLE Document
- * is in-place activated.
- *
- * <p>When an OLE Document is in-place active, the Document provides its own menus but the application
- * is given the opportunity to merge some of its menus into the menubar. The application
- * is allowed to insert its menus in three locations: File (far left), Container(middle) and Window
- * (far right just before Help). The OLE Document retains control of the Edit, Object and Help
- * menu locations. Note that an application can insert more than one menu into a single location.
- *
- * <p>This method must be called before in place activation of the OLE Document. After the Document
- * is activated, the menu bar will not be modified until a subsequent activation.
- *
- * @param containerMenus an array of top level MenuItems to be inserted into the Container location of
- * the menubar
- */
-public void setContainerMenus(MenuItem[] containerMenus){
- containerMenuItems = containerMenus;
-}
-OleClientSite getCurrentDocument() {
- return currentdoc;
-}
-void setCurrentDocument(OleClientSite doc) {
- currentdoc = doc;
-
- if (currentdoc != null && objIOleInPlaceActiveObject != null) {
- RECT lpRect = new RECT();
- OS.GetClientRect(handle, lpRect);
- objIOleInPlaceActiveObject.ResizeBorder(lpRect, iOleInPlaceFrame.getAddress(), true);
- }
-}
-/**
- *
- * Specify the menu items that should appear in the File location when an OLE Document
- * is in-place activated.
- *
- * <p>When an OLE Document is in-place active, the Document provides its own menus but the application
- * is given the opportunity to merge some of its menus into the menubar. The application
- * is allowed to insert its menus in three locations: File (far left), Container(middle) and Window
- * (far right just before Help). The OLE Document retains control of the Edit, Object and Help
- * menu locations. Note that an application can insert more than one menu into a single location.
- *
- * <p>This method must be called before in place activation of the OLE Document. After the Document
- * is activated, the menu bar will not be modified until a subsequent activation.
- *
- * @param fileMenus an array of top level MenuItems to be inserted into the File location of
- * the menubar
- */
-public void setFileMenus(MenuItem[] fileMenus){
- fileMenuItems = fileMenus;
-}
-private int SetMenu(int /*long*/ hmenuShared, int /*long*/ holemenu, int /*long*/ hwndActiveObject) {
- int /*long*/ inPlaceActiveObject = 0;
- if (objIOleInPlaceActiveObject != null)
- inPlaceActiveObject = objIOleInPlaceActiveObject.getAddress();
-
- Menu menubar = getShell().getMenuBar();
- if (menubar == null || menubar.isDisposed()){
- return COM.OleSetMenuDescriptor(0, getShell().handle, hwndActiveObject, iOleInPlaceFrame.getAddress(), inPlaceActiveObject);
- }
-
- int /*long*/ handle = menubar.getShell().handle;
-
- if (hmenuShared == 0 && holemenu == 0) {
- // re-instate the original menu - this occurs on deactivation
- hmenuShared = menubar.handle;
- }
- if (hmenuShared == 0) return COM.E_FAIL;
-
- OS.SetMenu(handle, hmenuShared);
- OS.DrawMenuBar(handle);
-
- return COM.OleSetMenuDescriptor(holemenu, handle, hwndActiveObject, iOleInPlaceFrame.getAddress(), inPlaceActiveObject);
-}
-/**
- *
- * Set the menu items that should appear in the Window location when an OLE Document
- * is in-place activated.
- *
- * <p>When an OLE Document is in-place active, the Document provides its own menus but the application
- * is given the opportunity to merge some of its menus into the menubar. The application
- * is allowed to insert its menus in three locations: File (far left), Container(middle) and Window
- * (far right just before Help). The OLE Document retains control of the Edit, Object and Help
- * menu locations. Note that an application can insert more than one menu into a single location.
- *
- * <p>This method must be called before in place activation of the OLE Document. After the Document
- * is activated, the menu bar will not be modified until a subsequent activation.
- *
- * @param windowMenus an array of top level MenuItems to be inserted into the Window location of
- * the menubar
- */
-public void setWindowMenus(MenuItem[] windowMenus){
- windowMenuItems = windowMenus;
-}
-private boolean translateOleAccelerator(MSG msg) {
- if (objIOleInPlaceActiveObject == null) return false;
- int result = objIOleInPlaceActiveObject.TranslateAccelerator(msg);
- return (result != COM.S_FALSE && result != COM.E_NOTIMPL);
-}
-private int TranslateAccelerator(int /*long*/ lpmsg, int wID){
- Menu menubar = getShell().getMenuBar();
- if (menubar == null || menubar.isDisposed() || !menubar.isEnabled()) return COM.S_FALSE;
- if (wID < 0) return COM.S_FALSE;
-
- Shell shell = menubar.getShell();
- int /*long*/ hwnd = shell.handle;
- int /*long*/ hAccel = OS.SendMessage(hwnd, OS.WM_APP+1, 0, 0);
- if (hAccel == 0) return COM.S_FALSE;
-
- MSG msg = new MSG();
- OS.MoveMemory(msg, lpmsg, MSG.sizeof);
- int result = OS.TranslateAccelerator(hwnd, hAccel, msg);
- return result == 0 ? COM.S_FALSE : COM.S_OK;
-}
-}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleFunctionDescription.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleFunctionDescription.java
deleted file mode 100755
index 2a65fa9121..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleFunctionDescription.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.ole.win32;
-
-
-public class OleFunctionDescription {
-
- public int id;
- public String name;
- public OleParameterDescription[] args;
- public int optionalArgCount;
- public short returnType;
- public int invokeKind;
- public int funcKind;
- public short flags;
- public int callingConvention;
- public String documentation;
- public String helpFile;
-
-}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleListener.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleListener.java
deleted file mode 100755
index ef094cbe3e..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleListener.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.ole.win32;
-
-
-/**
- * Implementers of <code>OleListener</code> provide a simple
- * <code>handleEvent()</code> method that is used internally
- * by SWT to dispatch events.
- * <p>
- * After creating an instance of a class that implements this
- * interface it can be added to an <code>OleControlSite</code>
- * using the <code>addEventListener()</code> method and removed
- * using the <code>removeEventListener()</code> method. When the
- * specified event occurs, <code>handleEvent()</code> will be
- * sent to the instance.
- * </p>
- *
- * @see OleControlSite
- */
-public interface OleListener {
-
-/**
- * Sent when an event that the receiver has registered for occurs.
- *
- * @param event the event which occurred
- */
-public void handleEvent(OleEvent event);
-}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleParameterDescription.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleParameterDescription.java
deleted file mode 100755
index 056525a53e..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleParameterDescription.java
+++ /dev/null
@@ -1,18 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.ole.win32;
-
-
-public class OleParameterDescription {
- public String name;
- public short flags;
- public short type;
-}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OlePropertyChangeSink.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OlePropertyChangeSink.java
deleted file mode 100755
index 98ca8a8a2a..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OlePropertyChangeSink.java
+++ /dev/null
@@ -1,173 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.ole.win32;
-
-
-import org.eclipse.swt.internal.ole.win32.*;
-import org.eclipse.swt.internal.win32.*;
-import org.eclipse.swt.*;
-
-final class OlePropertyChangeSink {
-
- private OleControlSite controlSite;
- //private IUnknown objIUnknown;
-
- private COMObject iUnknown;
- private COMObject iPropertyNotifySink;
-
- private int refCount;
-
- private int propertyCookie;
-
- private OleEventTable eventTable;
-
-OlePropertyChangeSink(OleControlSite controlSite) {
-
- this.controlSite = controlSite;
-
- createCOMInterfaces();
-}
-void addListener(int propertyID, OleListener listener) {
- if (listener == null) OLE.error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) eventTable = new OleEventTable ();
- eventTable.hook(propertyID, listener);
-}
-int AddRef() {
- refCount++;
- return refCount;
-}
-void connect(IUnknown objIUnknown) {
-
- // Set up property change notification sink
- int /*long*/[] ppvObject = new int /*long*/[1];
- if (objIUnknown.QueryInterface(COM.IIDIConnectionPointContainer, ppvObject) == COM.S_OK) {
- IConnectionPointContainer cpc = new IConnectionPointContainer(ppvObject[0]);
- if (cpc.FindConnectionPoint(COM.IIDIPropertyNotifySink, ppvObject) == COM.S_OK) {
- IConnectionPoint cp = new IConnectionPoint(ppvObject[0]);
- int[] cookie = new int[1];
- if (cp.Advise(iPropertyNotifySink.getAddress(), cookie) == COM.S_OK) {
- propertyCookie = cookie[0];
- }
- cp.Release();
- }
- cpc.Release();
- }
-}
-private void createCOMInterfaces() {
- // register each of the interfaces that this object implements
- iUnknown = new COMObject(new int[]{2, 0, 0}){
- public int /*long*/ method0(int /*long*/[] args) {return QueryInterface(args[0], args[1]);}
- public int /*long*/ method1(int /*long*/[] args) {return AddRef();}
- public int /*long*/ method2(int /*long*/[] args) {return Release();}
- };
-
- iPropertyNotifySink = new COMObject(new int[]{2, 0, 0, 1, 1}){
- public int /*long*/ method0(int /*long*/[] args) {return QueryInterface(args[0], args[1]);}
- public int /*long*/ method1(int /*long*/[] args) {return AddRef();}
- public int /*long*/ method2(int /*long*/[] args) {return Release();}
- public int /*long*/ method3(int /*long*/[] args) {return OnChanged((int)/*64*/args[0]);}
- public int /*long*/ method4(int /*long*/[] args) {return OnRequestEdit((int)/*64*/args[0]);}
- };
-}
-void disconnect(IUnknown objIUnknown) {
-
- // disconnect property notification sink
- if (propertyCookie != 0 && objIUnknown != null) {
- int /*long*/[] ppvObject = new int /*long*/[1];
- if (objIUnknown.QueryInterface(COM.IIDIConnectionPointContainer, ppvObject) == COM.S_OK) {
- IConnectionPointContainer cpc = new IConnectionPointContainer(ppvObject[0]);
- if (cpc.FindConnectionPoint(COM.IIDIPropertyNotifySink, ppvObject) == COM.S_OK) {
- IConnectionPoint cp = new IConnectionPoint(ppvObject[0]);
- if (cp.Unadvise(propertyCookie) == COM.S_OK) {
- propertyCookie = 0;
- }
- cp.Release();
- }
- cpc.Release();
- }
- }
-}
-private void disposeCOMInterfaces() {
- if (iUnknown != null) iUnknown.dispose();
- iUnknown = null;
- if (iPropertyNotifySink != null) iPropertyNotifySink.dispose();
- iPropertyNotifySink = null;
-}
-/**
-* Notify listeners of an event.
-* <p>
-* This method notifies all listeners that an event
-* has occurred.
-*
-* @param eventType the desired SWT event
-* @param event the event data
-*
-* @exception IllegalArgumentException <ul>
-* <li>ERROR_NULL_ARGUMENT when handler is null</li>
-* </ul>
-* @exception SWTException <ul>
-* <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
-* <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
-* </ul>
-*/
-private void notifyListener (int eventType, OleEvent event) {
- if (event == null) OLE.error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) return;
- event.type = eventType;
- event.widget = controlSite;
- eventTable.sendEvent (event);
-}
-private int OnChanged(int dispID) {
- if (eventTable == null || !eventTable.hooks(dispID)) return COM.S_OK;
- OleEvent event = new OleEvent();
- event.detail = OLE.PROPERTY_CHANGED;
- notifyListener(dispID,event);
- return COM.S_OK;
-}
-private int OnRequestEdit(int dispID) {
- if (eventTable == null || !eventTable.hooks(dispID)) return COM.S_OK;
- OleEvent event = new OleEvent();
- event.doit = true;
- event.detail = OLE.PROPERTY_CHANGING;
- notifyListener(dispID,event);
- return (event.doit) ? COM.S_OK : COM.S_FALSE;
-}
-private int QueryInterface(int /*long*/ riid, int /*long*/ ppvObject) {
- if (riid == 0 || ppvObject == 0)
- return COM.E_INVALIDARG;
- GUID guid = new GUID();
- COM.MoveMemory(guid, riid, GUID.sizeof);
- if (COM.IsEqualGUID(guid, COM.IIDIUnknown)) {
- COM.MoveMemory(ppvObject, new int /*long*/[] {iUnknown.getAddress()}, OS.PTR_SIZEOF);
- AddRef();
- return COM.S_OK;
- }
- if (COM.IsEqualGUID(guid, COM.IIDIPropertyNotifySink)) {
- COM.MoveMemory(ppvObject, new int /*long*/[] {iPropertyNotifySink.getAddress()}, OS.PTR_SIZEOF);
- AddRef();
- return COM.S_OK;
- }
- COM.MoveMemory(ppvObject, new int /*long*/[] {0}, OS.PTR_SIZEOF);
- return COM.E_NOINTERFACE;
-}
-int Release() {
- refCount--;
- if (refCount == 0) {
- disposeCOMInterfaces();
- }
- return refCount;
-}
-void removeListener(int propertyID, OleListener listener) {
- if (listener == null) OLE.error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) return;
- eventTable.unhook (propertyID, listener);
-}
-}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OlePropertyDescription.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OlePropertyDescription.java
deleted file mode 100755
index 5ce315ff15..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OlePropertyDescription.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.ole.win32;
-
-
-public class OlePropertyDescription {
- public int id;
- public String name;
- public int type;
- public int flags;
- public int kind;
- public String description;
- public String helpFile;
-}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/Variant.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/Variant.java
deleted file mode 100755
index 0cb028da44..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/Variant.java
+++ /dev/null
@@ -1,1057 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.ole.win32;
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.internal.ole.win32.*;
-import org.eclipse.swt.internal.win32.*;
-/**
- *
- * A Variant is a generic OLE mechanism for passing data of different types via a common interface.
- *
- * <p>It is used within the OleAutomation object for getting a property, setting a property or invoking
- * a method on an OLE Control or OLE Document.
- *
- */
-public final class Variant {
- /**
- * The size in bytes of a native VARIANT struct.
- */
- public static final int sizeof = VARIANT.sizeof;
-
- private short type; // OLE.VT_* type
- private boolean booleanData;
- private byte byteData;
- private short shortData;
- private char charData;
- private int intData;
- private long longData;
- private float floatData;
- private double doubleData;
- private String stringData;
- private int /*long*/ byRefPtr;
- private IDispatch dispatchData;
- private IUnknown unknownData;
-
-/**
- * Invokes platform specific functionality to copy a variant
- * into operating system memory.
- * <p>
- * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
- * API for <code>Variant</code>. It is marked public only so that it
- * can be shared within the packages provided by SWT. It is not
- * available on all platforms, and should never be called from
- * application code.
- * </p>
- *
- * @param pVarDest destination pointer to a variant
- * @param varSrc source <code>Variant</code>
- *
- * @since 3.3
- */
-public static void win32_copy (int /*long*/ pVarDest, Variant varSrc) {
- varSrc.getData (pVarDest);
-}
-
-/**
- * Invokes platform specific functionality to wrap a variant
- * that was allocated in operating system memory.
- * <p>
- * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
- * API for <code>Variant</code>. It is marked public only so that it
- * can be shared within the packages provided by SWT. It is not
- * available on all platforms, and should never be called from
- * application code.
- * </p>
- *
- * @param pVariant pointer to a variant
- *
- * @return a new <code>Variant</code>
- *
- * @since 3.3
- */
-public static Variant win32_new (int /*long*/ pVariant) {
- Variant variant = new Variant ();
- variant.setData (pVariant);
- return variant;
-}
-
-/**
- * Create an empty Variant object with type VT_EMPTY.
- *
- * @since 2.0
- */
-public Variant(){
- type = COM.VT_EMPTY;
-}
-/**
- * Create a Variant object which represents a Java float as a VT_R4.
- *
- * @param val the Java float value that this Variant represents
- *
- */
-public Variant(float val) {
- type = COM.VT_R4;
- floatData = val;
-
-}
-/**
- * Create a Variant object which represents a Java double as a VT_R8.
- *
- * @param val the Java double value that this Variant represents
- *
- * @since 3.2
- */
-public Variant(double val) {
- type = COM.VT_R8;
- doubleData = val;
-}
-/**
- * Create a Variant object which represents a Java int as a VT_I4.
- *
- * @param val the Java int value that this Variant represents
- *
- */
- public Variant(int val) {
- type = COM.VT_I4;
- intData = val;
-}
-/**
- * Create a Variant object which contains a reference to the data being transferred.
- *
- * <p>When creating a VT_BYREF Variant, you must give the full Variant type
- * including VT_BYREF such as
- *
- * <pre><code>short byRefType = OLE.VT_BSTR | OLE.VT_BYREF</code></pre>.
- *
- * @param ptr a pointer to the data being transferred.
- * @param byRefType the type of the data being transferred such as OLE.VT_BSTR | OLE.VT_BYREF
- *
- */
-public Variant(int /*long*/ ptr, short byRefType) {
- type = byRefType;
- byRefPtr = ptr;
-}
-/**
- * Create a Variant object which represents an IDispatch interface as a VT_Dispatch.
- *
- * @param automation the OleAutomation object that this Variant represents
- *
- */
-public Variant(OleAutomation automation) {
- type = COM.VT_DISPATCH;
- dispatchData = new IDispatch(automation.getAddress());
-}
-/**
- * Create a Variant object which represents an IDispatch interface as a VT_Dispatch.
- * <p>The caller is expected to have appropriately invoked unknown.AddRef() before creating
- * this Variant.
- *
- * @since 2.0
- *
- * @param idispatch the IDispatch object that this Variant represents
- *
- */
-public Variant(IDispatch idispatch) {
- type = COM.VT_DISPATCH;
- dispatchData = idispatch;
-}
-/**
- * Create a Variant object which represents an IUnknown interface as a VT_UNKNOWN.
- *
- * <p>The caller is expected to have appropriately invoked unknown.AddRef() before creating
- * this Variant.
- *
- * @param unknown the IUnknown object that this Variant represents
- *
- */
-public Variant(IUnknown unknown) {
- type = COM.VT_UNKNOWN;
- unknownData = unknown;
-}
-/**
- * Create a Variant object which represents a Java long as a VT_I8.
- *
- * @param val the Java long value that this Variant represents
- *
- * @since 3.2
- */
- public Variant(long val) {
- type = COM.VT_I8;
- longData = val;
-}
-/**
- * Create a Variant object which represents a Java String as a VT_BSTR.
- *
- * @param string the Java String value that this Variant represents
- *
- */
-public Variant(String string) {
- type = COM.VT_BSTR;
- stringData = string;
-}
-/**
- * Create a Variant object which represents a Java short as a VT_I2.
- *
- * @param val the Java short value that this Variant represents
- *
- */
-public Variant(short val) {
- type = COM.VT_I2;
- shortData = val;
-}
-/**
- * Create a Variant object which represents a Java boolean as a VT_BOOL.
- *
- * @param val the Java boolean value that this Variant represents
- *
- */
-public Variant(boolean val) {
- type = COM.VT_BOOL;
- booleanData = val;
-}
-
-/**
- * Calling dispose will release resources associated with this Variant.
- * If the resource is an IDispatch or IUnknown interface, Release will be called.
- * If the resource is a ByRef pointer, nothing is released.
- *
- * @since 2.1
- */
-public void dispose() {
- if ((type & COM.VT_BYREF) == COM.VT_BYREF) {
- return;
- }
-
- switch (type) {
- case COM.VT_DISPATCH :
- dispatchData.Release();
- break;
- case COM.VT_UNKNOWN :
- unknownData.Release();
- break;
- }
-
-}
-/**
- * Returns the OleAutomation object represented by this Variant.
- *
- * <p>If this Variant does not contain an OleAutomation object, an attempt is made to
- * coerce the Variant type into an OleAutomation object. If this fails, an error is
- * thrown. Note that OleAutomation objects must be disposed when no longer
- * needed.
- *
- * @return the OleAutomation object represented by this Variant
- *
- * @exception SWTException <ul>
- * <li>ERROR_CANNOT_CHANGE_VARIANT_TYPE when type of Variant can not be coerced into an OleAutomation object</li>
- * </ul>
- */
-public OleAutomation getAutomation() {
- if (type == COM.VT_EMPTY) {
- OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, -1);
- }
- if (type == COM.VT_DISPATCH) {
- return new OleAutomation(dispatchData);
- }
- // try to coerce the value to the desired type
- int /*long*/ oldPtr = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, sizeof);
- int /*long*/ newPtr = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, sizeof);
- try {
- getData(oldPtr);
- int result = COM.VariantChangeType(newPtr, oldPtr, (short) 0, COM.VT_DISPATCH);
- if (result != COM.S_OK)
- OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, result);
- Variant autoVar = new Variant();
- autoVar.setData(newPtr);
- return autoVar.getAutomation();
- } finally {
- COM.VariantClear(oldPtr);
- OS.GlobalFree(oldPtr);
- COM.VariantClear(newPtr); // Note: This must absolutely be done AFTER the
- // OleAutomation object is created as Variant Clear
- // will result in a Release being performed on the
- // Dispatch object
- OS.GlobalFree(newPtr);
- }
-}
-/**
- * Returns the IDispatch object represented by this Variant.
- *
- * <p>If this Variant does not contain an IDispatch object, an attempt is made to
- * coerce the Variant type into an IDIspatch object. If this fails, an error is
- * thrown.
- *
- * @since 2.0
- *
- * @return the IDispatch object represented by this Variant
- *
- * @exception SWTException <ul>
- * <li>ERROR_CANNOT_CHANGE_VARIANT_TYPE when type of Variant can not be coerced into an IDispatch object</li>
- * </ul>
- */
-public IDispatch getDispatch() {
- if (type == COM.VT_EMPTY) {
- OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, -1);
- }
- if (type == COM.VT_DISPATCH) {
- return dispatchData;
- }
- // try to coerce the value to the desired type
- int /*long*/ oldPtr = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, sizeof);
- int /*long*/ newPtr = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, sizeof);
- try {
- getData(oldPtr);
- int result = COM.VariantChangeType(newPtr, oldPtr, (short) 0, COM.VT_DISPATCH);
- if (result != COM.S_OK)
- OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, result);
- Variant autoVar = new Variant();
- autoVar.setData(newPtr);
- return autoVar.getDispatch();
- } finally {
- COM.VariantClear(oldPtr);
- OS.GlobalFree(oldPtr);
- COM.VariantClear(newPtr); // Note: This must absolutely be done AFTER the
- // OleAutomation object is created as Variant Clear
- // will result in a Release being performed on the
- // Dispatch object
- OS.GlobalFree(newPtr);
- }
-}
-/**
- * Returns the Java boolean represented by this Variant.
- *
- * <p>If this Variant does not contain a Java boolean, an attempt is made to
- * coerce the Variant type into a Java boolean. If this fails, an error is thrown.
- *
- * @return the Java boolean represented by this Variant
- *
- * @exception SWTException <ul>
- * <li>ERROR_CANNOT_CHANGE_VARIANT_TYPE when type of Variant can not be coerced into a boolean</li>
- * </ul>
- *
- */
-public boolean getBoolean() {
- if (type == COM.VT_EMPTY) {
- OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, -1);
- }
- if (type == COM.VT_BOOL) {
- return booleanData;
- }
-
- // try to coerce the value to the desired type
- int /*long*/ oldPtr = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, sizeof);
- int /*long*/ newPtr = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, sizeof);
- try {
- getData(oldPtr);
- int result = COM.VariantChangeType(newPtr, oldPtr, (short) 0, COM.VT_BOOL);
- if (result != COM.S_OK)
- OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, result);
- Variant boolVar = new Variant();
- boolVar.setData(newPtr);
- return boolVar.getBoolean();
- } finally {
- COM.VariantClear(oldPtr);
- OS.GlobalFree(oldPtr);
- COM.VariantClear(newPtr);
- OS.GlobalFree(newPtr);
- }
-}
-/**
- * Returns a pointer to the referenced data represented by this Variant.
- *
- * <p>If this Variant does not contain a reference to data, zero is returned.
- *
- * @return a pointer to the referenced data represented by this Variant or 0
- *
- */
-public int /*long*/ getByRef() {
- if (type == COM.VT_EMPTY) {
- OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, -1);
- }
- if ((type & COM.VT_BYREF)== COM.VT_BYREF) {
- return byRefPtr;
- }
-
- return 0;
-}
-/**
- * Returns the Java byte represented by this Variant.
- *
- * <p>If this Variant does not contain a Java byte, an attempt is made to
- * coerce the Variant type into a Java byte. If this fails, an error is thrown.
- *
- * @return the Java byte represented by this Variant
- *
- * @exception SWTException <ul>
- * <li>ERROR_CANNOT_CHANGE_VARIANT_TYPE when type of Variant can not be coerced into a byte</li>
- * </ul>
- *
- * @since 3.3
- */
-public byte getByte() {
- if (type == COM.VT_EMPTY) {
- OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, -1);
- }
- if (type == COM.VT_I1) {
- return byteData;
- }
-
- // try to coerce the value to the desired type
- int /*long*/ oldPtr = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, sizeof);
- int /*long*/ newPtr = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, sizeof);
- try {
- getData(oldPtr);
- int result = COM.VariantChangeType(newPtr, oldPtr, (short) 0, COM.VT_I1);
- if (result != COM.S_OK)
- OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, result);
- Variant byteVar = new Variant();
- byteVar.setData(newPtr);
- return byteVar.getByte();
- } finally {
- COM.VariantClear(oldPtr);
- OS.GlobalFree(oldPtr);
- COM.VariantClear(newPtr);
- OS.GlobalFree(newPtr);
- }
-}
-/**
- * Returns the Java char represented by this Variant.
- *
- * <p>If this Variant does not contain a Java char, an attempt is made to
- * coerce the Variant type into a Java char. If this fails, an error is thrown.
- *
- * @return the Java char represented by this Variant
- *
- * @exception SWTException <ul>
- * <li>ERROR_CANNOT_CHANGE_VARIANT_TYPE when type of Variant can not be coerced into a char</li>
- * </ul>
- *
- * @since 3.3
- */
-public char getChar() {
- if (type == COM.VT_EMPTY) {
- OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, -1);
- }
- if (type == COM.VT_UI2) {
- return charData;
- }
-
- // try to coerce the value to the desired type
- int /*long*/ oldPtr = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, sizeof);
- int /*long*/ newPtr = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, sizeof);
- try {
- getData(oldPtr);
- int result = COM.VariantChangeType(newPtr, oldPtr, (short) 0, COM.VT_UI2);
- if (result != COM.S_OK)
- OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, result);
- Variant charVar = new Variant();
- charVar.setData(newPtr);
- return charVar.getChar();
- } finally {
- COM.VariantClear(oldPtr);
- OS.GlobalFree(oldPtr);
- COM.VariantClear(newPtr);
- OS.GlobalFree(newPtr);
- }
-}
-void getData(int /*long*/ pData){
- if (pData == 0) OLE.error(OLE.ERROR_OUT_OF_MEMORY);
-
- COM.VariantInit(pData);
-
- if ((type & COM.VT_BYREF) == COM.VT_BYREF) {
- //TODO - use VARIANT structure
- COM.MoveMemory(pData, new short[] {type}, 2);
- COM.MoveMemory(pData + 8, new int /*long*/[]{byRefPtr}, OS.PTR_SIZEOF);
- return;
- }
-
- switch (type) {
- case COM.VT_EMPTY :
- case COM.VT_NULL :
- COM.MoveMemory(pData, new short[] {type}, 2);
- break;
- case COM.VT_BOOL :
- COM.MoveMemory(pData, new short[] {type}, 2);
- COM.MoveMemory(pData + 8, new short[]{(booleanData) ? COM.VARIANT_TRUE : COM.VARIANT_FALSE}, 2);
- break;
- case COM.VT_I1 :
- COM.MoveMemory(pData, new short[] {type}, 2);
- COM.MoveMemory(pData + 8, new byte[]{byteData}, 1);
- break;
- case COM.VT_I2 :
- COM.MoveMemory(pData, new short[] {type}, 2);
- COM.MoveMemory(pData + 8, new short[]{shortData}, 2);
- break;
- case COM.VT_UI2 :
- COM.MoveMemory(pData, new short[] {type}, 2);
- COM.MoveMemory(pData + 8, new char[]{charData}, 2);
- break;
- case COM.VT_I4 :
- COM.MoveMemory(pData, new short[] {type}, 2);
- COM.MoveMemory(pData + 8, new int[]{intData}, 4);
- break;
- case COM.VT_I8 :
- COM.MoveMemory(pData, new short[] {type}, 2);
- COM.MoveMemory(pData + 8, new long[]{longData}, 8);
- break;
- case COM.VT_R4 :
- COM.MoveMemory(pData, new short[] {type}, 2);
- COM.MoveMemory(pData + 8, new float[]{floatData}, 4);
- break;
- case COM.VT_R8 :
- COM.MoveMemory(pData, new short[] {type}, 2);
- COM.MoveMemory(pData + 8, new double[]{doubleData}, 8);
- break;
- case COM.VT_DISPATCH :
- dispatchData.AddRef();
- COM.MoveMemory(pData, new short[] {type}, 2);
- COM.MoveMemory(pData + 8, new int /*long*/[]{dispatchData.getAddress()}, OS.PTR_SIZEOF);
- break;
- case COM.VT_UNKNOWN :
- unknownData.AddRef();
- COM.MoveMemory(pData, new short[] {type}, 2);
- COM.MoveMemory(pData + 8, new int /*long*/[]{unknownData.getAddress()}, OS.PTR_SIZEOF);
- break;
- case COM.VT_BSTR :
- COM.MoveMemory(pData, new short[] {type}, 2);
- char[] data = (stringData+"\0").toCharArray();
- int /*long*/ ptr = COM.SysAllocString(data);
- COM.MoveMemory(pData + 8, new int /*long*/[] {ptr}, OS.PTR_SIZEOF);
- break;
-
- default :
- OLE.error(SWT.ERROR_NOT_IMPLEMENTED);
- }
-}
-/**
- * Returns the Java double represented by this Variant.
- *
- * <p>If this Variant does not contain a Java double, an attempt is made to
- * coerce the Variant type into a Java double. If this fails, an error is thrown.
- *
- * @return the Java double represented by this Variant
- *
- * @exception SWTException <ul>
- * <li>ERROR_CANNOT_CHANGE_VARIANT_TYPE when type of Variant can not be coerced into a double</li>
- * </ul>
- *
- * @since 3.2
- */
-public double getDouble() {
- if (type == COM.VT_EMPTY) {
- OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, -1);
- }
- if (type == COM.VT_R8) {
- return doubleData;
- }
-
- // try to coerce the value to the desired type
- int /*long*/ oldPtr = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, sizeof);
- int /*long*/ newPtr = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, sizeof);
- try {
- getData(oldPtr);
- int result = COM.VariantChangeType(newPtr, oldPtr, (short) 0, COM.VT_R8);
- if (result != COM.S_OK)
- OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, result);
- Variant doubleVar = new Variant();
- doubleVar.setData(newPtr);
- return doubleVar.getDouble();
- } finally {
- COM.VariantClear(oldPtr);
- OS.GlobalFree(oldPtr);
- COM.VariantClear(newPtr);
- OS.GlobalFree(newPtr);
- }
-}
-
-/**
- * Returns the Java float represented by this Variant.
- *
- * <p>If this Variant does not contain a Java float, an attempt is made to
- * coerce the Variant type into a Java float. If this fails, an error is thrown.
- *
- * @return the Java float represented by this Variant
- *
- * @exception SWTException <ul>
- * <li>ERROR_CANNOT_CHANGE_VARIANT_TYPE when type of Variant can not be coerced into a float</li>
- * </ul>
- */
-public float getFloat() {
- if (type == COM.VT_EMPTY) {
- OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, -1);
- }
- if (type == COM.VT_R4) {
- return floatData;
- }
-
- // try to coerce the value to the desired type
- int /*long*/ oldPtr = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, sizeof);
- int /*long*/ newPtr = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, sizeof);
- try {
- getData(oldPtr);
- int result = COM.VariantChangeType(newPtr, oldPtr, (short) 0, COM.VT_R4);
- if (result != COM.S_OK)
- OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, result);
- Variant floatVar = new Variant();
- floatVar.setData(newPtr);
- return floatVar.getFloat();
- } finally {
- COM.VariantClear(oldPtr);
- OS.GlobalFree(oldPtr);
- COM.VariantClear(newPtr);
- OS.GlobalFree(newPtr);
- }
-
-}
-/**
- * Returns the Java int represented by this Variant.
- *
- * <p>If this Variant does not contain a Java int, an attempt is made to
- * coerce the Variant type into a Java int. If this fails, an error is thrown.
- *
- * @return the Java int represented by this Variant
- *
- * @exception SWTException <ul>
- * <li>ERROR_CANNOT_CHANGE_VARIANT_TYPE when type of Variant can not be coerced into a int</li>
- * </ul>
- */
-public int getInt() {
- if (type == COM.VT_EMPTY) {
- OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, -1);
- }
- if (type == COM.VT_I4) {
- return intData;
- }
-
- // try to coerce the value to the desired type
- int /*long*/ oldPtr = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, sizeof);
- int /*long*/ newPtr = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, sizeof);
- try {
- getData(oldPtr);
- int result = COM.VariantChangeType(newPtr, oldPtr, (short) 0, COM.VT_I4);
- if (result != COM.S_OK)
- OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, result);
- Variant intVar = new Variant();
- intVar.setData(newPtr);
- return intVar.getInt();
- } finally {
- COM.VariantClear(oldPtr);
- OS.GlobalFree(oldPtr);
- COM.VariantClear(newPtr);
- OS.GlobalFree(newPtr);
- }
-}
-/**
- * Returns the Java long represented by this Variant.
- *
- * <p>If this Variant does not contain a Java long, an attempt is made to
- * coerce the Variant type into a Java long. If this fails, an error is thrown.
- *
- * @return the Java long represented by this Variant
- *
- * @exception SWTException <ul>
- * <li>ERROR_CANNOT_CHANGE_VARIANT_TYPE when type of Variant can not be coerced into a long</li>
- * </ul>
- *
- * @since 3.2
- */
-public long getLong() {
- if (type == COM.VT_EMPTY) {
- OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, -1);
- }
- if (type == COM.VT_I8) {
- return longData;
- }
-
- // try to coerce the value to the desired type
- int /*long*/ oldPtr = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, sizeof);
- int /*long*/ newPtr = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, sizeof);
- try {
- getData(oldPtr);
- int result = COM.VariantChangeType(newPtr, oldPtr, (short) 0, COM.VT_I8);
- if (result != COM.S_OK)
- OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, result);
- Variant longVar = new Variant();
- longVar.setData(newPtr);
- return longVar.getLong();
- } finally {
- COM.VariantClear(oldPtr);
- OS.GlobalFree(oldPtr);
- COM.VariantClear(newPtr);
- OS.GlobalFree(newPtr);
- }
-}
-/**
- * Returns the Java short represented by this Variant.
- *
- * <p>If this Variant does not contain a Java short, an attempt is made to
- * coerce the Variant type into a Java short. If this fails, an error is thrown.
- *
- * @return the Java short represented by this Variant
- *
- * @exception SWTException <ul>
- * <li>ERROR_CANNOT_CHANGE_VARIANT_TYPE when type of Variant can not be coerced into a short</li>
- * </ul>
- */
-public short getShort() {
- if (type == COM.VT_EMPTY) {
- OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, -1);
- }
- if (type == COM.VT_I2) {
- return shortData;
- }
-
- // try to coerce the value to the desired type
- int /*long*/ oldPtr = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, sizeof);
- int /*long*/ newPtr = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, sizeof);
- try {
- getData(oldPtr);
- int result = COM.VariantChangeType(newPtr, oldPtr, (short) 0, COM.VT_I2);
- if (result != COM.S_OK)
- OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, result);
- Variant shortVar = new Variant();
- shortVar.setData(newPtr);
- return shortVar.getShort();
- } finally {
- COM.VariantClear(oldPtr);
- OS.GlobalFree(oldPtr);
- COM.VariantClear(newPtr);
- OS.GlobalFree(newPtr);
- }
-
-}
-/**
- * Returns the Java String represented by this Variant.
- *
- * <p>If this Variant does not contain a Java String, an attempt is made to
- * coerce the Variant type into a Java String. If this fails, an error is thrown.
- *
- * @return the Java String represented by this Variant
- *
- * @exception SWTException <ul>
- * <li>ERROR_CANNOT_CHANGE_VARIANT_TYPE when type of Variant can not be coerced into a String</li>
- * </ul>
- */
-public String getString() {
- if (type == COM.VT_EMPTY) {
- OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, -1);
- }
- if (type == COM.VT_BSTR) {
- return stringData;
- }
-
- // try to coerce the value to the desired type
- int /*long*/ oldPtr = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, sizeof);
- int /*long*/ newPtr = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, sizeof);
- try {
- getData(oldPtr);
- int result = COM.VariantChangeType(newPtr, oldPtr, (short) 0, COM.VT_BSTR);
- if (result != COM.S_OK)
- OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, result);
-
- Variant stringVar = new Variant();
- stringVar.setData(newPtr);
- return stringVar.getString();
-
- } finally {
- COM.VariantClear(oldPtr);
- OS.GlobalFree(oldPtr);
- COM.VariantClear(newPtr);
- OS.GlobalFree(newPtr);
- }
-}
-/**
- * Returns the type of the variant type. This will be an OLE.VT_* value or
- * a bitwise combination of OLE.VT_* values as in the case of
- * OLE.VT_BSTR | OLE.VT_BYREF.
- *
- * @return the type of the variant data
- *
- * @since 2.0
- */
-public short getType() {
- return type;
-}
-/**
- * Returns the IUnknown object represented by this Variant.
- *
- * <p>If this Variant does not contain an IUnknown object, an attempt is made to
- * coerce the Variant type into an IUnknown object. If this fails, an error is
- * thrown.
- *
- * @return the IUnknown object represented by this Variant
- *
- * @exception SWTException <ul>
- * <li>ERROR_CANNOT_CHANGE_VARIANT_TYPE when type of Variant can not be coerced into
- * an IUnknown object</li>
- * </ul>
- */
-public IUnknown getUnknown() {
- if (type == COM.VT_EMPTY) {
- OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, -1);
- }
- if (type == COM.VT_UNKNOWN) {
- return unknownData;
- }
-
- // try to coerce the value to the desired type
- int /*long*/ oldPtr = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, sizeof);
- int /*long*/ newPtr = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, sizeof);
- try {
- getData(oldPtr);
- int result = COM.VariantChangeType(newPtr, oldPtr, (short) 0, COM.VT_UNKNOWN);
- if (result != COM.S_OK)
- OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, result);
- Variant unknownVar = new Variant();
- unknownVar.setData(newPtr);
- return unknownVar.getUnknown();
- } finally {
- COM.VariantClear(oldPtr);
- OS.GlobalFree(oldPtr);
- COM.VariantClear(newPtr); // Note: This must absolutely be done AFTER the
- // IUnknown object is created as Variant Clear
- // will result in a Release being performed on the
- // Dispatch object
- OS.GlobalFree(newPtr);
- }
-}
-/**
- * Update the by reference value of this variant with a new boolean value.
- *
- * @param val the new boolean value
- *
- * @exception SWTException <ul>
- * <li>ERROR_CANNOT_CHANGE_VARIANT_TYPE when type of Variant is not
- * a (VT_BYREF | VT_BOOL) object</li>
- * </ul>
- *
- * @since 2.1
- */
-public void setByRef(boolean val) {
- if ((type & COM.VT_BYREF) == 0 || (type & COM.VT_BOOL) == 0) {
- OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE);
- }
- COM.MoveMemory(byRefPtr, new short[]{val ? COM.VARIANT_TRUE : COM.VARIANT_FALSE}, 2);
-}
-/**
- * Update the by reference value of this variant with a new float value.
- *
- * @param val the new float value
- *
- * @exception SWTException <ul>
- * <li>ERROR_CANNOT_CHANGE_VARIANT_TYPE when type of Variant is not
- * a (VT_BYREF | VT_R4) object</li>
- * </ul>
- *
- * @since 2.1
- */
-public void setByRef(float val) {
- if ((type & COM.VT_BYREF) == 0 || (type & COM.VT_R4) == 0) {
- OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE);
- }
- COM.MoveMemory(byRefPtr, new float[]{val}, 4);
-}
-/**
- * Update the by reference value of this variant with a new integer value.
- *
- * @param val the new integer value
- *
- * @exception SWTException <ul>
- * <li>ERROR_CANNOT_CHANGE_VARIANT_TYPE when type of Variant is not a (VT_BYREF | VT_I4) object</li>
- * </ul>
- *
- * @since 2.1
- */
-public void setByRef(int /*long*/ val) {
- if ((type & COM.VT_BYREF) == 0 || (type & COM.VT_I4) == 0) {
- OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE);
- }
- COM.MoveMemory(byRefPtr, new int /*long*/[]{val}, OS.PTR_SIZEOF);
-}
-/**
- * Update the by reference value of this variant with a new short value.
- *
- * @param val the new short value
- *
- * @exception SWTException <ul>
- * <li>ERROR_CANNOT_CHANGE_VARIANT_TYPE when type of Variant is not a (VT_BYREF | VT_I2) object
- * </ul>
- *
- * @since 2.1
- */
-public void setByRef(short val) {
- if ((type & COM.VT_BYREF) == 0 || (type & COM.VT_I2) == 0) {
- OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE);
- }
- COM.MoveMemory(byRefPtr, new short[]{val}, 2);
-}
-
-void setData(int /*long*/ pData){
- if (pData == 0) OLE.error(OLE.ERROR_INVALID_ARGUMENT);
-
- //TODO - use VARIANT structure
- short[] dataType = new short[1];
- COM.MoveMemory(dataType, pData, 2);
- type = dataType[0];
-
- if ((type & COM.VT_BYREF) == COM.VT_BYREF) {
- int /*long*/[] newByRefPtr = new int /*long*/[1];
- OS.MoveMemory(newByRefPtr, pData + 8, OS.PTR_SIZEOF);
- byRefPtr = newByRefPtr[0];
- return;
- }
-
- switch (type) {
- case COM.VT_EMPTY :
- case COM.VT_NULL :
- break;
- case COM.VT_BOOL :
- short[] newBooleanData = new short[1];
- COM.MoveMemory(newBooleanData, pData + 8, 2);
- booleanData = (newBooleanData[0] != COM.VARIANT_FALSE);
- break;
- case COM.VT_I1 :
- byte[] newByteData = new byte[1];
- COM.MoveMemory(newByteData, pData + 8, 1);
- byteData = newByteData[0];
- break;
- case COM.VT_I2 :
- short[] newShortData = new short[1];
- COM.MoveMemory(newShortData, pData + 8, 2);
- shortData = newShortData[0];
- break;
- case COM.VT_UI2 :
- char[] newCharData = new char[1];
- COM.MoveMemory(newCharData, pData + 8, 2);
- charData = newCharData[0];
- break;
- case COM.VT_I4 :
- int[] newIntData = new int[1];
- OS.MoveMemory(newIntData, pData + 8, 4);
- intData = newIntData[0];
- break;
- case COM.VT_I8 :
- long[] newLongData = new long[1];
- OS.MoveMemory(newLongData, pData + 8, 8);
- longData = newLongData[0];
- break;
- case COM.VT_R4 :
- float[] newFloatData = new float[1];
- COM.MoveMemory(newFloatData, pData + 8, 4);
- floatData = newFloatData[0];
- break;
- case COM.VT_R8 :
- double[] newDoubleData = new double[1];
- COM.MoveMemory(newDoubleData, pData + 8, 8);
- doubleData = newDoubleData[0];
- break;
- case COM.VT_DISPATCH : {
- int /*long*/[] ppvObject = new int /*long*/[1];
- OS.MoveMemory(ppvObject, pData + 8, OS.PTR_SIZEOF);
- if (ppvObject[0] == 0) {
- type = COM.VT_EMPTY;
- break;
- }
- dispatchData = new IDispatch(ppvObject[0]);
- dispatchData.AddRef();
- break;
- }
- case COM.VT_UNKNOWN : {
- int /*long*/[] ppvObject = new int /*long*/[1];
- OS.MoveMemory(ppvObject, pData + 8, OS.PTR_SIZEOF);
- if (ppvObject[0] == 0) {
- type = COM.VT_EMPTY;
- break;
- }
- unknownData = new IUnknown(ppvObject[0]);
- unknownData.AddRef();
- break;
- }
- case COM.VT_BSTR :
- // get the address of the memory in which the string resides
- int /*long*/[] hMem = new int /*long*/[1];
- OS.MoveMemory(hMem, pData + 8, OS.PTR_SIZEOF);
- if (hMem[0] == 0) {
- type = COM.VT_EMPTY;
- break;
- }
- // Get the size of the string from the OS - the size is expressed in number
- // of bytes - each unicode character is 2 bytes.
- int size = COM.SysStringByteLen(hMem[0]);
- if (size > 0){
- // get the unicode character array from the global memory and create a String
- char[] buffer = new char[(size + 1) /2]; // add one to avoid rounding errors
- COM.MoveMemory(buffer, hMem[0], size);
- stringData = new String(buffer);
- } else {
- stringData = ""; //$NON-NLS-1$
- }
- break;
-
- default :
- // try coercing it into one of the known forms
- int /*long*/ newPData = OS.GlobalAlloc(OS.GMEM_FIXED | OS.GMEM_ZEROINIT, sizeof);
- if (COM.VariantChangeType(newPData, pData, (short) 0, COM.VT_R4) == COM.S_OK) {
- setData(newPData);
- } else if (COM.VariantChangeType(newPData, pData, (short) 0, COM.VT_I4) == COM.S_OK) {
- setData(newPData);
- } else if (COM.VariantChangeType(newPData, pData, (short) 0, COM.VT_BSTR) == COM.S_OK) {
- setData(newPData);
- }
- COM.VariantClear(newPData);
- OS.GlobalFree(newPData);
- break;
- }
-}
-
-/**
- * Returns a string containing a concise, human-readable
- * description of the receiver.
- *
- * @return a string representation of the Variant
- */
-public String toString () {
- switch (type) {
- case COM.VT_BOOL :
- return "VT_BOOL{"+booleanData+"}";
- case COM.VT_I1 :
- return "VT_I1{"+byteData+"}";
- case COM.VT_I2 :
- return "VT_I2{"+shortData+"}";
- case COM.VT_UI2 :
- return "VT_UI2{"+charData+"}";
- case COM.VT_I4 :
- return "VT_I4{"+intData+"}";
- case COM.VT_I8 :
- return "VT_I8{"+longData+"}";
- case COM.VT_R4 :
- return "VT_R4{"+floatData+"}";
- case COM.VT_R8 :
- return "VT_R8{"+doubleData+"}";
- case COM.VT_BSTR :
- return "VT_BSTR{"+stringData+"}";
- case COM.VT_DISPATCH :
- return "VT_DISPATCH{"+(dispatchData == null ? 0 : dispatchData.getAddress())+"}";
- case COM.VT_UNKNOWN :
- return "VT_UNKNOWN{"+(unknownData == null ? 0 : unknownData.getAddress())+"}";
- case COM.VT_EMPTY :
- return "VT_EMPTY";
- case COM.VT_NULL :
- return "VT_NULL";
- }
- if ((type & COM.VT_BYREF) != 0) {
- return "VT_BYREF|"+(type & ~COM.VT_BYREF)+"{"+byRefPtr+"}";
- }
- return "Unsupported Type "+type;
-}
-}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/package.html b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/package.html
deleted file mode 100755
index 93c5fd16a4..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/package.html
+++ /dev/null
@@ -1,20 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
-<html>
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <meta name="Author" content="IBM">
- <title>Package-level Javadoc</title>
-</head>
-<body>
-SWT Win32 OLE implementation classes.
-<h2>
-Package Specification</h2>
-This package contains the classes which provide the public API to the
-the Microsoft Win32 Object Linking and Embedding mechanism
-that the win32 variant of SWT is capable of using.
-<p>
-Referencing any of the classes in this package directly guarantees
-that the code is platform specific.
-</p>
-</body>
-</html>