Generated basic javadoc for most methods. Still need some help here
Reformatteda all source using eclipse eliminated parameters with same names as method variagles repackaged all tests so that their package names match the directories they are in merged in Jiffie and Variant EventProxy changes
This commit is contained in:
283
EventCallbacks.htm
Normal file
283
EventCallbacks.htm
Normal file
@@ -0,0 +1,283 @@
|
||||
<html xmlns:o="urn:schemas-microsoft-com:office:office"
|
||||
xmlns:w="urn:schemas-microsoft-com:office:word"
|
||||
xmlns="http://www.w3.org/TR/REC-html40">
|
||||
|
||||
<head>
|
||||
<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
|
||||
<meta name=ProgId content=Word.Document>
|
||||
<meta name=Generator content="Microsoft Word 11">
|
||||
<meta name=Originator content="Microsoft Word 11">
|
||||
<link rel=File-List href="EventsAndCallBacks_files/filelist.xml">
|
||||
<title>Jacob can register Java classes for MS application events or callbacks</title>
|
||||
<!--[if gte mso 9]><xml>
|
||||
<o:OfficeDocumentSettings>
|
||||
<o:RemovePersonalInformation/>
|
||||
</o:OfficeDocumentSettings>
|
||||
</xml><![endif]--><!--[if gte mso 9]><xml>
|
||||
<w:WordDocument>
|
||||
<w:DisplayBackgroundShape/>
|
||||
<w:SpellingState>Clean</w:SpellingState>
|
||||
<w:GrammarState>Clean</w:GrammarState>
|
||||
<w:ValidateAgainstSchemas/>
|
||||
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
|
||||
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
|
||||
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
|
||||
<w:Compatibility>
|
||||
<w:SelectEntireFieldWithStartOrEnd/>
|
||||
<w:UseWord2002TableStyleRules/>
|
||||
</w:Compatibility>
|
||||
<w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
|
||||
</w:WordDocument>
|
||||
</xml><![endif]--><!--[if gte mso 9]><xml>
|
||||
<w:LatentStyles DefLockedState="false" LatentStyleCount="156">
|
||||
</w:LatentStyles>
|
||||
</xml><![endif]-->
|
||||
<style>
|
||||
<!--
|
||||
/* Style Definitions */
|
||||
p.MsoNormal, li.MsoNormal, div.MsoNormal
|
||||
{mso-style-parent:"";
|
||||
margin:0in;
|
||||
margin-bottom:.0001pt;
|
||||
mso-pagination:widow-orphan;
|
||||
font-size:12.0pt;
|
||||
font-family:"Times New Roman";
|
||||
mso-fareast-font-family:"Times New Roman";}
|
||||
p.MsoPlainText, li.MsoPlainText, div.MsoPlainText
|
||||
{margin:0in;
|
||||
margin-bottom:.0001pt;
|
||||
mso-pagination:widow-orphan;
|
||||
font-size:10.0pt;
|
||||
font-family:"Courier New";
|
||||
mso-fareast-font-family:"Times New Roman";}
|
||||
span.SpellE
|
||||
{mso-style-name:"";
|
||||
mso-spl-e:yes;}
|
||||
span.GramE
|
||||
{mso-style-name:"";
|
||||
mso-gram-e:yes;}
|
||||
@page Section1
|
||||
{size:8.5in 11.0in;
|
||||
margin:1.0in 65.95pt 1.0in 65.95pt;
|
||||
mso-header-margin:.5in;
|
||||
mso-footer-margin:.5in;
|
||||
mso-paper-source:0;}
|
||||
div.Section1
|
||||
{page:Section1;}
|
||||
/* List Definitions */
|
||||
@list l0
|
||||
{mso-list-id:369961789;
|
||||
mso-list-type:hybrid;
|
||||
mso-list-template-ids:-80199436 -1920937264 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;}
|
||||
@list l0:level1
|
||||
{mso-level-text:"%1\)";
|
||||
mso-level-tab-stop:42.0pt;
|
||||
mso-level-number-position:left;
|
||||
margin-left:42.0pt;
|
||||
text-indent:-24.0pt;}
|
||||
@list l1
|
||||
{mso-list-id:1316765558;
|
||||
mso-list-type:hybrid;
|
||||
mso-list-template-ids:860497186 -1920937264 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;}
|
||||
@list l1:level1
|
||||
{mso-level-text:"%1\)";
|
||||
mso-level-tab-stop:42.0pt;
|
||||
mso-level-number-position:left;
|
||||
margin-left:42.0pt;
|
||||
text-indent:-24.0pt;}
|
||||
ol
|
||||
{margin-bottom:0in;}
|
||||
ul
|
||||
{margin-bottom:0in;}
|
||||
-->
|
||||
</style>
|
||||
<!--[if gte mso 10]>
|
||||
<style>
|
||||
/* Style Definitions */
|
||||
table.MsoNormalTable
|
||||
{mso-style-name:"Table Normal";
|
||||
mso-tstyle-rowband-size:0;
|
||||
mso-tstyle-colband-size:0;
|
||||
mso-style-noshow:yes;
|
||||
mso-style-parent:"";
|
||||
mso-padding-alt:0in 5.4pt 0in 5.4pt;
|
||||
mso-para-margin:0in;
|
||||
mso-para-margin-bottom:.0001pt;
|
||||
mso-pagination:widow-orphan;
|
||||
font-size:10.0pt;
|
||||
font-family:"Times New Roman";
|
||||
mso-ansi-language:#0400;
|
||||
mso-fareast-language:#0400;
|
||||
mso-bidi-language:#0400;}
|
||||
</style>
|
||||
<![endif]-->
|
||||
</head>
|
||||
|
||||
<body lang=EN-US style='tab-interval:.5in'>
|
||||
|
||||
<div class=Section1>
|
||||
|
||||
<p class=MsoPlainText>Jacob can register Java classes for MS application events
|
||||
or callbacks.<span style='mso-spacerun:yes'><EFBFBD> </span>The normal flow for this
|
||||
is:</p>
|
||||
|
||||
<p class=MsoPlainText><o:p> </o:p></p>
|
||||
|
||||
<p class=MsoPlainText style='margin-left:42.0pt;text-indent:-24.0pt;mso-list:
|
||||
l1 level1 lfo1;tab-stops:list 42.0pt'><![if !supportLists]><span
|
||||
style='mso-fareast-font-family:"Courier New"'><span style='mso-list:Ignore'>1)<span
|
||||
style='font:7.0pt "Times New Roman"'>
|
||||
</span></span></span><![endif]>Application thread creates an instance of the
|
||||
event handler and registers it with Jacob</p>
|
||||
|
||||
<p class=MsoPlainText style='margin-left:42.0pt;text-indent:-24.0pt;mso-list:
|
||||
l1 level1 lfo1;tab-stops:list 42.0pt'><![if !supportLists]><span
|
||||
style='mso-fareast-font-family:"Courier New"'><span style='mso-list:Ignore'>2)<span
|
||||
style='font:7.0pt "Times New Roman"'>
|
||||
</span></span></span><![endif]>The application continues on doing other work.</p>
|
||||
|
||||
<p class=MsoPlainText style='margin-left:42.0pt;text-indent:-24.0pt;mso-list:
|
||||
l1 level1 lfo1;tab-stops:list 42.0pt'><![if !supportLists]><span
|
||||
style='mso-fareast-font-family:"Courier New"'><span style='mso-list:Ignore'>3)<span
|
||||
style='font:7.0pt "Times New Roman"'>
|
||||
</span></span></span><![endif]>Some time later, the MS application takes some
|
||||
action and initiates the event callback.</p>
|
||||
|
||||
<p class=MsoPlainText style='margin-left:42.0pt;text-indent:-24.0pt;mso-list:
|
||||
l1 level1 lfo1;tab-stops:list 42.0pt'><![if !supportLists]><span
|
||||
style='mso-fareast-font-family:"Courier New"'><span style='mso-list:Ignore'>4)<span
|
||||
style='font:7.0pt "Times New Roman"'>
|
||||
</span></span></span><![endif]>The Java VM receives the event and spins up a
|
||||
new thread to handle it.</p>
|
||||
|
||||
<p class=MsoPlainText style='margin-left:42.0pt;text-indent:-24.0pt;mso-list:
|
||||
l1 level1 lfo1;tab-stops:list 42.0pt'><![if !supportLists]><span
|
||||
style='mso-fareast-font-family:"Courier New"'><span style='mso-list:Ignore'>5)<span
|
||||
style='font:7.0pt "Times New Roman"'>
|
||||
</span></span></span><![endif]>The Jacob <span class=SpellE>EventProxy</span>
|
||||
in the <span class=SpellE>dll</span> is called by the VM.</p>
|
||||
|
||||
<p class=MsoPlainText style='margin-left:42.0pt;text-indent:-24.0pt;mso-list:
|
||||
l1 level1 lfo1;tab-stops:list 42.0pt'><![if !supportLists]><span
|
||||
style='mso-fareast-font-family:"Courier New"'><span style='mso-list:Ignore'>6)<span
|
||||
style='font:7.0pt "Times New Roman"'>
|
||||
</span></span></span><![endif]>The Jacob <span class=SpellE>EventProxy</span>
|
||||
creates Variant objects to handle the parameters of the passed in event.</p>
|
||||
|
||||
<p class=MsoPlainText style='margin-left:42.0pt;text-indent:-24.0pt;mso-list:
|
||||
l1 level1 lfo1;tab-stops:list 42.0pt'><![if !supportLists]><span
|
||||
style='mso-fareast-font-family:"Courier New"'><span style='mso-list:Ignore'>7)<span
|
||||
style='font:7.0pt "Times New Roman"'>
|
||||
</span></span></span><![endif]>The Jacob <span class=SpellE>EventProxy</span>
|
||||
uses reflection to map the event name to a method name with the exact same
|
||||
name.</p>
|
||||
|
||||
<p class=MsoPlainText style='margin-left:42.0pt;text-indent:-24.0pt;mso-list:
|
||||
l1 level1 lfo1;tab-stops:list 42.0pt'><![if !supportLists]><span
|
||||
style='mso-fareast-font-family:"Courier New"'><span style='mso-list:Ignore'>8)<span
|
||||
style='font:7.0pt "Times New Roman"'>
|
||||
</span></span></span><![endif]>The Jacob <span class=SpellE>EventProxy</span>
|
||||
sends the message to the registered event handler.</p>
|
||||
|
||||
<p class=MsoPlainText><o:p> </o:p></p>
|
||||
|
||||
<p class=MsoPlainText>Swing developers should note that this message comes in
|
||||
on a thread other than the event thread.<span style='mso-spacerun:yes'><EFBFBD>
|
||||
</span>All objects receiving events that require user intervention or drawing
|
||||
in the UI should use <span class=SpellE><span class=GramE>invokeLater</span></span><span
|
||||
class=GramE>(</span>) to post requests for actions onto the event queue.<span
|
||||
style='mso-spacerun:yes'><EFBFBD> </span>Failure to do so will insure random failures
|
||||
in the GUI.</p>
|
||||
|
||||
<p class=MsoPlainText><o:p> </o:p></p>
|
||||
|
||||
<p class=MsoPlainText>Java Web Start (JWS) and other launchers can have
|
||||
additional issues related to the class loader.<span style='mso-spacerun:yes'><EFBFBD>
|
||||
</span>The Jacob C++ library uses <span class=SpellE><span class=GramE>FindClass</span></span><span
|
||||
class=GramE>(</span>) to find the Variant class when building the parameter
|
||||
list.<span style='mso-spacerun:yes'><EFBFBD> </span><span class=SpellE><span
|
||||
class=GramE>FindClass</span></span><span class=GramE>(</span>) uses the system
|
||||
class loader which includes only the classes specified at run time or in the
|
||||
CLASSPATH.<span style='mso-spacerun:yes'><EFBFBD> </span>Most of the application
|
||||
classes in this situation live in an alternate set of class loaders that were
|
||||
created when the launcher located and ran the application classes.<span
|
||||
style='mso-spacerun:yes'><EFBFBD> </span>This means that the search for Variant will
|
||||
fail usually with the silent and immediate termination of the Java application.<span
|
||||
style='mso-spacerun:yes'><EFBFBD> </span>The thread <span class=SpellE>classloader</span>
|
||||
probably can<61>t be used to try and find the class because this new thread does
|
||||
not have a <span class=SpellE>classloader</span> associated with it other than
|
||||
the system class loader.<span style='mso-spacerun:yes'><EFBFBD> </span>The end result
|
||||
is that the Variant class needs to be located via other means and that the
|
||||
thread <span class=SpellE>classloader</span> should be set to be the context
|
||||
class loader of the event handler class.</p>
|
||||
|
||||
<p class=MsoPlainText><o:p> </o:p></p>
|
||||
|
||||
<p class=MsoPlainText>The Jacob <span class=SpellE>EventProxy</span> class has
|
||||
been modified (off of the 1.8 tree) so that it takes a two step approach to towards
|
||||
fixing these problems.</p>
|
||||
|
||||
<p class=MsoPlainText><span style='mso-tab-count:1'><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> </span><span
|
||||
style='mso-tab-count:1'><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> </span></p>
|
||||
|
||||
<p class=MsoPlainText style='margin-left:42.0pt;text-indent:-24.0pt;mso-list:
|
||||
l0 level1 lfo2;tab-stops:list 42.0pt'><![if !supportLists]><span
|
||||
style='mso-fareast-font-family:"Courier New"'><span style='mso-list:Ignore'>1)<span
|
||||
style='font:7.0pt "Times New Roman"'>
|
||||
</span></span></span><![endif]><span class=SpellE>EventProxy</span> first
|
||||
attempts to locate the Variant class using <span class=SpellE>FindClass</span>()</p>
|
||||
|
||||
<p class=MsoPlainText style='margin-left:42.0pt;text-indent:-24.0pt;mso-list:
|
||||
l0 level1 lfo2;tab-stops:list 42.0pt'><![if !supportLists]><span
|
||||
style='mso-fareast-font-family:"Courier New"'><span style='mso-list:Ignore'>2)<span
|
||||
style='font:7.0pt "Times New Roman"'>
|
||||
</span></span></span><![endif]>Failing that, it looks to see if the event
|
||||
callback object implements <span class=SpellE><span class=GramE>getVariantClass</span></span><span
|
||||
class=GramE>(</span>) that returns the <span class=SpellE>Variant.class</span>
|
||||
object.<span style='mso-spacerun:yes'><EFBFBD> </span>If so, it uses that class to
|
||||
create variants for the callback parameters.</p>
|
||||
|
||||
<p class=MsoPlainText style='margin-left:42.0pt;text-indent:-24.0pt;mso-list:
|
||||
l0 level1 lfo2;tab-stops:list 42.0pt'><![if !supportLists]><span
|
||||
style='mso-fareast-font-family:"Courier New"'><span style='mso-list:Ignore'>3)<span
|
||||
style='font:7.0pt "Times New Roman"'>
|
||||
</span></span></span><![endif]>If all that fails, it logs a message and then
|
||||
fails in the spectacular fashion of the previous versions.</p>
|
||||
|
||||
<p class=MsoPlainText><o:p> </o:p></p>
|
||||
|
||||
<p class=MsoPlainText>This means developers can receive call back events in JWS
|
||||
other Java launching programs by implementing <span class=SpellE><span
|
||||
class=GramE>getVariantClass</span></span><span class=GramE>(</span>) on all of
|
||||
their classes that receive Microsoft Events.<span style='mso-spacerun:yes'><EFBFBD>
|
||||
</span>The <span class=SpellE><span class=GramE>getVariantClass</span></span><span
|
||||
class=GramE>(</span>) method has the added benefit of providing a spot for the
|
||||
thread <span class=SpellE>classloader</span> to be set:</p>
|
||||
|
||||
<p class=MsoPlainText><span style='mso-tab-count:1'><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> </span>Public Class <span
|
||||
class=SpellE><span class=GramE>getVariantClass</span></span><span class=GramE>(</span>){</p>
|
||||
|
||||
<p class=MsoPlainText><span style='mso-tab-count:1'><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> </span><span
|
||||
style='mso-tab-count:1'><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> </span><span class=SpellE><span class=GramE>Thread.currentThread</span></span><span
|
||||
class=GramE>(</span>).<span class=SpellE>setContextClassLoader</span>(</p>
|
||||
|
||||
<p class=MsoPlainText><span style='mso-tab-count:3'><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> </span><span
|
||||
class=SpellE><span class=GramE>this.getClass</span></span><span class=GramE>(</span>).<span
|
||||
class=SpellE>getClassLoader</span>());</p>
|
||||
|
||||
<p class=MsoPlainText><span style='mso-tab-count:1'><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> </span><span
|
||||
style='mso-tab-count:1'><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> </span><span class=GramE>return</span> <span
|
||||
class=SpellE>Variant.class</span></p>
|
||||
|
||||
<p class=MsoPlainText><span style='mso-tab-count:1'><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> </span>}</p>
|
||||
|
||||
<p class=MsoPlainText><o:p> </o:p></p>
|
||||
|
||||
<p class=MsoPlainText>There may still be a dual event queue issue in JWS
|
||||
applications that needs to be looked at.</p>
|
||||
|
||||
</div>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -32,42 +32,57 @@ package com.jacob.activeX;
|
||||
import com.jacob.com.*;
|
||||
|
||||
/**
|
||||
* This class simulates com.ms.activeX.ActiveXComponent only as
|
||||
* it used for creating Dispatch objects
|
||||
* This class simulates com.ms.activeX.ActiveXComponent only as it used for
|
||||
* creating Dispatch objects
|
||||
*/
|
||||
public class ActiveXComponent extends Dispatch
|
||||
{
|
||||
public ActiveXComponent(String progid)
|
||||
{
|
||||
super(progid);
|
||||
}
|
||||
public class ActiveXComponent extends Dispatch {
|
||||
/**
|
||||
* @param progid
|
||||
*/
|
||||
public ActiveXComponent(String progid) {
|
||||
super(progid);
|
||||
}
|
||||
|
||||
public Object getObject()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* @return actually returns this bject
|
||||
*/
|
||||
public Object getObject() {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Variant invoke(String name, Variant[] args)
|
||||
{
|
||||
return Dispatch.callN(this, name, args);
|
||||
}
|
||||
/**
|
||||
* @param name
|
||||
* @param args
|
||||
* @return Variant result of the invoke
|
||||
*/
|
||||
public Variant invoke(String name, Variant[] args) {
|
||||
return Dispatch.callN(this, name, args);
|
||||
}
|
||||
|
||||
public Variant getProperty(String name)
|
||||
{
|
||||
return Dispatch.get(this, name);
|
||||
}
|
||||
/**
|
||||
* @param name property name
|
||||
* @return Variant value of property
|
||||
*/
|
||||
public Variant getProperty(String name) {
|
||||
return Dispatch.get(this, name);
|
||||
}
|
||||
|
||||
public void setProperty(String name, Variant arg)
|
||||
{
|
||||
Dispatch.put(this, name, arg);
|
||||
}
|
||||
/**
|
||||
* @param name
|
||||
* @param arg
|
||||
*/
|
||||
public void setProperty(String name, Variant arg) {
|
||||
Dispatch.put(this, name, arg);
|
||||
}
|
||||
|
||||
protected void finalize()
|
||||
{
|
||||
super.finalize();
|
||||
}
|
||||
/**
|
||||
* @see com.jacob.com.Dispatch#finalize()
|
||||
*/
|
||||
protected void finalize() {
|
||||
super.finalize();
|
||||
}
|
||||
|
||||
static {
|
||||
System.loadLibrary("jacob");
|
||||
}
|
||||
static {
|
||||
System.loadLibrary("jacob");
|
||||
}
|
||||
}
|
||||
@@ -1,88 +1,136 @@
|
||||
/*
|
||||
* Copyright (c) 1999-2004 Sourceforge JACOB Project.
|
||||
* All rights reserved. Originator: Dan Adler (http://danadler.com).
|
||||
* Copyright (c) 1999-2004 Sourceforge JACOB Project. All rights reserved.
|
||||
* Originator: Dan Adler (http://danadler.com).
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Redistributions in any form must be accompanied by information on
|
||||
* how to obtain complete source code for the JACOB software.
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer. 2. Redistributions in
|
||||
* binary form must reproduce the above copyright notice, this list of
|
||||
* conditions and the following disclaimer in the documentation and/or other
|
||||
* materials provided with the distribution. 3. Redistributions in any form must
|
||||
* be accompanied by information on how to obtain complete source code for the
|
||||
* JACOB software.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package com.jacob.com;
|
||||
|
||||
public abstract class ComException extends RuntimeException
|
||||
{
|
||||
// Fields
|
||||
protected int hr;
|
||||
protected int m_helpContext;
|
||||
protected String m_helpFile;
|
||||
protected String m_source;
|
||||
/**
|
||||
* Standard exception thrown by com jni code when there is a problem
|
||||
*/
|
||||
public abstract class ComException extends RuntimeException {
|
||||
// Fields
|
||||
/** TODO: what is this field */
|
||||
protected int hr;
|
||||
/** TODO: what is this field */
|
||||
protected int m_helpContext;
|
||||
/** TODO: what is this field */
|
||||
protected String m_helpFile;
|
||||
/** TODO: what is this field */
|
||||
protected String m_source;
|
||||
|
||||
// Constructors
|
||||
public ComException()
|
||||
{
|
||||
super();
|
||||
}
|
||||
/**
|
||||
* constructor
|
||||
*
|
||||
*/
|
||||
public ComException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public ComException(int hr)
|
||||
{
|
||||
super();
|
||||
this.hr = hr;
|
||||
}
|
||||
/**
|
||||
* constructor with error code?
|
||||
*
|
||||
* @param newHr ??
|
||||
*/
|
||||
public ComException(int newHr) {
|
||||
super();
|
||||
this.hr = newHr;
|
||||
}
|
||||
|
||||
public ComException(int hr, String description)
|
||||
{
|
||||
super(description);
|
||||
this.hr = hr;
|
||||
}
|
||||
/**
|
||||
* @param newHr
|
||||
* @param description
|
||||
*/
|
||||
public ComException(int newHr, String description) {
|
||||
super(description);
|
||||
this.hr = newHr;
|
||||
}
|
||||
|
||||
public ComException(int hr, String source, String helpFile,
|
||||
int helpContext)
|
||||
{
|
||||
super();
|
||||
this.hr = hr;
|
||||
m_source = source;
|
||||
m_helpFile = helpFile;
|
||||
m_helpContext = helpContext;
|
||||
}
|
||||
/**
|
||||
* @param newHr
|
||||
* @param source
|
||||
* @param helpFile
|
||||
* @param helpContext
|
||||
*/
|
||||
public ComException(int newHr, String source, String helpFile,
|
||||
int helpContext) {
|
||||
super();
|
||||
this.hr = newHr;
|
||||
m_source = source;
|
||||
m_helpFile = helpFile;
|
||||
m_helpContext = helpContext;
|
||||
}
|
||||
|
||||
public ComException(int hr, String description, String source,
|
||||
String helpFile, int helpContext)
|
||||
{
|
||||
super(description);
|
||||
this.hr = hr;
|
||||
m_source = source;
|
||||
m_helpFile = helpFile;
|
||||
m_helpContext = helpContext;
|
||||
}
|
||||
/**
|
||||
* @param newHr
|
||||
* @param description
|
||||
* @param source
|
||||
* @param helpFile
|
||||
* @param helpContext
|
||||
*/
|
||||
public ComException(int newHr, String description, String source,
|
||||
String helpFile, int helpContext) {
|
||||
super(description);
|
||||
this.hr = newHr;
|
||||
m_source = source;
|
||||
m_helpFile = helpFile;
|
||||
m_helpContext = helpContext;
|
||||
}
|
||||
|
||||
public ComException(String description)
|
||||
{
|
||||
super(description);
|
||||
}
|
||||
/**
|
||||
* @param description
|
||||
*/
|
||||
public ComException(String description) {
|
||||
super(description);
|
||||
}
|
||||
|
||||
// Methods
|
||||
public int getHelpContext() { return m_helpContext; }
|
||||
public String getHelpFile() { return m_helpFile; }
|
||||
public int getHResult() { return hr; }
|
||||
public String getSource() { return m_source; }
|
||||
/**
|
||||
* @return int representation of the help context
|
||||
*/
|
||||
// Methods
|
||||
public int getHelpContext() {
|
||||
return m_helpContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return String ??? help file
|
||||
*/
|
||||
public String getHelpFile() {
|
||||
return m_helpFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int hr result ??
|
||||
*/
|
||||
public int getHResult() {
|
||||
return hr;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return String source ??
|
||||
*/
|
||||
public String getSource() {
|
||||
return m_source;
|
||||
}
|
||||
}
|
||||
@@ -1,65 +1,88 @@
|
||||
/*
|
||||
* Copyright (c) 1999-2004 Sourceforge JACOB Project.
|
||||
* All rights reserved. Originator: Dan Adler (http://danadler.com).
|
||||
* Copyright (c) 1999-2004 Sourceforge JACOB Project. All rights reserved.
|
||||
* Originator: Dan Adler (http://danadler.com).
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Redistributions in any form must be accompanied by information on
|
||||
* how to obtain complete source code for the JACOB software.
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer. 2. Redistributions in
|
||||
* binary form must reproduce the above copyright notice, this list of
|
||||
* conditions and the following disclaimer in the documentation and/or other
|
||||
* materials provided with the distribution. 3. Redistributions in any form must
|
||||
* be accompanied by information on how to obtain complete source code for the
|
||||
* JACOB software.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package com.jacob.com;
|
||||
|
||||
public class ComFailException extends ComException
|
||||
{
|
||||
// Constructors
|
||||
public ComFailException(int hr)
|
||||
{
|
||||
super(hr);
|
||||
}
|
||||
public ComFailException(int hr, String message)
|
||||
{
|
||||
super(hr, message);
|
||||
}
|
||||
/**
|
||||
* @author joe
|
||||
*
|
||||
* TODO To change the template for this generated type comment go to
|
||||
* Window - Preferences - Java - Code Style - Code Templates
|
||||
*/
|
||||
public class ComFailException extends ComException {
|
||||
/**
|
||||
* @param hrNew
|
||||
*/
|
||||
// Constructors
|
||||
public ComFailException(int hrNew) {
|
||||
super(hrNew);
|
||||
}
|
||||
|
||||
public ComFailException(int hr, String source, String helpFile,
|
||||
int helpContext)
|
||||
{
|
||||
super(hr, source, helpFile, helpContext);
|
||||
}
|
||||
/**
|
||||
* @param hrNew
|
||||
* @param message
|
||||
*/
|
||||
public ComFailException(int hrNew, String message) {
|
||||
super(hrNew, message);
|
||||
}
|
||||
|
||||
public ComFailException(int hr, String description,
|
||||
String source, String helpFile, int helpContext)
|
||||
{
|
||||
super(hr, description, source, helpFile, helpContext);
|
||||
}
|
||||
/**
|
||||
* @param hrNew
|
||||
* @param source
|
||||
* @param helpFile
|
||||
* @param helpContext
|
||||
*/
|
||||
public ComFailException(int hrNew, String source, String helpFile,
|
||||
int helpContext) {
|
||||
super(hrNew, source, helpFile, helpContext);
|
||||
}
|
||||
|
||||
public ComFailException()
|
||||
{
|
||||
super();
|
||||
}
|
||||
/**
|
||||
* @param hrNew
|
||||
* @param description
|
||||
* @param source
|
||||
* @param helpFile
|
||||
* @param helpContext
|
||||
*/
|
||||
public ComFailException(int hrNew, String description, String source,
|
||||
String helpFile, int helpContext) {
|
||||
super(hrNew, description, source, helpFile, helpContext);
|
||||
}
|
||||
|
||||
public ComFailException(String message)
|
||||
{
|
||||
super(message);
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public ComFailException() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param message
|
||||
*/
|
||||
public ComFailException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
@@ -1,130 +1,145 @@
|
||||
/*
|
||||
* Copyright (c) 1999-2004 Sourceforge JACOB Project.
|
||||
* All rights reserved. Originator: Dan Adler (http://danadler.com).
|
||||
* Copyright (c) 1999-2004 Sourceforge JACOB Project. All rights reserved.
|
||||
* Originator: Dan Adler (http://danadler.com).
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Redistributions in any form must be accompanied by information on
|
||||
* how to obtain complete source code for the JACOB software.
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer. 2. Redistributions in
|
||||
* binary form must reproduce the above copyright notice, this list of
|
||||
* conditions and the following disclaimer in the documentation and/or other
|
||||
* materials provided with the distribution. 3. Redistributions in any form must
|
||||
* be accompanied by information on how to obtain complete source code for the
|
||||
* JACOB software.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package com.jacob.com;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
|
||||
public abstract class ComThread
|
||||
{
|
||||
/**
|
||||
* @author joe
|
||||
*
|
||||
* TODO To change the template for this generated type comment go to
|
||||
* Window - Preferences - Java - Code Style - Code Templates
|
||||
*/
|
||||
public abstract class ComThread {
|
||||
private static final int MTA = 0x0;
|
||||
|
||||
private static final int STA = 0x2;
|
||||
|
||||
/**
|
||||
* Comment for <code>haveSTA</code>
|
||||
*/
|
||||
public static boolean haveSTA = false;
|
||||
|
||||
/**
|
||||
* Comment for <code>mainSTA</code>
|
||||
*/
|
||||
public static MainSTA mainSTA = null;
|
||||
|
||||
/**
|
||||
* Initialize the current java thread to be part of the
|
||||
* Multi-threaded COM Apartment
|
||||
* Initialize the current java thread to be part of the Multi-threaded COM
|
||||
* Apartment
|
||||
*/
|
||||
public static synchronized void InitMTA()
|
||||
{
|
||||
InitMTA(false);
|
||||
public static synchronized void InitMTA() {
|
||||
InitMTA(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the current java thread to be an STA
|
||||
*/
|
||||
public static synchronized void InitSTA()
|
||||
{
|
||||
InitSTA(false);
|
||||
public static synchronized void InitSTA() {
|
||||
InitSTA(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the current java thread to be part of the
|
||||
* Multi-threaded COM Apartment, if createMainSTA is true,
|
||||
* create a separate MainSTA
|
||||
* thread that will house all Apartment Threaded components
|
||||
* Initialize the current java thread to be part of the Multi-threaded COM
|
||||
* Apartment, if createMainSTA is true, create a separate MainSTA thread
|
||||
* that will house all Apartment Threaded components
|
||||
* @param createMainSTA
|
||||
*/
|
||||
public static synchronized void InitMTA(boolean createMainSTA)
|
||||
{
|
||||
Init(createMainSTA, MTA);
|
||||
public static synchronized void InitMTA(boolean createMainSTA) {
|
||||
Init(createMainSTA, MTA);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the current java thread to be an STA
|
||||
* COM Apartment, if createMainSTA is true,
|
||||
* create a separate MainSTA
|
||||
* thread that will house all Apartment Threaded components
|
||||
* Initialize the current java thread to be an STA COM Apartment, if
|
||||
* createMainSTA is true, create a separate MainSTA thread that will house
|
||||
* all Apartment Threaded components
|
||||
* @param createMainSTA
|
||||
*/
|
||||
public static synchronized void InitSTA(boolean createMainSTA)
|
||||
{
|
||||
Init(createMainSTA, STA);
|
||||
}
|
||||
|
||||
public static synchronized void startMainSTA()
|
||||
{
|
||||
mainSTA = new MainSTA();
|
||||
haveSTA = true;
|
||||
}
|
||||
|
||||
public static synchronized void quitMainSTA()
|
||||
{
|
||||
if (mainSTA != null) mainSTA.quit();
|
||||
public static synchronized void InitSTA(boolean createMainSTA) {
|
||||
Init(createMainSTA, STA);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the current java thread to be part of the
|
||||
* MTA/STA COM Apartment
|
||||
*
|
||||
*/
|
||||
public static synchronized void Init(boolean createMainSTA, int mode)
|
||||
{
|
||||
if (createMainSTA && !haveSTA)
|
||||
{
|
||||
// if the current thread is going to be in the MTA and there
|
||||
// is no STA thread yet, then create a main STA thread
|
||||
// to avoid COM creating its own
|
||||
startMainSTA();
|
||||
}
|
||||
//System.out.println("before Init: "+mode);
|
||||
doCoInitialize(mode);
|
||||
//System.out.println("after Init");
|
||||
ROT.addThread();
|
||||
//System.out.println("after ROT.addThread");
|
||||
public static synchronized void startMainSTA() {
|
||||
mainSTA = new MainSTA();
|
||||
haveSTA = true;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static synchronized void quitMainSTA() {
|
||||
if (mainSTA != null)
|
||||
mainSTA.quit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the current java thread to be part of the MTA/STA COM
|
||||
* Apartment
|
||||
* @param createMainSTA
|
||||
* @param mode
|
||||
*/
|
||||
public static synchronized void Init(boolean createMainSTA, int mode) {
|
||||
if (createMainSTA && !haveSTA) {
|
||||
// if the current thread is going to be in the MTA and there
|
||||
// is no STA thread yet, then create a main STA thread
|
||||
// to avoid COM creating its own
|
||||
startMainSTA();
|
||||
}
|
||||
//System.out.println("before Init: "+mode);
|
||||
doCoInitialize(mode);
|
||||
//System.out.println("after Init");
|
||||
ROT.addThread();
|
||||
//System.out.println("after ROT.addThread");
|
||||
}
|
||||
|
||||
/**
|
||||
* Call CoUninitialize to release this java thread from COM
|
||||
*/
|
||||
public static synchronized void Release()
|
||||
{
|
||||
//System.out.println("before clearObjects");
|
||||
ROT.clearObjects();
|
||||
//System.out.println("before UnInit");
|
||||
doCoUninitialize();
|
||||
//System.out.println("after UnInit");
|
||||
public static synchronized void Release() {
|
||||
//System.out.println("before clearObjects");
|
||||
ROT.clearObjects();
|
||||
//System.out.println("before UnInit");
|
||||
doCoUninitialize();
|
||||
//System.out.println("after UnInit");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param threadModel
|
||||
*/
|
||||
public static native void doCoInitialize(int threadModel);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static native void doCoUninitialize();
|
||||
|
||||
static {
|
||||
System.loadLibrary("jacob");
|
||||
System.loadLibrary("jacob");
|
||||
}
|
||||
}
|
||||
@@ -29,36 +29,50 @@
|
||||
*/
|
||||
package com.jacob.com;
|
||||
|
||||
public class DispatchEvents extends JacobObject
|
||||
{
|
||||
int m_pConnPtProxy = 0;
|
||||
/**
|
||||
* @author joe
|
||||
*
|
||||
* TODO To change the template for this generated type comment go to Window -
|
||||
* Preferences - Java - Code Style - Code Templates
|
||||
*/
|
||||
public class DispatchEvents extends JacobObject {
|
||||
int m_pConnPtProxy = 0;
|
||||
|
||||
public DispatchEvents(Dispatch src, Object sink)
|
||||
{
|
||||
init(src, sink);
|
||||
}
|
||||
public DispatchEvents(Dispatch src, Object sink, String progId)
|
||||
{
|
||||
init2(src, sink,progId);
|
||||
}
|
||||
/**
|
||||
* @param src
|
||||
* @param sink
|
||||
*/
|
||||
public DispatchEvents(Dispatch src, Object sink) {
|
||||
init(src, sink);
|
||||
}
|
||||
|
||||
// hook up a connection point proxy object
|
||||
// event methods on the sink object will be called
|
||||
// by name with a signature of <name>(Variant[] args)
|
||||
protected native void init(Dispatch src, Object sink);
|
||||
protected native void init2(Dispatch src, Object sink, String progId);
|
||||
/**
|
||||
* @param src
|
||||
* @param sink
|
||||
* @param progId
|
||||
*/
|
||||
public DispatchEvents(Dispatch src, Object sink, String progId) {
|
||||
init2(src, sink, progId);
|
||||
}
|
||||
|
||||
// call this to explicitly release the com object before gc
|
||||
public native void release();
|
||||
// hook up a connection point proxy object
|
||||
// event methods on the sink object will be called
|
||||
// by name with a signature of <name>(Variant[] args)
|
||||
protected native void init(Dispatch src, Object sink);
|
||||
|
||||
protected void finalize()
|
||||
{
|
||||
//System.out.println("DispatchEvents finalize start");
|
||||
if (m_pConnPtProxy != 0) release();
|
||||
//System.out.println("DispatchEvents finalize end");
|
||||
}
|
||||
protected native void init2(Dispatch src, Object sink, String progId);
|
||||
|
||||
static {
|
||||
System.loadLibrary("jacob");
|
||||
}
|
||||
// call this to explicitly release the com object before gc
|
||||
public native void release();
|
||||
|
||||
protected void finalize() {
|
||||
//System.out.println("DispatchEvents finalize start");
|
||||
if (m_pConnPtProxy != 0)
|
||||
release();
|
||||
//System.out.println("DispatchEvents finalize end");
|
||||
}
|
||||
|
||||
static {
|
||||
System.loadLibrary("jacob");
|
||||
}
|
||||
}
|
||||
@@ -30,36 +30,48 @@
|
||||
package com.jacob.com;
|
||||
|
||||
/**
|
||||
* If you need to pass a COM Dispatch object between STA threads, you
|
||||
* have to marshall the interface.
|
||||
* This class is used as follows: the STA that creates the Dispatch
|
||||
* object must construct an instance of this class. Another thread
|
||||
* can then call toDispatch() on that instance and get a Dispatch
|
||||
* pointer which has been marshalled.
|
||||
* WARNING: You can only call toDispatch() once! If you need to call
|
||||
* it multiple times (or from multiple threads) you need to construct
|
||||
* a separate DispatchProxy instance for each such case!
|
||||
* If you need to pass a COM Dispatch object between STA threads, you have to
|
||||
* marshall the interface. This class is used as follows: the STA that creates
|
||||
* the Dispatch object must construct an instance of this class. Another thread
|
||||
* can then call toDispatch() on that instance and get a Dispatch pointer which
|
||||
* has been marshalled. WARNING: You can only call toDispatch() once! If you
|
||||
* need to call it multiple times (or from multiple threads) you need to
|
||||
* construct a separate DispatchProxy instance for each such case!
|
||||
*/
|
||||
public class DispatchProxy extends JacobObject
|
||||
{
|
||||
public int m_pStream;
|
||||
public class DispatchProxy extends JacobObject {
|
||||
/**
|
||||
* Comment for <code>m_pStream</code>
|
||||
*/
|
||||
public int m_pStream;
|
||||
|
||||
public DispatchProxy(Dispatch localDispatch)
|
||||
{
|
||||
MarshalIntoStream(localDispatch);
|
||||
}
|
||||
/**
|
||||
* @param localDispatch
|
||||
*/
|
||||
public DispatchProxy(Dispatch localDispatch) {
|
||||
MarshalIntoStream(localDispatch);
|
||||
}
|
||||
|
||||
public Dispatch toDispatch()
|
||||
{
|
||||
return MarshalFromStream();
|
||||
}
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public Dispatch toDispatch() {
|
||||
return MarshalFromStream();
|
||||
}
|
||||
|
||||
private native void MarshalIntoStream(Dispatch d);
|
||||
private native Dispatch MarshalFromStream();
|
||||
public native void release();
|
||||
private native void MarshalIntoStream(Dispatch d);
|
||||
|
||||
public void finalize()
|
||||
{
|
||||
if (m_pStream != 0) release();
|
||||
}
|
||||
private native Dispatch MarshalFromStream();
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.jacob.com.JacobObject#release()
|
||||
*/
|
||||
public native void release();
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#finalize()
|
||||
*/
|
||||
public void finalize() {
|
||||
if (m_pStream != 0)
|
||||
release();
|
||||
}
|
||||
}
|
||||
@@ -30,93 +30,102 @@
|
||||
package com.jacob.com;
|
||||
|
||||
/**
|
||||
* An implementation of IEnumVariant based on code submitted by
|
||||
* Thomas Hallgren (mailto:Thomas.Hallgren@eoncompany.com)
|
||||
* An implementation of IEnumVariant based on code submitted by Thomas Hallgren
|
||||
* (mailto:Thomas.Hallgren@eoncompany.com)
|
||||
*/
|
||||
public class EnumVariant extends JacobObject implements java.util.Enumeration
|
||||
{
|
||||
private int m_pIEnumVARIANT;
|
||||
private final Variant[] m_recBuf = new Variant[1];
|
||||
public class EnumVariant extends JacobObject implements java.util.Enumeration {
|
||||
private int m_pIEnumVARIANT;
|
||||
|
||||
// this only gets called from JNI
|
||||
//
|
||||
protected EnumVariant(int pIEnumVARIANT)
|
||||
{
|
||||
m_pIEnumVARIANT = pIEnumVARIANT;
|
||||
}
|
||||
private final Variant[] m_recBuf = new Variant[1];
|
||||
|
||||
public EnumVariant(Object disp)
|
||||
{
|
||||
int[] hres = new int[1];
|
||||
Variant evv = Dispatch.invokev(
|
||||
disp,
|
||||
Dispatch.DISPID_NEWENUM,
|
||||
Dispatch.Get,
|
||||
new Variant[0],
|
||||
hres);
|
||||
if(evv.getvt() != Variant.VariantObject)
|
||||
// this only gets called from JNI
|
||||
//
|
||||
// The DISPID_NEWENUM did not result in a valid object
|
||||
//
|
||||
throw new ComFailException("Can't obtain EnumVARIANT");
|
||||
|
||||
EnumVariant tmp = evv.toEnumVariant();
|
||||
m_pIEnumVARIANT = tmp.m_pIEnumVARIANT;
|
||||
tmp.m_pIEnumVARIANT = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements java.util.Enumeration
|
||||
*/
|
||||
public boolean hasMoreElements()
|
||||
{
|
||||
{
|
||||
if(m_recBuf[0] == null)
|
||||
{
|
||||
if(this.Next(m_recBuf) <= 0)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
protected EnumVariant(int pIEnumVARIANT) {
|
||||
m_pIEnumVARIANT = pIEnumVARIANT;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements java.util.Enumeration
|
||||
*/
|
||||
public Object nextElement()
|
||||
{
|
||||
Object last = m_recBuf[0];
|
||||
if(last == null)
|
||||
{
|
||||
if(this.Next(m_recBuf) <= 0)
|
||||
throw new java.util.NoSuchElementException();
|
||||
last = m_recBuf[0];
|
||||
/**
|
||||
* @param disp
|
||||
*/
|
||||
public EnumVariant(Object disp) {
|
||||
int[] hres = new int[1];
|
||||
Variant evv = Dispatch.invokev(disp, Dispatch.DISPID_NEWENUM,
|
||||
Dispatch.Get, new Variant[0], hres);
|
||||
if (evv.getvt() != Variant.VariantObject)
|
||||
//
|
||||
// The DISPID_NEWENUM did not result in a valid object
|
||||
//
|
||||
throw new ComFailException("Can't obtain EnumVARIANT");
|
||||
|
||||
EnumVariant tmp = evv.toEnumVariant();
|
||||
m_pIEnumVARIANT = tmp.m_pIEnumVARIANT;
|
||||
tmp.m_pIEnumVARIANT = 0;
|
||||
}
|
||||
m_recBuf[0] = null;
|
||||
return last;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get next element in collection or null if at end
|
||||
*/
|
||||
public Variant Next()
|
||||
{
|
||||
if (hasMoreElements()) return (Variant)nextElement();
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Implements java.util.Enumeration
|
||||
* @return
|
||||
*/
|
||||
public boolean hasMoreElements() {
|
||||
{
|
||||
if (m_recBuf[0] == null) {
|
||||
if (this.Next(m_recBuf) <= 0)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public native int Next(Variant[] receiverArray);
|
||||
/**
|
||||
* Implements java.util.Enumeration
|
||||
* @return
|
||||
*/
|
||||
public Object nextElement() {
|
||||
Object last = m_recBuf[0];
|
||||
if (last == null) {
|
||||
if (this.Next(m_recBuf) <= 0)
|
||||
throw new java.util.NoSuchElementException();
|
||||
last = m_recBuf[0];
|
||||
}
|
||||
m_recBuf[0] = null;
|
||||
return last;
|
||||
}
|
||||
|
||||
public native void Skip(int count);
|
||||
/**
|
||||
* Get next element in collection or null if at end
|
||||
* @return
|
||||
*/
|
||||
public Variant Next() {
|
||||
if (hasMoreElements())
|
||||
return (Variant) nextElement();
|
||||
return null;
|
||||
}
|
||||
|
||||
public native void Reset();
|
||||
/**
|
||||
* @param receiverArray
|
||||
* @return
|
||||
*/
|
||||
public native int Next(Variant[] receiverArray);
|
||||
|
||||
public native void release();
|
||||
/**
|
||||
* @param count
|
||||
*/
|
||||
public native void Skip(int count);
|
||||
|
||||
protected void finalize()
|
||||
{
|
||||
//System.out.println("EnumVariant finalize start");
|
||||
if (m_pIEnumVARIANT != 0) this.release();
|
||||
//System.out.println("EnumVariant finalize end");
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public native void Reset();
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.jacob.com.JacobObject#release()
|
||||
*/
|
||||
public native void release();
|
||||
|
||||
protected void finalize() {
|
||||
//System.out.println("EnumVariant finalize start");
|
||||
if (m_pIEnumVARIANT != 0)
|
||||
this.release();
|
||||
//System.out.println("EnumVariant finalize end");
|
||||
}
|
||||
}
|
||||
@@ -30,17 +30,23 @@
|
||||
package com.jacob.com;
|
||||
|
||||
/**
|
||||
* All COM object created by JACOB extend this class so that
|
||||
* we can automatically release them when the thread is detached from
|
||||
* COM - if we leave it to the finalizer it will call the release from
|
||||
* another thread, which may result in a segmentation violation.
|
||||
* All COM object created by JACOB extend this class so that we can
|
||||
* automatically release them when the thread is detached from COM - if we leave
|
||||
* it to the finalizer it will call the release from another thread, which may
|
||||
* result in a segmentation violation.
|
||||
*/
|
||||
public class JacobObject
|
||||
{
|
||||
public JacobObject()
|
||||
{
|
||||
ROT.addObject(this);
|
||||
}
|
||||
public class JacobObject {
|
||||
/**
|
||||
* Standard constructor
|
||||
*/
|
||||
public JacobObject() {
|
||||
ROT.addObject(this);
|
||||
}
|
||||
|
||||
public void release() {}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void release() {
|
||||
// currently does nothing
|
||||
}
|
||||
}
|
||||
@@ -35,9 +35,8 @@ package com.jacob.com;
|
||||
* threaded components will be created if the client chooses an MTA
|
||||
* threading model for the java side of the app.
|
||||
*/
|
||||
public class MainSTA extends STA
|
||||
{
|
||||
public class MainSTA extends STA {
|
||||
static {
|
||||
System.loadLibrary("jacob");
|
||||
System.loadLibrary("jacob");
|
||||
}
|
||||
}
|
||||
@@ -28,72 +28,65 @@
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package com.jacob.com;
|
||||
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
|
||||
/**
|
||||
* The Running Object Table (ROT) maps each thread to a vector of
|
||||
* all the JacobObjects that were created in that thread. It always
|
||||
* operates on the current thread so all the methods are static and
|
||||
* they implicitly get the current thread.
|
||||
* Conceptually, this is similar to the ThreadLocal class of Java 1.2
|
||||
* but we are also supporting Java 1.6
|
||||
* The clearObjects method is used to release all the COM objects
|
||||
* created by Jacob in the current thread prior to uninitializing COM
|
||||
* for that thread. If we leave this job to the garbage collector,
|
||||
* then finalize might get called from a separate thread which is not
|
||||
* initialized for COM, and also the component itself may have been
|
||||
* freed.
|
||||
* The Running Object Table (ROT) maps each thread to a vector of all the
|
||||
* JacobObjects that were created in that thread. It always operates on the
|
||||
* current thread so all the methods are static and they implicitly get the
|
||||
* current thread. Conceptually, this is similar to the ThreadLocal class of
|
||||
* Java 1.2 but we are also supporting Java 1.6 The clearObjects method is used
|
||||
* to release all the COM objects created by Jacob in the current thread prior
|
||||
* to uninitializing COM for that thread. If we leave this job to the garbage
|
||||
* collector, then finalize might get called from a separate thread which is not
|
||||
* initialized for COM, and also the component itself may have been freed.
|
||||
*/
|
||||
public abstract class ROT
|
||||
{
|
||||
public abstract class ROT {
|
||||
private static Hashtable rot = new Hashtable();
|
||||
|
||||
protected static void addThread()
|
||||
{
|
||||
String t_name = Thread.currentThread().getName();
|
||||
if (rot.contains(t_name)) return;
|
||||
Vector v = new Vector();
|
||||
rot.put(t_name, v);
|
||||
protected static void addThread() {
|
||||
String t_name = Thread.currentThread().getName();
|
||||
if (rot.contains(t_name))
|
||||
return;
|
||||
Vector v = new Vector();
|
||||
rot.put(t_name, v);
|
||||
}
|
||||
|
||||
protected static void clearObjects()
|
||||
{
|
||||
String t_name = Thread.currentThread().getName();
|
||||
Vector v = (Vector)rot.get(t_name);
|
||||
if (v != null)
|
||||
{
|
||||
while (!v.isEmpty())
|
||||
{
|
||||
JacobObject o = (JacobObject)v.elementAt(0);
|
||||
//System.out.println(t_name + " release:"+o+"->"+o.getClass().getName());
|
||||
if (o != null) o.release();
|
||||
v.removeElementAt(0);
|
||||
protected static void clearObjects() {
|
||||
String t_name = Thread.currentThread().getName();
|
||||
Vector v = (Vector) rot.get(t_name);
|
||||
if (v != null) {
|
||||
while (!v.isEmpty()) {
|
||||
JacobObject o = (JacobObject) v.elementAt(0);
|
||||
//System.out.println(t_name + "
|
||||
// release:"+o+"->"+o.getClass().getName());
|
||||
if (o != null)
|
||||
o.release();
|
||||
v.removeElementAt(0);
|
||||
}
|
||||
rot.remove(t_name);
|
||||
}
|
||||
rot.remove(t_name);
|
||||
}
|
||||
}
|
||||
|
||||
protected static void addObject(JacobObject o)
|
||||
{
|
||||
String t_name = Thread.currentThread().getName();
|
||||
//System.out.println(t_name + " add:"+o+"->"+o.getClass().getName());
|
||||
Vector v = (Vector)rot.get(t_name);
|
||||
if (v == null)
|
||||
{
|
||||
// this thread has not been initialized as a COM thread
|
||||
// so make it part of MTA for backwards compatibility
|
||||
ComThread.InitMTA(false);
|
||||
addThread();
|
||||
v = (Vector)rot.get(t_name);
|
||||
}
|
||||
if (v != null)
|
||||
{
|
||||
v.addElement(o);
|
||||
}
|
||||
protected static void addObject(JacobObject o) {
|
||||
String t_name = Thread.currentThread().getName();
|
||||
//System.out.println(t_name + " add:"+o+"->"+o.getClass().getName());
|
||||
Vector v = (Vector) rot.get(t_name);
|
||||
if (v == null) {
|
||||
// this thread has not been initialized as a COM thread
|
||||
// so make it part of MTA for backwards compatibility
|
||||
ComThread.InitMTA(false);
|
||||
addThread();
|
||||
v = (Vector) rot.get(t_name);
|
||||
}
|
||||
if (v != null) {
|
||||
v.addElement(o);
|
||||
}
|
||||
}
|
||||
|
||||
static {
|
||||
System.loadLibrary("jacob");
|
||||
System.loadLibrary("jacob");
|
||||
}
|
||||
}
|
||||
@@ -30,56 +30,62 @@
|
||||
package com.jacob.com;
|
||||
|
||||
/**
|
||||
* A class that implements a Single Threaded Apartment.
|
||||
* Users will subclass this and override OnInit() and OnQuit()
|
||||
* where they will create and destroy a COM component that wants to
|
||||
* run in an STA other than the main STA.
|
||||
* A class that implements a Single Threaded Apartment. Users will subclass this
|
||||
* and override OnInit() and OnQuit() where they will create and destroy a COM
|
||||
* component that wants to run in an STA other than the main STA.
|
||||
*/
|
||||
public class STA extends Thread
|
||||
{
|
||||
public class STA extends Thread {
|
||||
/**
|
||||
* TODO: no references exist to this. should it be dropped
|
||||
*/
|
||||
public int threadID;
|
||||
|
||||
public STA()
|
||||
{
|
||||
start(); // start the thread
|
||||
}
|
||||
/**
|
||||
* constructor for STA
|
||||
*/
|
||||
public STA() {
|
||||
start(); // start the thread
|
||||
}
|
||||
|
||||
public void run()
|
||||
{
|
||||
// init COM
|
||||
ComThread.InitSTA();
|
||||
if (OnInit())
|
||||
{
|
||||
// this call blocks in the win32 message loop
|
||||
// until quitMessagePump is called
|
||||
doMessagePump();
|
||||
}
|
||||
OnQuit();
|
||||
// uninit COM
|
||||
ComThread.Release();
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Thread#run()
|
||||
*/
|
||||
public void run() {
|
||||
// init COM
|
||||
ComThread.InitSTA();
|
||||
if (OnInit()) {
|
||||
// this call blocks in the win32 message loop
|
||||
// until quitMessagePump is called
|
||||
doMessagePump();
|
||||
}
|
||||
OnQuit();
|
||||
// uninit COM
|
||||
ComThread.Release();
|
||||
}
|
||||
|
||||
/**
|
||||
* Override this method to create and initialize any COM
|
||||
* component that you want to run in this thread. If anything
|
||||
* fails, return false to terminate the thread.
|
||||
* Override this method to create and initialize any COM component that you
|
||||
* want to run in this thread. If anything fails, return false to terminate
|
||||
* the thread.
|
||||
* @return always returns true
|
||||
*/
|
||||
public boolean OnInit()
|
||||
{
|
||||
return true;
|
||||
public boolean OnInit() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Override this method to destroy any resource
|
||||
* before the thread exits and COM in uninitialized
|
||||
* Override this method to destroy any resource before the thread exits and
|
||||
* COM in uninitialized
|
||||
*/
|
||||
public void OnQuit()
|
||||
{
|
||||
public void OnQuit() {
|
||||
// there is nothing to see here
|
||||
}
|
||||
|
||||
public void quit()
|
||||
{
|
||||
quitMessagePump();
|
||||
/**
|
||||
* calls quitMessagePump
|
||||
*/
|
||||
public void quit() {
|
||||
quitMessagePump();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -93,6 +99,6 @@ public class STA extends Thread
|
||||
public native void quitMessagePump();
|
||||
|
||||
static {
|
||||
System.loadLibrary("jacob");
|
||||
System.loadLibrary("jacob");
|
||||
}
|
||||
}
|
||||
@@ -1,247 +1,659 @@
|
||||
/*
|
||||
* Copyright (c) 1999-2004 Sourceforge JACOB Project.
|
||||
* All rights reserved. Originator: Dan Adler (http://danadler.com).
|
||||
* Copyright (c) 1999-2004 Sourceforge JACOB Project. All rights reserved.
|
||||
* Originator: Dan Adler (http://danadler.com).
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Redistributions in any form must be accompanied by information on
|
||||
* how to obtain complete source code for the JACOB software.
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer. 2. Redistributions in
|
||||
* binary form must reproduce the above copyright notice, this list of
|
||||
* conditions and the following disclaimer in the documentation and/or other
|
||||
* materials provided with the distribution. 3. Redistributions in any form must
|
||||
* be accompanied by information on how to obtain complete source code for the
|
||||
* JACOB software.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package com.jacob.com;
|
||||
|
||||
public class SafeArray extends JacobObject
|
||||
{
|
||||
int m_pV = 0;
|
||||
/**
|
||||
* @author joe
|
||||
*
|
||||
* TODO To change the template for this generated type comment go to
|
||||
* Window - Preferences - Java - Code Style - Code Templates
|
||||
*/
|
||||
public class SafeArray extends JacobObject {
|
||||
int m_pV = 0;
|
||||
|
||||
public SafeArray() {}
|
||||
|
||||
public SafeArray(int vt)
|
||||
{
|
||||
init(vt, new int[] {0}, new int[] {-1});
|
||||
}
|
||||
|
||||
public SafeArray(int vt,int celems)
|
||||
{
|
||||
init(vt, new int[] {0}, new int[] {celems});
|
||||
}
|
||||
|
||||
public SafeArray(int vt,int celems1,int celems2)
|
||||
{
|
||||
init(vt, new int[] {0,0}, new int[] {celems1, celems2});
|
||||
}
|
||||
|
||||
public SafeArray(int vt,int lbounds[],int celems[])
|
||||
{
|
||||
init(vt, lbounds, celems);
|
||||
}
|
||||
|
||||
// convert a string to a VT_UI1 array
|
||||
public SafeArray(String s)
|
||||
{
|
||||
char[] ca = s.toCharArray();
|
||||
init(Variant.VariantByte, new int[] {0}, new int[] {ca.length});
|
||||
fromCharArray(ca);
|
||||
}
|
||||
|
||||
protected native void init(int vt, int lbounds[], int celems[]);
|
||||
|
||||
// not impl
|
||||
public int getNumLocks() { return 0; }
|
||||
|
||||
// convert a VT_UI1 array to string
|
||||
public String asString()
|
||||
{
|
||||
if (getvt() != Variant.VariantByte) return null;
|
||||
char ja[] = toCharArray();
|
||||
return new String(ja);
|
||||
}
|
||||
|
||||
|
||||
public native Object clone();
|
||||
// call this to explicitly release the com object before gc
|
||||
|
||||
public void release()
|
||||
{
|
||||
destroy();
|
||||
}
|
||||
|
||||
public native void destroy();
|
||||
public native int getvt();
|
||||
protected void finalize()
|
||||
{
|
||||
//System.out.println("SafeArray finalize start");
|
||||
if (m_pV != 0) release();
|
||||
//System.out.println("SafeArray finalize end");
|
||||
}
|
||||
public native void reinit(SafeArray sa);
|
||||
public native void reinterpretType(int vt);
|
||||
|
||||
public native int getLBound();
|
||||
public native int getLBound(int dim);
|
||||
public native int getUBound();
|
||||
public native int getUBound(int dim);
|
||||
|
||||
public native int getNumDim();
|
||||
public native int getFeatures();
|
||||
public native int getElemSize();
|
||||
|
||||
public native void fromCharArray(char ja[]);
|
||||
public native void fromIntArray(int ja[]);
|
||||
public native void fromShortArray(short ja[]);
|
||||
public native void fromDoubleArray(double ja[]);
|
||||
public native void fromStringArray(String ja[]);
|
||||
public native void fromByteArray(byte ja[]);
|
||||
public native void fromFloatArray(float ja[]);
|
||||
public native void fromBooleanArray(boolean ja[]);
|
||||
public native void fromVariantArray(Variant ja[]);
|
||||
|
||||
public native char[] toCharArray();
|
||||
public native int[] toIntArray();
|
||||
public native short[] toShortArray();
|
||||
public native double[] toDoubleArray();
|
||||
public native String[] toStringArray();
|
||||
public native byte[] toByteArray();
|
||||
public native float[] toFloatArray();
|
||||
public native boolean[] toBooleanArray();
|
||||
public native Variant[] toVariantArray();
|
||||
|
||||
// char access
|
||||
public native char getChar(int sa_idx);
|
||||
public native char getChar(int sa_idx1, int sa_idx2);
|
||||
public native void setChar(int sa_idx, char c);
|
||||
public native void setChar(int sa_idx1, int sa_idx2, char c);
|
||||
public native void getChars(int sa_idx, int nelems, char ja[], int ja_start);
|
||||
public native void setChars(int sa_idx, int nelems, char ja[], int ja_start);
|
||||
|
||||
// int access
|
||||
public native int getInt(int sa_idx);
|
||||
public native int getInt(int sa_idx1, int sa_idx2);
|
||||
public native void setInt(int sa_idx, int c);
|
||||
public native void setInt(int sa_idx1, int sa_idx2, int c);
|
||||
public native void getInts(int sa_idx, int nelems, int ja[], int ja_start);
|
||||
public native void setInts(int sa_idx, int nelems, int ja[], int ja_start);
|
||||
|
||||
// short access
|
||||
public native short getShort(int sa_idx);
|
||||
public native short getShort(int sa_idx1, int sa_idx2);
|
||||
public native void setShort(int sa_idx, short c);
|
||||
public native void setShort(int sa_idx1, int sa_idx2, short c);
|
||||
public native void getShorts(int sa_idx, int nelems, short ja[], int ja_start);
|
||||
public native void setShorts(int sa_idx, int nelems, short ja[], int ja_start);
|
||||
|
||||
// double access
|
||||
public native double getDouble(int sa_idx);
|
||||
public native double getDouble(int sa_idx1, int sa_idx2);
|
||||
public native void setDouble(int sa_idx, double c);
|
||||
public native void setDouble(int sa_idx1, int sa_idx2, double c);
|
||||
public native void getDoubles(int sa_idx, int nelems, double ja[], int ja_start);
|
||||
public native void setDoubles(int sa_idx, int nelems, double ja[], int ja_start);
|
||||
|
||||
// string access
|
||||
public native String getString(int sa_idx);
|
||||
public native String getString(int sa_idx1, int sa_idx2);
|
||||
public native void setString(int sa_idx, String c);
|
||||
public native void setString(int sa_idx1, int sa_idx2, String c);
|
||||
public native void getStrings(int sa_idx, int nelems, String ja[], int ja_start);
|
||||
public native void setStrings(int sa_idx, int nelems, String ja[], int ja_start);
|
||||
|
||||
// byte access
|
||||
public native byte getByte(int sa_idx);
|
||||
public native byte getByte(int sa_idx1, int sa_idx2);
|
||||
public native void setByte(int sa_idx, byte c);
|
||||
public native void setByte(int sa_idx1, int sa_idx2, byte c);
|
||||
public native void getBytes(int sa_idx, int nelems, byte ja[], int ja_start);
|
||||
public native void setBytes(int sa_idx, int nelems, byte ja[], int ja_start);
|
||||
|
||||
// float access
|
||||
public native float getFloat(int sa_idx);
|
||||
public native float getFloat(int sa_idx1, int sa_idx2);
|
||||
public native void setFloat(int sa_idx, float c);
|
||||
public native void setFloat(int sa_idx1, int sa_idx2, float c);
|
||||
public native void getFloats(int sa_idx, int nelems, float ja[], int ja_start);
|
||||
public native void setFloats(int sa_idx, int nelems, float ja[], int ja_start);
|
||||
|
||||
// boolean access
|
||||
public native boolean getBoolean(int sa_idx);
|
||||
public native boolean getBoolean(int sa_idx1, int sa_idx2);
|
||||
public native void setBoolean(int sa_idx, boolean c);
|
||||
public native void setBoolean(int sa_idx1, int sa_idx2, boolean c);
|
||||
public native void getBooleans(int sa_idx, int nelems, boolean ja[], int ja_start);
|
||||
public native void setBooleans(int sa_idx, int nelems, boolean ja[], int ja_start);
|
||||
|
||||
// variant access
|
||||
public native Variant getVariant(int sa_idx);
|
||||
public native Variant getVariant(int sa_idx1, int sa_idx2);
|
||||
public native void setVariant(int sa_idx, Variant c);
|
||||
public native void setVariant(int sa_idx1, int sa_idx2, Variant c);
|
||||
public native void getVariants(int sa_idx, int nelems, Variant ja[], int ja_start);
|
||||
public native void setVariants(int sa_idx, int nelems, Variant ja[], int ja_start);
|
||||
|
||||
public String toString()
|
||||
{
|
||||
String s = "";
|
||||
int ndim = getNumDim();
|
||||
if (ndim == 1)
|
||||
{
|
||||
int ldim = getLBound();
|
||||
int udim = getUBound();
|
||||
for (int i = ldim; i <= udim; i++)
|
||||
{
|
||||
Variant v = getVariant(i);
|
||||
|
||||
if (((v.getvt() & Variant.VariantTypeMask) | Variant.VariantArray) == v.getvt())
|
||||
{
|
||||
return s + "[" + v.toSafeArray().toString() + "]";
|
||||
}
|
||||
else
|
||||
{
|
||||
s += " " + v.toString();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* constructor
|
||||
*
|
||||
*/
|
||||
public SafeArray() {
|
||||
}
|
||||
else if (ndim == 2)
|
||||
{
|
||||
int ldim1 = getLBound(1);
|
||||
int udim1 = getUBound(1);
|
||||
|
||||
int ldim2 = getLBound(2);
|
||||
int udim2 = getUBound(2);
|
||||
|
||||
for (int i = ldim1; i <= udim1; i++)
|
||||
{
|
||||
for (int j = ldim2; j <= udim2; j++)
|
||||
{
|
||||
Variant v = getVariant(i, j);
|
||||
s += " " + v.toString();
|
||||
}
|
||||
s += "\n";
|
||||
}
|
||||
/**
|
||||
* constructor
|
||||
* @param vt
|
||||
*/
|
||||
public SafeArray(int vt) {
|
||||
init(vt, new int[] { 0 }, new int[] { -1 });
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
static {
|
||||
System.loadLibrary("jacob");
|
||||
}
|
||||
/**
|
||||
* constructor
|
||||
* @param vt
|
||||
* @param celems
|
||||
*/
|
||||
public SafeArray(int vt, int celems) {
|
||||
init(vt, new int[] { 0 }, new int[] { celems });
|
||||
}
|
||||
|
||||
/**
|
||||
* @param vt
|
||||
* @param celems1
|
||||
* @param celems2
|
||||
*/
|
||||
public SafeArray(int vt, int celems1, int celems2) {
|
||||
init(vt, new int[] { 0, 0 }, new int[] { celems1, celems2 });
|
||||
}
|
||||
|
||||
/**
|
||||
* constructor
|
||||
* @param vt
|
||||
* @param lbounds
|
||||
* @param celems
|
||||
*/
|
||||
public SafeArray(int vt, int lbounds[], int celems[]) {
|
||||
init(vt, lbounds, celems);
|
||||
}
|
||||
|
||||
/**
|
||||
* convert a string to a VT_UI1 array
|
||||
* @param s source string
|
||||
*/
|
||||
public SafeArray(String s) {
|
||||
char[] ca = s.toCharArray();
|
||||
init(Variant.VariantByte, new int[] { 0 }, new int[] { ca.length });
|
||||
fromCharArray(ca);
|
||||
}
|
||||
|
||||
protected native void init(int vt, int lbounds[], int celems[]);
|
||||
|
||||
/**
|
||||
* not impl
|
||||
* @return 0
|
||||
*/
|
||||
public int getNumLocks() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* convert a VT_UI1 array to string
|
||||
* @return variant byte as a string
|
||||
*/
|
||||
public String asString() {
|
||||
if (getvt() != Variant.VariantByte)
|
||||
return null;
|
||||
char ja[] = toCharArray();
|
||||
return new String(ja);
|
||||
}
|
||||
|
||||
public native Object clone();
|
||||
|
||||
|
||||
/**
|
||||
* call this to explicitly release the com object before gc
|
||||
*/
|
||||
public void release() {
|
||||
destroy();
|
||||
}
|
||||
|
||||
public native void destroy();
|
||||
|
||||
public native int getvt();
|
||||
|
||||
protected void finalize() {
|
||||
//System.out.println("SafeArray finalize start");
|
||||
if (m_pV != 0)
|
||||
release();
|
||||
//System.out.println("SafeArray finalize end");
|
||||
}
|
||||
|
||||
public native void reinit(SafeArray sa);
|
||||
|
||||
public native void reinterpretType(int vt);
|
||||
|
||||
public native int getLBound();
|
||||
|
||||
public native int getLBound(int dim);
|
||||
|
||||
public native int getUBound();
|
||||
|
||||
public native int getUBound(int dim);
|
||||
|
||||
public native int getNumDim();
|
||||
|
||||
public native int getFeatures();
|
||||
|
||||
public native int getElemSize();
|
||||
|
||||
public native void fromCharArray(char ja[]);
|
||||
|
||||
public native void fromIntArray(int ja[]);
|
||||
|
||||
public native void fromShortArray(short ja[]);
|
||||
|
||||
public native void fromDoubleArray(double ja[]);
|
||||
|
||||
public native void fromStringArray(String ja[]);
|
||||
|
||||
public native void fromByteArray(byte ja[]);
|
||||
|
||||
public native void fromFloatArray(float ja[]);
|
||||
|
||||
public native void fromBooleanArray(boolean ja[]);
|
||||
|
||||
public native void fromVariantArray(Variant ja[]);
|
||||
|
||||
public native char[] toCharArray();
|
||||
|
||||
public native int[] toIntArray();
|
||||
|
||||
public native short[] toShortArray();
|
||||
|
||||
public native double[] toDoubleArray();
|
||||
|
||||
public native String[] toStringArray();
|
||||
|
||||
public native byte[] toByteArray();
|
||||
|
||||
public native float[] toFloatArray();
|
||||
|
||||
public native boolean[] toBooleanArray();
|
||||
|
||||
public native Variant[] toVariantArray();
|
||||
|
||||
/**
|
||||
* char access
|
||||
* @param sa_idx
|
||||
* @return
|
||||
*/
|
||||
public native char getChar(int sa_idx);
|
||||
|
||||
/**
|
||||
* char access
|
||||
* @param sa_idx1
|
||||
* @param sa_idx2
|
||||
* @return
|
||||
*/
|
||||
public native char getChar(int sa_idx1, int sa_idx2);
|
||||
|
||||
/**
|
||||
* char access
|
||||
* @param sa_idx
|
||||
* @param c
|
||||
*/
|
||||
public native void setChar(int sa_idx, char c);
|
||||
|
||||
/**
|
||||
* char access
|
||||
* @param sa_idx1
|
||||
* @param sa_idx2
|
||||
* @param c
|
||||
*/
|
||||
public native void setChar(int sa_idx1, int sa_idx2, char c);
|
||||
|
||||
/**
|
||||
* char access
|
||||
* @param sa_idx
|
||||
* @param nelems
|
||||
* @param ja
|
||||
* @param ja_start
|
||||
*/
|
||||
public native void getChars(int sa_idx, int nelems, char ja[], int ja_start);
|
||||
|
||||
/**
|
||||
* char access
|
||||
* @param sa_idx
|
||||
* @param nelems
|
||||
* @param ja
|
||||
* @param ja_start
|
||||
*/
|
||||
public native void setChars(int sa_idx, int nelems, char ja[], int ja_start);
|
||||
|
||||
/**
|
||||
* int access
|
||||
* @param sa_idx
|
||||
* @return
|
||||
*/
|
||||
public native int getInt(int sa_idx);
|
||||
|
||||
/**
|
||||
* int access
|
||||
* @param sa_idx1
|
||||
* @param sa_idx2
|
||||
* @return
|
||||
*/
|
||||
public native int getInt(int sa_idx1, int sa_idx2);
|
||||
|
||||
/**
|
||||
* int access
|
||||
* @param sa_idx
|
||||
* @param c
|
||||
*/
|
||||
public native void setInt(int sa_idx, int c);
|
||||
|
||||
/**
|
||||
* int access
|
||||
* @param sa_idx1
|
||||
* @param sa_idx2
|
||||
* @param c
|
||||
*/
|
||||
public native void setInt(int sa_idx1, int sa_idx2, int c);
|
||||
|
||||
/**
|
||||
* int access
|
||||
* @param sa_idx
|
||||
* @param nelems
|
||||
* @param ja
|
||||
* @param ja_start
|
||||
*/
|
||||
public native void getInts(int sa_idx, int nelems, int ja[], int ja_start);
|
||||
|
||||
/**
|
||||
* int access
|
||||
* @param sa_idx
|
||||
* @param nelems
|
||||
* @param ja
|
||||
* @param ja_start
|
||||
*/
|
||||
public native void setInts(int sa_idx, int nelems, int ja[], int ja_start);
|
||||
|
||||
/**
|
||||
* short access
|
||||
* @param sa_idx
|
||||
* @return
|
||||
*/
|
||||
public native short getShort(int sa_idx);
|
||||
|
||||
/**
|
||||
* short access
|
||||
* @param sa_idx1
|
||||
* @param sa_idx2
|
||||
* @return
|
||||
*/
|
||||
public native short getShort(int sa_idx1, int sa_idx2);
|
||||
|
||||
/**
|
||||
* short access
|
||||
* @param sa_idx
|
||||
* @param c
|
||||
*/
|
||||
public native void setShort(int sa_idx, short c);
|
||||
|
||||
/**
|
||||
* short access
|
||||
* @param sa_idx1
|
||||
* @param sa_idx2
|
||||
* @param c
|
||||
*/
|
||||
public native void setShort(int sa_idx1, int sa_idx2, short c);
|
||||
|
||||
/**
|
||||
* short access
|
||||
* @param sa_idx
|
||||
* @param nelems
|
||||
* @param ja
|
||||
* @param ja_start
|
||||
*/
|
||||
public native void getShorts(int sa_idx, int nelems, short ja[],
|
||||
int ja_start);
|
||||
|
||||
/**
|
||||
* short access
|
||||
* @param sa_idx
|
||||
* @param nelems
|
||||
* @param ja
|
||||
* @param ja_start
|
||||
*/
|
||||
public native void setShorts(int sa_idx, int nelems, short ja[],
|
||||
int ja_start);
|
||||
|
||||
/**
|
||||
* double access
|
||||
* @param sa_idx
|
||||
* @return
|
||||
*/
|
||||
public native double getDouble(int sa_idx);
|
||||
|
||||
/**
|
||||
* double access
|
||||
* @param sa_idx1
|
||||
* @param sa_idx2
|
||||
* @return
|
||||
*/
|
||||
public native double getDouble(int sa_idx1, int sa_idx2);
|
||||
|
||||
/**
|
||||
* double access
|
||||
* @param sa_idx
|
||||
* @param c
|
||||
*/
|
||||
public native void setDouble(int sa_idx, double c);
|
||||
|
||||
/**
|
||||
* double access
|
||||
* @param sa_idx1
|
||||
* @param sa_idx2
|
||||
* @param c
|
||||
*/
|
||||
public native void setDouble(int sa_idx1, int sa_idx2, double c);
|
||||
|
||||
/**
|
||||
* double access
|
||||
* @param sa_idx
|
||||
* @param nelems
|
||||
* @param ja
|
||||
* @param ja_start
|
||||
*/
|
||||
public native void getDoubles(int sa_idx, int nelems, double ja[],
|
||||
int ja_start);
|
||||
|
||||
/**
|
||||
* double access
|
||||
* @param sa_idx
|
||||
* @param nelems
|
||||
* @param ja
|
||||
* @param ja_start
|
||||
*/
|
||||
public native void setDoubles(int sa_idx, int nelems, double ja[],
|
||||
int ja_start);
|
||||
|
||||
/**
|
||||
* string access
|
||||
* @param sa_idx
|
||||
* @return
|
||||
*/
|
||||
public native String getString(int sa_idx);
|
||||
|
||||
/**
|
||||
* string access
|
||||
* @param sa_idx1
|
||||
* @param sa_idx2
|
||||
* @return
|
||||
*/
|
||||
public native String getString(int sa_idx1, int sa_idx2);
|
||||
|
||||
/**
|
||||
* string access
|
||||
* @param sa_idx
|
||||
* @param c
|
||||
*/
|
||||
public native void setString(int sa_idx, String c);
|
||||
|
||||
/**
|
||||
* string access
|
||||
* @param sa_idx1
|
||||
* @param sa_idx2
|
||||
* @param c
|
||||
*/
|
||||
public native void setString(int sa_idx1, int sa_idx2, String c);
|
||||
|
||||
/**
|
||||
* string access
|
||||
* @param sa_idx
|
||||
* @param nelems
|
||||
* @param ja
|
||||
* @param ja_start
|
||||
*/
|
||||
public native void getStrings(int sa_idx, int nelems, String ja[],
|
||||
int ja_start);
|
||||
|
||||
/**
|
||||
* string access
|
||||
* @param sa_idx
|
||||
* @param nelems
|
||||
* @param ja
|
||||
* @param ja_start
|
||||
*/
|
||||
public native void setStrings(int sa_idx, int nelems, String ja[],
|
||||
int ja_start);
|
||||
|
||||
/**
|
||||
* byte access
|
||||
* @param sa_idx
|
||||
* @return
|
||||
*/
|
||||
public native byte getByte(int sa_idx);
|
||||
|
||||
/**
|
||||
* byte access
|
||||
* @param sa_idx1
|
||||
* @param sa_idx2
|
||||
* @return
|
||||
*/
|
||||
public native byte getByte(int sa_idx1, int sa_idx2);
|
||||
|
||||
/**
|
||||
* byte access
|
||||
* @param sa_idx
|
||||
* @param c
|
||||
*/
|
||||
public native void setByte(int sa_idx, byte c);
|
||||
|
||||
/**
|
||||
* byte access
|
||||
* @param sa_idx1
|
||||
* @param sa_idx2
|
||||
* @param c
|
||||
*/
|
||||
public native void setByte(int sa_idx1, int sa_idx2, byte c);
|
||||
|
||||
public native void getBytes(int sa_idx, int nelems, byte ja[], int ja_start);
|
||||
|
||||
public native void setBytes(int sa_idx, int nelems, byte ja[], int ja_start);
|
||||
|
||||
/**
|
||||
* float access
|
||||
* @param sa_idx
|
||||
* @return
|
||||
*/
|
||||
public native float getFloat(int sa_idx);
|
||||
|
||||
/**
|
||||
* float access
|
||||
* @param sa_idx1
|
||||
* @param sa_idx2
|
||||
* @return
|
||||
*/
|
||||
public native float getFloat(int sa_idx1, int sa_idx2);
|
||||
|
||||
/**
|
||||
* float access
|
||||
* @param sa_idx
|
||||
* @param c
|
||||
*/
|
||||
public native void setFloat(int sa_idx, float c);
|
||||
|
||||
/**
|
||||
* float access
|
||||
* @param sa_idx1
|
||||
* @param sa_idx2
|
||||
* @param c
|
||||
*/
|
||||
public native void setFloat(int sa_idx1, int sa_idx2, float c);
|
||||
|
||||
/**
|
||||
* float access
|
||||
* @param sa_idx
|
||||
* @param nelems
|
||||
* @param ja
|
||||
* @param ja_start
|
||||
*/
|
||||
public native void getFloats(int sa_idx, int nelems, float ja[],
|
||||
int ja_start);
|
||||
|
||||
/**
|
||||
* float access
|
||||
* @param sa_idx
|
||||
* @param nelems
|
||||
* @param ja
|
||||
* @param ja_start
|
||||
*/
|
||||
public native void setFloats(int sa_idx, int nelems, float ja[],
|
||||
int ja_start);
|
||||
|
||||
/**
|
||||
* boolean access
|
||||
* @param sa_idx
|
||||
* @return
|
||||
*/
|
||||
public native boolean getBoolean(int sa_idx);
|
||||
|
||||
/**
|
||||
* boolean access
|
||||
* @param sa_idx1
|
||||
* @param sa_idx2
|
||||
* @return
|
||||
*/
|
||||
public native boolean getBoolean(int sa_idx1, int sa_idx2);
|
||||
|
||||
/**
|
||||
* boolean access
|
||||
* @param sa_idx
|
||||
* @param c
|
||||
*/
|
||||
public native void setBoolean(int sa_idx, boolean c);
|
||||
|
||||
/**
|
||||
* boolean access
|
||||
* @param sa_idx1
|
||||
* @param sa_idx2
|
||||
* @param c
|
||||
*/
|
||||
public native void setBoolean(int sa_idx1, int sa_idx2, boolean c);
|
||||
|
||||
/**
|
||||
* boolean access
|
||||
* @param sa_idx
|
||||
* @param nelems
|
||||
* @param ja
|
||||
* @param ja_start
|
||||
*/
|
||||
public native void getBooleans(int sa_idx, int nelems, boolean ja[],
|
||||
int ja_start);
|
||||
|
||||
/**
|
||||
* boolean access
|
||||
* @param sa_idx
|
||||
* @param nelems
|
||||
* @param ja
|
||||
* @param ja_start
|
||||
*/
|
||||
public native void setBooleans(int sa_idx, int nelems, boolean ja[],
|
||||
int ja_start);
|
||||
|
||||
/**
|
||||
* variant access
|
||||
* @param sa_idx
|
||||
* @return
|
||||
*/
|
||||
public native Variant getVariant(int sa_idx);
|
||||
|
||||
/**
|
||||
* variant access
|
||||
* @param sa_idx1
|
||||
* @param sa_idx2
|
||||
* @return
|
||||
*/
|
||||
public native Variant getVariant(int sa_idx1, int sa_idx2);
|
||||
|
||||
/**
|
||||
* variant access
|
||||
* @param sa_idx
|
||||
* @param c
|
||||
*/
|
||||
public native void setVariant(int sa_idx, Variant c);
|
||||
|
||||
/**
|
||||
* variant access
|
||||
* @param sa_idx1
|
||||
* @param sa_idx2
|
||||
* @param c
|
||||
*/
|
||||
public native void setVariant(int sa_idx1, int sa_idx2, Variant c);
|
||||
|
||||
/**
|
||||
* variant access
|
||||
* @param sa_idx
|
||||
* @param nelems
|
||||
* @param ja
|
||||
* @param ja_start
|
||||
*/
|
||||
public native void getVariants(int sa_idx, int nelems, Variant ja[],
|
||||
int ja_start);
|
||||
|
||||
/**
|
||||
* variant access
|
||||
* @param sa_idx
|
||||
* @param nelems
|
||||
* @param ja
|
||||
* @param ja_start
|
||||
*/
|
||||
public native void setVariants(int sa_idx, int nelems, Variant ja[],
|
||||
int ja_start);
|
||||
|
||||
/**
|
||||
* standard toString
|
||||
* @return
|
||||
*/
|
||||
public String toString() {
|
||||
String s = "";
|
||||
int ndim = getNumDim();
|
||||
if (ndim == 1) {
|
||||
int ldim = getLBound();
|
||||
int udim = getUBound();
|
||||
for (int i = ldim; i <= udim; i++) {
|
||||
Variant v = getVariant(i);
|
||||
|
||||
if (((v.getvt() & Variant.VariantTypeMask) | Variant.VariantArray) == v
|
||||
.getvt()) {
|
||||
return s + "[" + v.toSafeArray().toString() + "]";
|
||||
} else {
|
||||
s += " " + v.toString();
|
||||
}
|
||||
}
|
||||
} else if (ndim == 2) {
|
||||
int ldim1 = getLBound(1);
|
||||
int udim1 = getUBound(1);
|
||||
|
||||
int ldim2 = getLBound(2);
|
||||
int udim2 = getUBound(2);
|
||||
|
||||
for (int i = ldim1; i <= udim1; i++) {
|
||||
for (int j = ldim2; j <= udim2; j++) {
|
||||
Variant v = getVariant(i, j);
|
||||
s += " " + v.toString();
|
||||
}
|
||||
s += "\n";
|
||||
}
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
static {
|
||||
System.loadLibrary("jacob");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,37 +1,48 @@
|
||||
/*
|
||||
* Copyright (c) 1999-2004 Sourceforge JACOB Project.
|
||||
* All rights reserved. Originator: Dan Adler (http://danadler.com).
|
||||
* Copyright (c) 1999-2004 Sourceforge JACOB Project. All rights reserved.
|
||||
* Originator: Dan Adler (http://danadler.com).
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Redistributions in any form must be accompanied by information on
|
||||
* how to obtain complete source code for the JACOB software.
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer. 2. Redistributions in
|
||||
* binary form must reproduce the above copyright notice, this list of
|
||||
* conditions and the following disclaimer in the documentation and/or other
|
||||
* materials provided with the distribution. 3. Redistributions in any form must
|
||||
* be accompanied by information on how to obtain complete source code for the
|
||||
* JACOB software.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package com.jacob.com;
|
||||
|
||||
public class WrongThreadException extends RuntimeException
|
||||
{
|
||||
// Constructors
|
||||
public WrongThreadException() { super(); }
|
||||
public WrongThreadException(String s) { super(s); }
|
||||
/**
|
||||
* TODO: Exception thrown when? No references found
|
||||
*/
|
||||
public class WrongThreadException extends RuntimeException {
|
||||
/**
|
||||
* standard 0 arg constructor with no message
|
||||
*
|
||||
*/
|
||||
public WrongThreadException() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* standard constructor with a string message
|
||||
* @param s
|
||||
*/
|
||||
public WrongThreadException(String s) {
|
||||
super(s);
|
||||
}
|
||||
}
|
||||
@@ -35,18 +35,28 @@ EventProxy::EventProxy(JNIEnv *env, jobject aSinkObj,
|
||||
IID eid, CComBSTR mName[], DISPID mID[], int mNum) :
|
||||
m_cRef(0), pCP(pConn),
|
||||
eventIID(eid), MethNum(mNum), MethName(mName),
|
||||
MethID(mID), JMethID(NULL), javaSinkClass(NULL)
|
||||
MethID(mID), JMethID(NULL), javaSinkClass(NULL),
|
||||
variantClassMethod(NULL)
|
||||
{
|
||||
javaSinkObj = env->NewGlobalRef(aSinkObj);
|
||||
if (env->ExceptionOccurred()) { env->ExceptionDescribe();}
|
||||
// we need this to attach to the event invocation thread
|
||||
env->GetJavaVM(&jvm);
|
||||
if (env->ExceptionOccurred()) { env->ExceptionDescribe(); }
|
||||
AddRef();
|
||||
HRESULT hr = pCP->Advise(this, &dwEventCookie);
|
||||
if (SUCCEEDED(hr)) {
|
||||
// create a mapping from the DISPID's to jmethodID's by using
|
||||
// the method names I extracted from the classinfo
|
||||
JMethID = new jmethodID[MethNum];
|
||||
|
||||
javaSinkClass = env->GetObjectClass(javaSinkObj);
|
||||
if (javaSinkClass == NULL){ printf("can't figure out java sink class"); }
|
||||
if (env->ExceptionOccurred()) { env->ExceptionDescribe(); }
|
||||
variantClassMethod = env->GetMethodID(javaSinkClass, "getVariantClass", "()Ljava/lang/Class;");
|
||||
if (env->ExceptionOccurred()) { env->ExceptionDescribe(); }
|
||||
if (variantClassMethod == NULL) { printf("variantClassMethod == null\n"); }
|
||||
|
||||
const char *method;
|
||||
for(int i=0;i<MethNum;i++)
|
||||
{
|
||||
@@ -73,6 +83,7 @@ EventProxy::~EventProxy()
|
||||
jvm->AttachCurrentThread((void **)&env, jvm);
|
||||
|
||||
env->DeleteGlobalRef(javaSinkObj);
|
||||
if (env->ExceptionOccurred()) { env->ExceptionDescribe(); }
|
||||
if (MethNum) {
|
||||
delete [] MethName;
|
||||
delete [] MethID;
|
||||
@@ -131,19 +142,41 @@ STDMETHODIMP EventProxy::Invoke(DISPID dispID, REFIID riid,
|
||||
// attach to the current running thread
|
||||
jvm->AttachCurrentThread((void**)&env, jvm);
|
||||
|
||||
|
||||
// get variant class
|
||||
jclass vClass;
|
||||
// do this in a JACOB 1.8 backwards compatable way
|
||||
// this succeeds if the class was loaded from the bootstrap class loader
|
||||
vClass = env->FindClass("com/jacob/com/Variant");
|
||||
if (vClass == NULL){
|
||||
// see if our call back class implements our "special" method
|
||||
if (variantClassMethod != NULL){
|
||||
jobject variantFound = env->CallObjectMethod(javaSinkObj, variantClassMethod);
|
||||
if (env->ExceptionOccurred()) { env->ExceptionDescribe(); }
|
||||
if (variantFound == NULL) { printf("variantFound == null\n"); }
|
||||
vClass = (jclass)variantFound;
|
||||
} else {
|
||||
// dang they didn't. lets tell the user they are having a bad day
|
||||
printf("We're going to fail now in a way that is probably pretty ugly");
|
||||
printf("This application is probably running from a launcher where system class loader knows not Jacob\n");
|
||||
printf("The call back class does not implement 'Class getVariantClass()' that we can use to work around this\n");
|
||||
}
|
||||
}
|
||||
|
||||
// how many params
|
||||
int num = pDispParams->cArgs;
|
||||
// get variant class
|
||||
jclass vClass = env->FindClass("com/jacob/com/Variant");
|
||||
// and the constructor
|
||||
jmethodID vCons = env->GetMethodID(vClass, "<init>", "()V");
|
||||
if (env->ExceptionOccurred()) { env->ExceptionDescribe(); }
|
||||
// make an array of them
|
||||
jobjectArray varr = env->NewObjectArray(num, vClass, 0);
|
||||
if (env->ExceptionOccurred()) { env->ExceptionDescribe(); }
|
||||
int i,j;
|
||||
for(i=num-1,j=0;i>=0;i--,j++)
|
||||
{
|
||||
// construct a java variant holder
|
||||
jobject arg = env->NewObject(vClass, vCons);
|
||||
if (env->ExceptionOccurred()) { env->ExceptionDescribe(); }
|
||||
// get the empty variant from it
|
||||
VARIANT *va = extractVariant(env, arg);
|
||||
// copy the value
|
||||
@@ -151,11 +184,638 @@ STDMETHODIMP EventProxy::Invoke(DISPID dispID, REFIID riid,
|
||||
// put it in the array
|
||||
env->SetObjectArrayElement(varr, j, arg);
|
||||
env->DeleteLocalRef(arg);
|
||||
if (env->ExceptionOccurred()) { env->ExceptionDescribe(); }
|
||||
}
|
||||
// call the method
|
||||
env->CallVoidMethod(javaSinkObj, meth, varr);
|
||||
if (env->ExceptionOccurred()) { env->ExceptionDescribe(); }
|
||||
|
||||
// detach from thread
|
||||
|
||||
// Begin code from Jiffie team that copies parameters back from java to COM
|
||||
for(i=num-1,j=0;i>=0;i--,j++)
|
||||
{
|
||||
jobject arg = env->GetObjectArrayElement(varr, j);
|
||||
VARIANT *java = extractVariant(env, arg);
|
||||
VARIANT *com = &pDispParams->rgvarg[i];
|
||||
|
||||
switch (com->vt)
|
||||
{
|
||||
case VT_DISPATCH:
|
||||
{
|
||||
switch (java->vt)
|
||||
{
|
||||
case VT_DISPATCH:
|
||||
{
|
||||
V_DISPATCH(com) = V_DISPATCH(java);
|
||||
break;
|
||||
}
|
||||
|
||||
case VT_DISPATCH | VT_BYREF:
|
||||
{
|
||||
V_DISPATCH(com) = *V_DISPATCHREF(java);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case VT_DISPATCH | VT_BYREF:
|
||||
{
|
||||
switch (java->vt)
|
||||
{
|
||||
case VT_DISPATCH:
|
||||
{
|
||||
*V_DISPATCHREF(com) = V_DISPATCH(java);
|
||||
break;
|
||||
}
|
||||
|
||||
case VT_DISPATCH | VT_BYREF:
|
||||
{
|
||||
*V_DISPATCHREF(com) = *V_DISPATCHREF(java);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case VT_BOOL:
|
||||
{
|
||||
switch (java->vt)
|
||||
{
|
||||
case VT_BOOL:
|
||||
{
|
||||
V_BOOL(com) = V_BOOL(java);
|
||||
break;
|
||||
}
|
||||
|
||||
case VT_BOOL | VT_BYREF:
|
||||
{
|
||||
V_BOOL(com) = *V_BOOLREF(java);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case VT_BOOL | VT_BYREF:
|
||||
{
|
||||
switch (java->vt)
|
||||
{
|
||||
case VT_BOOL:
|
||||
{
|
||||
*V_BOOLREF(com) = V_BOOL(java);
|
||||
break;
|
||||
}
|
||||
|
||||
case VT_BOOL | VT_BYREF:
|
||||
{
|
||||
*V_BOOLREF(com) = *V_BOOLREF(java);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case VT_UI1:
|
||||
{
|
||||
switch (java->vt)
|
||||
{
|
||||
case VT_UI1:
|
||||
{
|
||||
V_UI1(com) = V_UI1(java);
|
||||
break;
|
||||
}
|
||||
|
||||
case VT_UI1 | VT_BYREF:
|
||||
{
|
||||
V_UI1(com) = *V_UI1REF(java);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case VT_UI1 | VT_BYREF:
|
||||
{
|
||||
switch (java->vt)
|
||||
{
|
||||
case VT_UI1:
|
||||
{
|
||||
*V_UI1REF(com) = V_UI1(java);
|
||||
break;
|
||||
}
|
||||
|
||||
case VT_UI1 | VT_BYREF:
|
||||
{
|
||||
*V_UI1REF(com) = *V_UI1REF(java);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case VT_I2:
|
||||
{
|
||||
switch (java->vt)
|
||||
{
|
||||
case VT_I2:
|
||||
{
|
||||
V_I2(com) = V_I2(java);
|
||||
break;
|
||||
}
|
||||
|
||||
case VT_I2 | VT_BYREF:
|
||||
{
|
||||
V_I2(com) = *V_I2REF(java);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case VT_I2 | VT_BYREF:
|
||||
{
|
||||
switch (java->vt)
|
||||
{
|
||||
case VT_I2:
|
||||
{
|
||||
*V_I2REF(com) = V_I2(java);
|
||||
break;
|
||||
}
|
||||
|
||||
case VT_I2 | VT_BYREF:
|
||||
{
|
||||
*V_I2REF(com) = *V_I2REF(java);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case VT_I4:
|
||||
{
|
||||
switch (java->vt)
|
||||
{
|
||||
case VT_I4:
|
||||
{
|
||||
V_I4(com) = V_I4(java);
|
||||
break;
|
||||
}
|
||||
|
||||
case VT_I4 | VT_BYREF:
|
||||
{
|
||||
V_I4(com) = *V_I4REF(java);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case VT_I4 | VT_BYREF:
|
||||
{
|
||||
switch (java->vt)
|
||||
{
|
||||
case VT_I4:
|
||||
{
|
||||
*V_I4REF(com) = V_I4(java);
|
||||
break;
|
||||
}
|
||||
|
||||
case VT_I4 | VT_BYREF:
|
||||
{
|
||||
*V_I4REF(com) = *V_I4REF(java);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case VT_R4:
|
||||
{
|
||||
switch (java->vt)
|
||||
{
|
||||
case VT_R4:
|
||||
{
|
||||
V_R4(com) = V_R4(java);
|
||||
break;
|
||||
}
|
||||
|
||||
case VT_R4 | VT_BYREF:
|
||||
{
|
||||
V_R4(com) = *V_R4REF(java);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case VT_R4 | VT_BYREF:
|
||||
{
|
||||
switch (java->vt)
|
||||
{
|
||||
case VT_R4:
|
||||
{
|
||||
*V_R4REF(com) = V_R4(java);
|
||||
break;
|
||||
}
|
||||
|
||||
case VT_R4 | VT_BYREF:
|
||||
{
|
||||
*V_R4REF(com) = *V_R4REF(java);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case VT_R8:
|
||||
{
|
||||
switch (java->vt)
|
||||
{
|
||||
case VT_R8:
|
||||
{
|
||||
V_R8(com) = V_R8(java);
|
||||
break;
|
||||
}
|
||||
|
||||
case VT_R8 | VT_BYREF:
|
||||
{
|
||||
V_R8(com) = *V_R8REF(java);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case VT_R8 | VT_BYREF:
|
||||
{
|
||||
switch (java->vt)
|
||||
{
|
||||
case VT_R8:
|
||||
{
|
||||
*V_R8REF(com) = V_R8(java);
|
||||
break;
|
||||
}
|
||||
|
||||
case VT_R8 | VT_BYREF:
|
||||
{
|
||||
*V_R8REF(com) = *V_R8REF(java);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case VT_I1:
|
||||
{
|
||||
switch (java->vt)
|
||||
{
|
||||
case VT_I1:
|
||||
{
|
||||
V_I1(com) = V_I1(java);
|
||||
break;
|
||||
}
|
||||
|
||||
case VT_I1 | VT_BYREF:
|
||||
{
|
||||
V_I1(com) = *V_I1REF(java);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case VT_I1 | VT_BYREF:
|
||||
{
|
||||
switch (java->vt)
|
||||
{
|
||||
case VT_I1:
|
||||
{
|
||||
*V_I1REF(com) = V_I1(java);
|
||||
break;
|
||||
}
|
||||
|
||||
case VT_I1 | VT_BYREF:
|
||||
{
|
||||
*V_I1REF(com) = *V_I1REF(java);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case VT_UI2:
|
||||
{
|
||||
switch (java->vt)
|
||||
{
|
||||
case VT_UI2:
|
||||
{
|
||||
V_UI2(com) = V_UI2(java);
|
||||
break;
|
||||
}
|
||||
|
||||
case VT_UI2 | VT_BYREF:
|
||||
{
|
||||
V_UI2(com) = *V_UI2REF(java);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case VT_UI2 | VT_BYREF:
|
||||
{
|
||||
switch (java->vt)
|
||||
{
|
||||
case VT_UI2:
|
||||
{
|
||||
*V_UI2REF(com) = V_UI2(java);
|
||||
break;
|
||||
}
|
||||
|
||||
case VT_UI2 | VT_BYREF:
|
||||
{
|
||||
*V_UI2REF(com) = *V_UI2REF(java);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case VT_UI4:
|
||||
{
|
||||
switch (java->vt)
|
||||
{
|
||||
case VT_UI4:
|
||||
{
|
||||
V_UI4(com) = V_UI4(java);
|
||||
break;
|
||||
}
|
||||
|
||||
case VT_UI4 | VT_BYREF:
|
||||
{
|
||||
V_UI4(com) = *V_UI4REF(java);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case VT_UI4 | VT_BYREF:
|
||||
{
|
||||
switch (java->vt)
|
||||
{
|
||||
case VT_UI4:
|
||||
{
|
||||
*V_UI4REF(com) = V_UI4(java);
|
||||
break;
|
||||
}
|
||||
|
||||
case VT_UI4 | VT_BYREF:
|
||||
{
|
||||
*V_UI4REF(com) = *V_UI4REF(java);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case VT_INT:
|
||||
{
|
||||
switch (java->vt)
|
||||
{
|
||||
case VT_INT:
|
||||
{
|
||||
V_INT(com) = V_INT(java);
|
||||
break;
|
||||
}
|
||||
|
||||
case VT_INT | VT_BYREF:
|
||||
{
|
||||
V_INT(com) = *V_INTREF(java);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case VT_INT | VT_BYREF:
|
||||
{
|
||||
switch (java->vt)
|
||||
{
|
||||
case VT_INT:
|
||||
{
|
||||
*V_INTREF(com) = V_INT(java);
|
||||
break;
|
||||
}
|
||||
|
||||
case VT_INT | VT_BYREF:
|
||||
{
|
||||
*V_INTREF(com) = *V_INTREF(java);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case VT_UINT:
|
||||
{
|
||||
switch (java->vt)
|
||||
{
|
||||
case VT_UINT:
|
||||
{
|
||||
V_UINT(com) = V_UINT(java);
|
||||
break;
|
||||
}
|
||||
|
||||
case VT_UINT | VT_BYREF:
|
||||
{
|
||||
V_UINT(com) = *V_UINTREF(java);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case VT_UINT | VT_BYREF:
|
||||
{
|
||||
switch (java->vt)
|
||||
{
|
||||
case VT_UINT:
|
||||
{
|
||||
*V_UINTREF(com) = V_UINT(java);
|
||||
break;
|
||||
}
|
||||
|
||||
case VT_UINT | VT_BYREF:
|
||||
{
|
||||
*V_UINTREF(com) = *V_UINTREF(java);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case VT_CY:
|
||||
{
|
||||
switch (java->vt)
|
||||
{
|
||||
case VT_CY:
|
||||
{
|
||||
V_CY(com) = V_CY(java);
|
||||
break;
|
||||
}
|
||||
|
||||
case VT_CY | VT_BYREF:
|
||||
{
|
||||
V_CY(com) = *V_CYREF(java);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case VT_CY | VT_BYREF:
|
||||
{
|
||||
switch (java->vt)
|
||||
{
|
||||
case VT_CY:
|
||||
{
|
||||
*V_CYREF(com) = V_CY(java);
|
||||
break;
|
||||
}
|
||||
|
||||
case VT_CY | VT_BYREF:
|
||||
{
|
||||
*V_CYREF(com) = *V_CYREF(java);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case VT_DATE:
|
||||
{
|
||||
switch (java->vt)
|
||||
{
|
||||
case VT_DATE:
|
||||
{
|
||||
V_DATE(com) = V_DATE(java);
|
||||
break;
|
||||
}
|
||||
|
||||
case VT_DATE | VT_BYREF:
|
||||
{
|
||||
V_DATE(com) = *V_DATEREF(java);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case VT_DATE | VT_BYREF:
|
||||
{
|
||||
switch (java->vt)
|
||||
{
|
||||
case VT_DATE:
|
||||
{
|
||||
*V_DATEREF(com) = V_DATE(java);
|
||||
break;
|
||||
}
|
||||
|
||||
case VT_DATE | VT_BYREF:
|
||||
{
|
||||
*V_DATEREF(com) = *V_DATEREF(java);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case VT_BSTR:
|
||||
{
|
||||
switch (java->vt)
|
||||
{
|
||||
case VT_BSTR:
|
||||
{
|
||||
V_BSTR(com) = V_BSTR(java);
|
||||
break;
|
||||
}
|
||||
|
||||
case VT_BSTR | VT_BYREF:
|
||||
{
|
||||
V_BSTR(com) = *V_BSTRREF(java);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case VT_BSTR | VT_BYREF:
|
||||
{
|
||||
switch (java->vt)
|
||||
{
|
||||
case VT_BSTR:
|
||||
{
|
||||
*V_BSTRREF(com) = V_BSTR(java);
|
||||
break;
|
||||
}
|
||||
|
||||
case VT_BSTR | VT_BYREF:
|
||||
{
|
||||
*V_BSTRREF(com) = *V_BSTRREF(java);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case VT_DECIMAL:
|
||||
{
|
||||
switch (java->vt)
|
||||
{
|
||||
case VT_DECIMAL:
|
||||
{
|
||||
V_DECIMAL(com) = V_DECIMAL(java);
|
||||
break;
|
||||
}
|
||||
|
||||
case VT_DECIMAL | VT_BYREF:
|
||||
{
|
||||
V_DECIMAL(com) = *V_DECIMALREF(java);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case VT_DECIMAL | VT_BYREF:
|
||||
{
|
||||
switch (java->vt)
|
||||
{
|
||||
case VT_DECIMAL:
|
||||
{
|
||||
*V_DECIMALREF(com) = V_DECIMAL(java);
|
||||
break;
|
||||
}
|
||||
|
||||
case VT_DECIMAL | VT_BYREF:
|
||||
{
|
||||
*V_DECIMALREF(com) = *V_DECIMALREF(java);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
env->DeleteLocalRef(arg);
|
||||
}
|
||||
// End code from Jiffie team that copies parameters back from java to COM
|
||||
|
||||
// detach from thread
|
||||
jvm->DetachCurrentThread();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@@ -59,6 +59,8 @@ private:
|
||||
DWORD dwEventCookie; // connection point cookie
|
||||
jobject javaSinkObj; // the java object to delegate calls
|
||||
jclass javaSinkClass; // the java class of the object
|
||||
jmethodID variantClassMethod; // the method on the javaSinkObj that will return the Variant class
|
||||
|
||||
IID eventIID; // the interface iid passed in
|
||||
int MethNum;
|
||||
CComBSTR *MethName; // Array of method names
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
package samples.ado;
|
||||
|
||||
import com.jacob.com.*;
|
||||
|
||||
public class Command extends Dispatch
|
||||
@@ -12,13 +14,14 @@ public class Command extends Dispatch
|
||||
* turn a Dispatch object into a wider object - it must exist
|
||||
* in every wrapper class whose instances may be returned from
|
||||
* method calls wrapped in VT_DISPATCH Variants.
|
||||
* @param dispatchTarget
|
||||
*/
|
||||
public Command(Dispatch d)
|
||||
public Command(Dispatch dispatchTarget)
|
||||
{
|
||||
// take over the IDispatch pointer
|
||||
m_pDispatch = d.m_pDispatch;
|
||||
m_pDispatch = dispatchTarget.m_pDispatch;
|
||||
// null out the input's pointer
|
||||
d.m_pDispatch = 0;
|
||||
dispatchTarget.m_pDispatch = 0;
|
||||
}
|
||||
|
||||
public Variant getProperties()
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
package samples.ado;
|
||||
|
||||
// Enum: CommandTypeEnum
|
||||
|
||||
public interface CommandTypeEnum
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
package samples.ado;
|
||||
|
||||
import com.jacob.com.*;
|
||||
|
||||
public class Connection extends Dispatch
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
package samples.ado;
|
||||
import com.jacob.com.*;
|
||||
|
||||
public class Field extends Dispatch
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
package samples.ado;
|
||||
import com.jacob.com.*;
|
||||
|
||||
public class Fields extends Dispatch
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
package samples.ado;
|
||||
import com.jacob.com.*;
|
||||
|
||||
public class Recordset extends Dispatch
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
This is the WFC equivalent of the JACOB ADO example.
|
||||
|
||||
This code must be compiled with JVC and run with JVIEW.
|
||||
9
samples/ado/ms/README.txt
Normal file
9
samples/ado/ms/README.txt
Normal file
@@ -0,0 +1,9 @@
|
||||
This is the WFC equivalent of the JACOB ADO example.
|
||||
|
||||
This code must be compiled with JVC and run with JVIEW.
|
||||
|
||||
The file testms.java has been renamed to tesetms.java.txt
|
||||
because most folks building this application will
|
||||
not have the MS JVM installed and will get compiler
|
||||
warnings. The MS JVM is going away eventually
|
||||
so this whole test will eventually go away.
|
||||
@@ -1,3 +1,5 @@
|
||||
package samples.ado.ms;
|
||||
|
||||
import com.ms.com.*;
|
||||
import com.ms.wfc.data.*;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
package samples.ado;
|
||||
import com.jacob.com.*;
|
||||
|
||||
public class test
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
package samples.applet;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.applet.*;
|
||||
@@ -5,6 +7,9 @@ import java.applet.*;
|
||||
import com.jacob.com.*;
|
||||
import com.jacob.activeX.*;
|
||||
|
||||
/**
|
||||
* Applet test case
|
||||
*/
|
||||
public class AppTest extends Applet implements ActionListener
|
||||
{
|
||||
TextField in;
|
||||
@@ -13,6 +18,9 @@ public class AppTest extends Applet implements ActionListener
|
||||
ActiveXComponent sC = null;
|
||||
Object sControl = null;
|
||||
|
||||
/**
|
||||
* startup method
|
||||
*/
|
||||
public void init()
|
||||
{
|
||||
setLayout(new FlowLayout());
|
||||
@@ -23,6 +31,10 @@ public class AppTest extends Applet implements ActionListener
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* action method that receives button actions
|
||||
* @param ev the event
|
||||
*/
|
||||
public void actionPerformed(ActionEvent ev)
|
||||
{
|
||||
if (sC == null) {
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
package samples.servlet;
|
||||
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.http.*;
|
||||
import java.io.*;
|
||||
|
||||
@@ -5,6 +5,11 @@ import com.jacob.activeX.*;
|
||||
|
||||
class Access
|
||||
{
|
||||
/**
|
||||
* the main loop for the test
|
||||
* @param args
|
||||
* @throws Exception
|
||||
*/
|
||||
public static void main(String[] args) throws Exception
|
||||
{
|
||||
ComThread.InitSTA();
|
||||
@@ -25,6 +30,9 @@ class Access
|
||||
|
||||
/**
|
||||
* Open a database
|
||||
* @param ax
|
||||
* @param fileName
|
||||
* @return dispatch object that was opened
|
||||
*/
|
||||
public static Dispatch open(ActiveXComponent ax, String fileName)
|
||||
{
|
||||
@@ -37,6 +45,7 @@ class Access
|
||||
|
||||
/**
|
||||
* Close a database
|
||||
* @param openDB db to be closed
|
||||
*/
|
||||
public static void close(Dispatch openDB)
|
||||
{
|
||||
@@ -45,6 +54,8 @@ class Access
|
||||
|
||||
/**
|
||||
* Extract the values from the recordset
|
||||
* @param recset
|
||||
* @return Variant that is the returned values
|
||||
*/
|
||||
public static Variant getValues(Dispatch recset)
|
||||
{
|
||||
@@ -54,6 +65,11 @@ class Access
|
||||
return v;
|
||||
}
|
||||
|
||||
/**
|
||||
* should return ?? for the passed in ??
|
||||
* @param qd
|
||||
* @return Variant results of query?
|
||||
*/
|
||||
public static Variant getByQueryDef(Dispatch qd)
|
||||
{
|
||||
// get a reference to the recordset
|
||||
@@ -69,6 +85,11 @@ class Access
|
||||
return vals;
|
||||
}
|
||||
|
||||
/**
|
||||
* gets the columns form the rec set
|
||||
* @param recset
|
||||
* @return list of column names
|
||||
*/
|
||||
public static String[] getColumns(Dispatch recset)
|
||||
{
|
||||
Dispatch flds = Dispatch.get(recset, "Fields").toDispatch();
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package samples.test.atl;
|
||||
|
||||
import com.jacob.com.*;
|
||||
import com.jacob.activeX.*;
|
||||
|
||||
class MultiFace
|
||||
class MultiFaceTest
|
||||
{
|
||||
public static void main(String[] args)
|
||||
{
|
||||
Reference in New Issue
Block a user