Fix on head for custom palettes.

Resolves 16559


git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@353402 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jason Height 2003-10-14 22:50:48 +00:00
parent f7a6f8320c
commit 32b0e0b541
2 changed files with 8 additions and 5 deletions

View File

@ -2074,15 +2074,18 @@ public class Workbook implements Model {
public PaletteRecord getCustomPalette() public PaletteRecord getCustomPalette()
{ {
PaletteRecord palette; PaletteRecord palette;
Record rec = records.get(records.getPalettepos()); int palettePos = records.getPalettepos();
if (rec instanceof PaletteRecord) if (palettePos != -1) {
{ Record rec = records.get(palettePos);
if (rec instanceof PaletteRecord) {
palette = (PaletteRecord) rec; palette = (PaletteRecord) rec;
} else throw new RuntimeException("InternalError: Expected PaletteRecord but got a '"+rec+"'");
} }
else else
{ {
palette = createPalette(); palette = createPalette();
records.add(records.getPalettepos(), palette); //Add the palette record after the bof which is always the first record
records.add(1, palette);
} }
return palette; return palette;
} }

View File

@ -74,7 +74,7 @@ public class WorkbookRecordList
private int namepos = 0; // holds the position of last name record private int namepos = 0; // holds the position of last name record
private int supbookpos = 0; // holds the position of sup book private int supbookpos = 0; // holds the position of sup book
private int externsheetPos = 0;// holds the position of the extern sheet private int externsheetPos = 0;// holds the position of the extern sheet
private int palettepos = 0; // hold the position of the palette, if applicable private int palettepos = -1; // hold the position of the palette, if applicable
public void setRecords( List records ) public void setRecords( List records )