cleaned up variant serialization code. Its still broken. There just isn't as much of it now.

This commit is contained in:
clay_shooter
2005-10-29 16:01:30 +00:00
parent 4e2d45e3ff
commit 38c5d9d358
20 changed files with 281 additions and 304 deletions

View File

@@ -24,8 +24,6 @@ public class AppTest extends Applet implements ActionListener {
ActiveXComponent sC = null;
Dispatch sControl = null;
/**
* startup method
*/
@@ -46,10 +44,9 @@ public class AppTest extends Applet implements ActionListener {
if (sC == null) {
String lang = "VBScript";
sC = new ActiveXComponent("ScriptControl");
sControl = sC.getObject();
Dispatch.put(sControl, "Language", lang);
Dispatch.put(sC, "Language", lang);
}
Variant v = Dispatch.call(sControl, "Eval", in.getText());
Variant v = Dispatch.call(sC, "Eval", in.getText());
out.setText(v.toString());
}
}

View File

@@ -1,7 +1,7 @@
package com.jacob.samples.office;
import com.jacob.activeX.ActiveXComponent;
import com.jacob.com.ComFailException;
import com.jacob.com.ComException;
import com.jacob.com.Dispatch;
import com.jacob.com.Variant;
@@ -99,7 +99,7 @@ public class WordDocumentProperties {
try {
cusPropName = Dispatch.call((Dispatch) custDocprops, "Item",
cusPropName).toString();
} catch (ComFailException e) {
} catch (ComException e) {
// Do nothing
cusPropName = null;
}
@@ -117,7 +117,7 @@ public class WordDocumentProperties {
try {
builtInPropName = Dispatch.call((Dispatch) builtInDocProps, "Item",
builtInPropName).toString();
} catch (ComFailException e) {
} catch (ComException e) {
// Do nothing
builtInPropName = null;
}

View File

@@ -3,7 +3,7 @@ package com.jacob.samples.test;
import com.jacob.com.*;
import com.jacob.activeX.*;
public class safearray
public class SafeArrayViaExcel
{
public static void main(java.lang.String[] args)
{
@@ -16,7 +16,8 @@ public class safearray
SafeArray sAProdText;
Dispatch workbooks = xl.getProperty("Workbooks").toDispatch();
System.out.println("have workbooks");
Dispatch workbook = Dispatch.call(workbooks, "Open", "d:\\jacob_15\\samples\\test\\jacobtest.xls").toDispatch();
Dispatch workbook = Dispatch.call(workbooks, "Open", "d:\\jacob\\samples\\test\\ExcelSafeArray" +
".xls").toDispatch();
System.out.println("Opened File - jacobtest.xls\n");
Dispatch sheet = Dispatch.get(workbook,"ActiveSheet").toDispatch();
cell = Dispatch.invoke(sheet,"Range",Dispatch.Get,new Object[] {"A1:D1000"},new int[1]).toDispatch();

View File

@@ -266,7 +266,7 @@ class test
printArray(bback);
try {
// this should throw ComFailException
// this should throw ComException
bba2.fromCharArray(new char[] {'a'});
} catch (Exception e) {
e.printStackTrace();

View File

@@ -1,49 +0,0 @@
package com.jacob.samples.test;
import com.jacob.com.*;
import java.io.*;
class varSerTest
{
public static void main(String[] args) throws Exception
{
Variant vs1 = new Variant("hi");
Variant vs2 = new Variant(123.456);
FileOutputStream fos = new FileOutputStream("foo.foo");
vs1.Save(fos);
vs2.Save(fos);
fos.close();
Variant vl1 = new Variant();
Variant vl2 = new Variant();
FileInputStream fis = new FileInputStream("foo.foo");
vl1.Load(fis);
vl2.Load(fis);
System.out.println(vl1);
System.out.println(vl2);
// same thing with serialization
fos = new FileOutputStream("foo.ser");
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeObject(vs1);
oos.writeObject(vs2);
oos.close();
fos.close();
fis = new FileInputStream("foo.ser");
ObjectInputStream ois = new ObjectInputStream(fis);
Variant vss1, vss2;
vss1 = (Variant)ois.readObject();
vss2 = (Variant)ois.readObject();
ois.close();
fis.close();
System.out.println(vss1);
System.out.println(vss2);
}
}

View File

@@ -1,23 +0,0 @@
package com.jacob.samples.test;
import com.jacob.com.*;
class variant_test {
public static void main(String[] args) {
//deprecated
//System.runFinalizersOnExit(true);
Variant v = new Variant();
v.putInt(10);
System.out.println("got=" + v.toInt());
v.putInt(10);
System.out.println("got=" + v.toDouble());
v.putString("1234.567");
System.out.println("got=" + v.toString());
v.putBoolean(true);
System.out.println("got=" + v.toBoolean());
v.putBoolean(false);
System.out.println("got=" + v.toBoolean());
v.putCurrency(123456789123456789L);
System.out.println("got=" + v.toCurrency());
}
}