52863 - add workaround for files with broken CHP SPRMs

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1405861 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Sergey Vladimirov 2012-11-05 16:06:36 +00:00
parent 2f9f29380a
commit 110ef33b6e
2 changed files with 26 additions and 3 deletions

View File

@ -34,6 +34,7 @@
<changes> <changes>
<release version="3.9-beta1" date="2012-??-??"> <release version="3.9-beta1" date="2012-??-??">
<action dev="poi-developers" type="add">52863 - add workaround for files with broken CHP SPRMs</action>
<action dev="poi-developers" type="fix">53182 - Reading combined character styling and direct formatting of a character run</action> <action dev="poi-developers" type="fix">53182 - Reading combined character styling and direct formatting of a character run</action>
<action dev="poi-developers" type="fix">52311 - Conversion to html : Problem in titles number </action> <action dev="poi-developers" type="fix">52311 - Conversion to html : Problem in titles number </action>
<action dev="poi-developers" type="fix">53914 - TableRow#getTopBorder() return bottom's border</action> <action dev="poi-developers" type="fix">53914 - TableRow#getTopBorder() return bottom's border</action>

View File

@ -70,15 +70,31 @@ public final class CharacterSprmUncompressor extends SprmUncompressor
*/ */
Integer style = getIstd( grpprl, offset ); Integer style = getIstd( grpprl, offset );
if ( style != null ) if ( style != null )
{
try
{ {
applySprms( parStyle, styleSheet.getCHPX( style ), 0, false, applySprms( parStyle, styleSheet.getCHPX( style ), 0, false,
newProperties ); newProperties );
} }
catch ( Exception exc )
{
logger.log( POILogger.ERROR, "Unable to apply all style ",
style, " CHP SPRMs to CHP: ", exc, exc );
}
}
CharacterProperties styleProperties = newProperties; CharacterProperties styleProperties = newProperties;
newProperties = styleProperties.clone(); newProperties = styleProperties.clone();
try
{
applySprms( styleProperties, grpprl, offset, true, newProperties ); applySprms( styleProperties, grpprl, offset, true, newProperties );
}
catch ( Exception exc )
{
logger.log( POILogger.ERROR,
"Unable to process all direct CHP SPRMs: ", exc, exc );
}
return newProperties; return newProperties;
} }
@ -109,6 +125,7 @@ public final class CharacterSprmUncompressor extends SprmUncompressor
private static Integer getIstd( byte[] grpprl, int offset ) private static Integer getIstd( byte[] grpprl, int offset )
{ {
Integer style = null; Integer style = null;
try
{ {
SprmIterator sprmIt = new SprmIterator( grpprl, offset ); SprmIterator sprmIt = new SprmIterator( grpprl, offset );
while ( sprmIt.hasNext() ) while ( sprmIt.hasNext() )
@ -122,6 +139,11 @@ public final class CharacterSprmUncompressor extends SprmUncompressor
} }
} }
} }
catch ( Exception exc )
{
logger.log( POILogger.ERROR,
"Unable to extract istd from direct CHP SPRM: ", exc, exc );
}
return style; return style;
} }