git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1882025 13f79535-47bb-0310-9956-ffa450edef68tags/before_ooxml_3rd_edition
@@ -33,7 +33,6 @@ import java.util.Set; | |||
import org.apache.poi.examples.hpsf.CopyCompare; | |||
import org.apache.poi.hpsf.DocumentSummaryInformation; | |||
import org.apache.poi.hpsf.HPSFPropertiesOnlyDocument; | |||
import org.apache.poi.hpsf.MarkUnsupportedException; | |||
import org.apache.poi.hpsf.PropertySet; | |||
import org.apache.poi.hpsf.SummaryInformation; | |||
import org.apache.poi.poifs.filesystem.DirectoryNode; | |||
@@ -85,7 +84,7 @@ public class HPSFFileHandler extends POIFSFileHandler { | |||
handlePOIDocument(hpsf); | |||
} | |||
private static boolean hasPropertyStream(POIFSFileSystem poifs, String streamName) throws IOException, MarkUnsupportedException { | |||
private static boolean hasPropertyStream(POIFSFileSystem poifs, String streamName) throws IOException { | |||
DirectoryNode root = poifs.getRoot(); | |||
if (!root.hasEntry(streamName)) { | |||
return false; | |||
@@ -121,7 +120,7 @@ public class HPSFFileHandler extends POIFSFileHandler { | |||
@Test | |||
@SuppressWarnings("java:S2699") | |||
public void test() throws Exception { | |||
String path = "test-data/hpsf/Test0313rur.adm"; | |||
String path = "test-data/diagram/44501.vsd"; | |||
try (InputStream stream = new FileInputStream(path)) { | |||
handleFile(stream, path); | |||
} |
@@ -43,7 +43,7 @@ public class OPCFileHandler extends AbstractFileHandler { | |||
assertEquals(ContentTypes.CORE_PROPERTIES_PART, part.getContentType()); | |||
} | |||
if (part.getPartName().toString().equals("/word/document.xml")) { | |||
assertTrue("Expected one of " + XWPFRelation.MACRO_DOCUMENT + ", " + XWPFRelation.DOCUMENT + ", " + XWPFRelation.TEMPLATE + | |||
assertTrue("Expected one of " + XWPFRelation.MACRO_DOCUMENT + ", " + XWPFRelation.DOCUMENT + ", " + XWPFRelation.TEMPLATE + | |||
", but had " + part.getContentType(), | |||
XWPFRelation.DOCUMENT.getContentType().equals(part.getContentType()) || | |||
XWPFRelation.MACRO_DOCUMENT.getContentType().equals(part.getContentType()) || | |||
@@ -54,9 +54,9 @@ public class OPCFileHandler extends AbstractFileHandler { | |||
} | |||
} | |||
} | |||
@Override | |||
public void handleExtracting(File file) throws Exception { | |||
public void handleExtracting(File file) { | |||
// text-extraction is not possible currently for these types of files | |||
} | |||
@@ -68,7 +68,7 @@ public class OPCFileHandler extends AbstractFileHandler { | |||
try (InputStream stream = new PushbackInputStream(new FileInputStream(file), 100000)) { | |||
handleFile(stream, file.getPath()); | |||
} | |||
handleExtracting(file); | |||
} | |||
} |
@@ -52,9 +52,7 @@ public class XSLFFileHandler extends SlideShowHandler { | |||
// additionally try the other getText() methods | |||
//noinspection rawtypes | |||
try (SlideShowExtractor extractor = (SlideShowExtractor) ExtractorFactory.createExtractor(file)) { | |||
try (SlideShowExtractor<?,?> extractor = (SlideShowExtractor<?, ?>) ExtractorFactory.createExtractor(file)) { | |||
assertNotNull(extractor); | |||
extractor.setSlidesByDefault(true); | |||
extractor.setNotesByDefault(true); | |||
@@ -81,4 +79,4 @@ public class XSLFFileHandler extends SlideShowHandler { | |||
handleExtracting(file); | |||
} | |||
} | |||
} |
@@ -56,17 +56,17 @@ public abstract class POIXMLRelation { | |||
/** | |||
* Describes the content stored in a part. | |||
*/ | |||
private String _type; | |||
private final String _type; | |||
/** | |||
* The kind of connection between a source part and a target part in a package. | |||
*/ | |||
private String _relation; | |||
private final String _relation; | |||
/** | |||
* The path component of a pack URI. | |||
*/ | |||
private String _defaultName; | |||
private final String _defaultName; | |||
/** | |||
* Constructors or factory method to construct instances of this relationship |
@@ -37,7 +37,6 @@ import java.util.List; | |||
import org.apache.poi.POIDataSamples; | |||
import org.apache.poi.ooxml.POIXMLDocumentPart.RelationPart; | |||
import org.apache.poi.ooxml.util.PackageHelper; | |||
import org.apache.poi.openxml4j.exceptions.InvalidFormatException; | |||
import org.apache.poi.openxml4j.exceptions.OpenXML4JRuntimeException; | |||
import org.apache.poi.openxml4j.opc.OPCPackage; | |||
import org.apache.poi.openxml4j.opc.PackagePart; | |||
@@ -87,7 +86,7 @@ public final class TestPOIXMLDocument { | |||
} | |||
} | |||
private static void traverse(POIXMLDocument doc) throws IOException{ | |||
private static void traverse(POIXMLDocument doc) { | |||
HashMap<String,POIXMLDocumentPart> context = new HashMap<>(); | |||
for (RelationPart p : doc.getRelationParts()){ | |||
traverse(p, context); | |||
@@ -97,7 +96,7 @@ public final class TestPOIXMLDocument { | |||
/** | |||
* Recursively traverse a OOXML document and assert that same logical parts have the same physical instances | |||
*/ | |||
private static void traverse(RelationPart rp, HashMap<String,POIXMLDocumentPart> context) throws IOException{ | |||
private static void traverse(RelationPart rp, HashMap<String,POIXMLDocumentPart> context) { | |||
POIXMLDocumentPart dp = rp.getDocumentPart(); | |||
assertEquals(rp.getRelationship().getTargetURI().toString(), dp.getPackagePart().getPartName().getName()); | |||
@@ -255,7 +254,7 @@ public final class TestPOIXMLDocument { | |||
} | |||
@Test | |||
public void testCommitNullPart() throws IOException, InvalidFormatException { | |||
public void testCommitNullPart() throws IOException { | |||
POIXMLDocumentPart part = new POIXMLDocumentPart(); | |||
part.prepareForCommit(); | |||
part.commit(); | |||
@@ -311,6 +310,7 @@ public final class TestPOIXMLDocument { | |||
try (InputStream is = pds.openResourceAsStream("bug62513.pptx"); | |||
XMLSlideShow ppt = new XMLSlideShow(is)) { | |||
POIXMLDocumentPart doc = ppt.getSlides().get(12).getRelationById("rId3"); | |||
assertNotNull(doc); | |||
assertEquals(POIXMLDocumentPart.class, doc.getClass()); | |||
} | |||
} | |||
@@ -320,19 +320,17 @@ public final class TestPOIXMLDocument { | |||
// the schema type loader is cached per thread in POIXMLTypeLoader. | |||
// So create a new Thread and change the context class loader (which would normally be used) | |||
// to not contain the OOXML classes | |||
Runnable run = new Runnable() { | |||
public void run() { | |||
InputStream is = POIDataSamples.getSlideShowInstance().openResourceAsStream("table_test.pptx"); | |||
XMLSlideShow ppt = null; | |||
try { | |||
ppt = new XMLSlideShow(is); | |||
ppt.getSlides().get(0).getShapes(); | |||
} catch (IOException e) { | |||
fail("failed to load XMLSlideShow"); | |||
} finally { | |||
IOUtils.closeQuietly(ppt); | |||
IOUtils.closeQuietly(is); | |||
} | |||
Runnable run = () -> { | |||
InputStream is = POIDataSamples.getSlideShowInstance().openResourceAsStream("table_test.pptx"); | |||
XMLSlideShow ppt = null; | |||
try { | |||
ppt = new XMLSlideShow(is); | |||
ppt.getSlides().get(0).getShapes(); | |||
} catch (IOException e) { | |||
fail("failed to load XMLSlideShow"); | |||
} finally { | |||
IOUtils.closeQuietly(ppt); | |||
IOUtils.closeQuietly(is); | |||
} | |||
}; | |||
@@ -348,15 +346,15 @@ public final class TestPOIXMLDocument { | |||
ta[i].setUncaughtExceptionHandler(uh); | |||
ta[i].start(); | |||
} | |||
for (int i=0; i<ta.length; i++) { | |||
for (Thread thread : ta) { | |||
try { | |||
ta[i].join(); | |||
thread.join(); | |||
} catch (InterruptedException e) { | |||
fail("failed to join thread"); | |||
} | |||
} | |||
} | |||
assertFalse(uh.hasException()); | |||
assertFalse("Should not have an exception now, but had " + uh.e, uh.hasException()); | |||
} | |||
private static class UncaughtHandler implements UncaughtExceptionHandler { |