From e32761be3b7d512d75b1e339795201898f73b63d Mon Sep 17 00:00:00 2001 From: Sergey Vladimirov Date: Sat, 9 Jul 2011 16:04:46 +0000 Subject: [PATCH] Same workaround for CHPX / SEPX, as for PAPX. Disable SPRM processing for Word95 files. git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1144689 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/org/apache/poi/hwpf/model/CHPX.java | 24 ++++++++++--------- .../apache/poi/hwpf/usermodel/Section.java | 17 +++++++++---- 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/src/scratchpad/src/org/apache/poi/hwpf/model/CHPX.java b/src/scratchpad/src/org/apache/poi/hwpf/model/CHPX.java index 7aebf89f02..b0f14ad375 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/model/CHPX.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/model/CHPX.java @@ -55,18 +55,20 @@ public final class CHPX extends BytePropertyNode return (SprmBuffer)_buf; } - public CharacterProperties getCharacterProperties(StyleSheet ss, short istd) - { - CharacterProperties baseStyle; - if (ss == null) { - //old document format - baseStyle = new CharacterProperties(); - } else { - baseStyle = ss.getCharacterStyle(istd); + public CharacterProperties getCharacterProperties( StyleSheet ss, short istd ) + { + if ( ss == null ) + { + // TODO Fix up for Word 6/95 + return new CharacterProperties(); + } + + CharacterProperties baseStyle = ss.getCharacterStyle( istd ); + CharacterProperties props = CharacterSprmUncompressor.uncompressCHP( + baseStyle, getGrpprl(), 0 ); + ; + return props; } - CharacterProperties props = CharacterSprmUncompressor.uncompressCHP(baseStyle, getGrpprl(), 0); - return props; - } public String toString() { return "CHPX from " + getStart() + " to " + getEnd() + diff --git a/src/scratchpad/src/org/apache/poi/hwpf/usermodel/Section.java b/src/scratchpad/src/org/apache/poi/hwpf/usermodel/Section.java index 3e314f1f19..8ce3787a18 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/usermodel/Section.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/usermodel/Section.java @@ -17,6 +17,7 @@ package org.apache.poi.hwpf.usermodel; +import org.apache.poi.hwpf.HWPFOldDocument; import org.apache.poi.hwpf.model.SEPX; public final class Section @@ -25,11 +26,17 @@ public final class Section private SectionProperties _props; - public Section(SEPX sepx, Range parent) - { - super(Math.max(parent._start, sepx.getStart()), Math.min(parent._end, sepx.getEnd()), parent); - _props = sepx.getSectionProperties(); - } + public Section( SEPX sepx, Range parent ) + { + super( Math.max( parent._start, sepx.getStart() ), Math.min( + parent._end, sepx.getEnd() ), parent ); + + // XXX: temporary workaround for old Word95 document + if ( parent.getDocument() instanceof HWPFOldDocument ) + _props = new SectionProperties(); + else + _props = sepx.getSectionProperties(); + } public int type() { -- 2.39.5