From 103116bff997aff718c7e7b73e173d38af0f672b Mon Sep 17 00:00:00 2001 From: Javen O'Neal Date: Sun, 10 Jul 2016 01:29:30 +0000 Subject: [PATCH] move string literals out to array that can be for-looped over git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1752053 13f79535-47bb-0310-9956-ffa450edef68 --- .../poi/extractor/ExtractorFactory.java | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/ooxml/java/org/apache/poi/extractor/ExtractorFactory.java b/src/ooxml/java/org/apache/poi/extractor/ExtractorFactory.java index a57b57a7c1..ce9c819fae 100644 --- a/src/ooxml/java/org/apache/poi/extractor/ExtractorFactory.java +++ b/src/ooxml/java/org/apache/poi/extractor/ExtractorFactory.java @@ -327,19 +327,24 @@ public class ExtractorFactory { return new PublisherTextExtractor(poifsDir); } - if (poifsDir.hasEntry("__substg1.0_1000001E") || poifsDir.hasEntry("__substg1.0_1000001F") - || poifsDir.hasEntry("__substg1.0_0047001E") - || poifsDir.hasEntry("__substg1.0_0047001F") - || poifsDir.hasEntry("__substg1.0_0037001E") - || poifsDir.hasEntry("__substg1.0_0037001F")) - { - return new OutlookTextExtactor(poifsDir); + final String[] outlookEntryNames = new String[] { + // message bodies, saved as plain text (PtypString) + // https://msdn.microsoft.com/en-us/library/cc433490(v=exchg.80).aspx + "__substg1.0_1000001E", //PidTagBody + "__substg1.0_1000001F", //PidTagBody + "__substg1.0_0047001E", //PidTagMessageSubmissionId + "__substg1.0_0047001F", //PidTagMessageSubmissionId + "__substg1.0_0037001E", //PidTagSubject + "__substg1.0_0037001F", //PidTagSubject + }; + for (String entryName : outlookEntryNames) { + if (poifsDir.hasEntry(entryName)) { + return new OutlookTextExtactor(poifsDir); + } } - for (Iterator entries = poifsDir.getEntries(); entries.hasNext();) { - Entry entry = entries.next(); - - if (entry.getName().equals("Package")) { + for (String entryName : poifsDir.getEntryNames()) { + if (entryName.equals("Package")) { OPCPackage pkg = OPCPackage.open(poifsDir.createDocumentInputStream("Package")); return createExtractor(pkg); } -- 2.39.5