You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by se...@apache.org on 2012/09/23 14:57:40 UTC

svn commit: r1389039 - in /poi/trunk/src/scratchpad: src/org/apache/poi/hwpf/ src/org/apache/poi/hwpf/sprm/ testcases/org/apache/poi/hwpf/converter/

Author: sergey
Date: Sun Sep 23 12:57:39 2012
New Revision: 1389039

URL: http://svn.apache.org/viewvc?rev=1389039&view=rev
Log:
refactor list format override structures (was marked with @Internal annotation)

Modified:
    poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/HWPFDocument.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/sprm/ParagraphSprmUncompressor.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/sprm/SprmOperation.java
    poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/converter/TestWordToTextConverter.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=1389039&r1=1389038&r2=1389039&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 Sun Sep 23 12:57:39 2012
@@ -346,12 +346,13 @@ public final class HWPFDocument extends 
     _ss = new StyleSheet(_tableStream, _fib.getFcStshf());
     _ft = new FontTable(_tableStream, _fib.getFcSttbfffn(), _fib.getLcbSttbfffn());
 
-    int listOffset = _fib.getFcPlcfLst();
-    int lfoOffset = _fib.getFcPlfLfo();
-    if (listOffset != 0 && _fib.getLcbPlcfLst() != 0)
-    {
-      _lt = new ListTables(_tableStream, _fib.getFcPlcfLst(), _fib.getFcPlfLfo());
-    }
+        int listOffset = _fib.getFcPlfLst();
+        int lfoOffset = _fib.getFcPlfLfo();
+        if ( listOffset != 0 && _fib.getLcbPlfLst() != 0 )
+        {
+            _lt = new ListTables( _tableStream, listOffset, _fib.getFcPlfLfo(),
+                    _fib.getLcbPlfLfo() );
+        }
 
     int sbtOffset = _fib.getFcSttbSavedBy();
     int sbtLength = _fib.getLcbSttbSavedBy();
@@ -830,9 +831,7 @@ public final class HWPFDocument extends 
              * Microsoft Office Word 97-2007 Binary File Format (.doc)
              * Specification; Page 26 of 210
              */
-            _fib.setFcPlfLfo( tableStream.getOffset() );
-            _lt.writeListOverridesTo( tableStream );
-            _fib.setLcbPlfLfo( tableStream.getOffset() - tableOffset );
+            _lt.writeListOverridesTo( _fib, tableStream );
             tableOffset = tableStream.getOffset();
         }
 
@@ -1024,14 +1023,15 @@ public final class HWPFDocument extends 
     return _tableStream;
   }
 
-  public int registerList(HWPFList list)
-  {
-    if (_lt == null)
+    public int registerList( HWPFList list )
     {
-      _lt = new ListTables();
+        if ( _lt == null )
+        {
+            _lt = new ListTables();
+        }
+        return _lt.addList( list.getListData(), list.getLFO(),
+                list.getLFOData() );
     }
-    return _lt.addList(list.getListData(), list.getOverride());
-  }
 
   public void delete(int start, int length)
   {

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/sprm/ParagraphSprmUncompressor.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/sprm/ParagraphSprmUncompressor.java?rev=1389039&r1=1389038&r2=1389039&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/sprm/ParagraphSprmUncompressor.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/sprm/ParagraphSprmUncompressor.java Sun Sep 23 12:57:39 2012
@@ -159,9 +159,10 @@ public final class ParagraphSprmUncompre
       case 0xa:
         newPAP.setIlvl ((byte) sprm.getOperand());
         break;
-      case 0xb:
-        newPAP.setIlfo (sprm.getOperand());
-        break;
+        case 0xb:
+            /* sprmPIlfo -- 0x460B */
+            newPAP.setIlfo( sprm.getOperandShortSigned() );
+            break;
       case 0xc:
         newPAP.setFNoLnn (sprm.getOperand() != 0);
         break;

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/sprm/SprmOperation.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/sprm/SprmOperation.java?rev=1389039&r1=1389038&r2=1389039&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/sprm/SprmOperation.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/sprm/SprmOperation.java Sun Sep 23 12:57:39 2012
@@ -134,6 +134,15 @@ public final class SprmOperation
         }
     }
 
+    public short getOperandShortSigned()
+    {
+        if ( getSizeCode() != 2 && getSizeCode() != 4 && getSizeCode() != 5 )
+            throw new UnsupportedOperationException(
+                    "Current SPRM doesn't have signed short operand: " + this );
+
+        return LittleEndian.getShort( _grpprl, _gOffset );
+    }
+
     public int getOperation()
     {
         return BITFIELD_OP.getValue( _value );

Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/converter/TestWordToTextConverter.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/converter/TestWordToTextConverter.java?rev=1389039&r1=1389038&r2=1389039&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/converter/TestWordToTextConverter.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/converter/TestWordToTextConverter.java Sun Sep 23 12:57:39 2012
@@ -35,4 +35,11 @@ public class TestWordToTextConverter ext
         assertTrue( foundText
                 .contains( "Soak the rice in water for three to four hours" ) );
     }
+
+    public void testBug53380_3() throws Exception
+    {
+        HWPFDocument doc = HWPFTestDataSamples
+                .openSampleFile( "Bug53380_3.doc" );
+        WordToTextConverter.getText( doc );
+    }
 }



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