Make a start on feature related records. Not finished yet, so not enabled in the recordfactory until complete+tested
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@835183 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
0108892c64
commit
4a57314dcc
100
src/java/org/apache/poi/hssf/record/FeatHdrRecord.java
Normal file
100
src/java/org/apache/poi/hssf/record/FeatHdrRecord.java
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
/* ====================================================================
|
||||||
|
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.hssf.record;
|
||||||
|
|
||||||
|
import org.apache.poi.util.LittleEndianOutput;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Title: FeatHdr (Feature Header) Record
|
||||||
|
* <P>
|
||||||
|
* This record specifies common information for Shared Features, and
|
||||||
|
* specifies the beginning of a collection of records to define them.
|
||||||
|
* The collection of data (Globals Substream ABNF, macro sheet substream
|
||||||
|
* ABNF or worksheet substream ABNF) specifies Shared Feature data.
|
||||||
|
*/
|
||||||
|
public final class FeatHdrRecord extends StandardRecord {
|
||||||
|
/**
|
||||||
|
* Specifies the enhanced protection type. Used to protect a
|
||||||
|
* shared workbook by restricting access to some areas of it
|
||||||
|
*/
|
||||||
|
public static final int SHAREDFEATURES_ISFPROTECTION = 0x02;
|
||||||
|
/**
|
||||||
|
* Specifies that formula errors should be ignored
|
||||||
|
*/
|
||||||
|
public static final int SHAREDFEATURES_ISFFEC2 = 0x03;
|
||||||
|
/**
|
||||||
|
* Specifies the smart tag type. Recognises certain
|
||||||
|
* types of entries (proper names, dates/times etc) and
|
||||||
|
* flags them for action
|
||||||
|
*/
|
||||||
|
public static final int SHAREDFEATURES_ISFFACTOID = 0x04;
|
||||||
|
/**
|
||||||
|
* Specifies the shared list type. Used for a table
|
||||||
|
* within a sheet
|
||||||
|
*/
|
||||||
|
public static final int SHAREDFEATURES_ISFLIST = 0x05;
|
||||||
|
|
||||||
|
|
||||||
|
public final static short sid = 0x0867;
|
||||||
|
|
||||||
|
private int isf_sharedFeatureType; // See SHAREDFEATURES_
|
||||||
|
private byte reserved; // Should always be one
|
||||||
|
/**
|
||||||
|
* 0x00000000 = rgbHdrData not present
|
||||||
|
* 0xffffffff = rgbHdrData present
|
||||||
|
*/
|
||||||
|
private long cbHdrData;
|
||||||
|
/** We need a BOFRecord to make sense of this... */
|
||||||
|
private byte[] rgbHdrData;
|
||||||
|
|
||||||
|
public FeatHdrRecord() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public short getSid() {
|
||||||
|
return sid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FeatHdrRecord(RecordInputStream in) {
|
||||||
|
isf_sharedFeatureType = in.readShort();
|
||||||
|
reserved = in.readByte();
|
||||||
|
cbHdrData = in.readLong();
|
||||||
|
// Don't process this just yet, need the BOFRecord
|
||||||
|
rgbHdrData = in.readRemainder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
StringBuffer buffer = new StringBuffer();
|
||||||
|
buffer.append("[FEATURE HEADER]\n");
|
||||||
|
|
||||||
|
// TODO ...
|
||||||
|
|
||||||
|
buffer.append("[/FEATURE HEADER]\n");
|
||||||
|
return buffer.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void serialize(LittleEndianOutput out) {
|
||||||
|
out.writeShort(isf_sharedFeatureType);
|
||||||
|
out.writeByte(reserved);
|
||||||
|
out.writeLong(cbHdrData);
|
||||||
|
out.write(rgbHdrData);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected int getDataSize() {
|
||||||
|
return 2+1+4+rgbHdrData.length;
|
||||||
|
}
|
||||||
|
}
|
90
src/java/org/apache/poi/hssf/record/FeatRecord.java
Normal file
90
src/java/org/apache/poi/hssf/record/FeatRecord.java
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
/* ====================================================================
|
||||||
|
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.hssf.record;
|
||||||
|
|
||||||
|
import org.apache.poi.hssf.record.common.Ref8U;
|
||||||
|
import org.apache.poi.util.LittleEndianOutput;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Title: Feat (Feature) Record
|
||||||
|
* <P>
|
||||||
|
* This record specifies Shared Features data. It is normally paired
|
||||||
|
* up with a {@link FeatHdrRecord}.
|
||||||
|
*/
|
||||||
|
public final class FeatRecord extends StandardRecord {
|
||||||
|
public final static short sid = 0x0868;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* See SHAREDFEATURES_* on {@link FeatHdrRecord}
|
||||||
|
*/
|
||||||
|
private int isf_sharedFeatureType;
|
||||||
|
private byte reserved1; // Should always be zero
|
||||||
|
private long reserved2; // Should always be zero
|
||||||
|
/** The number of refs */
|
||||||
|
private int cref;
|
||||||
|
/** Only matters if type is ISFFEC2 */
|
||||||
|
private long cbFeatData;
|
||||||
|
private int reserved3; // Should always be zero
|
||||||
|
private Ref8U[] cellRefs;
|
||||||
|
|
||||||
|
private byte[] rgbFeat;
|
||||||
|
|
||||||
|
public FeatRecord() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public short getSid() {
|
||||||
|
return sid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FeatRecord(RecordInputStream in) {
|
||||||
|
isf_sharedFeatureType = in.readShort();
|
||||||
|
reserved1 = in.readByte();
|
||||||
|
reserved2 = in.readLong();
|
||||||
|
cref = in.readUShort();
|
||||||
|
cbFeatData = in.readLong();
|
||||||
|
reserved3 = in.readShort();
|
||||||
|
|
||||||
|
cellRefs = new Ref8U[cref];
|
||||||
|
for(int i=0; i<cellRefs.length; i++) {
|
||||||
|
cellRefs[i] = new Ref8U(in);
|
||||||
|
}
|
||||||
|
|
||||||
|
rgbFeat = in.readRemainder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
StringBuffer buffer = new StringBuffer();
|
||||||
|
buffer.append("[SHARDED FEATURE]\n");
|
||||||
|
|
||||||
|
// TODO ...
|
||||||
|
|
||||||
|
buffer.append("[/SHARED FEATURE]\n");
|
||||||
|
return buffer.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void serialize(LittleEndianOutput out) {
|
||||||
|
out.writeShort(isf_sharedFeatureType);
|
||||||
|
|
||||||
|
// TODO ...
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected int getDataSize() {
|
||||||
|
return -1; // TODO
|
||||||
|
}
|
||||||
|
}
|
64
src/java/org/apache/poi/hssf/record/common/Ref8U.java
Normal file
64
src/java/org/apache/poi/hssf/record/common/Ref8U.java
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
/* ====================================================================
|
||||||
|
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.hssf.record.common;
|
||||||
|
|
||||||
|
import org.apache.poi.hssf.record.RecordInputStream;
|
||||||
|
import org.apache.poi.util.LittleEndianOutput;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Title: Ref8U (Cell Range) common record part
|
||||||
|
* <P>
|
||||||
|
* This record part specifies common way of encoding a
|
||||||
|
* block of cells via first-last row-column.
|
||||||
|
*/
|
||||||
|
public final class Ref8U {
|
||||||
|
private short firstRow; // zero-based
|
||||||
|
private short lastRow; // zero-based
|
||||||
|
private short firstCol; // zero-based
|
||||||
|
private short lastCol; // zero-based
|
||||||
|
|
||||||
|
public Ref8U() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Ref8U(RecordInputStream in) {
|
||||||
|
firstRow = in.readShort();
|
||||||
|
lastRow = in.readShort();
|
||||||
|
firstCol = in.readShort();
|
||||||
|
lastCol = in.readShort();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
StringBuffer buffer = new StringBuffer();
|
||||||
|
buffer.append(" [CELL RANGE]\n");
|
||||||
|
buffer.append(" Rows " + firstRow + " to " + lastRow);
|
||||||
|
buffer.append(" Cols " + firstCol + " to " + lastCol);
|
||||||
|
buffer.append(" [/CELL RANGE]\n");
|
||||||
|
return buffer.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void serialize(LittleEndianOutput out) {
|
||||||
|
out.writeShort(firstRow);
|
||||||
|
out.writeShort(lastRow);
|
||||||
|
out.writeShort(firstCol);
|
||||||
|
out.writeShort(lastCol);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected int getDataSize() {
|
||||||
|
return 8;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user