Bug 48403 - Color index is set incorrectly in PaletteRecord
Summary: Color index is set incorrectly in PaletteRecord
Status: RESOLVED WORKSFORME
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 3.5-FINAL
Hardware: PC Windows Vista
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-12-17 00:56 UTC by Minh Tran
Modified: 2015-09-29 10:15 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Minh Tran 2009-12-17 00:56:35 UTC
Color color = Color.decode("#006B6B");
HSSFPalette palette = wb.getCustomPalette();
HSSFColor hssfColor = palette.findColor((byte) color.getRed(), (byte) color.getGreen(),(byte) color.getBlue());
if (hssfColor == null)
{
   palette.setColorAtIndex((short)(PaletteRecord.STANDARD_PALETTE_SIZE -1) , (byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue());
   hssfColor = palette.getColor((short)(PaletteRecord.STANDARD_PALETTE_SIZE -1) );

....


This did not return Color that had been set to a specific index because the setColorIndex() in PaletteRecord picks wrong index. It set new color to the different index at byteIndex(the index that user wants HSSFPalette to add) - FIRST_COLOR_INDEX; (line 118 in PaletteRecord )
Comment 1 Dominik Stadler 2015-09-29 10:15:47 UTC
I could not reproduce this with the latest POI 3.13/trunk, however I am not 100% sure to have understood the problem here. 

For now there is a unit test at r1705830, please report a new bug if this is still a problem for you.