refactor list format override structures (was marked with @Internal annotation)

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1389039 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Sergey Vladimirov 2012-09-23 12:57:39 +00:00
parent 3c200abd02
commit dc4fd539e0
4 changed files with 35 additions and 18 deletions

View File

@ -346,12 +346,13 @@ public final class HWPFDocument extends HWPFDocumentCore
_ss = new StyleSheet(_tableStream, _fib.getFcStshf()); _ss = new StyleSheet(_tableStream, _fib.getFcStshf());
_ft = new FontTable(_tableStream, _fib.getFcSttbfffn(), _fib.getLcbSttbfffn()); _ft = new FontTable(_tableStream, _fib.getFcSttbfffn(), _fib.getLcbSttbfffn());
int listOffset = _fib.getFcPlcfLst(); int listOffset = _fib.getFcPlfLst();
int lfoOffset = _fib.getFcPlfLfo(); int lfoOffset = _fib.getFcPlfLfo();
if (listOffset != 0 && _fib.getLcbPlcfLst() != 0) if ( listOffset != 0 && _fib.getLcbPlfLst() != 0 )
{ {
_lt = new ListTables(_tableStream, _fib.getFcPlcfLst(), _fib.getFcPlfLfo()); _lt = new ListTables( _tableStream, listOffset, _fib.getFcPlfLfo(),
} _fib.getLcbPlfLfo() );
}
int sbtOffset = _fib.getFcSttbSavedBy(); int sbtOffset = _fib.getFcSttbSavedBy();
int sbtLength = _fib.getLcbSttbSavedBy(); int sbtLength = _fib.getLcbSttbSavedBy();
@ -830,9 +831,7 @@ public final class HWPFDocument extends HWPFDocumentCore
* Microsoft Office Word 97-2007 Binary File Format (.doc) * Microsoft Office Word 97-2007 Binary File Format (.doc)
* Specification; Page 26 of 210 * Specification; Page 26 of 210
*/ */
_fib.setFcPlfLfo( tableStream.getOffset() ); _lt.writeListOverridesTo( _fib, tableStream );
_lt.writeListOverridesTo( tableStream );
_fib.setLcbPlfLfo( tableStream.getOffset() - tableOffset );
tableOffset = tableStream.getOffset(); tableOffset = tableStream.getOffset();
} }
@ -1024,14 +1023,15 @@ public final class HWPFDocument extends HWPFDocumentCore
return _tableStream; return _tableStream;
} }
public int registerList(HWPFList list) public int registerList( HWPFList list )
{
if (_lt == null)
{ {
_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) public void delete(int start, int length)
{ {

View File

@ -159,9 +159,10 @@ public final class ParagraphSprmUncompressor
case 0xa: case 0xa:
newPAP.setIlvl ((byte) sprm.getOperand()); newPAP.setIlvl ((byte) sprm.getOperand());
break; break;
case 0xb: case 0xb:
newPAP.setIlfo (sprm.getOperand()); /* sprmPIlfo -- 0x460B */
break; newPAP.setIlfo( sprm.getOperandShortSigned() );
break;
case 0xc: case 0xc:
newPAP.setFNoLnn (sprm.getOperand() != 0); newPAP.setFNoLnn (sprm.getOperand() != 0);
break; break;

View 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() public int getOperation()
{ {
return BITFIELD_OP.getValue( _value ); return BITFIELD_OP.getValue( _value );

View File

@ -35,4 +35,11 @@ public class TestWordToTextConverter extends TestCase
assertTrue( foundText assertTrue( foundText
.contains( "Soak the rice in water for three to four hours" ) ); .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 );
}
} }