diff --git a/src/documentation/content/xdocs/status.xml b/src/documentation/content/xdocs/status.xml index 4a76471ae..ad3b0f62b 100644 --- a/src/documentation/content/xdocs/status.xml +++ b/src/documentation/content/xdocs/status.xml @@ -34,6 +34,7 @@ + 52863 - add workaround for files with broken CHP SPRMs 53182 - Reading combined character styling and direct formatting of a character run 52311 - Conversion to html : Problem in titles number 53914 - TableRow#getTopBorder() return bottom's border diff --git a/src/scratchpad/src/org/apache/poi/hwpf/sprm/CharacterSprmUncompressor.java b/src/scratchpad/src/org/apache/poi/hwpf/sprm/CharacterSprmUncompressor.java index c1b718709..6bb3785f4 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/sprm/CharacterSprmUncompressor.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/sprm/CharacterSprmUncompressor.java @@ -71,14 +71,30 @@ public final class CharacterSprmUncompressor extends SprmUncompressor Integer style = getIstd( grpprl, offset ); if ( style != null ) { - applySprms( parStyle, styleSheet.getCHPX( style ), 0, false, - newProperties ); + try + { + applySprms( parStyle, styleSheet.getCHPX( style ), 0, false, + newProperties ); + } + catch ( Exception exc ) + { + logger.log( POILogger.ERROR, "Unable to apply all style ", + style, " CHP SPRMs to CHP: ", exc, exc ); + } } CharacterProperties styleProperties = newProperties; newProperties = styleProperties.clone(); - applySprms( styleProperties, grpprl, offset, true, newProperties ); + try + { + applySprms( styleProperties, grpprl, offset, true, newProperties ); + } + catch ( Exception exc ) + { + logger.log( POILogger.ERROR, + "Unable to process all direct CHP SPRMs: ", exc, exc ); + } return newProperties; } @@ -109,6 +125,7 @@ public final class CharacterSprmUncompressor extends SprmUncompressor private static Integer getIstd( byte[] grpprl, int offset ) { Integer style = null; + try { SprmIterator sprmIt = new SprmIterator( grpprl, offset ); 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; }