Skip to content

Commit

Permalink
Merged from master.
Browse files Browse the repository at this point in the history
  • Loading branch information
dblock committed Oct 4, 2013
2 parents cb8f9dd + 35cc5e2 commit f6ceaf3
Show file tree
Hide file tree
Showing 116 changed files with 17,367 additions and 9,606 deletions.
1 change: 1 addition & 0 deletions .classpath
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
<classpathentry kind="lib" path="lib/test/reflections-0.9.8.jar"/>
<classpathentry kind="var" path="JNA_LIB"/>
<classpathentry kind="output" path="build.eclipse/classes"/>
</classpath>
62 changes: 0 additions & 62 deletions .settings/org.eclipse.jdt.core.prefs

This file was deleted.

3 changes: 0 additions & 3 deletions .settings/org.eclipse.ltk.core.refactoring.prefs

This file was deleted.

12 changes: 8 additions & 4 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
NOTE: as of JNA 4.0, JNA is now dual-licensed under LGPL and ASL (see LICENSE).
NOTE: as of JNA 4.0, JNA is now dual-licensed under LGPL and ASL (see LICENSE).

NOTE: JNI native support is typically incompatible between minor versions, and almost always incompatible between major versions.

Expand All @@ -7,12 +7,16 @@ Next Release (4.0.1)

Features
--------
* Add `com.sun.jna.platform.win32.Advapi32Util.registryCloseKey` - [@falldog] (https://github.com/falldog).
* Enable platform tests to be run w/o building native bits - [@twall](https://github.com/twall)
* Added `com.sun.jna.platform.win32.Advapi32Util.registryCloseKey` - [@falldog] (https://github.com/falldog).
* Enabled platform tests to be run w/o building native bits - [@twall](https://github.com/twall).
* Added COM/Typelib java code generator `com.sun.jna.platform.win32.COM.tlb.TlbImp` - [@wolftobias](https://github.com/wolftobias).
* [#226](https://github.com/twall/jna/issues/226): Added OSGI information to jna-platform.jar - [@brettwooldridge](https://github.com/brettwooldridge).
* [#267](https://github.com/twall/jna/pull/267): Added support for Windows RAS32 API, `com.sun.jna.platform.win32.Rasapi32` and `Rasapi32Util` - [@kc7bfi](https://github.com/kc7bfi).
* [#101](https://github.com/twall/jna/issues/101): Modify `com.sun.jna.platform.win32.Advapi32Util.registryGet*` API to support `KEY_WOW64` option - [@falldog] (https://github.com/falldog).

Bug Fixes
---------
* Fix inconsistent behavior on `Structure.ByValue` fields within a `Structure` - [@twall](https://github.com/twall)
* Fixed inconsistent behavior on `Structure.ByValue` fields within a `Structure` - [@twall](https://github.com/twall).

Release 4.0
===========
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ Features
* Type-safety for native pointers
* VM crash protection (optional)
* Optimized direct mapping for high-performance applications.
* COM support for early and late binding.
* COM/Typelib java code generator.

Community and Support
=====================
Expand Down
10 changes: 9 additions & 1 deletion build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@
<attribute name="Bundle-Name" value="jna"/>
<attribute name="Bundle-Description" value="JNA Library"/>
<attribute name="Bundle-SymbolicName" value="com.sun.jna"/>
<attribute name="Bundle-Version" value="${spec.version}"/>
<attribute name="Bundle-Version" value="${jna.major}.${jna.minor}.${jna.revision}"/>
<attribute name="Bundle-RequiredExecutionEnvironment" value="J2SE-1.4"/>
<attribute name="Bundle-Vendor" value="${vendor}"/>
<attribute name="Bundle-ActivationPolicy" value="lazy"/>
Expand Down Expand Up @@ -489,6 +489,14 @@ osname=macosx;processor=x86;processor=x86-64;processor=ppc
<property name="libs.junit.classpath" location="lib/junit.jar"/>
<property name="javac.source" value="${platform.compatibility}"/>
<property name="javac.target" value="${platform.compatibility}"/>
<!-- OSGi manifest properties -->
<property name="vendor" value="${vendor}"/>
<property name="impl.title" value="${impl.title}.platform"/>
<property name="impl.version" value="${impl.version}"/>
<property name="spec.title" value="${spec.title}"/>
<property name="spec.vendor" value="${spec.vendor}"/>
<property name="spec.version" value="${spec.version}"/>
<property name="osgi.version" value="${jna.major}.${jna.minor}.${jna.revision}"/>
<fileset dir="${contrib}" includes="platform/build.xml" />
</subant>
<!-- Sources package as required by maven -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
import com.sun.jna.platform.win32.WinGDI.BITMAPINFO;
import com.sun.jna.platform.win32.WinNT.HANDLE;
import com.sun.jna.platform.win32.WinUser.BLENDFUNCTION;
import com.sun.jna.platform.win32.WinUser.POINT;
import com.sun.jna.platform.win32.WinDef.POINT;
import com.sun.jna.platform.win32.WinUser.SIZE;
import com.sun.jna.ptr.PointerByReference;

Expand Down
2 changes: 1 addition & 1 deletion contrib/msoffice/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry combineaccessrules="false" kind="src" path="/jnalib"/>
<classpathentry kind="lib" path="C:/GitHub/jna-3.5.1.jar"/>
<classpathentry kind="var" path="JNA_LIB"/>
<classpathentry kind="output" path="bin"/>
</classpath>
2 changes: 0 additions & 2 deletions contrib/msoffice/.settings/org.eclipse.core.resources.prefs

This file was deleted.

Binary file modified contrib/msoffice/jnatest.doc
Binary file not shown.
Binary file modified contrib/msoffice/jnatest.xls
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.sun.jna.platform.win32.office;
package com.sun.jna.platform.win32.COM;

import java.io.FileWriter;
import java.io.IOException;
Expand All @@ -10,10 +10,11 @@
public class COMInfoUtil {

public static void main(String[] args) {
FileWriter writer = null;
try {
String filename = "C:\\TEMP\\CLSIDs.txt";
ArrayList<COMInfo> comInfos = COMUtils.getAllCOMInfoOnSystem();
FileWriter writer = new FileWriter(filename);
writer = new FileWriter(filename);

for (COMInfo comInfo : comInfos) {
String result = "CLSID: " + comInfo.clsid + "\n";
Expand All @@ -31,6 +32,12 @@ public static void main(String[] args) {
+ comInfos.size());
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
writer.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
package com.sun.jna.platform.win32.COM.office;

import com.sun.jna.platform.win32.Variant.VARIANT;
import com.sun.jna.platform.win32.COM.COMException;
import com.sun.jna.platform.win32.COM.COMLateBindingObject;
import com.sun.jna.platform.win32.COM.IDispatch;

public class MSExcel extends COMLateBindingObject {

public MSExcel() throws COMException {
super("Excel.Application", false);
}

public MSExcel(boolean visible) throws COMException {
this();
this.setVisible(visible);
}

public void setVisible(boolean bVisible) throws COMException {
this.setProperty("Visible", bVisible);
}

public String getVersion() throws COMException {
return this.getStringProperty("Version");
}

public void newExcelBook() throws COMException {
this.invokeNoReply("Add", getWorkbooks());
}

public void openExcelBook(String filename, boolean bVisible)
throws COMException {
// OpenDocument
this.invokeNoReply("Open", getWorkbooks(), new VARIANT(filename));
}

public void closeActiveWorkbook(boolean bSave) throws COMException {
this.invokeNoReply("Close", getActiveWorkbook(), new VARIANT(bSave));
}

public void quit() throws COMException {
this.invokeNoReply("Quit");
}

public void insertValue(String range, String value) throws COMException {
Range pRange = new Range(this.getAutomationProperty("Range",
this.getActiveSheet(), new VARIANT(range)));
this.setProperty("Value", pRange, new VARIANT(value));
}

public Application getApplication() {
return new Application(this.getAutomationProperty("Application"));
}

public ActiveWorkbook getActiveWorkbook() {
return new ActiveWorkbook(this.getAutomationProperty("ActiveWorkbook"));
}

public Workbooks getWorkbooks() {
return new Workbooks(this.getAutomationProperty("WorkBooks"));
}

public ActiveSheet getActiveSheet() {
return new ActiveSheet(this.getAutomationProperty("ActiveSheet"));
}

public class Application extends COMLateBindingObject {

public Application(IDispatch iDispatch) throws COMException {
super(iDispatch);
}
}

public class Workbooks extends COMLateBindingObject {
public Workbooks(IDispatch iDispatch) throws COMException {
super(iDispatch);
}
}

public class ActiveWorkbook extends COMLateBindingObject {
public ActiveWorkbook(IDispatch iDispatch) throws COMException {
super(iDispatch);
}
}

public class ActiveSheet extends COMLateBindingObject {
public ActiveSheet(IDispatch iDispatch) throws COMException {
super(iDispatch);
}
}

public class Range extends COMLateBindingObject {
public Range(IDispatch iDispatch) throws COMException {
super(iDispatch);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
package com.sun.jna.platform.win32.COM.office;

import java.io.File;

import com.sun.jna.platform.win32.COM.COMException;
import com.sun.jna.platform.win32.WinDef.LONG;

public class MSOfficeDemo {

/**
* @param args
*/
public static void main(String[] args) {
new MSOfficeDemo();
}

private String currentWorkingDir = new File("").getAbsolutePath()
+ File.separator;

public MSOfficeDemo() {
this.testMSWord();
// this.testMSExcel();
}

public void testMSWord() {
MSWord msWord = null;
LONG wdFormatPDF = new LONG(17); // PDF format.
LONG wdFormatRTF = new LONG(6); // Rich text format (RTF).
LONG wdFormatHTML = new LONG(8); // Standard HTML format.

try {
msWord = new MSWord();
System.out.println("MSWord version: " + msWord.getVersion());

msWord.setVisible(true);
// msWord.newDocument();
msWord.openDocument(currentWorkingDir + "jnatest.doc", true);
msWord.insertText("Hello from JNA!");
// wait 10sec. before closing
Thread.currentThread().sleep(10000);
// save in different formats
// pdf format is only supported in MSWord 2007 and above
// msWord.SaveAs("C:\\TEMP\\jnatestSaveAs.pdf", wdFormatPDF);
msWord.SaveAs("C:\\TEMP\\jnatestSaveAs.rtf", wdFormatRTF);
msWord.SaveAs("C:\\TEMP\\jnatestSaveAs.html", wdFormatHTML);
// close and save the document
msWord.closeActiveDocument(true);
msWord.setVisible(true);
msWord.newDocument();
// msWord.openDocument(currentWorkingDir + "jnatest.doc", true);
msWord.insertText("Hello from JNA!");
// close and save the document
msWord.closeActiveDocument(true);
// wait then close word
msWord.quit();
} catch(InterruptedException ie) {
ie.printStackTrace();
} catch (COMException e) {
if (e.getExcepInfo() != null) {
System.out
.println("bstrSource: " + e.getExcepInfo().bstrSource);
System.out.println("bstrDescription: "
+ e.getExcepInfo().bstrDescription);
}

// print stack trace
e.printStackTrace();

if (msWord != null)
msWord.quit();
}
}

public void testMSExcel() {
MSExcel msExcel = null;

try {
msExcel = new MSExcel();
System.out.println("MSExcel version: " + msExcel.getVersion());
msExcel.setVisible(true);
// msExcel.newExcelBook();
msExcel.openExcelBook(currentWorkingDir + "jnatest.xls", true);
msExcel.insertValue("A1", "Hello from JNA!");
// wait 10sec. before closing
Thread.currentThread().sleep(10000);
// close and save the active sheet
msExcel.closeActiveWorkbook(true);
msExcel.setVisible(true);
// msExcel.newExcelBook();
msExcel.openExcelBook(currentWorkingDir + "jnatest.xls", true);
msExcel.insertValue("A1", "Hello from JNA!");
// close and save the active sheet
msExcel.closeActiveWorkbook(true);
} catch (Exception e) {
e.printStackTrace();

if (msExcel != null)
msExcel.quit();
}
}
}
Loading

0 comments on commit f6ceaf3

Please sign in to comment.