-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update msoffice samples with two MSDN demos and test compatibility
The office samples were verified for these environments: Platform Windows 10 64Bit: * Java 1.8.0_77 64 Bit + Office 2013 64 Bit (Testversion) * Java 1.8.0_77 32 Bit + Office 2013 64 Bit (Testversion) Platform Windows 7 64Bit: * Java 1.8.0_60 64 Bit + Office 2007 32 Bit * Java 1.8.0_60 32 Bit + Office 2007 32 Bit Closes #572
- Loading branch information
1 parent
0db246e
commit 25729de
Showing
68 changed files
with
3,288 additions
and
515 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
contrib/msoffice/src/com/sun/jna/platform/win32/COM/Helper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
|
||
package com.sun.jna.platform.win32.COM; | ||
|
||
import java.io.File; | ||
import java.io.FileOutputStream; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.io.OutputStream; | ||
import java.nio.file.Files; | ||
|
||
public class Helper { | ||
public static final File tempDir = new File(System.getProperty("java.io.tmpdir")); | ||
|
||
/** | ||
* Sleep for specified seconds. | ||
* | ||
* @param seconds | ||
*/ | ||
public static void sleep(int seconds) { | ||
try { | ||
Thread.sleep(seconds * 1000L); | ||
} catch (InterruptedException ex) { | ||
// Ignore | ||
} | ||
} | ||
|
||
/** | ||
* Extract data contained in classpath into a system accessible target file. | ||
* | ||
* @param localPath | ||
* @param target | ||
* @throws IOException | ||
*/ | ||
public static void extractClasspathFileToReal(String localPath, File target) throws IOException { | ||
InputStream is = null; | ||
OutputStream os = null; | ||
try { | ||
is = Helper.class.getResourceAsStream(localPath); | ||
os = new FileOutputStream(target); | ||
|
||
int read; | ||
byte[] buffer = new byte[20480]; | ||
|
||
while((read = is.read(buffer)) > 0) { | ||
os.write(buffer, 0, read); | ||
} | ||
|
||
} finally { | ||
if(is != null) { | ||
try { | ||
is.close(); | ||
} catch(Exception ex) {} | ||
} | ||
if(os != null) { | ||
try { | ||
os.close(); | ||
} catch(Exception ex) {} | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Create a temporary file, that does not exist. | ||
* | ||
* @param prefix | ||
* @param suffix | ||
* @return | ||
* @throws IOException | ||
*/ | ||
public static File createNotExistingFile(String prefix, String suffix) throws IOException { | ||
File tempFile = Files.createTempFile(prefix, suffix).toFile(); | ||
tempFile.delete(); | ||
return tempFile; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.