From 03528d6293189bb35dcc62b687451bcb7b402912 Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Mon, 3 Mar 2008 16:09:02 +0000 Subject: [PATCH] Patch from Josh from bug #44510 - Fix how DVALRecord works with dropdowns git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@633151 13f79535-47bb-0310-9956-ffa450edef68 --- src/documentation/content/xdocs/changes.xml | 1 + src/documentation/content/xdocs/status.xml | 3 + .../apache/poi/hssf/record/DVALRecord.java | 16 +++--- .../poi/hssf/record/TestDVALRecord.java | 55 +++++++++++++++++++ 4 files changed, 66 insertions(+), 9 deletions(-) create mode 100755 src/testcases/org/apache/poi/hssf/record/TestDVALRecord.java diff --git a/src/documentation/content/xdocs/changes.xml b/src/documentation/content/xdocs/changes.xml index d85e3a3a71..23143a1bde 100644 --- a/src/documentation/content/xdocs/changes.xml +++ b/src/documentation/content/xdocs/changes.xml @@ -36,6 +36,7 @@ + 44510 - Fix how DVALRecord works with dropdowns 44495 - Handle named cell ranges in formulas that have lower case parts 44491 - Don't have the new-style "HPSF properties are always available" affect the old-style use of HPSF alongside HSSF 44471 - Crystal Reports generates files with short StyleRecords, which isn't allowed in the spec. Work around this diff --git a/src/documentation/content/xdocs/status.xml b/src/documentation/content/xdocs/status.xml index 4b836f6a96..ae32a1cc7a 100644 --- a/src/documentation/content/xdocs/status.xml +++ b/src/documentation/content/xdocs/status.xml @@ -33,6 +33,9 @@ + 44495 - Handle named cell ranges in formulas that have lower case parts + 44491 - Don't have the new-style "HPSF properties are always available" affect the old-style use of HPSF alongside HSSF + 44471 - Crystal Reports generates files with short StyleRecords, which isn't allowed in the spec. Work around this 44495 - Handle named cell ranges in formulas that have lower case parts 44491 - Don't have the new-style "HPSF properties are always available" affect the old-style use of HPSF alongside HSSF 44471 - Crystal Reports generates files with short StyleRecords, which isn't allowed in the spec. Work around this diff --git a/src/java/org/apache/poi/hssf/record/DVALRecord.java b/src/java/org/apache/poi/hssf/record/DVALRecord.java index 2846f5066c..011c0a4355 100644 --- a/src/java/org/apache/poi/hssf/record/DVALRecord.java +++ b/src/java/org/apache/poi/hssf/record/DVALRecord.java @@ -1,4 +1,3 @@ - /* ==================================================================== Copyright 2002-2004 Apache Software Foundation @@ -20,13 +19,11 @@ package org.apache.poi.hssf.record; import org.apache.poi.util.LittleEndian; /** - * Title: DVAL Record

+ * Title: DATAVALIDATIONS Record

* Description: used in data validation ; - * This record is the list header of all data validation records in the current sheet. + * This record is the list header of all data validation records (0x01BE) in the current sheet. * @author Dragos Buleandra (dragos.buleandra@trade2b.ro) - * @version 2.0-pre */ - public class DVALRecord extends Record { public final static short sid = 0x01B2; @@ -41,13 +38,14 @@ public class DVALRecord extends Record /** Object ID of the drop down arrow object for list boxes ; * in our case this will be always FFFF , until * MSODrawingGroup and MSODrawing records are implemented */ - private int field_cbo_id = 0xFFFFFFFF; + private int field_cbo_id; /** Number of following DV Records */ - private int field_5_dv_no = 0x00000000; + private int field_5_dv_no; - public DVALRecord() - { + public DVALRecord() { + field_cbo_id = 0xFFFFFFFF; + field_5_dv_no = 0x00000000; } /** diff --git a/src/testcases/org/apache/poi/hssf/record/TestDVALRecord.java b/src/testcases/org/apache/poi/hssf/record/TestDVALRecord.java new file mode 100755 index 0000000000..bcfb76645d --- /dev/null +++ b/src/testcases/org/apache/poi/hssf/record/TestDVALRecord.java @@ -0,0 +1,55 @@ +/* ==================================================================== + 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.hssf.record; + +import java.io.ByteArrayInputStream; + +import org.apache.poi.util.LittleEndian; + +import junit.framework.TestCase; + +/** + * + * @author Josh Micich + */ +public final class TestDVALRecord extends TestCase { + public void testRead() { + + byte[] data = new byte[22]; + LittleEndian.putShort(data, 0, DVALRecord.sid); + LittleEndian.putShort(data, 2, (short)18); + LittleEndian.putShort(data, 4, (short)55); + LittleEndian.putInt(data, 6, 56); + LittleEndian.putInt(data, 10, 57); + LittleEndian.putInt(data, 14, 58); + LittleEndian.putInt(data, 18, 59); + + RecordInputStream in = new RecordInputStream(new ByteArrayInputStream(data)); + in.nextRecord(); + DVALRecord dv = new DVALRecord(in); + + assertEquals(55, dv.getOptions()); + assertEquals(56, dv.getHorizontalPos()); + assertEquals(57, dv.getVerticalPos()); + assertEquals(58, dv.getObjectID()); + if(dv.getDVRecNo() == 0) { + fail("Identified bug 44510"); + } + assertEquals(59, dv.getDVRecNo()); + } +} -- 2.39.5