Add some simple coverage of HSLF-Dev-Tools

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1849765 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Dominik Stadler 2018-12-26 13:28:32 +00:00
parent 5b62dcd379
commit c218c3cbc4
26 changed files with 797 additions and 173 deletions

View File

@ -562,7 +562,7 @@ public final class IOUtils {
public static byte[] safelyAllocate(long length, int maxLength) { public static byte[] safelyAllocate(long length, int maxLength) {
if (length < 0L) { if (length < 0L) {
throw new RecordFormatException("Can't allocate an array of length < 0"); throw new RecordFormatException("Can't allocate an array of length < 0, but had " + length + " and " + maxLength);
} }
if (length > (long)Integer.MAX_VALUE) { if (length > (long)Integer.MAX_VALUE) {
throw new RecordFormatException("Can't allocate an array > "+Integer.MAX_VALUE); throw new RecordFormatException("Can't allocate an array > "+Integer.MAX_VALUE);

View File

@ -39,43 +39,44 @@ public final class PPDrawingTextListing {
System.exit(1); System.exit(1);
} }
HSLFSlideShowImpl ss = new HSLFSlideShowImpl(args[0]); try (HSLFSlideShowImpl ss = new HSLFSlideShowImpl(args[0])) {
// Find PPDrawings at any second level position // Find PPDrawings at any second level position
Record[] records = ss.getRecords(); Record[] records = ss.getRecords();
for(int i=0; i<records.length; i++) { for (int i = 0; i < records.length; i++) {
Record[] children = records[i].getChildRecords(); Record[] children = records[i].getChildRecords();
if(children != null && children.length != 0) { if (children != null && children.length != 0) {
for(int j=0; j<children.length; j++) { for (int j = 0; j < children.length; j++) {
if(children[j] instanceof PPDrawing) { if (children[j] instanceof PPDrawing) {
System.out.println("Found PPDrawing at " + j + " in top level record " + i + " (" + records[i].getRecordType() + ")" ); System.out.println("Found PPDrawing at " + j + " in top level record " + i + " (" + records[i].getRecordType() + ")");
// Look for EscherTextboxWrapper's // Look for EscherTextboxWrapper's
PPDrawing ppd = (PPDrawing)children[j]; PPDrawing ppd = (PPDrawing) children[j];
EscherTextboxWrapper[] wrappers = ppd.getTextboxWrappers(); EscherTextboxWrapper[] wrappers = ppd.getTextboxWrappers();
System.out.println(" Has " + wrappers.length + " textbox wrappers within"); System.out.println(" Has " + wrappers.length + " textbox wrappers within");
// Loop over the wrappers, showing what they contain // Loop over the wrappers, showing what they contain
for(int k=0; k<wrappers.length; k++) { for (int k = 0; k < wrappers.length; k++) {
EscherTextboxWrapper tbw = wrappers[k]; EscherTextboxWrapper tbw = wrappers[k];
System.out.println(" " + k + " has " + tbw.getChildRecords().length + " PPT atoms within"); System.out.println(" " + k + " has " + tbw.getChildRecords().length + " PPT atoms within");
// Loop over the records, printing the text // Loop over the records, printing the text
Record[] pptatoms = tbw.getChildRecords(); Record[] pptatoms = tbw.getChildRecords();
for(int l=0; l<pptatoms.length; l++) { for (Record pptatom : pptatoms) {
String text = null; String text = null;
if(pptatoms[l] instanceof TextBytesAtom) { if (pptatom instanceof TextBytesAtom) {
TextBytesAtom tba = (TextBytesAtom)pptatoms[l]; TextBytesAtom tba = (TextBytesAtom) pptatom;
text = tba.getText(); text = tba.getText();
} }
if(pptatoms[l] instanceof TextCharsAtom) { if (pptatom instanceof TextCharsAtom) {
TextCharsAtom tca = (TextCharsAtom)pptatoms[l]; TextCharsAtom tca = (TextCharsAtom) pptatom;
text = tca.getText(); text = tca.getText();
} }
if(text != null) { if (text != null) {
text = text.replace('\r','\n'); text = text.replace('\r', '\n');
System.out.println(" ''" + text + "''"); System.out.println(" ''" + text + "''");
}
} }
} }
} }
@ -83,7 +84,5 @@ public final class PPDrawingTextListing {
} }
} }
} }
ss.close();
} }
} }

View File

@ -54,12 +54,9 @@ public final class PPTXMLDump {
private boolean hexHeader = true; private boolean hexHeader = true;
public PPTXMLDump(File ppt) throws IOException { public PPTXMLDump(File ppt) throws IOException {
POIFSFileSystem fs = new POIFSFileSystem(ppt, true); try (POIFSFileSystem fs = new POIFSFileSystem(ppt, true)) {
try {
docstream = readEntry(fs, HSLFSlideShow.POWERPOINT_DOCUMENT); docstream = readEntry(fs, HSLFSlideShow.POWERPOINT_DOCUMENT);
pictstream = readEntry(fs, PICTURES_ENTRY); pictstream = readEntry(fs, PICTURES_ENTRY);
} finally {
fs.close();
} }
} }
@ -69,20 +66,17 @@ public final class PPTXMLDump {
if (!dn.hasEntry(entry)) { if (!dn.hasEntry(entry)) {
return null; return null;
} }
InputStream is = dn.createDocumentInputStream(entry); try (InputStream is = dn.createDocumentInputStream(entry)) {
try {
ByteArrayOutputStream bos = new ByteArrayOutputStream(); ByteArrayOutputStream bos = new ByteArrayOutputStream();
IOUtils.copy(is, bos); IOUtils.copy(is, bos);
return bos.toByteArray(); return bos.toByteArray();
} finally {
is.close();
} }
} }
/** /**
* Dump the structure of the supplied PPT file into XML * Dump the structure of the supplied PPT file into XML
* @param outWriter <code>Writer</code> to write out * @param outWriter <code>Writer</code> to write out
* @throws java.io.IOException * @throws java.io.IOException If writing to the writer fails
*/ */
public void dump(Writer outWriter) throws IOException { public void dump(Writer outWriter) throws IOException {
this.out = outWriter; this.out = outWriter;
@ -98,7 +92,9 @@ public final class PPTXMLDump {
//dump the structure of the powerpoint document //dump the structure of the powerpoint document
write(out, "<PowerPointDocument>" + CR, padding); write(out, "<PowerPointDocument>" + CR, padding);
padding++; padding++;
dump(docstream, 0, docstream.length, padding); if(docstream != null) {
dump(docstream, 0, docstream.length, padding);
}
padding--; padding--;
write(out, "</PowerPointDocument>" + CR, padding); write(out, "</PowerPointDocument>" + CR, padding);
padding--; padding--;
@ -111,7 +107,7 @@ public final class PPTXMLDump {
* @param offset offset from the beginning of the document * @param offset offset from the beginning of the document
* @param length of the document * @param length of the document
* @param padding used for formatting results * @param padding used for formatting results
* @throws java.io.IOException * @throws java.io.IOException If writing out information fails
*/ */
public void dump(byte[] data, int offset, int length, int padding) throws IOException { public void dump(byte[] data, int offset, int length, int padding) throws IOException {
int pos = offset; int pos = offset;
@ -158,16 +154,24 @@ public final class PPTXMLDump {
* Dumps the Pictures OLE stream into XML. * Dumps the Pictures OLE stream into XML.
* *
* @param data from the Pictures OLE data stream * @param data from the Pictures OLE data stream
* @param padding * @param padding How many leading blanks to add in the output
* @throws java.io.IOException * @throws java.io.IOException If writing out information fails
*/ */
public void dumpPictures(byte[] data, int padding) throws IOException { public void dumpPictures(byte[] data, int padding) throws IOException {
int pos = 0; int pos = 0;
while (pos < data.length) { while (pos < data.length) {
byte[] header = new byte[PICT_HEADER_SIZE]; byte[] header = new byte[PICT_HEADER_SIZE];
if(data.length - pos < header.length) {
// corrupt file, cannot read header
return;
}
System.arraycopy(data, pos, header, 0, header.length); System.arraycopy(data, pos, header, 0, header.length);
int size = LittleEndian.getInt(header, 4) - 17; int size = LittleEndian.getInt(header, 4) - 17;
if(size < 0) {
// corrupt file, negative image size
return;
}
byte[] pictdata = IOUtils.safelyAllocate(size, MAX_RECORD_LENGTH); byte[] pictdata = IOUtils.safelyAllocate(size, MAX_RECORD_LENGTH);
System.arraycopy(data, pos + PICT_HEADER_SIZE, pictdata, 0, pictdata.length); System.arraycopy(data, pos + PICT_HEADER_SIZE, pictdata, 0, pictdata.length);
pos += PICT_HEADER_SIZE + size; pos += PICT_HEADER_SIZE + size;
@ -184,7 +188,6 @@ public final class PPTXMLDump {
padding--; padding--;
write(out, "</picture>" + CR, padding); write(out, "</picture>" + CR, padding);
padding--; padding--;
} }
} }
@ -272,5 +275,4 @@ public final class PPTXMLDump {
(byte) '4', (byte) '5', (byte) '6', (byte) '7', (byte) '4', (byte) '5', (byte) '6', (byte) '7',
(byte) '8', (byte) '9', (byte) 'A', (byte) 'B', (byte) '8', (byte) '9', (byte) 'A', (byte) 'B',
(byte) 'C', (byte) 'D', (byte) 'E', (byte) 'F'}; (byte) 'C', (byte) 'D', (byte) 'E', (byte) 'F'};
} }

View File

@ -41,7 +41,7 @@ public final class SlideAndNotesAtomListing {
} }
HSLFSlideShowImpl ss = new HSLFSlideShowImpl(args[0]); HSLFSlideShowImpl ss = new HSLFSlideShowImpl(args[0]);
System.out.println(""); System.out.println();
// Find either Slides or Notes // Find either Slides or Notes
Record[] records = ss.getRecords(); Record[] records = ss.getRecords();
@ -55,14 +55,14 @@ public final class SlideAndNotesAtomListing {
System.out.println("Found Slide at " + i); System.out.println("Found Slide at " + i);
System.out.println(" Slide's master ID is " + sa.getMasterID()); System.out.println(" Slide's master ID is " + sa.getMasterID());
System.out.println(" Slide's notes ID is " + sa.getNotesID()); System.out.println(" Slide's notes ID is " + sa.getNotesID());
System.out.println(""); System.out.println();
} }
if(r instanceof Notes) { if(r instanceof Notes) {
Notes n = (Notes)r; Notes n = (Notes)r;
NotesAtom na = n.getNotesAtom(); NotesAtom na = n.getNotesAtom();
System.out.println("Found Notes at " + i); System.out.println("Found Notes at " + i);
System.out.println(" Notes ID is " + na.getSlideID()); System.out.println(" Notes ID is " + na.getSlideID());
System.out.println(""); System.out.println();
} }
} }

View File

@ -61,23 +61,23 @@ public final class SlideIdListing {
// Grab any records that interest us // Grab any records that interest us
Document document = null; Document document = null;
for(int i=0; i<latestRecords.length; i++) { for (Record latestRecord : latestRecords) {
if(latestRecords[i] instanceof Document) { if (latestRecord instanceof Document) {
document = (Document)latestRecords[i]; document = (Document) latestRecord;
} }
} }
System.out.println(""); System.out.println();
// Look for SlidePersistAtoms, and report what they have to // Look for SlidePersistAtoms, and report what they have to
// say about possible slide IDs // say about possible slide IDs
SlideListWithText[] slwts = document.getSlideListWithTexts(); SlideListWithText[] slwts = document.getSlideListWithTexts();
for(int i=0; i<slwts.length; i++) { for (SlideListWithText slwt : slwts) {
Record[] cr = slwts[i].getChildRecords(); Record[] cr = slwt.getChildRecords();
for(int j=0; j<cr.length; j++) { for (Record record : cr) {
if(cr[j] instanceof SlidePersistAtom) { if (record instanceof SlidePersistAtom) {
SlidePersistAtom spa = (SlidePersistAtom)cr[j]; SlidePersistAtom spa = (SlidePersistAtom) record;
System.out.println("SlidePersistAtom knows about slide:"); System.out.println("SlidePersistAtom knows about slide:");
System.out.println("\t" + spa.getRefID()); System.out.println("\t" + spa.getRefID());
System.out.println("\t" + spa.getSlideIdentifier()); System.out.println("\t" + spa.getSlideIdentifier());
@ -85,7 +85,7 @@ public final class SlideIdListing {
} }
} }
System.out.println(""); System.out.println();
// Look for latest core records that are slides or notes // Look for latest core records that are slides or notes
for(int i=0; i<latestRecords.length; i++) { for(int i=0; i<latestRecords.length; i++) {
@ -100,7 +100,7 @@ public final class SlideIdListing {
System.out.println("\tNotes ID is " + sa.getNotesID()); System.out.println("\tNotes ID is " + sa.getNotesID());
} }
} }
System.out.println(""); System.out.println();
for(int i=0; i<latestRecords.length; i++) { for(int i=0; i<latestRecords.length; i++) {
if(latestRecords[i] instanceof Notes) { if(latestRecords[i] instanceof Notes) {
Notes n = (Notes)latestRecords[i]; Notes n = (Notes)latestRecords[i];
@ -113,27 +113,24 @@ public final class SlideIdListing {
} }
} }
System.out.println(""); System.out.println();
// Find any persist ones first // Find any persist ones first
int pos = 0; int pos = 0;
for(int i=0; i<records.length; i++) { for (Record r : records) {
Record r = records[i]; if (r.getRecordType() == 6001L) {
if(r.getRecordType() == 6001l) {
// PersistPtrFullBlock // PersistPtrFullBlock
System.out.println("Found PersistPtrFullBlock at " + pos + " (" + Integer.toHexString(pos) + ")"); System.out.println("Found PersistPtrFullBlock at " + pos + " (" + Integer.toHexString(pos) + ")");
} }
if(r.getRecordType() == 6002l) { if (r.getRecordType() == 6002L) {
// PersistPtrIncrementalBlock // PersistPtrIncrementalBlock
System.out.println("Found PersistPtrIncrementalBlock at " + pos + " (" + Integer.toHexString(pos) + ")"); System.out.println("Found PersistPtrIncrementalBlock at " + pos + " (" + Integer.toHexString(pos) + ")");
PersistPtrHolder pph = (PersistPtrHolder)r; PersistPtrHolder pph = (PersistPtrHolder) r;
// Check the sheet offsets // Check the sheet offsets
int[] sheetIDs = pph.getKnownSlideIDs(); int[] sheetIDs = pph.getKnownSlideIDs();
Map<Integer,Integer> sheetOffsets = pph.getSlideLocationsLookup(); Map<Integer, Integer> sheetOffsets = pph.getSlideLocationsLookup();
for(int j=0; j<sheetIDs.length; j++) { for (Integer id : sheetIDs) {
Integer id = sheetIDs[j];
Integer offset = sheetOffsets.get(id); Integer offset = sheetOffsets.get(id);
System.out.println(" Knows about sheet " + id); System.out.println(" Knows about sheet " + id);
@ -143,7 +140,7 @@ public final class SlideIdListing {
System.out.println(" The record at that pos is of type " + atPos.getRecordType()); System.out.println(" The record at that pos is of type " + atPos.getRecordType());
System.out.println(" The record at that pos has class " + atPos.getClass().getName()); System.out.println(" The record at that pos has class " + atPos.getClass().getName());
if(! (atPos instanceof PositionDependentRecord)) { if (!(atPos instanceof PositionDependentRecord)) {
System.out.println(" ** The record class isn't position aware! **"); System.out.println(" ** The record class isn't position aware! **");
} }
} }
@ -157,7 +154,7 @@ public final class SlideIdListing {
ss.close(); ss.close();
System.out.println(""); System.out.println();
} }

View File

@ -56,7 +56,6 @@ public final class SlideShowRecordDumper {
* dump of what it contains * dump of what it contains
*/ */
public static void main(String[] args) throws IOException { public static void main(String[] args) throws IOException {
String filename = "";
boolean verbose = false; boolean verbose = false;
boolean escher = false; boolean escher = false;
@ -81,12 +80,14 @@ public final class SlideShowRecordDumper {
return; return;
} }
filename = args[ndx]; String filename = args[ndx];
SlideShowRecordDumper foo = new SlideShowRecordDumper(System.out, SlideShowRecordDumper foo = new SlideShowRecordDumper(System.out,
filename, verbose, escher); filename, verbose, escher);
foo.printDump(); foo.printDump();
foo.doc.close();
} }
public static void printUsage() { public static void printUsage() {
@ -118,11 +119,11 @@ public final class SlideShowRecordDumper {
} }
public String makeHex(int number, int padding) { public String makeHex(int number, int padding) {
String hex = Integer.toHexString(number).toUpperCase(Locale.ROOT); StringBuilder hex = new StringBuilder(Integer.toHexString(number).toUpperCase(Locale.ROOT));
while (hex.length() < padding) { while (hex.length() < padding) {
hex = "0" + hex; hex.insert(0, "0");
} }
return hex; return hex.toString();
} }
public String reverseHex(String s) { public String reverseHex(String s) {
@ -186,7 +187,7 @@ public final class SlideShowRecordDumper {
for (Record child : etw.getChildRecords()) { for (Record child : etw.getChildRecords()) {
if (child instanceof StyleTextPropAtom) { if (child instanceof StyleTextPropAtom) {
// need preceding Text[Chars|Bytes]Atom to initialize the data structure // need preceding Text[Chars|Bytes]Atom to initialize the data structure
String text = null; String text;
if (prevChild instanceof TextCharsAtom) { if (prevChild instanceof TextCharsAtom) {
text = ((TextCharsAtom)prevChild).getText(); text = ((TextCharsAtom)prevChild).getText();
} else if (prevChild instanceof TextBytesAtom) { } else if (prevChild instanceof TextBytesAtom) {
@ -227,8 +228,7 @@ public final class SlideShowRecordDumper {
public void walkTree(int depth, int pos, Record[] records, int indent) throws IOException { public void walkTree(int depth, int pos, Record[] records, int indent) throws IOException {
String ind = tabs.substring(0, indent); String ind = tabs.substring(0, indent);
for (int i = 0; i < records.length; i++) { for (Record r : records) {
Record r = records[i];
if (r == null) { if (r == null) {
ps.println(ind + "At position " + pos + " (" + makeHex(pos, 6) + "):"); ps.println(ind + "At position " + pos + " (" + makeHex(pos, 6) + "):");
ps.println(ind + "Warning! Null record found."); ps.println(ind + "Warning! Null record found.");
@ -242,49 +242,49 @@ public final class SlideShowRecordDumper {
String hexType = makeHex((int) r.getRecordType(), 4); String hexType = makeHex((int) r.getRecordType(), 4);
String rHexType = reverseHex(hexType); String rHexType = reverseHex(hexType);
// Grab the hslf.record type // Grab the hslf.record type
Class<? extends Record> c = r.getClass(); Class<? extends Record> c = r.getClass();
String cname = c.toString(); String cname = c.toString();
if(cname.startsWith("class ")) { if (cname.startsWith("class ")) {
cname = cname.substring(6); cname = cname.substring(6);
} }
if(cname.startsWith("org.apache.poi.hslf.record.")) { if (cname.startsWith("org.apache.poi.hslf.record.")) {
cname = cname.substring(27); cname = cname.substring(27);
} }
// Display the record // Display the record
ps.println(ind + "At position " + pos + " (" + makeHex(pos,6) + "):"); ps.println(ind + "At position " + pos + " (" + makeHex(pos, 6) + "):");
ps.println(ind + " Record is of type " + cname); ps.println(ind + " Record is of type " + cname);
ps.println(ind + " Type is " + r.getRecordType() + " (" + hexType + " -> " + rHexType + " )"); ps.println(ind + " Type is " + r.getRecordType() + " (" + hexType + " -> " + rHexType + " )");
ps.println(ind + " Len is " + (len-8) + " (" + makeHex((len-8),8) + "), on disk len is " + len ); ps.println(ind + " Len is " + (len - 8) + " (" + makeHex((len - 8), 8) + "), on disk len is " + len);
// print additional information for drawings and atoms // print additional information for drawings and atoms
if (optEscher && cname.equals("PPDrawing")) { if (optEscher && cname.equals("PPDrawing")) {
DefaultEscherRecordFactory factory = new HSLFEscherRecordFactory(); DefaultEscherRecordFactory factory = new HSLFEscherRecordFactory();
ByteArrayOutputStream baos = new ByteArrayOutputStream(); ByteArrayOutputStream baos = new ByteArrayOutputStream();
r.writeOut(baos); r.writeOut(baos);
byte[] b = baos.toByteArray(); byte[] b = baos.toByteArray();
EscherRecord er = factory.createRecord(b, 0); EscherRecord er = factory.createRecord(b, 0);
er.fillFields(b, 0, factory); er.fillFields(b, 0, factory);
printEscherRecord( er, indent+1 ); printEscherRecord(er, indent + 1);
} else if(optVerbose && r.getChildRecords() == null) { } else if (optVerbose && r.getChildRecords() == null) {
String recData = getPrintableRecordContents(r); String recData = getPrintableRecordContents(r);
ps.println(ind + recData ); ps.println(ind + recData);
} }
ps.println(); ps.println();
// If it has children, show them // If it has children, show them
if(r.getChildRecords() != null) { if (r.getChildRecords() != null) {
walkTree((depth+3),pos+8,r.getChildRecords(), indent+1); walkTree((depth + 3), pos + 8, r.getChildRecords(), indent + 1);
} }
// Wind on the position marker // Wind on the position marker
pos += len; pos += len;
} }
} }
} }

View File

@ -45,25 +45,24 @@ public final class TextStyleListing {
// Find the documents, and then their SLWT // Find the documents, and then their SLWT
Record[] records = ss.getRecords(); Record[] records = ss.getRecords();
for(int i=0; i<records.length; i++) { for (Record record : records) {
if(records[i].getRecordType() == 1000l) { if (record.getRecordType() == 1000L) {
Record docRecord = records[i]; Record[] docChildren = record.getChildRecords();
Record[] docChildren = docRecord.getChildRecords(); for (Record docChild : docChildren) {
for(int j=0; j<docChildren.length; j++) { if (docChild instanceof SlideListWithText) {
if(docChildren[j] instanceof SlideListWithText) { Record[] slwtChildren = docChild.getChildRecords();
Record[] slwtChildren = docChildren[j].getChildRecords();
int lastTextLen = -1; int lastTextLen = -1;
for(int k=0; k<slwtChildren.length; k++) { for (Record slwtChild : slwtChildren) {
if(slwtChildren[k] instanceof TextCharsAtom) { if (slwtChild instanceof TextCharsAtom) {
lastTextLen = ((TextCharsAtom)slwtChildren[k]).getText().length(); lastTextLen = ((TextCharsAtom) slwtChild).getText().length();
} }
if(slwtChildren[k] instanceof TextBytesAtom) { if (slwtChild instanceof TextBytesAtom) {
lastTextLen = ((TextBytesAtom)slwtChildren[k]).getText().length(); lastTextLen = ((TextBytesAtom) slwtChild).getText().length();
} }
if(slwtChildren[k] instanceof StyleTextPropAtom) { if (slwtChild instanceof StyleTextPropAtom) {
StyleTextPropAtom stpa = (StyleTextPropAtom)slwtChildren[k]; StyleTextPropAtom stpa = (StyleTextPropAtom) slwtChild;
stpa.setParentTextSize(lastTextLen); stpa.setParentTextSize(lastTextLen);
showStyleTextPropAtom(stpa); showStyleTextPropAtom(stpa);
} }

View File

@ -47,7 +47,7 @@ public final class UserEditAndPersistListing {
// Create the slideshow object, for normal working with // Create the slideshow object, for normal working with
HSLFSlideShowImpl ss = new HSLFSlideShowImpl(args[0]); HSLFSlideShowImpl ss = new HSLFSlideShowImpl(args[0]);
fileContents = ss.getUnderlyingBytes(); fileContents = ss.getUnderlyingBytes();
System.out.println(""); System.out.println();
// Find any persist ones first // Find any persist ones first
int pos = 0; int pos = 0;
@ -85,7 +85,7 @@ public final class UserEditAndPersistListing {
pos += baos.size(); pos += baos.size();
} }
System.out.println(""); System.out.println();
pos = 0; pos = 0;
// Now look for UserEditAtoms // Now look for UserEditAtoms
@ -105,7 +105,7 @@ public final class UserEditAndPersistListing {
pos += baos.size(); pos += baos.size();
} }
System.out.println(""); System.out.println();
// Query the CurrentUserAtom // Query the CurrentUserAtom
@ -113,7 +113,7 @@ public final class UserEditAndPersistListing {
System.out.println("Checking Current User Atom"); System.out.println("Checking Current User Atom");
System.out.println(" Thinks the CurrentEditOffset is " + cua.getCurrentEditOffset()); System.out.println(" Thinks the CurrentEditOffset is " + cua.getCurrentEditOffset());
System.out.println(""); System.out.println();
ss.close(); ss.close();
} }

View File

@ -0,0 +1,139 @@
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
package org.apache.poi.hslf.dev;
import org.apache.poi.POIDataSamples;
import org.apache.poi.hslf.exceptions.EncryptedPowerPointFileException;
import org.apache.poi.hslf.exceptions.OldPowerPointFormatException;
import org.apache.poi.util.IOUtils;
import org.apache.poi.util.LocaleUtil;
import org.apache.poi.util.NullOutputStream;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.io.File;
import java.io.OutputStream;
import java.io.PrintStream;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import static org.junit.Assert.assertNotNull;
@RunWith(Parameterized.class)
public abstract class BasePPTIteratingTest {
protected static final OutputStream NULL_OUTPUT_STREAM = new NullOutputStream();
protected static final Set<String> OLD_FILES = new HashSet<>();
static {
OLD_FILES.add("PPT95.ppt");
OLD_FILES.add("pp40only.ppt");
}
protected static final Set<String> ENCRYPTED_FILES = new HashSet<>();
static {
ENCRYPTED_FILES.add("cryptoapi-proc2356.ppt");
ENCRYPTED_FILES.add("Password_Protected-np-hello.ppt");
ENCRYPTED_FILES.add("Password_Protected-56-hello.ppt");
ENCRYPTED_FILES.add("Password_Protected-hello.ppt");
}
@Rule
public ExpectedException thrown = ExpectedException.none();
protected static final Map<String,Class<? extends Throwable>> EXCLUDED =
new HashMap<>();
@Parameterized.Parameters(name="{index}: {0}")
public static Iterable<Object[]> files() {
String dataDirName = System.getProperty(POIDataSamples.TEST_PROPERTY);
if(dataDirName == null) {
dataDirName = "test-data";
}
List<Object[]> files = new ArrayList<>();
findFile(files, dataDirName + "/slideshow");
return files;
}
private final PrintStream save = System.out;
@Before
public void setUpBase() throws UnsupportedEncodingException {
// set a higher max allocation limit as some test-files require more
IOUtils.setByteArrayMaxOverride(5*1024*1024);
// redirect standard out during the test to avoid spamming the console with output
System.setOut(new PrintStream(NULL_OUTPUT_STREAM, true, LocaleUtil.CHARSET_1252.name()));
}
@After
public void tearDownBase() {
System.setOut(save);
// reset
IOUtils.setByteArrayMaxOverride(-1);
}
private static void findFile(List<Object[]> list, String dir) {
String[] files = new File(dir).list((arg0, arg1) -> arg1.toLowerCase(Locale.ROOT).endsWith(".ppt"));
assertNotNull("Did not find any ppt files in directory " + dir, files);
for(String file : files) {
list.add(new Object[] { new File(dir, file) });
}
}
@Parameterized.Parameter
public File file;
@Test
public void testAllFiles() throws Exception {
String fileName = file.getName();
if (EXCLUDED.containsKey(fileName)) {
thrown.expect(EXCLUDED.get(fileName));
}
try {
runOneFile(file);
} catch (OldPowerPointFormatException e) {
// expected for some files
if(!OLD_FILES.contains(file.getName())) {
throw e;
}
} catch (EncryptedPowerPointFileException e) {
// expected for some files
if(!ENCRYPTED_FILES.contains(file.getName())) {
throw e;
}
}
}
abstract void runOneFile(File pFile) throws Exception;
}

View File

@ -0,0 +1,44 @@
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
package org.apache.poi.hslf.dev;
import org.apache.poi.EmptyFileException;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
import static org.junit.Assert.fail;
public class TestPPDrawingTextListing extends BasePPTIteratingTest {
@Test
public void testMain() throws IOException {
// calls System.exit(): PPDrawingTextListing.main(new String[0]);
try {
PPDrawingTextListing.main(new String[]{"invalidfile"});
fail("Should catch exception here");
} catch (EmptyFileException e) {
// expected here
}
}
@Override
void runOneFile(File pFile) throws Exception {
PPDrawingTextListing.main(new String[]{pFile.getAbsolutePath()});
}
}

View File

@ -0,0 +1,49 @@
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
package org.apache.poi.hslf.dev;
import org.apache.poi.EmptyFileException;
import org.apache.poi.hslf.HSLFTestDataSamples;
import org.junit.Test;
import java.io.File;
import static org.junit.Assert.fail;
public class TestPPTXMLDump extends BasePPTIteratingTest {
@Test
public void testMain() throws Exception {
PPTXMLDump.main(new String[0]);
PPTXMLDump.main(new String[]{
HSLFTestDataSamples.getSampleFile("slide_master.ppt").getAbsolutePath(),
HSLFTestDataSamples.getSampleFile("pictures.ppt").getAbsolutePath()
});
try {
PPTXMLDump.main(new String[]{"invalidfile"});
fail("Should catch exception here");
} catch (EmptyFileException e) {
// expected here
}
}
@Override
void runOneFile(File pFile) throws Exception {
PPTXMLDump.main(new String[]{pFile.getAbsolutePath()});
}
}

View File

@ -0,0 +1,43 @@
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
package org.apache.poi.hslf.dev;
import org.apache.poi.EmptyFileException;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
import static org.junit.Assert.fail;
public class TestSLWTListing extends BasePPTIteratingTest {
@Test
public void testMain() throws IOException {
// calls System.exit(): SLWTListing.main(new String[0]);
try {
SLWTListing.main(new String[]{"invalidfile"});
fail("Should catch exception here");
} catch (EmptyFileException e) {
// expected here
}
}
@Override
void runOneFile(File pFile) throws Exception {
SLWTListing.main(new String[]{pFile.getAbsolutePath()});
}
}

View File

@ -0,0 +1,44 @@
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
package org.apache.poi.hslf.dev;
import org.apache.poi.EmptyFileException;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
import static org.junit.Assert.fail;
public class TestSLWTTextListing extends BasePPTIteratingTest {
@Test
public void testMain() throws IOException {
// calls System.exit(): SLWTTextListing.main(new String[0]);
try {
SLWTTextListing.main(new String[]{"invalidfile"});
fail("Should catch exception here");
} catch (EmptyFileException e) {
// expected here
}
}
@Override
void runOneFile(File pFile) throws Exception {
SLWTTextListing.main(new String[]{pFile.getAbsolutePath()});
}
}

View File

@ -0,0 +1,48 @@
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
package org.apache.poi.hslf.dev;
import org.apache.poi.EmptyFileException;
import org.apache.poi.hslf.HSLFTestDataSamples;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
import static org.junit.Assert.fail;
public class TestSlideAndNotesAtomListing extends BasePPTIteratingTest {
@Test
public void testMain() throws IOException {
// calls System.exit(): SlideAndNotesAtomListing.main(new String[0]);
SlideAndNotesAtomListing.main(new String[] {
HSLFTestDataSamples.getSampleFile("slide_master.ppt").getAbsolutePath()
});
try {
SlideAndNotesAtomListing.main(new String[]{"invalidfile"});
fail("Should catch exception here");
} catch (EmptyFileException e) {
// expected here
}
}
@Override
void runOneFile(File pFile) throws Exception {
SlideAndNotesAtomListing.main(new String[]{pFile.getAbsolutePath()});
}
}

View File

@ -0,0 +1,48 @@
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
package org.apache.poi.hslf.dev;
import org.apache.poi.EmptyFileException;
import org.apache.poi.hslf.HSLFTestDataSamples;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
import static org.junit.Assert.fail;
public class TestSlideIdListing extends BasePPTIteratingTest {
@Test
public void testMain() throws IOException {
// calls System.exit(): SlideIdListing.main(new String[0]);
SlideIdListing.main(new String[] {
HSLFTestDataSamples.getSampleFile("slide_master.ppt").getAbsolutePath()
});
try {
SlideIdListing.main(new String[]{"invalidfile"});
fail("Should catch exception here");
} catch (EmptyFileException e) {
// expected here
}
}
@Override
void runOneFile(File pFile) throws Exception {
SlideIdListing.main(new String[]{pFile.getAbsolutePath()});
}
}

View File

@ -0,0 +1,79 @@
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
package org.apache.poi.hslf.dev;
import org.apache.poi.EmptyFileException;
import org.apache.poi.hslf.HSLFTestDataSamples;
import org.apache.poi.util.IOUtils;
import org.junit.Test;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.HashSet;
import java.util.Set;
import static org.junit.Assert.fail;
public class TestSlideShowDumper extends BasePPTIteratingTest {
private static final Set<String> FAILING = new HashSet<>();
static {
FAILING.add("cryptoapi-proc2356.ppt");
FAILING.add("41384.ppt");
FAILING.add("bug56240.ppt");
}
@Test
public void testMain() throws IOException {
SlideShowDumper.main(new String[0]);
// SlideShowDumper calls IOUtils.toByteArray(is), which would fail if a different size is defined
IOUtils.setByteArrayMaxOverride(-1);
SlideShowDumper.main(new String[] {
HSLFTestDataSamples.getSampleFile("slide_master.ppt").getAbsolutePath(),
HSLFTestDataSamples.getSampleFile("pictures.ppt").getAbsolutePath()
});
try {
SlideShowDumper.main(new String[]{"invalidfile"});
fail("Should catch exception here");
} catch (EmptyFileException e) {
// expected here
}
}
@Override
void runOneFile(File pFile) throws Exception {
try {
// SlideShowDumper calls IOUtils.toByteArray(is), which would fail if a different size is defined
IOUtils.setByteArrayMaxOverride(-1);
SlideShowDumper.main(new String[]{pFile.getAbsolutePath()});
} catch (ArrayIndexOutOfBoundsException e) {
// some corrupted documents currently can cause this excpetion
if (!FAILING.contains(pFile.getName()) && !ENCRYPTED_FILES.contains(pFile.getName())) {
throw e;
}
} catch (FileNotFoundException e) {
// some old files are not detected correctly
if(!OLD_FILES.contains(pFile.getName())) {
throw e;
}
}
}
}

View File

@ -0,0 +1,59 @@
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
package org.apache.poi.hslf.dev;
import org.apache.poi.EmptyFileException;
import org.apache.poi.hslf.HSLFTestDataSamples;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
import static org.junit.Assert.fail;
public class TestSlideShowRecordDumper extends BasePPTIteratingTest {
@Test
public void testMain() throws IOException {
SlideShowRecordDumper.main(new String[0]);
SlideShowRecordDumper.main(new String[] {
HSLFTestDataSamples.getSampleFile("slide_master.ppt").getAbsolutePath(),
});
SlideShowRecordDumper.main(new String[] {
"-escher",
HSLFTestDataSamples.getSampleFile("slide_master.ppt").getAbsolutePath(),
});
SlideShowRecordDumper.main(new String[] {
"-verbose",
HSLFTestDataSamples.getSampleFile("pictures.ppt").getAbsolutePath()
});
try {
SlideShowRecordDumper.main(new String[]{"invalidfile"});
fail("Should catch exception here");
} catch (EmptyFileException e) {
// expected here
}
}
@Override
void runOneFile(File pFile) throws Exception {
SlideShowRecordDumper.main(new String[]{pFile.getAbsolutePath()});
}
}

View File

@ -0,0 +1,57 @@
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
package org.apache.poi.hslf.dev;
import org.apache.poi.EmptyFileException;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
import java.util.HashSet;
import java.util.Set;
import static org.junit.Assert.fail;
public class TestTextStyleListing extends BasePPTIteratingTest {
private static Set<String> FAILING = new HashSet<>();
static {
FAILING.add("empty_textbox.ppt");
}
@Test
public void testMain() throws IOException {
// calls System.exit(): TextStyleListing.main(new String[0]);
try {
TextStyleListing.main(new String[]{"invalidfile"});
fail("Should catch exception here");
} catch (EmptyFileException e) {
// expected here
}
}
@Override
void runOneFile(File pFile) throws Exception {
try {
TextStyleListing.main(new String[]{pFile.getAbsolutePath()});
} catch (ArrayIndexOutOfBoundsException e) {
// some corrupted documents currently can cause this excpetion
if (!FAILING.contains(pFile.getName())) {
throw e;
}
}
}
}

View File

@ -0,0 +1,44 @@
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
package org.apache.poi.hslf.dev;
import org.apache.poi.EmptyFileException;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
import static org.junit.Assert.fail;
public class TestUserEditAndPersistListing extends BasePPTIteratingTest {
@Test
public void testMain() throws IOException {
// calls System.exit(): UserEditAndPersistListing.main(new String[0]);
try {
UserEditAndPersistListing.main(new String[]{"invalidfile"});
fail("Should catch exception here");
} catch (EmptyFileException e) {
// expected here
}
}
@Override
void runOneFile(File pFile) throws Exception {
UserEditAndPersistListing.main(new String[]{pFile.getAbsolutePath()});
}
}

View File

@ -52,7 +52,7 @@ public class TestEscherDump {
@Test @Test
public void testWithData() throws Exception { public void testWithData() throws Exception {
new EscherDump().dumpOld(8, new ByteArrayInputStream(new byte[] { 00, 00, 00, 00, 00, 00, 00, 00 }), nullPS); new EscherDump().dumpOld(8, new ByteArrayInputStream(new byte[] {0, 0, 0, 0, 0, 0, 0, 0}), nullPS);
} }
@Test @Test
@ -63,14 +63,11 @@ public class TestEscherDump {
//new EscherDump().dumpOld(data.length, new ByteArrayInputStream(data), System.out); //new EscherDump().dumpOld(data.length, new ByteArrayInputStream(data), System.out);
data = new byte[2586114]; data = new byte[2586114];
InputStream stream = HSSFTestDataSamples.openSampleFileStream("44593.xls"); try (InputStream stream = HSSFTestDataSamples.openSampleFileStream("44593.xls")) {
try {
int bytes = IOUtils.readFully(stream, data); int bytes = IOUtils.readFully(stream, data);
assertTrue(bytes != -1); assertTrue(bytes != -1);
//new EscherDump().dump(bytes, data, System.out); //new EscherDump().dump(bytes, data, System.out);
//new EscherDump().dumpOld(bytes, new ByteArrayInputStream(data), System.out); //new EscherDump().dumpOld(bytes, new ByteArrayInputStream(data), System.out);
} finally {
stream.close();
} }
} }

View File

@ -20,7 +20,6 @@ import static org.junit.Assert.assertNotNull;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FilenameFilter;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
@ -29,7 +28,6 @@ import java.util.Locale;
import java.util.Map; import java.util.Map;
import org.apache.poi.POIDataSamples; import org.apache.poi.POIDataSamples;
import org.apache.poi.hssf.record.crypto.Biff8EncryptionKey;
import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.util.NullOutputStream; import org.apache.poi.util.NullOutputStream;
import org.junit.Rule; import org.junit.Rule;
@ -71,12 +69,7 @@ public abstract class BaseXLSIteratingTest {
} }
private static void findFile(List<Object[]> list, String dir) { private static void findFile(List<Object[]> list, String dir) {
String[] files = new File(dir).list(new FilenameFilter() { String[] files = new File(dir).list((arg0, arg1) -> arg1.toLowerCase(Locale.ROOT).endsWith(".xls"));
@Override
public boolean accept(File arg0, String arg1) {
return arg1.toLowerCase(Locale.ROOT).endsWith(".xls");
}
});
assertNotNull("Did not find any xls files in directory " + dir, files); assertNotNull("Did not find any xls files in directory " + dir, files);
@ -99,17 +92,9 @@ public abstract class BaseXLSIteratingTest {
runOneFile(file); runOneFile(file);
} catch (Exception e) { } catch (Exception e) {
// try to read it in HSSFWorkbook to quickly fail if we cannot read the file there at all and thus probably should use EXCLUDED instead // try to read it in HSSFWorkbook to quickly fail if we cannot read the file there at all and thus probably should use EXCLUDED instead
FileInputStream stream = new FileInputStream(file); try (FileInputStream stream = new FileInputStream(file); HSSFWorkbook wb = new HSSFWorkbook(stream)) {
HSSFWorkbook wb = null; assertNotNull(wb);
try { }
wb = new HSSFWorkbook(stream);
assertNotNull(wb);
} finally {
if (wb != null) {
wb.close();
}
stream.close();
}
throw e; throw e;
} }

View File

@ -43,7 +43,6 @@ public class TestBiffDrawingToXml extends BaseXLSIteratingTest {
EXCLUDED.put("testEXCEL_5.xls", OldExcelFormatException.class); // Biff 5 / Excel 5 EXCLUDED.put("testEXCEL_5.xls", OldExcelFormatException.class); // Biff 5 / Excel 5
EXCLUDED.put("60284.xls", OldExcelFormatException.class); // Biff 5 / Excel 5 EXCLUDED.put("60284.xls", OldExcelFormatException.class); // Biff 5 / Excel 5
EXCLUDED.put("testEXCEL_95.xls", OldExcelFormatException.class); // Biff 5 / Excel 95 EXCLUDED.put("testEXCEL_95.xls", OldExcelFormatException.class); // Biff 5 / Excel 95
EXCLUDED.put("60284.xls", OldExcelFormatException.class); // Biff 5 / Excel 95
EXCLUDED.put("43493.xls", RecordInputStream.LeftoverDataException.class); // HSSFWorkbook cannot open it as well EXCLUDED.put("43493.xls", RecordInputStream.LeftoverDataException.class); // HSSFWorkbook cannot open it as well
EXCLUDED.put("44958_1.xls", RecordInputStream.LeftoverDataException.class); EXCLUDED.put("44958_1.xls", RecordInputStream.LeftoverDataException.class);
EXCLUDED.put("61300.xls", RecordFormatException.class); EXCLUDED.put("61300.xls", RecordFormatException.class);
@ -55,12 +54,9 @@ public class TestBiffDrawingToXml extends BaseXLSIteratingTest {
try { try {
//System.setOut(new PrintStream(TestBiffViewer.NULL_OUTPUT_STREAM)); //System.setOut(new PrintStream(TestBiffViewer.NULL_OUTPUT_STREAM));
// use a NullOutputStream to not write the bytes anywhere for best runtime // use a NullOutputStream to not write the bytes anywhere for best runtime
InputStream wb = new FileInputStream(pFile); try (InputStream wb = new FileInputStream(pFile)) {
try { BiffDrawingToXml.writeToFile(NULL_OUTPUT_STREAM, wb, false, new String[]{});
BiffDrawingToXml.writeToFile(NULL_OUTPUT_STREAM, wb, false, new String[] {}); }
} finally {
wb.close();
}
} finally { } finally {
System.setOut(save); System.setOut(save);
} }

View File

@ -43,7 +43,6 @@ public class TestEFBiffViewer extends BaseXLSIteratingTest {
EXCLUDED.put("testEXCEL_5.xls", OldExcelFormatException.class); // Biff 5 / Excel 5 EXCLUDED.put("testEXCEL_5.xls", OldExcelFormatException.class); // Biff 5 / Excel 5
EXCLUDED.put("60284.xls", OldExcelFormatException.class); // Biff 5 / Excel 5 EXCLUDED.put("60284.xls", OldExcelFormatException.class); // Biff 5 / Excel 5
EXCLUDED.put("testEXCEL_95.xls", OldExcelFormatException.class); // Biff 5 / Excel 95 EXCLUDED.put("testEXCEL_95.xls", OldExcelFormatException.class); // Biff 5 / Excel 95
EXCLUDED.put("60284.xls", OldExcelFormatException.class); // Biff 5 / Excel 95
EXCLUDED.put("43493.xls", RecordInputStream.LeftoverDataException.class); // HSSFWorkbook cannot open it as well EXCLUDED.put("43493.xls", RecordInputStream.LeftoverDataException.class); // HSSFWorkbook cannot open it as well
EXCLUDED.put("44958_1.xls", RecordInputStream.LeftoverDataException.class); EXCLUDED.put("44958_1.xls", RecordInputStream.LeftoverDataException.class);
EXCLUDED.put("XRefCalc.xls", RuntimeException.class); // "Buffer overrun" EXCLUDED.put("XRefCalc.xls", RuntimeException.class); // "Buffer overrun"

View File

@ -44,7 +44,6 @@ public class TestFormulaViewer extends BaseXLSIteratingTest {
EXCLUDED.put("testEXCEL_5.xls", OldExcelFormatException.class); // Biff 5 / Excel 5 EXCLUDED.put("testEXCEL_5.xls", OldExcelFormatException.class); // Biff 5 / Excel 5
EXCLUDED.put("60284.xls", OldExcelFormatException.class); // Biff 5 / Excel 5 EXCLUDED.put("60284.xls", OldExcelFormatException.class); // Biff 5 / Excel 5
EXCLUDED.put("testEXCEL_95.xls", OldExcelFormatException.class); // Biff 5 / Excel 95 EXCLUDED.put("testEXCEL_95.xls", OldExcelFormatException.class); // Biff 5 / Excel 95
EXCLUDED.put("60284.xls", OldExcelFormatException.class); // Biff 5 / Excel 95
EXCLUDED.put("43493.xls", RecordInputStream.LeftoverDataException.class); // HSSFWorkbook cannot open it as well EXCLUDED.put("43493.xls", RecordInputStream.LeftoverDataException.class); // HSSFWorkbook cannot open it as well
EXCLUDED.put("44958_1.xls", RecordInputStream.LeftoverDataException.class); EXCLUDED.put("44958_1.xls", RecordInputStream.LeftoverDataException.class);
EXCLUDED.put("61300.xls", RecordFormatException.class); EXCLUDED.put("61300.xls", RecordFormatException.class);

View File

@ -47,7 +47,6 @@ public class TestReSave extends BaseXLSIteratingTest {
EXCLUDED.put("testEXCEL_5.xls", OldExcelFormatException.class); // Biff 5 / Excel 5 EXCLUDED.put("testEXCEL_5.xls", OldExcelFormatException.class); // Biff 5 / Excel 5
EXCLUDED.put("60284.xls", OldExcelFormatException.class); // Biff 5 / Excel 5 EXCLUDED.put("60284.xls", OldExcelFormatException.class); // Biff 5 / Excel 5
EXCLUDED.put("testEXCEL_95.xls", OldExcelFormatException.class); // Biff 5 / Excel 95 EXCLUDED.put("testEXCEL_95.xls", OldExcelFormatException.class); // Biff 5 / Excel 95
EXCLUDED.put("60284.xls", OldExcelFormatException.class); // Biff 5 / Excel 95
EXCLUDED.put("43493.xls", RecordInputStream.LeftoverDataException.class); // HSSFWorkbook cannot open it as well EXCLUDED.put("43493.xls", RecordInputStream.LeftoverDataException.class); // HSSFWorkbook cannot open it as well
EXCLUDED.put("44958_1.xls", RecordInputStream.LeftoverDataException.class); EXCLUDED.put("44958_1.xls", RecordInputStream.LeftoverDataException.class);
EXCLUDED.put("XRefCalc.xls", RuntimeException.class); // "Buffer overrun" EXCLUDED.put("XRefCalc.xls", RuntimeException.class); // "Buffer overrun"
@ -79,7 +78,6 @@ public class TestReSave extends BaseXLSIteratingTest {
// clean up the re-saved file // clean up the re-saved file
assertTrue(!reSavedFile.exists() || reSavedFile.delete()); assertTrue(!reSavedFile.exists() || reSavedFile.delete());
} }
} finally { } finally {
System.setOut(save); System.setOut(save);
} }

View File

@ -37,7 +37,6 @@ public class TestRecordLister extends BaseXLSIteratingTest {
EXCLUDED.put("testEXCEL_5.xls", OldExcelFormatException.class); // Biff 5 / Excel 5 EXCLUDED.put("testEXCEL_5.xls", OldExcelFormatException.class); // Biff 5 / Excel 5
EXCLUDED.put("60284.xls", OldExcelFormatException.class); // Biff 5 / Excel 5 EXCLUDED.put("60284.xls", OldExcelFormatException.class); // Biff 5 / Excel 5
EXCLUDED.put("testEXCEL_95.xls", OldExcelFormatException.class); // Biff 5 / Excel 95 EXCLUDED.put("testEXCEL_95.xls", OldExcelFormatException.class); // Biff 5 / Excel 95
EXCLUDED.put("60284.xls", OldExcelFormatException.class); // Biff 5 / Excel 95
EXCLUDED.put("61300.xls", RecordFormatException.class); EXCLUDED.put("61300.xls", RecordFormatException.class);
} }