--- src/java/org/apache/poi/hssf/dev/BiffViewer.java (revision 720765) +++ src/java/org/apache/poi/hssf/dev/BiffViewer.java (working copy) @@ -32,6 +32,7 @@ import org.apache.poi.hssf.record.*; import org.apache.poi.hssf.record.chart.*; +import org.apache.poi.hssf.record.pivottable.*; import org.apache.poi.poifs.filesystem.POIFSFileSystem; import org.apache.poi.util.HexDump; import org.apache.poi.util.LittleEndian; @@ -210,6 +211,7 @@ case StyleRecord.sid: return new StyleRecord(in); case SupBookRecord.sid: return new SupBookRecord(in); case TabIdRecord.sid: return new TabIdRecord(in); + case TableStylesRecord.sid: return new TableStylesRecord(in); case TableRecord.sid: return new TableRecord(in); case TextObjectRecord.sid: return new TextObjectRecord(in); case TextRecord.sid: return new TextRecord(in); @@ -227,6 +229,22 @@ case WriteAccessRecord.sid: return new WriteAccessRecord(in); case WriteProtectRecord.sid: return new WriteProtectRecord(in); + // chart + case CatLabRecord.sid: return new CatLabRecord(in); + case ChartEndBlockRecord.sid: return new ChartEndBlockRecord(in); + case ChartEndObjectRecord.sid: return new ChartEndObjectRecord(in); + case ChartFRTInfoRecord.sid: return new ChartFRTInfoRecord(in); + case ChartStartBlockRecord.sid: return new ChartStartBlockRecord(in); + case ChartStartObjectRecord.sid: return new ChartStartObjectRecord(in); + + // pivot table + case StreamIDRecord.sid: return new StreamIDRecord(in); + case ViewSourceRecord.sid: return new ViewSourceRecord(in); + case PageItemRecord.sid: return new PageItemRecord(in); + case ViewDefinitionRecord.sid: return new ViewDefinitionRecord(in); + case ViewFieldsRecord.sid: return new ViewFieldsRecord(in); + case DataItemRecord.sid: return new DataItemRecord(in); + case ExtendedPivotTableViewFieldsRecord.sid: return new ExtendedPivotTableViewFieldsRecord(in); } return new UnknownRecord(in); } --- src/java/org/apache/poi/hssf/record/RecordFactory.java (revision 720765) +++ src/java/org/apache/poi/hssf/record/RecordFactory.java (working copy) @@ -31,6 +31,7 @@ import java.util.Set; import org.apache.poi.hssf.record.chart.*; +import org.apache.poi.hssf.record.pivottable.*; /** * Title: Record Factory

@@ -173,6 +174,17 @@ BeginRecord.class, EndRecord.class, SeriesToChartGroupRecord.class, + + TableStylesRecord.class, + + StreamIDRecord.class, + ViewSourceRecord.class, + PageItemRecord.class, + + ViewDefinitionRecord.class, + ViewFieldsRecord.class, + DataItemRecord.class, + ExtendedPivotTableViewFieldsRecord.class, }; /** --- src/java/org/apache/poi/hssf/record/UnknownRecord.java (revision 720765) +++ src/java/org/apache/poi/hssf/record/UnknownRecord.java (working copy) @@ -122,21 +122,19 @@ // this method any time a new Record subclass is created. switch (sid) { case PLS_004D: return "PLS"; - case 0x0050: return "DCON"; + case 0x0050: return "DCON"; // Data Consolidation Information case 0x007F: return "IMDATA"; case SHEETPR_0081: return "SHEETPR"; - case 0x0090: return "SORT"; - case 0x0094: return "LHRECORD"; - case STANDARDWIDTH_0099: return "STANDARDWIDTH"; - case 0x009D: return "AUTOFILTERINFO"; - case SCL_00A0: return "SCL"; - case 0x00AE: return "SCENMAN"; - case SXVIEW_00B0: return "SXVIEW"; // (pivot table) View Definition - case 0x00B1: return "SXVD"; // (pivot table) View Fields + case 0x0090: return "SORT"; // Sorting Options + case 0x0094: return "LHRECORD"; // .WK? File Conversion Information + case STANDARDWIDTH_0099: return "STANDARDWIDTH"; //Standard Column Width + case 0x009D: return "AUTOFILTERINFO"; // Drop-Down Arrow Count + case SCL_00A0: return "SCL"; // Window Zoom Magnification + case 0x00AE: return "SCENMAN"; // Scenario Output Data + case 0x00B2: return "SXVI"; // (pivot table) View Item case 0x00B4: return "SXIVD"; // (pivot table) Row/Column Field IDs case 0x00B5: return "SXLI"; // (pivot table) Line Item Array - case 0x00C5: return "SXDI"; // (pivot table) Data Item case 0x00D3: return "OBPROJ"; case 0x00DC: return "PARAMQRY"; @@ -144,7 +142,6 @@ case BITMAP_00E9: return "BITMAP"; case PHONETICPR_00EF: return "PHONETICPR"; case 0x00F1: return "SXEX"; // PivotTable View Extended Information - case 0x0100: return "SXVDEX"; // Extended PivotTable View Fields case LABELRANGES_015F: return "LABELRANGES"; case 0x01BA: return "CODENAME"; @@ -178,7 +175,6 @@ case 0x088B: return "PLV"; case 0x088C: return "COMPAT12"; case 0x088D: return "DXF"; - case 0x088E: return "TABLESTYLES"; case 0x0892: return "STYLEEXT"; case 0x0896: return "THEME"; case 0x0897: return "GUIDTYPELIB"; --- src/java/org/apache/poi/util/StringUtil.java (revision 720765) +++ src/java/org/apache/poi/util/StringUtil.java (working copy) @@ -141,6 +141,21 @@ return readUnicodeLE(in, nChars); } /** + * InputStream in is expected to contain: + *

    + *
  1. byte is16BitFlag
  2. + *
  3. byte[]/char[] characterData
  4. + *
+ * For this encoding, the is16BitFlag is always present even if nChars==0. + */ + public static String readUnicodeStringWithSize(LittleEndianInput in, int requestedSize) { + byte flag = in.readByte(); + if ((flag & 0x01) == 0) { + return readCompressedUnicode(in, requestedSize); + } + return readUnicodeLE(in, requestedSize); + } + /** * OutputStream out will get: *
    *
  1. ushort nChars
  2. @@ -161,8 +176,25 @@ putCompressedUnicode(value, out); } } - /** + * OutputStream out will get: + *
      + *
    1. byte is16BitFlag
    2. + *
    3. byte[]/char[] characterData
    4. + *
    + * For this encoding, the is16BitFlag is always present even if nChars==0. + */ + public static void writeUnicodeStringOnly(LittleEndianOutput out, String value) { + boolean is16Bit = hasMultibyte(value); + out.writeByte(is16Bit ? 0x01 : 0x00); + if (is16Bit) { + putUnicodeLE(value, out); + } else { + putCompressedUnicode(value, out); + } + } + + /** * @return the number of bytes that would be written by {@link #writeUnicodeString(LittleEndianOutput, String)} */ public static int getEncodedSize(String value) {