Bug 58326 - Forbidden APIs patches - second set of changes for charset settings
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1701713 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
91e6a64627
commit
50107cae16
@ -82,6 +82,7 @@ import org.apache.poi.hssf.record.WriteAccessRecord;
|
|||||||
import org.apache.poi.hssf.record.WriteProtectRecord;
|
import org.apache.poi.hssf.record.WriteProtectRecord;
|
||||||
import org.apache.poi.hssf.record.common.UnicodeString;
|
import org.apache.poi.hssf.record.common.UnicodeString;
|
||||||
import org.apache.poi.hssf.util.HSSFColor;
|
import org.apache.poi.hssf.util.HSSFColor;
|
||||||
|
import org.apache.poi.poifs.crypt.CryptoFunctions;
|
||||||
import org.apache.poi.ss.formula.EvaluationWorkbook.ExternalName;
|
import org.apache.poi.ss.formula.EvaluationWorkbook.ExternalName;
|
||||||
import org.apache.poi.ss.formula.EvaluationWorkbook.ExternalSheet;
|
import org.apache.poi.ss.formula.EvaluationWorkbook.ExternalSheet;
|
||||||
import org.apache.poi.ss.formula.EvaluationWorkbook.ExternalSheetRange;
|
import org.apache.poi.ss.formula.EvaluationWorkbook.ExternalSheetRange;
|
||||||
@ -2375,7 +2376,7 @@ public final class InternalWorkbook {
|
|||||||
WriteAccessRecord waccess = getWriteAccess();
|
WriteAccessRecord waccess = getWriteAccess();
|
||||||
/* WriteProtectRecord wprotect =*/ getWriteProtect();
|
/* WriteProtectRecord wprotect =*/ getWriteProtect();
|
||||||
frec.setReadOnly((short)1);
|
frec.setReadOnly((short)1);
|
||||||
frec.setPassword(FileSharingRecord.hashPassword(password));
|
frec.setPassword((short)CryptoFunctions.createXorVerifier1(password));
|
||||||
frec.setUsername(username);
|
frec.setUsername(username);
|
||||||
waccess.setUsername(username);
|
waccess.setUsername(username);
|
||||||
}
|
}
|
||||||
|
@ -52,25 +52,6 @@ public final class FileSharingRecord extends StandardRecord {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//this is the world's lamest "security". thanks to Wouter van Vugt for making me
|
|
||||||
//not have to try real hard. -ACO
|
|
||||||
public static short hashPassword(String password) {
|
|
||||||
byte[] passwordCharacters = password.getBytes();
|
|
||||||
int hash = 0;
|
|
||||||
if (passwordCharacters.length > 0) {
|
|
||||||
int charIndex = passwordCharacters.length;
|
|
||||||
while (charIndex-- > 0) {
|
|
||||||
hash = ((hash >> 14) & 0x01) | ((hash << 1) & 0x7fff);
|
|
||||||
hash ^= passwordCharacters[charIndex];
|
|
||||||
}
|
|
||||||
// also hash with charcount
|
|
||||||
hash = ((hash >> 14) & 0x01) | ((hash << 1) & 0x7fff);
|
|
||||||
hash ^= passwordCharacters.length;
|
|
||||||
hash ^= (0x8000 | ('N' << 8) | 'K');
|
|
||||||
}
|
|
||||||
return (short)hash;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set the readonly flag
|
* set the readonly flag
|
||||||
*
|
*
|
||||||
|
@ -1819,21 +1819,20 @@ public final class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet {
|
|||||||
* Aggregates the drawing records and dumps the escher record hierarchy
|
* Aggregates the drawing records and dumps the escher record hierarchy
|
||||||
* to the standard output.
|
* to the standard output.
|
||||||
*/
|
*/
|
||||||
public void dumpDrawingRecords(boolean fat) {
|
public void dumpDrawingRecords(boolean fat, PrintWriter pw) {
|
||||||
_sheet.aggregateDrawingRecords(_book.getDrawingManager(), false);
|
_sheet.aggregateDrawingRecords(_book.getDrawingManager(), false);
|
||||||
|
|
||||||
EscherAggregate r = (EscherAggregate) getSheet().findFirstRecordBySid(EscherAggregate.sid);
|
EscherAggregate r = (EscherAggregate) getSheet().findFirstRecordBySid(EscherAggregate.sid);
|
||||||
List<EscherRecord> escherRecords = r.getEscherRecords();
|
List<EscherRecord> escherRecords = r.getEscherRecords();
|
||||||
PrintWriter w = new PrintWriter(System.out);
|
|
||||||
for (Iterator<EscherRecord> iterator = escherRecords.iterator(); iterator.hasNext(); ) {
|
for (Iterator<EscherRecord> iterator = escherRecords.iterator(); iterator.hasNext(); ) {
|
||||||
EscherRecord escherRecord = iterator.next();
|
EscherRecord escherRecord = iterator.next();
|
||||||
if (fat) {
|
if (fat) {
|
||||||
System.out.println(escherRecord.toString());
|
pw.println(escherRecord.toString());
|
||||||
} else {
|
} else {
|
||||||
escherRecord.display(w, 0);
|
escherRecord.display(pw, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
w.flush();
|
pw.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2053,6 +2052,7 @@ public final class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet {
|
|||||||
*
|
*
|
||||||
* @return the name of this sheet
|
* @return the name of this sheet
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("resource")
|
||||||
public String getSheetName() {
|
public String getSheetName() {
|
||||||
HSSFWorkbook wb = getWorkbook();
|
HSSFWorkbook wb = getWorkbook();
|
||||||
int idx = wb.getSheetIndex(this);
|
int idx = wb.getSheetIndex(this);
|
||||||
|
@ -20,6 +20,9 @@ package org.apache.poi.util;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.OutputStreamWriter;
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
|
|
||||||
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||||
@ -30,23 +33,24 @@ import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
|
|||||||
*/
|
*/
|
||||||
public class DrawingDump
|
public class DrawingDump
|
||||||
{
|
{
|
||||||
public static void main( String[] args ) throws IOException
|
public static void main( String[] args ) throws IOException {
|
||||||
{
|
OutputStreamWriter osw = new OutputStreamWriter(System.out, Charset.defaultCharset());
|
||||||
NPOIFSFileSystem fs =
|
PrintWriter pw = new PrintWriter(osw);
|
||||||
new NPOIFSFileSystem(new File(args[0]));
|
NPOIFSFileSystem fs = new NPOIFSFileSystem(new File(args[0]));
|
||||||
HSSFWorkbook wb = new HSSFWorkbook(fs);
|
HSSFWorkbook wb = new HSSFWorkbook(fs);
|
||||||
try {
|
try {
|
||||||
System.out.println( "Drawing group:" );
|
pw.println( "Drawing group:" );
|
||||||
wb.dumpDrawingGroupRecords(true);
|
wb.dumpDrawingGroupRecords(true);
|
||||||
|
|
||||||
for (int sheetNum = 1; sheetNum <= wb.getNumberOfSheets(); sheetNum++)
|
for (int sheetNum = 1; sheetNum <= wb.getNumberOfSheets(); sheetNum++)
|
||||||
{
|
{
|
||||||
System.out.println( "Sheet " + sheetNum + ":" );
|
pw.println( "Sheet " + sheetNum + ":" );
|
||||||
HSSFSheet sheet = wb.getSheetAt(sheetNum - 1);
|
HSSFSheet sheet = wb.getSheetAt(sheetNum - 1);
|
||||||
sheet.dumpDrawingRecords(true);
|
sheet.dumpDrawingRecords(true, pw);
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
wb.close();
|
wb.close();
|
||||||
|
fs.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,6 +47,7 @@ import javax.xml.bind.DatatypeConverter;
|
|||||||
import org.apache.poi.poifs.crypt.CryptoFunctions;
|
import org.apache.poi.poifs.crypt.CryptoFunctions;
|
||||||
import org.apache.poi.poifs.crypt.HashAlgorithm;
|
import org.apache.poi.poifs.crypt.HashAlgorithm;
|
||||||
import org.apache.poi.poifs.crypt.dsig.SignatureConfig;
|
import org.apache.poi.poifs.crypt.dsig.SignatureConfig;
|
||||||
|
import org.apache.poi.util.HexDump;
|
||||||
import org.apache.poi.util.IOUtils;
|
import org.apache.poi.util.IOUtils;
|
||||||
import org.apache.poi.util.POILogFactory;
|
import org.apache.poi.util.POILogFactory;
|
||||||
import org.apache.poi.util.POILogger;
|
import org.apache.poi.util.POILogger;
|
||||||
@ -160,7 +161,7 @@ public class TSPTimeStampService implements TimeStampService {
|
|||||||
|
|
||||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||||
IOUtils.copy(huc.getInputStream(), bos);
|
IOUtils.copy(huc.getInputStream(), bos);
|
||||||
LOG.log(POILogger.DEBUG, "response content: ", bos.toString());
|
LOG.log(POILogger.DEBUG, "response content: ", HexDump.dump(bos.toByteArray(), 0, 0));
|
||||||
|
|
||||||
if (!contentType.startsWith(signatureConfig.isTspOldProtocol()
|
if (!contentType.startsWith(signatureConfig.isTspOldProtocol()
|
||||||
? "application/timestamp-response"
|
? "application/timestamp-response"
|
||||||
|
@ -40,6 +40,8 @@ public class TestEncryptionInfo {
|
|||||||
assertEquals(32, info.getVerifier().getEncryptedVerifierHash().length);
|
assertEquals(32, info.getVerifier().getEncryptedVerifierHash().length);
|
||||||
assertEquals(CipherProvider.aes, info.getHeader().getCipherProvider());
|
assertEquals(CipherProvider.aes, info.getHeader().getCipherProvider());
|
||||||
assertEquals("Microsoft Enhanced RSA and AES Cryptographic Provider", info.getHeader().getCspName());
|
assertEquals("Microsoft Enhanced RSA and AES Cryptographic Provider", info.getHeader().getCspName());
|
||||||
|
|
||||||
|
fs.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -57,5 +59,7 @@ public class TestEncryptionInfo {
|
|||||||
assertEquals(64, info.getVerifier().getEncryptedVerifierHash().length);
|
assertEquals(64, info.getVerifier().getEncryptedVerifierHash().length);
|
||||||
assertEquals(CipherProvider.aes, info.getHeader().getCipherProvider());
|
assertEquals(CipherProvider.aes, info.getHeader().getCipherProvider());
|
||||||
// assertEquals("Microsoft Enhanced RSA and AES Cryptographic Provider", info.getHeader().getCspName());
|
// assertEquals("Microsoft Enhanced RSA and AES Cryptographic Provider", info.getHeader().getCspName());
|
||||||
|
|
||||||
|
fs.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
package org.apache.poi.hdgf;
|
package org.apache.poi.hdgf;
|
||||||
|
|
||||||
import java.io.FileInputStream;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
|
||||||
@ -34,6 +34,7 @@ import org.apache.poi.poifs.filesystem.DocumentEntry;
|
|||||||
import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
|
import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
|
||||||
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
|
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
|
||||||
import org.apache.poi.util.LittleEndian;
|
import org.apache.poi.util.LittleEndian;
|
||||||
|
import org.apache.poi.util.LocaleUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* See
|
* See
|
||||||
@ -80,7 +81,7 @@ public final class HDGFDiagram extends POIDocument {
|
|||||||
dir.createDocumentInputStream("VisioDocument").read(_docstream);
|
dir.createDocumentInputStream("VisioDocument").read(_docstream);
|
||||||
|
|
||||||
// Check it's really visio
|
// Check it's really visio
|
||||||
String typeString = new String(_docstream, 0, 20);
|
String typeString = new String(_docstream, 0, 20, LocaleUtil.CHARSET_1252 );
|
||||||
if(! typeString.equals(VISIO_HEADER)) {
|
if(! typeString.equals(VISIO_HEADER)) {
|
||||||
throw new IllegalArgumentException("Wasn't a valid visio document, started with " + typeString);
|
throw new IllegalArgumentException("Wasn't a valid visio document, started with " + typeString);
|
||||||
}
|
}
|
||||||
@ -171,7 +172,9 @@ public final class HDGFDiagram extends POIDocument {
|
|||||||
* For testing only
|
* For testing only
|
||||||
*/
|
*/
|
||||||
public static void main(String args[]) throws Exception {
|
public static void main(String args[]) throws Exception {
|
||||||
HDGFDiagram hdgf = new HDGFDiagram(new POIFSFileSystem(new FileInputStream(args[0])));
|
NPOIFSFileSystem pfs = new NPOIFSFileSystem(new File(args[0]));
|
||||||
|
HDGFDiagram hdgf = new HDGFDiagram(pfs);
|
||||||
hdgf.debug();
|
hdgf.debug();
|
||||||
|
pfs.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
|
|
||||||
|
import org.apache.poi.util.LocaleUtil;
|
||||||
import org.apache.poi.util.POILogFactory;
|
import org.apache.poi.util.POILogFactory;
|
||||||
import org.apache.poi.util.POILogger;
|
import org.apache.poi.util.POILogger;
|
||||||
|
|
||||||
@ -65,43 +66,49 @@ public final class ChunkFactory {
|
|||||||
*/
|
*/
|
||||||
private void processChunkParseCommands() throws IOException {
|
private void processChunkParseCommands() throws IOException {
|
||||||
String line;
|
String line;
|
||||||
InputStream cpd = ChunkFactory.class.getResourceAsStream(chunkTableName);
|
InputStream cpd = null;
|
||||||
if(cpd == null) {
|
BufferedReader inp = null;
|
||||||
throw new IllegalStateException("Unable to find HDGF chunk definition on the classpath - " + chunkTableName);
|
try {
|
||||||
|
cpd = ChunkFactory.class.getResourceAsStream(chunkTableName);
|
||||||
|
if(cpd == null) {
|
||||||
|
throw new IllegalStateException("Unable to find HDGF chunk definition on the classpath - " + chunkTableName);
|
||||||
|
}
|
||||||
|
|
||||||
|
inp = new BufferedReader(new InputStreamReader(cpd, LocaleUtil.CHARSET_1252));
|
||||||
|
|
||||||
|
while( (line = inp.readLine()) != null ) {
|
||||||
|
if(line.startsWith("#")) continue;
|
||||||
|
if(line.startsWith(" ")) continue;
|
||||||
|
if(line.startsWith("\t")) continue;
|
||||||
|
if(line.length() == 0) continue;
|
||||||
|
|
||||||
|
// Start xxx
|
||||||
|
if(!line.startsWith("start")) {
|
||||||
|
throw new IllegalStateException("Expecting start xxx, found " + line);
|
||||||
|
}
|
||||||
|
int chunkType = Integer.parseInt(line.substring(6));
|
||||||
|
ArrayList<CommandDefinition> defsL = new ArrayList<CommandDefinition>();
|
||||||
|
|
||||||
|
// Data entries
|
||||||
|
while( ! (line = inp.readLine()).startsWith("end") ) {
|
||||||
|
StringTokenizer st = new StringTokenizer(line, " ");
|
||||||
|
int defType = Integer.parseInt(st.nextToken());
|
||||||
|
int offset = Integer.parseInt(st.nextToken());
|
||||||
|
String name = st.nextToken("\uffff").substring(1);
|
||||||
|
|
||||||
|
CommandDefinition def = new CommandDefinition(defType,offset,name);
|
||||||
|
defsL.add(def);
|
||||||
|
}
|
||||||
|
|
||||||
|
CommandDefinition[] defs = defsL.toArray(new CommandDefinition[defsL.size()]);
|
||||||
|
|
||||||
|
// Add to the hashtable
|
||||||
|
chunkCommandDefinitions.put(Integer.valueOf(chunkType), defs);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
if (inp != null) inp.close();
|
||||||
|
if (cpd != null) cpd.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
BufferedReader inp = new BufferedReader(new InputStreamReader(cpd));
|
|
||||||
while( (line = inp.readLine()) != null ) {
|
|
||||||
if(line.startsWith("#")) continue;
|
|
||||||
if(line.startsWith(" ")) continue;
|
|
||||||
if(line.startsWith("\t")) continue;
|
|
||||||
if(line.length() == 0) continue;
|
|
||||||
|
|
||||||
// Start xxx
|
|
||||||
if(!line.startsWith("start")) {
|
|
||||||
throw new IllegalStateException("Expecting start xxx, found " + line);
|
|
||||||
}
|
|
||||||
int chunkType = Integer.parseInt(line.substring(6));
|
|
||||||
ArrayList<CommandDefinition> defsL = new ArrayList<CommandDefinition>();
|
|
||||||
|
|
||||||
// Data entries
|
|
||||||
while( ! (line = inp.readLine()).startsWith("end") ) {
|
|
||||||
StringTokenizer st = new StringTokenizer(line, " ");
|
|
||||||
int defType = Integer.parseInt(st.nextToken());
|
|
||||||
int offset = Integer.parseInt(st.nextToken());
|
|
||||||
String name = st.nextToken("\uffff").substring(1);
|
|
||||||
|
|
||||||
CommandDefinition def = new CommandDefinition(defType,offset,name);
|
|
||||||
defsL.add(def);
|
|
||||||
}
|
|
||||||
|
|
||||||
CommandDefinition[] defs = defsL.toArray(new CommandDefinition[defsL.size()]);
|
|
||||||
|
|
||||||
// Add to the hashtable
|
|
||||||
chunkCommandDefinitions.put(Integer.valueOf(chunkType), defs);
|
|
||||||
}
|
|
||||||
inp.close();
|
|
||||||
cpd.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getVersion() { return version; }
|
public int getVersion() { return version; }
|
||||||
|
@ -25,6 +25,7 @@ import org.apache.poi.hpbf.model.qcbits.QCTextBit;
|
|||||||
import org.apache.poi.hpbf.model.qcbits.UnknownQCBit;
|
import org.apache.poi.hpbf.model.qcbits.UnknownQCBit;
|
||||||
import org.apache.poi.poifs.filesystem.DirectoryNode;
|
import org.apache.poi.poifs.filesystem.DirectoryNode;
|
||||||
import org.apache.poi.util.LittleEndian;
|
import org.apache.poi.util.LittleEndian;
|
||||||
|
import org.apache.poi.util.LocaleUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Quill -> QuillSub -> CONTENTS
|
* Quill -> QuillSub -> CONTENTS
|
||||||
@ -40,7 +41,7 @@ public final class QuillContents extends HPBFPart {
|
|||||||
// all our bits
|
// all our bits
|
||||||
|
|
||||||
// Check first 8 bytes
|
// Check first 8 bytes
|
||||||
String f8 = new String(data, 0, 8);
|
String f8 = new String(data, 0, 8, LocaleUtil.CHARSET_1252);
|
||||||
if(! f8.equals("CHNKINK ")) {
|
if(! f8.equals("CHNKINK ")) {
|
||||||
throw new IllegalArgumentException("Expecting 'CHNKINK ' but was '"+f8+"'");
|
throw new IllegalArgumentException("Expecting 'CHNKINK ' but was '"+f8+"'");
|
||||||
}
|
}
|
||||||
@ -52,11 +53,11 @@ public final class QuillContents extends HPBFPart {
|
|||||||
int offset = 0x20 + i*24;
|
int offset = 0x20 + i*24;
|
||||||
if(data[offset] == 0x18 && data[offset+1] == 0x00) {
|
if(data[offset] == 0x18 && data[offset+1] == 0x00) {
|
||||||
// Has some data
|
// Has some data
|
||||||
String thingType = new String(data, offset+2, 4);
|
String thingType = new String(data, offset+2, 4, LocaleUtil.CHARSET_1252);
|
||||||
int optA = LittleEndian.getUShort(data, offset+6);
|
int optA = LittleEndian.getUShort(data, offset+6);
|
||||||
int optB = LittleEndian.getUShort(data, offset+8);
|
int optB = LittleEndian.getUShort(data, offset+8);
|
||||||
int optC = LittleEndian.getUShort(data, offset+10);
|
int optC = LittleEndian.getUShort(data, offset+10);
|
||||||
String bitType = new String(data, offset+12, 4);
|
String bitType = new String(data, offset+12, 4, LocaleUtil.CHARSET_1252);
|
||||||
int from = (int)LittleEndian.getUInt(data, offset+16);
|
int from = (int)LittleEndian.getUInt(data, offset+16);
|
||||||
int len = (int)LittleEndian.getUInt(data, offset+20);
|
int len = (int)LittleEndian.getUInt(data, offset+20);
|
||||||
|
|
||||||
|
@ -19,10 +19,12 @@ package org.apache.poi.hslf.dev;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.FileWriter;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.OutputStreamWriter;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
import java.io.Writer;
|
import java.io.Writer;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
|
|
||||||
import org.apache.poi.hslf.record.RecordTypes;
|
import org.apache.poi.hslf.record.RecordTypes;
|
||||||
import org.apache.poi.poifs.filesystem.DocumentEntry;
|
import org.apache.poi.poifs.filesystem.DocumentEntry;
|
||||||
@ -49,21 +51,26 @@ public final class PPTXMLDump {
|
|||||||
protected boolean hexHeader = true;
|
protected boolean hexHeader = true;
|
||||||
|
|
||||||
public PPTXMLDump(File ppt) throws IOException {
|
public PPTXMLDump(File ppt) throws IOException {
|
||||||
NPOIFSFileSystem fs = new NPOIFSFileSystem(ppt);
|
NPOIFSFileSystem fs = new NPOIFSFileSystem(ppt, true);
|
||||||
|
DocumentInputStream is = null;
|
||||||
//read the document entry from OLE file system
|
|
||||||
DocumentEntry entry = (DocumentEntry)fs.getRoot().getEntry(PPDOC_ENTRY);
|
|
||||||
docstream = new byte[entry.getSize()];
|
|
||||||
DocumentInputStream is = fs.createDocumentInputStream(PPDOC_ENTRY);
|
|
||||||
is.read(docstream);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
//read the document entry from OLE file system
|
||||||
|
DocumentEntry entry = (DocumentEntry)fs.getRoot().getEntry(PPDOC_ENTRY);
|
||||||
|
docstream = new byte[entry.getSize()];
|
||||||
|
is = fs.createDocumentInputStream(PPDOC_ENTRY);
|
||||||
|
is.read(docstream);
|
||||||
|
is.close();
|
||||||
|
|
||||||
entry = (DocumentEntry)fs.getRoot().getEntry(PICTURES_ENTRY);
|
entry = (DocumentEntry)fs.getRoot().getEntry(PICTURES_ENTRY);
|
||||||
pictstream = new byte[entry.getSize()];
|
pictstream = new byte[entry.getSize()];
|
||||||
is = fs.createDocumentInputStream(PICTURES_ENTRY);
|
is = fs.createDocumentInputStream(PICTURES_ENTRY);
|
||||||
is.read(pictstream);
|
is.read(pictstream);
|
||||||
} catch(FileNotFoundException e){
|
} catch(FileNotFoundException e){
|
||||||
//silently catch errors if the presentation does not contain pictures
|
//silently catch errors if the presentation does not contain pictures
|
||||||
|
} finally {
|
||||||
|
if (is != null) is.close();
|
||||||
|
fs.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,8 +79,8 @@ public final class PPTXMLDump {
|
|||||||
* @param out <code>Writer</code> to write out
|
* @param out <code>Writer</code> to write out
|
||||||
* @throws java.io.IOException
|
* @throws java.io.IOException
|
||||||
*/
|
*/
|
||||||
public void dump(Writer out) throws IOException {
|
public void dump(Writer outWriter) throws IOException {
|
||||||
this.out = out;
|
this.out = outWriter;
|
||||||
|
|
||||||
int padding = 0;
|
int padding = 0;
|
||||||
write(out, "<Presentation>" + CR, padding);
|
write(out, "<Presentation>" + CR, padding);
|
||||||
@ -197,7 +204,8 @@ public final class PPTXMLDump {
|
|||||||
System.out.println("Dumping " + args[i]);
|
System.out.println("Dumping " + args[i]);
|
||||||
|
|
||||||
if (outFile){
|
if (outFile){
|
||||||
FileWriter out = new FileWriter(ppt.getName() + ".xml");
|
FileOutputStream fos = new FileOutputStream(ppt.getName() + ".xml");
|
||||||
|
OutputStreamWriter out = new OutputStreamWriter(fos, Charset.forName("UTF8"));
|
||||||
dump.dump(out);
|
dump.dump(out);
|
||||||
out.close();
|
out.close();
|
||||||
} else {
|
} else {
|
||||||
|
@ -1244,7 +1244,7 @@ public final class HSLFTextParagraph implements TextParagraph<HSLFShape,HSLFText
|
|||||||
wrapper.appendChildRecord(tha);
|
wrapper.appendChildRecord(tha);
|
||||||
|
|
||||||
TextBytesAtom tba = new TextBytesAtom();
|
TextBytesAtom tba = new TextBytesAtom();
|
||||||
tba.setText("".getBytes());
|
tba.setText("".getBytes(LocaleUtil.CHARSET_1252));
|
||||||
wrapper.appendChildRecord(tba);
|
wrapper.appendChildRecord(tba);
|
||||||
|
|
||||||
StyleTextPropAtom sta = new StyleTextPropAtom(1);
|
StyleTextPropAtom sta = new StyleTextPropAtom(1);
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
package org.apache.poi.hssf.converter;
|
package org.apache.poi.hssf.converter;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileWriter;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -77,38 +76,27 @@ public class ExcelToFoConverter extends AbstractExcelConverter
|
|||||||
* Where infile is an input .xls file ( Word 97-2007) which will be rendered
|
* Where infile is an input .xls file ( Word 97-2007) which will be rendered
|
||||||
* as XSL FO into outfile
|
* as XSL FO into outfile
|
||||||
*/
|
*/
|
||||||
public static void main( String[] args )
|
public static void main( String[] args ) throws Exception {
|
||||||
{
|
if ( args.length < 2 ) {
|
||||||
if ( args.length < 2 )
|
System.err.println( "Usage: ExcelToFoConverter <inputFile.xls> <saveTo.xml>" );
|
||||||
{
|
|
||||||
System.err
|
|
||||||
.println( "Usage: ExcelToFoConverter <inputFile.xls> <saveTo.xml>" );
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println( "Converting " + args[0] );
|
System.out.println( "Converting " + args[0] );
|
||||||
System.out.println( "Saving output to " + args[1] );
|
System.out.println( "Saving output to " + args[1] );
|
||||||
try
|
|
||||||
{
|
|
||||||
Document doc = ExcelToHtmlConverter.process( new File( args[0] ) );
|
|
||||||
|
|
||||||
FileWriter out = new FileWriter( args[1] );
|
Document doc = ExcelToHtmlConverter.process( new File( args[0] ) );
|
||||||
DOMSource domSource = new DOMSource( doc );
|
|
||||||
StreamResult streamResult = new StreamResult( out );
|
|
||||||
|
|
||||||
TransformerFactory tf = TransformerFactory.newInstance();
|
DOMSource domSource = new DOMSource( doc );
|
||||||
Transformer serializer = tf.newTransformer();
|
StreamResult streamResult = new StreamResult( new File(args[1]) );
|
||||||
// TODO set encoding from a command argument
|
|
||||||
serializer.setOutputProperty( OutputKeys.ENCODING, "UTF-8" );
|
TransformerFactory tf = TransformerFactory.newInstance();
|
||||||
serializer.setOutputProperty( OutputKeys.INDENT, "no" );
|
Transformer serializer = tf.newTransformer();
|
||||||
serializer.setOutputProperty( OutputKeys.METHOD, "xml" );
|
// TODO set encoding from a command argument
|
||||||
serializer.transform( domSource, streamResult );
|
serializer.setOutputProperty( OutputKeys.ENCODING, "UTF-8" );
|
||||||
out.close();
|
serializer.setOutputProperty( OutputKeys.INDENT, "no" );
|
||||||
}
|
serializer.setOutputProperty( OutputKeys.METHOD, "xml" );
|
||||||
catch ( Exception e )
|
serializer.transform( domSource, streamResult );
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -125,7 +113,9 @@ public class ExcelToFoConverter extends AbstractExcelConverter
|
|||||||
XMLHelper.getDocumentBuilderFactory().newDocumentBuilder()
|
XMLHelper.getDocumentBuilderFactory().newDocumentBuilder()
|
||||||
.newDocument() );
|
.newDocument() );
|
||||||
excelToHtmlConverter.processWorkbook( workbook );
|
excelToHtmlConverter.processWorkbook( workbook );
|
||||||
return excelToHtmlConverter.getDocument();
|
Document doc = excelToHtmlConverter.getDocument();
|
||||||
|
workbook.close();
|
||||||
|
return doc;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final FoDocumentFacade foDocumentFacade;
|
private final FoDocumentFacade foDocumentFacade;
|
||||||
|
@ -495,8 +495,7 @@ public abstract class AbstractWordConverter
|
|||||||
}
|
}
|
||||||
|
|
||||||
String text = characterRun.text();
|
String text = characterRun.text();
|
||||||
if ( text.getBytes().length == 0 )
|
if ( text.isEmpty() ) continue;
|
||||||
continue;
|
|
||||||
|
|
||||||
if ( characterRun.isSpecialCharacter() )
|
if ( characterRun.isSpecialCharacter() )
|
||||||
{
|
{
|
||||||
@ -530,7 +529,7 @@ public abstract class AbstractWordConverter
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( text.getBytes()[0] == FIELD_BEGIN_MARK )
|
if ( text.charAt(0) == FIELD_BEGIN_MARK )
|
||||||
{
|
{
|
||||||
if ( wordDocument instanceof HWPFDocument )
|
if ( wordDocument instanceof HWPFDocument )
|
||||||
{
|
{
|
||||||
@ -566,12 +565,12 @@ public abstract class AbstractWordConverter
|
|||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ( text.getBytes()[0] == FIELD_SEPARATOR_MARK )
|
if ( text.charAt(0) == FIELD_SEPARATOR_MARK )
|
||||||
{
|
{
|
||||||
// shall not appear without FIELD_BEGIN_MARK
|
// shall not appear without FIELD_BEGIN_MARK
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ( text.getBytes()[0] == FIELD_END_MARK )
|
if ( text.charAt(0) == FIELD_END_MARK )
|
||||||
{
|
{
|
||||||
// shall not appear without FIELD_BEGIN_MARK
|
// shall not appear without FIELD_BEGIN_MARK
|
||||||
continue;
|
continue;
|
||||||
@ -1168,10 +1167,9 @@ public abstract class AbstractWordConverter
|
|||||||
CharacterRun characterRun = range.getCharacterRun( c );
|
CharacterRun characterRun = range.getCharacterRun( c );
|
||||||
|
|
||||||
String text = characterRun.text();
|
String text = characterRun.text();
|
||||||
if ( text.getBytes().length == 0 )
|
if ( text.isEmpty() ) continue;
|
||||||
continue;
|
|
||||||
|
|
||||||
final byte firstByte = text.getBytes()[0];
|
final char firstByte = text.charAt(0);
|
||||||
if ( firstByte == FIELD_BEGIN_MARK )
|
if ( firstByte == FIELD_BEGIN_MARK )
|
||||||
{
|
{
|
||||||
int[] nested = tryDeadField_lookupFieldSeparatorEnd(
|
int[] nested = tryDeadField_lookupFieldSeparatorEnd(
|
||||||
@ -1195,7 +1193,7 @@ public abstract class AbstractWordConverter
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( text.getBytes()[0] == FIELD_END_MARK )
|
if ( firstByte == FIELD_END_MARK )
|
||||||
{
|
{
|
||||||
if ( endMark != -1 )
|
if ( endMark != -1 )
|
||||||
{
|
{
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
package org.apache.poi.hwpf.converter;
|
package org.apache.poi.hwpf.converter;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileWriter;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -73,36 +72,25 @@ public class WordToFoConverter extends AbstractWordConverter
|
|||||||
* Where infile is an input .doc file ( Word 97-2007) which will be rendered
|
* Where infile is an input .doc file ( Word 97-2007) which will be rendered
|
||||||
* as XSL-FO into outfile
|
* as XSL-FO into outfile
|
||||||
*/
|
*/
|
||||||
public static void main( String[] args )
|
public static void main( String[] args ) throws Exception {
|
||||||
{
|
|
||||||
if ( args.length < 2 )
|
if ( args.length < 2 )
|
||||||
{
|
{
|
||||||
System.err
|
System.err.println( "Usage: WordToFoConverter <inputFile.doc> <saveTo.fo>" );
|
||||||
.println( "Usage: WordToFoConverter <inputFile.doc> <saveTo.fo>" );
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println( "Converting " + args[0] );
|
System.out.println( "Converting " + args[0] );
|
||||||
System.out.println( "Saving output to " + args[1] );
|
System.out.println( "Saving output to " + args[1] );
|
||||||
try
|
Document doc = WordToFoConverter.process( new File( args[0] ) );
|
||||||
{
|
|
||||||
Document doc = WordToFoConverter.process( new File( args[0] ) );
|
|
||||||
|
|
||||||
FileWriter out = new FileWriter( args[1] );
|
DOMSource domSource = new DOMSource( doc );
|
||||||
DOMSource domSource = new DOMSource( doc );
|
StreamResult streamResult = new StreamResult( new File( args[1] ) );
|
||||||
StreamResult streamResult = new StreamResult( out );
|
TransformerFactory tf = TransformerFactory.newInstance();
|
||||||
TransformerFactory tf = TransformerFactory.newInstance();
|
Transformer serializer = tf.newTransformer();
|
||||||
Transformer serializer = tf.newTransformer();
|
// TODO set encoding from a command argument
|
||||||
// TODO set encoding from a command argument
|
serializer.setOutputProperty( OutputKeys.ENCODING, "UTF-8" );
|
||||||
serializer.setOutputProperty( OutputKeys.ENCODING, "UTF-8" );
|
serializer.setOutputProperty( OutputKeys.INDENT, "yes" );
|
||||||
serializer.setOutputProperty( OutputKeys.INDENT, "yes" );
|
serializer.transform( domSource, streamResult );
|
||||||
serializer.transform( domSource, streamResult );
|
|
||||||
out.close();
|
|
||||||
}
|
|
||||||
catch ( Exception e )
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static Document process( File docFile ) throws Exception
|
static Document process( File docFile ) throws Exception
|
||||||
|
@ -19,7 +19,6 @@ package org.apache.poi.hwpf.converter;
|
|||||||
import static org.apache.poi.hwpf.converter.AbstractWordUtils.TWIPS_PER_INCH;
|
import static org.apache.poi.hwpf.converter.AbstractWordUtils.TWIPS_PER_INCH;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileWriter;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Stack;
|
import java.util.Stack;
|
||||||
|
|
||||||
@ -119,7 +118,7 @@ public class WordToHtmlConverter extends AbstractWordConverter
|
|||||||
* Where infile is an input .doc file ( Word 95-2007) which will be rendered
|
* Where infile is an input .doc file ( Word 95-2007) which will be rendered
|
||||||
* as HTML into outfile
|
* as HTML into outfile
|
||||||
*/
|
*/
|
||||||
public static void main( String[] args )
|
public static void main( String[] args ) throws Exception
|
||||||
{
|
{
|
||||||
if ( args.length < 2 )
|
if ( args.length < 2 )
|
||||||
{
|
{
|
||||||
@ -130,27 +129,19 @@ public class WordToHtmlConverter extends AbstractWordConverter
|
|||||||
|
|
||||||
System.out.println( "Converting " + args[0] );
|
System.out.println( "Converting " + args[0] );
|
||||||
System.out.println( "Saving output to " + args[1] );
|
System.out.println( "Saving output to " + args[1] );
|
||||||
try
|
|
||||||
{
|
|
||||||
Document doc = WordToHtmlConverter.process( new File( args[0] ) );
|
|
||||||
|
|
||||||
FileWriter out = new FileWriter( args[1] );
|
Document doc = WordToHtmlConverter.process( new File( args[0] ) );
|
||||||
DOMSource domSource = new DOMSource( doc );
|
|
||||||
StreamResult streamResult = new StreamResult( out );
|
|
||||||
|
|
||||||
TransformerFactory tf = TransformerFactory.newInstance();
|
DOMSource domSource = new DOMSource( doc );
|
||||||
Transformer serializer = tf.newTransformer();
|
StreamResult streamResult = new StreamResult( new File(args[1]) );
|
||||||
// TODO set encoding from a command argument
|
|
||||||
serializer.setOutputProperty( OutputKeys.ENCODING, "UTF-8" );
|
TransformerFactory tf = TransformerFactory.newInstance();
|
||||||
serializer.setOutputProperty( OutputKeys.INDENT, "yes" );
|
Transformer serializer = tf.newTransformer();
|
||||||
serializer.setOutputProperty( OutputKeys.METHOD, "html" );
|
// TODO set encoding from a command argument
|
||||||
serializer.transform( domSource, streamResult );
|
serializer.setOutputProperty( OutputKeys.ENCODING, "UTF-8" );
|
||||||
out.close();
|
serializer.setOutputProperty( OutputKeys.INDENT, "yes" );
|
||||||
}
|
serializer.setOutputProperty( OutputKeys.METHOD, "html" );
|
||||||
catch ( Exception e )
|
serializer.transform( domSource, streamResult );
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static Document process( File docFile ) throws Exception
|
static Document process( File docFile ) throws Exception
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
package org.apache.poi.hwpf.converter;
|
package org.apache.poi.hwpf.converter;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileWriter;
|
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -91,38 +90,28 @@ public class WordToTextConverter extends AbstractWordConverter
|
|||||||
* Where infile is an input .doc file ( Word 95-2007) which will be rendered
|
* Where infile is an input .doc file ( Word 95-2007) which will be rendered
|
||||||
* as plain text into outfile
|
* as plain text into outfile
|
||||||
*/
|
*/
|
||||||
public static void main( String[] args )
|
public static void main( String[] args ) throws Exception {
|
||||||
{
|
|
||||||
if ( args.length < 2 )
|
if ( args.length < 2 )
|
||||||
{
|
{
|
||||||
System.err
|
System.err.println( "Usage: WordToTextConverter <inputFile.doc> <saveTo.txt>" );
|
||||||
.println( "Usage: WordToTextConverter <inputFile.doc> <saveTo.txt>" );
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println( "Converting " + args[0] );
|
System.out.println( "Converting " + args[0] );
|
||||||
System.out.println( "Saving output to " + args[1] );
|
System.out.println( "Saving output to " + args[1] );
|
||||||
try
|
|
||||||
{
|
|
||||||
Document doc = WordToTextConverter.process( new File( args[0] ) );
|
|
||||||
|
|
||||||
FileWriter out = new FileWriter( args[1] );
|
Document doc = WordToTextConverter.process( new File( args[0] ) );
|
||||||
DOMSource domSource = new DOMSource( doc );
|
|
||||||
StreamResult streamResult = new StreamResult( out );
|
|
||||||
|
|
||||||
TransformerFactory tf = TransformerFactory.newInstance();
|
DOMSource domSource = new DOMSource( doc );
|
||||||
Transformer serializer = tf.newTransformer();
|
StreamResult streamResult = new StreamResult( new File( args[1] ) );
|
||||||
// TODO set encoding from a command argument
|
|
||||||
serializer.setOutputProperty( OutputKeys.ENCODING, "UTF-8" );
|
TransformerFactory tf = TransformerFactory.newInstance();
|
||||||
serializer.setOutputProperty( OutputKeys.INDENT, "no" );
|
Transformer serializer = tf.newTransformer();
|
||||||
serializer.setOutputProperty( OutputKeys.METHOD, "text" );
|
// TODO set encoding from a command argument
|
||||||
serializer.transform( domSource, streamResult );
|
serializer.setOutputProperty( OutputKeys.ENCODING, "UTF-8" );
|
||||||
out.close();
|
serializer.setOutputProperty( OutputKeys.INDENT, "no" );
|
||||||
}
|
serializer.setOutputProperty( OutputKeys.METHOD, "text" );
|
||||||
catch ( Exception e )
|
serializer.transform( domSource, streamResult );
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static Document process( File docFile ) throws Exception
|
static Document process( File docFile ) throws Exception
|
||||||
|
@ -17,9 +17,14 @@
|
|||||||
|
|
||||||
package org.apache.poi.hdgf.chunks;
|
package org.apache.poi.hdgf.chunks;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
import static org.junit.Assert.assertNull;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
public final class TestChunks extends TestCase {
|
import org.junit.Test;
|
||||||
|
|
||||||
|
public final class TestChunks {
|
||||||
public static final byte[] data_a = new byte[] { 70, 0, 0, 0,
|
public static final byte[] data_a = new byte[] { 70, 0, 0, 0,
|
||||||
-1, -1, -1, -1, 2, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0,
|
-1, -1, -1, -1, 2, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0,
|
||||||
0, 0, 2, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
0, 0, 2, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||||
@ -83,8 +88,8 @@ public static final byte[] data_b = new byte[] { 70, 0, 0, 0,
|
|||||||
0, 0, 0
|
0, 0, 0
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testChunkHeaderA() throws Exception {
|
public void testChunkHeaderA() throws Exception {
|
||||||
ChunkFactory cf = new ChunkFactory(11);
|
|
||||||
ChunkHeader h =
|
ChunkHeader h =
|
||||||
ChunkHeader.createChunkHeader(11, data_a, 0);
|
ChunkHeader.createChunkHeader(11, data_a, 0);
|
||||||
|
|
||||||
@ -101,8 +106,9 @@ public static final byte[] data_b = new byte[] { 70, 0, 0, 0,
|
|||||||
assertTrue(header.hasTrailer());
|
assertTrue(header.hasTrailer());
|
||||||
assertTrue(header.hasSeparator());
|
assertTrue(header.hasSeparator());
|
||||||
}
|
}
|
||||||
public void testChunkHeaderB() throws Exception {
|
|
||||||
ChunkFactory cf = new ChunkFactory(11);
|
@Test
|
||||||
|
public void testChunkHeaderB() throws Exception {
|
||||||
ChunkHeader h =
|
ChunkHeader h =
|
||||||
ChunkHeader.createChunkHeader(11, data_b, 0);
|
ChunkHeader.createChunkHeader(11, data_b, 0);
|
||||||
|
|
||||||
@ -120,7 +126,8 @@ public static final byte[] data_b = new byte[] { 70, 0, 0, 0,
|
|||||||
assertTrue(header.hasSeparator());
|
assertTrue(header.hasSeparator());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testOneChunk() throws Exception {
|
@Test
|
||||||
|
public void testOneChunk() throws Exception {
|
||||||
ChunkFactory cf = new ChunkFactory(11);
|
ChunkFactory cf = new ChunkFactory(11);
|
||||||
cf.createChunk(data_a, 0);
|
cf.createChunk(data_a, 0);
|
||||||
cf.createChunk(data_b, 0);
|
cf.createChunk(data_b, 0);
|
||||||
@ -152,7 +159,8 @@ public static final byte[] data_b = new byte[] { 70, 0, 0, 0,
|
|||||||
assertEquals("0", chunk.commandDefinitions[1].getName());
|
assertEquals("0", chunk.commandDefinitions[1].getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAnotherChunk() throws Exception {
|
@Test
|
||||||
|
public void testAnotherChunk() throws Exception {
|
||||||
ChunkFactory cf = new ChunkFactory(11);
|
ChunkFactory cf = new ChunkFactory(11);
|
||||||
|
|
||||||
// Go for the 2nd chunk in the stream
|
// Go for the 2nd chunk in the stream
|
||||||
@ -187,7 +195,8 @@ public static final byte[] data_b = new byte[] { 70, 0, 0, 0,
|
|||||||
assertEquals("0", chunk.commandDefinitions[1].getName());
|
assertEquals("0", chunk.commandDefinitions[1].getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testManyChunks() throws Exception {
|
@Test
|
||||||
|
public void testManyChunks() throws Exception {
|
||||||
ChunkFactory cf = new ChunkFactory(11);
|
ChunkFactory cf = new ChunkFactory(11);
|
||||||
Chunk chunk;
|
Chunk chunk;
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user