Skip to content

Commit

Permalink
#54916 - POI does not always read all the slides in pptx files
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1723966 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
kiwiwings committed Jan 10, 2016
1 parent b3b4ed6 commit f56b918
Show file tree
Hide file tree
Showing 73 changed files with 1,389 additions and 650 deletions.
10 changes: 10 additions & 0 deletions src/integrationtest/org/apache/poi/TestAllFiles.java
Expand Up @@ -259,12 +259,22 @@ public class TestAllFiles {
// non-TNEF files
EXPECTED_FAILURES.add("ddf/Container.dat");
EXPECTED_FAILURES.add("ddf/47143.dat");

// sheet cloning errors
EXPECTED_FAILURES.add("spreadsheet/47813.xlsx");
EXPECTED_FAILURES.add("spreadsheet/56450.xls");
EXPECTED_FAILURES.add("spreadsheet/57231_MixedGasReport.xls");
EXPECTED_FAILURES.add("spreadsheet/OddStyleRecord.xls");
EXPECTED_FAILURES.add("spreadsheet/WithChartSheet.xlsx");
EXPECTED_FAILURES.add("spreadsheet/chart_sheet.xlsx");
}

private static final Set<String> IGNORED = new HashSet<String>();
static {
// need JDK8+ - https://bugs.openjdk.java.net/browse/JDK-8038081
IGNORED.add("slideshow/42474-2.ppt");
// OPC handler works / XSSF handler fails
IGNORED.add("spreadsheet/57181.xlsm");
}

@Parameters(name="{index}: {0} using {1}")
Expand Down
26 changes: 26 additions & 0 deletions src/integrationtest/org/apache/poi/stress/SpreadsheetHandler.java
Expand Up @@ -29,6 +29,7 @@ Licensed to the Apache Software Foundation (ASF) under one or more
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;
import org.apache.poi.util.RecordFormatException;

public abstract class SpreadsheetHandler extends AbstractFileHandler {
public void handleWorkbook(Workbook wb, String extension) throws IOException {
Expand All @@ -54,6 +55,10 @@ public void handleWorkbook(Workbook wb, String extension) throws IOException {
assertNotNull(read);

readContent(read);

modifyContent(read);

read.close();
}

private ByteArrayOutputStream writeToArray(Workbook wb)
Expand Down Expand Up @@ -88,4 +93,25 @@ private void readContent(Workbook wb) {
}
}
}

private void modifyContent(Workbook wb) {
for (int i=wb.getNumberOfSheets()-1; i>=0; i--) {
try {
wb.cloneSheet(i);
} catch (RecordFormatException e) {
if (e.getCause() instanceof CloneNotSupportedException) {
// ignore me
continue;
}
throw e;
} catch (RuntimeException e) {
if ("Could not find 'internal references' EXTERNALBOOK".equals(e.getMessage())) {
continue;
} else if ("CountryRecord not found".equals(e.getMessage())) {
continue;
}
throw e;
}
}
}
}
Expand Up @@ -68,6 +68,8 @@ public void handleFile(InputStream stream) throws Exception {
exportToXML(wb);

checkXSSFReader(OPCPackage.open(new ByteArrayInputStream(bytes)));

wb.close();
}


Expand Down

0 comments on commit f56b918

Please sign in to comment.