You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by jo...@apache.org on 2008/05/03 00:36:49 UTC
svn commit: r652934 - in /poi/trunk/src: documentation/content/xdocs/
java/org/apache/poi/hssf/record/ java/org/apache/poi/hssf/record/formula/
testcases/org/apache/poi/hssf/data/
testcases/org/apache/poi/hssf/record/formula/
Author: josh
Date: Fri May 2 15:36:49 2008
New Revision: 652934
URL: http://svn.apache.org/viewvc?rev=652934&view=rev
Log:
44921 - allow Ptg.writeBytes() to be called on relative ref Ptgs (RefN* and AreaN*)
Added:
poi/trunk/src/testcases/org/apache/poi/hssf/data/ex44921-21902.xls (with props)
Modified:
poi/trunk/src/documentation/content/xdocs/changes.xml
poi/trunk/src/documentation/content/xdocs/status.xml
poi/trunk/src/java/org/apache/poi/hssf/record/SharedFormulaRecord.java
poi/trunk/src/java/org/apache/poi/hssf/record/formula/AreaNAPtg.java
poi/trunk/src/java/org/apache/poi/hssf/record/formula/AreaNPtg.java
poi/trunk/src/java/org/apache/poi/hssf/record/formula/AreaNVPtg.java
poi/trunk/src/java/org/apache/poi/hssf/record/formula/AreaPtg.java
poi/trunk/src/java/org/apache/poi/hssf/record/formula/RefNAPtg.java
poi/trunk/src/java/org/apache/poi/hssf/record/formula/RefNPtg.java
poi/trunk/src/java/org/apache/poi/hssf/record/formula/ReferencePtg.java
poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/TestReferencePtg.java
Modified: poi/trunk/src/documentation/content/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/changes.xml?rev=652934&r1=652933&r2=652934&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/changes.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/changes.xml Fri May 2 15:36:49 2008
@@ -37,6 +37,7 @@
<!-- Don't forget to update status.xml too! -->
<release version="3.1-beta2" date="2008-05-??">
+ <action dev="POI-DEVELOPERS" type="fix">44921 - allow Ptg.writeBytes() to be called on relative ref Ptgs (RefN* and AreaN*)</action>
<action dev="POI-DEVELOPERS" type="fix">44914 - Fix/suppress warning message "WARN. Unread n bytes of record 0xNN"</action>
<action dev="POI-DEVELOPERS" type="fix">44892 - made HSSFWorkbook.getSheet(String) case insensitive</action>
<action dev="POI-DEVELOPERS" type="fix">44886] - Correctly process PICT metafile in EscherMetafileBlip</action>
Modified: poi/trunk/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/status.xml?rev=652934&r1=652933&r2=652934&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/status.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/status.xml Fri May 2 15:36:49 2008
@@ -34,6 +34,7 @@
<!-- Don't forget to update changes.xml too! -->
<changes>
<release version="3.1-beta2" date="2008-05-??">
+ <action dev="POI-DEVELOPERS" type="fix">44921 - allow Ptg.writeBytes() to be called on relative ref Ptgs (RefN* and AreaN*)</action>
<action dev="POI-DEVELOPERS" type="fix">44914 - Fix/suppress warning message "WARN. Unread n bytes of record 0xNN"</action>
<action dev="POI-DEVELOPERS" type="fix">44892 - made HSSFWorkbook.getSheet(String) case insensitive</action>
<action dev="POI-DEVELOPERS" type="fix">44886] - Correctly process PICT metafile in EscherMetafileBlip</action>
Modified: poi/trunk/src/java/org/apache/poi/hssf/record/SharedFormulaRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/SharedFormulaRecord.java?rev=652934&r1=652933&r2=652934&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/SharedFormulaRecord.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/SharedFormulaRecord.java Fri May 2 15:36:49 2008
@@ -33,7 +33,7 @@
* @author Danny Mui at apache dot org
*/
public final class SharedFormulaRecord extends Record {
- public final static short sid = 0x4BC;
+ public final static short sid = 0x4BC;
private int field_1_first_row;
private int field_2_last_row;
@@ -186,6 +186,16 @@
* counter part
*/
protected static Stack convertSharedFormulas(Stack ptgs, int formulaRow, int formulaColumn) {
+ if(false) {
+ /*
+ * TODO - (May-2008) Stop converting relative ref Ptgs in shared formula records.
+ * If/when POI writes out the workbook, this conversion makes an unnecessary diff in the BIFF records.
+ * Disabling this code breaks one existing junit.
+ * Some fix-up will be required to make Ptg.toFormulaString(HSSFWorkbook) work properly.
+ * That method will need 2 extra params: rowIx and colIx.
+ */
+ return ptgs;
+ }
Stack newPtgStack = new Stack();
if (ptgs != null)
@@ -265,7 +275,7 @@
throw new RuntimeException("Shared Formula Conversion: Coding Error");
}
}
-
+
private static int fixupRelativeColumn(int currentcolumn, int column, boolean relative) {
if(relative) {
// mask out upper bits to produce 'wrapping' at column 256 ("IV")
Modified: poi/trunk/src/java/org/apache/poi/hssf/record/formula/AreaNAPtg.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/formula/AreaNAPtg.java?rev=652934&r1=652933&r2=652934&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/formula/AreaNAPtg.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/formula/AreaNAPtg.java Fri May 2 15:36:49 2008
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -16,19 +15,9 @@
limitations under the License.
==================================================================== */
-/*
- * AreaPtg.java
- *
- * Created on November 17, 2001, 9:30 PM
- */
package org.apache.poi.hssf.record.formula;
-import org.apache.poi.util.LittleEndian;
-import org.apache.poi.util.BitField;
-
import org.apache.poi.hssf.record.RecordInputStream;
-import org.apache.poi.hssf.util.AreaReference;
-import org.apache.poi.hssf.util.CellReference;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
/**
@@ -36,8 +25,7 @@
* @author Jason Height (jheight at chariot dot net dot au)
*/
-public class AreaNAPtg
- extends AreaPtg
+public final class AreaNAPtg extends AreaPtg
{
public final static short sid = 0x6D;
@@ -50,20 +38,16 @@
super(in);
}
- public void writeBytes(byte [] array, int offset) {
- throw new RuntimeException("Coding Error: This method should never be called. This ptg should be converted");
- }
-
public String getAreaPtgName() {
return "AreaNAPtg";
}
public String toFormulaString(HSSFWorkbook book)
{
- throw new RuntimeException("Coding Error: This method should never be called. This ptg should be converted");
+ throw notImplemented();
}
public Object clone() {
- throw new RuntimeException("Coding Error: This method should never be called. This ptg should be converted");
+ throw notImplemented();
}
}
Modified: poi/trunk/src/java/org/apache/poi/hssf/record/formula/AreaNPtg.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/formula/AreaNPtg.java?rev=652934&r1=652933&r2=652934&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/formula/AreaNPtg.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/formula/AreaNPtg.java Fri May 2 15:36:49 2008
@@ -36,8 +36,7 @@
* @author Jason Height (jheight at chariot dot net dot au)
*/
-public class AreaNPtg
- extends AreaPtg
+public final class AreaNPtg extends AreaPtg
{
public final static short sid = 0x2D;
@@ -50,23 +49,16 @@
super(in);
}
- public void writeBytes(byte [] array, int offset) {
- super.writeBytes(array,offset);
- //this should be a warning...there doesn't seem to be any rationale to throwing an exception here...
- //this excpeiton appears to break user defined named ranges...
- //throw new RuntimeException("Coding Error: This method should never be called. This ptg should be converted");
- }
-
public String getAreaPtgName() {
return "AreaNPtg";
}
public String toFormulaString(HSSFWorkbook book)
{
- throw new RuntimeException("Coding Error: This method should never be called. This ptg should be converted");
+ throw notImplemented();
}
public Object clone() {
- throw new RuntimeException("Coding Error: This method should never be called. This ptg should be converted");
+ throw notImplemented();
}
}
Modified: poi/trunk/src/java/org/apache/poi/hssf/record/formula/AreaNVPtg.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/formula/AreaNVPtg.java?rev=652934&r1=652933&r2=652934&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/formula/AreaNVPtg.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/formula/AreaNVPtg.java Fri May 2 15:36:49 2008
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -16,19 +15,9 @@
limitations under the License.
==================================================================== */
-/*
- * AreaPtg.java
- *
- * Created on November 17, 2001, 9:30 PM
- */
package org.apache.poi.hssf.record.formula;
-import org.apache.poi.util.LittleEndian;
-import org.apache.poi.util.BitField;
-
import org.apache.poi.hssf.record.RecordInputStream;
-import org.apache.poi.hssf.util.AreaReference;
-import org.apache.poi.hssf.util.CellReference;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
/**
@@ -36,10 +25,7 @@
* @author andy
* @author Jason Height (jheight at chariot dot net dot au)
*/
-
-public class AreaNVPtg
- extends AreaPtg
-{
+public final class AreaNVPtg extends AreaPtg {
public final static short sid = 0x4D;
protected AreaNVPtg() {
@@ -51,20 +37,16 @@
super(in);
}
- public void writeBytes(byte [] array, int offset) {
- throw new RuntimeException("Coding Error: This method should never be called. This ptg should be converted");
- }
-
public String getAreaPtgName() {
return "AreaNVPtg";
}
public String toFormulaString(HSSFWorkbook book)
{
- throw new RuntimeException("Coding Error: This method should never be called. This ptg should be converted");
+ throw notImplemented();
}
public Object clone() {
- throw new RuntimeException("Coding Error: This method should never be called. This ptg should be converted");
+ throw notImplemented();
}
}
Modified: poi/trunk/src/java/org/apache/poi/hssf/record/formula/AreaPtg.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/formula/AreaPtg.java?rev=652934&r1=652933&r2=652934&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/formula/AreaPtg.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/formula/AreaPtg.java Fri May 2 15:36:49 2008
@@ -15,7 +15,6 @@
limitations under the License.
==================================================================== */
-
package org.apache.poi.hssf.record.formula;
import org.apache.poi.util.LittleEndian;
@@ -32,10 +31,15 @@
* @author andy
* @author Jason Height (jheight at chariot dot net dot au)
*/
+public class AreaPtg extends Ptg implements AreaI {
+ /**
+ * TODO - (May-2008) fix subclasses of AreaPtg 'AreaN~' which are used in shared formulas.
+ * see similar comment in ReferencePtg
+ */
+ protected final RuntimeException notImplemented() {
+ return new RuntimeException("Coding Error: This method should never be called. This ptg should be converted");
+ }
-public class AreaPtg
- extends Ptg implements AreaI
-{
public final static short sid = 0x25;
private final static int SIZE = 9;
/** zero based, unsigned 16 bit */
Modified: poi/trunk/src/java/org/apache/poi/hssf/record/formula/RefNAPtg.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/formula/RefNAPtg.java?rev=652934&r1=652933&r2=652934&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/formula/RefNAPtg.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/formula/RefNAPtg.java Fri May 2 15:36:49 2008
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -16,26 +15,16 @@
limitations under the License.
==================================================================== */
-/*
- * ValueReferencePtg.java
- *
- * Created on November 21, 2001, 5:27 PM
- */
package org.apache.poi.hssf.record.formula;
-import org.apache.poi.util.LittleEndian;
-import org.apache.poi.util.BitField;
-
import org.apache.poi.hssf.record.RecordInputStream;
-import org.apache.poi.hssf.util.CellReference;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
/**
* RefNAPtg
* @author Jason Height (jheight at chariot dot net dot au)
*/
-
-public class RefNAPtg extends ReferencePtg
+public final class RefNAPtg extends ReferencePtg
{
public final static byte sid = 0x6C;
@@ -48,21 +37,16 @@
super(in);
}
- public void writeBytes(byte [] array, int offset)
- {
- throw new RuntimeException("Coding Error: This method should never be called. This ptg should be converted");
- }
-
public String getRefPtgName() {
return "RefNAPtg";
}
public String toFormulaString(HSSFWorkbook book)
{
- throw new RuntimeException("Coding Error: This method should never be called. This ptg should be converted");
+ throw notImplemented();
}
public Object clone() {
- throw new RuntimeException("Coding Error: This method should never be called. This ptg should be converted");
+ throw notImplemented();
}
}
Modified: poi/trunk/src/java/org/apache/poi/hssf/record/formula/RefNPtg.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/formula/RefNPtg.java?rev=652934&r1=652933&r2=652934&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/formula/RefNPtg.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/formula/RefNPtg.java Fri May 2 15:36:49 2008
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -16,25 +15,16 @@
limitations under the License.
==================================================================== */
-/*
- * RefNPtg.java
- *
- */
package org.apache.poi.hssf.record.formula;
-import org.apache.poi.util.LittleEndian;
-import org.apache.poi.util.BitField;
-
import org.apache.poi.hssf.record.RecordInputStream;
-import org.apache.poi.hssf.util.CellReference;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
/**
* RefNPtg
* @author Jason Height (jheight at apache dot com)
*/
-
-public class RefNPtg extends ReferencePtg
+public final class RefNPtg extends ReferencePtg
{
public final static byte sid = 0x2C;
@@ -49,21 +39,16 @@
super(in);
}
- public void writeBytes(byte [] array, int offset)
- {
- throw new RuntimeException("Coding Error: This method should never be called. This ptg should be converted");
- }
-
public String getRefPtgName() {
return "RefNPtg";
}
public String toFormulaString(HSSFWorkbook book)
{
- throw new RuntimeException("Coding Error: This method should never be called. This ptg should be converted");
+ throw notImplemented();
}
public Object clone() {
- throw new RuntimeException("Coding Error: This method should never be called. This ptg should be converted");
+ throw notImplemented();
}
}
Modified: poi/trunk/src/java/org/apache/poi/hssf/record/formula/ReferencePtg.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/formula/ReferencePtg.java?rev=652934&r1=652933&r2=652934&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/formula/ReferencePtg.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/formula/ReferencePtg.java Fri May 2 15:36:49 2008
@@ -30,8 +30,20 @@
* @author Andrew C. Oliver (acoliver@apache.org)
* @author Jason Height (jheight at chariot dot net dot au)
*/
-
public class ReferencePtg extends Ptg {
+ /**
+ * TODO - (May-2008) fix subclasses of ReferencePtg 'RefN~' which are used in shared formulas.
+ * (See bugzilla 44921)
+ * The 'RefN~' instances do not work properly, and are expected to be converted by
+ * SharedFormulaRecord.convertSharedFormulas().
+ * This conversion currently does not take place for formulas of named ranges, conditional
+ * format rules and data validation rules.
+ * Furthermore, conversion is probably not appropriate in those instances.
+ */
+ protected final RuntimeException notImplemented() {
+ return new RuntimeException("Coding Error: This method should never be called. This ptg should be converted");
+ }
+
private final static int SIZE = 5;
public final static byte sid = 0x24;
private final static int MAX_ROW_NUMBER = 65536;
Added: poi/trunk/src/testcases/org/apache/poi/hssf/data/ex44921-21902.xls
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/data/ex44921-21902.xls?rev=652934&view=auto
==============================================================================
Binary file - no diff available.
Propchange: poi/trunk/src/testcases/org/apache/poi/hssf/data/ex44921-21902.xls
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/TestReferencePtg.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/TestReferencePtg.java?rev=652934&r1=652933&r2=652934&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/TestReferencePtg.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/TestReferencePtg.java Fri May 2 15:36:49 2008
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -18,20 +17,22 @@
package org.apache.poi.hssf.record.formula;
+import junit.framework.AssertionFailedError;
+import junit.framework.TestCase;
+
+import org.apache.poi.hssf.HSSFTestDataSamples;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
/**
* Tests for {@link ReferencePtg}.
*/
-public class TestReferencePtg extends AbstractPtgTestCase
-{
+public final class TestReferencePtg extends TestCase {
/**
* Tests reading a file containing this ptg.
*/
- public void testReading() throws Exception
- {
- HSSFWorkbook workbook = loadWorkbook("ReferencePtg.xls");
+ public void testReading() {
+ HSSFWorkbook workbook = HSSFTestDataSamples.openSampleWorkbook("ReferencePtg.xls");
HSSFSheet sheet = workbook.getSheetAt(0);
// First row
@@ -72,6 +73,18 @@
assertEquals("Wrong formula string for reference", "A32770",
sheet.getRow(32769).getCell((short) 1).getCellFormula());
}
+
+ public void testBug44921() {
+ HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("ex44921-21902.xls");
+
+ try {
+ HSSFTestDataSamples.writeOutAndReadBack(wb);
+ } catch (RuntimeException e) {
+ if(e.getMessage().equals("Coding Error: This method should never be called. This ptg should be converted")) {
+ throw new AssertionFailedError("Identified bug 44921");
+ }
+ throw e;
+ }
+ }
}
-
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org