Statically link DLL to remove need for VC++ installation

2762275 support conversion of arrays of primitives
2171967 throw exception for unexpected data types rather than crash VM
This commit is contained in:
clay_shooter
2009-06-08 01:10:43 +00:00
parent ae08cf32d0
commit a79a1a08ca
9 changed files with 232 additions and 66 deletions

View File

@@ -13,5 +13,5 @@ release
.cdtproject
foo.foo
foo.ser
JacobVersion.properties
.settings

View File

@@ -16,10 +16,10 @@
The file for MS Visual C++ 8.0 building 32 and 64 bit
(releases up to 1.11 only supported 32 builds) looks something like:
JDK=c:\\dev\\jdk1.5.0_15
MSDEV_DIR=c:\\dev\\Microsoft Visual Studio 8\\VC
MSDEV_IDE_DIR=c:\\dev\\Microsoft Visual Studio 8\\Common7\\IDE
version=1.14.1
JDK=c:\\dev\\jdk1.5.0_18
MSDEV_DIR=c:\\Program Files\\Microsoft Visual Studio 8\\VC
MSDEV_IDE_DIR=c:\\Program Files\\Microsoft Visual Studio 8\\Common7\\IDE
version=1.15-M1
DO NOT check compilation_tools.properties into source control as the
values are specific to YOUR environment.
@@ -275,7 +275,7 @@
<arg value="/D _USRDLL"/>
<arg value="/D _WINDLL" />
<!-- create a multi threaded dll -->
<arg value="/MD"/>
<arg value="/MT"/>
<!-- raise the warning level from the default -->
<!-- <arg value="/Wp64"/> -->
<arg value="/W3" />
@@ -307,7 +307,7 @@
<arg value="/D _USRDLL"/>
<arg value="/D _WINDLL" />
<!-- create a multi threaded dll -->
<arg value="/MD"/>
<arg value="/MT"/>
<!-- raise the warning level from the default -->
<!-- <arg value="/Wp64"/> -->
<arg value="/W3" />

View File

@@ -38,10 +38,10 @@ Eclipse 3.3 with the C/C++ module and JDK 1.5.
In that situation, you would just create the <i>compilation_tools.properties</i>
using the example build.xml as a template.
<UL>
<li> Microsoft Visual C++ 8.0 and it's included library. (to D:\apps in my case)
<li> Eclipse 3.3 or later from www.eclipse.org as the Java IDE.
<li> Eclipse 3.3 or later with the C/C++ plugin can be used for C coding in place of VC++ IDE.
<li> Java JDK 1.5 (1.14 was built using 1.5.0.11)
<li> Microsoft Visual C++ 8.0 and it's included library. (to C:\ProgramFiles in my case)
<li> Eclipse 3.4 or later from www.eclipse.org as the Java IDE.
<li> Eclipse 3.4 or later with the C/C++ plugin can be used for C coding in place of VC++ IDE.
<li> Java JDK 1.5 (1.15 was built using 1.5.0.16)
</ul>
<p>
<p>
@@ -56,6 +56,7 @@ using the example build.xml as a template.
<TR><TD>1.12</TD><TD>VC 98 (6.0) & 2003 64bit libs</TD><TD>1.4.2</TD><td>1.6.5</td><TD>3.2.2</TD><TD>32 and 64 bit</TD></TR>
<TR><TD>1.13</TD><TD>VC 2005</TD><TD>1.4.2</TD><TD>1.7.0</TD><TD>3.3</TD><TD>32 and 64 bit</TD></TR>
<TR><TD>1.14</TD><TD>VC 2005</TD><TD>1.5.0</TD><TD>1.7.0</TD><TD>3.3</TD><TD>32 and 64 bit</TD></TR>
<TR><TD>1.15</TD><TD>VC 2005</TD><TD>1.5.0</TD><TD>1.7.0</TD><TD>3.4</TD><TD>32 and 64 bit</TD></TR>
</table>
Microsoft Visual C++ 8.0 supports 64 bit builds. so no additional tools are required.
@@ -128,7 +129,7 @@ path variable must be set to include the directory the jacob.dll is in. The
simplest way to do that is to add it as a command line option. The following
assume that your jacob development area is located in c:\dev\jacob:
<pre>
-Djava.library.path=c:/jacob/release/x86
-Djava.library.path=c:/dev/jacob/release/x86
-Dcom.jacob.autogc=false
-Dcom.jacob.debug=false
-Xcheck:jni
@@ -137,7 +138,7 @@ assume that your jacob development area is located in c:\dev\jacob:
JUnit test programs can be individually run from inside eclipse or en-masse
via the <code>ant test</code> target.
Last Modified 4/2008 1.15
Last Modified 10/2008 1.15
</BODY>
</HTML>

View File

@@ -1,11 +1,60 @@
<HTML>
<BODY>
<!-- --------- -->
<h2>JACOB 1.15 M1</h2>
<h3>What's New</h3>
<ul>
<li>
MS Libraries are now statically linked using /MT instead of /MD to reduce issues library compatability issues, especially on older platforms.
</li>
</ul>
<h3>Tracked Changes</h3>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" >
<tr>
<td colspan="2"><b>Bugs</b></td>
</tr>
<tr>
<td width="13%" valign="top">&nbsp;</td>
<td width="87%" valign="top">&nbsp;</td>
</tr>
<tr>
<td colspan="2"><b>Patches</b></td>
</tr>
<tr>
<td width="13%" valign="top">2762275 </td>
<td width="87%" valign="top">Support conversion of primitive arrays to Variant arrays. (M1)</td>
</tr>
<tr>
<td width="13%" valign="top">2171967 </td>
<td width="87%" valign="top">VariantUtils.populateVariant can cause VM crash with unrecognized type.(M1)</td>
</tr>
<tr>
<td width="13%" valign="top">&nbsp;</td>
<td width="87%" valign="top">&nbsp;</td>
</tr>
<tr>
<td colspan="2"><b>Feature Requests</b></td>
</tr>
<tr>
<td width="13%" valign="top">&nbsp;</td>
<td width="87%" valign="top">&nbsp;</td>
</tr>
<tr>
<td colspan="2"><b>Known Issues</b></td>
</tr>
<tr>
<td width="13%" valign="top"></td>
<td width="87%" valign="top"></td>
</tr>
</table>
<!-- --------- -->
<h2>JACOB 1.14.3</h2>
<h3>Tracked Changes</h3>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" >
<tr>
<td width="100%" colspan="2"><b>Bugs</b></td>
<td colspan="2"><b>Bugs</b></td>
</tr>
<tr>
<td width="13%" valign="top">2011706</td>
@@ -22,21 +71,21 @@
<td width="87%" valign="top">&nbsp;</td>
</tr>
<tr>
<td width="100%" colspan="2"><b>Patches</b></td>
<td colspan="2"><b>Patches</b></td>
</tr>
<tr>
<td width="13%" valign="top">&nbsp;</td>
<td width="87%" valign="top">&nbsp;</td>
</tr>
<tr>
<td width="100%" colspan="2"><b>Feature Requests</b></td>
<td colspan="2"><b>Feature Requests</b></td>
</tr>
<tr>
<td width="13%" valign="top">&nbsp;</td>
<td width="87%" valign="top">&nbsp;</td>
</tr>
<tr>
<td width="100%" colspan="2"><b>Known Issues</b></td>
<td colspan="2"><b>Known Issues</b></td>
</tr>
<tr>
<td width="13%" valign="top"></td>
@@ -51,7 +100,7 @@
<h3>Tracked Changes</h3>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" >
<tr>
<td width="100%" colspan="2"><b>Bugs</b></td>
<td colspan="2"><b>Bugs</b></td>
</tr>
<tr>
<td width="13%" valign="top">1919441</td>
@@ -63,21 +112,21 @@
<td width="87%" valign="top">&nbsp;</td>
</tr>
<tr>
<td width="100%" colspan="2"><b>Patches</b></td>
<td colspan="2"><b>Patches</b></td>
</tr>
<tr>
<td width="13%" valign="top">&nbsp;</td>
<td width="87%" valign="top">&nbsp;</td>
</tr>
<tr>
<td width="100%" colspan="2"><b>Feature Requests</b></td>
<td colspan="2"><b>Feature Requests</b></td>
</tr>
<tr>
<td width="13%" valign="top">&nbsp;</td>
<td width="87%" valign="top">&nbsp;</td>
</tr>
<tr>
<td width="100%" colspan="2"><b>Known Issues</b></td>
<td colspan="2"><b>Known Issues</b></td>
</tr>
<tr>
<td width="13%" valign="top"></td>
@@ -102,7 +151,7 @@
<h3>Tracked Changes</h3>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" >
<tr>
<td width="100%" colspan="2"><b>Bugs</b></td>
<td colspan="2"><b>Bugs</b></td>
</tr>
<tr>
<td width="13%" valign="top">1857439</td>
@@ -139,14 +188,14 @@
<td width="87%" valign="top">&nbsp;</td>
</tr>
<tr>
<td width="100%" colspan="2"><b>Patches</b></td>
<td colspan="2"><b>Patches</b></td>
</tr>
<tr>
<td width="13%" valign="top">&nbsp;</td>
<td width="87%" valign="top">&nbsp;</td>
</tr>
<tr>
<td width="100%" colspan="2"><b>Feature Requests</b></td>
<td colspan="2"><b>Feature Requests</b></td>
</tr>
<tr>
<td width="13%" valign="top">1845039 </td>
@@ -181,7 +230,7 @@
<td width="87%" valign="top">&nbsp;</td>
</tr>
<tr>
<td width="100%" colspan="2"><b>Known Issues</b></td>
<td colspan="2"><b>Known Issues</b></td>
</tr>
<tr>
<td width="13%" valign="top"></td>
@@ -214,7 +263,7 @@
<h3>Tracked Changes</h3>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" >
<tr>
<td width="100%" colspan="2"><b>Bugs</b></td>
<td colspan="2"><b>Bugs</b></td>
</tr>
<tr>
<td width="13%" valign="top">1793362</td>
@@ -230,7 +279,7 @@
<td width="87%" valign="top">&nbsp;</td>
</tr>
<tr>
<td width="100%" colspan="2"><b>Patches</b></td>
<td colspan="2"><b>Patches</b></td>
</tr>
<tr>
<td width="13%" valign="top">1794811 </td>
@@ -259,7 +308,7 @@
<td width="87%" valign="top">&nbsp;</td>
</tr>
<tr>
<td width="100%" colspan="2"><b>Feature Requests</b></td>
<td colspan="2"><b>Feature Requests</b></td>
</tr>
<tr>
<td width="13%" valign="top">1772783 </td>
@@ -275,7 +324,7 @@
<td width="87%" valign="top">&nbsp;</td>
</tr>
<tr>
<td width="100%" colspan="2"><b>Known Issues</b></td>
<td colspan="2"><b>Known Issues</b></td>
</tr>
<tr>
<td width="13%" valign="top"></td>
@@ -302,7 +351,7 @@
<h3>Tracked Changes</h3>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" >
<tr>
<td width="100%" colspan="2"><b>Bugs</b></td>
<td colspan="2"><b>Bugs</b></td>
</tr>
<tr>
<td width="13%" valign="top">1651926 </td>
@@ -333,7 +382,7 @@
<td width="87%" valign="top">&nbsp;</td>
</tr>
<tr>
<td width="100%" colspan="2"><b>Patches</b></td>
<td colspan="2"><b>Patches</b></td>
</tr>
<tr>
<td width="13%" valign="top">1674015</td>
@@ -369,7 +418,7 @@
<td width="87%" valign="top">&nbsp;</td>
</tr>
<tr>
<td width="100%" colspan="2"><b>Feature Requests</b></td>
<td colspan="2"><b>Feature Requests</b></td>
</tr>
<tr>
<td width="13%" valign="top">1662887</td>
@@ -388,7 +437,7 @@
<td width="87%" valign="top">&nbsp;</td>
</tr>
<tr>
<td width="100%" colspan="2"><b>Known Issues</b></td>
<td colspan="2"><b>Known Issues</b></td>
</tr>
<tr>
<td width="13%" valign="top">1504120</td>
@@ -417,7 +466,7 @@ Bug fix release
<h3>Tracked Changes</h3>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%">
<tr>
<td width="100%" colspan="2"><b>Bugs</b></td>
<td colspan="2"><b>Bugs</b></td>
</tr>
<tr>
<td width="13%" valign="top">1602188</td>
@@ -439,7 +488,7 @@ Bug fix release
<td width="87%" valign="top">&nbsp;</td>
</tr>
<tr>
<td width="100%" colspan="2"><b>Patches</b></td>
<td colspan="2"><b>Patches</b></td>
</tr>
<tr>
<td width="13%" valign="top">SF1603631</td>
@@ -451,7 +500,7 @@ Bug fix release
<td width="87%" valign="top">&nbsp;</td>
</tr>
<tr>
<td width="100%" colspan="2"><b>Feature Requests</b></td>
<td colspan="2"><b>Feature Requests</b></td>
</tr>
<tr>
<td width="13%" valign="top">&nbsp;</td>
@@ -491,7 +540,7 @@ Bug fix release
<h3>Tracked Changes</h3>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%">
<tr>
<td width="100%" colspan="2"><b>Bugs</b></td>
<td colspan="2"><b>Bugs</b></td>
</tr>
<tr>
<td width="13%" valign="top">1550604</td>
@@ -526,7 +575,7 @@ Bug fix release
<td width="87%" valign="top">&nbsp;</td>
</tr>
<tr>
<td width="100%" colspan="2"><b>Patches</b></td>
<td colspan="2"><b>Patches</b></td>
</tr>
<tr>
<td width="13%" valign="top">SF1493647</td>
@@ -540,7 +589,7 @@ Bug fix release
<td width="87%" valign="top">&nbsp;</td>
</tr>
<tr>
<td width="100%" colspan="2"><b>Feature Requests</b></td>
<td colspan="2"><b>Feature Requests</b></td>
</tr>
<tr>
<td width="13%" valign="top">1580993</td>
@@ -571,7 +620,7 @@ Bug fix release
<h3>Tracked Changes</h3>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%">
<tr>
<td width="100%" colspan="2"><b>Bugs</b></td>
<td colspan="2"><b>Bugs</b></td>
</tr>
<tr>
<td width="13%" valign="top">1474474</td>
@@ -586,14 +635,14 @@ Bug fix release
<td width="87%" valign="top">&nbsp;</td>
</tr>
<tr>
<td width="100%" colspan="2"><b>Patches</b></td>
<td colspan="2"><b>Patches</b></td>
</tr>
<tr>
<td width="13%" valign="top">&nbsp;</td>
<td width="87%" valign="top">&nbsp;</td>
</tr>
<tr>
<td width="100%" colspan="2"><b>Feature Requests</b></td>
<td colspan="2"><b>Feature Requests</b></td>
</tr>
</table>
@@ -641,7 +690,7 @@ Bug fix release
<h3>Tracked Changes</h3>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%">
<tr>
<td width="100%" colspan="2"><b>Bugs</b></td>
<td colspan="2"><b>Bugs</b></td>
</tr>
<tr>
<td width="13%" valign="top">1340233</td>
@@ -671,7 +720,7 @@ Bug fix release
<td width="87%" valign="top">&nbsp;</td>
</tr>
<tr>
<td width="100%" colspan="2"><b>Patches</b></td>
<td colspan="2"><b>Patches</b></td>
</tr>
<tr>
<td width="13%" valign="top">1386454</td>
@@ -690,7 +739,7 @@ Bug fix release
<td width="87%" valign="top">&nbsp;</td>
</tr>
<tr>
<td width="100%" colspan="2"><b>Feature Requests</b></td>
<td colspan="2"><b>Feature Requests</b></td>
</tr>
<tr>
<td width="13%" valign="top">1241037</td>
@@ -752,7 +801,7 @@ Bug fix release
<h3>Tracked Changes</h3>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%">
<tr>
<td width="100%" colspan="2"><b>Bugs</b></td>
<td colspan="2"><b>Bugs</b></td>
</tr>
<tr>
<td width="13%" valign="top">1335897 </td>
@@ -763,7 +812,7 @@ Bug fix release
<td width="87%" valign="top">&nbsp;</td>
</tr>
<tr>
<td width="100%" colspan="2"><b>Patches</b></td>
<td colspan="2"><b>Patches</b></td>
</tr>
<tr>
<td width="13%" valign="top">1314116 </td>
@@ -774,7 +823,7 @@ Bug fix release
<td width="87%" valign="top">&nbsp;</td>
</tr>
<tr>
<td width="100%" colspan="2"><b>Feature Requests</b></td>
<td colspan="2"><b>Feature Requests</b></td>
</tr>
<tr>
<td width="13%" valign="top">1264850</td>
@@ -904,7 +953,7 @@ running this from inside of Eclipse</li>
<h3>Tracked Changes</h3>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%">
<tr>
<td width="100%" colspan="2"><b>Bugs</b></td>
<td colspan="2"><b>Bugs</b></td>
</tr>
<tr>
<td width="13%" valign="top">1116101</td>
@@ -947,7 +996,7 @@ running this from inside of Eclipse</li>
<td width="87%" valign="top">&nbsp;</td>
</tr>
<tr>
<td width="100%" colspan="2"><b>Patches</b></td>
<td colspan="2"><b>Patches</b></td>
</tr>
<tr>
<td width="13%" valign="top">1115187</td>
@@ -974,7 +1023,7 @@ running this from inside of Eclipse</li>
<td width="87%" valign="top">&nbsp;</td>
</tr>
<tr>
<td width="100%" colspan="2"><b>Feature Requests</b></td>
<td colspan="2"><b>Feature Requests</b></td>
</tr>
<tr>
<td width="13%" valign="top">1049390</td>

View File

@@ -114,13 +114,11 @@ public final class VariantUtilities {
// newly added 1.12-pre6 to support VT_VARIANT
targetVariant.putVariant(pValueObject);
} else {
// should really throw an illegal argument exception if its an
// invalid type
if (fByRef) {
targetVariant.putObjectRef(pValueObject);
} else {
targetVariant.putObject(pValueObject);
}
// sourceforge patch 2171967
// used to rely on coercion but sometimes crashed VM
throw new NotImplementedException(
"populateVariant() not implemented for "
+ pValueObject.getClass());
}
}
@@ -131,7 +129,6 @@ public final class VariantUtilities {
* @param objectToBeMadeIntoVariant
* @return Variant that represents the object
*/
@SuppressWarnings("unchecked")
protected static Variant objectToVariant(Object objectToBeMadeIntoVariant) {
if (objectToBeMadeIntoVariant == null) {
return new Variant();
@@ -140,10 +137,14 @@ public final class VariantUtilities {
return (Variant) objectToBeMadeIntoVariant;
} else if (objectToBeMadeIntoVariant.getClass().isArray()) {
// automatically convert arrays using reflection
// handle it differently based on the type of array
// added primitive support sourceforge 2762275
SafeArray sa = null;
int len1 = Array.getLength(objectToBeMadeIntoVariant);
Object first = Array.get(objectToBeMadeIntoVariant, 0);
if (first.getClass().isArray()) {
Class componentType = objectToBeMadeIntoVariant.getClass()
.getComponentType();
if (componentType.isArray()) { // array of arrays
int max = 0;
for (int i = 0; i < len1; i++) {
Object e1 = Array.get(objectToBeMadeIntoVariant, i);
@@ -159,7 +160,32 @@ public final class VariantUtilities {
sa.setVariant(i, j, objectToVariant(Array.get(e1, j)));
}
}
} else if (byte.class.equals(componentType)) {
byte[] arr = (byte[]) objectToBeMadeIntoVariant;
sa = new SafeArray(Variant.VariantByte, len1);
for (int i = 0; i < len1; i++) {
sa.setByte(i, arr[i]);
}
} else if (int.class.equals(componentType)) {
int[] arr = (int[]) objectToBeMadeIntoVariant;
sa = new SafeArray(Variant.VariantInt, len1);
for (int i = 0; i < len1; i++) {
sa.setInt(i, arr[i]);
}
} else if (double.class.equals(componentType)) {
double[] arr = (double[]) objectToBeMadeIntoVariant;
sa = new SafeArray(Variant.VariantDouble, len1);
for (int i = 0; i < len1; i++) {
sa.setDouble(i, arr[i]);
}
} else if (long.class.equals(componentType)) {
long[] arr = (long[]) objectToBeMadeIntoVariant;
sa = new SafeArray(Variant.VariantLongInt, len1);
for (int i = 0; i < len1; i++) {
sa.setLong(i, arr[i]);
}
} else {
// array of object
sa = new SafeArray(Variant.VariantVariant, len1);
for (int i = 0; i < len1; i++) {
sa.setVariant(i, objectToVariant(Array.get(

View File

@@ -1,5 +1,6 @@
package com.jacob.com;
import java.util.Arrays;
import java.util.Date;
import com.jacob.test.BaseTestCase;
@@ -30,4 +31,73 @@ public class VariantUtilitiesTest extends BaseTestCase {
System.out.println("currency returned was: " + someMoneyConverted);
}
public void testPrimitiveByteArray() {
byte[] arr = new byte[] { 1, 2, 3 };
Variant arrVar = VariantUtilities.objectToVariant(arr);
assertNotNull(arrVar);
SafeArray sa = arrVar.toSafeArray();
assertNotNull(sa);
assertEquals(Variant.VariantByte, sa.getvt());
assertEquals(0, sa.getLBound());
assertEquals(2, sa.getUBound());
byte[] bytes = sa.toByteArray();
assertTrue(Arrays.equals(bytes, arr));
}
public void testPrimitiveIntArray() {
int[] arr = new int[] { 1000, 2000, 3 };
Variant arrVar = VariantUtilities.objectToVariant(arr);
assertNotNull(arrVar);
SafeArray sa = arrVar.toSafeArray();
assertNotNull(sa);
assertEquals(Variant.VariantInt, sa.getvt());
assertEquals(0, sa.getLBound());
assertEquals(2, sa.getUBound());
int[] ints = sa.toIntArray();
assertTrue(Arrays.equals(ints, arr));
}
public void testPrimitiveDoubleArray() {
double[] arr = new double[] { 1000, 2000, 3 };
Variant arrVar = VariantUtilities.objectToVariant(arr);
assertNotNull(arrVar);
SafeArray sa = arrVar.toSafeArray();
assertNotNull(sa);
assertEquals(Variant.VariantDouble, sa.getvt());
assertEquals(0, sa.getLBound());
assertEquals(2, sa.getUBound());
double[] doubles = sa.toDoubleArray();
assertTrue(Arrays.equals(doubles, arr));
}
public void testPrimitiveLongArray() {
long[] arr = new long[] { 0xcafebabecafebabeL, 42, 0xbabecafebabeL };
Variant arrVar = VariantUtilities.objectToVariant(arr);
assertNotNull(arrVar);
SafeArray sa = arrVar.toSafeArray();
assertNotNull(sa);
assertEquals(Variant.VariantLongInt, sa.getvt());
assertEquals(0, sa.getLBound());
assertEquals(2, sa.getUBound());
long[] longs = sa.toLongArray();
assertTrue(Arrays.equals(longs, arr));
}
}

View File

@@ -32,7 +32,11 @@ public class ExcelEventTest extends BaseTestCase {
// You can probably also listen Excel.Sheet and Excel.Chart
String excelApplicationProgramId = "Excel.Application";
String excelSheetProgramId = "Excel.Sheet";
String typeLibLocation = "C:\\Program Files\\Microsoft Office\\OFFICE11\\EXCEL.EXE";
String typeLibLocation;
// office 2003
typeLibLocation = "C:\\Program Files\\Microsoft Office\\OFFICE11\\EXCEL.EXE";
// office 2007
typeLibLocation = "C:\\Program Files\\Microsoft Office\\OFFICE12\\EXCEL.EXE";
// Grab The Component.
ActiveXComponent axc = new ActiveXComponent(excelApplicationProgramId);
@@ -46,7 +50,14 @@ public class ExcelEventTest extends BaseTestCase {
Dispatch workbooks = axc.getPropertyAsComponent("Workbooks");
Dispatch workbook = Dispatch.get(workbooks, "Add").toDispatch();
Dispatch sheet = Dispatch.get(workbook, "ActiveSheet").toDispatch();
hookupListener(sheet, excelSheetProgramId, typeLibLocation);
System.out.println("Workbook: "+workbook);
System.out.println("Sheet: "+sheet);
if (typeLibLocation.contains("OFFICE11")){
// office 2007 throws crashes the VM
System.out.println("Hooking up sheet listener");
hookupListener(sheet, excelSheetProgramId, typeLibLocation);
}
System.out.println("Retrieving cells");
Dispatch a1 = Dispatch.invoke(sheet, "Range", Dispatch.Get,
new Object[] { "A1" }, new int[1]).toDispatch();
Dispatch a2 = Dispatch.invoke(sheet, "Range", Dispatch.Get,
@@ -101,7 +112,7 @@ public class ExcelEventTest extends BaseTestCase {
.println("No exception thrown but no dispatch returned for Excel events");
} else {
// Yea!
System.out.println("Successfully attached to " + programId);
System.out.println("Successfully attached listener to " + programId);
}
}

View File

@@ -18,9 +18,12 @@ import com.jacob.test.BaseTestCase;
*
* power point test program posted to sourceforge to demonstrate memory problem.
* The submitter stated they had the problem on windows 2000 with office 2000 I
* have been unable to duplicate on windows XP with office 2003. I am comitting
* have been unable to duplicate on windows XP with office 2003. I am adding
* this to the tree just in case we need to come back to it.
* <P>
* This test was modified for office 2007 to synchronize communication with Excel.
* Office 2003 didn't require this.
* <p>
* This relies on BaseTestCase to provide the root path to the file under test
* <p>
* May need to run with some command line options (including from inside
@@ -117,8 +120,13 @@ public class PowerpointTest extends BaseTestCase {
+ ": Iteration " + i);
System.out.flush();
}
// office 2003 seems to have been able to handle more
// multi-threaded requests than office 2007
// office 2003 could handle 5 threads @ 50 iterations
// office 2007 can only handle 1 thread at a time
synchronized(comPowerpoint){
Dispatch comPresentations = Dispatch.get(comPowerpoint,
"Presentations").toDispatch();
"Presentations").toDispatch();
Dispatch comPresentation = Dispatch.call(
comPresentations,
"Open",
@@ -127,6 +135,7 @@ public class PowerpointTest extends BaseTestCase {
new Integer(0), new Integer(0), new Integer(0))
.toDispatch();
Dispatch.call(comPresentation, "Close");
}
}
} catch (ComFailException cfe) {
threadFailedWithException = cfe;