update list types definitions using new Grfhic class

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1195068 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Sergey Vladimirov 2011-10-29 23:01:54 +00:00
parent 992fe34dc7
commit 1c3711e4ce
14 changed files with 585 additions and 271 deletions

View File

@ -70,7 +70,7 @@ public class FieldIterator
String result = "";
if ( type.equals( "short[]" ) )
result = "LittleEndian.getSimpleShortArray( data, 0x"
result = "LittleEndian.getShortArray( data, 0x"
+ Integer.toHexString( offset ) + " + offset, " + size
+ " )";
else if ( type.equals( "byte[]" ) )
@ -86,6 +86,9 @@ public class FieldIterator
else if ( type.equals( "DateAndTime" ) )
result = "new DateAndTime( data, 0x" + Integer.toHexString( offset )
+ " + offset )";
else if ( type.equals( "Grfhic" ) )
result = "new Grfhic( data, 0x" + Integer.toHexString( offset )
+ " + offset )";
else if ( size.equals( "2" ) )
result = "LittleEndian.getShort( data, 0x"
+ Integer.toHexString( offset ) + " + offset )";
@ -156,6 +159,9 @@ public class FieldIterator
else if ( type.equals( "DateAndTime" ) )
result = javaFieldName + ".serialize( data, 0x"
+ Integer.toHexString( offset ) + " + offset );";
else if ( type.equals( "Grfhic" ) )
result = javaFieldName + ".serialize( data, 0x"
+ Integer.toHexString( offset ) + " + offset );";
else if ( size.equals( "2" ) )
if ( type.equals( "short" ) )
{

View File

@ -0,0 +1,57 @@
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
package org.apache.poi.hwpf.model;
import org.apache.poi.hwpf.model.types.GrfhicAbstractType;
import org.apache.poi.util.Internal;
/**
* The grfhic structure is a set of HTML incompatibility flags that specify the
* HTML incompatibilities of a list structure. The values specify possible
* incompatibilities between an LVL or LVLF and HTML lists. The values do not
* define list properties.
* <p>
* Class and fields descriptions are quoted from [MS-DOC] -- v20110315 Word
* (.doc) Binary File Format specification
* <p>
* This class is internal. It content or properties may change without notice
* due to changes in our knowledge of internal Microsoft Word binary structures.
*
* @author Sergey Vladimirov; according to [MS-DOC] -- v20110315 Word (.doc)
* Binary File Format specification
*/
@Internal
public class Grfhic extends GrfhicAbstractType
{
public Grfhic()
{
}
public Grfhic( byte[] bytes, int offset )
{
fillFields( bytes, offset );
}
public byte[] toByteArray()
{
byte[] buf = new byte[getSize()];
serialize( buf, 0 );
return buf;
}
}

View File

@ -31,7 +31,6 @@ import org.apache.poi.hwpf.model.types.LFOAbstractType;
@Internal
class LFO extends LFOAbstractType
{
public LFO()
{
}
@ -40,46 +39,4 @@ class LFO extends LFOAbstractType
{
fillFields( std, offset );
}
@Override
public boolean equals( Object obj )
{
if ( this == obj )
return true;
if ( obj == null )
return false;
if ( getClass() != obj.getClass() )
return false;
LFO other = (LFO) obj;
if ( field_1_lsid != other.field_1_lsid )
return false;
if ( field_2_reserved1 != other.field_2_reserved1 )
return false;
if ( field_3_reserved2 != other.field_3_reserved2 )
return false;
if ( field_4_clfolvl != other.field_4_clfolvl )
return false;
if ( field_5_ibstFltAutoNum != other.field_5_ibstFltAutoNum )
return false;
if ( field_6_grfhic != other.field_6_grfhic )
return false;
if ( field_7_reserved3 != other.field_7_reserved3 )
return false;
return true;
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + field_1_lsid;
result = prime * result + field_2_reserved1;
result = prime * result + field_3_reserved2;
result = prime * result + field_4_clfolvl;
result = prime * result + field_5_ibstFltAutoNum;
result = prime * result + field_6_grfhic;
result = prime * result + field_7_reserved3;
return result;
}
}

View File

@ -45,9 +45,9 @@ public final class ListLevel
private LVLF _lvlf;
private char[] _xst = {};
public ListLevel( final byte[] buf, final int originalOffset )
public ListLevel( final byte[] buf, final int startOffset )
{
int offset = originalOffset;
int offset = startOffset;
_lvlf = new LVLF( buf, offset );
offset += LVLF.getSize();
@ -74,7 +74,7 @@ public final class ListLevel
if ( numberTextLength != 1 )
{
logger.log( POILogger.WARN, "LVL at offset ",
Integer.valueOf( originalOffset ),
Integer.valueOf( startOffset ),
" has nfc == 0x17 (bullets), but cch != 1 (",
Integer.valueOf( numberTextLength ), ")" );
}

View File

@ -0,0 +1,305 @@
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
package org.apache.poi.hwpf.model.types;
import org.apache.poi.util.BitField;
import org.apache.poi.util.Internal;
/**
* The grfhic structure is a set of HTML incompatibility flags that specify the HTML
incompatibilities of a list structure. The values specify possible incompatibilities between
an LVL or LVLF and HTML lists. The values do not define list properties. <p>Class and
fields descriptions are quoted from [MS-DOC] -- v20110315 Word (.doc) Binary File Format
specification
* <p>
* NOTE: This source is automatically generated please do not modify this file. Either subclass or
* remove the record in src/types/definitions.
* <p>
* This class is internal. It content or properties may change without notice
* due to changes in our knowledge of internal Microsoft Word binary structures.
* @author Sergey Vladimirov; according to [MS-DOC] -- v20110315 Word (.doc) Binary File Format
specification
*/
@Internal
public abstract class GrfhicAbstractType
{
protected byte field_1_grfhic;
/**/private static final BitField fHtmlChecked = new BitField(0x01);
/**/private static final BitField fHtmlUnsupported = new BitField(0x02);
/**/private static final BitField fHtmlListTextNotSharpDot = new BitField(0x04);
/**/private static final BitField fHtmlNotPeriod = new BitField(0x08);
/**/private static final BitField fHtmlFirstLineMismatch = new BitField(0x10);
/**/private static final BitField fHtmlTabLeftIndentMismatch = new BitField(0x20);
/**/private static final BitField fHtmlHangingIndentBeneathNumber = new BitField(0x40);
/**/private static final BitField fHtmlBuiltInBullet = new BitField(0x80);
protected GrfhicAbstractType()
{
}
protected void fillFields( byte[] data, int offset )
{
field_1_grfhic = data[ 0x0 + offset ];
}
public void serialize( byte[] data, int offset )
{
data[ 0x0 + offset ] = field_1_grfhic;
}
public byte[] serialize()
{
final byte[] result = new byte[ getSize() ];
serialize( result, 0 );
return result;
}
/**
* Size of record
*/
public static int getSize()
{
return 0 + 1;
}
@Override
public boolean equals( Object obj )
{
if ( this == obj )
return true;
if ( obj == null )
return false;
if ( getClass() != obj.getClass() )
return false;
GrfhicAbstractType other = (GrfhicAbstractType) obj;
if ( field_1_grfhic != other.field_1_grfhic )
return false;
return true;
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + field_1_grfhic;
return result;
}
public String toString()
{
StringBuilder builder = new StringBuilder();
builder.append("[Grfhic]\n");
builder.append(" .grfhic = ");
builder.append(" (").append(getGrfhic()).append(" )\n");
builder.append(" .fHtmlChecked = ").append(isFHtmlChecked()).append('\n');
builder.append(" .fHtmlUnsupported = ").append(isFHtmlUnsupported()).append('\n');
builder.append(" .fHtmlListTextNotSharpDot = ").append(isFHtmlListTextNotSharpDot()).append('\n');
builder.append(" .fHtmlNotPeriod = ").append(isFHtmlNotPeriod()).append('\n');
builder.append(" .fHtmlFirstLineMismatch = ").append(isFHtmlFirstLineMismatch()).append('\n');
builder.append(" .fHtmlTabLeftIndentMismatch = ").append(isFHtmlTabLeftIndentMismatch()).append('\n');
builder.append(" .fHtmlHangingIndentBeneathNumber = ").append(isFHtmlHangingIndentBeneathNumber()).append('\n');
builder.append(" .fHtmlBuiltInBullet = ").append(isFHtmlBuiltInBullet()).append('\n');
builder.append("[/Grfhic]\n");
return builder.toString();
}
/**
* HTML compatibility flags.
*/
@Internal
public byte getGrfhic()
{
return field_1_grfhic;
}
/**
* HTML compatibility flags.
*/
@Internal
public void setGrfhic( byte field_1_grfhic )
{
this.field_1_grfhic = field_1_grfhic;
}
/**
* Sets the fHtmlChecked field value.
* Checked
*/
@Internal
public void setFHtmlChecked( boolean value )
{
field_1_grfhic = (byte)fHtmlChecked.setBoolean(field_1_grfhic, value);
}
/**
* Checked
* @return the fHtmlChecked field value.
*/
@Internal
public boolean isFHtmlChecked()
{
return fHtmlChecked.isSet(field_1_grfhic);
}
/**
* Sets the fHtmlUnsupported field value.
* The numbering sequence or format is unsupported (includes tab & size)
*/
@Internal
public void setFHtmlUnsupported( boolean value )
{
field_1_grfhic = (byte)fHtmlUnsupported.setBoolean(field_1_grfhic, value);
}
/**
* The numbering sequence or format is unsupported (includes tab & size)
* @return the fHtmlUnsupported field value.
*/
@Internal
public boolean isFHtmlUnsupported()
{
return fHtmlUnsupported.isSet(field_1_grfhic);
}
/**
* Sets the fHtmlListTextNotSharpDot field value.
* The list text is not "#."
*/
@Internal
public void setFHtmlListTextNotSharpDot( boolean value )
{
field_1_grfhic = (byte)fHtmlListTextNotSharpDot.setBoolean(field_1_grfhic, value);
}
/**
* The list text is not "#."
* @return the fHtmlListTextNotSharpDot field value.
*/
@Internal
public boolean isFHtmlListTextNotSharpDot()
{
return fHtmlListTextNotSharpDot.isSet(field_1_grfhic);
}
/**
* Sets the fHtmlNotPeriod field value.
* Something other than a period is used
*/
@Internal
public void setFHtmlNotPeriod( boolean value )
{
field_1_grfhic = (byte)fHtmlNotPeriod.setBoolean(field_1_grfhic, value);
}
/**
* Something other than a period is used
* @return the fHtmlNotPeriod field value.
*/
@Internal
public boolean isFHtmlNotPeriod()
{
return fHtmlNotPeriod.isSet(field_1_grfhic);
}
/**
* Sets the fHtmlFirstLineMismatch field value.
* First line indent mismatch
*/
@Internal
public void setFHtmlFirstLineMismatch( boolean value )
{
field_1_grfhic = (byte)fHtmlFirstLineMismatch.setBoolean(field_1_grfhic, value);
}
/**
* First line indent mismatch
* @return the fHtmlFirstLineMismatch field value.
*/
@Internal
public boolean isFHtmlFirstLineMismatch()
{
return fHtmlFirstLineMismatch.isSet(field_1_grfhic);
}
/**
* Sets the fHtmlTabLeftIndentMismatch field value.
* The list tab and the dxaLeft don't match (need table?)
*/
@Internal
public void setFHtmlTabLeftIndentMismatch( boolean value )
{
field_1_grfhic = (byte)fHtmlTabLeftIndentMismatch.setBoolean(field_1_grfhic, value);
}
/**
* The list tab and the dxaLeft don't match (need table?)
* @return the fHtmlTabLeftIndentMismatch field value.
*/
@Internal
public boolean isFHtmlTabLeftIndentMismatch()
{
return fHtmlTabLeftIndentMismatch.isSet(field_1_grfhic);
}
/**
* Sets the fHtmlHangingIndentBeneathNumber field value.
* The hanging indent falls beneath the number (need plain text)
*/
@Internal
public void setFHtmlHangingIndentBeneathNumber( boolean value )
{
field_1_grfhic = (byte)fHtmlHangingIndentBeneathNumber.setBoolean(field_1_grfhic, value);
}
/**
* The hanging indent falls beneath the number (need plain text)
* @return the fHtmlHangingIndentBeneathNumber field value.
*/
@Internal
public boolean isFHtmlHangingIndentBeneathNumber()
{
return fHtmlHangingIndentBeneathNumber.isSet(field_1_grfhic);
}
/**
* Sets the fHtmlBuiltInBullet field value.
* A built-in HTML bullet
*/
@Internal
public void setFHtmlBuiltInBullet( boolean value )
{
field_1_grfhic = (byte)fHtmlBuiltInBullet.setBoolean(field_1_grfhic, value);
}
/**
* A built-in HTML bullet
* @return the fHtmlBuiltInBullet field value.
*/
@Internal
public boolean isFHtmlBuiltInBullet()
{
return fHtmlBuiltInBullet.isSet(field_1_grfhic);
}
} // END OF CLASS

View File

@ -16,7 +16,7 @@
==================================================================== */
package org.apache.poi.hwpf.model.types;
import org.apache.poi.util.BitField;
import org.apache.poi.hwpf.model.Grfhic;
import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndian;
@ -44,19 +44,12 @@ public abstract class LFOAbstractType
protected int field_3_reserved2;
protected byte field_4_clfolvl;
protected byte field_5_ibstFltAutoNum;
protected byte field_6_grfhic;
/**/private static final BitField fHtmlChecked = new BitField(0x01);
/**/private static final BitField fHtmlUnsupported = new BitField(0x02);
/**/private static final BitField fHtmlListTextNotSharpDot = new BitField(0x04);
/**/private static final BitField fHtmlNotPeriod = new BitField(0x08);
/**/private static final BitField fHtmlFirstLineMismatch = new BitField(0x10);
/**/private static final BitField fHtmlTabLeftIndentMismatch = new BitField(0x20);
/**/private static final BitField fHtmlHangingIndentBeneathNumber = new BitField(0x40);
/**/private static final BitField fHtmlBuiltInBullet = new BitField(0x80);
protected Grfhic field_6_grfhic;
protected byte field_7_reserved3;
protected LFOAbstractType()
{
this.field_6_grfhic = new Grfhic();
}
protected void fillFields( byte[] data, int offset )
@ -66,7 +59,7 @@ public abstract class LFOAbstractType
field_3_reserved2 = LittleEndian.getInt( data, 0x8 + offset );
field_4_clfolvl = data[ 0xc + offset ];
field_5_ibstFltAutoNum = data[ 0xd + offset ];
field_6_grfhic = data[ 0xe + offset ];
field_6_grfhic = new Grfhic( data, 0xe + offset );
field_7_reserved3 = data[ 0xf + offset ];
}
@ -77,7 +70,7 @@ public abstract class LFOAbstractType
LittleEndian.putInt( data, 0x8 + offset, field_3_reserved2 );
data[ 0xc + offset ] = field_4_clfolvl;
data[ 0xd + offset ] = field_5_ibstFltAutoNum;
data[ 0xe + offset ] = field_6_grfhic;
field_6_grfhic.serialize( data, 0xe + offset );
data[ 0xf + offset ] = field_7_reserved3;
}
@ -96,6 +89,53 @@ public abstract class LFOAbstractType
return 0 + 4 + 4 + 4 + 1 + 1 + 1 + 1;
}
@Override
public boolean equals( Object obj )
{
if ( this == obj )
return true;
if ( obj == null )
return false;
if ( getClass() != obj.getClass() )
return false;
LFOAbstractType other = (LFOAbstractType) obj;
if ( field_1_lsid != other.field_1_lsid )
return false;
if ( field_2_reserved1 != other.field_2_reserved1 )
return false;
if ( field_3_reserved2 != other.field_3_reserved2 )
return false;
if ( field_4_clfolvl != other.field_4_clfolvl )
return false;
if ( field_5_ibstFltAutoNum != other.field_5_ibstFltAutoNum )
return false;
if ( field_6_grfhic == null )
{
if ( other.field_6_grfhic != null )
return false;
}
else if ( !field_6_grfhic.equals( other.field_6_grfhic ) )
return false;
if ( field_7_reserved3 != other.field_7_reserved3 )
return false;
return true;
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + field_1_lsid;
result = prime * result + field_2_reserved1;
result = prime * result + field_3_reserved2;
result = prime * result + field_4_clfolvl;
result = prime * result + field_5_ibstFltAutoNum;
result = prime * result + field_6_grfhic.hashCode();
result = prime * result + field_7_reserved3;
return result;
}
public String toString()
{
StringBuilder builder = new StringBuilder();
@ -112,14 +152,6 @@ public abstract class LFOAbstractType
builder.append(" (").append(getIbstFltAutoNum()).append(" )\n");
builder.append(" .grfhic = ");
builder.append(" (").append(getGrfhic()).append(" )\n");
builder.append(" .fHtmlChecked = ").append(isFHtmlChecked()).append('\n');
builder.append(" .fHtmlUnsupported = ").append(isFHtmlUnsupported()).append('\n');
builder.append(" .fHtmlListTextNotSharpDot = ").append(isFHtmlListTextNotSharpDot()).append('\n');
builder.append(" .fHtmlNotPeriod = ").append(isFHtmlNotPeriod()).append('\n');
builder.append(" .fHtmlFirstLineMismatch = ").append(isFHtmlFirstLineMismatch()).append('\n');
builder.append(" .fHtmlTabLeftIndentMismatch = ").append(isFHtmlTabLeftIndentMismatch()).append('\n');
builder.append(" .fHtmlHangingIndentBeneathNumber = ").append(isFHtmlHangingIndentBeneathNumber()).append('\n');
builder.append(" .fHtmlBuiltInBullet = ").append(isFHtmlBuiltInBullet()).append('\n');
builder.append(" .reserved3 = ");
builder.append(" (").append(getReserved3()).append(" )\n");
@ -221,7 +253,7 @@ public abstract class LFOAbstractType
* HTML compatibility flags.
*/
@Internal
public byte getGrfhic()
public Grfhic getGrfhic()
{
return field_6_grfhic;
}
@ -230,7 +262,7 @@ public abstract class LFOAbstractType
* HTML compatibility flags.
*/
@Internal
public void setGrfhic( byte field_6_grfhic )
public void setGrfhic( Grfhic field_6_grfhic )
{
this.field_6_grfhic = field_6_grfhic;
}
@ -253,164 +285,4 @@ public abstract class LFOAbstractType
this.field_7_reserved3 = field_7_reserved3;
}
/**
* Sets the fHtmlChecked field value.
* Checked
*/
@Internal
public void setFHtmlChecked( boolean value )
{
field_6_grfhic = (byte)fHtmlChecked.setBoolean(field_6_grfhic, value);
}
/**
* Checked
* @return the fHtmlChecked field value.
*/
@Internal
public boolean isFHtmlChecked()
{
return fHtmlChecked.isSet(field_6_grfhic);
}
/**
* Sets the fHtmlUnsupported field value.
* The numbering sequence or format is unsupported (includes tab & size)
*/
@Internal
public void setFHtmlUnsupported( boolean value )
{
field_6_grfhic = (byte)fHtmlUnsupported.setBoolean(field_6_grfhic, value);
}
/**
* The numbering sequence or format is unsupported (includes tab & size)
* @return the fHtmlUnsupported field value.
*/
@Internal
public boolean isFHtmlUnsupported()
{
return fHtmlUnsupported.isSet(field_6_grfhic);
}
/**
* Sets the fHtmlListTextNotSharpDot field value.
* The list text is not "#."
*/
@Internal
public void setFHtmlListTextNotSharpDot( boolean value )
{
field_6_grfhic = (byte)fHtmlListTextNotSharpDot.setBoolean(field_6_grfhic, value);
}
/**
* The list text is not "#."
* @return the fHtmlListTextNotSharpDot field value.
*/
@Internal
public boolean isFHtmlListTextNotSharpDot()
{
return fHtmlListTextNotSharpDot.isSet(field_6_grfhic);
}
/**
* Sets the fHtmlNotPeriod field value.
* Something other than a period is used
*/
@Internal
public void setFHtmlNotPeriod( boolean value )
{
field_6_grfhic = (byte)fHtmlNotPeriod.setBoolean(field_6_grfhic, value);
}
/**
* Something other than a period is used
* @return the fHtmlNotPeriod field value.
*/
@Internal
public boolean isFHtmlNotPeriod()
{
return fHtmlNotPeriod.isSet(field_6_grfhic);
}
/**
* Sets the fHtmlFirstLineMismatch field value.
* First line indent mismatch
*/
@Internal
public void setFHtmlFirstLineMismatch( boolean value )
{
field_6_grfhic = (byte)fHtmlFirstLineMismatch.setBoolean(field_6_grfhic, value);
}
/**
* First line indent mismatch
* @return the fHtmlFirstLineMismatch field value.
*/
@Internal
public boolean isFHtmlFirstLineMismatch()
{
return fHtmlFirstLineMismatch.isSet(field_6_grfhic);
}
/**
* Sets the fHtmlTabLeftIndentMismatch field value.
* The list tab and the dxaLeft don't match (need table?)
*/
@Internal
public void setFHtmlTabLeftIndentMismatch( boolean value )
{
field_6_grfhic = (byte)fHtmlTabLeftIndentMismatch.setBoolean(field_6_grfhic, value);
}
/**
* The list tab and the dxaLeft don't match (need table?)
* @return the fHtmlTabLeftIndentMismatch field value.
*/
@Internal
public boolean isFHtmlTabLeftIndentMismatch()
{
return fHtmlTabLeftIndentMismatch.isSet(field_6_grfhic);
}
/**
* Sets the fHtmlHangingIndentBeneathNumber field value.
* The hanging indent falls beneath the number (need plain text)
*/
@Internal
public void setFHtmlHangingIndentBeneathNumber( boolean value )
{
field_6_grfhic = (byte)fHtmlHangingIndentBeneathNumber.setBoolean(field_6_grfhic, value);
}
/**
* The hanging indent falls beneath the number (need plain text)
* @return the fHtmlHangingIndentBeneathNumber field value.
*/
@Internal
public boolean isFHtmlHangingIndentBeneathNumber()
{
return fHtmlHangingIndentBeneathNumber.isSet(field_6_grfhic);
}
/**
* Sets the fHtmlBuiltInBullet field value.
* A built-in HTML bullet
*/
@Internal
public void setFHtmlBuiltInBullet( boolean value )
{
field_6_grfhic = (byte)fHtmlBuiltInBullet.setBoolean(field_6_grfhic, value);
}
/**
* A built-in HTML bullet
* @return the fHtmlBuiltInBullet field value.
*/
@Internal
public boolean isFHtmlBuiltInBullet()
{
return fHtmlBuiltInBullet.isSet(field_6_grfhic);
}
} // END OF CLASS

View File

@ -18,6 +18,7 @@ package org.apache.poi.hwpf.model.types;
import java.util.Arrays;
import org.apache.poi.hwpf.model.Grfhic;
import org.apache.poi.util.BitField;
import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndian;
@ -52,11 +53,12 @@ public abstract class LSTFAbstractType
/**/private static final BitField unused2 = new BitField(0x08);
/**/private static final BitField fHybrid = new BitField(0x10);
/**/private static final BitField reserved1 = new BitField(0xE0);
protected byte field_5_grfhic;
protected Grfhic field_5_grfhic;
protected LSTFAbstractType()
{
this.field_3_rgistdPara = new short[0];
this.field_5_grfhic = new Grfhic();
}
protected void fillFields( byte[] data, int offset )
@ -65,7 +67,7 @@ public abstract class LSTFAbstractType
field_2_tplc = LittleEndian.getInt( data, 0x4 + offset );
field_3_rgistdPara = LittleEndian.getShortArray( data, 0x8 + offset, 18 );
field_4_flags = data[ 0x1a + offset ];
field_5_grfhic = data[ 0x1b + offset ];
field_5_grfhic = new Grfhic( data, 0x1b + offset );
}
public void serialize( byte[] data, int offset )
@ -74,7 +76,7 @@ public abstract class LSTFAbstractType
LittleEndian.putInt( data, 0x4 + offset, field_2_tplc );
LittleEndian.putShortArray( data, 0x8 + offset, field_3_rgistdPara );
data[ 0x1a + offset ] = field_4_flags;
data[ 0x1b + offset ] = field_5_grfhic;
field_5_grfhic.serialize( data, 0x1b + offset );
}
public byte[] serialize()
@ -110,7 +112,12 @@ public abstract class LSTFAbstractType
return false;
if ( field_4_flags != other.field_4_flags )
return false;
if ( field_5_grfhic != other.field_5_grfhic )
if ( field_5_grfhic == null )
{
if ( other.field_5_grfhic != null )
return false;
}
else if ( !field_5_grfhic.equals( other.field_5_grfhic ) )
return false;
return true;
}
@ -124,7 +131,7 @@ public abstract class LSTFAbstractType
result = prime * result + field_2_tplc;
result = prime * result + Arrays.hashCode( field_3_rgistdPara );
result = prime * result + field_4_flags;
result = prime * result + field_5_grfhic;
result = prime * result + field_5_grfhic.hashCode();
return result;
}
@ -229,7 +236,7 @@ public abstract class LSTFAbstractType
* A grfhic that specifies the HTML incompatibilities of the list..
*/
@Internal
public byte getGrfhic()
public Grfhic getGrfhic()
{
return field_5_grfhic;
}
@ -238,7 +245,7 @@ public abstract class LSTFAbstractType
* A grfhic that specifies the HTML incompatibilities of the list..
*/
@Internal
public void setGrfhic( byte field_5_grfhic )
public void setGrfhic( Grfhic field_5_grfhic )
{
this.field_5_grfhic = field_5_grfhic;
}

View File

@ -16,8 +16,10 @@
==================================================================== */
package org.apache.poi.hwpf.model.types;
import java.util.Arrays;
import org.apache.poi.hwpf.model.Grfhic;
import org.apache.poi.util.BitField;
import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndian;
@ -59,11 +61,12 @@ public abstract class LVLFAbstractType
protected short field_8_cbGrpprlChpx;
protected short field_9_cbGrpprlPapx;
protected short field_10_ilvlRestartLim;
protected short field_11_grfhic;
protected Grfhic field_11_grfhic;
protected LVLFAbstractType()
{
this.field_4_rgbxchNums = new byte[9];
this.field_11_grfhic = new Grfhic();
}
protected void fillFields( byte[] data, int offset )
@ -78,7 +81,7 @@ public abstract class LVLFAbstractType
field_8_cbGrpprlChpx = LittleEndian.getUByte( data, 0x18 + offset );
field_9_cbGrpprlPapx = LittleEndian.getUByte( data, 0x19 + offset );
field_10_ilvlRestartLim = LittleEndian.getUByte( data, 0x1a + offset );
field_11_grfhic = LittleEndian.getUByte( data, 0x1b + offset );
field_11_grfhic = new Grfhic( data, 0x1b + offset );
}
public void serialize( byte[] data, int offset )
@ -93,7 +96,7 @@ public abstract class LVLFAbstractType
LittleEndian.putUByte( data, 0x18 + offset, field_8_cbGrpprlChpx );
LittleEndian.putUByte( data, 0x19 + offset, field_9_cbGrpprlPapx );
LittleEndian.putUByte( data, 0x1a + offset, field_10_ilvlRestartLim );
LittleEndian.putUByte( data, 0x1b + offset, field_11_grfhic );
field_11_grfhic.serialize( data, 0x1b + offset );
}
public byte[] serialize()
@ -141,7 +144,12 @@ public abstract class LVLFAbstractType
return false;
if ( field_10_ilvlRestartLim != other.field_10_ilvlRestartLim )
return false;
if ( field_11_grfhic != other.field_11_grfhic )
if ( field_11_grfhic == null )
{
if ( other.field_11_grfhic != null )
return false;
}
else if ( !field_11_grfhic.equals( other.field_11_grfhic ) )
return false;
return true;
}
@ -161,7 +169,7 @@ public abstract class LVLFAbstractType
result = prime * result + field_8_cbGrpprlChpx;
result = prime * result + field_9_cbGrpprlPapx;
result = prime * result + field_10_ilvlRestartLim;
result = prime * result + field_11_grfhic;
result = prime * result + field_11_grfhic.hashCode();
return result;
}
@ -387,7 +395,7 @@ public abstract class LVLFAbstractType
* A grfhic that specifies the HTML incompatibilities of the level..
*/
@Internal
public short getGrfhic()
public Grfhic getGrfhic()
{
return field_11_grfhic;
}
@ -396,7 +404,7 @@ public abstract class LVLFAbstractType
* A grfhic that specifies the HTML incompatibilities of the level..
*/
@Internal
public void setGrfhic( short field_11_grfhic )
public void setGrfhic( Grfhic field_11_grfhic )
{
this.field_11_grfhic = field_11_grfhic;
}

View File

@ -719,15 +719,31 @@ public class TestBugs extends TestCase
HWPFTestDataSamples.writeOutAndReadBack( HWPFTestDataSamples
.openSampleFile( "Bug51834.doc" ) );
}
/**
* Bug 52032 - [BUG] & [partial-PATCH] HWPF - ArrayIndexOutofBoundsException
* with no stack trace (broken after revision 1178063)
*/
public void testBug52032() throws Exception
public void testBug52032_1() throws Exception
{
HWPFTestDataSamples.openSampleFile( "Bug52032.doc" );
HWPFTestDataSamples.writeOutAndReadBack( HWPFTestDataSamples
.openSampleFile( "Bug52032.doc" ) );
HWPFTestDataSamples.openSampleFile( "Bug52032_1.doc" );
}
/**
* Bug 52032 - [BUG] & [partial-PATCH] HWPF - ArrayIndexOutofBoundsException
* with no stack trace (broken after revision 1178063)
*/
public void testBug52032_2() throws Exception
{
HWPFTestDataSamples.openSampleFile( "Bug52032_2.doc" );
}
/**
* Bug 52032 - [BUG] & [partial-PATCH] HWPF - ArrayIndexOutofBoundsException
* with no stack trace (broken after revision 1178063)
*/
public void testBug52032_3() throws Exception
{
HWPFTestDataSamples.openSampleFile( "Bug52032_3.doc" );
}
}

View File

@ -0,0 +1,46 @@
<?xml version="1.0"?>
<!--
====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
====================================================================
-->
<record fromfile="true" name="Grfhic" package="org.apache.poi.hwpf.model.types">
<suffix>AbstractType</suffix>
<description>The grfhic structure is a set of HTML incompatibility flags that specify the HTML
incompatibilities of a list structure. The values specify possible incompatibilities between
an LVL or LVLF and HTML lists. The values do not define list properties. &lt;p&gt;Class and
fields descriptions are quoted from [MS-DOC] -- v20110315 Word (.doc) Binary File Format
specification
</description>
<author>Sergey Vladimirov; according to [MS-DOC] -- v20110315 Word (.doc) Binary File Format
specification
</author>
<fields>
<field type="byte" size="1" name="grfhic" description="HTML compatibility flags">
<bit number="0" mask="0x01" name="fHtmlChecked" description="Checked"/>
<bit number="1" mask="0x02" name="fHtmlUnsupported"
description="The numbering sequence or format is unsupported (includes tab &amp; size)"/>
<bit number="2" mask="0x04" name="fHtmlListTextNotSharpDot" description="The list text is not &quot;#.&quot;"/>
<bit number="3" mask="0x08" name="fHtmlNotPeriod" description="Something other than a period is used"/>
<bit number="4" mask="0x10" name="fHtmlFirstLineMismatch" description="First line indent mismatch"/>
<bit number="5" mask="0x20" name="fHtmlTabLeftIndentMismatch"
description="The list tab and the dxaLeft don't match (need table?)"/>
<bit number="6" mask="0x40" name="fHtmlHangingIndentBeneathNumber"
description="The hanging indent falls beneath the number (need plain text)"/>
<bit number="7" mask="0x80" name="fHtmlBuiltInBullet" description="A built-in HTML bullet"/>
</field>
</fields>
</record>

View File

@ -33,19 +33,7 @@
<field type="byte" size="1" name="clfolvl"
description="Count of levels whose format is overridden (see LFOLVL)"/>
<field type="byte" size="1" name="ibstFltAutoNum" description="Used for AUTONUM field emulation"/>
<field type="byte" size="1" name="grfhic" description="HTML compatibility flags">
<bit number="0" mask="0x01" name="fHtmlChecked" description="Checked"/>
<bit number="1" mask="0x02" name="fHtmlUnsupported"
description="The numbering sequence or format is unsupported (includes tab &amp; size)"/>
<bit number="2" mask="0x04" name="fHtmlListTextNotSharpDot" description="The list text is not &quot;#.&quot;"/>
<bit number="3" mask="0x08" name="fHtmlNotPeriod" description="Something other than a period is used"/>
<bit number="4" mask="0x10" name="fHtmlFirstLineMismatch" description="First line indent mismatch"/>
<bit number="5" mask="0x20" name="fHtmlTabLeftIndentMismatch"
description="The list tab and the dxaLeft don't match (need table?)"/>
<bit number="6" mask="0x40" name="fHtmlHangingIndentBeneathNumber"
description="The hanging indent falls beneath the number (need plain text)"/>
<bit number="7" mask="0x80" name="fHtmlBuiltInBullet" description="A built-in HTML bullet"/>
</field>
<field type="Grfhic" size="1" name="grfhic" description="HTML compatibility flags" />
<field type="byte" size="1" name="reserved3" description="Reserved"/>
</fields>
</record>

View File

@ -45,7 +45,7 @@
<bit mask="0xE0" name="reserved1" deprecated="true"
description="This MUST be zero, and MUST be ignored."/>
</field>
<field type="byte" size="1" name="grfhic"
<field type="Grfhic" size="1" name="grfhic"
description="A grfhic that specifies the HTML incompatibilities of the list."/>
</fields>
</record>

View File

@ -59,7 +59,7 @@
description="An unsigned integer that specifies the size, in bytes, of the grpprlPapx in the LVL that contains this LVLF"/>
<field type="short" size="1" name="ilvlRestartLim"
description="An unsigned integer that specifies the first (most-significant) zero-based level after which the number sequence of this level does not restart. The number sequence of this level does restart after any level that is more significant than the specified level. This MUST be less than or equal to the zero-based level of the list to which this LVLF corresponds. If fNoRestart is zero, this MUST be ignored. If this level does not have a number sequence (see nfc), this MUST be ignored"/>
<field type="short" size="1" name="grfhic"
<field type="Grfhic" size="1" name="grfhic"
description="A grfhic that specifies the HTML incompatibilities of the level."/>
</fields>
</record>

View File

@ -227,28 +227,76 @@ public abstract class </xsl:text><xsl:call-template name="outputClassName"/><xsl
<xsl:variable name="fieldName" select="recutil:getFieldName(position(),@name,0)"/>
<xsl:call-template name="indent"/>
<xsl:call-template name="indent"/>
<xsl:text>if ( </xsl:text>
<xsl:choose>
<xsl:when test="substring(@type, string-length(@type)-1)='[]'">
<xsl:text>if ( </xsl:text>
<xsl:text>!Arrays.equals( </xsl:text>
<xsl:value-of select="$fieldName"/>
<xsl:text>, other.</xsl:text>
<xsl:value-of select="$fieldName"/>
<xsl:text> )</xsl:text>
<xsl:text> )</xsl:text>
<xsl:call-template name="linebreak"/>
<xsl:call-template name="indent"/>
<xsl:call-template name="indent"/>
<xsl:call-template name="indent"/>
<xsl:text>return false;</xsl:text>
<xsl:call-template name="linebreak"/>
</xsl:when>
<xsl:when test="@type='Grfhic'">
<xsl:text>if ( </xsl:text>
<xsl:value-of select="$fieldName"/>
<xsl:text> == null )</xsl:text>
<xsl:call-template name="linebreak"/>
<xsl:call-template name="indent"/>
<xsl:call-template name="indent"/>
<xsl:text>{</xsl:text>
<xsl:call-template name="linebreak"/>
<xsl:call-template name="indent"/>
<xsl:call-template name="indent"/>
<xsl:call-template name="indent"/>
<xsl:text>if ( other.</xsl:text>
<xsl:value-of select="$fieldName"/>
<xsl:text> != null )</xsl:text>
<xsl:call-template name="linebreak"/>
<xsl:call-template name="indent"/>
<xsl:call-template name="indent"/>
<xsl:call-template name="indent"/>
<xsl:call-template name="indent"/>
<xsl:text>return false;</xsl:text>
<xsl:call-template name="linebreak"/>
<xsl:call-template name="indent"/>
<xsl:call-template name="indent"/>
<xsl:text>}</xsl:text>
<xsl:call-template name="linebreak"/>
<xsl:call-template name="indent"/>
<xsl:call-template name="indent"/>
<xsl:text>else if ( !</xsl:text>
<xsl:value-of select="$fieldName"/>
<xsl:text>.equals( other.</xsl:text>
<xsl:value-of select="$fieldName"/>
<xsl:text> ) )</xsl:text>
<xsl:call-template name="linebreak"/>
<xsl:call-template name="indent"/>
<xsl:call-template name="indent"/>
<xsl:call-template name="indent"/>
<xsl:text>return false;</xsl:text>
<xsl:call-template name="linebreak"/>
</xsl:when>
<xsl:otherwise>
<xsl:text>if ( </xsl:text>
<xsl:value-of select="$fieldName"/>
<xsl:text> != other.</xsl:text>
<xsl:value-of select="$fieldName"/>
<xsl:text> )</xsl:text>
<xsl:call-template name="linebreak"/>
<xsl:call-template name="indent"/>
<xsl:call-template name="indent"/>
<xsl:call-template name="indent"/>
<xsl:text>return false;</xsl:text>
<xsl:call-template name="linebreak"/>
</xsl:otherwise>
</xsl:choose>
<xsl:text> )</xsl:text>
<xsl:call-template name="linebreak"/>
<xsl:call-template name="indent"/>
<xsl:call-template name="indent"/>
<xsl:call-template name="indent"/>
<xsl:text>return false;</xsl:text>
<xsl:call-template name="linebreak"/>
</xsl:for-each>
<xsl:call-template name="indent"/>
<xsl:call-template name="indent"/>
@ -279,6 +327,10 @@ public abstract class </xsl:text><xsl:call-template name="outputClassName"/><xsl
<xsl:value-of select="recutil:getFieldName(position(),@name,0)"/>
<xsl:text> )</xsl:text>
</xsl:when>
<xsl:when test="@type='Grfhic'">
<xsl:value-of select="recutil:getFieldName(position(),@name,0)"/>
<xsl:text>.hashCode()</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="recutil:getFieldName(position(),@name,0)"/>
</xsl:otherwise>