From 8eb4ea33e656d9481bed687962356f801e0259fe Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Mon, 21 Jul 2008 09:34:08 +0000 Subject: [PATCH] New class org.apache.poi.hssf.record.RecordFormatException, which DDF uses instead of the HSSF version, and the HSSF version inherits from git-svn-id: https://svn.apache.org/repos/asf/poi/branches/ooxml@678374 13f79535-47bb-0310-9956-ffa450edef68 --- src/documentation/content/xdocs/changes.xml | 1 + .../content/xdocs/spreadsheet/converting.xml | 11 +++++ src/documentation/content/xdocs/status.xml | 1 + .../poi/ddf/DefaultEscherRecordFactory.java | 2 +- .../apache/poi/ddf/EscherBlipWMFRecord.java | 2 +- .../org/apache/poi/ddf/EscherDggRecord.java | 2 +- .../org/apache/poi/ddf/EscherSpgrRecord.java | 2 +- .../poi/ddf/EscherSplitMenuColorsRecord.java | 2 +- .../apache/poi/ddf/EscherTextboxRecord.java | 2 +- .../hssf/record/RecordFormatException.java | 2 +- .../poi/util/RecordFormatException.java | 42 +++++++++++++++++++ 11 files changed, 62 insertions(+), 7 deletions(-) create mode 100644 src/java/org/apache/poi/util/RecordFormatException.java diff --git a/src/documentation/content/xdocs/changes.xml b/src/documentation/content/xdocs/changes.xml index b98efd167c..43d6bb7b16 100644 --- a/src/documentation/content/xdocs/changes.xml +++ b/src/documentation/content/xdocs/changes.xml @@ -37,6 +37,7 @@ + New class org.apache.poi.hssf.record.RecordFormatException, which DDF uses instead of the HSSF version, and the HSSF version inherits from 45431 - Partial support for .xlm files. Not quite enough for excel to load them though 45430 - Correct named range sheet reporting when no local sheet id is given in the xml diff --git a/src/documentation/content/xdocs/spreadsheet/converting.xml b/src/documentation/content/xdocs/spreadsheet/converting.xml index b9fcdcd0d6..8d0e966e35 100644 --- a/src/documentation/content/xdocs/spreadsheet/converting.xml +++ b/src/documentation/content/xdocs/spreadsheet/converting.xml @@ -48,6 +48,17 @@ org.apache.poi.ss.usermodel.Row.MissingCellPolicy

+
DDF and org.apache.poi.hssf.record.RecordFormatException +

Previously, record level errors within DDF would throw an + exception from the hssf class heirachy. Now, record level errors + within DDF will throw a more general RecordFormatException, + org.apache.poi.util.RecordFormatException

+

In addition, org.apache.poi.hssf.record.RecordFormatException + has been changed to inherit from the new + org.apache.poi.util.RecordFormatException, so you may + wish to change catches of the hssf version to the new util version. +

+
Converting existing HSSF Usermodel code to SS Usermodel (for XSSF and HSSF) diff --git a/src/documentation/content/xdocs/status.xml b/src/documentation/content/xdocs/status.xml index c4e6cc5189..f1f81d0699 100644 --- a/src/documentation/content/xdocs/status.xml +++ b/src/documentation/content/xdocs/status.xml @@ -34,6 +34,7 @@ + New class org.apache.poi.hssf.record.RecordFormatException, which DDF uses instead of the HSSF version, and the HSSF version inherits from 45431 - Partial support for .xlm files. Not quite enough for excel to load them though 45430 - Correct named range sheet reporting when no local sheet id is given in the xml diff --git a/src/java/org/apache/poi/ddf/DefaultEscherRecordFactory.java b/src/java/org/apache/poi/ddf/DefaultEscherRecordFactory.java index 4ca1bfebc9..f1d051d7be 100644 --- a/src/java/org/apache/poi/ddf/DefaultEscherRecordFactory.java +++ b/src/java/org/apache/poi/ddf/DefaultEscherRecordFactory.java @@ -18,7 +18,7 @@ package org.apache.poi.ddf; -import org.apache.poi.hssf.record.RecordFormatException; +import org.apache.poi.util.RecordFormatException; import java.lang.reflect.Constructor; import java.util.HashMap; diff --git a/src/java/org/apache/poi/ddf/EscherBlipWMFRecord.java b/src/java/org/apache/poi/ddf/EscherBlipWMFRecord.java index 54217e1bb1..c307d2b0d5 100644 --- a/src/java/org/apache/poi/ddf/EscherBlipWMFRecord.java +++ b/src/java/org/apache/poi/ddf/EscherBlipWMFRecord.java @@ -18,9 +18,9 @@ package org.apache.poi.ddf; -import org.apache.poi.hssf.record.RecordFormatException; import org.apache.poi.util.HexDump; import org.apache.poi.util.LittleEndian; +import org.apache.poi.util.RecordFormatException; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; diff --git a/src/java/org/apache/poi/ddf/EscherDggRecord.java b/src/java/org/apache/poi/ddf/EscherDggRecord.java index cdc9281a8e..cc0d3aef8e 100644 --- a/src/java/org/apache/poi/ddf/EscherDggRecord.java +++ b/src/java/org/apache/poi/ddf/EscherDggRecord.java @@ -18,9 +18,9 @@ package org.apache.poi.ddf; -import org.apache.poi.hssf.record.RecordFormatException; import org.apache.poi.util.HexDump; import org.apache.poi.util.LittleEndian; +import org.apache.poi.util.RecordFormatException; import java.util.*; diff --git a/src/java/org/apache/poi/ddf/EscherSpgrRecord.java b/src/java/org/apache/poi/ddf/EscherSpgrRecord.java index 526f03eab5..4ff8eb4e7c 100644 --- a/src/java/org/apache/poi/ddf/EscherSpgrRecord.java +++ b/src/java/org/apache/poi/ddf/EscherSpgrRecord.java @@ -20,7 +20,7 @@ package org.apache.poi.ddf; import org.apache.poi.util.HexDump; import org.apache.poi.util.LittleEndian; -import org.apache.poi.hssf.record.RecordFormatException; +import org.apache.poi.util.RecordFormatException; /** * The spgr record defines information about a shape group. Groups in escher diff --git a/src/java/org/apache/poi/ddf/EscherSplitMenuColorsRecord.java b/src/java/org/apache/poi/ddf/EscherSplitMenuColorsRecord.java index 65a8427f62..5fc0f36035 100644 --- a/src/java/org/apache/poi/ddf/EscherSplitMenuColorsRecord.java +++ b/src/java/org/apache/poi/ddf/EscherSplitMenuColorsRecord.java @@ -20,7 +20,7 @@ package org.apache.poi.ddf; import org.apache.poi.util.HexDump; import org.apache.poi.util.LittleEndian; -import org.apache.poi.hssf.record.RecordFormatException; +import org.apache.poi.util.RecordFormatException; /** * A list of the most recently used colours for the drawings contained in diff --git a/src/java/org/apache/poi/ddf/EscherTextboxRecord.java b/src/java/org/apache/poi/ddf/EscherTextboxRecord.java index f6fa597b3b..1a14dbb065 100644 --- a/src/java/org/apache/poi/ddf/EscherTextboxRecord.java +++ b/src/java/org/apache/poi/ddf/EscherTextboxRecord.java @@ -18,9 +18,9 @@ package org.apache.poi.ddf; -import org.apache.poi.hssf.record.RecordFormatException; import org.apache.poi.util.HexDump; import org.apache.poi.util.LittleEndian; +import org.apache.poi.util.RecordFormatException; /** * Holds data from the parent application. Most commonly used to store diff --git a/src/java/org/apache/poi/hssf/record/RecordFormatException.java b/src/java/org/apache/poi/hssf/record/RecordFormatException.java index b5da31c141..b1afd6f9bd 100644 --- a/src/java/org/apache/poi/hssf/record/RecordFormatException.java +++ b/src/java/org/apache/poi/hssf/record/RecordFormatException.java @@ -25,7 +25,7 @@ package org.apache.poi.hssf.record; */ public class RecordFormatException - extends RuntimeException + extends org.apache.poi.util.RecordFormatException { public RecordFormatException(String exception) { diff --git a/src/java/org/apache/poi/util/RecordFormatException.java b/src/java/org/apache/poi/util/RecordFormatException.java new file mode 100644 index 0000000000..d1643b8be0 --- /dev/null +++ b/src/java/org/apache/poi/util/RecordFormatException.java @@ -0,0 +1,42 @@ + +/* ==================================================================== + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +==================================================================== */ + + +package org.apache.poi.util; + +/** + * A common exception thrown by our binary format parsers + * (especially HSSF and DDF), when they hit invalid + * format or data when processing a record. + */ +public class RecordFormatException + extends RuntimeException +{ + public RecordFormatException(String exception) + { + super(exception); + } + + public RecordFormatException(String exception, Throwable thr) { + super(exception, thr); + } + + public RecordFormatException(Throwable thr) { + super(thr); + } +}