From d28720afd08d1998a7784f09e6cfd5ed9bec2dc9 Mon Sep 17 00:00:00 2001 From: Dominik Stadler Date: Sun, 25 Nov 2018 21:56:43 +0000 Subject: Add test for FileMagic JavaDoc warning fixes Remove some IDE warnings Reformat code of sample application git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1847437 13f79535-47bb-0310-9956-ffa450edef68 --- src/integrationtest/org/apache/poi/stress/XSSFFileHandler.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/integrationtest') diff --git a/src/integrationtest/org/apache/poi/stress/XSSFFileHandler.java b/src/integrationtest/org/apache/poi/stress/XSSFFileHandler.java index 5c47d9af7e..48a30a2569 100644 --- a/src/integrationtest/org/apache/poi/stress/XSSFFileHandler.java +++ b/src/integrationtest/org/apache/poi/stress/XSSFFileHandler.java @@ -35,7 +35,6 @@ import java.util.Iterator; import java.util.Locale; import java.util.Set; -import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.TransformerException; import org.apache.poi.EncryptedDocumentException; @@ -148,7 +147,7 @@ public class XSSFFileHandler extends SpreadsheetHandler { } private void exportToXML(XSSFWorkbook wb) throws SAXException, - ParserConfigurationException, TransformerException { + TransformerException { for (XSSFMap map : wb.getCustomXMLMappings()) { XSSFExportToXml exporter = new XSSFExportToXml(map); @@ -165,7 +164,6 @@ public class XSSFFileHandler extends SpreadsheetHandler { // zip-bomb EXPECTED_ADDITIONAL_FAILURES.add("spreadsheet/54764.xlsx"); EXPECTED_ADDITIONAL_FAILURES.add("spreadsheet/54764-2.xlsx"); - EXPECTED_ADDITIONAL_FAILURES.add("spreadsheet/54764.xlsx"); EXPECTED_ADDITIONAL_FAILURES.add("spreadsheet/poc-xmlbomb.xlsx"); EXPECTED_ADDITIONAL_FAILURES.add("spreadsheet/poc-xmlbomb-empty.xlsx"); // strict OOXML @@ -185,18 +183,19 @@ public class XSSFFileHandler extends SpreadsheetHandler { public void handleAdditional(File file) throws Exception { // redirect stdout as the examples often write lots of text PrintStream oldOut = System.out; + String testFile = file.getParentFile().getName() + "/" + file.getName(); try { System.setOut(new NullPrintStream()); FromHowTo.main(new String[]{file.getAbsolutePath()}); XLSX2CSV.main(new String[]{file.getAbsolutePath()}); assertFalse("Expected Extraction to fail for file " + file + " and handler " + this + ", but did not fail!", - EXPECTED_ADDITIONAL_FAILURES.contains(file.getParentFile().getName() + "/" + file.getName())); + EXPECTED_ADDITIONAL_FAILURES.contains(testFile)); } catch (OLE2NotOfficeXmlFileException e) { // we have some files that are not actually OOXML and thus cannot be tested here } catch (IllegalArgumentException | InvalidFormatException | POIXMLException | IOException e) { - if(!EXPECTED_ADDITIONAL_FAILURES.contains(file.getParentFile().getName() + "/" + file.getName())) { + if(!EXPECTED_ADDITIONAL_FAILURES.contains(testFile)) { throw e; } } finally { -- cgit v1.2.3 From aad955d3bfa210d7d146663e64d6d8b68b7843c9 Mon Sep 17 00:00:00 2001 From: Andreas Beeker Date: Sun, 25 Nov 2018 23:01:54 +0000 Subject: Fix exception for old powerpoint documents without the usual stream name git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1847442 13f79535-47bb-0310-9956-ffa450edef68 --- src/integrationtest/org/apache/poi/TestAllFiles.java | 1 + .../org/apache/poi/xslf/usermodel/TestPPTX2PNG.java | 2 +- .../org/apache/poi/hslf/record/CurrentUserAtom.java | 4 +++- .../org/apache/poi/hslf/usermodel/HSLFSlideShow.java | 1 + .../apache/poi/hslf/usermodel/HSLFSlideShowImpl.java | 19 ++++++++++++++----- test-data/slideshow/keyframes.ppt | Bin 389330 -> 0 bytes test-data/slideshow/keyframes.pptx | Bin 0 -> 389330 bytes 7 files changed, 20 insertions(+), 7 deletions(-) delete mode 100644 test-data/slideshow/keyframes.ppt create mode 100644 test-data/slideshow/keyframes.pptx (limited to 'src/integrationtest') diff --git a/src/integrationtest/org/apache/poi/TestAllFiles.java b/src/integrationtest/org/apache/poi/TestAllFiles.java index 61c47b9e88..40f19f9c85 100644 --- a/src/integrationtest/org/apache/poi/TestAllFiles.java +++ b/src/integrationtest/org/apache/poi/TestAllFiles.java @@ -289,6 +289,7 @@ public class TestAllFiles { "document/Bug50955.doc", "document/57843.doc", "slideshow/PPT95.ppt", + "slideshow/pp40only.ppt", "slideshow/Divino_Revelado.pptx", "openxml4j/OPCCompliance_CoreProperties_DCTermsNamespaceLimitedUseFAIL.docx", "openxml4j/OPCCompliance_CoreProperties_DoNotUseCompatibilityMarkupFAIL.docx", diff --git a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestPPTX2PNG.java b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestPPTX2PNG.java index 6e27599729..199a9f6286 100644 --- a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestPPTX2PNG.java +++ b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestPPTX2PNG.java @@ -47,7 +47,7 @@ public class TestPPTX2PNG { private static final POIDataSamples samples = POIDataSamples.getSlideShowInstance(); private static final File basedir = null; private static final String files = - "53446.ppt, alterman_security.ppt, alterman_security.pptx, KEY02.pptx, themes.pptx, backgrounds.pptx, layouts.pptx, sample.pptx, shapes.pptx, 54880_chinese.ppt, keyframes.ppt"; + "53446.ppt, alterman_security.ppt, alterman_security.pptx, KEY02.pptx, themes.pptx, backgrounds.pptx, layouts.pptx, sample.pptx, shapes.pptx, 54880_chinese.ppt, keyframes.pptx"; diff --git a/src/scratchpad/src/org/apache/poi/hslf/record/CurrentUserAtom.java b/src/scratchpad/src/org/apache/poi/hslf/record/CurrentUserAtom.java index cedfbb0470..26ba59d2c6 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/record/CurrentUserAtom.java +++ b/src/scratchpad/src/org/apache/poi/hslf/record/CurrentUserAtom.java @@ -20,6 +20,8 @@ package org.apache.poi.hslf.record; +import static org.apache.poi.hslf.usermodel.HSLFSlideShow.PP95_DOCUMENT; + import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -143,7 +145,7 @@ public class CurrentUserAtom // See how long it is. If it's under 28 bytes long, we can't // read it if(_contents.length < 28) { - boolean isPP95 = dir.hasEntry("PP40"); + boolean isPP95 = dir.hasEntry(PP95_DOCUMENT); // PPT95 has 4 byte size, then data if (!isPP95 && _contents.length >= 4) { int size = LittleEndian.getInt(_contents); diff --git a/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShow.java b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShow.java index ecc360e135..2f0a116d68 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShow.java +++ b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShow.java @@ -71,6 +71,7 @@ public final class HSLFSlideShow implements SlideShow