// 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 {
--- /dev/null
+/* ====================================================================
+ 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 );
+}
--- /dev/null
+/* ====================================================================
+ 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.
+ * <p>
+ * 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 );
+ }
+
+}
* (.doc) Binary File Format
*/
@Internal
-class FibRgLw97 extends FibRgLw97AbstractType
+class FibRgLw97 extends FibRgLw97AbstractType implements FibRgLw
{
public FibRgLw97()
+ 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;
- }
-
}
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
@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 )
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;
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 )
return stringBuilder.toString();
}
+ public int getNFib()
+ {
+ if ( _cswNew == 0 )
+ return _fibBase.getNFib();
+
+ return _nFibNew;
+ }
+
public int getFcDop()
{
return _fieldHandler.getFieldOffset(FIBFieldHandler.DOP);
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()
--- /dev/null
+/* ====================================================================\r
+ Licensed to the Apache Software Foundation (ASF) under one or more\r
+ contributor license agreements. See the NOTICE file distributed with\r
+ this work for additional information regarding copyright ownership.\r
+ The ASF licenses this file to You under the Apache License, Version 2.0\r
+ (the "License"); you may not use this file except in compliance with\r
+ the License. You may obtain a copy of the License at\r
+\r
+ http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+ Unless required by applicable law or agreed to in writing, software\r
+ distributed under the License is distributed on an "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ See the License for the specific language governing permissions and\r
+ limitations under the License.\r
+==================================================================== */\r
+\r
+\r
+package org.apache.poi.hwpf.model.types;\r
+\r
+import org.apache.poi.util.Internal;\r
+import org.apache.poi.util.LittleEndian;\r
+\r
+/**\r
+ * The FibRgLw95 structure is the third section of the FIB for Word95.\r
+ \r
+ * <p>\r
+ * NOTE: This source is automatically generated please do not modify this file. Either subclass or\r
+ * remove the record in src/types/definitions.\r
+ * <p>\r
+ * This class is internal. It content or properties may change without notice \r
+ * due to changes in our knowledge of internal Microsoft Word binary structures.\r
+\r
+ * @author Sergey Vladimirov\r
+ \r
+ */\r
+@Internal\r
+public abstract class FibRgLw95AbstractType\r
+{\r
+\r
+ protected int field_1_cbMac;\r
+ @Deprecated\r
+ protected int field_2_reserved1;\r
+ @Deprecated\r
+ protected int field_3_reserved2;\r
+ @Deprecated\r
+ protected int field_4_reserved3;\r
+ @Deprecated\r
+ protected int field_5_reserved4;\r
+ protected int field_6_ccpText;\r
+ protected int field_7_ccpFtn;\r
+ protected int field_8_ccpHdd;\r
+ protected int field_9_ccpMcr;\r
+ protected int field_10_ccpAtn;\r
+ protected int field_11_ccpEdn;\r
+ protected int field_12_ccpTxbx;\r
+ protected int field_13_ccpHdrTxbx;\r
+ @Deprecated\r
+ protected int field_14_reserved5;\r
+\r
+ protected FibRgLw95AbstractType()\r
+ {\r
+ }\r
+\r
+ protected void fillFields( byte[] data, int offset )\r
+ {\r
+ field_1_cbMac = LittleEndian.getInt( data, 0x0 + offset );\r
+ field_2_reserved1 = LittleEndian.getInt( data, 0x4 + offset );\r
+ field_3_reserved2 = LittleEndian.getInt( data, 0x8 + offset );\r
+ field_4_reserved3 = LittleEndian.getInt( data, 0xc + offset );\r
+ field_5_reserved4 = LittleEndian.getInt( data, 0x10 + offset );\r
+ field_6_ccpText = LittleEndian.getInt( data, 0x14 + offset );\r
+ field_7_ccpFtn = LittleEndian.getInt( data, 0x18 + offset );\r
+ field_8_ccpHdd = LittleEndian.getInt( data, 0x1c + offset );\r
+ field_9_ccpMcr = LittleEndian.getInt( data, 0x20 + offset );\r
+ field_10_ccpAtn = LittleEndian.getInt( data, 0x24 + offset );\r
+ field_11_ccpEdn = LittleEndian.getInt( data, 0x28 + offset );\r
+ field_12_ccpTxbx = LittleEndian.getInt( data, 0x2c + offset );\r
+ field_13_ccpHdrTxbx = LittleEndian.getInt( data, 0x30 + offset );\r
+ field_14_reserved5 = LittleEndian.getInt( data, 0x34 + offset );\r
+ }\r
+\r
+ public void serialize( byte[] data, int offset )\r
+ {\r
+ LittleEndian.putInt( data, 0x0 + offset, field_1_cbMac );\r
+ LittleEndian.putInt( data, 0x4 + offset, field_2_reserved1 );\r
+ LittleEndian.putInt( data, 0x8 + offset, field_3_reserved2 );\r
+ LittleEndian.putInt( data, 0xc + offset, field_4_reserved3 );\r
+ LittleEndian.putInt( data, 0x10 + offset, field_5_reserved4 );\r
+ LittleEndian.putInt( data, 0x14 + offset, field_6_ccpText );\r
+ LittleEndian.putInt( data, 0x18 + offset, field_7_ccpFtn );\r
+ LittleEndian.putInt( data, 0x1c + offset, field_8_ccpHdd );\r
+ LittleEndian.putInt( data, 0x20 + offset, field_9_ccpMcr );\r
+ LittleEndian.putInt( data, 0x24 + offset, field_10_ccpAtn );\r
+ LittleEndian.putInt( data, 0x28 + offset, field_11_ccpEdn );\r
+ LittleEndian.putInt( data, 0x2c + offset, field_12_ccpTxbx );\r
+ LittleEndian.putInt( data, 0x30 + offset, field_13_ccpHdrTxbx );\r
+ LittleEndian.putInt( data, 0x34 + offset, field_14_reserved5 );\r
+ }\r
+\r
+ public byte[] serialize()\r
+ {\r
+ final byte[] result = new byte[ getSize() ];\r
+ serialize( result, 0 );\r
+ return result;\r
+ }\r
+\r
+ /**\r
+ * Size of record\r
+ */\r
+ public static int getSize()\r
+ {\r
+ return 0 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4;\r
+ }\r
+\r
+ @Override\r
+ public boolean equals( Object obj )\r
+ {\r
+ if ( this == obj )\r
+ return true;\r
+ if ( obj == null )\r
+ return false;\r
+ if ( getClass() != obj.getClass() )\r
+ return false;\r
+ FibRgLw95AbstractType other = (FibRgLw95AbstractType) obj;\r
+ if ( field_1_cbMac != other.field_1_cbMac )\r
+ return false;\r
+ if ( field_2_reserved1 != other.field_2_reserved1 )\r
+ return false;\r
+ if ( field_3_reserved2 != other.field_3_reserved2 )\r
+ return false;\r
+ if ( field_4_reserved3 != other.field_4_reserved3 )\r
+ return false;\r
+ if ( field_5_reserved4 != other.field_5_reserved4 )\r
+ return false;\r
+ if ( field_6_ccpText != other.field_6_ccpText )\r
+ return false;\r
+ if ( field_7_ccpFtn != other.field_7_ccpFtn )\r
+ return false;\r
+ if ( field_8_ccpHdd != other.field_8_ccpHdd )\r
+ return false;\r
+ if ( field_9_ccpMcr != other.field_9_ccpMcr )\r
+ return false;\r
+ if ( field_10_ccpAtn != other.field_10_ccpAtn )\r
+ return false;\r
+ if ( field_11_ccpEdn != other.field_11_ccpEdn )\r
+ return false;\r
+ if ( field_12_ccpTxbx != other.field_12_ccpTxbx )\r
+ return false;\r
+ if ( field_13_ccpHdrTxbx != other.field_13_ccpHdrTxbx )\r
+ return false;\r
+ if ( field_14_reserved5 != other.field_14_reserved5 )\r
+ return false;\r
+ return true;\r
+ }\r
+\r
+ @Override\r
+ public int hashCode()\r
+ {\r
+ final int prime = 31;\r
+ int result = 1;\r
+ result = prime * result + field_1_cbMac;\r
+ result = prime * result + field_2_reserved1;\r
+ result = prime * result + field_3_reserved2;\r
+ result = prime * result + field_4_reserved3;\r
+ result = prime * result + field_5_reserved4;\r
+ result = prime * result + field_6_ccpText;\r
+ result = prime * result + field_7_ccpFtn;\r
+ result = prime * result + field_8_ccpHdd;\r
+ result = prime * result + field_9_ccpMcr;\r
+ result = prime * result + field_10_ccpAtn;\r
+ result = prime * result + field_11_ccpEdn;\r
+ result = prime * result + field_12_ccpTxbx;\r
+ result = prime * result + field_13_ccpHdrTxbx;\r
+ result = prime * result + field_14_reserved5;\r
+ return result;\r
+ }\r
+\r
+ public String toString()\r
+ {\r
+ StringBuilder builder = new StringBuilder();\r
+ builder.append("[FibRgLw95]\n");\r
+ builder.append(" .cbMac = ");\r
+ builder.append(" (").append(getCbMac()).append(" )\n");\r
+ builder.append(" .reserved1 = ");\r
+ builder.append(" (").append(getReserved1()).append(" )\n");\r
+ builder.append(" .reserved2 = ");\r
+ builder.append(" (").append(getReserved2()).append(" )\n");\r
+ builder.append(" .reserved3 = ");\r
+ builder.append(" (").append(getReserved3()).append(" )\n");\r
+ builder.append(" .reserved4 = ");\r
+ builder.append(" (").append(getReserved4()).append(" )\n");\r
+ builder.append(" .ccpText = ");\r
+ builder.append(" (").append(getCcpText()).append(" )\n");\r
+ builder.append(" .ccpFtn = ");\r
+ builder.append(" (").append(getCcpFtn()).append(" )\n");\r
+ builder.append(" .ccpHdd = ");\r
+ builder.append(" (").append(getCcpHdd()).append(" )\n");\r
+ builder.append(" .ccpMcr = ");\r
+ builder.append(" (").append(getCcpMcr()).append(" )\n");\r
+ builder.append(" .ccpAtn = ");\r
+ builder.append(" (").append(getCcpAtn()).append(" )\n");\r
+ builder.append(" .ccpEdn = ");\r
+ builder.append(" (").append(getCcpEdn()).append(" )\n");\r
+ builder.append(" .ccpTxbx = ");\r
+ builder.append(" (").append(getCcpTxbx()).append(" )\n");\r
+ builder.append(" .ccpHdrTxbx = ");\r
+ builder.append(" (").append(getCcpHdrTxbx()).append(" )\n");\r
+ builder.append(" .reserved5 = ");\r
+ builder.append(" (").append(getReserved5()).append(" )\n");\r
+\r
+ builder.append("[/FibRgLw95]\n");\r
+ return builder.toString();\r
+ }\r
+\r
+ /**\r
+ * Get the cbMac field for the FibRgLw95 record.\r
+ */\r
+ @Internal\r
+ public int getCbMac()\r
+ {\r
+ return field_1_cbMac;\r
+ }\r
+\r
+ /**\r
+ * Set the cbMac field for the FibRgLw95 record.\r
+ */\r
+ @Internal\r
+ public void setCbMac( int field_1_cbMac )\r
+ {\r
+ this.field_1_cbMac = field_1_cbMac;\r
+ }\r
+\r
+ /**\r
+ * Get the reserved1 field for the FibRgLw95 record.\r
+ */\r
+ @Internal\r
+ public int getReserved1()\r
+ {\r
+ return field_2_reserved1;\r
+ }\r
+\r
+ /**\r
+ * Set the reserved1 field for the FibRgLw95 record.\r
+ */\r
+ @Internal\r
+ public void setReserved1( int field_2_reserved1 )\r
+ {\r
+ this.field_2_reserved1 = field_2_reserved1;\r
+ }\r
+\r
+ /**\r
+ * Get the reserved2 field for the FibRgLw95 record.\r
+ */\r
+ @Internal\r
+ public int getReserved2()\r
+ {\r
+ return field_3_reserved2;\r
+ }\r
+\r
+ /**\r
+ * Set the reserved2 field for the FibRgLw95 record.\r
+ */\r
+ @Internal\r
+ public void setReserved2( int field_3_reserved2 )\r
+ {\r
+ this.field_3_reserved2 = field_3_reserved2;\r
+ }\r
+\r
+ /**\r
+ * Get the reserved3 field for the FibRgLw95 record.\r
+ */\r
+ @Internal\r
+ public int getReserved3()\r
+ {\r
+ return field_4_reserved3;\r
+ }\r
+\r
+ /**\r
+ * Set the reserved3 field for the FibRgLw95 record.\r
+ */\r
+ @Internal\r
+ public void setReserved3( int field_4_reserved3 )\r
+ {\r
+ this.field_4_reserved3 = field_4_reserved3;\r
+ }\r
+\r
+ /**\r
+ * Get the reserved4 field for the FibRgLw95 record.\r
+ */\r
+ @Internal\r
+ public int getReserved4()\r
+ {\r
+ return field_5_reserved4;\r
+ }\r
+\r
+ /**\r
+ * Set the reserved4 field for the FibRgLw95 record.\r
+ */\r
+ @Internal\r
+ public void setReserved4( int field_5_reserved4 )\r
+ {\r
+ this.field_5_reserved4 = field_5_reserved4;\r
+ }\r
+\r
+ /**\r
+ * Get the ccpText field for the FibRgLw95 record.\r
+ */\r
+ @Internal\r
+ public int getCcpText()\r
+ {\r
+ return field_6_ccpText;\r
+ }\r
+\r
+ /**\r
+ * Set the ccpText field for the FibRgLw95 record.\r
+ */\r
+ @Internal\r
+ public void setCcpText( int field_6_ccpText )\r
+ {\r
+ this.field_6_ccpText = field_6_ccpText;\r
+ }\r
+\r
+ /**\r
+ * Get the ccpFtn field for the FibRgLw95 record.\r
+ */\r
+ @Internal\r
+ public int getCcpFtn()\r
+ {\r
+ return field_7_ccpFtn;\r
+ }\r
+\r
+ /**\r
+ * Set the ccpFtn field for the FibRgLw95 record.\r
+ */\r
+ @Internal\r
+ public void setCcpFtn( int field_7_ccpFtn )\r
+ {\r
+ this.field_7_ccpFtn = field_7_ccpFtn;\r
+ }\r
+\r
+ /**\r
+ * Get the ccpHdd field for the FibRgLw95 record.\r
+ */\r
+ @Internal\r
+ public int getCcpHdd()\r
+ {\r
+ return field_8_ccpHdd;\r
+ }\r
+\r
+ /**\r
+ * Set the ccpHdd field for the FibRgLw95 record.\r
+ */\r
+ @Internal\r
+ public void setCcpHdd( int field_8_ccpHdd )\r
+ {\r
+ this.field_8_ccpHdd = field_8_ccpHdd;\r
+ }\r
+\r
+ /**\r
+ * Get the ccpMcr field for the FibRgLw95 record.\r
+ */\r
+ @Internal\r
+ public int getCcpMcr()\r
+ {\r
+ return field_9_ccpMcr;\r
+ }\r
+\r
+ /**\r
+ * Set the ccpMcr field for the FibRgLw95 record.\r
+ */\r
+ @Internal\r
+ public void setCcpMcr( int field_9_ccpMcr )\r
+ {\r
+ this.field_9_ccpMcr = field_9_ccpMcr;\r
+ }\r
+\r
+ /**\r
+ * Get the ccpAtn field for the FibRgLw95 record.\r
+ */\r
+ @Internal\r
+ public int getCcpAtn()\r
+ {\r
+ return field_10_ccpAtn;\r
+ }\r
+\r
+ /**\r
+ * Set the ccpAtn field for the FibRgLw95 record.\r
+ */\r
+ @Internal\r
+ public void setCcpAtn( int field_10_ccpAtn )\r
+ {\r
+ this.field_10_ccpAtn = field_10_ccpAtn;\r
+ }\r
+\r
+ /**\r
+ * Get the ccpEdn field for the FibRgLw95 record.\r
+ */\r
+ @Internal\r
+ public int getCcpEdn()\r
+ {\r
+ return field_11_ccpEdn;\r
+ }\r
+\r
+ /**\r
+ * Set the ccpEdn field for the FibRgLw95 record.\r
+ */\r
+ @Internal\r
+ public void setCcpEdn( int field_11_ccpEdn )\r
+ {\r
+ this.field_11_ccpEdn = field_11_ccpEdn;\r
+ }\r
+\r
+ /**\r
+ * Get the ccpTxbx field for the FibRgLw95 record.\r
+ */\r
+ @Internal\r
+ public int getCcpTxbx()\r
+ {\r
+ return field_12_ccpTxbx;\r
+ }\r
+\r
+ /**\r
+ * Set the ccpTxbx field for the FibRgLw95 record.\r
+ */\r
+ @Internal\r
+ public void setCcpTxbx( int field_12_ccpTxbx )\r
+ {\r
+ this.field_12_ccpTxbx = field_12_ccpTxbx;\r
+ }\r
+\r
+ /**\r
+ * Get the ccpHdrTxbx field for the FibRgLw95 record.\r
+ */\r
+ @Internal\r
+ public int getCcpHdrTxbx()\r
+ {\r
+ return field_13_ccpHdrTxbx;\r
+ }\r
+\r
+ /**\r
+ * Set the ccpHdrTxbx field for the FibRgLw95 record.\r
+ */\r
+ @Internal\r
+ public void setCcpHdrTxbx( int field_13_ccpHdrTxbx )\r
+ {\r
+ this.field_13_ccpHdrTxbx = field_13_ccpHdrTxbx;\r
+ }\r
+\r
+ /**\r
+ * Get the reserved5 field for the FibRgLw95 record.\r
+ */\r
+ @Internal\r
+ public int getReserved5()\r
+ {\r
+ return field_14_reserved5;\r
+ }\r
+\r
+ /**\r
+ * Set the reserved5 field for the FibRgLw95 record.\r
+ */\r
+ @Internal\r
+ public void setReserved5( int field_14_reserved5 )\r
+ {\r
+ this.field_14_reserved5 = field_14_reserved5;\r
+ }\r
+\r
+} // END OF CLASS\r
return 0 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4;\r
}\r
\r
+ @Override\r
+ public boolean equals( Object obj )\r
+ {\r
+ if ( this == obj )\r
+ return true;\r
+ if ( obj == null )\r
+ return false;\r
+ if ( getClass() != obj.getClass() )\r
+ return false;\r
+ FibRgLw97AbstractType other = (FibRgLw97AbstractType) obj;\r
+ if ( field_1_cbMac != other.field_1_cbMac )\r
+ return false;\r
+ if ( field_2_reserved1 != other.field_2_reserved1 )\r
+ return false;\r
+ if ( field_3_reserved2 != other.field_3_reserved2 )\r
+ return false;\r
+ if ( field_4_ccpText != other.field_4_ccpText )\r
+ return false;\r
+ if ( field_5_ccpFtn != other.field_5_ccpFtn )\r
+ return false;\r
+ if ( field_6_ccpHdd != other.field_6_ccpHdd )\r
+ return false;\r
+ if ( field_7_reserved3 != other.field_7_reserved3 )\r
+ return false;\r
+ if ( field_8_ccpAtn != other.field_8_ccpAtn )\r
+ return false;\r
+ if ( field_9_ccpEdn != other.field_9_ccpEdn )\r
+ return false;\r
+ if ( field_10_ccpTxbx != other.field_10_ccpTxbx )\r
+ return false;\r
+ if ( field_11_ccpHdrTxbx != other.field_11_ccpHdrTxbx )\r
+ return false;\r
+ if ( field_12_reserved4 != other.field_12_reserved4 )\r
+ return false;\r
+ if ( field_13_reserved5 != other.field_13_reserved5 )\r
+ return false;\r
+ if ( field_14_reserved6 != other.field_14_reserved6 )\r
+ return false;\r
+ if ( field_15_reserved7 != other.field_15_reserved7 )\r
+ return false;\r
+ if ( field_16_reserved8 != other.field_16_reserved8 )\r
+ return false;\r
+ if ( field_17_reserved9 != other.field_17_reserved9 )\r
+ return false;\r
+ if ( field_18_reserved10 != other.field_18_reserved10 )\r
+ return false;\r
+ if ( field_19_reserved11 != other.field_19_reserved11 )\r
+ return false;\r
+ if ( field_20_reserved12 != other.field_20_reserved12 )\r
+ return false;\r
+ if ( field_21_reserved13 != other.field_21_reserved13 )\r
+ return false;\r
+ if ( field_22_reserved14 != other.field_22_reserved14 )\r
+ return false;\r
+ return true;\r
+ }\r
+\r
+ @Override\r
+ public int hashCode()\r
+ {\r
+ final int prime = 31;\r
+ int result = 1;\r
+ result = prime * result + field_1_cbMac;\r
+ result = prime * result + field_2_reserved1;\r
+ result = prime * result + field_3_reserved2;\r
+ result = prime * result + field_4_ccpText;\r
+ result = prime * result + field_5_ccpFtn;\r
+ result = prime * result + field_6_ccpHdd;\r
+ result = prime * result + field_7_reserved3;\r
+ result = prime * result + field_8_ccpAtn;\r
+ result = prime * result + field_9_ccpEdn;\r
+ result = prime * result + field_10_ccpTxbx;\r
+ result = prime * result + field_11_ccpHdrTxbx;\r
+ result = prime * result + field_12_reserved4;\r
+ result = prime * result + field_13_reserved5;\r
+ result = prime * result + field_14_reserved6;\r
+ result = prime * result + field_15_reserved7;\r
+ result = prime * result + field_16_reserved8;\r
+ result = prime * result + field_17_reserved9;\r
+ result = prime * result + field_18_reserved10;\r
+ result = prime * result + field_19_reserved11;\r
+ result = prime * result + field_20_reserved12;\r
+ result = prime * result + field_21_reserved13;\r
+ result = prime * result + field_22_reserved14;\r
+ return result;\r
+ }\r
+\r
public String toString()\r
{\r
StringBuilder builder = new StringBuilder();\r
--- /dev/null
+<?xml version="1.0"?>\r
+<!--\r
+ ====================================================================\r
+ Licensed to the Apache Software Foundation (ASF) under one or more\r
+ contributor license agreements. See the NOTICE file distributed with\r
+ this work for additional information regarding copyright ownership.\r
+ The ASF licenses this file to You under the Apache License, Version 2.0\r
+ (the "License"); you may not use this file except in compliance with\r
+ the License. You may obtain a copy of the License at\r
+\r
+ http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+ Unless required by applicable law or agreed to in writing, software\r
+ distributed under the License is distributed on an "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ See the License for the specific language governing permissions and\r
+ limitations under the License.\r
+ ====================================================================\r
+-->\r
+<record fromfile="true" name="FibRgLw95" package="org.apache.poi.hwpf.model.types">\r
+ <suffix>AbstractType</suffix>\r
+ <description>The FibRgLw95 structure is the third section of the FIB for Word95.\r
+ </description>\r
+ <author>Sergey Vladimirov\r
+ </author>\r
+ <fields>\r
+ <field type="int" size="4" name="cbMac"/>\r
+\r
+ <field type="int" size="4" name="reserved1" deprecated="true"/>\r
+ <field type="int" size="4" name="reserved2" deprecated="true"/>\r
+ <field type="int" size="4" name="reserved3" deprecated="true"/>\r
+ <field type="int" size="4" name="reserved4" deprecated="true"/>\r
+\r
+ <field type="int" size="4" name="ccpText"/>\r
+ <field type="int" size="4" name="ccpFtn"/>\r
+ <field type="int" size="4" name="ccpHdd"/>\r
+ <field type="int" size="4" name="ccpMcr"/>\r
+ <field type="int" size="4" name="ccpAtn"/>\r
+ <field type="int" size="4" name="ccpEdn"/>\r
+ <field type="int" size="4" name="ccpTxbx"/>\r
+ <field type="int" size="4" name="ccpHdrTxbx"/>\r
+\r
+ <field type="int" size="4" name="reserved5" deprecated="true"/>\r
+ </fields>\r
+</record>\r
<xsl:output method="text"/>
+ <xsl:template name="outputClassName">
+ <xsl:value-of select="/record/@name"/>
+ <xsl:value-of select="/record/suffix"/>
+ </xsl:template>
+
<xsl:template match="record">
<xsl:if test="@package">
<xsl:apply-templates select="author"/><xsl:text>
*/
@Internal
-public abstract class </xsl:text><xsl:value-of select="@name"/><xsl:text>AbstractType
+public abstract class </xsl:text><xsl:call-template name="outputClassName"/><xsl:text>
{
</xsl:text>
<xsl:call-template name="linebreak"/>
</xsl:if>
+ <!-- equals() -->
+ <xsl:call-template name="linebreak"/>
+ <xsl:call-template name="indent"/>
+ <xsl:text>@Override</xsl:text>
+ <xsl:call-template name="linebreak"/>
+ <xsl:call-template name="indent"/>
+ <xsl:text>public boolean equals( Object obj )
+ {
+ if ( this == obj )
+ return true;
+ if ( obj == null )
+ return false;
+ if ( getClass() != obj.getClass() )
+ return false;
+</xsl:text>
+ <xsl:call-template name="indent"/>
+ <xsl:call-template name="indent"/>
+ <xsl:call-template name="outputClassName"/>
+ <xsl:text> other = (</xsl:text>
+ <xsl:call-template name="outputClassName"/>
+ <xsl:text>) obj;</xsl:text>
+ <xsl:call-template name="linebreak"/>
+ <xsl:for-each select="//fields/field">
+ <xsl:call-template name="indent"/>
+ <xsl:call-template name="indent"/>
+ <xsl:text>if ( </xsl:text>
+ <xsl:value-of select="recutil:getFieldName(position(),@name,0)"/>
+ <xsl:text> != other.</xsl:text>
+ <xsl:value-of select="recutil:getFieldName(position(),@name,0)"/>
+ <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"/>
+ <xsl:text>return true;</xsl:text>
+ <xsl:call-template name="linebreak"/>
+ <xsl:call-template name="indent"/>
+ <xsl:text>}</xsl:text>
+ <xsl:call-template name="linebreak"/>
+
+ <!-- hashCode() -->
+ <xsl:call-template name="linebreak"/>
+ <xsl:call-template name="indent"/>
+ <xsl:text>@Override</xsl:text>
+ <xsl:call-template name="linebreak"/>
+ <xsl:call-template name="indent"/>
+ <xsl:text>public int hashCode()
+ {
+ final int prime = 31;
+ int result = 1;
+</xsl:text>
+ <xsl:for-each select="//fields/field">
+ <xsl:call-template name="indent"/>
+ <xsl:call-template name="indent"/>
+ <xsl:text>result = prime * result + </xsl:text>
+ <xsl:value-of select="recutil:getFieldName(position(),@name,0)"/>
+ <xsl:text>;</xsl:text>
+ <xsl:call-template name="linebreak"/>
+ </xsl:for-each>
+ <xsl:call-template name="indent"/>
+ <xsl:call-template name="indent"/>
+ <xsl:text>return result;</xsl:text>
+ <xsl:call-template name="linebreak"/>
+ <xsl:call-template name="indent"/>
+ <xsl:text>}</xsl:text>
+ <xsl:call-template name="linebreak"/>
+
<xsl:call-template name="linebreak"/>
<xsl:call-template name="indent"/>
<xsl:text>public String toString()