<!-- 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>
<!-- 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>
* @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;
* 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)
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")
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
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;
/**
* @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;
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();
}
}
* @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;
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();
}
}
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
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;
/**
* @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() {
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();
}
}
limitations under the License.
==================================================================== */
-
package org.apache.poi.hssf.record.formula;
import org.apache.poi.util.LittleEndian;
* @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 */
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
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;
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();
}
}
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
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;
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();
}
}
* @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;
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
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
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;
+ }
+ }
}
-