Commit cf897f10 authored by Stéphane  DALLONGEVILLE's avatar Stéphane DALLONGEVILLE
Browse files

Fixed NPE errors

parent 6c68cf13
......@@ -11,7 +11,7 @@
</parent>
<artifactId>workbooks</artifactId>
<version>3.4.11</version>
<version>3.4.12</version>
<packaging>jar</packaging>
......
package plugins.adufour.vars.gui.swing;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font;
......@@ -109,7 +110,7 @@ public class WorkbookEditor extends SwingVarEditor<Workbook>
private JTabbedPane tabs;
private final HashMap<Sheet, JXTable> tables = new HashMap<Sheet, JXTable>();
private final HashMap<Sheet, JXTable> headers = new HashMap<Sheet, JXTable>();
// cached workbook to avoid reference of old book being leaked by GUI
private Workbook book;
......@@ -231,7 +232,8 @@ public class WorkbookEditor extends SwingVarEditor<Workbook>
/**
* Sets whether the open button should be visible
*
* @param visible visible state
* @param visible
* visible state
*/
public void setOpenButtonVisible(boolean visible)
{
......@@ -241,7 +243,8 @@ public class WorkbookEditor extends SwingVarEditor<Workbook>
/**
* Sets whether the table editor is read-only, and therefore rejects user input
*
* @param readOnly read only state
* @param readOnly
* read only state
*/
public void setReadOnly(boolean readOnly)
{
......@@ -972,7 +975,9 @@ public class WorkbookEditor extends SwingVarEditor<Workbook>
Component component = super.getTableCellRendererComponent(theTable, value, isSelected, hasFocus,
theRow, theColumn);
component.setBackground(icySheet.getFillColor(theRow, theColumn));
Color fillColor = icySheet.getFillColor(theRow, theColumn);
if (fillColor != null)
component.setBackground(fillColor);
return component;
}
......
......@@ -222,17 +222,23 @@ public class IcySpreadSheet
if (color instanceof HSSFColor)
{
short[] rgb = ((HSSFColor) color).getTriplet();
if (rgb[0] != 0 || rgb[1] != 0 || rgb[2] != 0)
if ((rgb != null) && (rgb.length >= 3))
{
return new Color(rgb[0], rgb[1], rgb[2]);
if (rgb[0] != 0 || rgb[1] != 0 || rgb[2] != 0)
{
return new Color(rgb[0], rgb[1], rgb[2]);
}
}
}
else if (color instanceof XSSFColor)
{
byte[] rgb = ((XSSFColor) color).getRGB();
if (rgb[0] != 0 || rgb[1] != 0 || rgb[2] != 0)
if ((rgb != null) && (rgb.length >= 3))
{
return new Color(rgb[0] & 0xff, rgb[1] & 0xff, rgb[2] & 0xff);
if (rgb[0] != 0 || rgb[1] != 0 || rgb[2] != 0)
{
return new Color(rgb[0] & 0xff, rgb[1] & 0xff, rgb[2] & 0xff);
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment