aboutsummaryrefslogtreecommitdiffstats
path: root/src/integrationtest/org/apache/poi/stress/SpreadsheetHandler.java
diff options
context:
space:
mode:
authorAndreas Beeker <kiwiwings@apache.org>2016-01-10 20:44:17 +0000
committerAndreas Beeker <kiwiwings@apache.org>2016-01-10 20:44:17 +0000
commitc47f6763971f3ab1a563c92d460f5cb48c4c0728 (patch)
tree697966dd46ed9e9263c52d3a0678b464d71f8da8 /src/integrationtest/org/apache/poi/stress/SpreadsheetHandler.java
parent05820728568c4ed68df34631d816dba223b8957a (diff)
downloadpoi-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/org/apache/poi/stress/SpreadsheetHandler.java')
-rw-r--r--src/integrationtest/org/apache/poi/stress/SpreadsheetHandler.java26
1 files changed, 26 insertions, 0 deletions
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