poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ser...@apache.org
Subject svn commit: r1145275 - /poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/CHPFormattedDiskPage.java
Date Mon, 11 Jul 2011 18:34:27 GMT
Author: sergey
Date: Mon Jul 11 18:34:26 2011
New Revision: 1145275

URL: http://svn.apache.org/viewvc?rev=1145275&view=rev
Log:
ignore CHPX references zero-length text pieces

Modified:
    poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/CHPFormattedDiskPage.java

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/CHPFormattedDiskPage.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/CHPFormattedDiskPage.java?rev=1145275&r1=1145274&r2=1145275&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/CHPFormattedDiskPage.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/CHPFormattedDiskPage.java Mon Jul
11 18:34:26 2011
@@ -74,31 +74,42 @@ public final class CHPFormattedDiskPage 
      * This constructs a CHPFormattedDiskPage from a raw fkp (512 byte array
      * read from a Word file).
      */
-    public CHPFormattedDiskPage( byte[] documentStream, int offset, TextPieceTable tpt,
-            boolean ignoreChpxWithoutTextPieces )
+    public CHPFormattedDiskPage( byte[] documentStream, int offset,
+            TextPieceTable tpt, boolean ignoreChpxWithoutTextPieces )
     {
-      super(documentStream, offset);
+        super( documentStream, offset );
 
-      for (int x = 0; x < _crun; x++)
-      {
-    	int startAt = getStart(x);
-		int endAt = getEnd(x);
-
-        if (!ignoreChpxWithoutTextPieces || tpt.isIndexInTable( startAt, endAt ) )
-        {
-		    _chpxList.add(new CHPX(startAt, endAt, tpt, getGrpprl(x)));
-        }
-        else
+        for ( int x = 0; x < _crun; x++ )
         {
-            logger.log( POILogger.WARN, "CHPX [",
-                    Integer.valueOf( startAt ), "; ",
-                    Integer.valueOf( endAt ),
-                    ") (bytes) doesn't have corresponding text pieces "
-                            + "and will be skipped" );
+            int startAt = getStart( x );
+            int endAt = getEnd( x );
+
+            if ( ignoreChpxWithoutTextPieces
+                    && !tpt.isIndexInTable( startAt, endAt ) )
+            {
+                logger.log( POILogger.WARN, "CHPX [",
+                        Integer.valueOf( startAt ), "; ",
+                        Integer.valueOf( endAt ),
+                        ") (bytes) doesn't have corresponding text pieces "
+                                + "and will be skipped" );
+
+                _chpxList.add( null );
+                continue;
+            }
+
+            CHPX chpx = new CHPX( startAt, endAt, tpt, getGrpprl( x ) );
+
+            if ( ignoreChpxWithoutTextPieces
+                    && chpx.getStart() == chpx.getEnd() )
+            {
+                logger.log( POILogger.WARN, chpx
+                        + " references zero-length range and will be skipped" );
+                _chpxList.add( null );
+                continue;
+            }
 
-            _chpxList.add(null);
+            _chpxList.add( chpx );
         }
-      }
     }
 
     public CHPX getCHPX(int index)



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message