temporary(?) workaround for Bug 49933 - Word 6/95 documents with sections cause ArrayIndexOutOfBoundsException
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1144683 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
530a209d01
commit
f23c8a021a
@ -19,24 +19,33 @@ package org.apache.poi.hwpf.model;
|
|||||||
|
|
||||||
import org.apache.poi.hwpf.sprm.SectionSprmCompressor;
|
import org.apache.poi.hwpf.sprm.SectionSprmCompressor;
|
||||||
import org.apache.poi.hwpf.sprm.SectionSprmUncompressor;
|
import org.apache.poi.hwpf.sprm.SectionSprmUncompressor;
|
||||||
|
import org.apache.poi.hwpf.sprm.SprmBuffer;
|
||||||
import org.apache.poi.hwpf.usermodel.SectionProperties;
|
import org.apache.poi.hwpf.usermodel.SectionProperties;
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public final class SEPX extends BytePropertyNode<SEPX>
|
public final class SEPX extends BytePropertyNode<SEPX>
|
||||||
{
|
{
|
||||||
|
|
||||||
|
SectionProperties sectionProperties;
|
||||||
|
|
||||||
SectionDescriptor _sed;
|
SectionDescriptor _sed;
|
||||||
|
|
||||||
public SEPX(SectionDescriptor sed, int start, int end, CharIndexTranslator translator, byte[] grpprl)
|
public SEPX( SectionDescriptor sed, int start, int end,
|
||||||
|
CharIndexTranslator translator, byte[] grpprl )
|
||||||
{
|
{
|
||||||
super(start, end, translator, SectionSprmUncompressor.uncompressSEP(grpprl, 0));
|
super( start, end, translator, new SprmBuffer( grpprl ) );
|
||||||
_sed = sed;
|
_sed = sed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] getGrpprl()
|
public byte[] getGrpprl()
|
||||||
{
|
{
|
||||||
return SectionSprmCompressor.compressSectionProperty((SectionProperties)_buf);
|
if ( sectionProperties != null )
|
||||||
|
{
|
||||||
|
byte[] grpprl = SectionSprmCompressor
|
||||||
|
.compressSectionProperty( sectionProperties );
|
||||||
|
_buf = new SprmBuffer( grpprl );
|
||||||
|
}
|
||||||
|
|
||||||
|
return ( (SprmBuffer) _buf ).toByteArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
public SectionDescriptor getSectionDescriptor()
|
public SectionDescriptor getSectionDescriptor()
|
||||||
@ -46,15 +55,20 @@ public final class SEPX extends BytePropertyNode<SEPX>
|
|||||||
|
|
||||||
public SectionProperties getSectionProperties()
|
public SectionProperties getSectionProperties()
|
||||||
{
|
{
|
||||||
return (SectionProperties)_buf;
|
if ( sectionProperties == null )
|
||||||
|
{
|
||||||
|
sectionProperties = SectionSprmUncompressor.uncompressSEP(
|
||||||
|
( (SprmBuffer) _buf ).toByteArray(), 0 );
|
||||||
|
}
|
||||||
|
return sectionProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean equals(Object o)
|
public boolean equals( Object o )
|
||||||
{
|
{
|
||||||
SEPX sepx = (SEPX)o;
|
SEPX sepx = (SEPX) o;
|
||||||
if (super.equals(o))
|
if ( super.equals( o ) )
|
||||||
{
|
{
|
||||||
return sepx._sed.equals(_sed);
|
return sepx._sed.equals( _sed );
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -793,6 +793,11 @@ public final class TestProblems extends HWPFTestCase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void test49933()
|
||||||
|
{
|
||||||
|
HWPFTestDataSamples.openOldSampleFile( "Bug49933.doc" );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bug 50936 - HWPF fails to read a file
|
* Bug 50936 - HWPF fails to read a file
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user