diff options
Diffstat (limited to 'src/ooxml/java/org')
5 files changed, 47 insertions, 46 deletions
diff --git a/src/ooxml/java/org/apache/poi/ooxml/POIXMLDocumentPart.java b/src/ooxml/java/org/apache/poi/ooxml/POIXMLDocumentPart.java index 54fa790eca..c8e1a277a4 100644 --- a/src/ooxml/java/org/apache/poi/ooxml/POIXMLDocumentPart.java +++ b/src/ooxml/java/org/apache/poi/ooxml/POIXMLDocumentPart.java @@ -615,7 +615,7 @@ public class POIXMLDocumentPart { protected void read(POIXMLFactory factory, Map<PackagePart, POIXMLDocumentPart> context) throws OpenXML4JException { PackagePart pp = getPackagePart(); - if (pp.getContentType().equals(XWPFRelation.TEMPLATE.getContentType())) { + if (pp.getContentType().equals(XWPFRelation.GLOSSARY_DOCUMENT.getContentType())) { logger.log(POILogger.WARN, "POI does not currently support template.main+xml (glossary) parts. " + "Skipping this part for now."); diff --git a/src/ooxml/java/org/apache/poi/ooxml/extractor/CommandLineTextExtractor.java b/src/ooxml/java/org/apache/poi/ooxml/extractor/CommandLineTextExtractor.java index 999abd46ee..c3d429b3c7 100644 --- a/src/ooxml/java/org/apache/poi/ooxml/extractor/CommandLineTextExtractor.java +++ b/src/ooxml/java/org/apache/poi/ooxml/extractor/CommandLineTextExtractor.java @@ -22,41 +22,37 @@ import org.apache.poi.extractor.POITextExtractor; /** * A command line wrapper around {@link ExtractorFactory}, useful - * for when debugging. + * for when debugging. */ public class CommandLineTextExtractor { - public static final String DIVIDER = "======================="; - - public static void main(String[] args) throws Exception { - if(args.length < 1) { - System.err.println("Use:"); - System.err.println(" CommandLineTextExtractor <filename> [filename] [filename]"); - System.exit(1); - } - - for (String arg : args) { - System.out.println(DIVIDER); - - File f = new File(arg); - System.out.println(f); - - POITextExtractor extractor = - ExtractorFactory.createExtractor(f); - try { - POITextExtractor metadataExtractor = - extractor.getMetadataTextExtractor(); - - System.out.println(" " + DIVIDER); - String metaData = metadataExtractor.getText(); - System.out.println(metaData); - System.out.println(" " + DIVIDER); - String text = extractor.getText(); - System.out.println(text); - System.out.println(DIVIDER); - System.out.println("Had " + metaData.length() + " characters of metadata and " + text.length() + " characters of text"); - } finally { - extractor.close(); - } - } - } + public static final String DIVIDER = "======================="; + + public static void main(String[] args) throws Exception { + if (args.length < 1) { + System.err.println("Use:"); + System.err.println(" CommandLineTextExtractor <filename> [filename] [filename]"); + System.exit(1); + } + + for (String arg : args) { + System.out.println(DIVIDER); + + File f = new File(arg); + System.out.println(f); + + try (POITextExtractor extractor = ExtractorFactory.createExtractor(f)) { + POITextExtractor metadataExtractor = + extractor.getMetadataTextExtractor(); + + System.out.println(" " + DIVIDER); + String metaData = metadataExtractor.getText(); + System.out.println(metaData); + System.out.println(" " + DIVIDER); + String text = extractor.getText(); + System.out.println(text); + System.out.println(DIVIDER); + System.out.println("Had " + metaData.length() + " characters of metadata and " + text.length() + " characters of text"); + } + } + } } diff --git a/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/ZipHelper.java b/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/ZipHelper.java index 094e89c6d7..0169909c9b 100644 --- a/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/ZipHelper.java +++ b/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/ZipHelper.java @@ -154,8 +154,6 @@ public final class ZipHelper { "The supplied data appears to be a raw XML file. " + "Formats such as Office 2003 XML are not supported"); default: - case OOXML: - case UNKNOWN: // Don't check for a Zip header, as to maintain backwards // compatibility we need to let them seek over junk at the // start before beginning processing. diff --git a/src/ooxml/java/org/apache/poi/openxml4j/util/ZipInputStreamZipEntrySource.java b/src/ooxml/java/org/apache/poi/openxml4j/util/ZipInputStreamZipEntrySource.java index e185239ff1..0a56966d4f 100644 --- a/src/ooxml/java/org/apache/poi/openxml4j/util/ZipInputStreamZipEntrySource.java +++ b/src/ooxml/java/org/apache/poi/openxml4j/util/ZipInputStreamZipEntrySource.java @@ -38,7 +38,7 @@ public class ZipInputStreamZipEntrySource implements ZipEntrySource { /** * Reads all the entries from the ZipInputStream - * into memory, and closes the source stream. + * into memory, and don't close (since POI 4.0.1) the source stream. * We'll then eat lots of memory, but be able to * work with the entries at-will. */ @@ -50,7 +50,6 @@ public class ZipInputStreamZipEntrySource implements ZipEntrySource { } zipEntries.put(zipEntry.getName(), new ZipArchiveFakeEntry(zipEntry, inp)); } - inp.close(); } @Override diff --git a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureShape.java b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureShape.java index 97b4ab8cb0..9f07b18bac 100644 --- a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureShape.java +++ b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureShape.java @@ -170,16 +170,24 @@ public class XSLFPictureShape extends XSLFSimpleShape @SuppressWarnings("WeakerAccess") protected String getBlipLink(){ - String link = getBlip().getLink(); - if (link.isEmpty()) return null; - return link; + CTBlip blip = getBlip(); + if (blip != null) { + String link = blip.getLink(); + return (link.isEmpty()) ? null : link; + } else { + return null; + } } @SuppressWarnings("WeakerAccess") protected String getBlipId(){ - String id = getBlip().getEmbed(); - if (id.isEmpty()) return null; - return id; + CTBlip blip = getBlip(); + if (blip != null) { + String id = blip.getEmbed(); + return (id.isEmpty()) ? null : id; + } else { + return null; + } } @Override |