SF2963102 use varargs in Dispatch instead of a million overloaded methods
This commit is contained in:
@@ -15,3 +15,4 @@ foo.foo
|
||||
foo.ser
|
||||
JacobVersion.properties
|
||||
.settings
|
||||
setenv.sh
|
||||
|
||||
@@ -2,7 +2,7 @@ JACOB (Java-COM bridge) is hosted on Sourceforge http://sourceforge.net/project/
|
||||
|
||||
Information about what's new in this release can be found in docs/ReleaseNotes.html
|
||||
|
||||
Instructions on building this project can be found in docs/HowToBuild.html
|
||||
Instructions on building this project can be found in docs/BuildingJacobFromSource.html
|
||||
Detailed instructions on creating a build configuration file are in build.xml
|
||||
|
||||
Put the appropriate DLL for your platform into your runtime library path.
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
<property name="generated.filename.zip" value="jacob-${version}" />
|
||||
<property name="generated.filename.version" value="JacobVersion.properties" />
|
||||
|
||||
<property name="junit.jar" value="${basedir}\lib\junit3.8.1\junit.jar" />
|
||||
<property name="junit.jar" value="${basedir}/lib/junit3.8.1/junit.jar" />
|
||||
|
||||
<property name="src.java.mainroot" value="${basedir}/src" />
|
||||
<property name="src.java.samples" value="${basedir}/samples" />
|
||||
|
||||
@@ -120,6 +120,10 @@ Sympton: Can't find jni.h or can't find C++ compiler<p>
|
||||
Problem: compilation_tools.properties configured incorrectly. Either
|
||||
paths are wrong or the separator is wrong. It requires two backslashes for a separator.<p>
|
||||
</li>
|
||||
<li>
|
||||
Symptom: Ant fails with the message <CODE> Could not create task or type of type: junit.</CODE>.<p>
|
||||
Problem: junit.jar must be copied from this project to the $ANT_HOME/lib directory.<p>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h1> Running Samples and Tests </h1>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<HTML>
|
||||
<BODY>
|
||||
<!-- --------- -->
|
||||
<h2>JACOB 1.15 M2</h2>
|
||||
<h2>JACOB 1.15 M4</h2>
|
||||
<h3>What's New</h3>
|
||||
<ul>
|
||||
<li>
|
||||
@@ -54,6 +54,11 @@
|
||||
<tr>
|
||||
<td colspan="2"><b>Feature Requests</b></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="13%" valign="top">2963102</td>
|
||||
<td width="87%" valign="top">Convert API to use var args and remove the many overloaded Dispatch
|
||||
methods that each added one more parameter.(M4)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="13%" valign="top"> </td>
|
||||
<td width="87%" valign="top"> </td>
|
||||
|
||||
BIN
samples/com/jacob/samples/office/TestDocument.doc
Normal file
BIN
samples/com/jacob/samples/office/TestDocument.doc
Normal file
Binary file not shown.
@@ -1,5 +1,7 @@
|
||||
package com.jacob.samples.office;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import com.jacob.activeX.ActiveXComponent;
|
||||
import com.jacob.com.ComException;
|
||||
import com.jacob.com.Dispatch;
|
||||
@@ -7,6 +9,8 @@ import com.jacob.com.Variant;
|
||||
|
||||
/**
|
||||
* Submitted to the Jacob SourceForge web site as a sample 3/2005
|
||||
* <p>
|
||||
* This sample is BROKEN because it doesn't call quit!
|
||||
*
|
||||
* @author Date Created Description Jason Twist 04 Mar 2005 Code opens a locally
|
||||
* stored Word document and extracts the Built In properties and Custom
|
||||
@@ -137,7 +141,9 @@ public class WordDocumentProperties {
|
||||
WordDocumentProperties jacTest = new WordDocumentProperties();
|
||||
|
||||
// Open the word doc
|
||||
jacTest.open("\\\\Saturn\\documentstorage\\s.doc");
|
||||
File doc = new File(
|
||||
"samples/com/jacob/samples/office/TestDocument.doc");
|
||||
jacTest.open(doc.getAbsolutePath());
|
||||
|
||||
// Set Custom Properties
|
||||
jacTest.selectCustomDocumentProperitiesMode();
|
||||
|
||||
BIN
samples/com/jacob/samples/office/~$stDocument.doc
Normal file
BIN
samples/com/jacob/samples/office/~$stDocument.doc
Normal file
Binary file not shown.
@@ -117,9 +117,9 @@ public class ActiveXComponent extends Dispatch {
|
||||
}
|
||||
|
||||
/**
|
||||
* Most code should use the standard ActiveXComponent(String) constructor and
|
||||
* not this factory method. This method exists for applications that need
|
||||
* special behavior. <B>Experimental in release 1.9.2.</B>
|
||||
* Most code should use the standard ActiveXComponent(String) constructor
|
||||
* and not this factory method. This method exists for applications that
|
||||
* need special behavior. <B>Experimental in release 1.9.2.</B>
|
||||
* <p>
|
||||
* Factory that returns a Dispatch wrapped around the result of a
|
||||
* getActiveObject() call. This differs from the standard constructor in
|
||||
@@ -150,6 +150,7 @@ public class ActiveXComponent extends Dispatch {
|
||||
/**
|
||||
* @see com.jacob.com.Dispatch#finalize()
|
||||
*/
|
||||
@Override
|
||||
protected void finalize() {
|
||||
super.finalize();
|
||||
}
|
||||
@@ -382,58 +383,12 @@ public class ActiveXComponent extends Dispatch {
|
||||
* makes a dispatch call for the passed in action and single parameter
|
||||
*
|
||||
* @param callAction
|
||||
* @param parameter
|
||||
* @param parameters
|
||||
* @return ActiveXComponent representing the results of the call
|
||||
*/
|
||||
public ActiveXComponent invokeGetComponent(String callAction,
|
||||
Variant parameter) {
|
||||
return new ActiveXComponent(invoke(callAction, parameter).toDispatch());
|
||||
}
|
||||
|
||||
/**
|
||||
* makes a dispatch call for the passed in action and single parameter
|
||||
*
|
||||
* @param callAction
|
||||
* @param parameter1
|
||||
* @param parameter2
|
||||
* @return ActiveXComponent representing the results of the call
|
||||
*/
|
||||
public ActiveXComponent invokeGetComponent(String callAction,
|
||||
Variant parameter1, Variant parameter2) {
|
||||
return new ActiveXComponent(invoke(callAction, parameter1, parameter2)
|
||||
.toDispatch());
|
||||
}
|
||||
|
||||
/**
|
||||
* makes a dispatch call for the passed in action and single parameter
|
||||
*
|
||||
* @param callAction
|
||||
* @param parameter1
|
||||
* @param parameter2
|
||||
* @param parameter3
|
||||
* @return ActiveXComponent representing the results of the call
|
||||
*/
|
||||
public ActiveXComponent invokeGetComponent(String callAction,
|
||||
Variant parameter1, Variant parameter2, Variant parameter3) {
|
||||
return new ActiveXComponent(invoke(callAction, parameter1, parameter2,
|
||||
parameter3).toDispatch());
|
||||
}
|
||||
|
||||
/**
|
||||
* makes a dispatch call for the passed in action and single parameter
|
||||
*
|
||||
* @param callAction
|
||||
* @param parameter1
|
||||
* @param parameter2
|
||||
* @param parameter3
|
||||
* @param parameter4
|
||||
* @return ActiveXComponent representing the results of the call
|
||||
*/
|
||||
public ActiveXComponent invokeGetComponent(String callAction,
|
||||
Variant parameter1, Variant parameter2, Variant parameter3,
|
||||
Variant parameter4) {
|
||||
return new ActiveXComponent(invoke(callAction, parameter1, parameter2,
|
||||
parameter3, parameter4).toDispatch());
|
||||
Variant... parameters) {
|
||||
return new ActiveXComponent(invoke(callAction, parameters).toDispatch());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -499,61 +454,6 @@ public class ActiveXComponent extends Dispatch {
|
||||
new Variant(parameter2));
|
||||
}
|
||||
|
||||
/**
|
||||
* makes a dispatch call for the passed in action and single parameter
|
||||
*
|
||||
* @param callAction
|
||||
* @param parameter
|
||||
* @return a Variant but that may be null for some calls
|
||||
*/
|
||||
public Variant invoke(String callAction, Variant parameter) {
|
||||
return Dispatch.call(this, callAction, parameter);
|
||||
}
|
||||
|
||||
/**
|
||||
* makes a dispatch call for the passed in action and two parameter
|
||||
*
|
||||
* @param callAction
|
||||
* @param parameter1
|
||||
* @param parameter2
|
||||
* @return a Variant but that may be null for some calls
|
||||
*/
|
||||
public Variant invoke(String callAction, Variant parameter1,
|
||||
Variant parameter2) {
|
||||
return Dispatch.call(this, callAction, parameter1, parameter2);
|
||||
}
|
||||
|
||||
/**
|
||||
* makes a dispatch call for the passed in action and two parameter
|
||||
*
|
||||
* @param callAction
|
||||
* @param parameter1
|
||||
* @param parameter2
|
||||
* @param parameter3
|
||||
* @return Variant result data
|
||||
*/
|
||||
public Variant invoke(String callAction, Variant parameter1,
|
||||
Variant parameter2, Variant parameter3) {
|
||||
return Dispatch.call(this, callAction, parameter1, parameter2,
|
||||
parameter3);
|
||||
}
|
||||
|
||||
/**
|
||||
* calls call() with 4 variant parameters
|
||||
*
|
||||
* @param callAction
|
||||
* @param parameter1
|
||||
* @param parameter2
|
||||
* @param parameter3
|
||||
* @param parameter4
|
||||
* @return Variant result data
|
||||
*/
|
||||
public Variant invoke(String callAction, Variant parameter1,
|
||||
Variant parameter2, Variant parameter3, Variant parameter4) {
|
||||
return Dispatch.call(this, callAction, parameter1, parameter2,
|
||||
parameter3, parameter4);
|
||||
}
|
||||
|
||||
/**
|
||||
* makes a dispatch call for the passed in action and no parameter
|
||||
*
|
||||
@@ -572,7 +472,7 @@ public class ActiveXComponent extends Dispatch {
|
||||
* @param args
|
||||
* @return Variant returned by the invoke (Dispatch.callN)
|
||||
*/
|
||||
public Variant invoke(String name, Variant[] args) {
|
||||
public Variant invoke(String name, Variant... args) {
|
||||
return Dispatch.callN(this, name, args);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,21 +1,19 @@
|
||||
/*
|
||||
* Copyright (c) 1999-2004 Sourceforge JACOB Project.
|
||||
* All rights reserved. Originator: Dan Adler (http://danadler.com).
|
||||
* Get more information about JACOB at http://sourceforge.net/projects/jacob-project
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Copyright (c) 1999-2004 Sourceforge JACOB Project. All rights reserved. Originator: Dan Adler
|
||||
* (http://danadler.com). Get more information about JACOB at
|
||||
* http://sourceforge.net/projects/jacob-project
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it under the terms of the
|
||||
* GNU Lesser General Public License as published by the Free Software Foundation; either version
|
||||
* 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
|
||||
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with this library;
|
||||
* if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA
|
||||
*/
|
||||
package com.jacob.com;
|
||||
|
||||
@@ -235,6 +233,7 @@ public class Dispatch extends JacobObject {
|
||||
*
|
||||
* @see java.lang.Object#finalize()
|
||||
*/
|
||||
@Override
|
||||
protected void finalize() {
|
||||
safeRelease();
|
||||
}
|
||||
@@ -244,6 +243,7 @@ public class Dispatch extends JacobObject {
|
||||
*
|
||||
* @see com.jacob.com.JacobObject#safeRelease()
|
||||
*/
|
||||
@Override
|
||||
public void safeRelease() {
|
||||
super.safeRelease();
|
||||
if (isAttached()) {
|
||||
@@ -380,11 +380,10 @@ public class Dispatch extends JacobObject {
|
||||
* an array of argument objects
|
||||
*/
|
||||
public static void callSubN(Dispatch dispatchTarget, String name,
|
||||
Object[] args) {
|
||||
Object... args) {
|
||||
throwIfUnattachedDispatch(dispatchTarget);
|
||||
invokeSubv(dispatchTarget, name, Dispatch.Method | Dispatch.Get,
|
||||
VariantUtilities.objectsToVariants(args),
|
||||
new int[args.length]);
|
||||
VariantUtilities.objectsToVariants(args), new int[args.length]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -394,11 +393,10 @@ public class Dispatch extends JacobObject {
|
||||
* an array of argument objects
|
||||
*/
|
||||
public static void callSubN(Dispatch dispatchTarget, int dispID,
|
||||
Object[] args) {
|
||||
Object... args) {
|
||||
throwIfUnattachedDispatch(dispatchTarget);
|
||||
invokeSubv(dispatchTarget, dispID, Dispatch.Method | Dispatch.Get,
|
||||
VariantUtilities.objectsToVariants(args),
|
||||
new int[args.length]);
|
||||
VariantUtilities.objectsToVariants(args), new int[args.length]);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -450,11 +448,10 @@ public class Dispatch extends JacobObject {
|
||||
* @return Variant returned by call
|
||||
*/
|
||||
public static Variant callN(Dispatch dispatchTarget, String name,
|
||||
Object[] args) {
|
||||
Object... args) {
|
||||
throwIfUnattachedDispatch(dispatchTarget);
|
||||
return invokev(dispatchTarget, name, Dispatch.Method | Dispatch.Get,
|
||||
VariantUtilities.objectsToVariants(args),
|
||||
new int[args.length]);
|
||||
VariantUtilities.objectsToVariants(args), new int[args.length]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -464,11 +461,10 @@ public class Dispatch extends JacobObject {
|
||||
* @return Variant returned by call
|
||||
*/
|
||||
public static Variant callN(Dispatch dispatchTarget, int dispID,
|
||||
Object[] args) {
|
||||
Object... args) {
|
||||
throwIfUnattachedDispatch(dispatchTarget);
|
||||
return invokev(dispatchTarget, dispID, Dispatch.Method | Dispatch.Get,
|
||||
VariantUtilities.objectsToVariants(args),
|
||||
new int[args.length]);
|
||||
VariantUtilities.objectsToVariants(args), new int[args.length]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -536,128 +532,13 @@ public class Dispatch extends JacobObject {
|
||||
/**
|
||||
* @param dispatchTarget
|
||||
* @param name
|
||||
* @param a1
|
||||
* @param attributes
|
||||
* @return Variant returned by underlying callN
|
||||
*/
|
||||
public static Variant call(Dispatch dispatchTarget, String name, Object a1) {
|
||||
public static Variant call(Dispatch dispatchTarget, String name,
|
||||
Object... attributes) {
|
||||
throwIfUnattachedDispatch(dispatchTarget);
|
||||
return callN(dispatchTarget, name, new Object[] { a1 });
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dispatchTarget
|
||||
* @param name
|
||||
* @param a1
|
||||
* @param a2
|
||||
* @return Variant returned by underlying callN
|
||||
*/
|
||||
public static Variant call(Dispatch dispatchTarget, String name, Object a1,
|
||||
Object a2) {
|
||||
throwIfUnattachedDispatch(dispatchTarget);
|
||||
return callN(dispatchTarget, name, new Object[] { a1, a2 });
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dispatchTarget
|
||||
* @param name
|
||||
* @param a1
|
||||
* @param a2
|
||||
* @param a3
|
||||
* @return Variant returned by underlying callN
|
||||
*/
|
||||
public static Variant call(Dispatch dispatchTarget, String name, Object a1,
|
||||
Object a2, Object a3) {
|
||||
throwIfUnattachedDispatch(dispatchTarget);
|
||||
return callN(dispatchTarget, name, new Object[] { a1, a2, a3 });
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dispatchTarget
|
||||
* @param name
|
||||
* @param a1
|
||||
* @param a2
|
||||
* @param a3
|
||||
* @param a4
|
||||
* @return Variant retuned by underlying callN
|
||||
*/
|
||||
public static Variant call(Dispatch dispatchTarget, String name, Object a1,
|
||||
Object a2, Object a3, Object a4) {
|
||||
throwIfUnattachedDispatch(dispatchTarget);
|
||||
return callN(dispatchTarget, name, new Object[] { a1, a2, a3, a4 });
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dispatchTarget
|
||||
* @param name
|
||||
* @param a1
|
||||
* @param a2
|
||||
* @param a3
|
||||
* @param a4
|
||||
* @param a5
|
||||
* @return Variant returned by underlying callN
|
||||
*/
|
||||
public static Variant call(Dispatch dispatchTarget, String name, Object a1,
|
||||
Object a2, Object a3, Object a4, Object a5) {
|
||||
throwIfUnattachedDispatch(dispatchTarget);
|
||||
return callN(dispatchTarget, name, new Object[] { a1, a2, a3, a4, a5 });
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dispatchTarget
|
||||
* @param name
|
||||
* @param a1
|
||||
* @param a2
|
||||
* @param a3
|
||||
* @param a4
|
||||
* @param a5
|
||||
* @param a6
|
||||
* @return Variant retuned by underlying callN
|
||||
*/
|
||||
public static Variant call(Dispatch dispatchTarget, String name, Object a1,
|
||||
Object a2, Object a3, Object a4, Object a5, Object a6) {
|
||||
throwIfUnattachedDispatch(dispatchTarget);
|
||||
return callN(dispatchTarget, name, new Object[] { a1, a2, a3, a4, a5,
|
||||
a6 });
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dispatchTarget
|
||||
* @param name
|
||||
* @param a1
|
||||
* @param a2
|
||||
* @param a3
|
||||
* @param a4
|
||||
* @param a5
|
||||
* @param a6
|
||||
* @param a7
|
||||
* @return Variant returned by underlying callN
|
||||
*/
|
||||
public static Variant call(Dispatch dispatchTarget, String name, Object a1,
|
||||
Object a2, Object a3, Object a4, Object a5, Object a6, Object a7) {
|
||||
throwIfUnattachedDispatch(dispatchTarget);
|
||||
return callN(dispatchTarget, name, new Object[] { a1, a2, a3, a4, a5,
|
||||
a6, a7 });
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dispatchTarget
|
||||
* @param name
|
||||
* @param a1
|
||||
* @param a2
|
||||
* @param a3
|
||||
* @param a4
|
||||
* @param a5
|
||||
* @param a6
|
||||
* @param a7
|
||||
* @param a8
|
||||
* @return Variant retuned by underlying callN
|
||||
*/
|
||||
public static Variant call(Dispatch dispatchTarget, String name, Object a1,
|
||||
Object a2, Object a3, Object a4, Object a5, Object a6, Object a7,
|
||||
Object a8) {
|
||||
throwIfUnattachedDispatch(dispatchTarget);
|
||||
return callN(dispatchTarget, name, new Object[] { a1, a2, a3, a4, a5,
|
||||
a6, a7, a8 });
|
||||
return callN(dispatchTarget, name, attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -673,129 +554,15 @@ public class Dispatch extends JacobObject {
|
||||
/**
|
||||
* @param dispatchTarget
|
||||
* @param dispid
|
||||
* @param a1
|
||||
* @param attributes
|
||||
* var arg list of attributes that will be passed to the
|
||||
* underlying function
|
||||
* @return Variant returned by underlying callN
|
||||
*/
|
||||
public static Variant call(Dispatch dispatchTarget, int dispid, Object a1) {
|
||||
public static Variant call(Dispatch dispatchTarget, int dispid,
|
||||
Object... attributes) {
|
||||
throwIfUnattachedDispatch(dispatchTarget);
|
||||
return callN(dispatchTarget, dispid, new Object[] { a1 });
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dispatchTarget
|
||||
* @param dispid
|
||||
* @param a1
|
||||
* @param a2
|
||||
* @return Variant returned by underlying callN
|
||||
*/
|
||||
public static Variant call(Dispatch dispatchTarget, int dispid, Object a1,
|
||||
Object a2) {
|
||||
throwIfUnattachedDispatch(dispatchTarget);
|
||||
return callN(dispatchTarget, dispid, new Object[] { a1, a2 });
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dispatchTarget
|
||||
* @param dispid
|
||||
* @param a1
|
||||
* @param a2
|
||||
* @param a3
|
||||
* @return Variant returned by underlying callN
|
||||
*/
|
||||
public static Variant call(Dispatch dispatchTarget, int dispid, Object a1,
|
||||
Object a2, Object a3) {
|
||||
throwIfUnattachedDispatch(dispatchTarget);
|
||||
return callN(dispatchTarget, dispid, new Object[] { a1, a2, a3 });
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dispatchTarget
|
||||
* @param dispid
|
||||
* @param a1
|
||||
* @param a2
|
||||
* @param a3
|
||||
* @param a4
|
||||
* @return Variant returned by underlying callN
|
||||
*/
|
||||
public static Variant call(Dispatch dispatchTarget, int dispid, Object a1,
|
||||
Object a2, Object a3, Object a4) {
|
||||
throwIfUnattachedDispatch(dispatchTarget);
|
||||
return callN(dispatchTarget, dispid, new Object[] { a1, a2, a3, a4 });
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dispatchTarget
|
||||
* @param dispid
|
||||
* @param a1
|
||||
* @param a2
|
||||
* @param a3
|
||||
* @param a4
|
||||
* @param a5
|
||||
* @return Variant returned by underlying callN
|
||||
*/
|
||||
public static Variant call(Dispatch dispatchTarget, int dispid, Object a1,
|
||||
Object a2, Object a3, Object a4, Object a5) {
|
||||
throwIfUnattachedDispatch(dispatchTarget);
|
||||
return callN(dispatchTarget, dispid,
|
||||
new Object[] { a1, a2, a3, a4, a5 });
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dispatchTarget
|
||||
* @param dispid
|
||||
* @param a1
|
||||
* @param a2
|
||||
* @param a3
|
||||
* @param a4
|
||||
* @param a5
|
||||
* @param a6
|
||||
* @return Variant returned by underlying callN
|
||||
*/
|
||||
public static Variant call(Dispatch dispatchTarget, int dispid, Object a1,
|
||||
Object a2, Object a3, Object a4, Object a5, Object a6) {
|
||||
throwIfUnattachedDispatch(dispatchTarget);
|
||||
return callN(dispatchTarget, dispid, new Object[] { a1, a2, a3, a4, a5,
|
||||
a6 });
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dispatchTarget
|
||||
* @param dispid
|
||||
* @param a1
|
||||
* @param a2
|
||||
* @param a3
|
||||
* @param a4
|
||||
* @param a5
|
||||
* @param a6
|
||||
* @param a7
|
||||
* @return Variant returned by underlying callN
|
||||
*/
|
||||
public static Variant call(Dispatch dispatchTarget, int dispid, Object a1,
|
||||
Object a2, Object a3, Object a4, Object a5, Object a6, Object a7) {
|
||||
throwIfUnattachedDispatch(dispatchTarget);
|
||||
return callN(dispatchTarget, dispid, new Object[] { a1, a2, a3, a4, a5,
|
||||
a6, a7 });
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dispatchTarget
|
||||
* @param dispid
|
||||
* @param a1
|
||||
* @param a2
|
||||
* @param a3
|
||||
* @param a4
|
||||
* @param a5
|
||||
* @param a6
|
||||
* @param a7
|
||||
* @param a8
|
||||
* @return Variant returned by underlying callN
|
||||
*/
|
||||
public static Variant call(Dispatch dispatchTarget, int dispid, Object a1,
|
||||
Object a2, Object a3, Object a4, Object a5, Object a6, Object a7,
|
||||
Object a8) {
|
||||
throwIfUnattachedDispatch(dispatchTarget);
|
||||
return callN(dispatchTarget, dispid, new Object[] { a1, a2, a3, a4, a5,
|
||||
a6, a7, a8 });
|
||||
return callN(dispatchTarget, dispid, attributes);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -910,8 +677,8 @@ public class Dispatch extends JacobObject {
|
||||
public static void invokeSub(Dispatch dispatchTarget, String name,
|
||||
int dispid, int lcid, int wFlags, Object[] oArg, int[] uArgErr) {
|
||||
throwIfUnattachedDispatch(dispatchTarget);
|
||||
invokeSubv(dispatchTarget, name, dispid, lcid, wFlags,
|
||||
VariantUtilities.objectsToVariants(oArg), uArgErr);
|
||||
invokeSubv(dispatchTarget, name, dispid, lcid, wFlags, VariantUtilities
|
||||
.objectsToVariants(oArg), uArgErr);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -968,133 +735,14 @@ public class Dispatch extends JacobObject {
|
||||
*
|
||||
* @param dispatchTarget
|
||||
* @param name
|
||||
* @param a1
|
||||
* @param attributes
|
||||
* var args list of attributes to be passed to underlying
|
||||
* functions
|
||||
*/
|
||||
public static void callSub(Dispatch dispatchTarget, String name, Object a1) {
|
||||
public static void callSub(Dispatch dispatchTarget, String name,
|
||||
Object... attributes) {
|
||||
throwIfUnattachedDispatch(dispatchTarget);
|
||||
callSubN(dispatchTarget, name, new Object[] { a1 });
|
||||
}
|
||||
|
||||
/**
|
||||
* makes call to native callSubN
|
||||
*
|
||||
* @param dispatchTarget
|
||||
* @param name
|
||||
* @param a1
|
||||
* @param a2
|
||||
*/
|
||||
public static void callSub(Dispatch dispatchTarget, String name, Object a1,
|
||||
Object a2) {
|
||||
throwIfUnattachedDispatch(dispatchTarget);
|
||||
callSubN(dispatchTarget, name, new Object[] { a1, a2 });
|
||||
}
|
||||
|
||||
/**
|
||||
* makes call to native callSubN
|
||||
*
|
||||
* @param dispatchTarget
|
||||
* @param name
|
||||
* @param a1
|
||||
* @param a2
|
||||
* @param a3
|
||||
*/
|
||||
public static void callSub(Dispatch dispatchTarget, String name, Object a1,
|
||||
Object a2, Object a3) {
|
||||
throwIfUnattachedDispatch(dispatchTarget);
|
||||
callSubN(dispatchTarget, name, new Object[] { a1, a2, a3 });
|
||||
}
|
||||
|
||||
/**
|
||||
* makes call to native callSubN
|
||||
*
|
||||
* @param dispatchTarget
|
||||
* @param name
|
||||
* @param a1
|
||||
* @param a2
|
||||
* @param a3
|
||||
* @param a4
|
||||
*/
|
||||
public static void callSub(Dispatch dispatchTarget, String name, Object a1,
|
||||
Object a2, Object a3, Object a4) {
|
||||
throwIfUnattachedDispatch(dispatchTarget);
|
||||
callSubN(dispatchTarget, name, new Object[] { a1, a2, a3, a4 });
|
||||
}
|
||||
|
||||
/**
|
||||
* makes call to native callSubN
|
||||
*
|
||||
* @param dispatchTarget
|
||||
* @param name
|
||||
* @param a1
|
||||
* @param a2
|
||||
* @param a3
|
||||
* @param a4
|
||||
* @param a5
|
||||
*/
|
||||
public static void callSub(Dispatch dispatchTarget, String name, Object a1,
|
||||
Object a2, Object a3, Object a4, Object a5) {
|
||||
throwIfUnattachedDispatch(dispatchTarget);
|
||||
callSubN(dispatchTarget, name, new Object[] { a1, a2, a3, a4, a5 });
|
||||
}
|
||||
|
||||
/**
|
||||
* makes call to native callSubN
|
||||
*
|
||||
* @param dispatchTarget
|
||||
* @param name
|
||||
* @param a1
|
||||
* @param a2
|
||||
* @param a3
|
||||
* @param a4
|
||||
* @param a5
|
||||
* @param a6
|
||||
*/
|
||||
public static void callSub(Dispatch dispatchTarget, String name, Object a1,
|
||||
Object a2, Object a3, Object a4, Object a5, Object a6) {
|
||||
throwIfUnattachedDispatch(dispatchTarget);
|
||||
callSubN(dispatchTarget, name, new Object[] { a1, a2, a3, a4, a5, a6 });
|
||||
}
|
||||
|
||||
/**
|
||||
* makes call to native callSubN
|
||||
*
|
||||
* @param dispatchTarget
|
||||
* @param name
|
||||
* @param a1
|
||||
* @param a2
|
||||
* @param a3
|
||||
* @param a4
|
||||
* @param a5
|
||||
* @param a6
|
||||
* @param a7
|
||||
*/
|
||||
public static void callSub(Dispatch dispatchTarget, String name, Object a1,
|
||||
Object a2, Object a3, Object a4, Object a5, Object a6, Object a7) {
|
||||
throwIfUnattachedDispatch(dispatchTarget);
|
||||
callSubN(dispatchTarget, name, new Object[] { a1, a2, a3, a4, a5, a6,
|
||||
a7 });
|
||||
}
|
||||
|
||||
/**
|
||||
* makes call to native callSubN
|
||||
*
|
||||
* @param dispatchTarget
|
||||
* @param name
|
||||
* @param a1
|
||||
* @param a2
|
||||
* @param a3
|
||||
* @param a4
|
||||
* @param a5
|
||||
* @param a6
|
||||
* @param a7
|
||||
* @param a8
|
||||
*/
|
||||
public static void callSub(Dispatch dispatchTarget, String name, Object a1,
|
||||
Object a2, Object a3, Object a4, Object a5, Object a6, Object a7,
|
||||
Object a8) {
|
||||
throwIfUnattachedDispatch(dispatchTarget);
|
||||
callSubN(dispatchTarget, name, new Object[] { a1, a2, a3, a4, a5, a6,
|
||||
a7, a8 });
|
||||
callSubN(dispatchTarget, name, attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1113,132 +761,14 @@ public class Dispatch extends JacobObject {
|
||||
*
|
||||
* @param dispatchTarget
|
||||
* @param dispid
|
||||
* @param a1
|
||||
* @param attributes
|
||||
* var args list of attributes to be passed to underlying
|
||||
* function
|
||||
*/
|
||||
public static void callSub(Dispatch dispatchTarget, int dispid, Object a1) {
|
||||
public static void callSub(Dispatch dispatchTarget, int dispid,
|
||||
Object... attributes) {
|
||||
throwIfUnattachedDispatch(dispatchTarget);
|
||||
callSubN(dispatchTarget, dispid, new Object[] { a1 });
|
||||
}
|
||||
|
||||
/**
|
||||
* makes call to native callSubN
|
||||
*
|
||||
* @param dispatchTarget
|
||||
* @param dispid
|
||||
* @param a1
|
||||
* @param a2
|
||||
*/
|
||||
public static void callSub(Dispatch dispatchTarget, int dispid, Object a1,
|
||||
Object a2) {
|
||||
throwIfUnattachedDispatch(dispatchTarget);
|
||||
callSubN(dispatchTarget, dispid, new Object[] { a1, a2 });
|
||||
}
|
||||
|
||||
/**
|
||||
* makes call to native callSubN
|
||||
*
|
||||
* @param dispatchTarget
|
||||
* @param dispid
|
||||
* @param a1
|
||||
* @param a2
|
||||
* @param a3
|
||||
*/
|
||||
public static void callSub(Dispatch dispatchTarget, int dispid, Object a1,
|
||||
Object a2, Object a3) {
|
||||
callSubN(dispatchTarget, dispid, new Object[] { a1, a2, a3 });
|
||||
}
|
||||
|
||||
/**
|
||||
* makes call to native callSubN
|
||||
*
|
||||
* @param dispatchTarget
|
||||
* @param dispid
|
||||
* @param a1
|
||||
* @param a2
|
||||
* @param a3
|
||||
* @param a4
|
||||
*/
|
||||
public static void callSub(Dispatch dispatchTarget, int dispid, Object a1,
|
||||
Object a2, Object a3, Object a4) {
|
||||
throwIfUnattachedDispatch(dispatchTarget);
|
||||
callSubN(dispatchTarget, dispid, new Object[] { a1, a2, a3, a4 });
|
||||
}
|
||||
|
||||
/**
|
||||
* makes call to native callSubN
|
||||
*
|
||||
* @param dispatchTarget
|
||||
* @param dispid
|
||||
* @param a1
|
||||
* @param a2
|
||||
* @param a3
|
||||
* @param a4
|
||||
* @param a5
|
||||
*/
|
||||
public static void callSub(Dispatch dispatchTarget, int dispid, Object a1,
|
||||
Object a2, Object a3, Object a4, Object a5) {
|
||||
throwIfUnattachedDispatch(dispatchTarget);
|
||||
callSubN(dispatchTarget, dispid, new Object[] { a1, a2, a3, a4, a5 });
|
||||
}
|
||||
|
||||
/**
|
||||
* makes call to native callSubN
|
||||
*
|
||||
* @param dispatchTarget
|
||||
* @param dispid
|
||||
* @param a1
|
||||
* @param a2
|
||||
* @param a3
|
||||
* @param a4
|
||||
* @param a5
|
||||
* @param a6
|
||||
*/
|
||||
public static void callSub(Dispatch dispatchTarget, int dispid, Object a1,
|
||||
Object a2, Object a3, Object a4, Object a5, Object a6) {
|
||||
throwIfUnattachedDispatch(dispatchTarget);
|
||||
callSubN(dispatchTarget, dispid,
|
||||
new Object[] { a1, a2, a3, a4, a5, a6 });
|
||||
}
|
||||
|
||||
/**
|
||||
* makes call to native callSubN
|
||||
*
|
||||
* @param dispatchTarget
|
||||
* @param dispid
|
||||
* @param a1
|
||||
* @param a2
|
||||
* @param a3
|
||||
* @param a4
|
||||
* @param a5
|
||||
* @param a6
|
||||
* @param a7
|
||||
*/
|
||||
public static void callSub(Dispatch dispatchTarget, int dispid, Object a1,
|
||||
Object a2, Object a3, Object a4, Object a5, Object a6, Object a7) {
|
||||
throwIfUnattachedDispatch(dispatchTarget);
|
||||
callSubN(dispatchTarget, dispid, new Object[] { a1, a2, a3, a4, a5, a6,
|
||||
a7 });
|
||||
}
|
||||
|
||||
/**
|
||||
* makes call to native callSubN
|
||||
*
|
||||
* @param dispatchTarget
|
||||
* @param dispid
|
||||
* @param a1
|
||||
* @param a2
|
||||
* @param a3
|
||||
* @param a4
|
||||
* @param a5
|
||||
* @param a6
|
||||
* @param a7
|
||||
* @param a8
|
||||
*/
|
||||
public static void callSub(Dispatch dispatchTarget, int dispid, Object a1,
|
||||
Object a2, Object a3, Object a4, Object a5, Object a6, Object a7,
|
||||
Object a8) {
|
||||
callSubN(dispatchTarget, dispid, new Object[] { a1, a2, a3, a4, a5, a6,
|
||||
a7, a8 });
|
||||
callSubN(dispatchTarget, dispid, attributes);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1315,4 +845,4 @@ public class Dispatch extends JacobObject {
|
||||
throw new NotImplementedException("not implemented yet");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,7 +63,6 @@ public class JacobObject {
|
||||
"true".equalsIgnoreCase(System.getProperty("com.jacob.debug"));
|
||||
|
||||
protected static boolean isDebugEnabled() {
|
||||
// return true;
|
||||
return DEBUG;
|
||||
}
|
||||
|
||||
|
||||
@@ -213,11 +213,16 @@ public final class VariantUtilities {
|
||||
*/
|
||||
protected static Variant[] objectsToVariants(
|
||||
Object[] arrayOfObjectsToBeConverted) {
|
||||
Variant vArg[] = new Variant[arrayOfObjectsToBeConverted.length];
|
||||
for (int i = 0; i < arrayOfObjectsToBeConverted.length; i++) {
|
||||
vArg[i] = objectToVariant(arrayOfObjectsToBeConverted[i]);
|
||||
if (arrayOfObjectsToBeConverted instanceof Variant[]) {
|
||||
// just return the passed in array if it is a Variant array
|
||||
return (Variant[]) arrayOfObjectsToBeConverted;
|
||||
} else {
|
||||
Variant vArg[] = new Variant[arrayOfObjectsToBeConverted.length];
|
||||
for (int i = 0; i < arrayOfObjectsToBeConverted.length; i++) {
|
||||
vArg[i] = objectToVariant(arrayOfObjectsToBeConverted[i]);
|
||||
}
|
||||
return vArg;
|
||||
}
|
||||
return vArg;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -32,14 +32,9 @@ public class LibraryLoaderTest extends TestCase {
|
||||
* verify LibraryLoader.JACOB_DLL_NAME is read by LibraryLoader
|
||||
*/
|
||||
public void testJacobDllNameSystemProperty() {
|
||||
// fill with bad dll name
|
||||
System.setProperty(LibraryLoader.JACOB_DLL_NAME, "xxx");
|
||||
try {
|
||||
LibraryLoader.loadJacobLibrary();
|
||||
fail("Should have been unable to load dll with name xxx");
|
||||
} catch (UnsatisfiedLinkError ule) {
|
||||
// yes, this is what we want to see when using a bad name
|
||||
}
|
||||
// this test used to run in the reverse order but that caused
|
||||
// ClassDefNotFound on DEBUG
|
||||
|
||||
// no way to clear a system property once set so lets try setting to
|
||||
// default
|
||||
System.setProperty(LibraryLoader.JACOB_DLL_NAME, LibraryLoader
|
||||
@@ -52,6 +47,16 @@ public class LibraryLoaderTest extends TestCase {
|
||||
+ LibraryLoader.getPreferredDLLName() + " "
|
||||
+ ule.getMessage());
|
||||
}
|
||||
|
||||
// fill with bad dll name and try again
|
||||
System.setProperty(LibraryLoader.JACOB_DLL_NAME, "xxx");
|
||||
try {
|
||||
LibraryLoader.loadJacobLibrary();
|
||||
fail("Should have been unable to load dll with name xxx");
|
||||
} catch (UnsatisfiedLinkError ule) {
|
||||
System.out.println("correctly caught UnsatisfiedLinkError");
|
||||
// yes, this is what we want to see when using a bad name
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -11,6 +11,35 @@ import com.jacob.test.BaseTestCase;
|
||||
*/
|
||||
public class VariantUtilitiesTest extends BaseTestCase {
|
||||
|
||||
/**
|
||||
* verifies our unpacking stuff
|
||||
*/
|
||||
public void testObjectsToVariants() {
|
||||
Object testArray[] = new Object[] { Integer.valueOf(1),
|
||||
Integer.valueOf(2) };
|
||||
Variant resultArray[] = VariantUtilities.objectsToVariants(testArray);
|
||||
assertEquals(2, resultArray.length);
|
||||
|
||||
Variant resultArray2[] = VariantUtilities
|
||||
.objectsToVariants(resultArray);
|
||||
assertEquals(2, resultArray2.length);
|
||||
assertSame(resultArray[0], resultArray2[0]);
|
||||
assertSame(resultArray[1], resultArray2[1]);
|
||||
}
|
||||
|
||||
/**
|
||||
* test nested arrays
|
||||
*/
|
||||
public void testObjectsToVariantNestedArray() {
|
||||
Object testArray[] = new Object[] { Integer.valueOf(1),
|
||||
Integer.valueOf(2) };
|
||||
Object testArrayOuter[] = new Object[] { testArray };
|
||||
Variant resultArray[] = VariantUtilities
|
||||
.objectsToVariants(testArrayOuter);
|
||||
// should be a SafeArray
|
||||
assertEquals(1, resultArray.length);
|
||||
}
|
||||
|
||||
/**
|
||||
* verify that dispatch can convert from object to variant and that the
|
||||
* variant holds the right value
|
||||
|
||||
@@ -25,7 +25,7 @@ public class IETest extends BaseTestCase {
|
||||
/**
|
||||
* well known address we can navigate to
|
||||
*/
|
||||
private String testUrls[] = {
|
||||
private final String testUrls[] = {
|
||||
"http://sourceforge.net/projects/jacob-project",
|
||||
"http://www.google.com" };
|
||||
|
||||
@@ -70,6 +70,7 @@ public class IETest extends BaseTestCase {
|
||||
+ Thread.currentThread().getName());
|
||||
|
||||
if (aThread.threadFailedWithException != null) {
|
||||
aThread.threadFailedWithException.printStackTrace();
|
||||
fail("caught an unexpected exception "
|
||||
+ aThread.threadFailedWithException);
|
||||
}
|
||||
@@ -113,6 +114,7 @@ class IETestThread extends Thread {
|
||||
/**
|
||||
* Run through the addresses passed in via the constructor
|
||||
*/
|
||||
@Override
|
||||
public void run() {
|
||||
// pick a time that lets sourceforge respond (in msec)
|
||||
int delay = 3000;
|
||||
|
||||
@@ -5,26 +5,65 @@ package com.jacob.test.windowsmedia;
|
||||
* that says you get a random "can't map name to dispid" when
|
||||
* getting the URL from the player
|
||||
* <p>
|
||||
* this doesn't actually play for some reason. It always says the length is 0.
|
||||
* <p>
|
||||
* May need to run with some command line options (including from inside Eclipse).
|
||||
* Look in the docs area at the Jacob usage document for command line options.
|
||||
* <p>
|
||||
*/
|
||||
import java.io.File;
|
||||
|
||||
import com.jacob.activeX.ActiveXComponent;
|
||||
import com.jacob.com.Dispatch;
|
||||
import com.jacob.com.Variant;
|
||||
import com.jacob.test.BaseTestCase;
|
||||
|
||||
public class WMPlayer extends BaseTestCase {
|
||||
|
||||
/**
|
||||
* This should demo the media player but it doesn't
|
||||
*/
|
||||
public void testOpenWMPlayer() {
|
||||
// this file exists in windows 7 installations
|
||||
File file = new File(
|
||||
"C:/Windows/winsxs/x86_microsoft-windows-videosamples_31bf3856ad364e35_6.1.7600.16385_none_f583837f77a63ec7");
|
||||
String filePath = file.getAbsolutePath();
|
||||
String microsoftTestURL = filePath;
|
||||
// use these instead if not on windows 7
|
||||
// "http://support.microsoft.com/support/mediaplayer/wmptest/samples/new/mediaexample.wma";
|
||||
// "http://support.microsoft.com/support/mediaplayer/wmptest/samples/new/mediaexample.wmv";
|
||||
ActiveXComponent wmp = null;
|
||||
wmp = new ActiveXComponent("WMPlayer.OCX");
|
||||
// could use WMPlayer.OCX alias also
|
||||
wmp = new ActiveXComponent(
|
||||
"CLSID:{6BF52A52-394A-11D3-B153-00C04F79FAA6}");// ("WMPlayer.OCX");
|
||||
|
||||
wmp.setProperty("URL", microsoftTestURL);
|
||||
assertEquals(wmp.getProperty("URL").toString(), microsoftTestURL);
|
||||
|
||||
// alternative way to get the controls
|
||||
Dispatch controls = Dispatch.get(wmp, "controls").toDispatch();
|
||||
Dispatch.call(controls, "Play");
|
||||
// the sourceforge posting didn't post all the code so this is all we
|
||||
// have we need some other information on how to set the document
|
||||
// so that we have a url to open
|
||||
|
||||
// pause to let it play a second or two
|
||||
try {
|
||||
Thread.sleep(1500);
|
||||
} catch (InterruptedException e) {
|
||||
System.out.println("Thread interrupted");
|
||||
}
|
||||
for (int i = 0; i < 1000; i++) {
|
||||
System.out.println("the wmp url is "
|
||||
+ wmp.getProperty("URL").toString());
|
||||
// Get media object
|
||||
Dispatch vMedObj = wmp.getProperty("currentMedia").toDispatch();
|
||||
// Get duration of media object
|
||||
Variant vdur = Dispatch.call(vMedObj, "duration");
|
||||
// why is this always 0?
|
||||
// System.out.println(microsoftTestURL + " length is "
|
||||
// + vdur.getDouble());
|
||||
// System.out.println("the wmp url is "
|
||||
// + wmp.getProperty("URL").toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user