From a0b324224b9f756a6c2b9c61e0c66a7dd96f9ea7 Mon Sep 17 00:00:00 2001 From: Andreas Beeker Date: Tue, 2 May 2017 23:30:17 +0000 Subject: [PATCH] Reverted DocumentSummary hack in codepage guessing code git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1793601 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/poi/hwpf/HWPFOldDocument.java | 31 +------------------ 1 file changed, 1 insertion(+), 30 deletions(-) diff --git a/src/scratchpad/src/org/apache/poi/hwpf/HWPFOldDocument.java b/src/scratchpad/src/org/apache/poi/hwpf/HWPFOldDocument.java index cfc010206..063d8b7b0 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/HWPFOldDocument.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/HWPFOldDocument.java @@ -198,36 +198,7 @@ public class HWPFOldDocument extends HWPFDocumentCore { * @return The detected Charset from the old font table */ private Charset guessCodePage(OldFontTable fontTable) { - //try to get it out of the overall document summary information - DocumentSummaryInformation summaryInformation = getDocumentSummaryInformation(); - if (summaryInformation != null) { - CustomProperties customProperties = summaryInformation.getCustomProperties(); - if (customProperties != null) { - int codePage = customProperties.getCodepage(); - if (codePage > -1) { - try { - return Charset.forName(CodePageUtil.codepageToEncoding(codePage)); - } catch (UnsupportedEncodingException e) { - //swallow - } - } - } - //If that didn't work, for now, try to get first valid code page in a valid section - for (Section section : summaryInformation.getSections()) { - if (section.getOffset() < 0) { - continue; - } - int codePage = section.getCodepage(); - if (codePage > -1) { - try { - return Charset.forName(CodePageUtil.codepageToEncoding(codePage)); - } catch (UnsupportedEncodingException e) { - //swallow - } - } - } - } - //if that still doesn't work, pick the first non-default, non-symbol charset + // pick the first non-default, non-symbol charset for (OldFfn oldFfn : fontTable.getFontNames()) { HwmfFont.WmfCharset wmfCharset = HwmfFont.WmfCharset.valueOf(oldFfn.getChs()& 0xff); if (wmfCharset != null &&