]> source.dussan.org Git - poi.git/commitdiff
refactor list format override structures (was marked with @Internal annotation)
authorSergey Vladimirov <sergey@apache.org>
Sun, 23 Sep 2012 12:57:39 +0000 (12:57 +0000)
committerSergey Vladimirov <sergey@apache.org>
Sun, 23 Sep 2012 12:57:39 +0000 (12:57 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1389039 13f79535-47bb-0310-9956-ffa450edef68

src/scratchpad/src/org/apache/poi/hwpf/HWPFDocument.java
src/scratchpad/src/org/apache/poi/hwpf/sprm/ParagraphSprmUncompressor.java
src/scratchpad/src/org/apache/poi/hwpf/sprm/SprmOperation.java
src/scratchpad/testcases/org/apache/poi/hwpf/converter/TestWordToTextConverter.java

index 070f0660eedef6c48a5e254c2f91b2749c336830..7012887899828f5f9774ae42941deeb24125b717 100644 (file)
@@ -346,12 +346,13 @@ public final class HWPFDocument extends HWPFDocumentCore
     _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 HWPFDocumentCore
              * 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 HWPFDocumentCore
     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)
   {
index bc35bd3e45de2f0f82328e082cf8d826231cbeb3..6634aa4d0bdc027431e250759f2a1a5870ada5fe 100644 (file)
@@ -159,9 +159,10 @@ public final class ParagraphSprmUncompressor
       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;
index 01262a88f63db2ffee507d65f811ce40001620f2..d4a2f5868bd862ba7657f953a4627ac6ef40e633 100644 (file)
@@ -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 );
index c633797117f6249a54b837aa4c255e2c494c375d..11d5976bbe3fca9b40ff50ee3a58dc33e502f32c 100644 (file)
@@ -35,4 +35,11 @@ public class TestWordToTextConverter extends TestCase
         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 );
+    }
 }