From a79a1a08ca402e6ade319962ba886523eb30cd68 Mon Sep 17 00:00:00 2001 From: clay_shooter Date: Mon, 8 Jun 2009 01:10:43 +0000 Subject: [PATCH] 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 --- .cvsignore | 2 +- build.xml | 12 +- docs/BuildingJacobFromSource.html | 13 +- docs/ReleaseNotes.html | 125 ++++++++++++------ src/com/jacob/com/VariantUtilities.java | 46 +++++-- .../com/jacob/com/VariantUtilitiesTest.java | 70 ++++++++++ .../com/jacob/test/events/ExcelEventTest.java | 17 ++- .../jacob/test/powerpoint/PowerpointTest.java | 13 +- .../test/safearray/SafeArrayViaExcel.xls | Bin 91136 -> 91136 bytes 9 files changed, 232 insertions(+), 66 deletions(-) diff --git a/.cvsignore b/.cvsignore index a08c618..51e41b6 100644 --- a/.cvsignore +++ b/.cvsignore @@ -13,5 +13,5 @@ release .cdtproject foo.foo foo.ser - JacobVersion.properties +.settings diff --git a/build.xml b/build.xml index a409066..e920840 100644 --- a/build.xml +++ b/build.xml @@ -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 @@ - + @@ -307,7 +307,7 @@ - + diff --git a/docs/BuildingJacobFromSource.html b/docs/BuildingJacobFromSource.html index b0b066e..03cfbf2 100644 --- a/docs/BuildingJacobFromSource.html +++ b/docs/BuildingJacobFromSource.html @@ -38,10 +38,10 @@ Eclipse 3.3 with the C/C++ module and JDK 1.5. In that situation, you would just create the compilation_tools.properties using the example build.xml as a template.
    -
  • Microsoft Visual C++ 8.0 and it's included library. (to D:\apps in my case) -
  • Eclipse 3.3 or later from www.eclipse.org as the Java IDE. -
  • Eclipse 3.3 or later with the C/C++ plugin can be used for C coding in place of VC++ IDE. -
  • Java JDK 1.5 (1.14 was built using 1.5.0.11) +
  • Microsoft Visual C++ 8.0 and it's included library. (to C:\ProgramFiles in my case) +
  • Eclipse 3.4 or later from www.eclipse.org as the Java IDE. +
  • Eclipse 3.4 or later with the C/C++ plugin can be used for C coding in place of VC++ IDE. +
  • Java JDK 1.5 (1.15 was built using 1.5.0.16)

@@ -56,6 +56,7 @@ using the example build.xml as a template. 1.12VC 98 (6.0) & 2003 64bit libs1.4.21.6.53.2.232 and 64 bit 1.13VC 20051.4.21.7.03.332 and 64 bit 1.14VC 20051.5.01.7.03.332 and 64 bit +1.15VC 20051.5.01.7.03.432 and 64 bit 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:

-	-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 ant test target.
 
-Last Modified 4/2008 1.15
+Last Modified 10/2008 1.15
 
 
 
\ No newline at end of file
diff --git a/docs/ReleaseNotes.html b/docs/ReleaseNotes.html
index 88ecaf0..35518fc 100644
--- a/docs/ReleaseNotes.html
+++ b/docs/ReleaseNotes.html
@@ -1,11 +1,60 @@
 
 
+
+

JACOB 1.15 M1

+

What's New

+
    +
  • + MS Libraries are now statically linked using /MT instead of /MD to reduce issues library compatability issues, especially on older platforms. +
  • +
+

Tracked Changes

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Bugs
  
Patches
2762275 Support conversion of primitive arrays to Variant arrays. (M1)
2171967 VariantUtils.populateVariant can cause VM crash with unrecognized type.(M1)
  
Feature Requests
  
Known Issues
+

JACOB 1.14.3

Tracked Changes

- + @@ -22,21 +71,21 @@ - + - + - + @@ -51,7 +100,7 @@

Tracked Changes

BugsBugs
2011706 
PatchesPatches
   
Feature RequestsFeature Requests
   
Known IssuesKnown Issues
- + @@ -63,21 +112,21 @@ - + - + - + @@ -102,7 +151,7 @@

Tracked Changes

BugsBugs
1919441 
PatchesPatches
   
Feature RequestsFeature Requests
   
Known IssuesKnown Issues
- + @@ -139,14 +188,14 @@ - + - + @@ -181,7 +230,7 @@ - + @@ -214,7 +263,7 @@

Tracked Changes

BugsBugs
1857439 
PatchesPatches
   
Feature RequestsFeature Requests
1845039  
Known IssuesKnown Issues
- + @@ -230,7 +279,7 @@ - + @@ -259,7 +308,7 @@ - + @@ -275,7 +324,7 @@ - + @@ -302,7 +351,7 @@

Tracked Changes

BugsBugs
1793362 
PatchesPatches
1794811  
Feature RequestsFeature Requests
1772783  
Known IssuesKnown Issues
- + @@ -333,7 +382,7 @@ - + @@ -369,7 +418,7 @@ - + @@ -388,7 +437,7 @@ - + @@ -417,7 +466,7 @@ Bug fix release

Tracked Changes

BugsBugs
1651926  
PatchesPatches
1674015 
Feature RequestsFeature Requests
1662887 
Known IssuesKnown Issues
1504120
- + @@ -439,7 +488,7 @@ Bug fix release - + @@ -451,7 +500,7 @@ Bug fix release - + @@ -491,7 +540,7 @@ Bug fix release

Tracked Changes

BugsBugs
1602188 
PatchesPatches
SF1603631 
Feature RequestsFeature Requests
 
- + @@ -526,7 +575,7 @@ Bug fix release - + @@ -540,7 +589,7 @@ Bug fix release - + @@ -571,7 +620,7 @@ Bug fix release

Tracked Changes

BugsBugs
1550604 
PatchesPatches
SF1493647 
Feature RequestsFeature Requests
1580993
- + @@ -586,14 +635,14 @@ Bug fix release - + - +
BugsBugs
1474474 
PatchesPatches
   
Feature RequestsFeature Requests
@@ -641,7 +690,7 @@ Bug fix release

Tracked Changes

- + @@ -671,7 +720,7 @@ Bug fix release - + @@ -690,7 +739,7 @@ Bug fix release - + @@ -752,7 +801,7 @@ Bug fix release

Tracked Changes

BugsBugs
1340233 
PatchesPatches
1386454 
Feature RequestsFeature Requests
1241037
- + @@ -763,7 +812,7 @@ Bug fix release - + @@ -774,7 +823,7 @@ Bug fix release - + @@ -904,7 +953,7 @@ running this from inside of Eclipse

Tracked Changes

BugsBugs
1335897  
PatchesPatches
1314116  
Feature RequestsFeature Requests
1264850
- + @@ -947,7 +996,7 @@ running this from inside of Eclipse - + @@ -974,7 +1023,7 @@ running this from inside of Eclipse - + diff --git a/src/com/jacob/com/VariantUtilities.java b/src/com/jacob/com/VariantUtilities.java index 62a3995..9d03e66 100644 --- a/src/com/jacob/com/VariantUtilities.java +++ b/src/com/jacob/com/VariantUtilities.java @@ -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( diff --git a/unittest/com/jacob/com/VariantUtilitiesTest.java b/unittest/com/jacob/com/VariantUtilitiesTest.java index 746cbaa..736884c 100644 --- a/unittest/com/jacob/com/VariantUtilitiesTest.java +++ b/unittest/com/jacob/com/VariantUtilitiesTest.java @@ -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)); + } + } diff --git a/unittest/com/jacob/test/events/ExcelEventTest.java b/unittest/com/jacob/test/events/ExcelEventTest.java index b076c29..9ec1fee 100644 --- a/unittest/com/jacob/test/events/ExcelEventTest.java +++ b/unittest/com/jacob/test/events/ExcelEventTest.java @@ -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); } } diff --git a/unittest/com/jacob/test/powerpoint/PowerpointTest.java b/unittest/com/jacob/test/powerpoint/PowerpointTest.java index 2bb42b7..906ce72 100644 --- a/unittest/com/jacob/test/powerpoint/PowerpointTest.java +++ b/unittest/com/jacob/test/powerpoint/PowerpointTest.java @@ -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. *

+ * This test was modified for office 2007 to synchronize communication with Excel. + * Office 2003 didn't require this. + *

* This relies on BaseTestCase to provide the root path to the file under test *

* 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; diff --git a/unittest/com/jacob/test/safearray/SafeArrayViaExcel.xls b/unittest/com/jacob/test/safearray/SafeArrayViaExcel.xls index 6359856ffc6993d2ba709fb1916b87a9ae53af3a..219a66474868a4b8d7b2492d1b1b3f2e069dcec7 100644 GIT binary patch delta 25 fcmZoT!P)>sTNrba*b|oKe2si@e0y;cV=p5Bl7tH` delta 25 fcmZoT!P)>sTNrba*gr5@X4~F4y1h7wv6m45i3JKT

BugsBugs
1116101  
PatchesPatches
1115187  
Feature RequestsFeature Requests
1049390