From 25df8a6a764b079f9846e43cb418f319b81a656e Mon Sep 17 00:00:00 2001 From: Sergey Vladimirov Date: Sat, 1 Oct 2011 18:18:51 +0000 Subject: [PATCH] correctly handle last part of FIB git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1178063 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/poi/hwpf/HWPFDocumentCore.java | 3 - .../org/apache/poi/hwpf/model/FibRgLw.java | 29 ++ .../org/apache/poi/hwpf/model/FibRgLw95.java | 107 ++++ .../org/apache/poi/hwpf/model/FibRgLw97.java | 91 +--- .../poi/hwpf/model/FileInformationBlock.java | 158 +++++- .../model/types/FibRgLw95AbstractType.java | 468 ++++++++++++++++++ .../model/types/FibRgLw97AbstractType.java | 87 ++++ src/types/definitions/FibRgLw95_type.xml | 45 ++ src/types/styles/hdftype.xsl | 79 ++- 9 files changed, 970 insertions(+), 97 deletions(-) create mode 100644 src/scratchpad/src/org/apache/poi/hwpf/model/FibRgLw.java create mode 100644 src/scratchpad/src/org/apache/poi/hwpf/model/FibRgLw95.java create mode 100644 src/scratchpad/src/org/apache/poi/hwpf/model/types/FibRgLw95AbstractType.java create mode 100644 src/types/definitions/FibRgLw95_type.xml diff --git a/src/scratchpad/src/org/apache/poi/hwpf/HWPFDocumentCore.java b/src/scratchpad/src/org/apache/poi/hwpf/HWPFDocumentCore.java index 4ffb81a741..ad54e4f186 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/HWPFDocumentCore.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/HWPFDocumentCore.java @@ -154,9 +154,6 @@ public abstract class HWPFDocumentCore extends POIDocument // Create our FIB, and check for the doc being encrypted _fib = new FileInformationBlock(_mainStream); - if (_fib.getFibBase().isFEncrypted()) { - throw new EncryptedDocumentException("Cannot process encrypted word files!"); - } DirectoryEntry objectPoolEntry; try { diff --git a/src/scratchpad/src/org/apache/poi/hwpf/model/FibRgLw.java b/src/scratchpad/src/org/apache/poi/hwpf/model/FibRgLw.java new file mode 100644 index 0000000000..53dd68f39f --- /dev/null +++ b/src/scratchpad/src/org/apache/poi/hwpf/model/FibRgLw.java @@ -0,0 +1,29 @@ +/* ==================================================================== + 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; + +interface FibRgLw +{ + int getCbMac(); + + int getSubdocumentTextStreamLength( SubdocumentType subdocumentType ); + + void setCbMac( int cbMac ); + + void setSubdocumentTextStreamLength( SubdocumentType subdocumentType, + int newLength ); +} diff --git a/src/scratchpad/src/org/apache/poi/hwpf/model/FibRgLw95.java b/src/scratchpad/src/org/apache/poi/hwpf/model/FibRgLw95.java new file mode 100644 index 0000000000..f2834eff39 --- /dev/null +++ b/src/scratchpad/src/org/apache/poi/hwpf/model/FibRgLw95.java @@ -0,0 +1,107 @@ +/* ==================================================================== + 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.FibRgLw95AbstractType; +import org.apache.poi.util.Internal; + +/** + * The FibRgLw97 structure is the third section of the FIB. This contains an + * array of 4-byte values. + *

+ * Class and fields descriptions are quoted from Microsoft Office Word 97-2007 + * Binary File Format and [MS-DOC] - v20110608 Word (.doc) Binary File Format + * + * @author Sergey Vladimirov; according to Microsoft Office Word 97-2007 Binary + * File Format Specification [*.doc] and [MS-DOC] - v20110608 Word + * (.doc) Binary File Format + */ +@Internal +class FibRgLw95 extends FibRgLw95AbstractType implements FibRgLw +{ + + public FibRgLw95() + { + } + + public FibRgLw95( byte[] std, int offset ) + { + fillFields( std, offset ); + } + + @SuppressWarnings( "deprecation" ) + public int getSubdocumentTextStreamLength( SubdocumentType subdocumentType ) + { + switch ( subdocumentType ) + { + case MAIN: + return getCcpText(); + case FOOTNOTE: + return getCcpFtn(); + case HEADER: + return getCcpHdd(); + case MACRO: + return getCcpMcr(); + case ANNOTATION: + return getCcpAtn(); + case ENDNOTE: + return getCcpEdn(); + case TEXTBOX: + return getCcpTxbx(); + case HEADER_TEXTBOX: + return getCcpHdrTxbx(); + } + throw new UnsupportedOperationException( "Unsupported: " + + subdocumentType ); + } + + @SuppressWarnings( "deprecation" ) + public void setSubdocumentTextStreamLength( + SubdocumentType subdocumentType, int newLength ) + { + switch ( subdocumentType ) + { + case MAIN: + setCcpText( newLength ); + return; + case FOOTNOTE: + setCcpFtn( newLength ); + return; + case HEADER: + setCcpHdd( newLength ); + return; + case MACRO: + setCbMac( newLength ); + return; + case ANNOTATION: + setCcpAtn( newLength ); + return; + case ENDNOTE: + setCcpEdn( newLength ); + return; + case TEXTBOX: + setCcpTxbx( newLength ); + return; + case HEADER_TEXTBOX: + setCcpHdrTxbx( newLength ); + return; + } + throw new UnsupportedOperationException( "Unsupported: " + + subdocumentType ); + } + +} diff --git a/src/scratchpad/src/org/apache/poi/hwpf/model/FibRgLw97.java b/src/scratchpad/src/org/apache/poi/hwpf/model/FibRgLw97.java index b2d2ac76bf..26cf4b637a 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/model/FibRgLw97.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/model/FibRgLw97.java @@ -31,7 +31,7 @@ import org.apache.poi.util.Internal; * (.doc) Binary File Format */ @Internal -class FibRgLw97 extends FibRgLw97AbstractType +class FibRgLw97 extends FibRgLw97AbstractType implements FibRgLw { public FibRgLw97() @@ -104,93 +104,4 @@ class FibRgLw97 extends FibRgLw97AbstractType + subdocumentType ); } - @Override - @SuppressWarnings( "deprecation" ) - public int hashCode() - { - final int prime = 31; - int result = 1; - result = prime * result + field_10_ccpTxbx; - result = prime * result + field_11_ccpHdrTxbx; - result = prime * result + field_12_reserved4; - result = prime * result + field_13_reserved5; - result = prime * result + field_14_reserved6; - result = prime * result + field_15_reserved7; - result = prime * result + field_16_reserved8; - result = prime * result + field_17_reserved9; - result = prime * result + field_18_reserved10; - result = prime * result + field_19_reserved11; - result = prime * result + field_1_cbMac; - result = prime * result + field_20_reserved12; - result = prime * result + field_21_reserved13; - result = prime * result + field_22_reserved14; - result = prime * result + field_2_reserved1; - result = prime * result + field_3_reserved2; - result = prime * result + field_4_ccpText; - result = prime * result + field_5_ccpFtn; - result = prime * result + field_6_ccpHdd; - result = prime * result + field_7_reserved3; - result = prime * result + field_8_ccpAtn; - result = prime * result + field_9_ccpEdn; - return result; - } - - @Override - @SuppressWarnings( "deprecation" ) - public boolean equals( Object obj ) - { - if ( this == obj ) - return true; - if ( obj == null ) - return false; - if ( getClass() != obj.getClass() ) - return false; - FibRgLw97 other = (FibRgLw97) obj; - if ( field_10_ccpTxbx != other.field_10_ccpTxbx ) - return false; - if ( field_11_ccpHdrTxbx != other.field_11_ccpHdrTxbx ) - return false; - if ( field_12_reserved4 != other.field_12_reserved4 ) - return false; - if ( field_13_reserved5 != other.field_13_reserved5 ) - return false; - if ( field_14_reserved6 != other.field_14_reserved6 ) - return false; - if ( field_15_reserved7 != other.field_15_reserved7 ) - return false; - if ( field_16_reserved8 != other.field_16_reserved8 ) - return false; - if ( field_17_reserved9 != other.field_17_reserved9 ) - return false; - if ( field_18_reserved10 != other.field_18_reserved10 ) - return false; - if ( field_19_reserved11 != other.field_19_reserved11 ) - return false; - if ( field_1_cbMac != other.field_1_cbMac ) - return false; - if ( field_20_reserved12 != other.field_20_reserved12 ) - return false; - if ( field_21_reserved13 != other.field_21_reserved13 ) - return false; - if ( field_22_reserved14 != other.field_22_reserved14 ) - 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_ccpText != other.field_4_ccpText ) - return false; - if ( field_5_ccpFtn != other.field_5_ccpFtn ) - return false; - if ( field_6_ccpHdd != other.field_6_ccpHdd ) - return false; - if ( field_7_reserved3 != other.field_7_reserved3 ) - return false; - if ( field_8_ccpAtn != other.field_8_ccpAtn ) - return false; - if ( field_9_ccpEdn != other.field_9_ccpEdn ) - return false; - return true; - } - } diff --git a/src/scratchpad/src/org/apache/poi/hwpf/model/FileInformationBlock.java b/src/scratchpad/src/org/apache/poi/hwpf/model/FileInformationBlock.java index 123f3ab1d7..989872d6a8 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/model/FileInformationBlock.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/model/FileInformationBlock.java @@ -22,9 +22,13 @@ import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.util.HashSet; +import org.apache.poi.EncryptedDocumentException; + import org.apache.poi.hwpf.model.io.HWPFOutputStream; import org.apache.poi.util.Internal; import org.apache.poi.util.LittleEndian; +import org.apache.poi.util.POILogFactory; +import org.apache.poi.util.POILogger; /** * The File Information Block (FIB). Holds pointers @@ -45,14 +49,19 @@ import org.apache.poi.util.LittleEndian; @Internal public final class FileInformationBlock implements Cloneable { + public static final POILogger logger = POILogFactory + .getLogger( FileInformationBlock.class ); private FibBase _fibBase; private int _csw; private FibRgW97 _fibRgW; private int _cslw; - private FibRgLw97 _fibRgLw; + private FibRgLw _fibRgLw; private int _cbRgFcLcb; private FIBFieldHandler _fieldHandler; + private int _cswNew; + private int _nFibNew; + private byte[] _fibRgCswNew; /** Creates a new instance of FileInformationBlock */ public FileInformationBlock( byte[] mainDocument ) @@ -63,6 +72,12 @@ public final class FileInformationBlock implements Cloneable offset = FibBase.getSize(); assert offset == 32; + if ( _fibBase.isFEncrypted() ) + { + throw new EncryptedDocumentException( + "Cannot process encrypted word file" ); + } + _csw = LittleEndian.getUShort( mainDocument, offset ); offset += LittleEndian.SHORT_SIZE; assert offset == 34; @@ -75,13 +90,129 @@ public final class FileInformationBlock implements Cloneable offset += LittleEndian.SHORT_SIZE; assert offset == 64; + if ( _fibBase.getNFib() < 105 ) + { + _fibRgLw = new FibRgLw95( mainDocument, offset ); + offset += FibRgLw97.getSize(); + + // magic number, run tests after changes + _cbRgFcLcb = 74; + + // skip fibRgFcLcbBlob (read later at fillVariableFields) + offset += _cbRgFcLcb * LittleEndian.INT_SIZE * 2; + + _cswNew = LittleEndian.getUShort( mainDocument, offset ); + offset += LittleEndian.SHORT_SIZE; + + _cswNew = 0; + _nFibNew = -1; + _fibRgCswNew = new byte[0]; + + return; + } + _fibRgLw = new FibRgLw97( mainDocument, offset ); offset += FibRgLw97.getSize(); assert offset == 152; - + _cbRgFcLcb = LittleEndian.getUShort( mainDocument, offset ); offset += LittleEndian.SHORT_SIZE; assert offset == 154; + + // skip fibRgFcLcbBlob (read later at fillVariableFields) + offset += _cbRgFcLcb * LittleEndian.INT_SIZE * 2; + + _cswNew = LittleEndian.getUShort( mainDocument, offset ); + offset += LittleEndian.SHORT_SIZE; + + if ( _cswNew != 0 ) + { + _nFibNew = LittleEndian.getUShort( mainDocument, offset ); + offset += LittleEndian.SHORT_SIZE; + + // first short is already read as _nFibNew + final int fibRgCswNewLength = ( _cswNew - 1 ) + * LittleEndian.SHORT_SIZE; + _fibRgCswNew = new byte[fibRgCswNewLength]; + LittleEndian.getByteArray( mainDocument, offset, fibRgCswNewLength ); + offset += fibRgCswNewLength; + } + else + { + _nFibNew = -1; + _fibRgCswNew = new byte[0]; + } + + assertCbRgFcLcb(); + assertCswNew(); + } + + private void assertCbRgFcLcb() + { + switch ( getNFib() ) + { + case 0x00C1: + assertCbRgFcLcb( "0x00C1", 0x005D, "0x005D", _cbRgFcLcb ); + break; + case 0x00D9: + assertCbRgFcLcb( "0x00D9", 0x006C, "0x006C", _cbRgFcLcb ); + break; + case 0x0101: + assertCbRgFcLcb( "0x0101", 0x0088, "0x0088", _cbRgFcLcb ); + break; + case 0x010C: + assertCbRgFcLcb( "0x010C", 0x00A4, "0x00A4", _cbRgFcLcb ); + break; + case 0x0112: + assertCbRgFcLcb( "0x0112", 0x00B7, "0x00B7", _cbRgFcLcb ); + break; + } + } + + private static void assertCbRgFcLcb( final String strNFib, + final int expectedCbRgFcLcb, final String strCbRgFcLcb, + final int cbRgFcLcb ) + { + if ( cbRgFcLcb == expectedCbRgFcLcb ) + return; + + logger.log( POILogger.WARN, "Since FIB.nFib == ", strNFib, + " value of FIB.cbRgFcLcb MUST be ", strCbRgFcLcb + ", not 0x", + Integer.toHexString( cbRgFcLcb ) ); + } + + private void assertCswNew() + { + switch ( getNFib() ) + { + case 0x00C1: + assertCswNew( "0x00C1", 0x0000, "0x0000", _cswNew ); + break; + case 0x00D9: + assertCswNew( "0x00D9", 0x0002, "0x0002", _cswNew ); + break; + case 0x0101: + assertCswNew( "0x0101", 0x0002, "0x0002", _cswNew ); + break; + case 0x010C: + assertCswNew( "0x010C", 0x0002, "0x0002", _cswNew ); + break; + case 0x0112: + assertCswNew( "0x0112", 0x0005, "0x0005", _cswNew ); + break; + } + } + + private static void assertCswNew( final String strNFib, + final int expectedCswNew, final String strExpectedCswNew, + final int cswNew ) + { + if ( cswNew == expectedCswNew ) + return; + + logger.log( POILogger.WARN, "Since FIB.nFib == ", strNFib, + " value of FIB.cswNew MUST be ", + strExpectedCswNew + ", not 0x", Integer.toHexString( cswNew ) ); } public void fillVariableFields( byte[] mainDocument, byte[] tableStream ) @@ -198,6 +329,14 @@ public final class FileInformationBlock implements Cloneable return stringBuilder.toString(); } + public int getNFib() + { + if ( _cswNew == 0 ) + return _fibBase.getNFib(); + + return _nFibNew; + } + public int getFcDop() { return _fieldHandler.getFieldOffset(FIBFieldHandler.DOP); @@ -884,13 +1023,26 @@ public final class FileInformationBlock implements Cloneable LittleEndian.putUShort( mainStream, offset, _cslw ); offset += LittleEndian.SHORT_SIZE; - _fibRgLw.serialize( mainStream, offset ); + ( (FibRgLw97) _fibRgLw ).serialize( mainStream, offset ); offset += FibRgLw97.getSize(); LittleEndian.putUShort( mainStream, offset, _cbRgFcLcb ); offset += LittleEndian.SHORT_SIZE; _fieldHandler.writeTo( mainStream, offset, tableStream ); + offset += _cbRgFcLcb * LittleEndian.INT_SIZE * 2; + + LittleEndian.putUShort( mainStream, offset, _cswNew ); + offset += LittleEndian.SHORT_SIZE; + if ( _cswNew != 0 ) + { + LittleEndian.putUShort( mainStream, offset, _nFibNew ); + offset += LittleEndian.SHORT_SIZE; + + System.arraycopy( _fibRgCswNew, 0, mainStream, offset, + _fibRgCswNew.length ); + offset += _fibRgCswNew.length; + } } public int getSize() diff --git a/src/scratchpad/src/org/apache/poi/hwpf/model/types/FibRgLw95AbstractType.java b/src/scratchpad/src/org/apache/poi/hwpf/model/types/FibRgLw95AbstractType.java new file mode 100644 index 0000000000..a67069b4d0 --- /dev/null +++ b/src/scratchpad/src/org/apache/poi/hwpf/model/types/FibRgLw95AbstractType.java @@ -0,0 +1,468 @@ +/* ==================================================================== + 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.Internal; +import org.apache.poi.util.LittleEndian; + +/** + * The FibRgLw95 structure is the third section of the FIB for Word95. + + *

+ * NOTE: This source is automatically generated please do not modify this file. Either subclass or + * remove the record in src/types/definitions. + *

+ * 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 + + */ +@Internal +public abstract class FibRgLw95AbstractType +{ + + protected int field_1_cbMac; + @Deprecated + protected int field_2_reserved1; + @Deprecated + protected int field_3_reserved2; + @Deprecated + protected int field_4_reserved3; + @Deprecated + protected int field_5_reserved4; + protected int field_6_ccpText; + protected int field_7_ccpFtn; + protected int field_8_ccpHdd; + protected int field_9_ccpMcr; + protected int field_10_ccpAtn; + protected int field_11_ccpEdn; + protected int field_12_ccpTxbx; + protected int field_13_ccpHdrTxbx; + @Deprecated + protected int field_14_reserved5; + + protected FibRgLw95AbstractType() + { + } + + protected void fillFields( byte[] data, int offset ) + { + field_1_cbMac = LittleEndian.getInt( data, 0x0 + offset ); + field_2_reserved1 = LittleEndian.getInt( data, 0x4 + offset ); + field_3_reserved2 = LittleEndian.getInt( data, 0x8 + offset ); + field_4_reserved3 = LittleEndian.getInt( data, 0xc + offset ); + field_5_reserved4 = LittleEndian.getInt( data, 0x10 + offset ); + field_6_ccpText = LittleEndian.getInt( data, 0x14 + offset ); + field_7_ccpFtn = LittleEndian.getInt( data, 0x18 + offset ); + field_8_ccpHdd = LittleEndian.getInt( data, 0x1c + offset ); + field_9_ccpMcr = LittleEndian.getInt( data, 0x20 + offset ); + field_10_ccpAtn = LittleEndian.getInt( data, 0x24 + offset ); + field_11_ccpEdn = LittleEndian.getInt( data, 0x28 + offset ); + field_12_ccpTxbx = LittleEndian.getInt( data, 0x2c + offset ); + field_13_ccpHdrTxbx = LittleEndian.getInt( data, 0x30 + offset ); + field_14_reserved5 = LittleEndian.getInt( data, 0x34 + offset ); + } + + public void serialize( byte[] data, int offset ) + { + LittleEndian.putInt( data, 0x0 + offset, field_1_cbMac ); + LittleEndian.putInt( data, 0x4 + offset, field_2_reserved1 ); + LittleEndian.putInt( data, 0x8 + offset, field_3_reserved2 ); + LittleEndian.putInt( data, 0xc + offset, field_4_reserved3 ); + LittleEndian.putInt( data, 0x10 + offset, field_5_reserved4 ); + LittleEndian.putInt( data, 0x14 + offset, field_6_ccpText ); + LittleEndian.putInt( data, 0x18 + offset, field_7_ccpFtn ); + LittleEndian.putInt( data, 0x1c + offset, field_8_ccpHdd ); + LittleEndian.putInt( data, 0x20 + offset, field_9_ccpMcr ); + LittleEndian.putInt( data, 0x24 + offset, field_10_ccpAtn ); + LittleEndian.putInt( data, 0x28 + offset, field_11_ccpEdn ); + LittleEndian.putInt( data, 0x2c + offset, field_12_ccpTxbx ); + LittleEndian.putInt( data, 0x30 + offset, field_13_ccpHdrTxbx ); + LittleEndian.putInt( data, 0x34 + offset, field_14_reserved5 ); + } + + public byte[] serialize() + { + final byte[] result = new byte[ getSize() ]; + serialize( result, 0 ); + return result; + } + + /** + * Size of record + */ + public static int getSize() + { + return 0 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4; + } + + @Override + public boolean equals( Object obj ) + { + if ( this == obj ) + return true; + if ( obj == null ) + return false; + if ( getClass() != obj.getClass() ) + return false; + FibRgLw95AbstractType other = (FibRgLw95AbstractType) obj; + if ( field_1_cbMac != other.field_1_cbMac ) + 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_reserved3 != other.field_4_reserved3 ) + return false; + if ( field_5_reserved4 != other.field_5_reserved4 ) + return false; + if ( field_6_ccpText != other.field_6_ccpText ) + return false; + if ( field_7_ccpFtn != other.field_7_ccpFtn ) + return false; + if ( field_8_ccpHdd != other.field_8_ccpHdd ) + return false; + if ( field_9_ccpMcr != other.field_9_ccpMcr ) + return false; + if ( field_10_ccpAtn != other.field_10_ccpAtn ) + return false; + if ( field_11_ccpEdn != other.field_11_ccpEdn ) + return false; + if ( field_12_ccpTxbx != other.field_12_ccpTxbx ) + return false; + if ( field_13_ccpHdrTxbx != other.field_13_ccpHdrTxbx ) + return false; + if ( field_14_reserved5 != other.field_14_reserved5 ) + return false; + return true; + } + + @Override + public int hashCode() + { + final int prime = 31; + int result = 1; + result = prime * result + field_1_cbMac; + result = prime * result + field_2_reserved1; + result = prime * result + field_3_reserved2; + result = prime * result + field_4_reserved3; + result = prime * result + field_5_reserved4; + result = prime * result + field_6_ccpText; + result = prime * result + field_7_ccpFtn; + result = prime * result + field_8_ccpHdd; + result = prime * result + field_9_ccpMcr; + result = prime * result + field_10_ccpAtn; + result = prime * result + field_11_ccpEdn; + result = prime * result + field_12_ccpTxbx; + result = prime * result + field_13_ccpHdrTxbx; + result = prime * result + field_14_reserved5; + return result; + } + + public String toString() + { + StringBuilder builder = new StringBuilder(); + builder.append("[FibRgLw95]\n"); + builder.append(" .cbMac = "); + builder.append(" (").append(getCbMac()).append(" )\n"); + builder.append(" .reserved1 = "); + builder.append(" (").append(getReserved1()).append(" )\n"); + builder.append(" .reserved2 = "); + builder.append(" (").append(getReserved2()).append(" )\n"); + builder.append(" .reserved3 = "); + builder.append(" (").append(getReserved3()).append(" )\n"); + builder.append(" .reserved4 = "); + builder.append(" (").append(getReserved4()).append(" )\n"); + builder.append(" .ccpText = "); + builder.append(" (").append(getCcpText()).append(" )\n"); + builder.append(" .ccpFtn = "); + builder.append(" (").append(getCcpFtn()).append(" )\n"); + builder.append(" .ccpHdd = "); + builder.append(" (").append(getCcpHdd()).append(" )\n"); + builder.append(" .ccpMcr = "); + builder.append(" (").append(getCcpMcr()).append(" )\n"); + builder.append(" .ccpAtn = "); + builder.append(" (").append(getCcpAtn()).append(" )\n"); + builder.append(" .ccpEdn = "); + builder.append(" (").append(getCcpEdn()).append(" )\n"); + builder.append(" .ccpTxbx = "); + builder.append(" (").append(getCcpTxbx()).append(" )\n"); + builder.append(" .ccpHdrTxbx = "); + builder.append(" (").append(getCcpHdrTxbx()).append(" )\n"); + builder.append(" .reserved5 = "); + builder.append(" (").append(getReserved5()).append(" )\n"); + + builder.append("[/FibRgLw95]\n"); + return builder.toString(); + } + + /** + * Get the cbMac field for the FibRgLw95 record. + */ + @Internal + public int getCbMac() + { + return field_1_cbMac; + } + + /** + * Set the cbMac field for the FibRgLw95 record. + */ + @Internal + public void setCbMac( int field_1_cbMac ) + { + this.field_1_cbMac = field_1_cbMac; + } + + /** + * Get the reserved1 field for the FibRgLw95 record. + */ + @Internal + public int getReserved1() + { + return field_2_reserved1; + } + + /** + * Set the reserved1 field for the FibRgLw95 record. + */ + @Internal + public void setReserved1( int field_2_reserved1 ) + { + this.field_2_reserved1 = field_2_reserved1; + } + + /** + * Get the reserved2 field for the FibRgLw95 record. + */ + @Internal + public int getReserved2() + { + return field_3_reserved2; + } + + /** + * Set the reserved2 field for the FibRgLw95 record. + */ + @Internal + public void setReserved2( int field_3_reserved2 ) + { + this.field_3_reserved2 = field_3_reserved2; + } + + /** + * Get the reserved3 field for the FibRgLw95 record. + */ + @Internal + public int getReserved3() + { + return field_4_reserved3; + } + + /** + * Set the reserved3 field for the FibRgLw95 record. + */ + @Internal + public void setReserved3( int field_4_reserved3 ) + { + this.field_4_reserved3 = field_4_reserved3; + } + + /** + * Get the reserved4 field for the FibRgLw95 record. + */ + @Internal + public int getReserved4() + { + return field_5_reserved4; + } + + /** + * Set the reserved4 field for the FibRgLw95 record. + */ + @Internal + public void setReserved4( int field_5_reserved4 ) + { + this.field_5_reserved4 = field_5_reserved4; + } + + /** + * Get the ccpText field for the FibRgLw95 record. + */ + @Internal + public int getCcpText() + { + return field_6_ccpText; + } + + /** + * Set the ccpText field for the FibRgLw95 record. + */ + @Internal + public void setCcpText( int field_6_ccpText ) + { + this.field_6_ccpText = field_6_ccpText; + } + + /** + * Get the ccpFtn field for the FibRgLw95 record. + */ + @Internal + public int getCcpFtn() + { + return field_7_ccpFtn; + } + + /** + * Set the ccpFtn field for the FibRgLw95 record. + */ + @Internal + public void setCcpFtn( int field_7_ccpFtn ) + { + this.field_7_ccpFtn = field_7_ccpFtn; + } + + /** + * Get the ccpHdd field for the FibRgLw95 record. + */ + @Internal + public int getCcpHdd() + { + return field_8_ccpHdd; + } + + /** + * Set the ccpHdd field for the FibRgLw95 record. + */ + @Internal + public void setCcpHdd( int field_8_ccpHdd ) + { + this.field_8_ccpHdd = field_8_ccpHdd; + } + + /** + * Get the ccpMcr field for the FibRgLw95 record. + */ + @Internal + public int getCcpMcr() + { + return field_9_ccpMcr; + } + + /** + * Set the ccpMcr field for the FibRgLw95 record. + */ + @Internal + public void setCcpMcr( int field_9_ccpMcr ) + { + this.field_9_ccpMcr = field_9_ccpMcr; + } + + /** + * Get the ccpAtn field for the FibRgLw95 record. + */ + @Internal + public int getCcpAtn() + { + return field_10_ccpAtn; + } + + /** + * Set the ccpAtn field for the FibRgLw95 record. + */ + @Internal + public void setCcpAtn( int field_10_ccpAtn ) + { + this.field_10_ccpAtn = field_10_ccpAtn; + } + + /** + * Get the ccpEdn field for the FibRgLw95 record. + */ + @Internal + public int getCcpEdn() + { + return field_11_ccpEdn; + } + + /** + * Set the ccpEdn field for the FibRgLw95 record. + */ + @Internal + public void setCcpEdn( int field_11_ccpEdn ) + { + this.field_11_ccpEdn = field_11_ccpEdn; + } + + /** + * Get the ccpTxbx field for the FibRgLw95 record. + */ + @Internal + public int getCcpTxbx() + { + return field_12_ccpTxbx; + } + + /** + * Set the ccpTxbx field for the FibRgLw95 record. + */ + @Internal + public void setCcpTxbx( int field_12_ccpTxbx ) + { + this.field_12_ccpTxbx = field_12_ccpTxbx; + } + + /** + * Get the ccpHdrTxbx field for the FibRgLw95 record. + */ + @Internal + public int getCcpHdrTxbx() + { + return field_13_ccpHdrTxbx; + } + + /** + * Set the ccpHdrTxbx field for the FibRgLw95 record. + */ + @Internal + public void setCcpHdrTxbx( int field_13_ccpHdrTxbx ) + { + this.field_13_ccpHdrTxbx = field_13_ccpHdrTxbx; + } + + /** + * Get the reserved5 field for the FibRgLw95 record. + */ + @Internal + public int getReserved5() + { + return field_14_reserved5; + } + + /** + * Set the reserved5 field for the FibRgLw95 record. + */ + @Internal + public void setReserved5( int field_14_reserved5 ) + { + this.field_14_reserved5 = field_14_reserved5; + } + +} // END OF CLASS diff --git a/src/scratchpad/src/org/apache/poi/hwpf/model/types/FibRgLw97AbstractType.java b/src/scratchpad/src/org/apache/poi/hwpf/model/types/FibRgLw97AbstractType.java index 45e1cb5b7b..eee5278103 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/model/types/FibRgLw97AbstractType.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/model/types/FibRgLw97AbstractType.java @@ -147,6 +147,93 @@ public abstract class FibRgLw97AbstractType return 0 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4; } + @Override + public boolean equals( Object obj ) + { + if ( this == obj ) + return true; + if ( obj == null ) + return false; + if ( getClass() != obj.getClass() ) + return false; + FibRgLw97AbstractType other = (FibRgLw97AbstractType) obj; + if ( field_1_cbMac != other.field_1_cbMac ) + 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_ccpText != other.field_4_ccpText ) + return false; + if ( field_5_ccpFtn != other.field_5_ccpFtn ) + return false; + if ( field_6_ccpHdd != other.field_6_ccpHdd ) + return false; + if ( field_7_reserved3 != other.field_7_reserved3 ) + return false; + if ( field_8_ccpAtn != other.field_8_ccpAtn ) + return false; + if ( field_9_ccpEdn != other.field_9_ccpEdn ) + return false; + if ( field_10_ccpTxbx != other.field_10_ccpTxbx ) + return false; + if ( field_11_ccpHdrTxbx != other.field_11_ccpHdrTxbx ) + return false; + if ( field_12_reserved4 != other.field_12_reserved4 ) + return false; + if ( field_13_reserved5 != other.field_13_reserved5 ) + return false; + if ( field_14_reserved6 != other.field_14_reserved6 ) + return false; + if ( field_15_reserved7 != other.field_15_reserved7 ) + return false; + if ( field_16_reserved8 != other.field_16_reserved8 ) + return false; + if ( field_17_reserved9 != other.field_17_reserved9 ) + return false; + if ( field_18_reserved10 != other.field_18_reserved10 ) + return false; + if ( field_19_reserved11 != other.field_19_reserved11 ) + return false; + if ( field_20_reserved12 != other.field_20_reserved12 ) + return false; + if ( field_21_reserved13 != other.field_21_reserved13 ) + return false; + if ( field_22_reserved14 != other.field_22_reserved14 ) + return false; + return true; + } + + @Override + public int hashCode() + { + final int prime = 31; + int result = 1; + result = prime * result + field_1_cbMac; + result = prime * result + field_2_reserved1; + result = prime * result + field_3_reserved2; + result = prime * result + field_4_ccpText; + result = prime * result + field_5_ccpFtn; + result = prime * result + field_6_ccpHdd; + result = prime * result + field_7_reserved3; + result = prime * result + field_8_ccpAtn; + result = prime * result + field_9_ccpEdn; + result = prime * result + field_10_ccpTxbx; + result = prime * result + field_11_ccpHdrTxbx; + result = prime * result + field_12_reserved4; + result = prime * result + field_13_reserved5; + result = prime * result + field_14_reserved6; + result = prime * result + field_15_reserved7; + result = prime * result + field_16_reserved8; + result = prime * result + field_17_reserved9; + result = prime * result + field_18_reserved10; + result = prime * result + field_19_reserved11; + result = prime * result + field_20_reserved12; + result = prime * result + field_21_reserved13; + result = prime * result + field_22_reserved14; + return result; + } + public String toString() { StringBuilder builder = new StringBuilder(); diff --git a/src/types/definitions/FibRgLw95_type.xml b/src/types/definitions/FibRgLw95_type.xml new file mode 100644 index 0000000000..74c5dc53a4 --- /dev/null +++ b/src/types/definitions/FibRgLw95_type.xml @@ -0,0 +1,45 @@ + + + + AbstractType + The FibRgLw95 structure is the third section of the FIB for Word95. + + Sergey Vladimirov + + + + + + + + + + + + + + + + + + + + + diff --git a/src/types/styles/hdftype.xsl b/src/types/styles/hdftype.xsl index 5c6d01200c..b511a9e6d9 100644 --- a/src/types/styles/hdftype.xsl +++ b/src/types/styles/hdftype.xsl @@ -25,6 +25,11 @@ + + + + + @@ -45,7 +50,7 @@ import org.apache.poi.util.*; */ @Internal -public abstract class AbstractType +public abstract class { @@ -196,6 +201,78 @@ public abstract class Abstrac + + + + @Override + + + public boolean equals( Object obj ) + { + if ( this == obj ) + return true; + if ( obj == null ) + return false; + if ( getClass() != obj.getClass() ) + return false; + + + + + other = ( + + ) obj; + + + + + if ( + + != other. + + ) + + + + + return false; + + + + + return true; + + + } + + + + + + @Override + + + public int hashCode() + { + final int prime = 31; + int result = 1; + + + + + result = prime * result + + + ; + + + + + return result; + + + } + + public String toString() -- 2.39.5