2004-04-09 09:05:39 -04:00
|
|
|
|
|
|
|
/* ====================================================================
|
2006-12-22 14:18:16 -05:00
|
|
|
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
|
2004-04-09 09:05:39 -04:00
|
|
|
|
|
|
|
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.
|
|
|
|
==================================================================== */
|
|
|
|
|
2004-03-02 01:26:04 -05:00
|
|
|
|
|
|
|
package org.apache.poi.hwpf.model;
|
|
|
|
|
|
|
|
import java.util.HashSet;
|
|
|
|
import java.io.IOException;
|
|
|
|
|
|
|
|
import org.apache.poi.hwpf.model.io.*;
|
|
|
|
|
|
|
|
|
|
|
|
import org.apache.poi.hwpf.model.types.FIBAbstractType;
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @author andy
|
|
|
|
*/
|
|
|
|
public class FileInformationBlock extends FIBAbstractType
|
|
|
|
implements Cloneable
|
|
|
|
{
|
|
|
|
|
|
|
|
FIBLongHandler _longHandler;
|
|
|
|
FIBShortHandler _shortHandler;
|
|
|
|
FIBFieldHandler _fieldHandler;
|
|
|
|
|
|
|
|
/** Creates a new instance of FileInformationBlock */
|
|
|
|
public FileInformationBlock(byte[] mainDocument)
|
|
|
|
{
|
|
|
|
fillFields(mainDocument, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void fillVariableFields(byte[] mainDocument, byte[] tableStream)
|
|
|
|
{
|
|
|
|
HashSet fieldSet = new HashSet();
|
|
|
|
fieldSet.add(new Integer(FIBFieldHandler.STSHF));
|
|
|
|
fieldSet.add(new Integer(FIBFieldHandler.CLX));
|
|
|
|
fieldSet.add(new Integer(FIBFieldHandler.DOP));
|
|
|
|
fieldSet.add(new Integer(FIBFieldHandler.PLCFBTECHPX));
|
|
|
|
fieldSet.add(new Integer(FIBFieldHandler.PLCFBTEPAPX));
|
|
|
|
fieldSet.add(new Integer(FIBFieldHandler.PLCFSED));
|
|
|
|
fieldSet.add(new Integer(FIBFieldHandler.PLCFLST));
|
|
|
|
fieldSet.add(new Integer(FIBFieldHandler.PLFLFO));
|
2004-03-09 23:18:57 -05:00
|
|
|
fieldSet.add(new Integer(FIBFieldHandler.PLCFFLDMOM));
|
2004-03-02 01:26:04 -05:00
|
|
|
fieldSet.add(new Integer(FIBFieldHandler.STTBFFFN));
|
2006-08-14 06:29:49 -04:00
|
|
|
fieldSet.add(new Integer(FIBFieldHandler.STTBSAVEDBY));
|
2004-03-02 01:26:04 -05:00
|
|
|
fieldSet.add(new Integer(FIBFieldHandler.MODIFIED));
|
|
|
|
|
|
|
|
|
|
|
|
_shortHandler = new FIBShortHandler(mainDocument);
|
|
|
|
_longHandler = new FIBLongHandler(mainDocument, _shortHandler.START + _shortHandler.sizeInBytes());
|
|
|
|
_fieldHandler = new FIBFieldHandler(mainDocument,
|
|
|
|
_shortHandler.START + _shortHandler.sizeInBytes() + _longHandler.sizeInBytes(),
|
|
|
|
tableStream, fieldSet, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getFcDop()
|
|
|
|
{
|
|
|
|
return _fieldHandler.getFieldOffset(FIBFieldHandler.DOP);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setFcDop(int fcDop)
|
|
|
|
{
|
|
|
|
_fieldHandler.setFieldOffset(FIBFieldHandler.DOP, fcDop);
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getLcbDop()
|
|
|
|
{
|
|
|
|
return _fieldHandler.getFieldSize(FIBFieldHandler.DOP);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setLcbDop(int lcbDop)
|
|
|
|
{
|
|
|
|
_fieldHandler.setFieldSize(FIBFieldHandler.DOP, lcbDop);
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getFcStshf()
|
|
|
|
{
|
|
|
|
return _fieldHandler.getFieldOffset(FIBFieldHandler.STSHF);
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getLcbStshf()
|
|
|
|
{
|
|
|
|
return _fieldHandler.getFieldSize(FIBFieldHandler.STSHF);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setFcStshf(int fcStshf)
|
|
|
|
{
|
|
|
|
_fieldHandler.setFieldOffset(FIBFieldHandler.STSHF, fcStshf);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setLcbStshf(int lcbStshf)
|
|
|
|
{
|
|
|
|
_fieldHandler.setFieldSize(FIBFieldHandler.STSHF, lcbStshf);
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getFcClx()
|
|
|
|
{
|
|
|
|
return _fieldHandler.getFieldOffset(FIBFieldHandler.CLX);
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getLcbClx()
|
|
|
|
{
|
|
|
|
return _fieldHandler.getFieldSize(FIBFieldHandler.CLX);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setFcClx(int fcClx)
|
|
|
|
{
|
|
|
|
_fieldHandler.setFieldOffset(FIBFieldHandler.CLX, fcClx);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setLcbClx(int lcbClx)
|
|
|
|
{
|
|
|
|
_fieldHandler.setFieldSize(FIBFieldHandler.CLX, lcbClx);
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getFcPlcfbteChpx()
|
|
|
|
{
|
|
|
|
return _fieldHandler.getFieldOffset(FIBFieldHandler.PLCFBTECHPX);
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getLcbPlcfbteChpx()
|
|
|
|
{
|
|
|
|
return _fieldHandler.getFieldSize(FIBFieldHandler.PLCFBTECHPX);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setFcPlcfbteChpx(int fcPlcfBteChpx)
|
|
|
|
{
|
|
|
|
_fieldHandler.setFieldOffset(FIBFieldHandler.PLCFBTECHPX, fcPlcfBteChpx);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setLcbPlcfbteChpx(int lcbPlcfBteChpx)
|
|
|
|
{
|
|
|
|
_fieldHandler.setFieldSize(FIBFieldHandler.PLCFBTECHPX, lcbPlcfBteChpx);
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getFcPlcfbtePapx()
|
|
|
|
{
|
|
|
|
return _fieldHandler.getFieldOffset(FIBFieldHandler.PLCFBTEPAPX);
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getLcbPlcfbtePapx()
|
|
|
|
{
|
|
|
|
return _fieldHandler.getFieldSize(FIBFieldHandler.PLCFBTEPAPX);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setFcPlcfbtePapx(int fcPlcfBtePapx)
|
|
|
|
{
|
|
|
|
_fieldHandler.setFieldOffset(FIBFieldHandler.PLCFBTEPAPX, fcPlcfBtePapx);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setLcbPlcfbtePapx(int lcbPlcfBtePapx)
|
|
|
|
{
|
|
|
|
_fieldHandler.setFieldSize(FIBFieldHandler.PLCFBTEPAPX, lcbPlcfBtePapx);
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getFcPlcfsed()
|
|
|
|
{
|
|
|
|
return _fieldHandler.getFieldOffset(FIBFieldHandler.PLCFSED);
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getLcbPlcfsed()
|
|
|
|
{
|
|
|
|
return _fieldHandler.getFieldSize(FIBFieldHandler.PLCFSED);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setFcPlcfsed(int fcPlcfSed)
|
|
|
|
{
|
|
|
|
_fieldHandler.setFieldOffset(FIBFieldHandler.PLCFSED, fcPlcfSed);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setLcbPlcfsed(int lcbPlcfSed)
|
|
|
|
{
|
|
|
|
_fieldHandler.setFieldSize(FIBFieldHandler.PLCFSED, lcbPlcfSed);
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getFcPlcfLst()
|
|
|
|
{
|
|
|
|
return _fieldHandler.getFieldOffset(FIBFieldHandler.PLCFLST);
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getLcbPlcfLst()
|
|
|
|
{
|
|
|
|
return _fieldHandler.getFieldSize(FIBFieldHandler.PLCFLST);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setFcPlcfLst(int fcPlcfLst)
|
|
|
|
{
|
|
|
|
_fieldHandler.setFieldOffset(FIBFieldHandler.PLCFLST, fcPlcfLst);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setLcbPlcfLst(int lcbPlcfLst)
|
|
|
|
{
|
|
|
|
_fieldHandler.setFieldSize(FIBFieldHandler.PLCFLST, lcbPlcfLst);
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getFcPlfLfo()
|
|
|
|
{
|
|
|
|
return _fieldHandler.getFieldOffset(FIBFieldHandler.PLFLFO);
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getLcbPlfLfo()
|
|
|
|
{
|
|
|
|
return _fieldHandler.getFieldSize(FIBFieldHandler.PLFLFO);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setFcPlfLfo(int fcPlfLfo)
|
|
|
|
{
|
|
|
|
_fieldHandler.setFieldOffset(FIBFieldHandler.PLFLFO, fcPlfLfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setLcbPlfLfo(int lcbPlfLfo)
|
|
|
|
{
|
|
|
|
_fieldHandler.setFieldSize(FIBFieldHandler.PLFLFO, lcbPlfLfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getFcSttbfffn()
|
|
|
|
{
|
|
|
|
return _fieldHandler.getFieldOffset(FIBFieldHandler.STTBFFFN);
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getLcbSttbfffn()
|
|
|
|
{
|
|
|
|
return _fieldHandler.getFieldSize(FIBFieldHandler.STTBFFFN);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setFcSttbfffn(int fcSttbFffn)
|
|
|
|
{
|
|
|
|
_fieldHandler.setFieldOffset(FIBFieldHandler.STTBFFFN, fcSttbFffn);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setLcbSttbfffn(int lcbSttbFffn)
|
|
|
|
{
|
|
|
|
_fieldHandler.setFieldSize(FIBFieldHandler.STTBFFFN, lcbSttbFffn);
|
|
|
|
}
|
|
|
|
|
2006-08-14 06:29:49 -04:00
|
|
|
public int getFcSttbSavedBy()
|
|
|
|
{
|
|
|
|
return _fieldHandler.getFieldOffset(FIBFieldHandler.STTBSAVEDBY);
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getLcbSttbSavedBy()
|
|
|
|
{
|
|
|
|
return _fieldHandler.getFieldSize(FIBFieldHandler.STTBSAVEDBY);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setFcSttbSavedBy(int fcSttbSavedBy)
|
|
|
|
{
|
|
|
|
_fieldHandler.setFieldOffset(FIBFieldHandler.STTBSAVEDBY, fcSttbSavedBy);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setLcbSttbSavedBy(int fcSttbSavedBy)
|
|
|
|
{
|
|
|
|
_fieldHandler.setFieldSize(FIBFieldHandler.STTBSAVEDBY, fcSttbSavedBy);
|
|
|
|
}
|
|
|
|
|
2004-03-02 01:26:04 -05:00
|
|
|
public int getModifiedLow()
|
|
|
|
{
|
|
|
|
return _fieldHandler.getFieldOffset(FIBFieldHandler.PLFLFO);
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getModifiedHigh()
|
|
|
|
{
|
|
|
|
return _fieldHandler.getFieldSize(FIBFieldHandler.PLFLFO);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setModifiedLow(int modifiedLow)
|
|
|
|
{
|
|
|
|
_fieldHandler.setFieldOffset(FIBFieldHandler.PLFLFO, modifiedLow);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setModifiedHigh(int modifiedHigh)
|
|
|
|
{
|
|
|
|
_fieldHandler.setFieldSize(FIBFieldHandler.PLFLFO, modifiedHigh);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setCbMac(int cbMac)
|
|
|
|
{
|
|
|
|
_longHandler.setLong(FIBLongHandler.CBMAC, cbMac);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void clearOffsetsSizes()
|
|
|
|
{
|
|
|
|
_fieldHandler.clearFields();
|
|
|
|
}
|
|
|
|
|
2004-03-09 23:18:57 -05:00
|
|
|
public int getFcPlcffldMom()
|
|
|
|
{
|
|
|
|
return _fieldHandler.getFieldOffset(FIBFieldHandler.PLCFFLDMOM);
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getLcbPlcffldMom()
|
|
|
|
{
|
|
|
|
return _fieldHandler.getFieldSize(FIBFieldHandler.PLCFFLDMOM);
|
|
|
|
}
|
Merged revisions 638786-638802,638805-638811,638813-638814,638816-639230,639233-639241,639243-639253,639255-639486,639488-639601,639603-639835,639837-639917,639919-640056,640058-640710,640712-641156,641158-641184,641186-641795,641797-641798,641800-641933,641935-641963,641965-641966,641968-641995,641997-642230,642232-642562,642564-642565,642568-642570,642572-642573,642576-642736,642739-642877,642879,642881-642890,642892-642903,642905-642945,642947-643624,643626-643653,643655-643669,643671,643673-643830,643832-643833,643835-644342,644344-644472,644474-644508,644510-645347,645349-645351,645353-645559,645561-645565,645568-645951,645953-646193,646195-646311,646313-646404,646406-646665,646667-646853,646855-646869,646871-647151,647153-647185,647187-647277,647279-647566,647568-647573,647575,647578-647711,647714-647737,647739-647823,647825-648155,648157-648202,648204-648273,648275,648277-648302,648304-648333,648335-648588,648590-648622,648625-648673,648675-649141,649144,649146-649556,649558-649795,649799,649801-649910,649912-649913,649915-650128,650131-650132,650134-650137,650140-650914,650916-651991,651993-652284,652286-652287,652289,652291,652293-652297,652299-652328,652330-652425,652427-652445,652447-652560,652562-652933,652935,652937-652993,652995-653116,653118-653124,653126-653483,653487-653519,653522-653550,653552-653607,653609-653667,653669-653674,653676-653814,653817-653830,653832-653891,653893-653944,653946-654055,654057-654355,654357-654365,654367-654648,654651-655215,655217-655277,655279-655281,655283-655911,655913-656212,656214,656216-656251,656253-656698,656700-656756,656758-656892,656894-657135,657137-657165,657168-657179,657181-657354,657356-657357,657359-658312 via svnmerge from
https://svn.apache.org/repos/asf/poi/trunk
........
r657702 | josh | 2008-05-19 02:06:54 +0100 (Mon, 19 May 2008) | 1 line
Bug 44306 - fixed reading/writing of AttrPtg and rendering of CHOOSE formulas
........
r657875 | yegor | 2008-05-19 18:29:55 +0100 (Mon, 19 May 2008) | 1 line
updated release date and started a new section for 3.1-final
........
r658033 | josh | 2008-05-20 00:07:27 +0100 (Tue, 20 May 2008) | 1 line
Minor patch to improve FormulaParser error messages like those from bug 45041
........
r658285 | nick | 2008-05-20 16:42:16 +0100 (Tue, 20 May 2008) | 1 line
Fix bug 44898 - Correctly handle short last blocks in POIFS
........
r658287 | nick | 2008-05-20 16:46:54 +0100 (Tue, 20 May 2008) | 1 line
Fix #44824 - Avoid an infinite loop when reading some HWPF pictures
........
r658302 | nick | 2008-05-20 17:01:53 +0100 (Tue, 20 May 2008) | 1 line
Patch from bug #44937 from Squeeself- Partial support for extracting Escher images from HWPF files
........
r658308 | nick | 2008-05-20 17:30:19 +0100 (Tue, 20 May 2008) | 1 line
Support for specifying a policy to HSSF on missing / blank cells when fetching
........
git-svn-id: https://svn.apache.org/repos/asf/poi/branches/ooxml@658333 13f79535-47bb-0310-9956-ffa450edef68
2008-05-20 12:49:41 -04:00
|
|
|
|
|
|
|
public int getFcPlcspaMom()
|
|
|
|
{
|
|
|
|
return _fieldHandler.getFieldOffset(FIBFieldHandler.PLCSPAMOM);
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getLcbPlcspaMom()
|
|
|
|
{
|
|
|
|
return _fieldHandler.getFieldSize(FIBFieldHandler.PLCSPAMOM);
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getFcDggInfo()
|
|
|
|
{
|
|
|
|
return _fieldHandler.getFieldOffset(FIBFieldHandler.DGGINFO);
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getLcbDggInfo()
|
|
|
|
{
|
|
|
|
return _fieldHandler.getFieldSize(FIBFieldHandler.DGGINFO);
|
|
|
|
}
|
2004-03-09 23:18:57 -05:00
|
|
|
|
2004-03-02 01:26:04 -05:00
|
|
|
public void writeTo (byte[] mainStream, HWPFOutputStream tableStream)
|
|
|
|
throws IOException
|
|
|
|
{
|
|
|
|
//HWPFOutputStream mainDocument = sys.getStream("WordDocument");
|
|
|
|
//HWPFOutputStream tableStream = sys.getStream("1Table");
|
|
|
|
|
|
|
|
super.serialize(mainStream, 0);
|
|
|
|
|
|
|
|
int size = super.getSize();
|
|
|
|
_shortHandler.serialize(mainStream);
|
|
|
|
_longHandler.serialize(mainStream, size + _shortHandler.sizeInBytes());
|
|
|
|
_fieldHandler.writeTo(mainStream,
|
|
|
|
super.getSize() + _shortHandler.sizeInBytes() + _longHandler.sizeInBytes(), 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;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
|