This makes toString() implementations obsolete. This also contains preparation for #64036 to (maybe) change the record factory interface of HSSF. Remove duplicated record SeriesToChartGroupRecord, which is a duplicate of SeriesChartGroupIndexRecord. git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1876433 13f79535-47bb-0310-9956-ffa450edef68tags/before_ooxml_3rd_edition
@@ -24,7 +24,7 @@ import java.util.Map; | |||
import java.util.function.Supplier; | |||
public interface GenericRecord { | |||
default Enum getGenericRecordType() { return null; } | |||
default Enum<?> getGenericRecordType() { return null; } | |||
Map<String, Supplier<?>> getGenericProperties(); | |||
@@ -20,9 +20,13 @@ package org.apache.poi.hpsf; | |||
import java.nio.ByteBuffer; | |||
import java.util.Arrays; | |||
import java.util.Locale; | |||
import java.util.Map; | |||
import java.util.UUID; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.common.Duplicatable; | |||
import org.apache.poi.common.usermodel.GenericRecord; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
import org.apache.poi.util.LittleEndianInput; | |||
import org.apache.poi.util.LittleEndianOutput; | |||
@@ -34,7 +38,7 @@ import org.apache.poi.util.LittleEndianOutput; | |||
* | |||
* The ClassID (or CLSID) is a UUID - see RFC 4122 | |||
*/ | |||
public class ClassID implements Duplicatable { | |||
public class ClassID implements Duplicatable, GenericRecord { | |||
/** @deprecated use enum {@link ClassIDPredefined} */ @Deprecated | |||
public static final ClassID OLE10_PACKAGE = ClassIDPredefined.OLE_V1_PACKAGE.getClassID(); | |||
/** @deprecated use enum {@link ClassIDPredefined} */ @Deprecated | |||
@@ -344,4 +348,9 @@ public class ClassID implements Duplicatable { | |||
public ClassID copy() { | |||
return new ClassID(this); | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties("uuid", this::toString); | |||
} | |||
} |
@@ -139,7 +139,7 @@ public final class BiffViewer { | |||
case CFHeader12Record.sid: return new CFHeader12Record(in); | |||
case CFRuleRecord.sid: return new CFRuleRecord(in); | |||
case CFRule12Record.sid: return new CFRule12Record(in); | |||
// TODO Add CF Ex, and remove from UnknownRecord | |||
// TODO Add CF Ex, and remove from UnknownRecord | |||
case CalcCountRecord.sid: return new CalcCountRecord(in); | |||
case CalcModeRecord.sid: return new CalcModeRecord(in); | |||
case CategorySeriesAxisRecord.sid:return new CategorySeriesAxisRecord(in); | |||
@@ -236,7 +236,7 @@ public final class BiffViewer { | |||
case SeriesListRecord.sid: return new SeriesListRecord(in); | |||
case SeriesRecord.sid: return new SeriesRecord(in); | |||
case SeriesTextRecord.sid: return new SeriesTextRecord(in); | |||
case SeriesToChartGroupRecord.sid:return new SeriesToChartGroupRecord(in); | |||
case SeriesChartGroupIndexRecord.sid:return new SeriesChartGroupIndexRecord(in); | |||
case SharedFormulaRecord.sid: return new SharedFormulaRecord(in); | |||
case SheetPropertiesRecord.sid: return new SheetPropertiesRecord(in); | |||
case StringRecord.sid: return new StringRecord(in); | |||
@@ -383,8 +383,8 @@ public final class BiffViewer { | |||
* <tr><td>--escher</td><td>turn on deserialization of escher records (default is off)</td></tr> | |||
* <tr><td>--noheader</td><td>do not print record header (default is on)</td></tr> | |||
* </table> | |||
* | |||
* @param args the command line arguments | |||
* | |||
* @param args the command line arguments | |||
* | |||
* @throws IOException if the file doesn't exist or contained errors | |||
* @throws CommandParseException if the command line contained errors | |||
@@ -676,7 +676,7 @@ public final class BiffViewer { | |||
} | |||
idx = arraycopy(NEW_LINE_CHARS, buf, idx); | |||
w.write(buf, 0, idx); | |||
} catch (IOException e) { | |||
throw new RuntimeException(e); | |||
@@ -690,7 +690,7 @@ public final class BiffViewer { | |||
} | |||
return idx; | |||
} | |||
private static char getPrintableChar(byte b) { | |||
char ib = (char) (b & 0x00FF); | |||
if (ib < 32 || ib > 126) { |
@@ -35,4 +35,6 @@ abstract class DummyRecordBase extends Record { | |||
public final int getRecordSize() { | |||
throw new RecordFormatException("Cannot serialize a dummy record"); | |||
} | |||
} |
@@ -18,6 +18,12 @@ | |||
package org.apache.poi.hssf.eventusermodel.dummyrecord; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.hssf.record.HSSFRecordTypes; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
/** | |||
* A dummy record to indicate that we've now had the last | |||
* cell record for this row. | |||
@@ -55,12 +61,20 @@ public final class LastCellOfRowDummyRecord extends DummyRecordBase { | |||
} | |||
@Override | |||
public String toString() { | |||
return "End-of-Row for Row=" + row + " at Column=" + lastColumnNumber; | |||
public LastCellOfRowDummyRecord copy() { | |||
return this; | |||
} | |||
@Override | |||
public LastCellOfRowDummyRecord copy() { | |||
return this; | |||
public HSSFRecordTypes getGenericRecordType() { | |||
return null; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties( | |||
"row", this::getRow, | |||
"lastColumnNumber", this::getLastColumnNumber | |||
); | |||
} | |||
} |
@@ -18,6 +18,12 @@ | |||
package org.apache.poi.hssf.eventusermodel.dummyrecord; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.hssf.record.HSSFRecordTypes; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
/** | |||
* A dummy record for when we're missing a cell in a row, | |||
* but still want to trigger something | |||
@@ -37,4 +43,17 @@ public final class MissingCellDummyRecord extends DummyRecordBase { | |||
public MissingCellDummyRecord copy() { | |||
return this; | |||
} | |||
@Override | |||
public HSSFRecordTypes getGenericRecordType() { | |||
return null; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties( | |||
"row", this::getRow, | |||
"column", this::getColumn | |||
); | |||
} | |||
} |
@@ -18,6 +18,12 @@ | |||
package org.apache.poi.hssf.eventusermodel.dummyrecord; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.hssf.record.HSSFRecordTypes; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
/** | |||
* A dummy record for when we're missing a row, but still | |||
* want to trigger something | |||
@@ -36,4 +42,16 @@ public final class MissingRowDummyRecord extends DummyRecordBase { | |||
public MissingRowDummyRecord copy() { | |||
return this; | |||
} | |||
@Override | |||
public HSSFRecordTypes getGenericRecordType() { | |||
return null; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties( | |||
"rowNumber", this::getRowNumber | |||
); | |||
} | |||
} |
@@ -82,23 +82,6 @@ public abstract class AbstractEscherHolderRecord extends Record { | |||
} | |||
} | |||
@Override | |||
public String toString() | |||
{ | |||
StringBuilder buffer = new StringBuilder(); | |||
final String nl = System.getProperty("line.separator"); | |||
buffer.append('[' + getRecordName() + ']' + nl); | |||
if (escherRecords.size() == 0) | |||
buffer.append("No Escher Records Decoded" + nl); | |||
for (EscherRecord r : escherRecords) { | |||
buffer.append(r); | |||
} | |||
buffer.append("[/" + getRecordName() + ']' + nl); | |||
return buffer.toString(); | |||
} | |||
protected abstract String getRecordName(); | |||
@Override | |||
@@ -268,4 +251,9 @@ public abstract class AbstractEscherHolderRecord extends Record { | |||
convertToEscherRecords(0, rawData.length, rawData ); | |||
} | |||
} | |||
@Override | |||
public List<EscherRecord> getGenericChildren() { | |||
return escherRecords; | |||
} | |||
} |
@@ -17,10 +17,13 @@ | |||
package org.apache.poi.hssf.record; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.hssf.util.CellRangeAddress8Bit; | |||
import org.apache.poi.ss.formula.Formula; | |||
import org.apache.poi.ss.formula.ptg.Ptg; | |||
import org.apache.poi.util.HexDump; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
import org.apache.poi.util.LittleEndianOutput; | |||
import org.apache.poi.util.Removal; | |||
@@ -86,24 +89,8 @@ public final class ArrayRecord extends SharedValueRecordBase { | |||
return sid; | |||
} | |||
public String toString() { | |||
StringBuilder sb = new StringBuilder(); | |||
sb.append(getClass().getName()).append(" [ARRAY]\n"); | |||
sb.append(" range=").append(getRange()).append("\n"); | |||
sb.append(" options=").append(HexDump.shortToHex(_options)).append("\n"); | |||
sb.append(" notUsed=").append(HexDump.intToHex(_field3notUsed)).append("\n"); | |||
sb.append(" formula:").append("\n"); | |||
Ptg[] ptgs = _formula.getTokens(); | |||
for (int i = 0; i < ptgs.length; i++) { | |||
Ptg ptg = ptgs[i]; | |||
sb.append(ptg).append(ptg.getRVAType()).append("\n"); | |||
} | |||
sb.append("]"); | |||
return sb.toString(); | |||
} | |||
@Override | |||
@SuppressWarnings("squid:S2975") | |||
@SuppressWarnings({"squid:S2975", "MethodDoesntCallSuperMethod"}) | |||
@Deprecated | |||
@Removal(version = "5.0.0") | |||
public ArrayRecord clone() { | |||
@@ -114,4 +101,19 @@ public final class ArrayRecord extends SharedValueRecordBase { | |||
public ArrayRecord copy() { | |||
return new ArrayRecord(this); | |||
} | |||
@Override | |||
public HSSFRecordTypes getGenericRecordType() { | |||
return HSSFRecordTypes.ARRAY; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties( | |||
"range", this::getRange, | |||
"options", () -> _options, | |||
"notUsed", () -> _field3notUsed, | |||
"formula", () -> _formula | |||
); | |||
} | |||
} |
@@ -19,6 +19,10 @@ | |||
package org.apache.poi.hssf.record; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
import org.apache.poi.util.LittleEndianOutput; | |||
import org.apache.poi.util.Removal; | |||
@@ -67,17 +71,6 @@ public final class AutoFilterInfoRecord extends StandardRecord { | |||
return _cEntries; | |||
} | |||
public String toString() | |||
{ | |||
StringBuilder buffer = new StringBuilder(); | |||
buffer.append("[AUTOFILTERINFO]\n"); | |||
buffer.append(" .numEntries = ") | |||
.append(_cEntries).append("\n"); | |||
buffer.append("[/AUTOFILTERINFO]\n"); | |||
return buffer.toString(); | |||
} | |||
public void serialize(LittleEndianOutput out) { | |||
out.writeShort(_cEntries); | |||
} | |||
@@ -92,7 +85,7 @@ public final class AutoFilterInfoRecord extends StandardRecord { | |||
} | |||
@Override | |||
@SuppressWarnings("squid:S2975") | |||
@SuppressWarnings({"squid:S2975", "MethodDoesntCallSuperMethod"}) | |||
@Deprecated | |||
@Removal(version = "5.0.0") | |||
public AutoFilterInfoRecord clone() { | |||
@@ -103,4 +96,16 @@ public final class AutoFilterInfoRecord extends StandardRecord { | |||
public AutoFilterInfoRecord copy() { | |||
return new AutoFilterInfoRecord(this); | |||
} | |||
@Override | |||
public HSSFRecordTypes getGenericRecordType() { | |||
return HSSFRecordTypes.AUTO_FILTER_INFO; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties( | |||
"numEntries", this::getNumEntries | |||
); | |||
} | |||
} |
@@ -17,7 +17,11 @@ | |||
package org.apache.poi.hssf.record; | |||
import org.apache.poi.util.HexDump; | |||
import java.util.Collections; | |||
import java.util.LinkedHashMap; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.util.LittleEndianOutput; | |||
import org.apache.poi.util.Removal; | |||
@@ -229,21 +233,6 @@ public final class BOFRecord extends StandardRecord { | |||
return field_6_rversion; | |||
} | |||
public String toString() { | |||
StringBuilder buffer = new StringBuilder(); | |||
buffer.append("[BOF RECORD]\n"); | |||
buffer.append(" .version = ").append(HexDump.shortToHex(getVersion())).append("\n"); | |||
buffer.append(" .type = ").append(HexDump.shortToHex(getType())); | |||
buffer.append(" (").append(getTypeName()).append(")").append("\n"); | |||
buffer.append(" .build = ").append(HexDump.shortToHex(getBuild())).append("\n"); | |||
buffer.append(" .buildyear= ").append(getBuildYear()).append("\n"); | |||
buffer.append(" .history = ").append(HexDump.intToHex(getHistoryBitMask())).append("\n"); | |||
buffer.append(" .reqver = ").append(HexDump.intToHex(getRequiredVersion())).append("\n"); | |||
buffer.append("[/BOF RECORD]\n"); | |||
return buffer.toString(); | |||
} | |||
private String getTypeName() { | |||
switch(field_2_type) { | |||
case TYPE_CHART: return "chart"; | |||
@@ -274,7 +263,7 @@ public final class BOFRecord extends StandardRecord { | |||
} | |||
@Override | |||
@SuppressWarnings("squid:S2975") | |||
@SuppressWarnings({"squid:S2975", "MethodDoesntCallSuperMethod"}) | |||
@Deprecated | |||
@Removal(version = "5.0.0") | |||
public BOFRecord clone() { | |||
@@ -285,4 +274,22 @@ public final class BOFRecord extends StandardRecord { | |||
public BOFRecord copy() { | |||
return new BOFRecord(this); | |||
} | |||
@Override | |||
public HSSFRecordTypes getGenericRecordType() { | |||
return HSSFRecordTypes.BOF; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
final Map<String,Supplier<?>> m = new LinkedHashMap<>(); | |||
m.put("version", this::getVersion); | |||
m.put("type", this::getType); | |||
m.put("typeName", this::getTypeName); | |||
m.put("build", this::getBuild); | |||
m.put("buildYear", this::getBuildYear); | |||
m.put("history", this::getHistoryBitMask); | |||
m.put("requiredVersion", this::getRequiredVersion); | |||
return Collections.unmodifiableMap(m); | |||
} | |||
} |
@@ -19,6 +19,10 @@ | |||
package org.apache.poi.hssf.record; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
import org.apache.poi.util.LittleEndianOutput; | |||
/** | |||
@@ -65,17 +69,6 @@ public final class BackupRecord extends StandardRecord { | |||
return field_1_backup; | |||
} | |||
public String toString() | |||
{ | |||
StringBuilder buffer = new StringBuilder(); | |||
buffer.append("[BACKUP]\n"); | |||
buffer.append(" .backup = ") | |||
.append(Integer.toHexString(getBackup())).append("\n"); | |||
buffer.append("[/BACKUP]\n"); | |||
return buffer.toString(); | |||
} | |||
public void serialize(LittleEndianOutput out) { | |||
out.writeShort(getBackup()); | |||
} | |||
@@ -93,4 +86,16 @@ public final class BackupRecord extends StandardRecord { | |||
public BackupRecord copy() { | |||
return new BackupRecord(this); | |||
} | |||
@Override | |||
public HSSFRecordTypes getGenericRecordType() { | |||
return HSSFRecordTypes.BACKUP; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties( | |||
"backup", this::getBackup | |||
); | |||
} | |||
} |
@@ -17,7 +17,10 @@ | |||
package org.apache.poi.hssf.record; | |||
import org.apache.poi.util.HexDump; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
import org.apache.poi.util.LittleEndianOutput; | |||
import org.apache.poi.util.Removal; | |||
@@ -119,18 +122,6 @@ public final class BlankRecord extends StandardRecord implements CellValueRecord | |||
return sid; | |||
} | |||
public String toString() | |||
{ | |||
StringBuilder sb = new StringBuilder(); | |||
sb.append("[BLANK]\n"); | |||
sb.append(" row= ").append(HexDump.shortToHex(getRow())).append("\n"); | |||
sb.append(" col= ").append(HexDump.shortToHex(getColumn())).append("\n"); | |||
sb.append(" xf = ").append(HexDump.shortToHex(getXFIndex())).append("\n"); | |||
sb.append("[/BLANK]\n"); | |||
return sb.toString(); | |||
} | |||
public void serialize(LittleEndianOutput out) { | |||
out.writeShort(getRow()); | |||
out.writeShort(getColumn()); | |||
@@ -142,7 +133,7 @@ public final class BlankRecord extends StandardRecord implements CellValueRecord | |||
} | |||
@Override | |||
@SuppressWarnings("squid:S2975") | |||
@SuppressWarnings({"squid:S2975", "MethodDoesntCallSuperMethod"}) | |||
@Deprecated | |||
@Removal(version = "5.0.0") | |||
public BlankRecord clone() { | |||
@@ -153,4 +144,18 @@ public final class BlankRecord extends StandardRecord implements CellValueRecord | |||
public BlankRecord copy() { | |||
return new BlankRecord(this); | |||
} | |||
@Override | |||
public HSSFRecordTypes getGenericRecordType() { | |||
return HSSFRecordTypes.BLANK; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties( | |||
"row", this::getRow, | |||
"col", this::getColumn, | |||
"xfIndex", this::getXFIndex | |||
); | |||
} | |||
} |
@@ -19,6 +19,10 @@ | |||
package org.apache.poi.hssf.record; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
import org.apache.poi.util.LittleEndianOutput; | |||
/** | |||
@@ -65,17 +69,6 @@ public final class BookBoolRecord extends StandardRecord { | |||
return field_1_save_link_values; | |||
} | |||
public String toString() | |||
{ | |||
StringBuilder buffer = new StringBuilder(); | |||
buffer.append("[BOOKBOOL]\n"); | |||
buffer.append(" .savelinkvalues = ") | |||
.append(Integer.toHexString(getSaveLinkValues())).append("\n"); | |||
buffer.append("[/BOOKBOOL]\n"); | |||
return buffer.toString(); | |||
} | |||
public void serialize(LittleEndianOutput out) { | |||
out.writeShort(field_1_save_link_values); | |||
} | |||
@@ -93,4 +86,16 @@ public final class BookBoolRecord extends StandardRecord { | |||
public BookBoolRecord copy() { | |||
return new BookBoolRecord(this); | |||
} | |||
@Override | |||
public HSSFRecordTypes getGenericRecordType() { | |||
return HSSFRecordTypes.BOOK_BOOL; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties( | |||
"saveLinkValues", this::getSaveLinkValues | |||
); | |||
} | |||
} |
@@ -17,8 +17,11 @@ | |||
package org.apache.poi.hssf.record; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.ss.usermodel.FormulaError; | |||
import org.apache.poi.util.HexDump; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
import org.apache.poi.util.LittleEndianOutput; | |||
import org.apache.poi.util.RecordFormatException; | |||
import org.apache.poi.util.Removal; | |||
@@ -159,17 +162,7 @@ public final class BoolErrRecord extends CellRecord { | |||
protected String getRecordName() { | |||
return "BOOLERR"; | |||
} | |||
@Override | |||
protected void appendValueText(StringBuilder sb) { | |||
if (isBoolean()) { | |||
sb.append(" .boolVal = "); | |||
sb.append(getBooleanValue()); | |||
} else { | |||
sb.append(" .errCode = "); | |||
sb.append(FormulaError.forInt(getErrorValue()).getString()); | |||
sb.append(" (").append(HexDump.byteToHex(getErrorValue())).append(")"); | |||
} | |||
} | |||
@Override | |||
protected void serializeValue(LittleEndianOutput out) { | |||
out.writeByte(_value); | |||
@@ -186,7 +179,7 @@ public final class BoolErrRecord extends CellRecord { | |||
} | |||
@Override | |||
@SuppressWarnings("squid:S2975") | |||
@SuppressWarnings({"squid:S2975", "MethodDoesntCallSuperMethod"}) | |||
@Deprecated | |||
@Removal(version = "5.0.0") | |||
public BoolErrRecord clone() { | |||
@@ -197,4 +190,21 @@ public final class BoolErrRecord extends CellRecord { | |||
public BoolErrRecord copy() { | |||
return new BoolErrRecord(this); | |||
} | |||
@Override | |||
public HSSFRecordTypes getGenericRecordType() { | |||
return HSSFRecordTypes.BOOL_ERR; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties( | |||
"base", super::getGenericProperties, | |||
"isBoolean", this::isBoolean, | |||
"booleanVal", this::getBooleanValue, | |||
"isError", this::isError, | |||
"errorVal", this::getErrorValue, | |||
"errorTxt", () -> isError() ? FormulaError.forInt(getErrorValue()).getString() : null | |||
); | |||
} | |||
} |
@@ -19,6 +19,10 @@ | |||
package org.apache.poi.hssf.record; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
import org.apache.poi.util.LittleEndianOutput; | |||
import org.apache.poi.util.Removal; | |||
@@ -41,16 +45,6 @@ public final class BottomMarginRecord extends StandardRecord implements Margin { | |||
field_1_margin = in.readDouble(); | |||
} | |||
public String toString() | |||
{ | |||
StringBuilder buffer = new StringBuilder(); | |||
buffer.append( "[BottomMargin]\n" ); | |||
buffer.append( " .margin = " ) | |||
.append( " (" ).append( getMargin() ).append( " )\n" ); | |||
buffer.append( "[/BottomMargin]\n" ); | |||
return buffer.toString(); | |||
} | |||
public void serialize(LittleEndianOutput out) { | |||
out.writeDouble(field_1_margin); | |||
} | |||
@@ -81,7 +75,7 @@ public final class BottomMarginRecord extends StandardRecord implements Margin { | |||
} | |||
@Override | |||
@SuppressWarnings("squid:S2975") | |||
@SuppressWarnings({"squid:S2975", "MethodDoesntCallSuperMethod"}) | |||
@Deprecated | |||
@Removal(version = "5.0.0") | |||
public BottomMarginRecord clone() { | |||
@@ -92,4 +86,16 @@ public final class BottomMarginRecord extends StandardRecord implements Margin { | |||
public BottomMarginRecord copy() { | |||
return new BottomMarginRecord(this); | |||
} | |||
@Override | |||
public HSSFRecordTypes getGenericRecordType() { | |||
return HSSFRecordTypes.BOTTOM_MARGIN; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties( | |||
"margin", this::getMargin | |||
); | |||
} | |||
} |
@@ -19,11 +19,13 @@ package org.apache.poi.hssf.record; | |||
import java.util.Arrays; | |||
import java.util.List; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.ss.util.WorkbookUtil; | |||
import org.apache.poi.util.BitField; | |||
import org.apache.poi.util.BitFieldFactory; | |||
import org.apache.poi.util.HexDump; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
import org.apache.poi.util.LittleEndian; | |||
import org.apache.poi.util.LittleEndianConsts; | |||
import org.apache.poi.util.LittleEndianOutput; | |||
@@ -125,18 +127,6 @@ public final class BoundSheetRecord extends StandardRecord { | |||
return field_5_sheetname; | |||
} | |||
public String toString() { | |||
StringBuilder buffer = new StringBuilder(); | |||
buffer.append("[BOUNDSHEET]\n"); | |||
buffer.append(" .bof = ").append(HexDump.intToHex(getPositionOfBof())).append("\n"); | |||
buffer.append(" .options = ").append(HexDump.shortToHex(field_2_option_flags)).append("\n"); | |||
buffer.append(" .unicodeflag= ").append(HexDump.byteToHex(field_4_isMultibyteUnicode)).append("\n"); | |||
buffer.append(" .sheetname = ").append(field_5_sheetname).append("\n"); | |||
buffer.append("[/BOUNDSHEET]\n"); | |||
return buffer.toString(); | |||
} | |||
protected int getDataSize() { | |||
return 8 + field_5_sheetname.length() * (isMultibyte() ? 2 : 1); | |||
} | |||
@@ -219,4 +209,21 @@ public final class BoundSheetRecord extends StandardRecord { | |||
public BoundSheetRecord copy() { | |||
return new BoundSheetRecord(this); | |||
} | |||
@Override | |||
public HSSFRecordTypes getGenericRecordType() { | |||
return HSSFRecordTypes.BOUND_SHEET; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties( | |||
"bof", this::getPositionOfBof, | |||
"optionFlags", () -> field_2_option_flags, | |||
"multiByte", this::isMultibyte, | |||
"sheetName", this::getSheetname, | |||
"hidden", this::isHidden, | |||
"veryHidden", this::isVeryHidden | |||
); | |||
} | |||
} |
@@ -17,9 +17,13 @@ | |||
package org.apache.poi.hssf.record; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.hssf.record.common.FtrHeader; | |||
import org.apache.poi.hssf.record.common.FutureRecord; | |||
import org.apache.poi.ss.util.CellRangeAddress; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
import org.apache.poi.util.LittleEndianOutput; | |||
import org.apache.poi.util.Removal; | |||
@@ -97,4 +101,17 @@ public final class CFHeader12Record extends CFHeaderBase implements FutureRecord | |||
public CFHeader12Record copy() { | |||
return new CFHeader12Record(this); | |||
} | |||
@Override | |||
public HSSFRecordTypes getGenericRecordType() { | |||
return HSSFRecordTypes.CF_HEADER_12; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties( | |||
"base", super::getGenericProperties, | |||
"futureHeader", this::getFutureHeader | |||
); | |||
} | |||
} |
@@ -17,9 +17,13 @@ | |||
package org.apache.poi.hssf.record; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.ss.util.CellRangeAddress; | |||
import org.apache.poi.ss.util.CellRangeAddressList; | |||
import org.apache.poi.ss.util.CellRangeUtil; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
import org.apache.poi.util.LittleEndianOutput; | |||
import org.apache.poi.util.Removal; | |||
@@ -129,23 +133,6 @@ public abstract class CFHeaderBase extends StandardRecord { | |||
protected abstract String getRecordName(); | |||
public String toString() { | |||
StringBuilder buffer = new StringBuilder(); | |||
buffer.append("[").append(getRecordName()).append("]\n"); | |||
buffer.append("\t.numCF = ").append(getNumberOfConditionalFormats()).append("\n"); | |||
buffer.append("\t.needRecalc = ").append(getNeedRecalculation()).append("\n"); | |||
buffer.append("\t.id = ").append(getID()).append("\n"); | |||
buffer.append("\t.enclosingCellRange= ").append(getEnclosingCellRange()).append("\n"); | |||
buffer.append("\t.cfranges=["); | |||
for( int i=0; i<field_4_cell_ranges.countRanges(); i++) { | |||
buffer.append(i==0?"":",").append(field_4_cell_ranges.getCellRangeAddress(i)); | |||
} | |||
buffer.append("]\n"); | |||
buffer.append("[/").append(getRecordName()).append("]\n"); | |||
return buffer.toString(); | |||
} | |||
protected int getDataSize() { | |||
return 4 // 2 short fields | |||
+ CellRangeAddress.ENCODED_SIZE | |||
@@ -167,4 +154,15 @@ public abstract class CFHeaderBase extends StandardRecord { | |||
@Override | |||
public abstract CFHeaderBase copy(); | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties( | |||
"id", this::getID, | |||
"numCF", this::getNumberOfConditionalFormats, | |||
"needRecalculationAndId", this::getNeedRecalculation, | |||
"enclosingCellRange", this::getEnclosingCellRange, | |||
"cfRanges", this::getCellRanges | |||
); | |||
} | |||
} |
@@ -64,4 +64,9 @@ public final class CFHeaderRecord extends CFHeaderBase { | |||
public CFHeaderRecord copy() { | |||
return new CFHeaderRecord(this); | |||
} | |||
@Override | |||
public HSSFRecordTypes getGenericRecordType() { | |||
return HSSFRecordTypes.CF_HEADER; | |||
} | |||
} |
@@ -17,7 +17,10 @@ | |||
package org.apache.poi.hssf.record; | |||
import java.util.Arrays; | |||
import java.util.Collections; | |||
import java.util.LinkedHashMap; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.hssf.record.cf.ColorGradientFormatting; | |||
import org.apache.poi.hssf.record.cf.ColorGradientThreshold; | |||
@@ -35,7 +38,6 @@ import org.apache.poi.ss.formula.ptg.Ptg; | |||
import org.apache.poi.ss.usermodel.ConditionalFormattingThreshold.RangeType; | |||
import org.apache.poi.ss.usermodel.IconMultiStateFormatting.IconSet; | |||
import org.apache.poi.ss.util.CellRangeAddress; | |||
import org.apache.poi.util.HexDump; | |||
import org.apache.poi.util.IOUtils; | |||
import org.apache.poi.util.LittleEndianOutput; | |||
import org.apache.poi.util.POILogger; | |||
@@ -447,43 +449,6 @@ public final class CFRule12Record extends CFRuleBase implements FutureRecord { | |||
return len; | |||
} | |||
public String toString() { | |||
StringBuilder buffer = new StringBuilder(); | |||
buffer.append("[CFRULE12]\n"); | |||
buffer.append(" .condition_type=").append(getConditionType()).append("\n"); | |||
buffer.append(" .dxfn12_length =0x").append(Integer.toHexString(ext_formatting_length)).append("\n"); | |||
buffer.append(" .option_flags =0x").append(Integer.toHexString(getOptions())).append("\n"); | |||
if (containsFontFormattingBlock()) { | |||
buffer.append(_fontFormatting).append("\n"); | |||
} | |||
if (containsBorderFormattingBlock()) { | |||
buffer.append(_borderFormatting).append("\n"); | |||
} | |||
if (containsPatternFormattingBlock()) { | |||
buffer.append(_patternFormatting).append("\n"); | |||
} | |||
buffer.append(" .dxfn12_ext=").append(HexDump.toHex(ext_formatting_data)).append("\n"); | |||
buffer.append(" .formula_1 =").append(Arrays.toString(getFormula1().getTokens())).append("\n"); | |||
buffer.append(" .formula_2 =").append(Arrays.toString(getFormula2().getTokens())).append("\n"); | |||
buffer.append(" .formula_S =").append(Arrays.toString(formula_scale.getTokens())).append("\n"); | |||
buffer.append(" .ext_opts =").append(ext_opts).append("\n"); | |||
buffer.append(" .priority =").append(priority).append("\n"); | |||
buffer.append(" .template_type =").append(template_type).append("\n"); | |||
buffer.append(" .template_params=").append(HexDump.toHex(template_params)).append("\n"); | |||
buffer.append(" .filter_data =").append(HexDump.toHex(filter_data)).append("\n"); | |||
if (color_gradient != null) { | |||
buffer.append(color_gradient); | |||
} | |||
if (multistate != null) { | |||
buffer.append(multistate); | |||
} | |||
if (data_bar != null) { | |||
buffer.append(data_bar); | |||
} | |||
buffer.append("[/CFRULE12]\n"); | |||
return buffer.toString(); | |||
} | |||
@Override | |||
@SuppressWarnings("squid:S2975") | |||
@Deprecated | |||
@@ -506,4 +471,27 @@ public final class CFRule12Record extends CFRuleBase implements FutureRecord { | |||
public CellRangeAddress getAssociatedRange() { | |||
return futureHeader.getAssociatedRange(); | |||
} | |||
@Override | |||
public HSSFRecordTypes getGenericRecordType() { | |||
return HSSFRecordTypes.CF_RULE_12; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
final Map<String, Supplier<?>> m = new LinkedHashMap<>(super.getGenericProperties()); | |||
m.put("dxFn12Length", () -> ext_formatting_length); | |||
m.put("futureHeader", this::getFutureHeader); | |||
m.put("dxFn12Ext", () -> ext_formatting_data); | |||
m.put("formulaScale", this::getParsedExpressionScale); | |||
m.put("extOptions", () -> ext_opts); | |||
m.put("priority", this::getPriority); | |||
m.put("templateType", () -> template_type); | |||
m.put("templateParams", () -> template_params); | |||
m.put("filterData", () -> filter_data); | |||
m.put("dataBar", this::getDataBarFormatting); | |||
m.put("multiState", this::getMultiStateFormatting); | |||
m.put("colorGradient", this::getColorGradientFormatting); | |||
return Collections.unmodifiableMap(m); | |||
} | |||
} |
@@ -17,6 +17,9 @@ | |||
package org.apache.poi.hssf.record; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.hssf.model.HSSFFormulaParser; | |||
import org.apache.poi.hssf.record.cf.BorderFormatting; | |||
import org.apache.poi.hssf.record.cf.FontFormatting; | |||
@@ -27,6 +30,7 @@ import org.apache.poi.ss.formula.FormulaType; | |||
import org.apache.poi.ss.formula.ptg.Ptg; | |||
import org.apache.poi.util.BitField; | |||
import org.apache.poi.util.BitFieldFactory; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
import org.apache.poi.util.LittleEndianOutput; | |||
import org.apache.poi.util.POILogFactory; | |||
import org.apache.poi.util.POILogger; | |||
@@ -466,4 +470,19 @@ public abstract class CFRuleBase extends StandardRecord { | |||
@Override | |||
public abstract CFRuleBase copy(); | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties( | |||
"conditionType", this::getConditionType, | |||
"comparisonOperation", this::getComparisonOperation, | |||
"formattingOptions", this::getOptions, | |||
"formattingNotUsed", () -> formatting_not_used, | |||
"fontFormatting", this::getFontFormatting, | |||
"borderFormatting", this::getBorderFormatting, | |||
"patternFormatting", this::getPatternFormatting, | |||
"formula1", this::getFormula1, | |||
"formula2", this::getFormula2 | |||
); | |||
} | |||
} |
@@ -17,8 +17,6 @@ | |||
package org.apache.poi.hssf.record; | |||
import java.util.Arrays; | |||
import org.apache.poi.hssf.usermodel.HSSFSheet; | |||
import org.apache.poi.ss.formula.Formula; | |||
import org.apache.poi.ss.formula.ptg.Ptg; | |||
@@ -39,15 +37,11 @@ public final class CFRuleRecord extends CFRuleBase { | |||
super(other); | |||
} | |||
private CFRuleRecord(byte conditionType, byte comparisonOperation) { | |||
super(conditionType, comparisonOperation); | |||
setDefaults(); | |||
} | |||
private CFRuleRecord(byte conditionType, byte comparisonOperation, Ptg[] formula1, Ptg[] formula2) { | |||
super(conditionType, comparisonOperation, formula1, formula2); | |||
setDefaults(); | |||
} | |||
private void setDefaults() { | |||
// Set modification flags to 1: by default options are not modified | |||
formatting_options = modificationBits.setValue(formatting_options, -1); | |||
@@ -138,27 +132,6 @@ public final class CFRuleRecord extends CFRuleBase { | |||
getFormulaSize(getFormula2()); | |||
} | |||
@Override | |||
public String toString() { | |||
StringBuilder buffer = new StringBuilder(); | |||
buffer.append("[CFRULE]\n"); | |||
buffer.append(" .condition_type =").append(getConditionType()).append("\n"); | |||
buffer.append(" OPTION FLAGS=0x").append(Integer.toHexString(getOptions())).append("\n"); | |||
if (containsFontFormattingBlock()) { | |||
buffer.append(_fontFormatting).append("\n"); | |||
} | |||
if (containsBorderFormattingBlock()) { | |||
buffer.append(_borderFormatting).append("\n"); | |||
} | |||
if (containsPatternFormattingBlock()) { | |||
buffer.append(_patternFormatting).append("\n"); | |||
} | |||
buffer.append(" Formula 1 =").append(Arrays.toString(getFormula1().getTokens())).append("\n"); | |||
buffer.append(" Formula 2 =").append(Arrays.toString(getFormula2().getTokens())).append("\n"); | |||
buffer.append("[/CFRULE]\n"); | |||
return buffer.toString(); | |||
} | |||
@Override | |||
@SuppressWarnings("squid:S2975") | |||
@Deprecated | |||
@@ -171,4 +144,9 @@ public final class CFRuleRecord extends CFRuleBase { | |||
public CFRuleRecord copy() { | |||
return new CFRuleRecord(this); | |||
} | |||
@Override | |||
public HSSFRecordTypes getGenericRecordType() { | |||
return HSSFRecordTypes.CF_RULE; | |||
} | |||
} |
@@ -17,6 +17,10 @@ | |||
package org.apache.poi.hssf.record; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
import org.apache.poi.util.LittleEndianOutput; | |||
/** | |||
* XCT - CRN Count | |||
@@ -29,10 +33,6 @@ public final class CRNCountRecord extends StandardRecord { | |||
private int field_1_number_crn_records; | |||
private int field_2_sheet_table_index; | |||
private CRNCountRecord() { | |||
// incomplete code | |||
} | |||
public CRNCountRecord(CRNCountRecord other) { | |||
super(other); | |||
field_1_number_crn_records = other.field_1_number_crn_records; | |||
@@ -53,15 +53,6 @@ public final class CRNCountRecord extends StandardRecord { | |||
return field_1_number_crn_records; | |||
} | |||
public String toString() { | |||
StringBuilder sb = new StringBuilder(); | |||
sb.append(getClass().getName()).append(" [XCT"); | |||
sb.append(" nCRNs=").append(field_1_number_crn_records); | |||
sb.append(" sheetIx=").append(field_2_sheet_table_index); | |||
sb.append("]"); | |||
return sb.toString(); | |||
} | |||
public void serialize(LittleEndianOutput out) { | |||
out.writeShort((short)field_1_number_crn_records); | |||
out.writeShort((short)field_2_sheet_table_index); | |||
@@ -81,4 +72,17 @@ public final class CRNCountRecord extends StandardRecord { | |||
public CRNCountRecord copy() { | |||
return new CRNCountRecord(this); | |||
} | |||
@Override | |||
public HSSFRecordTypes getGenericRecordType() { | |||
return HSSFRecordTypes.CRN_COUNT; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties( | |||
"numberOfCRNs", this::getNumberOfCRNs, | |||
"sheetTableIndex", () -> field_2_sheet_table_index | |||
); | |||
} | |||
} |
@@ -17,7 +17,11 @@ | |||
package org.apache.poi.hssf.record; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.ss.formula.constant.ConstantValueParser; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
import org.apache.poi.util.LittleEndianOutput; | |||
/** | |||
@@ -31,10 +35,6 @@ public final class CRNRecord extends StandardRecord { | |||
private int field_3_row_index; | |||
private Object[] field_4_constant_values; | |||
private CRNRecord() { | |||
// incomplete code | |||
} | |||
public CRNRecord(CRNRecord other) { | |||
super(other); | |||
field_1_last_column_index = other.field_1_last_column_index; | |||
@@ -57,15 +57,6 @@ public final class CRNRecord extends StandardRecord { | |||
return field_1_last_column_index; | |||
} | |||
public String toString() { | |||
StringBuilder sb = new StringBuilder(); | |||
sb.append(getClass().getName()).append(" [CRN"); | |||
sb.append(" rowIx=").append(field_3_row_index); | |||
sb.append(" firstColIx=").append(field_2_first_column_index); | |||
sb.append(" lastColIx=").append(field_1_last_column_index); | |||
sb.append("]"); | |||
return sb.toString(); | |||
} | |||
protected int getDataSize() { | |||
return 4 + ConstantValueParser.getEncodedSize(field_4_constant_values); | |||
} | |||
@@ -88,4 +79,19 @@ public final class CRNRecord extends StandardRecord { | |||
public CRNRecord copy() { | |||
return new CRNRecord(this); | |||
} | |||
@Override | |||
public HSSFRecordTypes getGenericRecordType() { | |||
return HSSFRecordTypes.CRN; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties( | |||
"row", () -> field_3_row_index, | |||
"firstColumn", () -> field_2_first_column_index, | |||
"lastColumn", () -> field_1_last_column_index, | |||
"constantValues", () -> field_4_constant_values | |||
); | |||
} | |||
} |
@@ -19,6 +19,10 @@ | |||
package org.apache.poi.hssf.record; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
import org.apache.poi.util.LittleEndianOutput; | |||
import org.apache.poi.util.Removal; | |||
@@ -69,17 +73,6 @@ public final class CalcCountRecord extends StandardRecord { | |||
return field_1_iterations; | |||
} | |||
public String toString() | |||
{ | |||
StringBuilder buffer = new StringBuilder(); | |||
buffer.append("[CALCCOUNT]\n"); | |||
buffer.append(" .iterations = ") | |||
.append(Integer.toHexString(getIterations())).append("\n"); | |||
buffer.append("[/CALCCOUNT]\n"); | |||
return buffer.toString(); | |||
} | |||
public void serialize(LittleEndianOutput out) { | |||
out.writeShort(getIterations()); | |||
} | |||
@@ -94,7 +87,7 @@ public final class CalcCountRecord extends StandardRecord { | |||
} | |||
@Override | |||
@SuppressWarnings("squid:S2975") | |||
@SuppressWarnings({"squid:S2975", "MethodDoesntCallSuperMethod"}) | |||
@Deprecated | |||
@Removal(version = "5.0.0") | |||
public CalcCountRecord clone() { | |||
@@ -105,4 +98,16 @@ public final class CalcCountRecord extends StandardRecord { | |||
public CalcCountRecord copy() { | |||
return new CalcCountRecord(this); | |||
} | |||
@Override | |||
public HSSFRecordTypes getGenericRecordType() { | |||
return HSSFRecordTypes.CALC_COUNT; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties( | |||
"iterations", this::getIterations | |||
); | |||
} | |||
} |
@@ -19,6 +19,10 @@ | |||
package org.apache.poi.hssf.record; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
import org.apache.poi.util.LittleEndianOutput; | |||
import org.apache.poi.util.Removal; | |||
@@ -84,17 +88,6 @@ public final class CalcModeRecord extends StandardRecord { | |||
return field_1_calcmode; | |||
} | |||
public String toString() | |||
{ | |||
StringBuilder buffer = new StringBuilder(); | |||
buffer.append("[CALCMODE]\n"); | |||
buffer.append(" .calcmode = ") | |||
.append(Integer.toHexString(getCalcMode())).append("\n"); | |||
buffer.append("[/CALCMODE]\n"); | |||
return buffer.toString(); | |||
} | |||
public void serialize(LittleEndianOutput out) { | |||
out.writeShort(getCalcMode()); | |||
} | |||
@@ -109,7 +102,7 @@ public final class CalcModeRecord extends StandardRecord { | |||
} | |||
@Override | |||
@SuppressWarnings("squid:S2975") | |||
@SuppressWarnings({"squid:S2975", "MethodDoesntCallSuperMethod"}) | |||
@Deprecated | |||
@Removal(version = "5.0.0") | |||
public CalcModeRecord clone() { | |||
@@ -120,4 +113,16 @@ public final class CalcModeRecord extends StandardRecord { | |||
public CalcModeRecord copy() { | |||
return new CalcModeRecord(this); | |||
} | |||
@Override | |||
public HSSFRecordTypes getGenericRecordType() { | |||
return HSSFRecordTypes.CALC_MODE; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties( | |||
"calcMode", this::getCalcMode | |||
); | |||
} | |||
} |
@@ -17,7 +17,10 @@ | |||
package org.apache.poi.hssf.record; | |||
import org.apache.poi.util.HexDump; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
import org.apache.poi.util.LittleEndianOutput; | |||
/** | |||
@@ -86,30 +89,6 @@ public abstract class CellRecord extends StandardRecord implements CellValueReco | |||
return (short) _formatIndex; | |||
} | |||
@Override | |||
public final String toString() { | |||
StringBuilder sb = new StringBuilder(); | |||
String recordName = getRecordName(); | |||
sb.append("[").append(recordName).append("]\n"); | |||
sb.append(" .row = ").append(HexDump.shortToHex(getRow())).append("\n"); | |||
sb.append(" .col = ").append(HexDump.shortToHex(getColumn())).append("\n"); | |||
sb.append(" .xfindex= ").append(HexDump.shortToHex(getXFIndex())).append("\n"); | |||
appendValueText(sb); | |||
sb.append("\n"); | |||
sb.append("[/").append(recordName).append("]\n"); | |||
return sb.toString(); | |||
} | |||
/** | |||
* Append specific debug info (used by {@link #toString()} for the value | |||
* contained in this record. Trailing new-line should not be appended | |||
* (superclass does that). | |||
* | |||
* @param sb the StringBuilder to write to | |||
*/ | |||
protected abstract void appendValueText(StringBuilder sb); | |||
/** | |||
* Gets the debug info BIFF record type name (used by {@link #toString()}. | |||
* | |||
@@ -144,4 +123,13 @@ public abstract class CellRecord extends StandardRecord implements CellValueReco | |||
@Override | |||
public abstract CellRecord copy(); | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties( | |||
"row", this::getRow, | |||
"col", this::getColumn, | |||
"xfIndex", this::getXFIndex | |||
); | |||
} | |||
} |
@@ -19,7 +19,11 @@ | |||
package org.apache.poi.hssf.record; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.util.CodePageUtil; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
import org.apache.poi.util.LittleEndianOutput; | |||
/** | |||
@@ -77,17 +81,6 @@ public final class CodepageRecord extends StandardRecord { | |||
return field_1_codepage; | |||
} | |||
public String toString() | |||
{ | |||
StringBuilder buffer = new StringBuilder(); | |||
buffer.append("[CODEPAGE]\n"); | |||
buffer.append(" .codepage = ") | |||
.append(Integer.toHexString(getCodepage())).append("\n"); | |||
buffer.append("[/CODEPAGE]\n"); | |||
return buffer.toString(); | |||
} | |||
public void serialize(LittleEndianOutput out) { | |||
out.writeShort(getCodepage()); | |||
} | |||
@@ -105,4 +98,16 @@ public final class CodepageRecord extends StandardRecord { | |||
public CodepageRecord copy() { | |||
return new CodepageRecord(this); | |||
} | |||
@Override | |||
public HSSFRecordTypes getGenericRecordType() { | |||
return HSSFRecordTypes.CODEPAGE; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties( | |||
"codepage", this::getCodepage | |||
); | |||
} | |||
} |
@@ -17,9 +17,12 @@ | |||
package org.apache.poi.hssf.record; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.util.BitField; | |||
import org.apache.poi.util.BitFieldFactory; | |||
import org.apache.poi.util.HexDump; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
import org.apache.poi.util.LittleEndianOutput; | |||
import org.apache.poi.util.Removal; | |||
@@ -216,10 +219,7 @@ public final class ColumnInfoRecord extends StandardRecord { | |||
if (_options != other._options) { | |||
return false; | |||
} | |||
if (_colWidth != other._colWidth) { | |||
return false; | |||
} | |||
return true; | |||
return _colWidth == other._colWidth; | |||
} | |||
public short getSid() { | |||
@@ -239,24 +239,8 @@ public final class ColumnInfoRecord extends StandardRecord { | |||
return 12; | |||
} | |||
public String toString() { | |||
StringBuilder sb = new StringBuilder(); | |||
sb.append("[COLINFO]\n"); | |||
sb.append(" colfirst = ").append(getFirstColumn()).append("\n"); | |||
sb.append(" collast = ").append(getLastColumn()).append("\n"); | |||
sb.append(" colwidth = ").append(getColumnWidth()).append("\n"); | |||
sb.append(" xfindex = ").append(getXFIndex()).append("\n"); | |||
sb.append(" options = ").append(HexDump.shortToHex(_options)).append("\n"); | |||
sb.append(" hidden = ").append(getHidden()).append("\n"); | |||
sb.append(" olevel = ").append(getOutlineLevel()).append("\n"); | |||
sb.append(" collapsed= ").append(getCollapsed()).append("\n"); | |||
sb.append("[/COLINFO]\n"); | |||
return sb.toString(); | |||
} | |||
@Override | |||
@SuppressWarnings("squid:S2975") | |||
@SuppressWarnings({"squid:S2975", "MethodDoesntCallSuperMethod"}) | |||
@Deprecated | |||
@Removal(version = "5.0.0") | |||
public ColumnInfoRecord clone() { | |||
@@ -267,4 +251,23 @@ public final class ColumnInfoRecord extends StandardRecord { | |||
public ColumnInfoRecord copy() { | |||
return new ColumnInfoRecord(this); | |||
} | |||
@Override | |||
public HSSFRecordTypes getGenericRecordType() { | |||
return HSSFRecordTypes.COLUMN_INFO; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties( | |||
"firstColumn", this::getFirstColumn, | |||
"lastColumn", this::getLastColumn, | |||
"columnWidth", this::getColumnWidth, | |||
"xfIndex", this::getXFIndex, | |||
"options", () -> _options, | |||
"hidden", this::getHidden, | |||
"outlineLevel", this::getOutlineLevel, | |||
"collapsed", this::getCollapsed | |||
); | |||
} | |||
} |
@@ -17,9 +17,14 @@ | |||
package org.apache.poi.hssf.record; | |||
import static org.apache.poi.util.GenericRecordUtil.getBitsAsString; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.util.BitField; | |||
import org.apache.poi.util.BitFieldFactory; | |||
import org.apache.poi.util.HexDump; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
import org.apache.poi.util.LittleEndianInput; | |||
import org.apache.poi.util.LittleEndianOutput; | |||
import org.apache.poi.util.RecordFormatException; | |||
@@ -89,6 +94,10 @@ public final class CommonObjectDataSubRecord extends SubRecord { | |||
} | |||
public CommonObjectDataSubRecord(LittleEndianInput in, int size) { | |||
this(in, size, -1); | |||
} | |||
CommonObjectDataSubRecord(LittleEndianInput in, int size, int cmoOt) { | |||
if (size != 18) { | |||
throw new RecordFormatException("Expected size 18 but got (" + size + ")"); | |||
} | |||
@@ -100,45 +109,6 @@ public final class CommonObjectDataSubRecord extends SubRecord { | |||
field_6_reserved3 = in.readInt(); | |||
} | |||
@Override | |||
public String toString() | |||
{ | |||
StringBuilder buffer = new StringBuilder(); | |||
buffer.append("[ftCmo]\n"); | |||
buffer.append(" .objectType = ") | |||
.append("0x").append(HexDump.toHex( getObjectType ())) | |||
.append(" (").append( getObjectType() ).append(" )"); | |||
buffer.append(System.getProperty("line.separator")); | |||
buffer.append(" .objectId = ") | |||
.append("0x").append(HexDump.toHex( getObjectId ())) | |||
.append(" (").append( getObjectId() ).append(" )"); | |||
buffer.append(System.getProperty("line.separator")); | |||
buffer.append(" .option = ") | |||
.append("0x").append(HexDump.toHex( getOption ())) | |||
.append(" (").append( getOption() ).append(" )"); | |||
buffer.append(System.getProperty("line.separator")); | |||
buffer.append(" .locked = ").append(isLocked()).append('\n'); | |||
buffer.append(" .printable = ").append(isPrintable()).append('\n'); | |||
buffer.append(" .autofill = ").append(isAutofill()).append('\n'); | |||
buffer.append(" .autoline = ").append(isAutoline()).append('\n'); | |||
buffer.append(" .reserved1 = ") | |||
.append("0x").append(HexDump.toHex( getReserved1 ())) | |||
.append(" (").append( getReserved1() ).append(" )"); | |||
buffer.append(System.getProperty("line.separator")); | |||
buffer.append(" .reserved2 = ") | |||
.append("0x").append(HexDump.toHex( getReserved2 ())) | |||
.append(" (").append( getReserved2() ).append(" )"); | |||
buffer.append(System.getProperty("line.separator")); | |||
buffer.append(" .reserved3 = ") | |||
.append("0x").append(HexDump.toHex( getReserved3 ())) | |||
.append(" (").append( getReserved3() ).append(" )"); | |||
buffer.append(System.getProperty("line.separator")); | |||
buffer.append("[/ftCmo]\n"); | |||
return buffer.toString(); | |||
} | |||
@Override | |||
public void serialize(LittleEndianOutput out) { | |||
@@ -442,4 +412,23 @@ public final class CommonObjectDataSubRecord extends SubRecord { | |||
{ | |||
return autoline.isSet(field_3_option); | |||
} | |||
@Override | |||
public SubRecordTypes getGenericRecordType() { | |||
return SubRecordTypes.COMMON_OBJECT_DATA; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties( | |||
"objectType", this::getObjectType, | |||
"objectId", this::getObjectId, | |||
"option", getBitsAsString(this::getOption, | |||
new BitField[]{locked,printable,autofill,autoline}, | |||
new String[]{"LOCKED","PRINTABLE","AUTOFILL","AUTOLINE"}), | |||
"reserved1", this::getReserved1, | |||
"reserved2", this::getReserved2, | |||
"reserved3", this::getReserved3 | |||
); | |||
} | |||
} |
@@ -17,7 +17,10 @@ | |||
package org.apache.poi.hssf.record; | |||
import org.apache.poi.util.HexDump; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
import org.apache.poi.util.LittleEndianOutput; | |||
import org.apache.poi.util.Removal; | |||
@@ -55,15 +58,6 @@ public final class ContinueRecord extends StandardRecord { | |||
return _data; | |||
} | |||
public String toString() { | |||
StringBuilder buffer = new StringBuilder(); | |||
buffer.append("[CONTINUE RECORD]\n"); | |||
buffer.append(" .data = ").append(HexDump.toHex(_data)).append("\n"); | |||
buffer.append("[/CONTINUE RECORD]\n"); | |||
return buffer.toString(); | |||
} | |||
public short getSid() { | |||
return sid; | |||
} | |||
@@ -73,7 +67,7 @@ public final class ContinueRecord extends StandardRecord { | |||
} | |||
@Override | |||
@SuppressWarnings("squid:S2975") | |||
@SuppressWarnings({"squid:S2975", "MethodDoesntCallSuperMethod"}) | |||
@Deprecated | |||
@Removal(version = "5.0.0") | |||
public ContinueRecord clone() { | |||
@@ -84,4 +78,14 @@ public final class ContinueRecord extends StandardRecord { | |||
public ContinueRecord copy() { | |||
return new ContinueRecord(this); | |||
} | |||
@Override | |||
public HSSFRecordTypes getGenericRecordType() { | |||
return HSSFRecordTypes.CONTINUE; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties("data", this::getData); | |||
} | |||
} |
@@ -19,6 +19,10 @@ | |||
package org.apache.poi.hssf.record; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
import org.apache.poi.util.LittleEndianOutput; | |||
/** | |||
@@ -93,19 +97,6 @@ public final class CountryRecord extends StandardRecord { | |||
return field_2_current_country; | |||
} | |||
public String toString() | |||
{ | |||
StringBuilder buffer = new StringBuilder(); | |||
buffer.append("[COUNTRY]\n"); | |||
buffer.append(" .defaultcountry = ") | |||
.append(Integer.toHexString(getDefaultCountry())).append("\n"); | |||
buffer.append(" .currentcountry = ") | |||
.append(Integer.toHexString(getCurrentCountry())).append("\n"); | |||
buffer.append("[/COUNTRY]\n"); | |||
return buffer.toString(); | |||
} | |||
public void serialize(LittleEndianOutput out) { | |||
out.writeShort(getDefaultCountry()); | |||
out.writeShort(getCurrentCountry()); | |||
@@ -124,4 +115,17 @@ public final class CountryRecord extends StandardRecord { | |||
public CountryRecord copy() { | |||
return new CountryRecord(this); | |||
} | |||
@Override | |||
public HSSFRecordTypes getGenericRecordType() { | |||
return HSSFRecordTypes.COUNTRY; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties( | |||
"defaultCountry", this::getDefaultCountry, | |||
"currentCountry", this::getCurrentCountry | |||
); | |||
} | |||
} |
@@ -17,7 +17,10 @@ | |||
package org.apache.poi.hssf.record; | |||
import org.apache.poi.util.HexDump; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
import org.apache.poi.util.LittleEndianOutput; | |||
import org.apache.poi.util.Removal; | |||
@@ -50,19 +53,6 @@ public final class DBCellRecord extends StandardRecord { | |||
} | |||
} | |||
public String toString() { | |||
StringBuilder buffer = new StringBuilder(); | |||
buffer.append("[DBCELL]\n"); | |||
buffer.append(" .rowoffset = ").append(HexDump.intToHex(field_1_row_offset)).append("\n"); | |||
for (int k = 0; k < field_2_cell_offsets.length; k++) { | |||
buffer.append(" .cell_").append(k).append(" = ") | |||
.append(HexDump.shortToHex(field_2_cell_offsets[ k ])).append("\n"); | |||
} | |||
buffer.append("[/DBCELL]\n"); | |||
return buffer.toString(); | |||
} | |||
public void serialize(LittleEndianOutput out) { | |||
out.writeInt(field_1_row_offset); | |||
for (short field_2_cell_offset : field_2_cell_offsets) { | |||
@@ -78,7 +68,7 @@ public final class DBCellRecord extends StandardRecord { | |||
} | |||
@Override | |||
@SuppressWarnings("squid:S2975") | |||
@SuppressWarnings({"squid:S2975", "MethodDoesntCallSuperMethod"}) | |||
@Deprecated | |||
@Removal(version = "5.0.0") | |||
public DBCellRecord clone() { | |||
@@ -90,4 +80,17 @@ public final class DBCellRecord extends StandardRecord { | |||
// safe because immutable | |||
return this; | |||
} | |||
@Override | |||
public HSSFRecordTypes getGenericRecordType() { | |||
return HSSFRecordTypes.DB_CELL; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties( | |||
"rowOffset", () -> field_1_row_offset, | |||
"cellOffsets", () -> field_2_cell_offsets | |||
); | |||
} | |||
} |
@@ -20,7 +20,10 @@ package org.apache.poi.hssf.record; | |||
import java.io.ByteArrayInputStream; | |||
import java.util.Arrays; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
import org.apache.poi.util.IOUtils; | |||
import org.apache.poi.util.LittleEndianOutput; | |||
import org.apache.poi.util.RecordFormatException; | |||
@@ -228,25 +231,6 @@ public class DConRefRecord extends StandardRecord { | |||
return lastRow; | |||
} | |||
@Override | |||
public String toString() | |||
{ | |||
StringBuilder b = new StringBuilder(); | |||
b.append("[DCONREF]\n"); | |||
b.append(" .ref\n"); | |||
b.append(" .firstrow = ").append(firstRow).append("\n"); | |||
b.append(" .lastrow = ").append(lastRow).append("\n"); | |||
b.append(" .firstcol = ").append(firstCol).append("\n"); | |||
b.append(" .lastcol = ").append(lastCol).append("\n"); | |||
b.append(" .cch = ").append(charCount).append("\n"); | |||
b.append(" .stFile\n"); | |||
b.append(" .h = ").append(charType).append("\n"); | |||
b.append(" .rgb = ").append(getReadablePath()).append("\n"); | |||
b.append("[/DCONREF]\n"); | |||
return b.toString(); | |||
} | |||
/** | |||
* | |||
* @return raw path byte array. | |||
@@ -298,4 +282,22 @@ public class DConRefRecord extends StandardRecord { | |||
ric.nextRecord(); | |||
return ric; | |||
} | |||
@Override | |||
public HSSFRecordTypes getGenericRecordType() { | |||
return HSSFRecordTypes.DCON_REF; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties( | |||
"firstRow", this::getFirstRow, | |||
"lastRow", this::getLastRow, | |||
"firstColumn", this::getFirstColumn, | |||
"lastColumn", this::getLastColumn, | |||
"charCount", () -> charCount, | |||
"charType", () -> charType, | |||
"path", this::getReadablePath | |||
); | |||
} | |||
} |
@@ -17,9 +17,12 @@ | |||
package org.apache.poi.hssf.record; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.util.BitField; | |||
import org.apache.poi.util.BitFieldFactory; | |||
import org.apache.poi.util.HexDump; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
import org.apache.poi.util.LittleEndianOutput; | |||
/** | |||
@@ -56,15 +59,6 @@ public final class DSFRecord extends StandardRecord { | |||
return biff5BookStreamFlag.isSet(_options); | |||
} | |||
public String toString() { | |||
StringBuilder buffer = new StringBuilder(); | |||
buffer.append("[DSF]\n"); | |||
buffer.append(" .options = ").append(HexDump.shortToHex(_options)).append("\n"); | |||
buffer.append("[/DSF]\n"); | |||
return buffer.toString(); | |||
} | |||
public void serialize(LittleEndianOutput out) { | |||
out.writeShort(_options); | |||
} | |||
@@ -81,4 +75,17 @@ public final class DSFRecord extends StandardRecord { | |||
public DSFRecord copy() { | |||
return new DSFRecord(this); | |||
} | |||
@Override | |||
public HSSFRecordTypes getGenericRecordType() { | |||
return HSSFRecordTypes.DSF; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties( | |||
"options", () -> _options, | |||
"biff5BookStreamPresent", this::isBiff5BookStreamPresent | |||
); | |||
} | |||
} |
@@ -17,6 +17,10 @@ | |||
package org.apache.poi.hssf.record; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
import org.apache.poi.util.LittleEndianOutput; | |||
import org.apache.poi.util.Removal; | |||
@@ -135,20 +139,6 @@ public final class DVALRecord extends StandardRecord { | |||
return field_5_dv_no; | |||
} | |||
public String toString() { | |||
StringBuilder buffer = new StringBuilder(); | |||
buffer.append("[DVAL]\n"); | |||
buffer.append(" .options = ").append(getOptions()).append('\n'); | |||
buffer.append(" .horizPos = ").append(getHorizontalPos()).append('\n'); | |||
buffer.append(" .vertPos = ").append(getVerticalPos()).append('\n'); | |||
buffer.append(" .comboObjectID = ").append(Integer.toHexString(getObjectID())).append("\n"); | |||
buffer.append(" .DVRecordsNumber = ").append(Integer.toHexString(getDVRecNo())).append("\n"); | |||
buffer.append("[/DVAL]\n"); | |||
return buffer.toString(); | |||
} | |||
public void serialize(LittleEndianOutput out) { | |||
out.writeShort(getOptions()); | |||
out.writeInt(getHorizontalPos()); | |||
@@ -166,7 +156,7 @@ public final class DVALRecord extends StandardRecord { | |||
} | |||
@Override | |||
@SuppressWarnings("squid:S2975") | |||
@SuppressWarnings({"squid:S2975", "MethodDoesntCallSuperMethod"}) | |||
@Deprecated | |||
@Removal(version = "5.0.0") | |||
public DVALRecord clone() { | |||
@@ -177,4 +167,20 @@ public final class DVALRecord extends StandardRecord { | |||
public DVALRecord copy() { | |||
return new DVALRecord(this); | |||
} | |||
@Override | |||
public HSSFRecordTypes getGenericRecordType() { | |||
return HSSFRecordTypes.DVAL; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties( | |||
"options", this::getOptions, | |||
"horizPos", this::getHorizontalPos, | |||
"vertPos", this::getVerticalPos, | |||
"comboObjectID", this::getObjectID, | |||
"dvRecordsNumber", this::getDVRecNo | |||
); | |||
} | |||
} |
@@ -17,13 +17,18 @@ | |||
package org.apache.poi.hssf.record; | |||
import static org.apache.poi.util.GenericRecordUtil.getBitsAsString; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.hssf.record.common.UnicodeString; | |||
import org.apache.poi.hssf.usermodel.HSSFDataValidation; | |||
import org.apache.poi.ss.formula.Formula; | |||
import org.apache.poi.ss.formula.ptg.Ptg; | |||
import org.apache.poi.ss.util.CellRangeAddress; | |||
import org.apache.poi.ss.util.CellRangeAddressList; | |||
import org.apache.poi.util.BitField; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
import org.apache.poi.util.LittleEndianOutput; | |||
import org.apache.poi.util.Removal; | |||
import org.apache.poi.util.StringUtil; | |||
@@ -53,6 +58,15 @@ public final class DVRecord extends StandardRecord { | |||
private static final BitField opt_show_error_on_invalid_value = new BitField(0x00080000); | |||
private static final BitField opt_condition_operator = new BitField(0x00700000); | |||
private static final int[] FLAG_MASKS = { 0x0000000F,0x00000070,0x00000080,0x00000100, | |||
0x00000200,0x00040000,0x00080000,0x00700000 }; | |||
private static final String[] FLAG_NAMES = { "DATA_TYPE", "ERROR_STYLE", "STRING_LIST_FORMULA", | |||
"EMPTY_CELL_ALLOWED", "SUPPRESS_DROPDOWN_ARROW", "SHOW_PROMPT_ON_CELL_SELECTED", | |||
"SHOW_ERROR_ON_INVALID_VALUE", "CONDITION_OPERATOR" }; | |||
/** Option flags */ | |||
private int _option_flags; | |||
/** Title of the prompt box, cannot be longer than 32 chars */ | |||
@@ -250,55 +264,6 @@ public final class DVRecord extends StandardRecord { | |||
} | |||
public String toString() { | |||
StringBuilder sb = new StringBuilder(); | |||
sb.append("[DV]\n"); | |||
sb.append(" options=").append(Integer.toHexString(_option_flags)); | |||
sb.append(" title-prompt=").append(formatTextTitle(_promptTitle)); | |||
sb.append(" title-error=").append(formatTextTitle(_errorTitle)); | |||
sb.append(" text-prompt=").append(formatTextTitle(_promptText)); | |||
sb.append(" text-error=").append(formatTextTitle(_errorText)); | |||
sb.append("\n"); | |||
appendFormula(sb, "Formula 1:", _formula1); | |||
appendFormula(sb, "Formula 2:", _formula2); | |||
sb.append("Regions: "); | |||
int nRegions = _regions.countRanges(); | |||
for(int i=0; i<nRegions; i++) { | |||
if (i>0) { | |||
sb.append(", "); | |||
} | |||
CellRangeAddress addr = _regions.getCellRangeAddress(i); | |||
sb.append('(').append(addr.getFirstRow()).append(',').append(addr.getLastRow()); | |||
sb.append(',').append(addr.getFirstColumn()).append(',').append(addr.getLastColumn()).append(')'); | |||
} | |||
sb.append("\n"); | |||
sb.append("[/DV]"); | |||
return sb.toString(); | |||
} | |||
private static String formatTextTitle(UnicodeString us) { | |||
String str = us.getString(); | |||
if (str.length() == 1 && str.charAt(0) == '\0') { | |||
return "'\\0'"; | |||
} | |||
return str; | |||
} | |||
private static void appendFormula(StringBuilder sb, String label, Formula f) { | |||
sb.append(label); | |||
if (f == null) { | |||
sb.append("<empty>\n"); | |||
return; | |||
} | |||
Ptg[] ptgs = f.getTokens(); | |||
sb.append('\n'); | |||
for (Ptg ptg : ptgs) { | |||
sb.append('\t').append(ptg).append('\n'); | |||
} | |||
} | |||
public void serialize(LittleEndianOutput out) { | |||
out.writeInt(_option_flags); | |||
@@ -367,7 +332,7 @@ public final class DVRecord extends StandardRecord { | |||
} | |||
@Override | |||
@SuppressWarnings("squid:S2975") | |||
@SuppressWarnings({"squid:S2975", "MethodDoesntCallSuperMethod"}) | |||
@Deprecated | |||
@Removal(version = "5.0.0") | |||
public DVRecord clone() { | |||
@@ -379,4 +344,23 @@ public final class DVRecord extends StandardRecord { | |||
public DVRecord copy() { | |||
return new DVRecord(this); | |||
} | |||
@Override | |||
public HSSFRecordTypes getGenericRecordType() { | |||
return HSSFRecordTypes.DV; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties( | |||
"optionFlags", getBitsAsString(() -> _option_flags, FLAG_MASKS, FLAG_NAMES), | |||
"promptTitle", this::getPromptTitle, | |||
"errorTitle", this::getErrorTitle, | |||
"promptText", this::getPromptText, | |||
"errorText", this::getErrorText, | |||
"formula1", this::getFormula1, | |||
"formula2", this::getFormula2, | |||
"regions", () -> _regions | |||
); | |||
} | |||
} |
@@ -19,6 +19,10 @@ | |||
package org.apache.poi.hssf.record; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
import org.apache.poi.util.LittleEndianOutput; | |||
/** | |||
@@ -63,17 +67,6 @@ public final class DateWindow1904Record extends StandardRecord { | |||
return field_1_window; | |||
} | |||
public String toString() | |||
{ | |||
StringBuilder buffer = new StringBuilder(); | |||
buffer.append("[1904]\n"); | |||
buffer.append(" .is1904 = ") | |||
.append(Integer.toHexString(getWindowing())).append("\n"); | |||
buffer.append("[/1904]\n"); | |||
return buffer.toString(); | |||
} | |||
public void serialize(LittleEndianOutput out) { | |||
out.writeShort(getWindowing()); | |||
} | |||
@@ -91,4 +84,14 @@ public final class DateWindow1904Record extends StandardRecord { | |||
public DateWindow1904Record copy() { | |||
return new DateWindow1904Record(this); | |||
} | |||
@Override | |||
public HSSFRecordTypes getGenericRecordType() { | |||
return HSSFRecordTypes.DATE_WINDOW_1904; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties("is1904", this::getWindowing); | |||
} | |||
} |
@@ -17,6 +17,10 @@ | |||
package org.apache.poi.hssf.record; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
import org.apache.poi.util.LittleEndianOutput; | |||
import org.apache.poi.util.Removal; | |||
@@ -69,17 +73,6 @@ public final class DefaultColWidthRecord extends StandardRecord { | |||
return field_1_col_width; | |||
} | |||
public String toString() | |||
{ | |||
StringBuilder buffer = new StringBuilder(); | |||
buffer.append("[DEFAULTCOLWIDTH]\n"); | |||
buffer.append(" .colwidth = ") | |||
.append(Integer.toHexString(getColWidth())).append("\n"); | |||
buffer.append("[/DEFAULTCOLWIDTH]\n"); | |||
return buffer.toString(); | |||
} | |||
public void serialize(LittleEndianOutput out) { | |||
out.writeShort(getColWidth()); | |||
} | |||
@@ -94,7 +87,7 @@ public final class DefaultColWidthRecord extends StandardRecord { | |||
} | |||
@Override | |||
@SuppressWarnings("squid:S2975") | |||
@SuppressWarnings({"squid:S2975", "MethodDoesntCallSuperMethod"}) | |||
@Deprecated | |||
@Removal(version = "5.0.0") | |||
public DefaultColWidthRecord clone() { | |||
@@ -105,4 +98,16 @@ public final class DefaultColWidthRecord extends StandardRecord { | |||
public DefaultColWidthRecord copy() { | |||
return new DefaultColWidthRecord(this); | |||
} | |||
@Override | |||
public HSSFRecordTypes getGenericRecordType() { | |||
return HSSFRecordTypes.DEFAULT_COL_WIDTH; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties( | |||
"colWidth", this::getColWidth | |||
); | |||
} | |||
} |
@@ -18,6 +18,10 @@ | |||
package org.apache.poi.hssf.record; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
import org.apache.poi.util.LittleEndianOutput; | |||
import org.apache.poi.util.Removal; | |||
@@ -92,19 +96,6 @@ public final class DefaultRowHeightRecord extends StandardRecord { | |||
return field_2_row_height; | |||
} | |||
public String toString() | |||
{ | |||
StringBuilder buffer = new StringBuilder(); | |||
buffer.append("[DEFAULTROWHEIGHT]\n"); | |||
buffer.append(" .optionflags = ") | |||
.append(Integer.toHexString(getOptionFlags())).append("\n"); | |||
buffer.append(" .rowheight = ") | |||
.append(Integer.toHexString(getRowHeight())).append("\n"); | |||
buffer.append("[/DEFAULTROWHEIGHT]\n"); | |||
return buffer.toString(); | |||
} | |||
public void serialize(LittleEndianOutput out) { | |||
out.writeShort(getOptionFlags()); | |||
out.writeShort(getRowHeight()); | |||
@@ -120,7 +111,7 @@ public final class DefaultRowHeightRecord extends StandardRecord { | |||
} | |||
@Override | |||
@SuppressWarnings("squid:S2975") | |||
@SuppressWarnings({"squid:S2975", "MethodDoesntCallSuperMethod"}) | |||
@Deprecated | |||
@Removal(version = "5.0.0") | |||
public DefaultRowHeightRecord clone() { | |||
@@ -129,6 +120,19 @@ public final class DefaultRowHeightRecord extends StandardRecord { | |||
@Override | |||
public DefaultRowHeightRecord copy() { | |||
return new DefaultRowHeightRecord(this); | |||
return new DefaultRowHeightRecord(this); | |||
} | |||
@Override | |||
public HSSFRecordTypes getGenericRecordType() { | |||
return HSSFRecordTypes.DEFAULT_ROW_HEIGHT; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties( | |||
"optionFlags", this::getOptionFlags, | |||
"rowHeight", this::getRowHeight | |||
); | |||
} | |||
} |
@@ -17,6 +17,10 @@ | |||
package org.apache.poi.hssf.record; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
import org.apache.poi.util.LittleEndianOutput; | |||
import org.apache.poi.util.Removal; | |||
@@ -50,15 +54,6 @@ public final class DeltaRecord extends StandardRecord { | |||
return field_1_max_change; | |||
} | |||
public String toString() { | |||
StringBuilder buffer = new StringBuilder(); | |||
buffer.append("[DELTA]\n"); | |||
buffer.append(" .maxchange = ").append(getMaxChange()).append("\n"); | |||
buffer.append("[/DELTA]\n"); | |||
return buffer.toString(); | |||
} | |||
public void serialize(LittleEndianOutput out) { | |||
out.writeDouble(getMaxChange()); | |||
} | |||
@@ -72,7 +67,7 @@ public final class DeltaRecord extends StandardRecord { | |||
} | |||
@Override | |||
@SuppressWarnings("squid:S2975") | |||
@SuppressWarnings({"squid:S2975", "MethodDoesntCallSuperMethod"}) | |||
@Deprecated | |||
@Removal(version = "5.0.0") | |||
public DeltaRecord clone() { | |||
@@ -84,4 +79,14 @@ public final class DeltaRecord extends StandardRecord { | |||
// immutable | |||
return this; | |||
} | |||
@Override | |||
public HSSFRecordTypes getGenericRecordType() { | |||
return HSSFRecordTypes.DELTA; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties("maxChange", this::getMaxChange); | |||
} | |||
} |
@@ -19,6 +19,10 @@ | |||
package org.apache.poi.hssf.record; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
import org.apache.poi.util.LittleEndianOutput; | |||
import org.apache.poi.util.POILogFactory; | |||
import org.apache.poi.util.POILogger; | |||
@@ -145,25 +149,6 @@ public final class DimensionsRecord extends StandardRecord { | |||
return field_4_last_col; | |||
} | |||
public String toString() | |||
{ | |||
StringBuilder buffer = new StringBuilder(); | |||
buffer.append("[DIMENSIONS]\n"); | |||
buffer.append(" .firstrow = ") | |||
.append(Integer.toHexString(getFirstRow())).append("\n"); | |||
buffer.append(" .lastrow = ") | |||
.append(Integer.toHexString(getLastRow())).append("\n"); | |||
buffer.append(" .firstcol = ") | |||
.append(Integer.toHexString(getFirstCol())).append("\n"); | |||
buffer.append(" .lastcol = ") | |||
.append(Integer.toHexString(getLastCol())).append("\n"); | |||
buffer.append(" .zero = ") | |||
.append(Integer.toHexString(field_5_zero)).append("\n"); | |||
buffer.append("[/DIMENSIONS]\n"); | |||
return buffer.toString(); | |||
} | |||
public void serialize(LittleEndianOutput out) { | |||
out.writeInt(getFirstRow()); | |||
out.writeInt(getLastRow()); | |||
@@ -182,7 +167,7 @@ public final class DimensionsRecord extends StandardRecord { | |||
} | |||
@Override | |||
@SuppressWarnings("squid:S2975") | |||
@SuppressWarnings({"squid:S2975", "MethodDoesntCallSuperMethod"}) | |||
@Deprecated | |||
@Removal(version = "5.0.0") | |||
public DimensionsRecord clone() { | |||
@@ -193,4 +178,20 @@ public final class DimensionsRecord extends StandardRecord { | |||
public DimensionsRecord copy() { | |||
return new DimensionsRecord(this); | |||
} | |||
@Override | |||
public HSSFRecordTypes getGenericRecordType() { | |||
return HSSFRecordTypes.DIMENSIONS; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties( | |||
"firstRow", this::getFirstRow, | |||
"lastRow", this::getLastRow, | |||
"firstColumn", this::getFirstCol, | |||
"lastColumn", this::getLastCol, | |||
"zero", () -> field_5_zero | |||
); | |||
} | |||
} |
@@ -17,8 +17,9 @@ | |||
package org.apache.poi.hssf.record; | |||
import java.util.Iterator; | |||
import java.util.List; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.ddf.EscherRecord; | |||
import org.apache.poi.ddf.NullEscherSerializationListener; | |||
@@ -60,10 +61,8 @@ public final class DrawingGroupRecord extends AbstractEscherHolderRecord { | |||
} | |||
byte[] buffer = new byte[getRawDataSize()]; | |||
int pos = 0; | |||
for ( Iterator<EscherRecord> iterator = getEscherRecords().iterator(); iterator.hasNext(); ) | |||
{ | |||
EscherRecord r = iterator.next(); | |||
pos += r.serialize(pos, buffer, new NullEscherSerializationListener() ); | |||
for (EscherRecord r : getEscherRecords()) { | |||
pos += r.serialize(pos, buffer, new NullEscherSerializationListener()); | |||
} | |||
return writeData( offset, data, buffer ); | |||
@@ -92,9 +91,7 @@ public final class DrawingGroupRecord extends AbstractEscherHolderRecord { | |||
return rawData.length; | |||
} | |||
int size = 0; | |||
for ( Iterator<EscherRecord> iterator = escherRecords.iterator(); iterator.hasNext(); ) | |||
{ | |||
EscherRecord r = iterator.next(); | |||
for (EscherRecord r : escherRecords) { | |||
size += r.getRecordSize(); | |||
} | |||
return size; | |||
@@ -128,18 +125,28 @@ public final class DrawingGroupRecord extends AbstractEscherHolderRecord { | |||
private void writeHeader( byte[] data, int offset, int sizeExcludingHeader ) | |||
{ | |||
LittleEndian.putShort(data, 0 + offset, getSid()); | |||
LittleEndian.putShort(data, 2 + offset, (short) sizeExcludingHeader); | |||
LittleEndian.putShort(data, offset, getSid()); | |||
LittleEndian.putShort(data, offset + 2, (short) sizeExcludingHeader); | |||
} | |||
private void writeContinueHeader( byte[] data, int offset, int sizeExcludingHeader ) | |||
{ | |||
LittleEndian.putShort(data, 0 + offset, ContinueRecord.sid); | |||
LittleEndian.putShort(data, 2 + offset, (short) sizeExcludingHeader); | |||
LittleEndian.putShort(data, offset, ContinueRecord.sid); | |||
LittleEndian.putShort(data, offset + 2, (short) sizeExcludingHeader); | |||
} | |||
@Override | |||
public DrawingGroupRecord copy() { | |||
return new DrawingGroupRecord(this); | |||
} | |||
@Override | |||
public HSSFRecordTypes getGenericRecordType() { | |||
return HSSFRecordTypes.DRAWING_GROUP; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return null; | |||
} | |||
} |
@@ -17,6 +17,10 @@ | |||
package org.apache.poi.hssf.record; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
import org.apache.poi.util.LittleEndianOutput; | |||
import org.apache.poi.util.Removal; | |||
@@ -80,7 +84,7 @@ public final class DrawingRecord extends StandardRecord { | |||
} | |||
@Override | |||
@SuppressWarnings("squid:S2975") | |||
@SuppressWarnings({"squid:S2975", "MethodDoesntCallSuperMethod"}) | |||
@Deprecated | |||
@Removal(version = "5.0.0") | |||
public DrawingRecord clone() { | |||
@@ -97,7 +101,15 @@ public final class DrawingRecord extends StandardRecord { | |||
} | |||
@Override | |||
public String toString() { | |||
return "DrawingRecord["+recordData.length+"]"; | |||
public HSSFRecordTypes getGenericRecordType() { | |||
return HSSFRecordTypes.DRAWING; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties( | |||
"recordData", this::getRecordData, | |||
"contd", () -> contd | |||
); | |||
} | |||
} |
@@ -18,6 +18,8 @@ | |||
package org.apache.poi.hssf.record; | |||
import java.io.ByteArrayInputStream; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
/** | |||
* This is purely for the biff viewer. During normal operations we don't want | |||
@@ -66,4 +68,14 @@ public final class DrawingRecordForBiffViewer extends AbstractEscherHolderRecord | |||
public DrawingRecordForBiffViewer copy() { | |||
return new DrawingRecordForBiffViewer(this); | |||
} | |||
@Override | |||
public HSSFRecordTypes getGenericRecordType() { | |||
return HSSFRecordTypes.DRAWING; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return null; | |||
} | |||
} |
@@ -17,7 +17,11 @@ | |||
package org.apache.poi.hssf.record; | |||
import org.apache.poi.util.HexDump; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.common.usermodel.GenericRecord; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
import org.apache.poi.util.LittleEndianInput; | |||
import org.apache.poi.util.LittleEndianOutput; | |||
import org.apache.poi.util.Removal; | |||
@@ -34,7 +38,7 @@ public final class DrawingSelectionRecord extends StandardRecord { | |||
* From [MS-ODRAW].pdf sec 2.2.1<p> | |||
* TODO - make EscherRecordHeader {@link LittleEndianInput} aware and refactor with this | |||
*/ | |||
private static final class OfficeArtRecordHeader { | |||
private static final class OfficeArtRecordHeader implements GenericRecord { | |||
public static final int ENCODED_SIZE = 8; | |||
/** | |||
* lower 4 bits is 'version' usually 0x01 or 0x0F (for containers) | |||
@@ -45,12 +49,6 @@ public final class DrawingSelectionRecord extends StandardRecord { | |||
private final int _type; | |||
private final int _length; | |||
public OfficeArtRecordHeader(OfficeArtRecordHeader other) { | |||
_verAndInstance = other._verAndInstance; | |||
_type = other._type; | |||
_length = other._length; | |||
} | |||
public OfficeArtRecordHeader(LittleEndianInput in) { | |||
_verAndInstance = in.readUShort(); | |||
_type = in.readUShort(); | |||
@@ -63,11 +61,13 @@ public final class DrawingSelectionRecord extends StandardRecord { | |||
out.writeInt(_length); | |||
} | |||
public String debugFormatAsString() { | |||
return | |||
"ver+inst=" + HexDump.shortToHex(_verAndInstance) + | |||
" type=" + HexDump.shortToHex(_type) + | |||
" len=" + HexDump.intToHex(_length); | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties( | |||
"verAndInstance", () -> _verAndInstance, | |||
"type", () -> _type, | |||
"length", () -> _length | |||
); | |||
} | |||
} | |||
@@ -109,13 +109,13 @@ public final class DrawingSelectionRecord extends StandardRecord { | |||
out.writeInt(_cpsp); | |||
out.writeInt(_dgslk); | |||
out.writeInt(_spidFocus); | |||
for (int i = 0; i < _shapeIds.length; i++) { | |||
out.writeInt(_shapeIds[i]); | |||
for (int shapeId : _shapeIds) { | |||
out.writeInt(shapeId); | |||
} | |||
} | |||
@Override | |||
@SuppressWarnings("squid:S2975") | |||
@SuppressWarnings({"squid:S2975", "MethodDoesntCallSuperMethod"}) | |||
@Deprecated | |||
@Removal(version = "5.0.0") | |||
public DrawingSelectionRecord clone() { | |||
@@ -128,24 +128,19 @@ public final class DrawingSelectionRecord extends StandardRecord { | |||
return this; | |||
} | |||
public String toString() { | |||
StringBuilder sb = new StringBuilder(); | |||
sb.append("[MSODRAWINGSELECTION]\n"); | |||
sb.append(" .rh =(").append(_header.debugFormatAsString()).append(")\n"); | |||
sb.append(" .cpsp =").append(HexDump.intToHex(_cpsp)).append('\n'); | |||
sb.append(" .dgslk =").append(HexDump.intToHex(_dgslk)).append('\n'); | |||
sb.append(" .spidFocus=").append(HexDump.intToHex(_spidFocus)).append('\n'); | |||
sb.append(" .shapeIds =("); | |||
for (int i = 0; i < _shapeIds.length; i++) { | |||
if (i > 0) { | |||
sb.append(", "); | |||
} | |||
sb.append(HexDump.intToHex(_shapeIds[i])); | |||
} | |||
sb.append(")\n"); | |||
@Override | |||
public HSSFRecordTypes getGenericRecordType() { | |||
return HSSFRecordTypes.DRAWING_SELECTION; | |||
} | |||
sb.append("[/MSODRAWINGSELECTION]\n"); | |||
return sb.toString(); | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties( | |||
"rh", () -> _header, | |||
"cpsp", () -> _cpsp, | |||
"dgslk", () -> _dgslk, | |||
"spidFocus", () -> _spidFocus, | |||
"shapeIds", () -> _shapeIds | |||
); | |||
} | |||
} |
@@ -17,6 +17,9 @@ | |||
package org.apache.poi.hssf.record; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.util.LittleEndianOutput; | |||
import org.apache.poi.util.Removal; | |||
@@ -38,15 +41,6 @@ public final class EOFRecord extends StandardRecord { | |||
*/ | |||
public EOFRecord(RecordInputStream in) {} | |||
public String toString() | |||
{ | |||
StringBuilder buffer = new StringBuilder(); | |||
buffer.append("[EOF]\n"); | |||
buffer.append("[/EOF]\n"); | |||
return buffer.toString(); | |||
} | |||
public void serialize(LittleEndianOutput out) { | |||
} | |||
@@ -60,7 +54,7 @@ public final class EOFRecord extends StandardRecord { | |||
} | |||
@Override | |||
@SuppressWarnings("squid:S2975") | |||
@SuppressWarnings({"squid:S2975", "MethodDoesntCallSuperMethod"}) | |||
@Deprecated | |||
@Removal(version = "5.0.0") | |||
public EOFRecord clone() { | |||
@@ -71,4 +65,14 @@ public final class EOFRecord extends StandardRecord { | |||
public EOFRecord copy() { | |||
return instance; | |||
} | |||
@Override | |||
public HSSFRecordTypes getGenericRecordType() { | |||
return HSSFRecordTypes.EOF; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return null; | |||
} | |||
} |
@@ -18,13 +18,15 @@ | |||
package org.apache.poi.hssf.record; | |||
import java.io.ByteArrayInputStream; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.ss.formula.ptg.Area3DPtg; | |||
import org.apache.poi.ss.formula.ptg.AreaPtg; | |||
import org.apache.poi.ss.formula.ptg.Ptg; | |||
import org.apache.poi.ss.formula.ptg.Ref3DPtg; | |||
import org.apache.poi.ss.formula.ptg.RefPtg; | |||
import org.apache.poi.util.HexDump; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
import org.apache.poi.util.IOUtils; | |||
import org.apache.poi.util.LittleEndianConsts; | |||
import org.apache.poi.util.LittleEndianInput; | |||
@@ -87,6 +89,10 @@ public final class EmbeddedObjectRefSubRecord extends SubRecord { | |||
} | |||
public EmbeddedObjectRefSubRecord(LittleEndianInput in, int size) { | |||
this(in,size,-1); | |||
} | |||
EmbeddedObjectRefSubRecord(LittleEndianInput in, int size, int cmoOt) { | |||
// Much guess-work going on here due to lack of any documentation. | |||
// See similar source code in OOO: | |||
@@ -327,32 +333,6 @@ public final class EmbeddedObjectRefSubRecord extends SubRecord { | |||
return new EmbeddedObjectRefSubRecord(this); | |||
} | |||
public String toString() { | |||
StringBuilder sb = new StringBuilder(); | |||
sb.append("[ftPictFmla]\n"); | |||
sb.append(" .f2unknown = ").append(HexDump.intToHex(field_1_unknown_int)).append("\n"); | |||
if (field_2_refPtg == null) { | |||
sb.append(" .f3unknown = ").append(HexDump.toHex(field_2_unknownFormulaData)).append("\n"); | |||
} else { | |||
sb.append(" .formula = ").append(field_2_refPtg).append("\n"); | |||
} | |||
if (field_4_ole_classname != null) { | |||
sb.append(" .unicodeFlag = ").append(field_3_unicode_flag).append("\n"); | |||
sb.append(" .oleClassname = ").append(field_4_ole_classname).append("\n"); | |||
} | |||
if (field_4_unknownByte != null) { | |||
sb.append(" .f4unknown = ").append(HexDump.byteToHex(field_4_unknownByte)).append("\n"); | |||
} | |||
if (field_5_stream_id != null) { | |||
sb.append(" .streamId = ").append(HexDump.intToHex(field_5_stream_id)).append("\n"); | |||
} | |||
if (field_6_unknown.length > 0) { | |||
sb.append(" .f7unknown = ").append(HexDump.toHex(field_6_unknown)).append("\n"); | |||
} | |||
sb.append("[/ftPictFmla]"); | |||
return sb.toString(); | |||
} | |||
public void setUnknownFormulaData(byte[] formularData) { | |||
field_2_unknownFormulaData = formularData; | |||
} | |||
@@ -364,4 +344,23 @@ public final class EmbeddedObjectRefSubRecord extends SubRecord { | |||
public void setStorageId(int storageId) { | |||
field_5_stream_id = storageId; | |||
} | |||
@Override | |||
public SubRecordTypes getGenericRecordType() { | |||
return SubRecordTypes.EMBEDDED_OBJECT_REF; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties( | |||
"f2unknown", () -> field_1_unknown_int, | |||
"f3unknown", () -> field_2_unknownFormulaData, | |||
"formula", () -> field_2_refPtg, | |||
"unicodeFlag", () -> field_3_unicode_flag, | |||
"oleClassname", () -> field_4_ole_classname, | |||
"f4unknown", () -> field_4_unknownByte, | |||
"streamId", () -> field_5_stream_id, | |||
"f7unknown", () -> field_6_unknown | |||
); | |||
} | |||
} |
@@ -17,6 +17,9 @@ | |||
package org.apache.poi.hssf.record; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.util.LittleEndianInput; | |||
import org.apache.poi.util.LittleEndianOutput; | |||
import org.apache.poi.util.RecordFormatException; | |||
@@ -39,6 +42,10 @@ public final class EndSubRecord extends SubRecord { | |||
* @param size must be 0 | |||
*/ | |||
public EndSubRecord(LittleEndianInput in, int size) { | |||
this(in, size, -1); | |||
} | |||
EndSubRecord(LittleEndianInput in, int size, int cmoOt) { | |||
if ((size & 0xFF) != ENCODED_SIZE) { // mask out random crap in upper byte | |||
throw new RecordFormatException("Unexpected size (" + size + ")"); | |||
} | |||
@@ -49,16 +56,6 @@ public final class EndSubRecord extends SubRecord { | |||
return true; | |||
} | |||
public String toString() | |||
{ | |||
StringBuilder buffer = new StringBuilder(); | |||
buffer.append("[ftEnd]\n"); | |||
buffer.append("[/ftEnd]\n"); | |||
return buffer.toString(); | |||
} | |||
public void serialize(LittleEndianOutput out) { | |||
out.writeShort(sid); | |||
out.writeShort(ENCODED_SIZE); | |||
@@ -85,4 +82,14 @@ public final class EndSubRecord extends SubRecord { | |||
public EndSubRecord copy() { | |||
return new EndSubRecord(); | |||
} | |||
@Override | |||
public SubRecordTypes getGenericRecordType() { | |||
return SubRecordTypes.END; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return null; | |||
} | |||
} |
@@ -29,6 +29,7 @@ import java.util.Iterator; | |||
import java.util.LinkedHashMap; | |||
import java.util.List; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.ddf.DefaultEscherRecordFactory; | |||
import org.apache.poi.ddf.EscherClientDataRecord; | |||
@@ -39,6 +40,7 @@ import org.apache.poi.ddf.EscherSerializationListener; | |||
import org.apache.poi.ddf.EscherSpRecord; | |||
import org.apache.poi.ddf.EscherSpgrRecord; | |||
import org.apache.poi.ddf.EscherTextboxRecord; | |||
import org.apache.poi.util.GenericRecordXmlWriter; | |||
import org.apache.poi.util.IOUtils; | |||
import org.apache.poi.util.RecordFormatException; | |||
@@ -332,23 +334,6 @@ public final class EscherAggregate extends AbstractEscherHolderRecord { | |||
return sid; | |||
} | |||
/** | |||
* Calculates the string representation of this record. This is | |||
* simply a dump of all the records. | |||
*/ | |||
public String toString() { | |||
String nl = System.getProperty("line.separtor"); | |||
StringBuilder result = new StringBuilder(); | |||
result.append('[').append(getRecordName()).append(']').append(nl); | |||
for (EscherRecord escherRecord : getEscherRecords()) { | |||
result.append(escherRecord); | |||
} | |||
result.append("[/").append(getRecordName()).append(']').append(nl); | |||
return result.toString(); | |||
} | |||
/** | |||
* Calculates the xml representation of this record. This is | |||
* simply a dump of all the records. | |||
@@ -356,13 +341,7 @@ public final class EscherAggregate extends AbstractEscherHolderRecord { | |||
* @return xml representation of the all aggregated records | |||
*/ | |||
public String toXml(String tab) { | |||
StringBuilder builder = new StringBuilder(); | |||
builder.append(tab).append("<").append(getRecordName()).append(">\n"); | |||
for (EscherRecord escherRecord : getEscherRecords()) { | |||
builder.append(escherRecord.toXml(tab + "\t")); | |||
} | |||
builder.append(tab).append("</").append(getRecordName()).append(">\n"); | |||
return builder.toString(); | |||
return GenericRecordXmlWriter.marshal(this); | |||
} | |||
/** | |||
@@ -789,4 +768,14 @@ public final class EscherAggregate extends AbstractEscherHolderRecord { | |||
public EscherAggregate copy() { | |||
return new EscherAggregate(this); | |||
} | |||
@Override | |||
public HSSFRecordTypes getGenericRecordType() { | |||
return HSSFRecordTypes.ESCHER_AGGREGATE; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return null; | |||
} | |||
} |
@@ -18,10 +18,14 @@ | |||
package org.apache.poi.hssf.record; | |||
import java.util.ArrayList; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import java.util.stream.Stream; | |||
import org.apache.poi.common.usermodel.GenericRecord; | |||
import org.apache.poi.hssf.record.cont.ContinuableRecord; | |||
import org.apache.poi.hssf.record.cont.ContinuableRecordOutput; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
import org.apache.poi.util.LittleEndianOutput; | |||
/** | |||
@@ -38,7 +42,7 @@ public final class ExtSSTRecord extends ContinuableRecord { | |||
public static final int MAX_BUCKETS = 128; | |||
public static final class InfoSubRecord { | |||
public static final class InfoSubRecord implements GenericRecord { | |||
public static final int ENCODED_SIZE = 8; | |||
private int field_1_stream_pos; // stream pointer to the SST record | |||
private int field_2_bucket_sst_offset; // don't really understand this yet. | |||
@@ -62,8 +66,7 @@ public final class ExtSSTRecord extends ContinuableRecord { | |||
field_3_zero = other.field_3_zero; | |||
} | |||
public InfoSubRecord(RecordInputStream in) | |||
{ | |||
public InfoSubRecord(RecordInputStream in) { | |||
field_1_stream_pos = in.readInt(); | |||
field_2_bucket_sst_offset = in.readShort(); | |||
field_3_zero = in.readShort(); | |||
@@ -82,6 +85,14 @@ public final class ExtSSTRecord extends ContinuableRecord { | |||
out.writeShort(field_2_bucket_sst_offset); | |||
out.writeShort(field_3_zero); | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties( | |||
"streamPos", this::getStreamPos, | |||
"bucketSSTOffset", this::getBucketSSTOffset | |||
); | |||
} | |||
} | |||
@@ -121,41 +132,18 @@ public final class ExtSSTRecord extends ContinuableRecord { | |||
_stringsPerBucket = numStrings; | |||
} | |||
public String toString() { | |||
StringBuilder buffer = new StringBuilder(); | |||
buffer.append("[EXTSST]\n"); | |||
buffer.append(" .dsst = ") | |||
.append(Integer.toHexString(_stringsPerBucket)) | |||
.append("\n"); | |||
buffer.append(" .numInfoRecords = ").append(_sstInfos.length) | |||
.append("\n"); | |||
for (int k = 0; k < _sstInfos.length; k++) | |||
{ | |||
buffer.append(" .inforecord = ").append(k).append("\n"); | |||
buffer.append(" .streampos = ") | |||
.append(Integer | |||
.toHexString(_sstInfos[k].getStreamPos())).append("\n"); | |||
buffer.append(" .sstoffset = ") | |||
.append(Integer | |||
.toHexString(_sstInfos[k].getBucketSSTOffset())) | |||
.append("\n"); | |||
} | |||
buffer.append("[/EXTSST]\n"); | |||
return buffer.toString(); | |||
} | |||
public void serialize(ContinuableRecordOutput out) { | |||
out.writeShort(_stringsPerBucket); | |||
for (int k = 0; k < _sstInfos.length; k++) { | |||
_sstInfos[k].serialize(out); | |||
for (InfoSubRecord sstInfo : _sstInfos) { | |||
sstInfo.serialize(out); | |||
} | |||
} | |||
protected int getDataSize() { | |||
int getDataSize() { | |||
return 2 + InfoSubRecord.ENCODED_SIZE*_sstInfos.length; | |||
} | |||
protected InfoSubRecord[] getInfoSubRecords() { | |||
InfoSubRecord[] getInfoSubRecords() { | |||
return _sstInfos; | |||
} | |||
@@ -197,4 +185,17 @@ public final class ExtSSTRecord extends ContinuableRecord { | |||
public ExtSSTRecord copy() { | |||
return new ExtSSTRecord(this); | |||
} | |||
@Override | |||
public HSSFRecordTypes getGenericRecordType() { | |||
return HSSFRecordTypes.EXT_SST; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties( | |||
"dataSize", this::getDataSize, | |||
"infoSubRecords", this::getInfoSubRecords | |||
); | |||
} | |||
} |
@@ -18,7 +18,15 @@ | |||
package org.apache.poi.hssf.record; | |||
import static org.apache.poi.util.GenericRecordUtil.getBitsAsString; | |||
import static org.apache.poi.util.GenericRecordUtil.getEnumBitsAsString; | |||
import java.util.Arrays; | |||
import java.util.Collections; | |||
import java.util.LinkedHashMap; | |||
import java.util.Map; | |||
import java.util.Objects; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.util.BitField; | |||
import org.apache.poi.util.BitFieldFactory; | |||
@@ -1644,114 +1652,6 @@ public final class ExtendedFormatRecord extends StandardRecord { | |||
return _fill_background.getShortValue(field_9_fill_palette_options); | |||
} | |||
@Override | |||
public String toString() | |||
{ | |||
StringBuilder buffer = new StringBuilder(); | |||
buffer.append("[EXTENDEDFORMAT]\n"); | |||
if (getXFType() == XF_STYLE) | |||
{ | |||
buffer.append(" STYLE_RECORD_TYPE\n"); | |||
} | |||
else if (getXFType() == XF_CELL) | |||
{ | |||
buffer.append(" CELL_RECORD_TYPE\n"); | |||
} | |||
buffer.append(" .fontindex = ") | |||
.append(Integer.toHexString(getFontIndex())).append("\n"); | |||
buffer.append(" .formatindex = ") | |||
.append(Integer.toHexString(getFormatIndex())).append("\n"); | |||
buffer.append(" .celloptions = ") | |||
.append(Integer.toHexString(getCellOptions())).append("\n"); | |||
buffer.append(" .islocked = ").append(isLocked()) | |||
.append("\n"); | |||
buffer.append(" .ishidden = ").append(isHidden()) | |||
.append("\n"); | |||
buffer.append(" .recordtype= ") | |||
.append(Integer.toHexString(getXFType())).append("\n"); | |||
buffer.append(" .parentidx = ") | |||
.append(Integer.toHexString(getParentIndex())).append("\n"); | |||
buffer.append(" .alignmentoptions= ") | |||
.append(Integer.toHexString(getAlignmentOptions())).append("\n"); | |||
buffer.append(" .alignment = ").append(getAlignment()) | |||
.append("\n"); | |||
buffer.append(" .wraptext = ").append(getWrapText()) | |||
.append("\n"); | |||
buffer.append(" .valignment= ") | |||
.append(Integer.toHexString(getVerticalAlignment())).append("\n"); | |||
buffer.append(" .justlast = ") | |||
.append(Integer.toHexString(getJustifyLast())).append("\n"); | |||
buffer.append(" .rotation = ") | |||
.append(Integer.toHexString(getRotation())).append("\n"); | |||
buffer.append(" .indentionoptions= ") | |||
.append(Integer.toHexString(getIndentionOptions())).append("\n"); | |||
buffer.append(" .indent = ") | |||
.append(Integer.toHexString(getIndent())).append("\n"); | |||
buffer.append(" .shrinktoft= ").append(getShrinkToFit()) | |||
.append("\n"); | |||
buffer.append(" .mergecells= ").append(getMergeCells()) | |||
.append("\n"); | |||
buffer.append(" .readngordr= ") | |||
.append(Integer.toHexString(getReadingOrder())).append("\n"); | |||
buffer.append(" .formatflag= ") | |||
.append(isIndentNotParentFormat()).append("\n"); | |||
buffer.append(" .fontflag = ") | |||
.append(isIndentNotParentFont()).append("\n"); | |||
buffer.append(" .prntalgnmt= ") | |||
.append(isIndentNotParentAlignment()).append("\n"); | |||
buffer.append(" .borderflag= ") | |||
.append(isIndentNotParentBorder()).append("\n"); | |||
buffer.append(" .paternflag= ") | |||
.append(isIndentNotParentPattern()).append("\n"); | |||
buffer.append(" .celloption= ") | |||
.append(isIndentNotParentCellOptions()).append("\n"); | |||
buffer.append(" .borderoptns = ") | |||
.append(Integer.toHexString(getBorderOptions())).append("\n"); | |||
buffer.append(" .lftln = ") | |||
.append(Integer.toHexString(getBorderLeft())).append("\n"); | |||
buffer.append(" .rgtln = ") | |||
.append(Integer.toHexString(getBorderRight())).append("\n"); | |||
buffer.append(" .topln = ") | |||
.append(Integer.toHexString(getBorderTop())).append("\n"); | |||
buffer.append(" .btmln = ") | |||
.append(Integer.toHexString(getBorderBottom())).append("\n"); | |||
buffer.append(" .paleteoptns = ") | |||
.append(Integer.toHexString(getPaletteOptions())).append("\n"); | |||
buffer.append(" .leftborder= ") | |||
.append(Integer.toHexString(getLeftBorderPaletteIdx())) | |||
.append("\n"); | |||
buffer.append(" .rghtborder= ") | |||
.append(Integer.toHexString(getRightBorderPaletteIdx())) | |||
.append("\n"); | |||
buffer.append(" .diag = ") | |||
.append(Integer.toHexString(getDiag())).append("\n"); | |||
buffer.append(" .paleteoptn2 = ") | |||
.append(Integer.toHexString(getAdtlPaletteOptions())) | |||
.append("\n"); | |||
buffer.append(" .topborder = ") | |||
.append(Integer.toHexString(getTopBorderPaletteIdx())) | |||
.append("\n"); | |||
buffer.append(" .botmborder= ") | |||
.append(Integer.toHexString(getBottomBorderPaletteIdx())) | |||
.append("\n"); | |||
buffer.append(" .adtldiag = ") | |||
.append(Integer.toHexString(getAdtlDiag())).append("\n"); | |||
buffer.append(" .diaglnstyl= ") | |||
.append(Integer.toHexString(getAdtlDiagLineStyle())).append("\n"); | |||
buffer.append(" .fillpattrn= ") | |||
.append(Integer.toHexString(getAdtlFillPattern())).append("\n"); | |||
buffer.append(" .fillpaloptn = ") | |||
.append(Integer.toHexString(getFillPaletteOptions())) | |||
.append("\n"); | |||
buffer.append(" .foreground= ") | |||
.append(Integer.toHexString(getFillForeground())).append("\n"); | |||
buffer.append(" .background= ") | |||
.append(Integer.toHexString(getFillBackground())).append("\n"); | |||
buffer.append("[/EXTENDEDFORMAT]\n"); | |||
return buffer.toString(); | |||
} | |||
@Override | |||
public void serialize(LittleEndianOutput out) { | |||
out.writeShort(getFontIndex()); | |||
@@ -1827,25 +1727,7 @@ public final class ExtendedFormatRecord extends StandardRecord { | |||
return false; | |||
if (obj instanceof ExtendedFormatRecord) { | |||
final ExtendedFormatRecord other = (ExtendedFormatRecord) obj; | |||
if (field_1_font_index != other.field_1_font_index) | |||
return false; | |||
if (field_2_format_index != other.field_2_format_index) | |||
return false; | |||
if (field_3_cell_options != other.field_3_cell_options) | |||
return false; | |||
if (field_4_alignment_options != other.field_4_alignment_options) | |||
return false; | |||
if (field_5_indention_options != other.field_5_indention_options) | |||
return false; | |||
if (field_6_border_options != other.field_6_border_options) | |||
return false; | |||
if (field_7_palette_options != other.field_7_palette_options) | |||
return false; | |||
if (field_8_adtl_palette_options != other.field_8_adtl_palette_options) | |||
return false; | |||
if (field_9_fill_palette_options != other.field_9_fill_palette_options) | |||
return false; | |||
return true; | |||
return Arrays.equals(stateSummary(), other.stateSummary()); | |||
} | |||
return false; | |||
} | |||
@@ -1860,4 +1742,54 @@ public final class ExtendedFormatRecord extends StandardRecord { | |||
public ExtendedFormatRecord copy() { | |||
return new ExtendedFormatRecord(this); | |||
} | |||
@Override | |||
public HSSFRecordTypes getGenericRecordType() { | |||
return HSSFRecordTypes.EXTENDED_FORMAT; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
final Map<String,Supplier<?>> m = new LinkedHashMap<>(); | |||
m.put("xfType", getEnumBitsAsString(this::getXFType, new int[]{0,1}, new String[]{"CELL", "STYLE"})); | |||
m.put("fontIndex", this::getFontIndex); | |||
m.put("formatIndex", this::getFormatIndex); | |||
m.put("cellOptions", getBitsAsString(this::getCellOptions, | |||
new BitField[]{_locked,_hidden,_123_prefix}, | |||
new String[]{"LOCKED","HIDDEN","LOTUS_123_PREFIX"})); | |||
m.put("parentIndex", this::getParentIndex); | |||
m.put("alignmentOptions", getBitsAsString(this::getAlignmentOptions, | |||
new BitField[]{_wrap_text, _justify_last}, | |||
new String[]{"WRAP_TEXT", "JUSTIFY_LAST"})); | |||
m.put("alignment", this::getAlignment); | |||
m.put("verticalAlignment", this::getVerticalAlignment); | |||
m.put("rotation", this::getRotation); | |||
m.put("indentionOptions", getBitsAsString(this::getIndentionOptions, | |||
new BitField[]{_shrink_to_fit,_merge_cells,_indent_not_parent_format,_indent_not_parent_font, | |||
_indent_not_parent_alignment,_indent_not_parent_border,_indent_not_parent_pattern,_indent_not_parent_cell_options}, | |||
new String[]{"SHRINK_TO_FIT","MERGE_CELLS","NOT_PARENT_FORMAT","NOT_PARENT_FONT", | |||
"NOT_PARENT_ALIGNMENT","NOT_PARENT_BORDER","NOT_PARENT_PATTERN","NOT_PARENT_CELL_OPTIONS"})); | |||
m.put("indent", this::getIndent); | |||
m.put("readingOrder", this::getReadingOrder); | |||
m.put("borderOptions", this::getBorderOptions); | |||
m.put("borderLeft", this::getBorderLeft); | |||
m.put("borderRight", this::getBorderRight); | |||
m.put("borderTop", this::getBorderTop); | |||
m.put("borderBottom", this::getBorderBottom); | |||
m.put("paletteOptions", this::getPaletteOptions); | |||
m.put("leftBorderPaletteIdx", this::getLeftBorderPaletteIdx); | |||
m.put("rightBorderPaletteIdx", this::getRightBorderPaletteIdx); | |||
m.put("diag", this::getDiag); | |||
m.put("adtlPaletteOptions", this::getAdtlPaletteOptions); | |||
m.put("topBorderPaletteIdx", this::getTopBorderPaletteIdx); | |||
m.put("bottomBorderPaletteIdx", this::getBottomBorderPaletteIdx); | |||
m.put("adtlDiag", this::getAdtlDiag); | |||
m.put("adtlDiagLineStyle", this::getAdtlDiagLineStyle); | |||
m.put("adtlFillPattern", this::getAdtlFillPattern); | |||
m.put("fillPaletteOptions", this::getFillPaletteOptions); | |||
m.put("fillForeground", this::getFillForeground); | |||
m.put("fillBackground", this::getFillBackground); | |||
return Collections.unmodifiableMap(m); | |||
} | |||
} |
@@ -19,7 +19,12 @@ package org.apache.poi.hssf.record; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.common.usermodel.GenericRecord; | |||
import org.apache.poi.util.GenericRecordJsonWriter; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
import org.apache.poi.util.LittleEndianOutput; | |||
/** | |||
@@ -31,7 +36,7 @@ public class ExternSheetRecord extends StandardRecord { | |||
public static final short sid = 0x0017; | |||
private final List<RefSubRecord> _list = new ArrayList<>(); | |||
private static final class RefSubRecord { | |||
private static final class RefSubRecord implements GenericRecord { | |||
public static final int ENCODED_SIZE = 6; | |||
/** index to External Book Block (which starts with a EXTERNALBOOK record) */ | |||
@@ -58,11 +63,6 @@ public class ExternSheetRecord extends StandardRecord { | |||
this(in.readShort(), in.readShort(), in.readShort()); | |||
} | |||
public void adjustIndex(int offset) { | |||
_firstSheetIndex += offset; | |||
_lastSheetIndex += offset; | |||
} | |||
public int getExtBookIndex(){ | |||
return _extBookIndex; | |||
} | |||
@@ -75,11 +75,7 @@ public class ExternSheetRecord extends StandardRecord { | |||
@Override | |||
public String toString() { | |||
StringBuilder buffer = new StringBuilder(); | |||
buffer.append("extBook=").append(_extBookIndex); | |||
buffer.append(" firstSheet=").append(_firstSheetIndex); | |||
buffer.append(" lastSheet=").append(_lastSheetIndex); | |||
return buffer.toString(); | |||
return GenericRecordJsonWriter.marshal(this); | |||
} | |||
public void serialize(LittleEndianOutput out) { | |||
@@ -87,6 +83,15 @@ public class ExternSheetRecord extends StandardRecord { | |||
out.writeShort(_firstSheetIndex); | |||
out.writeShort(_lastSheetIndex); | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties( | |||
"extBookIndex", this::getExtBookIndex, | |||
"firstSheetIndex", this::getFirstSheetIndex, | |||
"lastSheetIndex", this::getLastSheetIndex | |||
); | |||
} | |||
} | |||
public ExternSheetRecord() {} | |||
@@ -127,24 +132,6 @@ public class ExternSheetRecord extends StandardRecord { | |||
return _list.size(); | |||
} | |||
@Override | |||
public String toString() { | |||
StringBuilder sb = new StringBuilder(); | |||
int nItems = _list.size(); | |||
sb.append("[EXTERNSHEET]\n"); | |||
sb.append(" numOfRefs = ").append(nItems).append("\n"); | |||
for (int i=0; i < nItems; i++) { | |||
sb.append("refrec #").append(i).append(": "); | |||
sb.append(getRef(i)); | |||
sb.append('\n'); | |||
} | |||
sb.append("[/EXTERNSHEET]\n"); | |||
return sb.toString(); | |||
} | |||
@Override | |||
protected int getDataSize() { | |||
return 2 + _list.size() * RefSubRecord.ENCODED_SIZE; | |||
@@ -309,4 +296,14 @@ public class ExternSheetRecord extends StandardRecord { | |||
public ExternSheetRecord copy() { | |||
return new ExternSheetRecord(this); | |||
} | |||
@Override | |||
public HSSFRecordTypes getGenericRecordType() { | |||
return HSSFRecordTypes.EXTERN_SHEET; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties("refrec", () -> _list); | |||
} | |||
} |
@@ -17,9 +17,13 @@ | |||
package org.apache.poi.hssf.record; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.ss.formula.Formula; | |||
import org.apache.poi.ss.formula.constant.ConstantValueParser; | |||
import org.apache.poi.ss.formula.ptg.Ptg; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
import org.apache.poi.util.LittleEndianOutput; | |||
import org.apache.poi.util.StringUtil; | |||
@@ -38,6 +42,12 @@ public final class ExternalNameRecord extends StandardRecord { | |||
// private static final int OPT_CLIP_FORMAT_MASK = 0x7FE0; | |||
private static final int OPT_ICONIFIED_PICTURE_LINK= 0x8000; | |||
private static final int[] OPTION_FLAGS = { | |||
OPT_BUILTIN_NAME,OPT_AUTOMATIC_LINK,OPT_PICTURE_LINK,OPT_STD_DOCUMENT_NAME,OPT_OLE_LINK,OPT_ICONIFIED_PICTURE_LINK}; | |||
private static final String[] OPTION_NAMES = { | |||
"BUILTIN_NAME","AUTOMATIC_LINK","PICTURE_LINK","STD_DOCUMENT_NAME","OLE_LINK","ICONIFIED_PICTURE_LINK"}; | |||
private short field_1_option_flag; | |||
private short field_2_ixals; | |||
@@ -225,24 +235,23 @@ public final class ExternalNameRecord extends StandardRecord { | |||
} | |||
@Override | |||
public String toString() { | |||
StringBuilder sb = new StringBuilder(); | |||
sb.append("[EXTERNALNAME]\n"); | |||
sb.append(" .options = ").append(field_1_option_flag).append("\n"); | |||
sb.append(" .ix = ").append(field_2_ixals).append("\n"); | |||
sb.append(" .name = ").append(field_4_name).append("\n"); | |||
if(field_5_name_definition != null) { | |||
Ptg[] ptgs = field_5_name_definition.getTokens(); | |||
for (Ptg ptg : ptgs) { | |||
sb.append(" .namedef = ").append(ptg).append(ptg.getRVAType()).append("\n"); | |||
} | |||
} | |||
sb.append("[/EXTERNALNAME]\n"); | |||
return sb.toString(); | |||
public ExternalNameRecord copy() { | |||
return new ExternalNameRecord(this); | |||
} | |||
@Override | |||
public ExternalNameRecord copy() { | |||
return new ExternalNameRecord(this); | |||
public HSSFRecordTypes getGenericRecordType() { | |||
return HSSFRecordTypes.EXTERNAL_NAME; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties( | |||
"options", GenericRecordUtil.getBitsAsString(() -> field_1_option_flag, OPTION_FLAGS, OPTION_NAMES), | |||
"ix", this::getIx, | |||
"name", this::getText, | |||
"nameDefinition", (field_5_name_definition == null ? () -> null : field_5_name_definition::getTokens) | |||
); | |||
} | |||
} |
@@ -17,7 +17,11 @@ | |||
package org.apache.poi.hssf.record; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.hssf.record.common.FtrHeader; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
import org.apache.poi.util.LittleEndianOutput; | |||
import org.apache.poi.util.Removal; | |||
@@ -55,8 +59,10 @@ public final class FeatHdrRecord extends StandardRecord { | |||
public static final short sid = 0x0867; | |||
private final FtrHeader futureHeader; | |||
private int isf_sharedFeatureType; // See SHAREDFEATURES_ | |||
private byte reserved; // Should always be one | |||
// See SHAREDFEATURES | |||
private int isf_sharedFeatureType; | |||
// Should always be one | |||
private byte reserved; | |||
/** | |||
* 0x00000000 = rgbHdrData not present | |||
* 0xffffffff = rgbHdrData present | |||
@@ -93,16 +99,6 @@ public final class FeatHdrRecord extends StandardRecord { | |||
return sid; | |||
} | |||
public String toString() { | |||
StringBuilder buffer = new StringBuilder(); | |||
buffer.append("[FEATURE HEADER]\n"); | |||
// TODO ... | |||
buffer.append("[/FEATURE HEADER]\n"); | |||
return buffer.toString(); | |||
} | |||
public void serialize(LittleEndianOutput out) { | |||
futureHeader.serialize(out); | |||
@@ -117,7 +113,7 @@ public final class FeatHdrRecord extends StandardRecord { | |||
} | |||
@Override | |||
@SuppressWarnings("squid:S2975") | |||
@SuppressWarnings({"squid:S2975", "MethodDoesntCallSuperMethod"}) | |||
@Deprecated | |||
@Removal(version = "5.0.0") | |||
public FeatHdrRecord clone() { | |||
@@ -130,5 +126,19 @@ public final class FeatHdrRecord extends StandardRecord { | |||
return new FeatHdrRecord(this); | |||
} | |||
@Override | |||
public HSSFRecordTypes getGenericRecordType() { | |||
return HSSFRecordTypes.FEAT_HDR; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties( | |||
"futureHeader", () -> futureHeader, | |||
"isf_sharedFeatureType", () -> isf_sharedFeatureType, | |||
"reserved", () -> reserved, | |||
"cbHdrData", () -> cbHdrData, | |||
"rgbHdrData", () -> rgbHdrData | |||
); | |||
} | |||
} |
@@ -17,6 +17,8 @@ | |||
package org.apache.poi.hssf.record; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import java.util.stream.Stream; | |||
import org.apache.poi.hssf.record.common.FeatFormulaErr2; | |||
@@ -25,6 +27,7 @@ import org.apache.poi.hssf.record.common.FeatSmartTag; | |||
import org.apache.poi.hssf.record.common.FtrHeader; | |||
import org.apache.poi.hssf.record.common.SharedFeature; | |||
import org.apache.poi.ss.util.CellRangeAddress; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
import org.apache.poi.util.LittleEndianOutput; | |||
import org.apache.poi.util.POILogFactory; | |||
import org.apache.poi.util.POILogger; | |||
@@ -114,16 +117,6 @@ public final class FeatRecord extends StandardRecord { | |||
return sid; | |||
} | |||
public String toString() { | |||
StringBuilder buffer = new StringBuilder(); | |||
buffer.append("[SHARED FEATURE]\n"); | |||
// TODO ... | |||
buffer.append("[/SHARED FEATURE]\n"); | |||
return buffer.toString(); | |||
} | |||
public void serialize(LittleEndianOutput out) { | |||
futureHeader.serialize(out); | |||
@@ -134,8 +127,8 @@ public final class FeatRecord extends StandardRecord { | |||
out.writeInt((int)cbFeatData); | |||
out.writeShort(reserved3); | |||
for(int i=0; i<cellRefs.length; i++) { | |||
cellRefs[i].serialize(out); | |||
for (CellRangeAddress cellRef : cellRefs) { | |||
cellRef.serialize(out); | |||
} | |||
sharedFeature.serialize(out); | |||
@@ -189,7 +182,7 @@ public final class FeatRecord extends StandardRecord { | |||
} | |||
@Override | |||
@SuppressWarnings("squid:S2975") | |||
@SuppressWarnings({"squid:S2975", "MethodDoesntCallSuperMethod"}) | |||
@Deprecated | |||
@Removal(version = "5.0.0") | |||
public FeatRecord clone() { | |||
@@ -200,4 +193,23 @@ public final class FeatRecord extends StandardRecord { | |||
public FeatRecord copy() { | |||
return new FeatRecord(this); | |||
} | |||
@Override | |||
public HSSFRecordTypes getGenericRecordType() { | |||
return HSSFRecordTypes.FEAT; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties( | |||
"futureHeader", () -> futureHeader, | |||
"isf_sharedFeatureType", this::getIsf_sharedFeatureType, | |||
"reserved1", () -> reserved1, | |||
"reserved2", () -> reserved2, | |||
"cbFeatData", this::getCbFeatData, | |||
"reserved3", () -> reserved3, | |||
"cellRefs", this::getCellRefs, | |||
"sharedFeature", this::getSharedFeature | |||
); | |||
} | |||
} |
@@ -19,6 +19,8 @@ package org.apache.poi.hssf.record; | |||
import java.io.ByteArrayOutputStream; | |||
import java.io.IOException; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.EncryptedDocumentException; | |||
import org.apache.poi.poifs.crypt.EncryptionInfo; | |||
@@ -29,7 +31,7 @@ import org.apache.poi.poifs.crypt.cryptoapi.CryptoAPIEncryptionHeader; | |||
import org.apache.poi.poifs.crypt.cryptoapi.CryptoAPIEncryptionVerifier; | |||
import org.apache.poi.poifs.crypt.xor.XOREncryptionHeader; | |||
import org.apache.poi.poifs.crypt.xor.XOREncryptionVerifier; | |||
import org.apache.poi.util.HexDump; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
import org.apache.poi.util.LittleEndianByteArrayOutputStream; | |||
import org.apache.poi.util.LittleEndianOutput; | |||
import org.apache.poi.util.LittleEndianOutputStream; | |||
@@ -86,7 +88,7 @@ public final class FilePassRecord extends StandardRecord { | |||
public void serialize(LittleEndianOutput out) { | |||
out.writeShort(encryptionType); | |||
byte data[] = new byte[1024]; | |||
byte[] data = new byte[1024]; | |||
try (LittleEndianByteArrayOutputStream bos = | |||
new LittleEndianByteArrayOutputStream(data, 0)) { // NOSONAR | |||
@@ -137,7 +139,7 @@ public final class FilePassRecord extends StandardRecord { | |||
} | |||
@Override | |||
@SuppressWarnings("squid:S2975") | |||
@SuppressWarnings({"squid:S2975", "MethodDoesntCallSuperMethod"}) | |||
@Deprecated | |||
@Removal(version = "5.0.0") | |||
public FilePassRecord clone() { | |||
@@ -149,19 +151,16 @@ public final class FilePassRecord extends StandardRecord { | |||
return new FilePassRecord(this); | |||
} | |||
@Override | |||
public String toString() { | |||
StringBuilder buffer = new StringBuilder(); | |||
buffer.append("[FILEPASS]\n"); | |||
buffer.append(" .type = ").append(HexDump.shortToHex(encryptionType)).append('\n'); | |||
String prefix = " ."+encryptionInfo.getEncryptionMode(); | |||
buffer.append(prefix+".info = ").append(HexDump.shortToHex(encryptionInfo.getVersionMajor())).append('\n'); | |||
buffer.append(prefix+".ver = ").append(HexDump.shortToHex(encryptionInfo.getVersionMinor())).append('\n'); | |||
buffer.append(prefix+".salt = ").append(HexDump.toHex(encryptionInfo.getVerifier().getSalt())).append('\n'); | |||
buffer.append(prefix+".verifier = ").append(HexDump.toHex(encryptionInfo.getVerifier().getEncryptedVerifier())).append('\n'); | |||
buffer.append(prefix+".verifierHash = ").append(HexDump.toHex(encryptionInfo.getVerifier().getEncryptedVerifierHash())).append('\n'); | |||
buffer.append("[/FILEPASS]\n"); | |||
return buffer.toString(); | |||
} | |||
@Override | |||
public HSSFRecordTypes getGenericRecordType() { | |||
return HSSFRecordTypes.FILE_PASS; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties( | |||
"type", () -> encryptionType, | |||
"encryptionInfo", this::getEncryptionInfo | |||
); | |||
} | |||
} |
@@ -17,6 +17,10 @@ | |||
package org.apache.poi.hssf.record; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
import org.apache.poi.util.LittleEndianOutput; | |||
import org.apache.poi.util.Removal; | |||
import org.apache.poi.util.StringUtil; | |||
@@ -106,20 +110,6 @@ public final class FileSharingRecord extends StandardRecord { | |||
} | |||
public String toString() { | |||
StringBuilder buffer = new StringBuilder(); | |||
buffer.append("[FILESHARING]\n"); | |||
buffer.append(" .readonly = ") | |||
.append(getReadOnly() == 1 ? "true" : "false").append("\n"); | |||
buffer.append(" .password = ") | |||
.append(Integer.toHexString(getPassword())).append("\n"); | |||
buffer.append(" .username = ") | |||
.append(getUsername()).append("\n"); | |||
buffer.append("[/FILESHARING]\n"); | |||
return buffer.toString(); | |||
} | |||
public void serialize(LittleEndianOutput out) { | |||
// TODO - junit | |||
out.writeShort(getReadOnly()); | |||
@@ -144,7 +134,7 @@ public final class FileSharingRecord extends StandardRecord { | |||
} | |||
@Override | |||
@SuppressWarnings("squid:S2975") | |||
@SuppressWarnings({"squid:S2975", "MethodDoesntCallSuperMethod"}) | |||
@Deprecated | |||
@Removal(version = "5.0.0") | |||
public FileSharingRecord clone() { | |||
@@ -153,6 +143,20 @@ public final class FileSharingRecord extends StandardRecord { | |||
@Override | |||
public FileSharingRecord copy() { | |||
return new FileSharingRecord(this); | |||
return new FileSharingRecord(this); | |||
} | |||
@Override | |||
public HSSFRecordTypes getGenericRecordType() { | |||
return HSSFRecordTypes.FILE_SHARING; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties( | |||
"readOnly", this::getReadOnly, | |||
"password", this::getPassword, | |||
"username", this::getUsername | |||
); | |||
} | |||
} |
@@ -19,6 +19,10 @@ | |||
package org.apache.poi.hssf.record; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
import org.apache.poi.util.LittleEndianOutput; | |||
/** | |||
@@ -70,17 +74,6 @@ public final class FnGroupCountRecord extends StandardRecord { | |||
return field_1_count; | |||
} | |||
public String toString() | |||
{ | |||
StringBuilder buffer = new StringBuilder(); | |||
buffer.append("[FNGROUPCOUNT]\n"); | |||
buffer.append(" .count = ").append(getCount()) | |||
.append("\n"); | |||
buffer.append("[/FNGROUPCOUNT]\n"); | |||
return buffer.toString(); | |||
} | |||
public void serialize(LittleEndianOutput out) { | |||
out.writeShort(getCount()); | |||
} | |||
@@ -98,4 +91,14 @@ public final class FnGroupCountRecord extends StandardRecord { | |||
public FnGroupCountRecord copy() { | |||
return new FnGroupCountRecord(this); | |||
} | |||
@Override | |||
public HSSFRecordTypes getGenericRecordType() { | |||
return HSSFRecordTypes.FN_GROUP_COUNT; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties("count", this::getCount); | |||
} | |||
} |
@@ -17,11 +17,13 @@ | |||
package org.apache.poi.hssf.record; | |||
import java.util.Map; | |||
import java.util.Objects; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.util.BitField; | |||
import org.apache.poi.util.BitFieldFactory; | |||
import org.apache.poi.util.HexDump; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
import org.apache.poi.util.LittleEndianOutput; | |||
import org.apache.poi.util.StringUtil; | |||
@@ -380,25 +382,6 @@ public final class FontRecord extends StandardRecord { | |||
return field_11_font_name; | |||
} | |||
public String toString() { | |||
return | |||
"[FONT]\n" + | |||
" .fontheight = " + HexDump.shortToHex(getFontHeight()) + "\n" + | |||
" .attributes = " + HexDump.shortToHex(getAttributes()) + "\n" + | |||
" .italic = " + isItalic() + "\n" + | |||
" .strikout = " + isStruckout() + "\n" + | |||
" .macoutlined= " + isMacoutlined() + "\n" + | |||
" .macshadowed= " + isMacshadowed() + "\n" + | |||
" .colorpalette = " + HexDump.shortToHex(getColorPaletteIndex()) + "\n" + | |||
" .boldweight = " + HexDump.shortToHex(getBoldWeight()) + "\n" + | |||
" .supersubscript= " + HexDump.shortToHex(getSuperSubScript()) + "\n" + | |||
" .underline = " + HexDump.byteToHex(getUnderline()) + "\n" + | |||
" .family = " + HexDump.byteToHex(getFamily()) + "\n" + | |||
" .charset = " + HexDump.byteToHex(getCharset()) + "\n" + | |||
" .fontname = " + getFontName() + "\n" + | |||
"[/FONT]\n"; | |||
} | |||
public void serialize(LittleEndianOutput out) { | |||
out.writeShort(getFontHeight()); | |||
@@ -509,4 +492,26 @@ public final class FontRecord extends StandardRecord { | |||
public FontRecord copy() { | |||
return new FontRecord(this); | |||
} | |||
@Override | |||
public HSSFRecordTypes getGenericRecordType() { | |||
return HSSFRecordTypes.FONT; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties( | |||
"fontHeight", this::getFontHeight, | |||
"attributes", GenericRecordUtil.getBitsAsString(this::getAttributes, | |||
new BitField[]{italic,strikeout,macoutline,macshadow}, | |||
new String[]{"ITALIC","STRIKEOUT","MACOUTLINE","MACSHADOW"}), | |||
"colorPalette", this::getColorPaletteIndex, | |||
"boldWeight", this::getBoldWeight, | |||
"superSubScript", this::getSuperSubScript, | |||
"underline", this::getUnderline, | |||
"family", this::getFamily, | |||
"charset", this::getCharset, | |||
"fontName", this::getFontName | |||
); | |||
} | |||
} |
@@ -37,21 +37,12 @@ public final class FooterRecord extends HeaderFooterBase { | |||
super(in); | |||
} | |||
public String toString() { | |||
StringBuilder buffer = new StringBuilder(); | |||
buffer.append("[FOOTER]\n"); | |||
buffer.append(" .footer = ").append(getText()).append("\n"); | |||
buffer.append("[/FOOTER]\n"); | |||
return buffer.toString(); | |||
} | |||
public short getSid() { | |||
return sid; | |||
} | |||
@Override | |||
@SuppressWarnings("squid:S2975") | |||
@SuppressWarnings({"squid:S2975", "MethodDoesntCallSuperMethod"}) | |||
@Deprecated | |||
@Removal(version = "5.0.0") | |||
public FooterRecord clone() { | |||
@@ -62,4 +53,9 @@ public final class FooterRecord extends HeaderFooterBase { | |||
public FooterRecord copy() { | |||
return new FooterRecord(this); | |||
} | |||
@Override | |||
public HSSFRecordTypes getGenericRecordType() { | |||
return HSSFRecordTypes.FOOTER; | |||
} | |||
} |
@@ -17,7 +17,10 @@ | |||
package org.apache.poi.hssf.record; | |||
import org.apache.poi.util.HexDump; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
import org.apache.poi.util.LittleEndianConsts; | |||
import org.apache.poi.util.LittleEndianOutput; | |||
import org.apache.poi.util.POILogFactory; | |||
@@ -82,17 +85,6 @@ public final class FormatRecord extends StandardRecord { | |||
return field_4_formatstring; | |||
} | |||
public String toString() { | |||
StringBuilder buffer = new StringBuilder(); | |||
buffer.append("[FORMAT]\n"); | |||
buffer.append(" .indexcode = ").append(HexDump.shortToHex(getIndexCode())).append("\n"); | |||
buffer.append(" .isUnicode = ").append(field_3_hasMultibyte ).append("\n"); | |||
buffer.append(" .formatstring = ").append(getFormatString()).append("\n"); | |||
buffer.append("[/FORMAT]\n"); | |||
return buffer.toString(); | |||
} | |||
public void serialize(LittleEndianOutput out) { | |||
String formatString = getFormatString(); | |||
out.writeShort(getIndexCode()); | |||
@@ -115,7 +107,7 @@ public final class FormatRecord extends StandardRecord { | |||
} | |||
@Override | |||
@SuppressWarnings("squid:S2975") | |||
@SuppressWarnings({"squid:S2975", "MethodDoesntCallSuperMethod"}) | |||
@Deprecated | |||
@Removal(version = "5.0.0") | |||
public FormatRecord clone() { | |||
@@ -134,10 +126,9 @@ public final class FormatRecord extends StandardRecord { | |||
if (requestedLength < 0 || requestedLength > 0x100000) { // 16 million chars? | |||
throw new IllegalArgumentException("Bad requested string length (" + requestedLength + ")"); | |||
} | |||
char[] buf = null; | |||
char[] buf; | |||
int availableChars = pIsCompressedEncoding ? ris.remaining() : ris.remaining() / LittleEndianConsts.SHORT_SIZE; | |||
//everything worked out. Great! | |||
int remaining = ris.remaining(); | |||
if (requestedLength == availableChars) { | |||
buf = new char[requestedLength]; | |||
} else { | |||
@@ -176,4 +167,17 @@ public final class FormatRecord extends StandardRecord { | |||
return new String(buf); | |||
} | |||
@Override | |||
public HSSFRecordTypes getGenericRecordType() { | |||
return HSSFRecordTypes.FORMAT; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties( | |||
"indexCode", this::getIndexCode, | |||
"unicode", () -> field_3_hasMultibyte, | |||
"formatString", this::getFormatString | |||
); | |||
} | |||
} |
@@ -17,12 +17,15 @@ | |||
package org.apache.poi.hssf.record; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.ss.formula.Formula; | |||
import org.apache.poi.ss.formula.ptg.Ptg; | |||
import org.apache.poi.ss.usermodel.CellType; | |||
import org.apache.poi.util.BitField; | |||
import org.apache.poi.util.BitFieldFactory; | |||
import org.apache.poi.util.HexDump; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
import org.apache.poi.util.LittleEndianOutput; | |||
import org.apache.poi.util.Removal; | |||
@@ -228,32 +231,7 @@ public final class FormulaRecord extends CellRecord { | |||
} | |||
@Override | |||
protected void appendValueText(StringBuilder sb) { | |||
sb.append(" .value = "); | |||
if (specialCachedValue == null) { | |||
sb.append(field_4_value).append("\n"); | |||
} else { | |||
sb.append(specialCachedValue.formatDebugString()).append("\n"); | |||
} | |||
sb.append(" .options = ").append(HexDump.shortToHex(getOptions())).append("\n"); | |||
sb.append(" .alwaysCalc= ").append(isAlwaysCalc()).append("\n"); | |||
sb.append(" .calcOnLoad= ").append(isCalcOnLoad()).append("\n"); | |||
sb.append(" .shared = ").append(isSharedFormula()).append("\n"); | |||
sb.append(" .zero = ").append(HexDump.intToHex(field_6_zero)).append("\n"); | |||
Ptg[] ptgs = field_8_parsed_expr.getTokens(); | |||
for (int k = 0; k < ptgs.length; k++ ) { | |||
if (k>0) { | |||
sb.append("\n"); | |||
} | |||
sb.append(" Ptg[").append(k).append("]="); | |||
Ptg ptg = ptgs[k]; | |||
sb.append(ptg).append(ptg.getRVAType()); | |||
} | |||
} | |||
@Override | |||
@SuppressWarnings("squid:S2975") | |||
@SuppressWarnings({"squid:S2975", "MethodDoesntCallSuperMethod"}) | |||
@Deprecated | |||
@Removal(version = "5.0.0") | |||
public FormulaRecord clone() { | |||
@@ -264,5 +242,24 @@ public final class FormulaRecord extends CellRecord { | |||
public FormulaRecord copy() { | |||
return new FormulaRecord(this); | |||
} | |||
@Override | |||
public HSSFRecordTypes getGenericRecordType() { | |||
return HSSFRecordTypes.FORMULA; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties( | |||
"base", super::getGenericProperties, | |||
"options", this::getOptions, | |||
"alwaysCalc", this::isAlwaysCalc, | |||
"calcOnLoad", this::isCalcOnLoad, | |||
"shared", this::isSharedFormula, | |||
"zero", () -> field_6_zero, | |||
"value", () -> specialCachedValue == null ? field_4_value : specialCachedValue, | |||
"formula", this::getFormula | |||
); | |||
} | |||
} | |||
@@ -17,8 +17,15 @@ | |||
package org.apache.poi.hssf.record; | |||
import static org.apache.poi.util.GenericRecordUtil.getEnumBitsAsString; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.common.usermodel.GenericRecord; | |||
import org.apache.poi.ss.formula.eval.ErrorEval; | |||
import org.apache.poi.ss.usermodel.CellType; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
import org.apache.poi.util.HexDump; | |||
import org.apache.poi.util.Internal; | |||
import org.apache.poi.util.LittleEndianOutput; | |||
@@ -29,7 +36,7 @@ import org.apache.poi.util.LittleEndianOutput; | |||
* values that are decoded/encoded by this class. | |||
*/ | |||
@Internal | |||
public final class FormulaSpecialCachedValue { | |||
public final class FormulaSpecialCachedValue implements GenericRecord { | |||
/** deliberately chosen by Excel in order to encode other values within Double NaNs */ | |||
private static final long BIT_MARKER = 0xFFFF000000000000L; | |||
private static final int VARIABLE_DATA_LENGTH = 6; | |||
@@ -164,4 +171,29 @@ public final class FormulaSpecialCachedValue { | |||
} | |||
return getDataValue(); | |||
} | |||
private Object getGenericValue() { | |||
int typeCode = getTypeCode(); | |||
switch (typeCode) { | |||
case EMPTY: // is this correct? | |||
return null; | |||
case STRING: | |||
return "string"; | |||
case BOOLEAN: | |||
return getBooleanValue(); | |||
case ERROR_CODE: | |||
return getErrorValue(); | |||
} | |||
throw new IllegalStateException("Unexpected type id (" + typeCode + ")"); | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties( | |||
"value", this::getGenericValue, | |||
"typeCode", getEnumBitsAsString(this::getTypeCode, | |||
new int[]{STRING,BOOLEAN,ERROR_CODE,EMPTY}, | |||
new String[]{"STRING","BOOLEAN","ERROR_CODE","EMPTY"}) | |||
); | |||
} | |||
} |
@@ -17,7 +17,10 @@ | |||
package org.apache.poi.hssf.record; | |||
import org.apache.poi.util.HexDump; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
import org.apache.poi.util.IOUtils; | |||
import org.apache.poi.util.LittleEndianInput; | |||
import org.apache.poi.util.LittleEndianOutput; | |||
@@ -48,6 +51,10 @@ public final class FtCblsSubRecord extends SubRecord { | |||
} | |||
public FtCblsSubRecord(LittleEndianInput in, int size) { | |||
this(in,size,-1); | |||
} | |||
FtCblsSubRecord(LittleEndianInput in, int size, int cmoOt) { | |||
if (size != ENCODED_SIZE) { | |||
throw new RecordFormatException("Unexpected size (" + size + ")"); | |||
} | |||
@@ -57,21 +64,6 @@ public final class FtCblsSubRecord extends SubRecord { | |||
reserved = buf; | |||
} | |||
/** | |||
* Convert this record to string. | |||
* Used by BiffViewer and other utilities. | |||
*/ | |||
public String toString() | |||
{ | |||
StringBuilder buffer = new StringBuilder(); | |||
buffer.append("[FtCbls ]").append("\n"); | |||
buffer.append(" size = ").append(getDataSize()).append("\n"); | |||
buffer.append(" reserved = ").append(HexDump.toHex(reserved)).append("\n"); | |||
buffer.append("[/FtCbls ]").append("\n"); | |||
return buffer.toString(); | |||
} | |||
/** | |||
* Serialize the record data into the supplied array of bytes | |||
* | |||
@@ -108,4 +100,13 @@ public final class FtCblsSubRecord extends SubRecord { | |||
return new FtCblsSubRecord(this); | |||
} | |||
@Override | |||
public SubRecordTypes getGenericRecordType() { | |||
return SubRecordTypes.FT_CBLS; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties("reserved", () -> reserved); | |||
} | |||
} |
@@ -17,7 +17,12 @@ | |||
package org.apache.poi.hssf.record; | |||
import org.apache.poi.util.HexDump; | |||
import static org.apache.poi.util.GenericRecordUtil.getEnumBitsAsString; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
import org.apache.poi.util.LittleEndianInput; | |||
import org.apache.poi.util.LittleEndianOutput; | |||
import org.apache.poi.util.RecordFormatException; | |||
@@ -61,25 +66,16 @@ public final class FtCfSubRecord extends SubRecord { | |||
} | |||
public FtCfSubRecord(LittleEndianInput in, int size) { | |||
this(in,size,-1); | |||
} | |||
FtCfSubRecord(LittleEndianInput in, int size, int cmoOt) { | |||
if (size != length) { | |||
throw new RecordFormatException("Unexpected size (" + size + ")"); | |||
} | |||
flags = in.readShort(); | |||
} | |||
/** | |||
* Convert this record to string. | |||
* Used by BiffViewer and other utilities. | |||
*/ | |||
public String toString() { | |||
StringBuilder buffer = new StringBuilder(); | |||
buffer.append("[FtCf ]\n"); | |||
buffer.append(" size = ").append(length).append("\n"); | |||
buffer.append(" flags = ").append(HexDump.toHex(flags)).append("\n"); | |||
buffer.append("[/FtCf ]\n"); | |||
return buffer.toString(); | |||
} | |||
/** | |||
* Serialize the record data into the supplied array of bytes | |||
* | |||
@@ -116,11 +112,23 @@ public final class FtCfSubRecord extends SubRecord { | |||
return new FtCfSubRecord(this); | |||
} | |||
public short getFlags() { | |||
return flags; | |||
} | |||
public short getFlags() { | |||
return flags; | |||
} | |||
public void setFlags(short flags) { | |||
this.flags = flags; | |||
} | |||
@Override | |||
public SubRecordTypes getGenericRecordType() { | |||
return SubRecordTypes.FT_CF; | |||
} | |||
public void setFlags(short flags) { | |||
this.flags = flags; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties("flags", getEnumBitsAsString(this::getFlags, | |||
new int[]{METAFILE_BIT,BITMAP_BIT,UNSPECIFIED_BIT}, | |||
new String[]{"METAFILE","BITMAP","UNSPECIFIED"})); | |||
} | |||
} |
@@ -17,7 +17,12 @@ | |||
package org.apache.poi.hssf.record; | |||
import org.apache.poi.util.HexDump; | |||
import static org.apache.poi.util.GenericRecordUtil.getBitsAsString; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
import org.apache.poi.util.LittleEndianInput; | |||
import org.apache.poi.util.LittleEndianOutput; | |||
import org.apache.poi.util.RecordFormatException; | |||
@@ -98,6 +103,10 @@ public final class FtPioGrbitSubRecord extends SubRecord { | |||
} | |||
public FtPioGrbitSubRecord(LittleEndianInput in, int size) { | |||
this(in,size,-1); | |||
} | |||
FtPioGrbitSubRecord(LittleEndianInput in, int size, int cmoOt) { | |||
if (size != length) { | |||
throw new RecordFormatException("Unexpected size (" + size + ")"); | |||
} | |||
@@ -121,19 +130,6 @@ public final class FtPioGrbitSubRecord extends SubRecord { | |||
return ((flags & bitmask) != 0); | |||
} | |||
/** | |||
* Convert this record to string. | |||
* Used by BiffViewer and other utilities. | |||
*/ | |||
public String toString() { | |||
StringBuilder buffer = new StringBuilder(); | |||
buffer.append("[FtPioGrbit ]\n"); | |||
buffer.append(" size = ").append(length).append("\n"); | |||
buffer.append(" flags = ").append(HexDump.toHex(flags)).append("\n"); | |||
buffer.append("[/FtPioGrbit ]\n"); | |||
return buffer.toString(); | |||
} | |||
/** | |||
* Serialize the record data into the supplied array of bytes | |||
* | |||
@@ -170,11 +166,25 @@ public final class FtPioGrbitSubRecord extends SubRecord { | |||
return new FtPioGrbitSubRecord(this); | |||
} | |||
public short getFlags() { | |||
return flags; | |||
} | |||
public short getFlags() { | |||
return flags; | |||
} | |||
public void setFlags(short flags) { | |||
this.flags = flags; | |||
} | |||
@Override | |||
public SubRecordTypes getGenericRecordType() { | |||
return SubRecordTypes.FT_PIO_GRBIT; | |||
} | |||
public void setFlags(short flags) { | |||
this.flags = flags; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties( | |||
"flags", getBitsAsString(this::getFlags, | |||
new int[]{AUTO_PICT_BIT, DDE_BIT, PRINT_CALC_BIT, ICON_BIT, CTL_BIT, PRSTM_BIT, CAMERA_BIT, DEFAULT_SIZE_BIT, AUTO_LOAD_BIT}, | |||
new String[]{"AUTO_PICT", "DDE", "PRINT_CALC", "ICON", "CTL", "PRSTM", "CAMERA", "DEFAULT_SIZE", "AUTO_LOAD"}) | |||
); | |||
} | |||
} |
@@ -17,6 +17,10 @@ | |||
==================================================================== */ | |||
package org.apache.poi.hssf.record; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
import org.apache.poi.util.LittleEndianOutput; | |||
import org.apache.poi.util.Removal; | |||
@@ -63,13 +67,6 @@ public final class GridsetRecord extends StandardRecord { | |||
return (field_1_gridset_flag == 1); | |||
} | |||
public String toString() { | |||
return "[GRIDSET]\n" + | |||
" .gridset = " + getGridset() + | |||
"\n" + | |||
"[/GRIDSET]\n"; | |||
} | |||
public void serialize(LittleEndianOutput out) { | |||
out.writeShort(field_1_gridset_flag); | |||
} | |||
@@ -84,7 +81,7 @@ public final class GridsetRecord extends StandardRecord { | |||
} | |||
@Override | |||
@SuppressWarnings("squid:S2975") | |||
@SuppressWarnings({"squid:S2975", "MethodDoesntCallSuperMethod"}) | |||
@Deprecated | |||
@Removal(version = "5.0.0") | |||
public GridsetRecord clone() { | |||
@@ -95,4 +92,14 @@ public final class GridsetRecord extends StandardRecord { | |||
public GridsetRecord copy() { | |||
return new GridsetRecord(this); | |||
} | |||
@Override | |||
public HSSFRecordTypes getGenericRecordType() { | |||
return HSSFRecordTypes.GRIDSET; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties("gridset", this::getGridset); | |||
} | |||
} |
@@ -17,7 +17,10 @@ | |||
package org.apache.poi.hssf.record; | |||
import org.apache.poi.util.HexDump; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
import org.apache.poi.util.IOUtils; | |||
import org.apache.poi.util.LittleEndianInput; | |||
import org.apache.poi.util.LittleEndianOutput; | |||
@@ -48,22 +51,15 @@ public final class GroupMarkerSubRecord extends SubRecord { | |||
} | |||
public GroupMarkerSubRecord(LittleEndianInput in, int size) { | |||
this(in,size,-1); | |||
} | |||
GroupMarkerSubRecord(LittleEndianInput in, int size, int cmoOt) { | |||
byte[] buf = IOUtils.safelyAllocate(size, MAX_RECORD_LENGTH); | |||
in.readFully(buf); | |||
reserved = buf; | |||
} | |||
public String toString() | |||
{ | |||
StringBuilder buffer = new StringBuilder(); | |||
String nl = System.getProperty("line.separator"); | |||
buffer.append("[ftGmo]" + nl); | |||
buffer.append(" reserved = ").append(HexDump.toHex(reserved)).append(nl); | |||
buffer.append("[/ftGmo]" + nl); | |||
return buffer.toString(); | |||
} | |||
public void serialize(LittleEndianOutput out) { | |||
out.writeShort(sid); | |||
out.writeShort(reserved.length); | |||
@@ -91,4 +87,15 @@ public final class GroupMarkerSubRecord extends SubRecord { | |||
public GroupMarkerSubRecord copy() { | |||
return new GroupMarkerSubRecord(this); | |||
} | |||
@Override | |||
public SubRecordTypes getGenericRecordType() { | |||
return SubRecordTypes.GROUP_MARKER; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties("reserved", () -> reserved); | |||
} | |||
} |
@@ -19,6 +19,10 @@ | |||
package org.apache.poi.hssf.record; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
import org.apache.poi.util.LittleEndianOutput; | |||
import org.apache.poi.util.Removal; | |||
@@ -144,23 +148,6 @@ public final class GutsRecord extends StandardRecord { | |||
return field_4_col_level_max; | |||
} | |||
public String toString() | |||
{ | |||
StringBuilder buffer = new StringBuilder(); | |||
buffer.append("[GUTS]\n"); | |||
buffer.append(" .leftgutter = ") | |||
.append(Integer.toHexString(getLeftRowGutter())).append("\n"); | |||
buffer.append(" .topgutter = ") | |||
.append(Integer.toHexString(getTopColGutter())).append("\n"); | |||
buffer.append(" .rowlevelmax = ") | |||
.append(Integer.toHexString(getRowLevelMax())).append("\n"); | |||
buffer.append(" .collevelmax = ") | |||
.append(Integer.toHexString(getColLevelMax())).append("\n"); | |||
buffer.append("[/GUTS]\n"); | |||
return buffer.toString(); | |||
} | |||
public void serialize(LittleEndianOutput out) { | |||
out.writeShort(getLeftRowGutter()); | |||
out.writeShort(getTopColGutter()); | |||
@@ -178,7 +165,7 @@ public final class GutsRecord extends StandardRecord { | |||
} | |||
@Override | |||
@SuppressWarnings("squid:S2975") | |||
@SuppressWarnings({"squid:S2975", "MethodDoesntCallSuperMethod"}) | |||
@Deprecated | |||
@Removal(version = "5.0.0") | |||
public GutsRecord clone() { | |||
@@ -189,4 +176,19 @@ public final class GutsRecord extends StandardRecord { | |||
public GutsRecord copy() { | |||
return new GutsRecord(this); | |||
} | |||
@Override | |||
public HSSFRecordTypes getGenericRecordType() { | |||
return HSSFRecordTypes.GUTS; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties( | |||
"leftGutter", this::getLeftRowGutter, | |||
"topGutter", this::getTopColGutter, | |||
"rowLevelMax", this::getRowLevelMax, | |||
"colLevelMax", this::getColLevelMax | |||
); | |||
} | |||
} |
@@ -16,6 +16,10 @@ | |||
==================================================================== */ | |||
package org.apache.poi.hssf.record; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
import org.apache.poi.util.LittleEndianOutput; | |||
import org.apache.poi.util.Removal; | |||
@@ -56,13 +60,6 @@ public final class HCenterRecord extends StandardRecord { | |||
return (field_1_hcenter == 1); | |||
} | |||
public String toString() { | |||
return "[HCENTER]\n" + | |||
" .hcenter = " + getHCenter() + | |||
"\n" + | |||
"[/HCENTER]\n"; | |||
} | |||
public void serialize(LittleEndianOutput out) { | |||
out.writeShort(field_1_hcenter); | |||
} | |||
@@ -77,7 +74,7 @@ public final class HCenterRecord extends StandardRecord { | |||
} | |||
@Override | |||
@SuppressWarnings("squid:S2975") | |||
@SuppressWarnings({"squid:S2975", "MethodDoesntCallSuperMethod"}) | |||
@Deprecated | |||
@Removal(version = "5.0.0") | |||
public HCenterRecord clone() { | |||
@@ -86,6 +83,16 @@ public final class HCenterRecord extends StandardRecord { | |||
@Override | |||
public HCenterRecord copy() { | |||
return new HCenterRecord(this); | |||
return new HCenterRecord(this); | |||
} | |||
@Override | |||
public HSSFRecordTypes getGenericRecordType() { | |||
return HSSFRecordTypes.H_CENTER; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties("hcenter", this::getHCenter); | |||
} | |||
} |
@@ -0,0 +1,233 @@ | |||
/* | |||
* ==================================================================== | |||
* 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 java.util.HashMap; | |||
import java.util.Map; | |||
import org.apache.poi.hssf.record.chart.*; | |||
import org.apache.poi.hssf.record.pivottable.DataItemRecord; | |||
import org.apache.poi.hssf.record.pivottable.ExtendedPivotTableViewFieldsRecord; | |||
import org.apache.poi.hssf.record.pivottable.PageItemRecord; | |||
import org.apache.poi.hssf.record.pivottable.StreamIDRecord; | |||
import org.apache.poi.hssf.record.pivottable.ViewDefinitionRecord; | |||
import org.apache.poi.hssf.record.pivottable.ViewFieldsRecord; | |||
import org.apache.poi.hssf.record.pivottable.ViewSourceRecord; | |||
public enum HSSFRecordTypes { | |||
UNKNOWN(-1, UnknownRecord::new), | |||
FORMULA(0x0006, FormulaRecord::new), | |||
EOF(0x000A, EOFRecord::new), | |||
CALC_COUNT(0x000C, CalcCountRecord::new), | |||
CALC_MODE(0x000D, CalcModeRecord::new), | |||
PRECISION(0x000E, PrecisionRecord::new), | |||
REF_MODE(0x000F, RefModeRecord::new), | |||
DELTA(0x0010, DeltaRecord::new), | |||
ITERATION(0x0011, IterationRecord::new), | |||
PROTECT(0x0012, ProtectRecord::new), | |||
PASSWORD(0x0013, PasswordRecord::new), | |||
HEADER(0x0014, HeaderRecord::new), | |||
FOOTER(0x0015, FooterRecord::new), | |||
EXTERN_SHEET(0x0017, ExternSheetRecord::new), | |||
NAME(0x0018, NameRecord::new), | |||
WINDOW_PROTECT(0x0019, WindowProtectRecord::new), | |||
VERTICAL_PAGE_BREAK(0x001A, VerticalPageBreakRecord::new), | |||
HORIZONTAL_PAGE_BREAK(0x001B, HorizontalPageBreakRecord::new), | |||
NOTE(0x001C, NoteRecord::new), | |||
SELECTION(0x001D, SelectionRecord::new), | |||
DATE_WINDOW_1904(0x0022, DateWindow1904Record::new), | |||
EXTERNAL_NAME(0x0023, ExternalNameRecord::new), | |||
LEFT_MARGIN(0x0026, LeftMarginRecord::new), | |||
RIGHT_MARGIN(0x0027, RightMarginRecord::new), | |||
TOP_MARGIN(0x0028, TopMarginRecord::new), | |||
BOTTOM_MARGIN(0x0029, BottomMarginRecord::new), | |||
PRINT_HEADERS(0x002A, PrintHeadersRecord::new), | |||
PRINT_GRIDLINES(0X002B, PrintGridlinesRecord::new), | |||
FILE_PASS(0x002F, FilePassRecord::new), | |||
FONT(0x0031, FontRecord::new), | |||
CONTINUE(0x003C, ContinueRecord::new), | |||
WINDOW_ONE(0x003D, WindowOneRecord::new), | |||
BACKUP(0x0040, BackupRecord::new), | |||
PANE(0x0041, PaneRecord::new), | |||
CODEPAGE(0x0042, CodepageRecord::new), | |||
DCON_REF(0x0051, DConRefRecord::new), | |||
DEFAULT_COL_WIDTH(0x0055, DefaultColWidthRecord::new), | |||
CRN_COUNT(0x0059, CRNCountRecord::new), | |||
CRN(0x005A, CRNRecord::new), | |||
WRITE_ACCESS(0x005C, WriteAccessRecord::new), | |||
FILE_SHARING(0x005B, FileSharingRecord::new), | |||
OBJ(0x005D, ObjRecord::new), | |||
UNCALCED(0x005E, UncalcedRecord::new), | |||
SAVE_RECALC(0x005F, SaveRecalcRecord::new), | |||
OBJECT_PROTECT(0x0063, ObjectProtectRecord::new), | |||
COLUMN_INFO(0x007D, ColumnInfoRecord::new), | |||
GUTS(0x0080, GutsRecord::new), | |||
WS_BOOL(0x0081, WSBoolRecord::new), | |||
GRIDSET(0x0082, GridsetRecord::new), | |||
H_CENTER(0x0083, HCenterRecord::new), | |||
V_CENTER(0x0084, VCenterRecord::new), | |||
BOUND_SHEET(0x0085, BoundSheetRecord::new), | |||
WRITE_PROTECT(0x0086, WriteProtectRecord::new), | |||
COUNTRY(0X008C, CountryRecord::new), | |||
HIDE_OBJ(0x008D, HideObjRecord::new), | |||
PALETTE(0x0092, PaletteRecord::new), | |||
FN_GROUP_COUNT(0x009c, FnGroupCountRecord::new), | |||
AUTO_FILTER_INFO(0x009D, AutoFilterInfoRecord::new), | |||
SCL(0x00A0, SCLRecord::new), | |||
PRINT_SETUP(0x00A1, PrintSetupRecord::new), | |||
VIEW_DEFINITION(0x00B0, ViewDefinitionRecord::new), | |||
VIEW_FIELDS(0x00B1, ViewFieldsRecord::new), | |||
PAGE_ITEM(0x00B6, PageItemRecord::new), | |||
MUL_BLANK(0x00BE, MulBlankRecord::new), | |||
MUL_RK(0x00BD, MulRKRecord::new), | |||
MMS(0x00C1, MMSRecord::new), | |||
DATA_ITEM(0x00C5, DataItemRecord::new), | |||
STREAM_ID(0x00D5, StreamIDRecord::new), | |||
DB_CELL(0x00D7, DBCellRecord::new), | |||
BOOK_BOOL(0x00DA, BookBoolRecord::new), | |||
SCENARIO_PROTECT(0x00DD, ScenarioProtectRecord::new), | |||
EXTENDED_FORMAT(0x00E0, ExtendedFormatRecord::new), | |||
INTERFACE_HDR(0x00E1, InterfaceHdrRecord::new), | |||
INTERFACE_END(0x00E2, InterfaceEndRecord::create), | |||
VIEW_SOURCE(0x00E3, ViewSourceRecord::new), | |||
MERGE_CELLS(0x00E5, MergeCellsRecord::new), | |||
DRAWING_GROUP(0x00EB, DrawingGroupRecord::new), | |||
DRAWING(0x00EC, DrawingRecord::new), | |||
DRAWING_SELECTION(0x00ED, DrawingSelectionRecord::new), | |||
SST(0x00FC, SSTRecord::new), | |||
LABEL_SST(0X00FD, LabelSSTRecord::new), | |||
EXT_SST(0x00FF, ExtSSTRecord::new), | |||
EXTENDED_PIVOT_TABLE_VIEW_FIELDS(0x0100, ExtendedPivotTableViewFieldsRecord::new), | |||
TAB_ID(0x013D, TabIdRecord::new), | |||
USE_SEL_FS(0x0160, UseSelFSRecord::new), | |||
DSF(0x0161, DSFRecord::new), | |||
USER_SVIEW_BEGIN(0x01AA, UserSViewBegin::new), | |||
USER_SVIEW_END(0x01AB, UserSViewEnd::new), | |||
SUP_BOOK(0x01AE, SupBookRecord::new), | |||
PROTECTION_REV_4(0x01AF, ProtectionRev4Record::new), | |||
CF_HEADER(0x01B0, CFHeaderRecord::new), | |||
CF_RULE(0x01B1, CFRuleRecord::new), | |||
DVAL(0x01B2, DVALRecord::new), | |||
TEXT_OBJECT(0x01B6, TextObjectRecord::new), | |||
REFRESH_ALL(0x01B7, RefreshAllRecord::new), | |||
HYPERLINK(0x01B8, HyperlinkRecord::new), | |||
PASSWORD_REV_4(0x01BC, PasswordRev4Record::new), | |||
DV(0x01BE, DVRecord::new), | |||
RECALC_ID(0x01C1, RecalcIdRecord::new), | |||
DIMENSIONS(0x0200, DimensionsRecord::new), | |||
BLANK(0x0201, BlankRecord::new), | |||
NUMBER(0x0203, NumberRecord::new), | |||
LABEL(0x0204, LabelRecord::new), | |||
BOOL_ERR(0x0205, BoolErrRecord::new), | |||
STRING(0x0207, StringRecord::new), | |||
ROW(0x0208, RowRecord::new), | |||
INDEX(0x020B, IndexRecord::new), | |||
ARRAY(0x0221, ArrayRecord::new), | |||
DEFAULT_ROW_HEIGHT(0x0225, DefaultRowHeightRecord::new), | |||
TABLE(0x0236, TableRecord::new), | |||
WINDOW_TWO(0x023E, WindowTwoRecord::new), | |||
RK(0x027E, RKRecord::new), | |||
STYLE(0x0293, StyleRecord::new), | |||
FORMAT(0x041E, FormatRecord::new), | |||
SHARED_FORMULA(0x04BC, SharedFormulaRecord::new), | |||
BOF(0x0809, BOFRecord::new), | |||
CHART_FRT_INFO(0x0850, ChartFRTInfoRecord::new), | |||
CHART_START_BLOCK(0x0852, ChartStartBlockRecord::new), | |||
CHART_END_BLOCK(0x0853, ChartEndBlockRecord::new), | |||
CHART_START_OBJECT(0x0854, ChartStartObjectRecord::new), | |||
CHART_END_OBJECT(0x0855, ChartEndObjectRecord::new), | |||
CAT_LAB(0x0856, CatLabRecord::new), | |||
FEAT_HDR(0x0867, FeatHdrRecord::new), | |||
FEAT(0x0868, FeatRecord::new), | |||
DATA_LABEL_EXTENSION(0x086A, DataLabelExtensionRecord::new), | |||
CF_HEADER_12(0x0879, CFHeader12Record::new), | |||
CF_RULE_12(0x087A, CFRule12Record::new), | |||
TABLE_STYLES(0x088E, TableStylesRecord::new), | |||
NAME_COMMENT(0x0894, NameCommentRecord::new), | |||
HEADER_FOOTER(0x089C, HeaderFooterRecord::new), | |||
UNITS(0x1001, UnitsRecord::new), | |||
CHART(0x1002, ChartRecord::new), | |||
SERIES(0x1003, SeriesRecord::new), | |||
DATA_FORMAT(0x1006, DataFormatRecord::new), | |||
LINE_FORMAT(0x1007, LineFormatRecord::new), | |||
AREA_FORMAT(0x100A, AreaFormatRecord::new), | |||
SERIES_LABELS(0x100C, SeriesLabelsRecord::new), | |||
SERIES_TEXT(0x100D, SeriesTextRecord::new), | |||
CHART_FORMAT(0x1014, ChartFormatRecord::new), | |||
LEGEND(0x1015, LegendRecord::new), | |||
SERIES_LIST(0x1016, SeriesListRecord::new), | |||
BAR(0x1017, BarRecord::new), | |||
AREA(0x101A, AreaRecord::new), | |||
AXIS(0x101D, AxisRecord::new), | |||
TICK(0x101E, TickRecord::new), | |||
VALUE_RANGE(0x101F, ValueRangeRecord::new), | |||
CATEGORY_SERIES_AXIS(0x1020, CategorySeriesAxisRecord::new), | |||
AXIS_LINE_FORMAT(0x1021, AxisLineFormatRecord::new), | |||
DEFAULT_DATA_LABEL_TEXT_PROPERTIES(0x1024, DefaultDataLabelTextPropertiesRecord::new), | |||
TEXT(0x1025, TextRecord::new), | |||
FONT_INDEX(0x1026, FontIndexRecord::new), | |||
OBJECT_LINK(0x1027, ObjectLinkRecord::new), | |||
FRAME(0x1032, FrameRecord::new), | |||
BEGIN(0x1033, BeginRecord::new), | |||
END(0x1034, EndRecord::new), | |||
PLOT_AREA(0x1035, PlotAreaRecord::new), | |||
AXIS_PARENT(0x1041, AxisParentRecord::new), | |||
SHEET_PROPERTIES(0x1044, SheetPropertiesRecord::new), | |||
SERIES_CHART_GROUP_INDEX(0x1045, SeriesChartGroupIndexRecord::new), | |||
AXIS_USED(0x1046, AxisUsedRecord::new), | |||
NUMBER_FORMAT_INDEX(0x104E, NumberFormatIndexRecord::new), | |||
CHART_TITLE_FORMAT(0x1050, ChartTitleFormatRecord::new), | |||
LINKED_DATA(0x1051, LinkedDataRecord::new), | |||
FONT_BASIS(0x1060, FontBasisRecord::new), | |||
AXIS_OPTIONS(0x1062, AxisOptionsRecord::new), | |||
DAT(0x1063, DatRecord::new), | |||
PLOT_GROWTH(0x1064, PlotGrowthRecord::new), | |||
SERIES_INDEX(0x1065, SeriesIndexRecord::new), | |||
// Dummy record | |||
ESCHER_AGGREGATE(9876, (in) -> new EscherAggregate(true)) | |||
; | |||
@FunctionalInterface | |||
public interface RecordConstructor<T extends Record> { | |||
T apply(RecordInputStream in); | |||
} | |||
private static final Map<Short,HSSFRecordTypes> LOOKUP; | |||
static { | |||
LOOKUP = new HashMap<>(); | |||
for(HSSFRecordTypes s : values()) { | |||
LOOKUP.put(s.sid, s); | |||
} | |||
} | |||
public final short sid; | |||
public final RecordConstructor<?> recordConstructor; | |||
HSSFRecordTypes(int sid, RecordConstructor<?> recordConstructor) { | |||
this.sid = (short)sid; | |||
this.recordConstructor = recordConstructor; | |||
} | |||
public static HSSFRecordTypes forTypeID(int typeID) { | |||
return LOOKUP.getOrDefault((short)typeID, UNKNOWN); | |||
} | |||
} |
@@ -17,6 +17,10 @@ | |||
package org.apache.poi.hssf.record; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
import org.apache.poi.util.LittleEndianOutput; | |||
import org.apache.poi.util.StringUtil; | |||
@@ -114,4 +118,9 @@ public abstract class HeaderFooterBase extends StandardRecord { | |||
@Override | |||
public abstract HeaderFooterBase copy(); | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties("text", this::getText); | |||
} | |||
} |
@@ -18,9 +18,10 @@ | |||
package org.apache.poi.hssf.record; | |||
import java.util.Arrays; | |||
import java.util.Locale; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.util.HexDump; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
import org.apache.poi.util.LittleEndianOutput; | |||
import org.apache.poi.util.Removal; | |||
@@ -29,6 +30,7 @@ import org.apache.poi.util.Removal; | |||
*/ | |||
public final class HeaderFooterRecord extends StandardRecord { | |||
public static final short sid = 0x089C; | |||
@SuppressWarnings("MismatchedReadAndWriteOfArray") | |||
private static final byte[] BLANK_GUID = new byte[16]; | |||
private byte[] _rawData; | |||
@@ -88,15 +90,8 @@ public final class HeaderFooterRecord extends StandardRecord { | |||
return Arrays.equals(getGuid(), BLANK_GUID); | |||
} | |||
public String toString() { | |||
return '[' + "HEADERFOOTER" + "] (0x" + | |||
Integer.toHexString(sid).toUpperCase(Locale.ROOT) + ")\n" + | |||
" rawData=" + HexDump.toHex(_rawData) + "\n" + | |||
"[/" + "HEADERFOOTER" + "]\n"; | |||
} | |||
@Override | |||
@SuppressWarnings("squid:S2975") | |||
@SuppressWarnings({"squid:S2975", "MethodDoesntCallSuperMethod"}) | |||
@Deprecated | |||
@Removal(version = "5.0.0") | |||
public HeaderFooterRecord clone() { | |||
@@ -108,5 +103,13 @@ public final class HeaderFooterRecord extends StandardRecord { | |||
return new HeaderFooterRecord(this); | |||
} | |||
@Override | |||
public HSSFRecordTypes getGenericRecordType() { | |||
return HSSFRecordTypes.HEADER_FOOTER; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties("rawData", () -> _rawData); | |||
} | |||
} |
@@ -37,21 +37,12 @@ public final class HeaderRecord extends HeaderFooterBase { | |||
super(in); | |||
} | |||
public String toString() { | |||
StringBuilder buffer = new StringBuilder(); | |||
buffer.append("[HEADER]\n"); | |||
buffer.append(" .header = ").append(getText()).append("\n"); | |||
buffer.append("[/HEADER]\n"); | |||
return buffer.toString(); | |||
} | |||
public short getSid() { | |||
return sid; | |||
} | |||
@Override | |||
@SuppressWarnings("squid:S2975") | |||
@SuppressWarnings({"squid:S2975", "MethodDoesntCallSuperMethod"}) | |||
@Deprecated | |||
@Removal(version = "5.0.0") | |||
public HeaderRecord clone() { | |||
@@ -62,4 +53,9 @@ public final class HeaderRecord extends HeaderFooterBase { | |||
public HeaderRecord copy() { | |||
return new HeaderRecord(this); | |||
} | |||
@Override | |||
public HSSFRecordTypes getGenericRecordType() { | |||
return HSSFRecordTypes.HEADER; | |||
} | |||
} |
@@ -19,6 +19,10 @@ | |||
package org.apache.poi.hssf.record; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
import org.apache.poi.util.LittleEndianOutput; | |||
/** | |||
@@ -73,17 +77,6 @@ public final class HideObjRecord extends StandardRecord { | |||
return field_1_hide_obj; | |||
} | |||
public String toString() | |||
{ | |||
StringBuilder buffer = new StringBuilder(); | |||
buffer.append("[HIDEOBJ]\n"); | |||
buffer.append(" .hideobj = ") | |||
.append(Integer.toHexString(getHideObj())).append("\n"); | |||
buffer.append("[/HIDEOBJ]\n"); | |||
return buffer.toString(); | |||
} | |||
public void serialize(LittleEndianOutput out) { | |||
out.writeShort(getHideObj()); | |||
} | |||
@@ -101,4 +94,14 @@ public final class HideObjRecord extends StandardRecord { | |||
public HideObjRecord copy() { | |||
return new HideObjRecord(this); | |||
} | |||
@Override | |||
public HSSFRecordTypes getGenericRecordType() { | |||
return HSSFRecordTypes.HIDE_OBJ; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties("hideObj", this::getHideObj); | |||
} | |||
} |
@@ -49,7 +49,7 @@ public final class HorizontalPageBreakRecord extends PageBreakRecord { | |||
} | |||
@Override | |||
@SuppressWarnings("squid:S2975") | |||
@SuppressWarnings({"squid:S2975", "MethodDoesntCallSuperMethod"}) | |||
@Deprecated | |||
@Removal(version = "5.0.0") | |||
public PageBreakRecord clone() { | |||
@@ -60,4 +60,9 @@ public final class HorizontalPageBreakRecord extends PageBreakRecord { | |||
public HorizontalPageBreakRecord copy() { | |||
return new HorizontalPageBreakRecord(this); | |||
} | |||
@Override | |||
public HSSFRecordTypes getGenericRecordType() { | |||
return HSSFRecordTypes.HORIZONTAL_PAGE_BREAK; | |||
} | |||
} |
@@ -20,9 +20,14 @@ package org.apache.poi.hssf.record; | |||
import static org.apache.poi.hpsf.ClassIDPredefined.FILE_MONIKER; | |||
import static org.apache.poi.hpsf.ClassIDPredefined.STD_MONIKER; | |||
import static org.apache.poi.hpsf.ClassIDPredefined.URL_MONIKER; | |||
import static org.apache.poi.util.GenericRecordUtil.getBitsAsString; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.hpsf.ClassID; | |||
import org.apache.poi.ss.util.CellRangeAddress; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
import org.apache.poi.util.HexDump; | |||
import org.apache.poi.util.HexRead; | |||
import org.apache.poi.util.IOUtils; | |||
@@ -512,16 +517,9 @@ public final class HyperlinkRecord extends StandardRecord { | |||
private static byte[] readTail(byte[] expectedTail, LittleEndianInput in) { | |||
byte[] result = new byte[TAIL_SIZE]; | |||
in.readFully(result); | |||
// if (false) { // Quite a few examples in the unit tests which don't have the exact expected tail | |||
// for (int i = 0; i < expectedTail.length; i++) { | |||
// if (expectedTail[i] != result[i]) { | |||
// logger.log( POILogger.ERROR, "Mismatch in tail byte [" + i + "]" | |||
// + "expected " + (expectedTail[i] & 0xFF) + " but got " + (result[i] & 0xFF)); | |||
// } | |||
// } | |||
// } | |||
return result; | |||
} | |||
private static void writeTail(byte[] tail, LittleEndianOutput out) { | |||
out.write(tail); | |||
} | |||
@@ -532,29 +530,6 @@ public final class HyperlinkRecord extends StandardRecord { | |||
} | |||
@Override | |||
public String toString() { | |||
StringBuilder buffer = new StringBuilder(); | |||
buffer.append("[HYPERLINK RECORD]\n"); | |||
buffer.append(" .range = ").append(_range.formatAsString()).append("\n"); | |||
buffer.append(" .guid = ").append(_guid.toString()).append("\n"); | |||
buffer.append(" .linkOpts= ").append(HexDump.intToHex(_linkOpts)).append("\n"); | |||
buffer.append(" .label = ").append(getLabel()).append("\n"); | |||
if ((_linkOpts & HLINK_TARGET_FRAME) != 0) { | |||
buffer.append(" .targetFrame= ").append(getTargetFrame()).append("\n"); | |||
} | |||
if((_linkOpts & HLINK_URL) != 0 && _moniker != null) { | |||
buffer.append(" .moniker = ").append(_moniker.toString()).append("\n"); | |||
} | |||
if ((_linkOpts & HLINK_PLACE) != 0) { | |||
buffer.append(" .textMark= ").append(getTextMark()).append("\n"); | |||
} | |||
buffer.append(" .address = ").append(getAddress()).append("\n"); | |||
buffer.append("[/HYPERLINK RECORD]\n"); | |||
return buffer.toString(); | |||
} | |||
/** | |||
* Based on the link options, is this a url? | |||
* | |||
@@ -636,4 +611,25 @@ public final class HyperlinkRecord extends StandardRecord { | |||
public HyperlinkRecord copy() { | |||
return new HyperlinkRecord(this); | |||
} | |||
@Override | |||
public HSSFRecordTypes getGenericRecordType() { | |||
return HSSFRecordTypes.HYPERLINK; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties( | |||
"range", () -> _range, | |||
"guid", this::getGuid, | |||
"linkOpts", () -> getBitsAsString(this::getLinkOptions, | |||
new int[]{HLINK_URL,HLINK_ABS,HLINK_PLACE,HLINK_LABEL,HLINK_TARGET_FRAME,HLINK_UNC_PATH}, | |||
new String[]{"URL","ABS","PLACE","LABEL","TARGET_FRAME","UNC_PATH"}), | |||
"label", this::getLabel, | |||
"targetFrame", this::getTargetFrame, | |||
"moniker", this::getMoniker, | |||
"textMark", this::getTextMark, | |||
"address", this::getAddress | |||
); | |||
} | |||
} |
@@ -17,6 +17,10 @@ | |||
package org.apache.poi.hssf.record; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
import org.apache.poi.util.IntList; | |||
import org.apache.poi.util.LittleEndianOutput; | |||
import org.apache.poi.util.RecordFormatException; | |||
@@ -106,24 +110,6 @@ public final class IndexRecord extends StandardRecord { | |||
return field_5_dbcells.get(cellnum); | |||
} | |||
@Override | |||
public String toString() | |||
{ | |||
StringBuilder buffer = new StringBuilder(); | |||
buffer.append("[INDEX]\n"); | |||
buffer.append(" .firstrow = ") | |||
.append(Integer.toHexString(getFirstRow())).append("\n"); | |||
buffer.append(" .lastrowadd1 = ") | |||
.append(Integer.toHexString(getLastRowAdd1())).append("\n"); | |||
for (int k = 0; k < getNumDbcells(); k++) { | |||
buffer.append(" .dbcell_").append(k).append(" = ") | |||
.append(Integer.toHexString(getDbcellAt(k))).append("\n"); | |||
} | |||
buffer.append("[/INDEX]\n"); | |||
return buffer.toString(); | |||
} | |||
@Override | |||
public void serialize(LittleEndianOutput out) { | |||
@@ -156,7 +142,7 @@ public final class IndexRecord extends StandardRecord { | |||
} | |||
@Override | |||
@SuppressWarnings("squid:S2975") | |||
@SuppressWarnings({"squid:S2975", "MethodDoesntCallSuperMethod"}) | |||
@Deprecated | |||
@Removal(version = "5.0.0") | |||
public IndexRecord clone() { | |||
@@ -165,6 +151,20 @@ public final class IndexRecord extends StandardRecord { | |||
@Override | |||
public IndexRecord copy() { | |||
return new IndexRecord(this); | |||
return new IndexRecord(this); | |||
} | |||
@Override | |||
public HSSFRecordTypes getGenericRecordType() { | |||
return HSSFRecordTypes.INDEX; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties( | |||
"firstRow", this::getFirstRow, | |||
"lastRowAdd1", this::getLastRowAdd1, | |||
"dbcell_", (field_5_dbcells == null) ? () -> null : field_5_dbcells::toArray | |||
); | |||
} | |||
} |
@@ -17,6 +17,9 @@ | |||
package org.apache.poi.hssf.record; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.util.LittleEndianOutput; | |||
import org.apache.poi.util.RecordFormatException; | |||
@@ -42,10 +45,6 @@ public final class InterfaceEndRecord extends StandardRecord { | |||
throw new RecordFormatException("Invalid record data size: " + in.remaining()); | |||
} | |||
public String toString() { | |||
return "[INTERFACEEND/]\n"; | |||
} | |||
public void serialize(LittleEndianOutput out) { | |||
// no instance data | |||
} | |||
@@ -62,4 +61,14 @@ public final class InterfaceEndRecord extends StandardRecord { | |||
public InterfaceEndRecord copy() { | |||
return instance; | |||
} | |||
@Override | |||
public HSSFRecordTypes getGenericRecordType() { | |||
return HSSFRecordTypes.INTERFACE_END; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return null; | |||
} | |||
} |
@@ -17,7 +17,10 @@ | |||
package org.apache.poi.hssf.record; | |||
import org.apache.poi.util.HexDump; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
import org.apache.poi.util.LittleEndianOutput; | |||
/** | |||
@@ -46,15 +49,6 @@ public final class InterfaceHdrRecord extends StandardRecord { | |||
_codepage = in.readShort(); | |||
} | |||
public String toString() { | |||
StringBuilder buffer = new StringBuilder(); | |||
buffer.append("[INTERFACEHDR]\n"); | |||
buffer.append(" .codepage = ").append(HexDump.shortToHex(_codepage)).append("\n"); | |||
buffer.append("[/INTERFACEHDR]\n"); | |||
return buffer.toString(); | |||
} | |||
public void serialize(LittleEndianOutput out) { | |||
out.writeShort(_codepage); | |||
} | |||
@@ -71,4 +65,14 @@ public final class InterfaceHdrRecord extends StandardRecord { | |||
public InterfaceHdrRecord copy() { | |||
return new InterfaceHdrRecord(this); | |||
} | |||
@Override | |||
public HSSFRecordTypes getGenericRecordType() { | |||
return HSSFRecordTypes.INTERFACE_HDR; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties("codePage", () -> _codepage); | |||
} | |||
} |
@@ -17,9 +17,12 @@ | |||
package org.apache.poi.hssf.record; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.util.BitField; | |||
import org.apache.poi.util.BitFieldFactory; | |||
import org.apache.poi.util.HexDump; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
import org.apache.poi.util.LittleEndianOutput; | |||
import org.apache.poi.util.Removal; | |||
@@ -65,15 +68,6 @@ public final class IterationRecord extends StandardRecord { | |||
return iterationOn.isSet(_flags); | |||
} | |||
public String toString() { | |||
StringBuilder buffer = new StringBuilder(); | |||
buffer.append("[ITERATION]\n"); | |||
buffer.append(" .flags = ").append(HexDump.shortToHex(_flags)).append("\n"); | |||
buffer.append("[/ITERATION]\n"); | |||
return buffer.toString(); | |||
} | |||
public void serialize(LittleEndianOutput out) { | |||
out.writeShort(_flags); | |||
} | |||
@@ -87,7 +81,7 @@ public final class IterationRecord extends StandardRecord { | |||
} | |||
@Override | |||
@SuppressWarnings("squid:S2975") | |||
@SuppressWarnings({"squid:S2975", "MethodDoesntCallSuperMethod"}) | |||
@Deprecated | |||
@Removal(version = "5.0.0") | |||
public IterationRecord clone() { | |||
@@ -98,4 +92,17 @@ public final class IterationRecord extends StandardRecord { | |||
public IterationRecord copy() { | |||
return new IterationRecord(this); | |||
} | |||
@Override | |||
public HSSFRecordTypes getGenericRecordType() { | |||
return HSSFRecordTypes.ITERATION; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties( | |||
"flags", () -> _flags, | |||
"iteration", this::getIteration | |||
); | |||
} | |||
} |
@@ -17,6 +17,10 @@ | |||
package org.apache.poi.hssf.record; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
import org.apache.poi.util.HexDump; | |||
import org.apache.poi.util.POILogFactory; | |||
import org.apache.poi.util.POILogger; | |||
@@ -149,21 +153,6 @@ public final class LabelRecord extends Record implements CellValueRecordInterfac | |||
return sid; | |||
} | |||
@Override | |||
public String toString() | |||
{ | |||
StringBuilder sb = new StringBuilder(); | |||
sb.append("[LABEL]\n"); | |||
sb.append(" .row = ").append(HexDump.shortToHex(getRow())).append("\n"); | |||
sb.append(" .column = ").append(HexDump.shortToHex(getColumn())).append("\n"); | |||
sb.append(" .xfindex = ").append(HexDump.shortToHex(getXFIndex())).append("\n"); | |||
sb.append(" .string_len= ").append(HexDump.shortToHex(field_4_string_len)).append("\n"); | |||
sb.append(" .unicode_flag= ").append(HexDump.byteToHex(field_5_unicode_flag)).append("\n"); | |||
sb.append(" .value = ").append(getValue()).append("\n"); | |||
sb.append("[/LABEL]\n"); | |||
return sb.toString(); | |||
} | |||
/** | |||
* NO-OP! | |||
*/ | |||
@@ -189,7 +178,7 @@ public final class LabelRecord extends Record implements CellValueRecordInterfac | |||
} | |||
@Override | |||
@SuppressWarnings("squid:S2975") | |||
@SuppressWarnings({"squid:S2975", "MethodDoesntCallSuperMethod"}) | |||
@Deprecated | |||
@Removal(version = "5.0.0") | |||
public LabelRecord clone() { | |||
@@ -200,4 +189,21 @@ public final class LabelRecord extends Record implements CellValueRecordInterfac | |||
public LabelRecord copy() { | |||
return new LabelRecord(this); | |||
} | |||
@Override | |||
public HSSFRecordTypes getGenericRecordType() { | |||
return HSSFRecordTypes.LABEL; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties( | |||
"row", this::getRow, | |||
"column", this::getColumn, | |||
"xfIndex", this::getXFIndex, | |||
"stringLen", this::getStringLength, | |||
"unCompressedUnicode", this::isUnCompressedUnicode, | |||
"value", this::getValue | |||
); | |||
} | |||
} |
@@ -17,7 +17,10 @@ | |||
package org.apache.poi.hssf.record; | |||
import org.apache.poi.util.HexDump; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
import org.apache.poi.util.LittleEndianOutput; | |||
import org.apache.poi.util.Removal; | |||
@@ -66,11 +69,6 @@ public final class LabelSSTRecord extends CellRecord { | |||
return "LABELSST"; | |||
} | |||
@Override | |||
protected void appendValueText(StringBuilder sb) { | |||
sb.append(" .sstIndex = "); | |||
sb.append(HexDump.shortToHex(getSSTIndex())); | |||
} | |||
@Override | |||
protected void serializeValue(LittleEndianOutput out) { | |||
out.writeInt(getSSTIndex()); | |||
@@ -87,7 +85,7 @@ public final class LabelSSTRecord extends CellRecord { | |||
} | |||
@Override | |||
@SuppressWarnings("squid:S2975") | |||
@SuppressWarnings({"squid:S2975", "MethodDoesntCallSuperMethod"}) | |||
@Deprecated | |||
@Removal(version = "5.0.0") | |||
public LabelSSTRecord clone() { | |||
@@ -98,4 +96,17 @@ public final class LabelSSTRecord extends CellRecord { | |||
public LabelSSTRecord copy() { | |||
return new LabelSSTRecord(this); | |||
} | |||
@Override | |||
public HSSFRecordTypes getGenericRecordType() { | |||
return HSSFRecordTypes.LABEL_SST; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties( | |||
"base", super::getGenericProperties, | |||
"sstIndex", this::getSSTIndex | |||
); | |||
} | |||
} |
@@ -16,9 +16,16 @@ | |||
==================================================================== */ | |||
package org.apache.poi.hssf.record; | |||
import java.util.Collections; | |||
import java.util.LinkedHashMap; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.common.Duplicatable; | |||
import org.apache.poi.common.usermodel.GenericRecord; | |||
import org.apache.poi.ss.formula.ptg.Ptg; | |||
import org.apache.poi.util.HexDump; | |||
import org.apache.poi.util.GenericRecordJsonWriter; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
import org.apache.poi.util.LittleEndianInput; | |||
import org.apache.poi.util.LittleEndianOutput; | |||
import org.apache.poi.util.RecordFormatException; | |||
@@ -287,27 +294,6 @@ public class LbsDataSubRecord extends SubRecord { | |||
return new LbsDataSubRecord(this); | |||
} | |||
@Override | |||
public String toString() { | |||
StringBuilder sb = new StringBuilder(256); | |||
sb.append("[ftLbsData]\n"); | |||
sb.append(" .unknownShort1 =").append(HexDump.shortToHex(_cbFContinued)).append("\n"); | |||
sb.append(" .formula = ").append('\n'); | |||
if(_linkPtg != null) { | |||
sb.append(_linkPtg).append(_linkPtg.getRVAType()).append('\n'); | |||
} | |||
sb.append(" .nEntryCount =").append(HexDump.shortToHex(_cLines)).append("\n"); | |||
sb.append(" .selEntryIx =").append(HexDump.shortToHex(_iSel)).append("\n"); | |||
sb.append(" .style =").append(HexDump.shortToHex(_flags)).append("\n"); | |||
sb.append(" .unknownShort10=").append(HexDump.shortToHex(_idEdit)).append("\n"); | |||
if(_dropData != null) { | |||
sb.append('\n').append(_dropData); | |||
} | |||
sb.append("[/ftLbsData]\n"); | |||
return sb.toString(); | |||
} | |||
/** | |||
* | |||
* @return the formula that specifies the range of cell values that are the items in this list. | |||
@@ -323,10 +309,32 @@ public class LbsDataSubRecord extends SubRecord { | |||
return _cLines; | |||
} | |||
@Override | |||
public SubRecordTypes getGenericRecordType() { | |||
return SubRecordTypes.LBS_DATA; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
final Map<String,Supplier<?>> m = new LinkedHashMap<>(); | |||
m.put("unknownShort1", () -> _cbFContinued); | |||
m.put("unknownPreFormulaInt", () -> _unknownPreFormulaInt); | |||
m.put("formula", this::getFormula); | |||
m.put("unknownPostFormulaByte", () -> _unknownPostFormulaByte); | |||
m.put("numberOfItems", this::getNumberOfItems); | |||
m.put("selEntryIx", () -> _iSel); | |||
m.put("style", () -> _flags); | |||
m.put("unknownShort10", () -> _idEdit); | |||
m.put("dropData", () -> _dropData); | |||
m.put("rgLines", () -> _rgLines); | |||
m.put("bsels", () -> _bsels); | |||
return Collections.unmodifiableMap(m); | |||
} | |||
/** | |||
* This structure specifies properties of the dropdown list control | |||
*/ | |||
public static class LbsDropData implements Duplicatable { | |||
public static class LbsDropData implements Duplicatable, GenericRecord { | |||
/** | |||
* Combo dropdown control | |||
*/ | |||
@@ -435,23 +443,23 @@ public class LbsDataSubRecord extends SubRecord { | |||
@Override | |||
public String toString(){ | |||
StringBuilder sb = new StringBuilder(); | |||
sb.append("[LbsDropData]\n"); | |||
sb.append(" ._wStyle: ").append(_wStyle).append('\n'); | |||
sb.append(" ._cLine: ").append(_cLine).append('\n'); | |||
sb.append(" ._dxMin: ").append(_dxMin).append('\n'); | |||
sb.append(" ._str: ").append(_str).append('\n'); | |||
if(_unused != null) { | |||
sb.append(" ._unused: ").append(_unused).append('\n'); | |||
} | |||
sb.append("[/LbsDropData]\n"); | |||
return sb.toString(); | |||
return GenericRecordJsonWriter.marshal(this); | |||
} | |||
@Override | |||
public LbsDropData copy() { | |||
return new LbsDropData(this); | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties( | |||
"wStyle", () -> _wStyle, | |||
"cLine", () -> _cLine, | |||
"dxMin", () -> _dxMin, | |||
"str", () -> _str, | |||
"unused", () -> _unused | |||
); | |||
} | |||
} | |||
} |
@@ -17,6 +17,10 @@ | |||
package org.apache.poi.hssf.record; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
import org.apache.poi.util.LittleEndianOutput; | |||
import org.apache.poi.util.Removal; | |||
@@ -38,15 +42,6 @@ public final class LeftMarginRecord extends StandardRecord implements Margin { | |||
field_1_margin = in.readDouble(); | |||
} | |||
public String toString() | |||
{ | |||
StringBuilder buffer = new StringBuilder(); | |||
buffer.append( "[LeftMargin]\n" ); | |||
buffer.append( " .margin = " ).append( " (" ).append( getMargin() ).append( " )\n" ); | |||
buffer.append( "[/LeftMargin]\n" ); | |||
return buffer.toString(); | |||
} | |||
public void serialize(LittleEndianOutput out) { | |||
out.writeDouble(field_1_margin); | |||
} | |||
@@ -75,7 +70,7 @@ public final class LeftMarginRecord extends StandardRecord implements Margin { | |||
} | |||
@Override | |||
@SuppressWarnings("squid:S2975") | |||
@SuppressWarnings({"squid:S2975", "MethodDoesntCallSuperMethod"}) | |||
@Deprecated | |||
@Removal(version = "5.0.0") | |||
public LeftMarginRecord clone() { | |||
@@ -86,4 +81,14 @@ public final class LeftMarginRecord extends StandardRecord implements Margin { | |||
public LeftMarginRecord copy() { | |||
return new LeftMarginRecord(this); | |||
} | |||
@Override | |||
public HSSFRecordTypes getGenericRecordType() { | |||
return HSSFRecordTypes.LEFT_MARGIN; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties("margin", this::getMargin); | |||
} | |||
} |
@@ -19,6 +19,10 @@ | |||
package org.apache.poi.hssf.record; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
import org.apache.poi.util.LittleEndianOutput; | |||
/** | |||
@@ -89,19 +93,6 @@ public final class MMSRecord extends StandardRecord { | |||
return field_2_delMenuCount; | |||
} | |||
public String toString() | |||
{ | |||
StringBuilder buffer = new StringBuilder(); | |||
buffer.append("[MMS]\n"); | |||
buffer.append(" .addMenu = ") | |||
.append(Integer.toHexString(getAddMenuCount())).append("\n"); | |||
buffer.append(" .delMenu = ") | |||
.append(Integer.toHexString(getDelMenuCount())).append("\n"); | |||
buffer.append("[/MMS]\n"); | |||
return buffer.toString(); | |||
} | |||
public void serialize(LittleEndianOutput out) { | |||
out.writeByte(getAddMenuCount()); | |||
out.writeByte(getDelMenuCount()); | |||
@@ -120,4 +111,17 @@ public final class MMSRecord extends StandardRecord { | |||
public MMSRecord copy() { | |||
return new MMSRecord(this); | |||
} | |||
@Override | |||
public HSSFRecordTypes getGenericRecordType() { | |||
return HSSFRecordTypes.MMS; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties( | |||
"addMenuCount", this::getAddMenuCount, | |||
"delMenuCount", this::getDelMenuCount | |||
); | |||
} | |||
} |
@@ -17,10 +17,14 @@ | |||
package org.apache.poi.hssf.record; | |||
import java.util.Arrays; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import java.util.stream.Stream; | |||
import org.apache.poi.ss.util.CellRangeAddress; | |||
import org.apache.poi.ss.util.CellRangeAddressList; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
import org.apache.poi.util.LittleEndianOutput; | |||
import org.apache.poi.util.Removal; | |||
@@ -100,25 +104,7 @@ public final class MergeCellsRecord extends StandardRecord { | |||
} | |||
@Override | |||
public String toString() { | |||
StringBuilder retval = new StringBuilder(); | |||
retval.append("[MERGEDCELLS]").append("\n"); | |||
retval.append(" .numregions =").append(getNumAreas()).append("\n"); | |||
for (int k = 0; k < _numberOfRegions; k++) { | |||
CellRangeAddress r = _regions[_startIndex + k]; | |||
retval.append(" .rowfrom =").append(r.getFirstRow()).append("\n"); | |||
retval.append(" .rowto =").append(r.getLastRow()).append("\n"); | |||
retval.append(" .colfrom =").append(r.getFirstColumn()).append("\n"); | |||
retval.append(" .colto =").append(r.getLastColumn()).append("\n"); | |||
} | |||
retval.append("[MERGEDCELLS]").append("\n"); | |||
return retval.toString(); | |||
} | |||
@Override | |||
@SuppressWarnings("squid:S2975") | |||
@SuppressWarnings({"squid:S2975", "MethodDoesntCallSuperMethod"}) | |||
@Deprecated | |||
@Removal(version = "5.0.0") | |||
public MergeCellsRecord clone() { | |||
@@ -129,4 +115,17 @@ public final class MergeCellsRecord extends StandardRecord { | |||
public MergeCellsRecord copy() { | |||
return new MergeCellsRecord(this); | |||
} | |||
@Override | |||
public HSSFRecordTypes getGenericRecordType() { | |||
return HSSFRecordTypes.MERGE_CELLS; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties( | |||
"numRegions", this::getNumAreas, | |||
"regions", () -> Arrays.copyOfRange(_regions, _startIndex, _startIndex+_numberOfRegions) | |||
); | |||
} | |||
} |
@@ -17,6 +17,10 @@ | |||
package org.apache.poi.hssf.record; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
import org.apache.poi.util.LittleEndianOutput; | |||
import org.apache.poi.util.Removal; | |||
@@ -97,21 +101,6 @@ public final class MulBlankRecord extends StandardRecord { | |||
return retval; | |||
} | |||
public String toString() { | |||
StringBuilder buffer = new StringBuilder(); | |||
buffer.append("[MULBLANK]\n"); | |||
buffer.append("row = ").append(Integer.toHexString(getRow())).append("\n"); | |||
buffer.append("firstcol = ").append(Integer.toHexString(getFirstColumn())).append("\n"); | |||
buffer.append(" lastcol = ").append(Integer.toHexString(_lastCol)).append("\n"); | |||
for (int k = 0; k < getNumColumns(); k++) { | |||
buffer.append("xf").append(k).append(" = ").append( | |||
Integer.toHexString(getXFAt(k))).append("\n"); | |||
} | |||
buffer.append("[/MULBLANK]\n"); | |||
return buffer.toString(); | |||
} | |||
public short getSid() { | |||
return sid; | |||
} | |||
@@ -119,7 +108,6 @@ public final class MulBlankRecord extends StandardRecord { | |||
public void serialize(LittleEndianOutput out) { | |||
out.writeShort(_row); | |||
out.writeShort(_firstCol); | |||
int nItems = _xfs.length; | |||
for (short xf : _xfs) { | |||
out.writeShort(xf); | |||
} | |||
@@ -132,7 +120,7 @@ public final class MulBlankRecord extends StandardRecord { | |||
} | |||
@Override | |||
@SuppressWarnings("squid:S2975") | |||
@SuppressWarnings({"squid:S2975", "MethodDoesntCallSuperMethod"}) | |||
@Deprecated | |||
@Removal(version = "5.0.0") | |||
public MulBlankRecord clone() { | |||
@@ -144,4 +132,19 @@ public final class MulBlankRecord extends StandardRecord { | |||
// immutable - so OK to return this | |||
return this; | |||
} | |||
@Override | |||
public HSSFRecordTypes getGenericRecordType() { | |||
return HSSFRecordTypes.MUL_BLANK; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties( | |||
"row", this::getRow, | |||
"firstColumn", this::getFirstColumn, | |||
"lastColumn", this::getLastColumn, | |||
"xf", () -> _xfs | |||
); | |||
} | |||
} |
@@ -17,8 +17,12 @@ | |||
package org.apache.poi.hssf.record; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.common.usermodel.GenericRecord; | |||
import org.apache.poi.hssf.util.RKUtil; | |||
import org.apache.poi.util.HexDump; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
import org.apache.poi.util.LittleEndianOutput; | |||
import org.apache.poi.util.RecordFormatException; | |||
@@ -96,24 +100,6 @@ public final class MulRKRecord extends StandardRecord { | |||
field_4_last_col = in.readShort(); | |||
} | |||
@Override | |||
public String toString() { | |||
StringBuilder buffer = new StringBuilder(); | |||
buffer.append("[MULRK]\n"); | |||
buffer.append(" .row = ").append(HexDump.shortToHex(getRow())).append("\n"); | |||
buffer.append(" .firstcol= ").append(HexDump.shortToHex(getFirstColumn())).append("\n"); | |||
buffer.append(" .lastcol = ").append(HexDump.shortToHex(getLastColumn())).append("\n"); | |||
for (int k = 0; k < getNumColumns(); k++) { | |||
buffer.append(" xf[").append(k).append("] = ").append(HexDump.shortToHex(getXFAt(k))).append("\n"); | |||
buffer.append(" rk[").append(k).append("] = ").append(getRKNumberAt(k)).append("\n"); | |||
} | |||
buffer.append("[/MULRK]\n"); | |||
return buffer.toString(); | |||
} | |||
@Override | |||
public short getSid() | |||
{ | |||
@@ -129,7 +115,7 @@ public final class MulRKRecord extends StandardRecord { | |||
throw new RecordFormatException( "Sorry, you can't serialize MulRK in this release"); | |||
} | |||
private static final class RkRec { | |||
private static final class RkRec implements GenericRecord { | |||
public static final int ENCODED_SIZE = 6; | |||
public final short xf; | |||
public final int rk; | |||
@@ -147,6 +133,14 @@ public final class MulRKRecord extends StandardRecord { | |||
} | |||
return retval; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties( | |||
"xf", () -> xf, | |||
"rk", () -> rk | |||
); | |||
} | |||
} | |||
@Override | |||
@@ -154,4 +148,19 @@ public final class MulRKRecord extends StandardRecord { | |||
// immutable - so OK to return this | |||
return this; | |||
} | |||
@Override | |||
public HSSFRecordTypes getGenericRecordType() { | |||
return HSSFRecordTypes.MUL_RK; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties( | |||
"row", this::getRow, | |||
"firstColumn", this::getFirstColumn, | |||
"lastColumn", this::getLastColumn, | |||
"rk", () -> field_3_rks | |||
); | |||
} | |||
} |
@@ -17,7 +17,10 @@ | |||
package org.apache.poi.hssf.record; | |||
import org.apache.poi.util.HexDump; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
import org.apache.poi.util.LittleEndianOutput; | |||
import org.apache.poi.util.StringUtil; | |||
@@ -115,23 +118,6 @@ public final class NameCommentRecord extends StandardRecord { | |||
return sid; | |||
} | |||
@Override | |||
public String toString() { | |||
final StringBuilder sb = new StringBuilder(); | |||
sb.append("[NAMECMT]\n"); | |||
sb.append(" .record type = ").append(HexDump.shortToHex(field_1_record_type)).append("\n"); | |||
sb.append(" .frt cell ref flag = ").append(HexDump.byteToHex(field_2_frt_cell_ref_flag)).append("\n"); | |||
sb.append(" .reserved = ").append(field_3_reserved).append("\n"); | |||
sb.append(" .name length = ").append(field_6_name_text.length()).append("\n"); | |||
sb.append(" .comment length = ").append(field_7_comment_text.length()).append("\n"); | |||
sb.append(" .name = ").append(field_6_name_text).append("\n"); | |||
sb.append(" .comment = ").append(field_7_comment_text).append("\n"); | |||
sb.append("[/NAMECMT]\n"); | |||
return sb.toString(); | |||
} | |||
/** | |||
* @return the name of the NameRecord to which this comment applies. | |||
*/ | |||
@@ -168,4 +154,20 @@ public final class NameCommentRecord extends StandardRecord { | |||
public NameCommentRecord copy() { | |||
return new NameCommentRecord(this); | |||
} | |||
@Override | |||
public HSSFRecordTypes getGenericRecordType() { | |||
return HSSFRecordTypes.NAME_COMMENT; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties( | |||
"recordType", this::getRecordType, | |||
"frtCellRefFlag", () -> field_2_frt_cell_ref_flag, | |||
"reserved", () -> field_3_reserved, | |||
"name", this::getNameText, | |||
"comment", this::getCommentText | |||
); | |||
} | |||
} |
@@ -17,13 +17,17 @@ | |||
package org.apache.poi.hssf.record; | |||
import java.util.Collections; | |||
import java.util.LinkedHashMap; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.hssf.record.cont.ContinuableRecord; | |||
import org.apache.poi.hssf.record.cont.ContinuableRecordOutput; | |||
import org.apache.poi.ss.formula.Formula; | |||
import org.apache.poi.ss.formula.ptg.Area3DPtg; | |||
import org.apache.poi.ss.formula.ptg.Ptg; | |||
import org.apache.poi.ss.formula.ptg.Ref3DPtg; | |||
import org.apache.poi.util.HexDump; | |||
import org.apache.poi.util.LittleEndianByteArrayInputStream; | |||
import org.apache.poi.util.LittleEndianInput; | |||
import org.apache.poi.util.StringUtil; | |||
@@ -31,6 +35,7 @@ import org.apache.poi.util.StringUtil; | |||
/** | |||
* Defines a named range within a workbook. | |||
*/ | |||
@SuppressWarnings("unused") | |||
public final class NameRecord extends ContinuableRecord { | |||
public static final short sid = 0x0018; | |||
/**Included for completeness sake, not implemented */ | |||
@@ -238,6 +243,7 @@ public final class NameRecord extends ContinuableRecord { | |||
public boolean isHiddenName() { | |||
return (field_1_option_flag & Option.OPT_HIDDEN_NAME) != 0; | |||
} | |||
public void setHidden(boolean b) { | |||
if (b) { | |||
field_1_option_flag |= Option.OPT_HIDDEN_NAME; | |||
@@ -416,7 +422,7 @@ public final class NameRecord extends ContinuableRecord { | |||
return nChars; | |||
} | |||
protected int getDataSize() { | |||
int getDataSize() { | |||
return 13 // 3 shorts + 7 bytes | |||
+ getNameRawSize() | |||
+ field_14_custom_menu_text.length() | |||
@@ -552,37 +558,6 @@ public final class NameRecord extends ContinuableRecord { | |||
3B 00 00 07 00 07 00 00 00 FF 00 ] | |||
*/ | |||
@Override | |||
public String toString() { | |||
StringBuilder sb = new StringBuilder(); | |||
sb.append("[NAME]\n"); | |||
sb.append(" .option flags = ").append(HexDump.shortToHex(field_1_option_flag)).append("\n"); | |||
sb.append(" .keyboard shortcut = ").append(HexDump.byteToHex(field_2_keyboard_shortcut)).append("\n"); | |||
sb.append(" .length of the name = ").append(getNameTextLength()).append("\n"); | |||
sb.append(" .extSheetIx(1-based, 0=Global)= ").append( field_5_externSheetIndex_plus1 ).append("\n"); | |||
sb.append(" .sheetTabIx = ").append(field_6_sheetNumber ).append("\n"); | |||
sb.append(" .Menu text length = ").append(field_14_custom_menu_text.length()).append("\n"); | |||
sb.append(" .Description text length= ").append(field_15_description_text.length()).append("\n"); | |||
sb.append(" .Help topic text length = ").append(field_16_help_topic_text.length()).append("\n"); | |||
sb.append(" .Status bar text length = ").append(field_17_status_bar_text.length()).append("\n"); | |||
sb.append(" .NameIsMultibyte = ").append(field_11_nameIsMultibyte).append("\n"); | |||
sb.append(" .Name (Unicode text) = ").append( getNameText() ).append("\n"); | |||
Ptg[] ptgs = field_13_name_definition.getTokens(); | |||
sb.append(" .Formula (nTokens=").append(ptgs.length).append("):") .append("\n"); | |||
for (Ptg ptg : ptgs) { | |||
sb.append(" ").append(ptg).append(ptg.getRVAType()).append("\n"); | |||
} | |||
sb.append(" .Menu text = ").append(field_14_custom_menu_text).append("\n"); | |||
sb.append(" .Description text= ").append(field_15_description_text).append("\n"); | |||
sb.append(" .Help topic text = ").append(field_16_help_topic_text).append("\n"); | |||
sb.append(" .Status bar text = ").append(field_17_status_bar_text).append("\n"); | |||
sb.append("[/NAME]\n"); | |||
return sb.toString(); | |||
} | |||
/**Creates a human readable name for built in types | |||
* @return Unknown if the built-in name cannot be translated | |||
*/ | |||
@@ -613,4 +588,29 @@ public final class NameRecord extends ContinuableRecord { | |||
public NameRecord copy() { | |||
return new NameRecord(this); | |||
} | |||
@Override | |||
public HSSFRecordTypes getGenericRecordType() { | |||
return HSSFRecordTypes.NAME; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
final Map<String,Supplier<?>> m = new LinkedHashMap<>(); | |||
m.put("dataSize", this::getDataSize); | |||
m.put("optionFlag", this::getOptionFlag); | |||
m.put("keyboardShortcut", this::getKeyboardShortcut); | |||
m.put("externSheetIndex", () -> field_5_externSheetIndex_plus1); | |||
m.put("sheetNumber", this::getSheetNumber); | |||
m.put("nameIsMultibyte", () -> field_11_nameIsMultibyte); | |||
m.put("builtInName", this::getBuiltInName); | |||
m.put("nameLength", this::getNameTextLength); | |||
m.put("nameText", this::getNameText); | |||
m.put("formula", this::getNameDefinition); | |||
m.put("customMenuText", this::getCustomMenuText); | |||
m.put("descriptionText", this::getDescriptionText); | |||
m.put("helpTopicText", this::getHelpTopicText); | |||
m.put("statusBarText", this::getStatusBarText); | |||
return Collections.unmodifiableMap(m); | |||
} | |||
} |
@@ -17,6 +17,10 @@ | |||
package org.apache.poi.hssf.record; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
import org.apache.poi.util.LittleEndianOutput; | |||
import org.apache.poi.util.Removal; | |||
import org.apache.poi.util.StringUtil; | |||
@@ -102,10 +106,10 @@ public final class NoteRecord extends StandardRecord { | |||
field_6_author = StringUtil.readCompressedUnicode(in, length); | |||
} | |||
if (in.available() == 1) { | |||
field_7_padding = Byte.valueOf(in.readByte()); | |||
field_7_padding = in.readByte(); | |||
} else if (in.available() == 2 && length == 0) { | |||
// If there's no author, may be double padded | |||
field_7_padding = Byte.valueOf(in.readByte()); | |||
field_7_padding = in.readByte(); | |||
in.readByte(); | |||
} | |||
} | |||
@@ -133,23 +137,6 @@ public final class NoteRecord extends StandardRecord { | |||
+ (field_7_padding == null ? 0 : 1); | |||
} | |||
/** | |||
* Convert this record to string. | |||
* Used by BiffViewer and other utilities. | |||
*/ | |||
public String toString() { | |||
StringBuilder buffer = new StringBuilder(); | |||
buffer.append("[NOTE]\n"); | |||
buffer.append(" .row = ").append(field_1_row).append("\n"); | |||
buffer.append(" .col = ").append(field_2_col).append("\n"); | |||
buffer.append(" .flags = ").append(field_3_flags).append("\n"); | |||
buffer.append(" .shapeid= ").append(field_4_shapeid).append("\n"); | |||
buffer.append(" .author = ").append(field_6_author).append("\n"); | |||
buffer.append("[/NOTE]\n"); | |||
return buffer.toString(); | |||
} | |||
/** | |||
* Return the row that contains the comment | |||
* | |||
@@ -213,7 +200,7 @@ public final class NoteRecord extends StandardRecord { | |||
* | |||
* @return true, if author element uses multi byte | |||
*/ | |||
protected boolean authorIsMultibyte() { | |||
boolean authorIsMultibyte() { | |||
return field_5_hasMultibyte; | |||
} | |||
@@ -255,7 +242,7 @@ public final class NoteRecord extends StandardRecord { | |||
} | |||
@Override | |||
@SuppressWarnings("squid:S2975") | |||
@SuppressWarnings({"squid:S2975", "MethodDoesntCallSuperMethod"}) | |||
@Deprecated | |||
@Removal(version = "5.0.0") | |||
public NoteRecord clone() { | |||
@@ -266,4 +253,20 @@ public final class NoteRecord extends StandardRecord { | |||
public NoteRecord copy() { | |||
return new NoteRecord(this); | |||
} | |||
@Override | |||
public HSSFRecordTypes getGenericRecordType() { | |||
return HSSFRecordTypes.NOTE; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties( | |||
"row", this::getRow, | |||
"column", this::getColumn, | |||
"flags", this::getFlags, | |||
"shapeId", this::getShapeId, | |||
"author", this::getAuthor | |||
); | |||
} | |||
} |
@@ -17,7 +17,10 @@ | |||
package org.apache.poi.hssf.record; | |||
import org.apache.poi.util.HexDump; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
import org.apache.poi.util.IOUtils; | |||
import org.apache.poi.util.LittleEndianInput; | |||
import org.apache.poi.util.LittleEndianOutput; | |||
@@ -58,6 +61,10 @@ public final class NoteStructureSubRecord extends SubRecord { | |||
* @param size the provided size - must be 22 | |||
*/ | |||
public NoteStructureSubRecord(LittleEndianInput in, int size) { | |||
this(in,size,-1); | |||
} | |||
public NoteStructureSubRecord(LittleEndianInput in, int size, int cmoOt) { | |||
if (size != ENCODED_SIZE) { | |||
throw new RecordFormatException("Unexpected size (" + size + ")"); | |||
} | |||
@@ -67,22 +74,6 @@ public final class NoteStructureSubRecord extends SubRecord { | |||
reserved = buf; | |||
} | |||
/** | |||
* Convert this record to string. | |||
* Used by BiffViewer and other utilities. | |||
*/ | |||
@Override | |||
public String toString() | |||
{ | |||
StringBuilder buffer = new StringBuilder(); | |||
buffer.append("[ftNts ]").append("\n"); | |||
buffer.append(" size = ").append(getDataSize()).append("\n"); | |||
buffer.append(" reserved = ").append(HexDump.toHex(reserved)).append("\n"); | |||
buffer.append("[/ftNts ]").append("\n"); | |||
return buffer.toString(); | |||
} | |||
/** | |||
* Serialize the record data into the supplied array of bytes | |||
* | |||
@@ -121,6 +112,17 @@ public final class NoteStructureSubRecord extends SubRecord { | |||
return new NoteStructureSubRecord(this); | |||
} | |||
@Override | |||
public SubRecordTypes getGenericRecordType() { | |||
return SubRecordTypes.NOTE_STRUCTURE; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties( | |||
"reserved", () -> reserved | |||
); | |||
} | |||
} | |||
@@ -17,7 +17,10 @@ | |||
package org.apache.poi.hssf.record; | |||
import org.apache.poi.ss.util.NumberToTextConverter; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
import org.apache.poi.util.LittleEndianOutput; | |||
import org.apache.poi.util.Removal; | |||
@@ -68,11 +71,6 @@ public final class NumberRecord extends CellRecord { | |||
return "NUMBER"; | |||
} | |||
@Override | |||
protected void appendValueText(StringBuilder sb) { | |||
sb.append(" .value= ").append(NumberToTextConverter.toText(field_4_value)); | |||
} | |||
@Override | |||
protected void serializeValue(LittleEndianOutput out) { | |||
out.writeDouble(getValue()); | |||
@@ -89,7 +87,7 @@ public final class NumberRecord extends CellRecord { | |||
} | |||
@Override | |||
@SuppressWarnings("squid:S2975") | |||
@SuppressWarnings({"squid:S2975", "MethodDoesntCallSuperMethod"}) | |||
@Deprecated | |||
@Removal(version = "5.0.0") | |||
public NumberRecord clone() { | |||
@@ -100,4 +98,17 @@ public final class NumberRecord extends CellRecord { | |||
public NumberRecord copy() { | |||
return new NumberRecord(this); | |||
} | |||
@Override | |||
public HSSFRecordTypes getGenericRecordType() { | |||
return HSSFRecordTypes.NUMBER; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties( | |||
"base", super::getGenericProperties, | |||
"value", this::getValue | |||
); | |||
} | |||
} |
@@ -20,7 +20,10 @@ package org.apache.poi.hssf.record; | |||
import java.io.IOException; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
import org.apache.poi.util.HexDump; | |||
import org.apache.poi.util.LittleEndian; | |||
import org.apache.poi.util.LittleEndianByteArrayInputStream; | |||
@@ -139,18 +142,6 @@ public final class ObjRecord extends Record { | |||
return true; | |||
} | |||
@Override | |||
public String toString() { | |||
StringBuilder sb = new StringBuilder(); | |||
sb.append("[OBJ]\n"); | |||
for (final SubRecord record : subrecords) { | |||
sb.append("SUBRECORD: ").append(record); | |||
} | |||
sb.append("[/OBJ]\n"); | |||
return sb.toString(); | |||
} | |||
@Override | |||
public int getRecordSize() { | |||
if (_uninterpretedData != null) { | |||
@@ -225,7 +216,7 @@ public final class ObjRecord extends Record { | |||
} | |||
@Override | |||
@SuppressWarnings("squid:S2975") | |||
@SuppressWarnings({"squid:S2975", "MethodDoesntCallSuperMethod"}) | |||
@Deprecated | |||
@Removal(version = "5.0.0") | |||
public ObjRecord clone() { | |||
@@ -236,4 +227,22 @@ public final class ObjRecord extends Record { | |||
public ObjRecord copy() { | |||
return new ObjRecord(this); | |||
} | |||
@Override | |||
public HSSFRecordTypes getGenericRecordType() { | |||
return HSSFRecordTypes.OBJ; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties( | |||
"uninterpretedData", () -> _uninterpretedData, | |||
"paddedToQuadByteMultiple", () -> _isPaddedToQuadByteMultiple | |||
); | |||
} | |||
@Override | |||
public List<SubRecord> getGenericChildren() { | |||
return getSubRecords(); | |||
} | |||
} |
@@ -19,6 +19,10 @@ | |||
package org.apache.poi.hssf.record; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
import org.apache.poi.util.LittleEndianOutput; | |||
import org.apache.poi.util.Removal; | |||
@@ -64,17 +68,6 @@ public final class ObjectProtectRecord extends StandardRecord { | |||
return (field_1_protect == 1); | |||
} | |||
public String toString() | |||
{ | |||
StringBuilder buffer = new StringBuilder(); | |||
buffer.append("[SCENARIOPROTECT]\n"); | |||
buffer.append(" .protect = ").append(getProtect()) | |||
.append("\n"); | |||
buffer.append("[/SCENARIOPROTECT]\n"); | |||
return buffer.toString(); | |||
} | |||
public void serialize(LittleEndianOutput out) { | |||
out.writeShort(field_1_protect); | |||
} | |||
@@ -89,7 +82,7 @@ public final class ObjectProtectRecord extends StandardRecord { | |||
} | |||
@Override | |||
@SuppressWarnings("squid:S2975") | |||
@SuppressWarnings({"squid:S2975", "MethodDoesntCallSuperMethod"}) | |||
@Deprecated | |||
@Removal(version = "5.0.0") | |||
public ObjectProtectRecord clone() { | |||
@@ -100,4 +93,14 @@ public final class ObjectProtectRecord extends StandardRecord { | |||
public ObjectProtectRecord copy() { | |||
return new ObjectProtectRecord(this); | |||
} | |||
@Override | |||
public HSSFRecordTypes getGenericRecordType() { | |||
return HSSFRecordTypes.OBJECT_PROTECT; | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties("protect", this::getProtect); | |||
} | |||
} |
@@ -21,7 +21,10 @@ import java.util.ArrayList; | |||
import java.util.HashMap; | |||
import java.util.Iterator; | |||
import java.util.Map; | |||
import java.util.function.Supplier; | |||
import org.apache.poi.common.usermodel.GenericRecord; | |||
import org.apache.poi.util.GenericRecordUtil; | |||
import org.apache.poi.util.LittleEndianOutput; | |||
/** | |||
@@ -47,7 +50,7 @@ public abstract class PageBreakRecord extends StandardRecord { | |||
* The subs (rows or columns, don't seem to be able to set but excel sets | |||
* them automatically) | |||
*/ | |||
public static final class Break { | |||
public static final class Break implements GenericRecord { | |||
public static final int ENCODED_SIZE = 6; | |||
public int main; | |||
@@ -77,6 +80,15 @@ public abstract class PageBreakRecord extends StandardRecord { | |||
out.writeShort(subFrom); | |||
out.writeShort(subTo); | |||
} | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties( | |||
"main", () -> main, | |||
"subFrom", () -> subFrom, | |||
"subTo", () -> subTo | |||
); | |||
} | |||
} | |||
protected PageBreakRecord() {} | |||
@@ -86,7 +98,7 @@ public abstract class PageBreakRecord extends StandardRecord { | |||
initMap(); | |||
} | |||
public PageBreakRecord(RecordInputStream in) { | |||
protected PageBreakRecord(RecordInputStream in) { | |||
final int nBreaks = in.readShort(); | |||
_breaks.ensureCapacity(nBreaks + 2); | |||
for(int k = 0; k < nBreaks; k++) { | |||
@@ -96,7 +108,7 @@ public abstract class PageBreakRecord extends StandardRecord { | |||
} | |||
private void initMap() { | |||
_breaks.forEach(br -> _breakMap.put(Integer.valueOf(br.main), br)); | |||
_breaks.forEach(br -> _breakMap.put(br.main, br)); | |||
} | |||
public boolean isEmpty() { | |||
@@ -122,40 +134,6 @@ public abstract class PageBreakRecord extends StandardRecord { | |||
return _breaks.iterator(); | |||
} | |||
public String toString() { | |||
StringBuilder retval = new StringBuilder(); | |||
String label; | |||
String mainLabel; | |||
String subLabel; | |||
if (getSid() == HorizontalPageBreakRecord.sid) { | |||
label = "HORIZONTALPAGEBREAK"; | |||
mainLabel = "row"; | |||
subLabel = "col"; | |||
} else { | |||
label = "VERTICALPAGEBREAK"; | |||
mainLabel = "column"; | |||
subLabel = "row"; | |||
} | |||
retval.append("["+label+"]").append("\n"); | |||
retval.append(" .sid =").append(getSid()).append("\n"); | |||
retval.append(" .numbreaks =").append(getNumBreaks()).append("\n"); | |||
Iterator<Break> iterator = getBreaksIterator(); | |||
for(int k = 0; k < getNumBreaks(); k++) | |||
{ | |||
Break region = iterator.next(); | |||
retval.append(" .").append(mainLabel).append(" (zero-based) =").append(region.main).append("\n"); | |||
retval.append(" .").append(subLabel).append("From =").append(region.subFrom).append("\n"); | |||
retval.append(" .").append(subLabel).append("To =").append(region.subTo).append("\n"); | |||
} | |||
retval.append("["+label+"]").append("\n"); | |||
return retval.toString(); | |||
} | |||
/** | |||
* Adds the page break at the specified parameters | |||
* @param main Depending on sid, will determine row or column to put page break (zero-based) | |||
@@ -164,7 +142,7 @@ public abstract class PageBreakRecord extends StandardRecord { | |||
*/ | |||
public void addBreak(int main, int subFrom, int subTo) { | |||
Integer key = Integer.valueOf(main); | |||
Integer key = main; | |||
Break region = _breakMap.get(key); | |||
if(region == null) { | |||
region = new Break(main, subFrom, subTo); | |||
@@ -182,7 +160,7 @@ public abstract class PageBreakRecord extends StandardRecord { | |||
* @param main (zero-based) | |||
*/ | |||
public final void removeBreak(int main) { | |||
Integer rowKey = Integer.valueOf(main); | |||
Integer rowKey = main; | |||
Break region = _breakMap.get(rowKey); | |||
_breaks.remove(region); | |||
_breakMap.remove(rowKey); | |||
@@ -194,7 +172,7 @@ public abstract class PageBreakRecord extends StandardRecord { | |||
* @return The Break or null if no break exists at the row/col specified. | |||
*/ | |||
public final Break getBreak(int main) { | |||
Integer rowKey = Integer.valueOf(main); | |||
Integer rowKey = main; | |||
return _breakMap.get(rowKey); | |||
} | |||
@@ -213,4 +191,12 @@ public abstract class PageBreakRecord extends StandardRecord { | |||
@Override | |||
public abstract PageBreakRecord copy(); | |||
@Override | |||
public Map<String, Supplier<?>> getGenericProperties() { | |||
return GenericRecordUtil.getGenericProperties( | |||
"numBreaks", this::getNumBreaks, | |||
"breaks", () -> _breaks | |||
); | |||
} | |||
} |