poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ser...@apache.org
Subject svn commit: r1144691 - in /poi/trunk/src/scratchpad: src/org/apache/poi/hwpf/ src/org/apache/poi/hwpf/model/ testcases/org/apache/poi/hwpf/model/
Date Sat, 09 Jul 2011 16:10:57 GMT
Author: sergey
Date: Sat Jul  9 16:10:57 2011
New Revision: 1144691

URL: http://svn.apache.org/viewvc?rev=1144691&view=rev
Log:
shortcut for test case to allow loading bad structure of CHP

Modified:
    poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/HWPFDocument.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/CHPBinTable.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/CHPFormattedDiskPage.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/OldCHPBinTable.java
    poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestCHPBinTable.java

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/HWPFDocument.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/HWPFDocument.java?rev=1144691&r1=1144690&r2=1144691&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/HWPFDocument.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/HWPFDocument.java Sat Jul  9 16:10:57
2011
@@ -222,7 +222,7 @@ public final class HWPFDocument extends 
 
     // Now load the rest of the properties, which need to be adjusted
     //  for where text really begin
-    _cbt = new CHPBinTable(_mainStream, _tableStream, _fib.getFcPlcfbteChpx(), _fib.getLcbPlcfbteChpx(),
cpMin, _tpt);
+    _cbt = new CHPBinTable(_mainStream, _tableStream, _fib.getFcPlcfbteChpx(), _fib.getLcbPlcfbteChpx(),
cpMin, _tpt, true);
     _pbt = new PAPBinTable(_mainStream, _tableStream, _dataStream, _fib.getFcPlcfbtePapx(),
_fib.getLcbPlcfbtePapx(), cpMin, _tpt, true);
 
     // Read FSPA and Escher information

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/CHPBinTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/CHPBinTable.java?rev=1144691&r1=1144690&r2=1144691&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/CHPBinTable.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/CHPBinTable.java Sat Jul  9 16:10:57
2011
@@ -47,18 +47,26 @@ public class CHPBinTable
   {
   }
 
-  /**
-   * Constructor used to read a binTable in from a Word document.
-   *
-   * @param documentStream
-   * @param tableStream
-   * @param offset
-   * @param size
-   * @param fcMin
-   */
+    /**
+     * Constructor used to read a binTable in from a Word document.
+     * 
+     * @deprecated Use
+     *             {@link #CHPBinTable(byte[],byte[],int,int,int,TextPieceTable,boolean)}
+     *             instead
+     */
     public CHPBinTable( byte[] documentStream, byte[] tableStream, int offset,
             int size, int fcMin, TextPieceTable tpt )
     {
+        this( documentStream, tableStream, offset, size, fcMin, tpt, true );
+    }
+
+    /**
+     * Constructor used to read a binTable in from a Word document.
+     */
+    public CHPBinTable( byte[] documentStream, byte[] tableStream, int offset,
+            int size, int fcMin, TextPieceTable tpt,
+            boolean ignoreChpxWithoutTextPieces )
+    {
         /*
          * Page 35:
          * 
@@ -79,7 +87,7 @@ public class CHPBinTable
       int pageOffset = POIFSConstants.SMALLER_BIG_BLOCK_SIZE * pageNum;
 
       CHPFormattedDiskPage cfkp = new CHPFormattedDiskPage(documentStream,
-        pageOffset, fcMin, tpt);
+        pageOffset, fcMin, tpt, ignoreChpxWithoutTextPieces);
 
       int fkpSize = cfkp.size();
 

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=1144691&r1=1144690&r2=1144691&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 Sat Jul
 9 16:10:57 2011
@@ -53,8 +53,26 @@ public final class CHPFormattedDiskPage 
     /**
      * This constructs a CHPFormattedDiskPage from a raw fkp (512 byte array
      * read from a Word file).
+     * 
+     * @deprecated Use
+     *             {@link #CHPFormattedDiskPage(byte[],int,int,TextPieceTable,boolean)}
+     *             instead
      */
-    public CHPFormattedDiskPage(byte[] documentStream, int offset, int fcMin, TextPieceTable
tpt)
+    public CHPFormattedDiskPage( byte[] documentStream, int offset, int fcMin,
+            TextPieceTable tpt )
+    {
+        this( documentStream, offset, fcMin, tpt, true );
+    }
+
+    /**
+     * This constructs a CHPFormattedDiskPage from a raw fkp (512 byte array
+     * read from a Word file).
+     * 
+     * @param ignoreChpxWithoutTextPieces
+     *            TODO
+     */
+    public CHPFormattedDiskPage( byte[] documentStream, int offset, int fcMin,
+            TextPieceTable tpt, boolean ignoreChpxWithoutTextPieces )
     {
       super(documentStream, offset);
 
@@ -63,7 +81,7 @@ public final class CHPFormattedDiskPage 
     	int startAt = getStart(x);
 		int endAt = getEnd(x);
 
-        if ( !tpt.isIndexInTable( startAt, endAt ) ) {
+        if (ignoreChpxWithoutTextPieces && !tpt.isIndexInTable( startAt, endAt )
) {
             _chpxList.add(null);
         } else {
 		    _chpxList.add(new CHPX(startAt, endAt, tpt, getGrpprl(x)));

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/OldCHPBinTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/OldCHPBinTable.java?rev=1144691&r1=1144690&r2=1144691&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/OldCHPBinTable.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/OldCHPBinTable.java Sat Jul  9
16:10:57 2011
@@ -55,7 +55,7 @@ public final class OldCHPBinTable extend
       int pageOffset = POIFSConstants.SMALLER_BIG_BLOCK_SIZE * pageNum;
 
       CHPFormattedDiskPage cfkp = new CHPFormattedDiskPage(documentStream,
-        pageOffset, fcMin, tpt);
+        pageOffset, fcMin, tpt, true);
 
       int fkpSize = cfkp.size();
 

Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestCHPBinTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestCHPBinTable.java?rev=1144691&r1=1144690&r2=1144691&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestCHPBinTable.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestCHPBinTable.java Sat
Jul  9 16:10:57 2011
@@ -20,10 +20,10 @@ package org.apache.poi.hwpf.model;
 import java.io.ByteArrayOutputStream;
 import java.util.ArrayList;
 
-import junit.framework.*;
+import junit.framework.TestCase;
 
-import org.apache.poi.hwpf.*;
-import org.apache.poi.hwpf.model.io.*;
+import org.apache.poi.hwpf.HWPFDocFixture;
+import org.apache.poi.hwpf.model.io.HWPFFileSystem;
 
 public final class TestCHPBinTable
   extends TestCase
@@ -46,7 +46,7 @@ public final class TestCHPBinTable
     byte[] tableStream = _hWPFDocFixture._tableStream;
     int fcMin = fib.getFcMin();
 
-    _cHPBinTable = new CHPBinTable(mainStream, tableStream, fib.getFcPlcfbteChpx(), fib.getLcbPlcfbteChpx(),
fcMin, fakeTPT);
+    _cHPBinTable = new CHPBinTable(mainStream, tableStream, fib.getFcPlcfbteChpx(), fib.getLcbPlcfbteChpx(),
fcMin, fakeTPT, false);
 
     HWPFFileSystem fileSys = new HWPFFileSystem();
 
@@ -57,7 +57,7 @@ public final class TestCHPBinTable
     byte[] newTableStream = tableOut.toByteArray();
     byte[] newMainStream = mainOut.toByteArray();
 
-    CHPBinTable newBinTable = new CHPBinTable(newMainStream, newTableStream, 0, newTableStream.length,
0, fakeTPT);
+    CHPBinTable newBinTable = new CHPBinTable(newMainStream, newTableStream, 0, newTableStream.length,
0, fakeTPT, false);
 
     ArrayList oldTextRuns = _cHPBinTable._textRuns;
     ArrayList newTextRuns = newBinTable._textRuns;



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


Mime
View raw message