From 528bda2729a3e7f8517afb143a509d79e8827152 Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Thu, 21 Feb 2008 10:36:08 +0000 Subject: [PATCH] Fix from Josh from bug #44456 - Update contrib SViewer to not fail if a HSSFRow is null git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@629738 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/org/apache/poi/hssf/contrib/view/SVRowHeader.java | 8 +++++++- .../src/org/apache/poi/hssf/contrib/view/SViewer.java | 4 ++++ .../org/apache/poi/hssf/contrib/view/SViewerPanel.java | 3 +++ src/documentation/content/xdocs/changes.xml | 1 + src/documentation/content/xdocs/status.xml | 1 + 5 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/contrib/src/org/apache/poi/hssf/contrib/view/SVRowHeader.java b/src/contrib/src/org/apache/poi/hssf/contrib/view/SVRowHeader.java index f53d9cd89..fa76b1e43 100644 --- a/src/contrib/src/org/apache/poi/hssf/contrib/view/SVRowHeader.java +++ b/src/contrib/src/org/apache/poi/hssf/contrib/view/SVRowHeader.java @@ -73,7 +73,13 @@ public class SVRowHeader extends JList { public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { Dimension d = getPreferredSize(); - int rowHeight = (int)sheet.getRow(index).getHeightInPoints(); + HSSFRow row = sheet.getRow(index); + int rowHeight; + if(row == null) { + rowHeight = (int)sheet.getDefaultRowHeightInPoints(); + } else { + rowHeight = (int)row.getHeightInPoints(); + } d.height = rowHeight+extraHeight; setPreferredSize(d); setText((value == null) ? "" : value.toString()); diff --git a/src/contrib/src/org/apache/poi/hssf/contrib/view/SViewer.java b/src/contrib/src/org/apache/poi/hssf/contrib/view/SViewer.java index 7d451d7c7..a3756ce65 100644 --- a/src/contrib/src/org/apache/poi/hssf/contrib/view/SViewer.java +++ b/src/contrib/src/org/apache/poi/hssf/contrib/view/SViewer.java @@ -143,6 +143,10 @@ public class SViewer extends JApplet { /**Main method*/ public static void main(String[] args) { + if(args.length < 1) { + throw new IllegalArgumentException("A filename to view must be supplied as the first argument, but none was given"); + } + SViewer applet = new SViewer(); applet.isStandalone = true; applet.filename = args[0]; diff --git a/src/contrib/src/org/apache/poi/hssf/contrib/view/SViewerPanel.java b/src/contrib/src/org/apache/poi/hssf/contrib/view/SViewerPanel.java index 3cd2c1c06..c400d4fe4 100644 --- a/src/contrib/src/org/apache/poi/hssf/contrib/view/SViewerPanel.java +++ b/src/contrib/src/org/apache/poi/hssf/contrib/view/SViewerPanel.java @@ -260,6 +260,9 @@ public class SViewerPanel extends JPanel { /**Main method*/ public static void main(String[] args) { + if(args.length < 1) { + throw new IllegalArgumentException("A filename to view must be supplied as the first argument, but none was given"); + } try { FileInputStream in = new FileInputStream(args[0]); HSSFWorkbook wb = new HSSFWorkbook(in); diff --git a/src/documentation/content/xdocs/changes.xml b/src/documentation/content/xdocs/changes.xml index 98c525405..46fdb22ac 100644 --- a/src/documentation/content/xdocs/changes.xml +++ b/src/documentation/content/xdocs/changes.xml @@ -36,6 +36,7 @@ + 44456 - Fix the contrib SViewer / SViewerPanel to not fail on sheets with missing rows 44403 - Further support for unusual, but valid, arguments to the Mid function 44410 - Support for whole-column ranges, such as C:C, in formula strings and the formula evaluator 44421 - Update Match function to properly support Area references diff --git a/src/documentation/content/xdocs/status.xml b/src/documentation/content/xdocs/status.xml index 82c206929..fec81a1e1 100644 --- a/src/documentation/content/xdocs/status.xml +++ b/src/documentation/content/xdocs/status.xml @@ -33,6 +33,7 @@ + 44456 - Fix the contrib SViewer / SViewerPanel to not fail on sheets with missing rows 44403 - Further support for unusual, but valid, arguments to the Mid function 44410 - Support for whole-column ranges, such as C:C, in formula strings and the formula evaluator 44421 - Update Match function to properly support Area references