You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ni...@apache.org on 2013/06/25 16:48:16 UTC

svn commit: r1496499 - in /poi/trunk: src/java/org/apache/poi/hssf/model/ src/java/org/apache/poi/hssf/record/ src/testcases/org/apache/poi/hssf/record/ test-data/spreadsheet/

Author: nick
Date: Tue Jun 25 14:48:16 2013
New Revision: 1496499

URL: http://svn.apache.org/r1496499
Log:
Patch from Andrew Novikov from bug #53972 - Presence of PLV record shouldn't affect HSSF Data Validation

Added:
    poi/trunk/src/testcases/org/apache/poi/hssf/record/TestPLVRecord.java
    poi/trunk/test-data/spreadsheet/53972.xls   (with props)
Modified:
    poi/trunk/src/java/org/apache/poi/hssf/model/RecordOrderer.java
    poi/trunk/src/java/org/apache/poi/hssf/record/UnknownRecord.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/AllRecordTests.java

Modified: poi/trunk/src/java/org/apache/poi/hssf/model/RecordOrderer.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/model/RecordOrderer.java?rev=1496499&r1=1496498&r2=1496499&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/model/RecordOrderer.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/model/RecordOrderer.java Tue Jun 25 14:48:16 2013
@@ -344,6 +344,7 @@ final class RecordOrderer {
 		switch(sid) {
 			case UnknownRecord.SHEETEXT_0862:
 			case UnknownRecord.SHEETPROTECTION_0867:
+			case UnknownRecord.PLV_MAC:
 			case FeatRecord.sid:
 			case EOFRecord.sid:
 				return true;

Modified: poi/trunk/src/java/org/apache/poi/hssf/record/UnknownRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/UnknownRecord.java?rev=1496499&r1=1496498&r2=1496499&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/UnknownRecord.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/UnknownRecord.java Tue Jun 25 14:48:16 2013
@@ -57,7 +57,8 @@ public final class UnknownRecord extends
 	public static final int SHEETEXT_0862        = 0x0862; // OOO calls this SHEETLAYOUT
 	public static final int SHEETPROTECTION_0867 = 0x0867;
 	public static final int HEADER_FOOTER_089C   = 0x089C;
-    public static final int CODENAME_1BA         = 0x01BA;
+	public static final int CODENAME_1BA         = 0x01BA;
+	public static final int PLV_MAC              = 0x08C8;
 
 	private int _sid;
 	private byte[] _rawData;

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/AllRecordTests.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/AllRecordTests.java?rev=1496499&r1=1496498&r2=1496499&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/AllRecordTests.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/AllRecordTests.java Tue Jun 25 14:48:16 2013
@@ -77,6 +77,7 @@ public final class AllRecordTests {
 		result.addTestSuite(TestObjRecord.class);
 		result.addTestSuite(TestPaletteRecord.class);
 		result.addTestSuite(TestPaneRecord.class);
+		result.addTestSuite(TestPLVRecord.class);
 		result.addTestSuite(TestRecalcIdRecord.class);
 		result.addTestSuite(TestRecordFactory.class);
 		result.addTestSuite(TestRecordFactoryInputStream.class);

Added: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestPLVRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestPLVRecord.java?rev=1496499&view=auto
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestPLVRecord.java (added)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestPLVRecord.java Tue Jun 25 14:48:16 2013
@@ -0,0 +1,59 @@
+/* ====================================================================
+   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 junit.framework.AssertionFailedError;
+import junit.framework.TestCase;
+import org.apache.poi.hssf.HSSFTestDataSamples;
+import org.apache.poi.hssf.usermodel.DVConstraint;
+import org.apache.poi.hssf.usermodel.HSSFDataValidation;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.ss.usermodel.DataValidationConstraint;
+import org.apache.poi.ss.util.CellRangeAddressList;
+
+import java.io.InputStream;
+
+/**
+ * Verify that presence of PLV record doesn't break data
+ * validation, bug #53972:
+ * https://issues.apache.org/bugzilla/show_bug.cgi?id=53972
+ *
+ * @author Andrew Novikov
+ */
+
+public final class TestPLVRecord extends TestCase {
+    private final static String DV_DEFINITION = "$A$1:$A$5";
+    private final static String XLS_FILENAME = "53972.xls";
+    private final static String SHEET_NAME = "S2";
+
+    public void testPLVRecord() throws Exception {
+        InputStream is = HSSFTestDataSamples.openSampleFileStream(XLS_FILENAME);
+        HSSFWorkbook workbook = new HSSFWorkbook(is);
+
+        CellRangeAddressList cellRange = new CellRangeAddressList(0, 0, 1, 1);
+        DataValidationConstraint constraint = DVConstraint.createFormulaListConstraint(DV_DEFINITION);
+        HSSFDataValidation dataValidation = new HSSFDataValidation(cellRange, constraint);
+
+        // This used to throw an error before
+        try {
+            workbook.getSheet(SHEET_NAME).addValidationData(dataValidation);
+        } catch (IllegalStateException ex) {
+            throw new AssertionFailedError("Identified bug 53972, PLV record breaks addDataValidation()");
+        }
+    }
+}

Added: poi/trunk/test-data/spreadsheet/53972.xls
URL: http://svn.apache.org/viewvc/poi/trunk/test-data/spreadsheet/53972.xls?rev=1496499&view=auto
==============================================================================
Binary file - no diff available.

Propchange: poi/trunk/test-data/spreadsheet/53972.xls
------------------------------------------------------------------------------
    svn:mime-type = application/vnd.ms-excel



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org