diff options
author | Andreas Beeker <kiwiwings@apache.org> | 2016-01-10 20:44:17 +0000 |
---|---|---|
committer | Andreas Beeker <kiwiwings@apache.org> | 2016-01-10 20:44:17 +0000 |
commit | c47f6763971f3ab1a563c92d460f5cb48c4c0728 (patch) | |
tree | 697966dd46ed9e9263c52d3a0678b464d71f8da8 /src/integrationtest | |
parent | 05820728568c4ed68df34631d816dba223b8957a (diff) | |
download | poi-c47f6763971f3ab1a563c92d460f5cb48c4c0728.tar.gz poi-c47f6763971f3ab1a563c92d460f5cb48c4c0728.zip |
#54916 - POI does not always read all the slides in pptx files
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1723966 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/integrationtest')
3 files changed, 38 insertions, 0 deletions
diff --git a/src/integrationtest/org/apache/poi/TestAllFiles.java b/src/integrationtest/org/apache/poi/TestAllFiles.java index a23dbdd7cc..a196797645 100644 --- a/src/integrationtest/org/apache/poi/TestAllFiles.java +++ b/src/integrationtest/org/apache/poi/TestAllFiles.java @@ -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}") diff --git a/src/integrationtest/org/apache/poi/stress/SpreadsheetHandler.java b/src/integrationtest/org/apache/poi/stress/SpreadsheetHandler.java index 64e9805cb9..243679d03d 100644 --- a/src/integrationtest/org/apache/poi/stress/SpreadsheetHandler.java +++ b/src/integrationtest/org/apache/poi/stress/SpreadsheetHandler.java @@ -29,6 +29,7 @@ import org.apache.poi.ss.usermodel.Row; 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 { @@ -54,6 +55,10 @@ public abstract class SpreadsheetHandler extends AbstractFileHandler { assertNotNull(read); readContent(read); + + modifyContent(read); + + read.close(); } private ByteArrayOutputStream writeToArray(Workbook wb) @@ -88,4 +93,25 @@ public abstract class SpreadsheetHandler extends AbstractFileHandler { } } } + + 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; + } + } + } }
\ No newline at end of file diff --git a/src/integrationtest/org/apache/poi/stress/XSSFFileHandler.java b/src/integrationtest/org/apache/poi/stress/XSSFFileHandler.java index 4de2dbd8eb..cf893949f0 100644 --- a/src/integrationtest/org/apache/poi/stress/XSSFFileHandler.java +++ b/src/integrationtest/org/apache/poi/stress/XSSFFileHandler.java @@ -68,6 +68,8 @@ public class XSSFFileHandler extends SpreadsheetHandler { exportToXML(wb); checkXSSFReader(OPCPackage.open(new ByteArrayInputStream(bytes))); + + wb.close(); } |