From b29c0af97c85339b99ae411b79536f8583d91b6d Mon Sep 17 00:00:00 2001 From: Sergey Vladimirov Date: Sat, 1 Oct 2011 15:32:32 +0000 Subject: [PATCH] extract FibBase from FIB git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1178019 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/org/apache/poi/hwpf/HWPFDocument.java | 10 +- .../org/apache/poi/hwpf/HWPFDocumentCore.java | 2 +- .../org/apache/poi/hwpf/HWPFOldDocument.java | 18 +- .../org/apache/poi/hwpf/model/FibBase.java | 111 +++ .../poi/hwpf/model/FileInformationBlock.java | 55 +- .../poi/hwpf/model/types/FIBAbstractType.java | 759 ---------------- .../hwpf/model/types/FibBaseAbstractType.java | 837 ++++++++++++++++++ .../org/apache/poi/hwpf/HWPFDocFixture.java | 2 +- .../poi/hwpf/model/TestCHPBinTable.java | 2 +- .../hwpf/model/TestFileInformationBlock.java | 2 +- .../poi/hwpf/model/TestSectionTable.java | 2 +- .../poi/hwpf/model/TestTextPieceTable.java | 2 +- src/types/definitions/FibBase_type.xml | 94 ++ src/types/definitions/fib_type.xml | 374 -------- src/types/styles/hdftype.xsl | 29 +- 15 files changed, 1112 insertions(+), 1187 deletions(-) create mode 100644 src/scratchpad/src/org/apache/poi/hwpf/model/FibBase.java delete mode 100644 src/scratchpad/src/org/apache/poi/hwpf/model/types/FIBAbstractType.java create mode 100644 src/scratchpad/src/org/apache/poi/hwpf/model/types/FibBaseAbstractType.java create mode 100644 src/types/definitions/FibBase_type.xml delete mode 100644 src/types/definitions/fib_type.xml diff --git a/src/scratchpad/src/org/apache/poi/hwpf/HWPFDocument.java b/src/scratchpad/src/org/apache/poi/hwpf/HWPFDocument.java index 8bffbb50e4..0c63041732 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/HWPFDocument.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/HWPFDocument.java @@ -226,13 +226,13 @@ public final class HWPFDocument extends HWPFDocumentCore _cpSplit = new CPSplitCalculator(_fib); // Is this document too old for us? - if(_fib.getNFib() < 106) { + if(_fib.getFibBase().getNFib() < 106) { throw new OldWordFileFormatException("The document is too old - Word 95 or older. Try HWPFOldDocument instead?"); } // use the fib to determine the name of the table stream. String name = STREAM_TABLE_0; - if (_fib.isFWhichTblStm()) + if (_fib.getFibBase().isFWhichTblStm()) { name = STREAM_TABLE_1; } @@ -904,8 +904,8 @@ public final class HWPFDocument extends HWPFDocumentCore tableOffset = tableStream.getOffset(); // set some variables in the FileInformationBlock. - _fib.setFcMin(fcMin); - _fib.setFcMac(fcMac); + _fib.getFibBase().setFcMin(fcMin); + _fib.getFibBase().setFcMac(fcMac); _fib.setCbMac(wordDocumentStream.getOffset()); // make sure that the table, doc and data streams use big blocks. @@ -918,7 +918,7 @@ public final class HWPFDocument extends HWPFDocumentCore } // Table1 stream will be used - _fib.setFWhichTblStm( true ); + _fib.getFibBase().setFWhichTblStm( true ); // write out the FileInformationBlock. //_fib.serialize(mainBuf, 0); diff --git a/src/scratchpad/src/org/apache/poi/hwpf/HWPFDocumentCore.java b/src/scratchpad/src/org/apache/poi/hwpf/HWPFDocumentCore.java index 4779cad53e..4ffb81a741 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/HWPFDocumentCore.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/HWPFDocumentCore.java @@ -154,7 +154,7 @@ public abstract class HWPFDocumentCore extends POIDocument // Create our FIB, and check for the doc being encrypted _fib = new FileInformationBlock(_mainStream); - if (_fib.isFEncrypted()) { + if (_fib.getFibBase().isFEncrypted()) { throw new EncryptedDocumentException("Cannot process encrypted word files!"); } diff --git a/src/scratchpad/src/org/apache/poi/hwpf/HWPFOldDocument.java b/src/scratchpad/src/org/apache/poi/hwpf/HWPFOldDocument.java index 2d636e06c7..58fb26b1b3 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/HWPFOldDocument.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/HWPFOldDocument.java @@ -67,10 +67,10 @@ public class HWPFOldDocument extends HWPFDocumentCore { // We need to get hold of the text that makes up the // document, which might be regular or fast-saved StringBuffer text = new StringBuffer(); - if(_fib.isFComplex()) { + if(_fib.getFibBase().isFComplex()) { ComplexFileTable cft = new ComplexFileTable( _mainStream, _mainStream, - complexTableOffset, _fib.getFcMin() + complexTableOffset, _fib.getFibBase().getFcMin() ); tpt = cft.getTextPieceTable(); @@ -83,13 +83,13 @@ public class HWPFOldDocument extends HWPFDocumentCore { // TODO Build the Piece Descriptor properly // (We have to fake it, as they don't seem to have a proper Piece table) PieceDescriptor pd = new PieceDescriptor(new byte[] {0,0, 0,0,0,127, 0,0}, 0); - pd.setFilePosition(_fib.getFcMin()); + pd.setFilePosition(_fib.getFibBase().getFcMin()); // Generate a single Text Piece Table, with a single Text Piece // which covers all the (8 bit only) text in the file tpt = new TextPieceTable(); - byte[] textData = new byte[_fib.getFcMac()-_fib.getFcMin()]; - System.arraycopy(_mainStream, _fib.getFcMin(), textData, 0, textData.length); + byte[] textData = new byte[_fib.getFibBase().getFcMac()-_fib.getFibBase().getFcMin()]; + System.arraycopy(_mainStream, _fib.getFibBase().getFcMin(), textData, 0, textData.length); TextPiece tp = new TextPiece( 0, textData.length, textData, pd ); @@ -103,22 +103,22 @@ public class HWPFOldDocument extends HWPFDocumentCore { // Now we can fetch the character and paragraph properties _cbt = new OldCHPBinTable( _mainStream, chpTableOffset, chpTableSize, - _fib.getFcMin(), tpt + _fib.getFibBase().getFcMin(), tpt ); _pbt = new OldPAPBinTable( _mainStream, papTableOffset, papTableSize, - _fib.getFcMin(), tpt + _fib.getFibBase().getFcMin(), tpt ); _st = new OldSectionTable( _mainStream, sedTableOffset, sedTableSize, - _fib.getFcMin(), tpt + _fib.getFibBase().getFcMin(), tpt ); } public Range getOverallRange() { // Life is easy when we have no footers, headers or unicode! - return new Range( 0, _fib.getFcMac() - _fib.getFcMin(), this ); + return new Range( 0, _fib.getFibBase().getFcMac() - _fib.getFibBase().getFcMin(), this ); } public Range getRange() diff --git a/src/scratchpad/src/org/apache/poi/hwpf/model/FibBase.java b/src/scratchpad/src/org/apache/poi/hwpf/model/FibBase.java new file mode 100644 index 0000000000..e7734a9539 --- /dev/null +++ b/src/scratchpad/src/org/apache/poi/hwpf/model/FibBase.java @@ -0,0 +1,111 @@ +/* ==================================================================== + 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.FibBaseAbstractType; +import org.apache.poi.util.Internal; + +/** + * Base part of the File information Block (FibBase). Holds the core part of the + * FIB, from the first 32 bytes. + *

+ * 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 Andrew C. Oliver; Sergey Vladimirov; according to Microsoft Office + * Word 97-2007 Binary File Format Specification [*.doc] and [MS-DOC] - + * v20110608 Word (.doc) Binary File Format + */ +@Internal +public class FibBase extends FibBaseAbstractType +{ + + public FibBase() + { + } + + public FibBase( byte[] std, int offset ) + { + fillFields( std, offset ); + } + + @Override + @SuppressWarnings( "deprecation" ) + public boolean equals( Object obj ) + { + if ( this == obj ) + return true; + if ( obj == null ) + return false; + if ( getClass() != obj.getClass() ) + return false; + FibBase other = (FibBase) obj; + if ( field_10_flags2 != other.field_10_flags2 ) + return false; + if ( field_11_Chs != other.field_11_Chs ) + return false; + if ( field_12_chsTables != other.field_12_chsTables ) + return false; + if ( field_13_fcMin != other.field_13_fcMin ) + return false; + if ( field_14_fcMac != other.field_14_fcMac ) + return false; + if ( field_1_wIdent != other.field_1_wIdent ) + return false; + if ( field_2_nFib != other.field_2_nFib ) + return false; + if ( field_3_unused != other.field_3_unused ) + return false; + if ( field_4_lid != other.field_4_lid ) + return false; + if ( field_5_pnNext != other.field_5_pnNext ) + return false; + if ( field_6_flags1 != other.field_6_flags1 ) + return false; + if ( field_7_nFibBack != other.field_7_nFibBack ) + return false; + if ( field_8_lKey != other.field_8_lKey ) + return false; + if ( field_9_envr != other.field_9_envr ) + return false; + return true; + } + + @Override + @SuppressWarnings( "deprecation" ) + public int hashCode() + { + final int prime = 31; + int result = 1; + result = prime * result + field_10_flags2; + result = prime * result + field_11_Chs; + result = prime * result + field_12_chsTables; + result = prime * result + field_13_fcMin; + result = prime * result + field_14_fcMac; + result = prime * result + field_1_wIdent; + result = prime * result + field_2_nFib; + result = prime * result + field_3_unused; + result = prime * result + field_4_lid; + result = prime * result + field_5_pnNext; + result = prime * result + field_6_flags1; + result = prime * result + field_7_nFibBack; + result = prime * result + field_8_lKey; + result = prime * result + field_9_envr; + return result; + } + +} 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 c7692cc3ec..f07f791fce 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/model/FileInformationBlock.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/model/FileInformationBlock.java @@ -23,7 +23,6 @@ import java.lang.reflect.Modifier; import java.util.HashSet; import org.apache.poi.hwpf.model.io.HWPFOutputStream; -import org.apache.poi.hwpf.model.types.FIBAbstractType; import org.apache.poi.util.Internal; /** @@ -43,10 +42,11 @@ import org.apache.poi.util.Internal; * @author andy */ @Internal -public final class FileInformationBlock extends FIBAbstractType - implements Cloneable +public final class FileInformationBlock implements Cloneable { + private FibBase _fibBase; + FIBLongHandler _longHandler; FIBShortHandler _shortHandler; FIBFieldHandler _fieldHandler; @@ -54,7 +54,7 @@ public final class FileInformationBlock extends FIBAbstractType /** Creates a new instance of FileInformationBlock */ public FileInformationBlock(byte[] mainDocument) { - fillFields(mainDocument, 0); + _fibBase = new FibBase(mainDocument, 0); } public void fillVariableFields( byte[] mainDocument, byte[] tableStream ) @@ -110,7 +110,8 @@ public final class FileInformationBlock extends FIBAbstractType @Override public String toString() { - StringBuilder stringBuilder = new StringBuilder( super.toString() ); + StringBuilder stringBuilder = new StringBuilder( ); + stringBuilder.append( _fibBase ); stringBuilder.append( "[FIB2]\n" ); stringBuilder.append( "\tSubdocuments info:\n" ); for ( SubdocumentType type : SubdocumentType.values() ) @@ -954,38 +955,32 @@ public final class FileInformationBlock extends FIBAbstractType offset ); } - public void writeTo( byte[] mainStream, HWPFOutputStream tableStream) - throws IOException + public void writeTo( byte[] mainStream, HWPFOutputStream tableStream ) + throws IOException { - //HWPFOutputStream mainDocument = sys.getStream("WordDocument"); - //HWPFOutputStream tableStream = sys.getStream("1Table"); + // HWPFOutputStream mainDocument = sys.getStream("WordDocument"); + // HWPFOutputStream tableStream = sys.getStream("1Table"); + + _fibBase.serialize( mainStream, 0 ); + int offset = FibBase.getSize(); - super.serialize(mainStream, 0); + _shortHandler.serialize( mainStream ); + offset += _shortHandler.sizeInBytes(); - int size = super.getSize(); - _shortHandler.serialize(mainStream); - _longHandler.serialize(mainStream, size + _shortHandler.sizeInBytes()); - _fieldHandler.writeTo(mainStream, - super.getSize() + _shortHandler.sizeInBytes() + _longHandler.sizeInBytes(), tableStream); + _longHandler.serialize( mainStream, offset ); + offset += _longHandler.sizeInBytes(); + _fieldHandler.writeTo( mainStream, offset, tableStream ); } public int getSize() { - return super.getSize() + _shortHandler.sizeInBytes() + - _longHandler.sizeInBytes() + _fieldHandler.sizeInBytes(); - } -// public Object clone() -// { -// try -// { -// return super.clone(); -// } -// catch (CloneNotSupportedException e) -// { -// e.printStackTrace(); -// return null; -// } -// } + return FibBase.getSize() + _shortHandler.sizeInBytes() + + _longHandler.sizeInBytes() + _fieldHandler.sizeInBytes(); + } + public FibBase getFibBase() + { + return _fibBase; + } } diff --git a/src/scratchpad/src/org/apache/poi/hwpf/model/types/FIBAbstractType.java b/src/scratchpad/src/org/apache/poi/hwpf/model/types/FIBAbstractType.java deleted file mode 100644 index 58253a9713..0000000000 --- a/src/scratchpad/src/org/apache/poi/hwpf/model/types/FIBAbstractType.java +++ /dev/null @@ -1,759 +0,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. -==================================================================== */ - -package org.apache.poi.hwpf.model.types; - - -import org.apache.poi.hdf.model.hdftypes.HDFType; -import org.apache.poi.util.BitField; -import org.apache.poi.util.BitFieldFactory; -import org.apache.poi.util.Internal; -import org.apache.poi.util.LittleEndian; - -/** - * Base part of the File information Block (FibBase). Holds the core part of the FIB, from the first 32 bytes. - * NOTE: This source is automatically generated please do not modify this file. Either subclass or - * remove the record in src/records/definitions. - * - * @author Andrew C. Oliver - */ -@Internal -public abstract class FIBAbstractType implements HDFType { - - protected int field_1_wIdent; - protected int field_2_nFib; - protected int field_3_nProduct; - protected int field_4_lid; - protected int field_5_pnNext; - protected short field_6_options; - private static BitField fDot = BitFieldFactory.getInstance(0x0001); - private static BitField fGlsy = BitFieldFactory.getInstance(0x0002); - private static BitField fComplex = BitFieldFactory.getInstance(0x0004); - private static BitField fHasPic = BitFieldFactory.getInstance(0x0008); - private static BitField cQuickSaves = BitFieldFactory.getInstance(0x00F0); - private static BitField fEncrypted = BitFieldFactory.getInstance(0x0100); - private static BitField fWhichTblStm = BitFieldFactory.getInstance(0x0200); - private static BitField fReadOnlyRecommended = BitFieldFactory.getInstance(0x0400); - private static BitField fWriteReservation = BitFieldFactory.getInstance(0x0800); - private static BitField fExtChar = BitFieldFactory.getInstance(0x1000); - private static BitField fLoadOverride = BitFieldFactory.getInstance(0x2000); - private static BitField fFarEast = BitFieldFactory.getInstance(0x4000); - private static BitField fCrypto = BitFieldFactory.getInstance(0x8000); - protected int field_7_nFibBack; - protected int field_8_lKey; - protected int field_9_envr; - protected short field_10_history; - private static BitField fMac = BitFieldFactory.getInstance(0x0001); - private static BitField fEmptySpecial = BitFieldFactory.getInstance(0x0002); - private static BitField fLoadOverridePage = BitFieldFactory.getInstance(0x0004); - private static BitField fFutureSavedUndo = BitFieldFactory.getInstance(0x0008); - private static BitField fWord97Saved = BitFieldFactory.getInstance(0x0010); - private static BitField fSpare0 = BitFieldFactory.getInstance(0x00FE); - protected int field_11_chs; /** Latest docs say this is Reserved3! */ - protected int field_12_chsTables; /** Latest docs say this is Reserved4! */ - protected int field_13_fcMin; /** Latest docs say this is Reserved5! */ - protected int field_14_fcMac; /** Latest docs say this is Reserved6! */ - - - public FIBAbstractType() - { - - } - - protected void fillFields(byte [] data, int offset) - { - field_1_wIdent = LittleEndian.getShort(data, 0x0 + offset); - field_2_nFib = LittleEndian.getShort(data, 0x2 + offset); - field_3_nProduct = LittleEndian.getShort(data, 0x4 + offset); - field_4_lid = LittleEndian.getShort(data, 0x6 + offset); - field_5_pnNext = LittleEndian.getShort(data, 0x8 + offset); - field_6_options = LittleEndian.getShort(data, 0xa + offset); - field_7_nFibBack = LittleEndian.getShort(data, 0xc + offset); - field_8_lKey = LittleEndian.getShort(data, 0xe + offset); - field_9_envr = LittleEndian.getShort(data, 0x10 + offset); - field_10_history = LittleEndian.getShort(data, 0x12 + offset); - field_11_chs = LittleEndian.getShort(data, 0x14 + offset); - field_12_chsTables = LittleEndian.getShort(data, 0x16 + offset); - field_13_fcMin = LittleEndian.getInt(data, 0x18 + offset); - field_14_fcMac = LittleEndian.getInt(data, 0x1c + offset); - } - - public void serialize(byte[] data, int offset) - { - LittleEndian.putShort(data, 0x0 + offset, (short)field_1_wIdent); - LittleEndian.putShort(data, 0x2 + offset, (short)field_2_nFib); - LittleEndian.putShort(data, 0x4 + offset, (short)field_3_nProduct); - LittleEndian.putShort(data, 0x6 + offset, (short)field_4_lid); - LittleEndian.putShort(data, 0x8 + offset, (short)field_5_pnNext); - LittleEndian.putShort(data, 0xa + offset, field_6_options); - LittleEndian.putShort(data, 0xc + offset, (short)field_7_nFibBack); - LittleEndian.putShort(data, 0xe + offset, (short)field_8_lKey); - LittleEndian.putShort(data, 0x10 + offset, (short)field_9_envr); - LittleEndian.putShort(data, 0x12 + offset, field_10_history); - LittleEndian.putShort(data, 0x14 + offset, (short)field_11_chs); - LittleEndian.putShort(data, 0x16 + offset, (short)field_12_chsTables); - LittleEndian.putInt(data, 0x18 + offset, field_13_fcMin); - LittleEndian.putInt(data, 0x1c + offset, field_14_fcMac); - } - - public String toString() - { - StringBuffer buffer = new StringBuffer(); - - buffer.append("[FIB]\n"); - - buffer.append(" .wIdent = "); - buffer.append(" (").append(getWIdent()).append(" )\n"); - - buffer.append(" .nFib = "); - buffer.append(" (").append(getNFib()).append(" )\n"); - - buffer.append(" .nProduct = "); - buffer.append(" (").append(getNProduct()).append(" )\n"); - - buffer.append(" .lid = "); - buffer.append(" (").append(getLid()).append(" )\n"); - - buffer.append(" .pnNext = "); - buffer.append(" (").append(getPnNext()).append(" )\n"); - - buffer.append(" .options = "); - buffer.append(" (").append(getOptions()).append(" )\n"); - buffer.append(" .fDot = ").append(isFDot()).append('\n'); - buffer.append(" .fGlsy = ").append(isFGlsy()).append('\n'); - buffer.append(" .fComplex = ").append(isFComplex()).append('\n'); - buffer.append(" .fHasPic = ").append(isFHasPic()).append('\n'); - buffer.append(" .cQuickSaves = ").append(getCQuickSaves()).append('\n'); - buffer.append(" .fEncrypted = ").append(isFEncrypted()).append('\n'); - buffer.append(" .fWhichTblStm = ").append(isFWhichTblStm()).append('\n'); - buffer.append(" .fReadOnlyRecommended = ").append(isFReadOnlyRecommended()).append('\n'); - buffer.append(" .fWriteReservation = ").append(isFWriteReservation()).append('\n'); - buffer.append(" .fExtChar = ").append(isFExtChar()).append('\n'); - buffer.append(" .fLoadOverride = ").append(isFLoadOverride()).append('\n'); - buffer.append(" .fFarEast = ").append(isFFarEast()).append('\n'); - buffer.append(" .fCrypto = ").append(isFCrypto()).append('\n'); - - buffer.append(" .nFibBack = "); - buffer.append(" (").append(getNFibBack()).append(" )\n"); - - buffer.append(" .lKey = "); - buffer.append(" (").append(getLKey()).append(" )\n"); - - buffer.append(" .envr = "); - buffer.append(" (").append(getEnvr()).append(" )\n"); - - buffer.append(" .history = "); - buffer.append(" (").append(getHistory()).append(" )\n"); - buffer.append(" .fMac = ").append(isFMac()).append('\n'); - buffer.append(" .fEmptySpecial = ").append(isFEmptySpecial()).append('\n'); - buffer.append(" .fLoadOverridePage = ").append(isFLoadOverridePage()).append('\n'); - buffer.append(" .fFutureSavedUndo = ").append(isFFutureSavedUndo()).append('\n'); - buffer.append(" .fWord97Saved = ").append(isFWord97Saved()).append('\n'); - buffer.append(" .fSpare0 = ").append(getFSpare0()).append('\n'); - - buffer.append(" .chs = "); - buffer.append(" (").append(getChs()).append(" )\n"); - - buffer.append(" .chsTables = "); - buffer.append(" (").append(getChsTables()).append(" )\n"); - - buffer.append(" .fcMin = "); - buffer.append(" (").append(getFcMin()).append(" )\n"); - - buffer.append(" .fcMac = "); - buffer.append(" (").append(getFcMac()).append(" )\n"); - - buffer.append("[/FIB]\n"); - return buffer.toString(); - } - - /** - * Size of record (exluding 4 byte header) - */ - public int getSize() - { - return 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 4 + 4; - } - - - - /** - * Get the wIdent field for the FIB record. - */ - public int getWIdent() - { - return field_1_wIdent; - } - - /** - * Set the wIdent field for the FIB record. - */ - public void setWIdent(int field_1_wIdent) - { - this.field_1_wIdent = field_1_wIdent; - } - - /** - * Get the nFib field for the FIB record. - */ - public int getNFib() - { - return field_2_nFib; - } - - /** - * Set the nFib field for the FIB record. - */ - public void setNFib(int field_2_nFib) - { - this.field_2_nFib = field_2_nFib; - } - - /** - * Get the nProduct field for the FIB record. - */ - public int getNProduct() - { - return field_3_nProduct; - } - - /** - * Set the nProduct field for the FIB record. - */ - public void setNProduct(int field_3_nProduct) - { - this.field_3_nProduct = field_3_nProduct; - } - - /** - * Get the lid field for the FIB record. - */ - public int getLid() - { - return field_4_lid; - } - - /** - * Set the lid field for the FIB record. - */ - public void setLid(int field_4_lid) - { - this.field_4_lid = field_4_lid; - } - - /** - * Get the pnNext field for the FIB record. - */ - public int getPnNext() - { - return field_5_pnNext; - } - - /** - * Set the pnNext field for the FIB record. - */ - public void setPnNext(int field_5_pnNext) - { - this.field_5_pnNext = field_5_pnNext; - } - - /** - * Get the options field for the FIB record. - */ - public short getOptions() - { - return field_6_options; - } - - /** - * Set the options field for the FIB record. - */ - public void setOptions(short field_6_options) - { - this.field_6_options = field_6_options; - } - - /** - * Get the nFibBack field for the FIB record. - */ - public int getNFibBack() - { - return field_7_nFibBack; - } - - /** - * Set the nFibBack field for the FIB record. - */ - public void setNFibBack(int field_7_nFibBack) - { - this.field_7_nFibBack = field_7_nFibBack; - } - - /** - * Get the lKey field for the FIB record. - */ - public int getLKey() - { - return field_8_lKey; - } - - /** - * Set the lKey field for the FIB record. - */ - public void setLKey(int field_8_lKey) - { - this.field_8_lKey = field_8_lKey; - } - - /** - * Get the envr field for the FIB record. - */ - public int getEnvr() - { - return field_9_envr; - } - - /** - * Set the envr field for the FIB record. - */ - public void setEnvr(int field_9_envr) - { - this.field_9_envr = field_9_envr; - } - - /** - * Get the history field for the FIB record. - */ - public short getHistory() - { - return field_10_history; - } - - /** - * Set the history field for the FIB record. - */ - public void setHistory(short field_10_history) - { - this.field_10_history = field_10_history; - } - - /** - * Get the chs field for the FIB record. - */ - public int getChs() - { - return field_11_chs; - } - - /** - * Set the chs field for the FIB record. - */ - public void setChs(int field_11_chs) - { - this.field_11_chs = field_11_chs; - } - - /** - * Get the chsTables field for the FIB record. - */ - public int getChsTables() - { - return field_12_chsTables; - } - - /** - * Set the chsTables field for the FIB record. - */ - public void setChsTables(int field_12_chsTables) - { - this.field_12_chsTables = field_12_chsTables; - } - - /** - * Get the fcMin field for the FIB record. - */ - public int getFcMin() - { - return field_13_fcMin; - } - - /** - * Set the fcMin field for the FIB record. - */ - public void setFcMin(int field_13_fcMin) - { - this.field_13_fcMin = field_13_fcMin; - } - - /** - * Get the fcMac field for the FIB record. - */ - public int getFcMac() - { - return field_14_fcMac; - } - - /** - * Set the fcMac field for the FIB record. - */ - public void setFcMac(int field_14_fcMac) - { - this.field_14_fcMac = field_14_fcMac; - } - - /** - * Sets the fDot field value. - * - */ - public void setFDot(boolean value) - { - field_6_options = (short)fDot.setBoolean(field_6_options, value); - } - - /** - * - * @return the fDot field value. - */ - public boolean isFDot() - { - return fDot.isSet(field_6_options); - } - - /** - * Sets the fGlsy field value. - * - */ - public void setFGlsy(boolean value) - { - field_6_options = (short)fGlsy.setBoolean(field_6_options, value); - } - - /** - * - * @return the fGlsy field value. - */ - public boolean isFGlsy() - { - return fGlsy.isSet(field_6_options); - } - - /** - * Sets the fComplex field value. - * - */ - public void setFComplex(boolean value) - { - field_6_options = (short)fComplex.setBoolean(field_6_options, value); - } - - /** - * - * @return the fComplex field value. - */ - public boolean isFComplex() - { - return fComplex.isSet(field_6_options); - } - - /** - * Sets the fHasPic field value. - * - */ - public void setFHasPic(boolean value) - { - field_6_options = (short)fHasPic.setBoolean(field_6_options, value); - } - - /** - * - * @return the fHasPic field value. - */ - public boolean isFHasPic() - { - return fHasPic.isSet(field_6_options); - } - - /** - * Sets the cQuickSaves field value. - * - */ - public void setCQuickSaves(byte value) - { - field_6_options = (short)cQuickSaves.setValue(field_6_options, value); - } - - /** - * - * @return the cQuickSaves field value. - */ - public byte getCQuickSaves() - { - return ( byte )cQuickSaves.getValue(field_6_options); - } - - /** - * Sets the fEncrypted field value. - * - */ - public void setFEncrypted(boolean value) - { - field_6_options = (short)fEncrypted.setBoolean(field_6_options, value); - } - - /** - * - * @return the fEncrypted field value. - */ - public boolean isFEncrypted() - { - return fEncrypted.isSet(field_6_options); - } - - /** - * Sets the fWhichTblStm field value. - * - */ - public void setFWhichTblStm(boolean value) - { - field_6_options = (short)fWhichTblStm.setBoolean(field_6_options, value); - } - - /** - * - * @return the fWhichTblStm field value. - */ - public boolean isFWhichTblStm() - { - return fWhichTblStm.isSet(field_6_options); - } - - /** - * Sets the fReadOnlyRecommended field value. - * - */ - public void setFReadOnlyRecommended(boolean value) - { - field_6_options = (short)fReadOnlyRecommended.setBoolean(field_6_options, value); - } - - /** - * - * @return the fReadOnlyRecommended field value. - */ - public boolean isFReadOnlyRecommended() - { - return fReadOnlyRecommended.isSet(field_6_options); - } - - /** - * Sets the fWriteReservation field value. - * - */ - public void setFWriteReservation(boolean value) - { - field_6_options = (short)fWriteReservation.setBoolean(field_6_options, value); - } - - /** - * - * @return the fWriteReservation field value. - */ - public boolean isFWriteReservation() - { - return fWriteReservation.isSet(field_6_options); - } - - /** - * Sets the fExtChar field value. - * - */ - public void setFExtChar(boolean value) - { - field_6_options = (short)fExtChar.setBoolean(field_6_options, value); - } - - /** - * - * @return the fExtChar field value. - */ - public boolean isFExtChar() - { - return fExtChar.isSet(field_6_options); - } - - /** - * Sets the fLoadOverride field value. - * - */ - public void setFLoadOverride(boolean value) - { - field_6_options = (short)fLoadOverride.setBoolean(field_6_options, value); - } - - /** - * - * @return the fLoadOverride field value. - */ - public boolean isFLoadOverride() - { - return fLoadOverride.isSet(field_6_options); - } - - /** - * Sets the fFarEast field value. - * - */ - public void setFFarEast(boolean value) - { - field_6_options = (short)fFarEast.setBoolean(field_6_options, value); - } - - /** - * - * @return the fFarEast field value. - */ - public boolean isFFarEast() - { - return fFarEast.isSet(field_6_options); - } - - /** - * Sets the fCrypto field value. - * - */ - public void setFCrypto(boolean value) - { - field_6_options = (short)fCrypto.setBoolean(field_6_options, value); - } - - /** - * - * @return the fCrypto field value. - */ - public boolean isFCrypto() - { - return fCrypto.isSet(field_6_options); - } - - /** - * Sets the fMac field value. - * - */ - public void setFMac(boolean value) - { - field_10_history = (short)fMac.setBoolean(field_10_history, value); - } - - /** - * - * @return the fMac field value. - */ - public boolean isFMac() - { - return fMac.isSet(field_10_history); - } - - /** - * Sets the fEmptySpecial field value. - * - */ - public void setFEmptySpecial(boolean value) - { - field_10_history = (short)fEmptySpecial.setBoolean(field_10_history, value); - } - - /** - * - * @return the fEmptySpecial field value. - */ - public boolean isFEmptySpecial() - { - return fEmptySpecial.isSet(field_10_history); - } - - /** - * Sets the fLoadOverridePage field value. - * - */ - public void setFLoadOverridePage(boolean value) - { - field_10_history = (short)fLoadOverridePage.setBoolean(field_10_history, value); - } - - /** - * - * @return the fLoadOverridePage field value. - */ - public boolean isFLoadOverridePage() - { - return fLoadOverridePage.isSet(field_10_history); - } - - /** - * Sets the fFutureSavedUndo field value. - * - */ - public void setFFutureSavedUndo(boolean value) - { - field_10_history = (short)fFutureSavedUndo.setBoolean(field_10_history, value); - } - - /** - * - * @return the fFutureSavedUndo field value. - */ - public boolean isFFutureSavedUndo() - { - return fFutureSavedUndo.isSet(field_10_history); - } - - /** - * Sets the fWord97Saved field value. - * - */ - public void setFWord97Saved(boolean value) - { - field_10_history = (short)fWord97Saved.setBoolean(field_10_history, value); - } - - /** - * - * @return the fWord97Saved field value. - */ - public boolean isFWord97Saved() - { - return fWord97Saved.isSet(field_10_history); - } - - /** - * Sets the fSpare0 field value. - * - */ - public void setFSpare0(byte value) - { - field_10_history = (short)fSpare0.setValue(field_10_history, value); - } - - /** - * - * @return the fSpare0 field value. - */ - public byte getFSpare0() - { - return ( byte )fSpare0.getValue(field_10_history); - } -} diff --git a/src/scratchpad/src/org/apache/poi/hwpf/model/types/FibBaseAbstractType.java b/src/scratchpad/src/org/apache/poi/hwpf/model/types/FibBaseAbstractType.java new file mode 100644 index 0000000000..7ef107883e --- /dev/null +++ b/src/scratchpad/src/org/apache/poi/hwpf/model/types/FibBaseAbstractType.java @@ -0,0 +1,837 @@ +/* ==================================================================== + 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; +import org.apache.poi.util.LittleEndian; + +/** + * Base part of the File information Block (FibBase). Holds the core part of the FIB, + from the first 32 bytes.

Class and fields descriptions are quoted from Microsoft + Office Word 97-2007 Binary File Format and [MS-DOC] - v20110608 Word (.doc) Binary File + Format + + *

+ * 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 Andrew C. Oliver; Sergey Vladimirov; according to Microsoft Office Word 97-2007 Binary + File Format Specification [*.doc] and [MS-DOC] - v20110608 Word (.doc) Binary File Format + + */ +@Internal +public abstract class FibBaseAbstractType +{ + + protected int field_1_wIdent; + protected int field_2_nFib; + protected int field_3_unused; + protected int field_4_lid; + protected int field_5_pnNext; + protected short field_6_flags1; + /**/private static final BitField fDot = new BitField(0x0001); + /**/private static final BitField fGlsy = new BitField(0x0002); + /**/private static final BitField fComplex = new BitField(0x0004); + /**/private static final BitField fHasPic = new BitField(0x0008); + /**/private static final BitField cQuickSaves = new BitField(0x00F0); + /**/private static final BitField fEncrypted = new BitField(0x0100); + /**/private static final BitField fWhichTblStm = new BitField(0x0200); + /**/private static final BitField fReadOnlyRecommended = new BitField(0x0400); + /**/private static final BitField fWriteReservation = new BitField(0x0800); + /**/private static final BitField fExtChar = new BitField(0x1000); + /**/private static final BitField fLoadOverride = new BitField(0x2000); + /**/private static final BitField fFarEast = new BitField(0x4000); + /**/private static final BitField fObfuscated = new BitField(0x8000); + protected int field_7_nFibBack; + protected int field_8_lKey; + @Deprecated + protected byte field_9_envr; + protected byte field_10_flags2; + /**/private static final BitField fMac = new BitField(0x01); + /**/private static final BitField fEmptySpecial = new BitField(0x02); + /**/private static final BitField fLoadOverridePage = new BitField(0x04); + /**/private static final BitField reserved1 = new BitField(0x08); + /**/private static final BitField reserved2 = new BitField(0x10); + /**/private static final BitField fSpare0 = new BitField(0xFE); + @Deprecated + protected short field_11_Chs; + @Deprecated + protected short field_12_chsTables; + @Deprecated + protected int field_13_fcMin; + @Deprecated + protected int field_14_fcMac; + + protected FibBaseAbstractType() + { + } + + protected void fillFields( byte[] data, int offset ) + { + field_1_wIdent = LittleEndian.getShort( data, 0x0 + offset ); + field_2_nFib = LittleEndian.getShort( data, 0x2 + offset ); + field_3_unused = LittleEndian.getShort( data, 0x4 + offset ); + field_4_lid = LittleEndian.getShort( data, 0x6 + offset ); + field_5_pnNext = LittleEndian.getShort( data, 0x8 + offset ); + field_6_flags1 = LittleEndian.getShort( data, 0xa + offset ); + field_7_nFibBack = LittleEndian.getShort( data, 0xc + offset ); + field_8_lKey = LittleEndian.getInt( data, 0xe + offset ); + field_9_envr = data[ 0x12 + offset ]; + field_10_flags2 = data[ 0x13 + offset ]; + field_11_Chs = LittleEndian.getShort( data, 0x14 + offset ); + field_12_chsTables = LittleEndian.getShort( data, 0x16 + offset ); + field_13_fcMin = LittleEndian.getInt( data, 0x18 + offset ); + field_14_fcMac = LittleEndian.getInt( data, 0x1c + offset ); + } + + public void serialize( byte[] data, int offset ) + { + LittleEndian.putUShort( data, 0x0 + offset, field_1_wIdent ); + LittleEndian.putUShort( data, 0x2 + offset, field_2_nFib ); + LittleEndian.putUShort( data, 0x4 + offset, field_3_unused ); + LittleEndian.putUShort( data, 0x6 + offset, field_4_lid ); + LittleEndian.putUShort( data, 0x8 + offset, field_5_pnNext ); + LittleEndian.putShort( data, 0xa + offset, field_6_flags1 ); + LittleEndian.putUShort( data, 0xc + offset, field_7_nFibBack ); + LittleEndian.putInt( data, 0xe + offset, field_8_lKey ); + data[ 0x12 + offset ] = field_9_envr; + data[ 0x13 + offset ] = field_10_flags2; + LittleEndian.putShort( data, 0x14 + offset, field_11_Chs ); + LittleEndian.putShort( data, 0x16 + offset, field_12_chsTables ); + LittleEndian.putInt( data, 0x18 + offset, field_13_fcMin ); + LittleEndian.putInt( data, 0x1c + offset, field_14_fcMac ); + } + + public byte[] serialize() + { + final byte[] result = new byte[ getSize() ]; + serialize( result, 0 ); + return result; + } + + /** + * Size of record + */ + public static int getSize() + { + return 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 4 + 1 + 1 + 2 + 2 + 4 + 4; + } + + public String toString() + { + StringBuilder builder = new StringBuilder(); + builder.append("[FibBase]\n"); + builder.append(" .wIdent = "); + builder.append(" (").append(getWIdent()).append(" )\n"); + builder.append(" .nFib = "); + builder.append(" (").append(getNFib()).append(" )\n"); + builder.append(" .unused = "); + builder.append(" (").append(getUnused()).append(" )\n"); + builder.append(" .lid = "); + builder.append(" (").append(getLid()).append(" )\n"); + builder.append(" .pnNext = "); + builder.append(" (").append(getPnNext()).append(" )\n"); + builder.append(" .flags1 = "); + builder.append(" (").append(getFlags1()).append(" )\n"); + builder.append(" .fDot = ").append(isFDot()).append('\n'); + builder.append(" .fGlsy = ").append(isFGlsy()).append('\n'); + builder.append(" .fComplex = ").append(isFComplex()).append('\n'); + builder.append(" .fHasPic = ").append(isFHasPic()).append('\n'); + builder.append(" .cQuickSaves = ").append(getCQuickSaves()).append('\n'); + builder.append(" .fEncrypted = ").append(isFEncrypted()).append('\n'); + builder.append(" .fWhichTblStm = ").append(isFWhichTblStm()).append('\n'); + builder.append(" .fReadOnlyRecommended = ").append(isFReadOnlyRecommended()).append('\n'); + builder.append(" .fWriteReservation = ").append(isFWriteReservation()).append('\n'); + builder.append(" .fExtChar = ").append(isFExtChar()).append('\n'); + builder.append(" .fLoadOverride = ").append(isFLoadOverride()).append('\n'); + builder.append(" .fFarEast = ").append(isFFarEast()).append('\n'); + builder.append(" .fObfuscated = ").append(isFObfuscated()).append('\n'); + builder.append(" .nFibBack = "); + builder.append(" (").append(getNFibBack()).append(" )\n"); + builder.append(" .lKey = "); + builder.append(" (").append(getLKey()).append(" )\n"); + builder.append(" .envr = "); + builder.append(" (").append(getEnvr()).append(" )\n"); + builder.append(" .flags2 = "); + builder.append(" (").append(getFlags2()).append(" )\n"); + builder.append(" .fMac = ").append(isFMac()).append('\n'); + builder.append(" .fEmptySpecial = ").append(isFEmptySpecial()).append('\n'); + builder.append(" .fLoadOverridePage = ").append(isFLoadOverridePage()).append('\n'); + builder.append(" .reserved1 = ").append(isReserved1()).append('\n'); + builder.append(" .reserved2 = ").append(isReserved2()).append('\n'); + builder.append(" .fSpare0 = ").append(getFSpare0()).append('\n'); + builder.append(" .Chs = "); + builder.append(" (").append(getChs()).append(" )\n"); + builder.append(" .chsTables = "); + builder.append(" (").append(getChsTables()).append(" )\n"); + builder.append(" .fcMin = "); + builder.append(" (").append(getFcMin()).append(" )\n"); + builder.append(" .fcMac = "); + builder.append(" (").append(getFcMac()).append(" )\n"); + + builder.append("[/FibBase]\n"); + return builder.toString(); + } + + /** + * An unsigned integer that specifies that this is a Word Binary File. This value MUST be 0xA5EC. + */ + @Internal + public int getWIdent() + { + return field_1_wIdent; + } + + /** + * An unsigned integer that specifies that this is a Word Binary File. This value MUST be 0xA5EC. + */ + @Internal + public void setWIdent( int field_1_wIdent ) + { + this.field_1_wIdent = field_1_wIdent; + } + + /** + * An unsigned integer that specifies the version number of the file format used. Superseded by FibRgCswNew.nFibNew if it is present. This value SHOULD be 0x00C1. + */ + @Internal + public int getNFib() + { + return field_2_nFib; + } + + /** + * An unsigned integer that specifies the version number of the file format used. Superseded by FibRgCswNew.nFibNew if it is present. This value SHOULD be 0x00C1. + */ + @Internal + public void setNFib( int field_2_nFib ) + { + this.field_2_nFib = field_2_nFib; + } + + /** + * This value is undefined and MUST be ignored. + */ + @Internal + public int getUnused() + { + return field_3_unused; + } + + /** + * This value is undefined and MUST be ignored. + */ + @Internal + public void setUnused( int field_3_unused ) + { + this.field_3_unused = field_3_unused; + } + + /** + * A LID that specifies the install language of the application that is producing the document. If nFib is 0x00D9 or greater, then any East Asian install lid or any install lid with a base language of Spanish, German or French MUST be recorded as lidAmerican. If the nFib is 0x0101 or greater, then any install lid with a base language of Vietnamese, Thai, or Hindi MUST be recorded as lidAmerican.. + */ + @Internal + public int getLid() + { + return field_4_lid; + } + + /** + * A LID that specifies the install language of the application that is producing the document. If nFib is 0x00D9 or greater, then any East Asian install lid or any install lid with a base language of Spanish, German or French MUST be recorded as lidAmerican. If the nFib is 0x0101 or greater, then any install lid with a base language of Vietnamese, Thai, or Hindi MUST be recorded as lidAmerican.. + */ + @Internal + public void setLid( int field_4_lid ) + { + this.field_4_lid = field_4_lid; + } + + /** + * An unsigned integer that specifies the offset in the WordDocument stream of the FIB for the document which contains all the AutoText items. + */ + @Internal + public int getPnNext() + { + return field_5_pnNext; + } + + /** + * An unsigned integer that specifies the offset in the WordDocument stream of the FIB for the document which contains all the AutoText items. + */ + @Internal + public void setPnNext( int field_5_pnNext ) + { + this.field_5_pnNext = field_5_pnNext; + } + + /** + * Get the flags1 field for the FibBase record. + */ + @Internal + public short getFlags1() + { + return field_6_flags1; + } + + /** + * Set the flags1 field for the FibBase record. + */ + @Internal + public void setFlags1( short field_6_flags1 ) + { + this.field_6_flags1 = field_6_flags1; + } + + /** + * This value SHOULD be 0x00BF. This value MUST be 0x00BF or 0x00C1. + */ + @Internal + public int getNFibBack() + { + return field_7_nFibBack; + } + + /** + * This value SHOULD be 0x00BF. This value MUST be 0x00BF or 0x00C1. + */ + @Internal + public void setNFibBack( int field_7_nFibBack ) + { + this.field_7_nFibBack = field_7_nFibBack; + } + + /** + * If fEncryption is 1 and fObfuscation is 1, this value specifies the XOR obfuscation password verifier. If fEncryption is 1 and fObfuscation is 0, this value specifies the size of the EncryptionHeader that is stored at the beginning of the Table stream as described in Encryption and Obfuscation. Otherwise, this value MUST be 0. + */ + @Internal + public int getLKey() + { + return field_8_lKey; + } + + /** + * If fEncryption is 1 and fObfuscation is 1, this value specifies the XOR obfuscation password verifier. If fEncryption is 1 and fObfuscation is 0, this value specifies the size of the EncryptionHeader that is stored at the beginning of the Table stream as described in Encryption and Obfuscation. Otherwise, this value MUST be 0. + */ + @Internal + public void setLKey( int field_8_lKey ) + { + this.field_8_lKey = field_8_lKey; + } + + /** + * This value MUST be 0, and MUST be ignored. + */ + @Internal + public byte getEnvr() + { + return field_9_envr; + } + + /** + * This value MUST be 0, and MUST be ignored. + */ + @Internal + public void setEnvr( byte field_9_envr ) + { + this.field_9_envr = field_9_envr; + } + + /** + * Get the flags2 field for the FibBase record. + */ + @Internal + public byte getFlags2() + { + return field_10_flags2; + } + + /** + * Set the flags2 field for the FibBase record. + */ + @Internal + public void setFlags2( byte field_10_flags2 ) + { + this.field_10_flags2 = field_10_flags2; + } + + /** + * This value MUST be 0 and MUST be ignored. + */ + @Internal + public short getChs() + { + return field_11_Chs; + } + + /** + * This value MUST be 0 and MUST be ignored. + */ + @Internal + public void setChs( short field_11_Chs ) + { + this.field_11_Chs = field_11_Chs; + } + + /** + * This value MUST be 0 and MUST be ignored. + */ + @Internal + public short getChsTables() + { + return field_12_chsTables; + } + + /** + * This value MUST be 0 and MUST be ignored. + */ + @Internal + public void setChsTables( short field_12_chsTables ) + { + this.field_12_chsTables = field_12_chsTables; + } + + /** + * This value is undefined and MUST be ignored. + */ + @Internal + public int getFcMin() + { + return field_13_fcMin; + } + + /** + * This value is undefined and MUST be ignored. + */ + @Internal + public void setFcMin( int field_13_fcMin ) + { + this.field_13_fcMin = field_13_fcMin; + } + + /** + * This value is undefined and MUST be ignored. + */ + @Internal + public int getFcMac() + { + return field_14_fcMac; + } + + /** + * This value is undefined and MUST be ignored. + */ + @Internal + public void setFcMac( int field_14_fcMac ) + { + this.field_14_fcMac = field_14_fcMac; + } + + /** + * Sets the fDot field value. + * Specifies whether this is a document template + */ + @Internal + public void setFDot( boolean value ) + { + field_6_flags1 = (short)fDot.setBoolean(field_6_flags1, value); + } + + /** + * Specifies whether this is a document template + * @return the fDot field value. + */ + @Internal + public boolean isFDot() + { + return fDot.isSet(field_6_flags1); + } + + /** + * Sets the fGlsy field value. + * Specifies whether this is a document that contains only AutoText items + */ + @Internal + public void setFGlsy( boolean value ) + { + field_6_flags1 = (short)fGlsy.setBoolean(field_6_flags1, value); + } + + /** + * Specifies whether this is a document that contains only AutoText items + * @return the fGlsy field value. + */ + @Internal + public boolean isFGlsy() + { + return fGlsy.isSet(field_6_flags1); + } + + /** + * Sets the fComplex field value. + * Specifies that the last save operation that was performed on this document was an incremental save operation + */ + @Internal + public void setFComplex( boolean value ) + { + field_6_flags1 = (short)fComplex.setBoolean(field_6_flags1, value); + } + + /** + * Specifies that the last save operation that was performed on this document was an incremental save operation + * @return the fComplex field value. + */ + @Internal + public boolean isFComplex() + { + return fComplex.isSet(field_6_flags1); + } + + /** + * Sets the fHasPic field value. + * When set to 0, there SHOULD be no pictures in the document + */ + @Internal + public void setFHasPic( boolean value ) + { + field_6_flags1 = (short)fHasPic.setBoolean(field_6_flags1, value); + } + + /** + * When set to 0, there SHOULD be no pictures in the document + * @return the fHasPic field value. + */ + @Internal + public boolean isFHasPic() + { + return fHasPic.isSet(field_6_flags1); + } + + /** + * Sets the cQuickSaves field value. + * An unsigned integer. If nFib is less than 0x00D9, then cQuickSaves specifies the number of consecutive times this document was incrementally saved. If nFib is 0x00D9 or greater, then cQuickSaves MUST be 0xF + */ + @Internal + public void setCQuickSaves( byte value ) + { + field_6_flags1 = (short)cQuickSaves.setValue(field_6_flags1, value); + } + + /** + * An unsigned integer. If nFib is less than 0x00D9, then cQuickSaves specifies the number of consecutive times this document was incrementally saved. If nFib is 0x00D9 or greater, then cQuickSaves MUST be 0xF + * @return the cQuickSaves field value. + */ + @Internal + public byte getCQuickSaves() + { + return ( byte )cQuickSaves.getValue(field_6_flags1); + } + + /** + * Sets the fEncrypted field value. + * Specifies whether the document is encrypted or obfuscated as specified in Encryption and Obfuscation + */ + @Internal + public void setFEncrypted( boolean value ) + { + field_6_flags1 = (short)fEncrypted.setBoolean(field_6_flags1, value); + } + + /** + * Specifies whether the document is encrypted or obfuscated as specified in Encryption and Obfuscation + * @return the fEncrypted field value. + */ + @Internal + public boolean isFEncrypted() + { + return fEncrypted.isSet(field_6_flags1); + } + + /** + * Sets the fWhichTblStm field value. + * Specifies the Table stream to which the FIB refers. When this value is set to 1, use 1Table; when this value is set to 0, use 0Table. + */ + @Internal + public void setFWhichTblStm( boolean value ) + { + field_6_flags1 = (short)fWhichTblStm.setBoolean(field_6_flags1, value); + } + + /** + * Specifies the Table stream to which the FIB refers. When this value is set to 1, use 1Table; when this value is set to 0, use 0Table. + * @return the fWhichTblStm field value. + */ + @Internal + public boolean isFWhichTblStm() + { + return fWhichTblStm.isSet(field_6_flags1); + } + + /** + * Sets the fReadOnlyRecommended field value. + * Specifies whether the document author recommended that the document be opened in read-only mode + */ + @Internal + public void setFReadOnlyRecommended( boolean value ) + { + field_6_flags1 = (short)fReadOnlyRecommended.setBoolean(field_6_flags1, value); + } + + /** + * Specifies whether the document author recommended that the document be opened in read-only mode + * @return the fReadOnlyRecommended field value. + */ + @Internal + public boolean isFReadOnlyRecommended() + { + return fReadOnlyRecommended.isSet(field_6_flags1); + } + + /** + * Sets the fWriteReservation field value. + * Specifies whether the document has a write-reservation password + */ + @Internal + public void setFWriteReservation( boolean value ) + { + field_6_flags1 = (short)fWriteReservation.setBoolean(field_6_flags1, value); + } + + /** + * Specifies whether the document has a write-reservation password + * @return the fWriteReservation field value. + */ + @Internal + public boolean isFWriteReservation() + { + return fWriteReservation.isSet(field_6_flags1); + } + + /** + * Sets the fExtChar field value. + * This value MUST be 1 + */ + @Internal + public void setFExtChar( boolean value ) + { + field_6_flags1 = (short)fExtChar.setBoolean(field_6_flags1, value); + } + + /** + * This value MUST be 1 + * @return the fExtChar field value. + */ + @Internal + public boolean isFExtChar() + { + return fExtChar.isSet(field_6_flags1); + } + + /** + * Sets the fLoadOverride field value. + * Specifies whether to override the language information and font that are specified in the paragraph style at istd 0 (the normal style) with the defaults that are appropriate for the installation language of the application + */ + @Internal + public void setFLoadOverride( boolean value ) + { + field_6_flags1 = (short)fLoadOverride.setBoolean(field_6_flags1, value); + } + + /** + * Specifies whether to override the language information and font that are specified in the paragraph style at istd 0 (the normal style) with the defaults that are appropriate for the installation language of the application + * @return the fLoadOverride field value. + */ + @Internal + public boolean isFLoadOverride() + { + return fLoadOverride.isSet(field_6_flags1); + } + + /** + * Sets the fFarEast field value. + * Specifies whether the installation language of the application that created the document was an East Asian language + */ + @Internal + public void setFFarEast( boolean value ) + { + field_6_flags1 = (short)fFarEast.setBoolean(field_6_flags1, value); + } + + /** + * Specifies whether the installation language of the application that created the document was an East Asian language + * @return the fFarEast field value. + */ + @Internal + public boolean isFFarEast() + { + return fFarEast.isSet(field_6_flags1); + } + + /** + * Sets the fObfuscated field value. + * If fEncrypted is 1, this bit specifies whether the document is obfuscated by using XOR obfuscation; otherwise, this bit MUST be ignored + */ + @Internal + public void setFObfuscated( boolean value ) + { + field_6_flags1 = (short)fObfuscated.setBoolean(field_6_flags1, value); + } + + /** + * If fEncrypted is 1, this bit specifies whether the document is obfuscated by using XOR obfuscation; otherwise, this bit MUST be ignored + * @return the fObfuscated field value. + */ + @Internal + public boolean isFObfuscated() + { + return fObfuscated.isSet(field_6_flags1); + } + + /** + * Sets the fMac field value. + * This value MUST be 0, and MUST be ignored + */ + @Internal + public void setFMac( boolean value ) + { + field_10_flags2 = (byte)fMac.setBoolean(field_10_flags2, value); + } + + /** + * This value MUST be 0, and MUST be ignored + * @return the fMac field value. + * @deprecated This field should not be used according to specification + */ + @Internal + @Deprecated + public boolean isFMac() + { + return fMac.isSet(field_10_flags2); + } + + /** + * Sets the fEmptySpecial field value. + * This value SHOULD be 0 and SHOULD be ignored + */ + @Internal + public void setFEmptySpecial( boolean value ) + { + field_10_flags2 = (byte)fEmptySpecial.setBoolean(field_10_flags2, value); + } + + /** + * This value SHOULD be 0 and SHOULD be ignored + * @return the fEmptySpecial field value. + * @deprecated This field should not be used according to specification + */ + @Internal + @Deprecated + public boolean isFEmptySpecial() + { + return fEmptySpecial.isSet(field_10_flags2); + } + + /** + * Sets the fLoadOverridePage field value. + * Specifies whether to override the section properties for page size, orientation, and margins with the defaults that are appropriate for the installation language of the application + */ + @Internal + public void setFLoadOverridePage( boolean value ) + { + field_10_flags2 = (byte)fLoadOverridePage.setBoolean(field_10_flags2, value); + } + + /** + * Specifies whether to override the section properties for page size, orientation, and margins with the defaults that are appropriate for the installation language of the application + * @return the fLoadOverridePage field value. + */ + @Internal + public boolean isFLoadOverridePage() + { + return fLoadOverridePage.isSet(field_10_flags2); + } + + /** + * Sets the reserved1 field value. + * This value is undefined and MUST be ignored + */ + @Internal + public void setReserved1( boolean value ) + { + field_10_flags2 = (byte)reserved1.setBoolean(field_10_flags2, value); + } + + /** + * This value is undefined and MUST be ignored + * @return the reserved1 field value. + * @deprecated This field should not be used according to specification + */ + @Internal + @Deprecated + public boolean isReserved1() + { + return reserved1.isSet(field_10_flags2); + } + + /** + * Sets the reserved2 field value. + * This value is undefined and MUST be ignored + */ + @Internal + public void setReserved2( boolean value ) + { + field_10_flags2 = (byte)reserved2.setBoolean(field_10_flags2, value); + } + + /** + * This value is undefined and MUST be ignored + * @return the reserved2 field value. + * @deprecated This field should not be used according to specification + */ + @Internal + @Deprecated + public boolean isReserved2() + { + return reserved2.isSet(field_10_flags2); + } + + /** + * Sets the fSpare0 field value. + * This value is undefined and MUST be ignored + */ + @Internal + public void setFSpare0( byte value ) + { + field_10_flags2 = (byte)fSpare0.setValue(field_10_flags2, value); + } + + /** + * This value is undefined and MUST be ignored + * @return the fSpare0 field value. + * @deprecated This field should not be used according to specification + */ + @Internal + @Deprecated + public byte getFSpare0() + { + return ( byte )fSpare0.getValue(field_10_flags2); + } + +} // END OF CLASS diff --git a/src/scratchpad/testcases/org/apache/poi/hwpf/HWPFDocFixture.java b/src/scratchpad/testcases/org/apache/poi/hwpf/HWPFDocFixture.java index 5afb0ee42a..1b4d94ca3c 100644 --- a/src/scratchpad/testcases/org/apache/poi/hwpf/HWPFDocFixture.java +++ b/src/scratchpad/testcases/org/apache/poi/hwpf/HWPFDocFixture.java @@ -53,7 +53,7 @@ public final class HWPFDocFixture _fib = new FileInformationBlock(_mainStream); String name = "0Table"; - if (_fib.isFWhichTblStm()) + if (_fib.getFibBase().isFWhichTblStm()) { name = "1Table"; } diff --git a/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestCHPBinTable.java b/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestCHPBinTable.java index 006fc77ddf..a36a729d5f 100644 --- a/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestCHPBinTable.java +++ b/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestCHPBinTable.java @@ -44,7 +44,7 @@ public final class TestCHPBinTable FileInformationBlock fib = _hWPFDocFixture._fib; byte[] mainStream = _hWPFDocFixture._mainStream; byte[] tableStream = _hWPFDocFixture._tableStream; - int fcMin = fib.getFcMin(); + int fcMin = fib.getFibBase().getFcMin(); _cHPBinTable = new CHPBinTable(mainStream, tableStream, fib.getFcPlcfbteChpx(), fib.getLcbPlcfbteChpx(), fakeTPT); diff --git a/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestFileInformationBlock.java b/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestFileInformationBlock.java index 2154fda9be..d113870cd8 100644 --- a/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestFileInformationBlock.java +++ b/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestFileInformationBlock.java @@ -35,7 +35,7 @@ public final class TestFileInformationBlock int size = _fileInformationBlock.getSize(); byte[] buf = new byte[size]; - _fileInformationBlock.serialize(buf, 0); + _fileInformationBlock.getFibBase().serialize(buf, 0); FileInformationBlock newFileInformationBlock = new FileInformationBlock(buf); diff --git a/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestSectionTable.java b/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestSectionTable.java index 2681496852..77c10c7d07 100644 --- a/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestSectionTable.java +++ b/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestSectionTable.java @@ -36,7 +36,7 @@ public final class TestSectionTable FileInformationBlock fib = _hWPFDocFixture._fib; byte[] mainStream = _hWPFDocFixture._mainStream; byte[] tableStream = _hWPFDocFixture._tableStream; - int fcMin = fib.getFcMin(); + int fcMin = fib.getFibBase().getFcMin(); CPSplitCalculator cps = new CPSplitCalculator(fib); diff --git a/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestTextPieceTable.java b/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestTextPieceTable.java index b44a3ba16b..beef1a8cb1 100644 --- a/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestTextPieceTable.java +++ b/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestTextPieceTable.java @@ -38,7 +38,7 @@ public final class TestTextPieceTable extends TestCase { FileInformationBlock fib = _hWPFDocFixture._fib; byte[] mainStream = _hWPFDocFixture._mainStream; byte[] tableStream = _hWPFDocFixture._tableStream; - int fcMin = fib.getFcMin(); + int fcMin = fib.getFibBase().getFcMin(); ComplexFileTable cft = new ComplexFileTable(mainStream, tableStream, fib.getFcClx(), fcMin); diff --git a/src/types/definitions/FibBase_type.xml b/src/types/definitions/FibBase_type.xml new file mode 100644 index 0000000000..37c81a4466 --- /dev/null +++ b/src/types/definitions/FibBase_type.xml @@ -0,0 +1,94 @@ + + + + AbstractType + Base part of the File information Block (FibBase). Holds the core part of the FIB, + from the first 32 bytes. <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 + + Andrew C. Oliver; Sergey Vladimirov; according to Microsoft Office Word 97-2007 Binary + File Format Specification [*.doc] and [MS-DOC] - v20110608 Word (.doc) Binary File Format + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/types/definitions/fib_type.xml b/src/types/definitions/fib_type.xml deleted file mode 100644 index 6558ac090c..0000000000 --- a/src/types/definitions/fib_type.xml +++ /dev/null @@ -1,374 +0,0 @@ - - - - AbstractType - HDFType - Base part of the File information Block (FibBase). Holds the core part of the FIB, from the first 32 bytes. - Andrew C. Oliver - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/types/styles/hdftype.xsl b/src/types/styles/hdftype.xsl index 303433302c..5c6d01200c 100644 --- a/src/types/styles/hdftype.xsl +++ b/src/types/styles/hdftype.xsl @@ -50,6 +50,11 @@ public abstract class Abstrac + + + @Deprecated + + protected @@ -236,10 +241,26 @@ public abstract class Abstrac /** * - * @return the field value. - */ - @Internal - public () + * @return the field value. + + + + * @deprecated This field should not be used according to specification + + + + */ + + + @Internal + + + + @Deprecated + + + + public () { return } -- 2.39.5