diff --git a/src/java/org/apache/poi/hssf/record/formula/Area2DPtgBase.java b/src/java/org/apache/poi/hssf/record/formula/Area2DPtgBase.java index 7802fcd13f..57f2c919db 100644 --- a/src/java/org/apache/poi/hssf/record/formula/Area2DPtgBase.java +++ b/src/java/org/apache/poi/hssf/record/formula/Area2DPtgBase.java @@ -17,6 +17,7 @@ package org.apache.poi.hssf.record.formula; +import org.apache.poi.ss.util.AreaReference; import org.apache.poi.util.LittleEndianInput; import org.apache.poi.util.LittleEndianOutput; @@ -29,6 +30,9 @@ public abstract class Area2DPtgBase extends AreaPtgBase { protected Area2DPtgBase(int firstRow, int lastRow, int firstColumn, int lastColumn, boolean firstRowRelative, boolean lastRowRelative, boolean firstColRelative, boolean lastColRelative) { super(firstRow, lastRow, firstColumn, lastColumn, firstRowRelative, lastRowRelative, firstColRelative, lastColRelative); } + protected Area2DPtgBase(AreaReference ar) { + super(ar); + } protected Area2DPtgBase(LittleEndianInput in) { readCoordinates(in); @@ -41,10 +45,6 @@ public abstract class Area2DPtgBase extends AreaPtgBase { writeCoordinates(out); } - public Area2DPtgBase(String arearef) { - super(arearef); - } - public final int getSize() { return SIZE; } diff --git a/src/java/org/apache/poi/hssf/record/formula/Area3DPtg.java b/src/java/org/apache/poi/hssf/record/formula/Area3DPtg.java index 675ee45551..26aa154e75 100644 --- a/src/java/org/apache/poi/hssf/record/formula/Area3DPtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/Area3DPtg.java @@ -17,6 +17,7 @@ package org.apache.poi.hssf.record.formula; +import org.apache.poi.hssf.util.AreaReference; import org.apache.poi.ss.formula.ExternSheetReferenceToken; import org.apache.poi.ss.formula.FormulaRenderingWorkbook; import org.apache.poi.ss.formula.WorkbookDependentFormula; @@ -30,7 +31,6 @@ import org.apache.poi.util.LittleEndianOutput; * @author Libin Roman (Vista Portal LDT. Developer) * @author avik * @author Jason Height (jheight at chariot dot net dot au) - * @version 1.0-pre */ public final class Area3DPtg extends AreaPtgBase implements WorkbookDependentFormula, ExternSheetReferenceToken { public final static byte sid = 0x3b; @@ -39,9 +39,9 @@ public final class Area3DPtg extends AreaPtgBase implements WorkbookDependentFor private int field_1_index_extern_sheet; - public Area3DPtg( String arearef, int externIdx ) { - super(arearef); - setExternSheetIndex( externIdx ); + public Area3DPtg(String arearef, int externIdx) { + super(new AreaReference(arearef)); + setExternSheetIndex(externIdx); } public Area3DPtg(LittleEndianInput in) { @@ -56,6 +56,11 @@ public final class Area3DPtg extends AreaPtgBase implements WorkbookDependentFor setExternSheetIndex(externalSheetIndex); } + public Area3DPtg(AreaReference arearef, int externIdx) { + super(arearef); + setExternSheetIndex(externIdx); + } + public String toString() { StringBuffer sb = new StringBuffer(); sb.append(getClass().getName()); diff --git a/src/java/org/apache/poi/hssf/record/formula/AreaPtg.java b/src/java/org/apache/poi/hssf/record/formula/AreaPtg.java index 1da9b784c8..2dd3129977 100755 --- a/src/java/org/apache/poi/hssf/record/formula/AreaPtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/AreaPtg.java @@ -17,6 +17,7 @@ package org.apache.poi.hssf.record.formula; +import org.apache.poi.ss.util.AreaReference; import org.apache.poi.util.LittleEndianInput; /** @@ -33,7 +34,10 @@ public final class AreaPtg extends Area2DPtgBase { super(in); } public AreaPtg(String arearef) { - super(arearef); + super(new AreaReference(arearef)); + } + public AreaPtg(AreaReference areaRef) { + super(areaRef); } protected byte getSid() { return sid; diff --git a/src/java/org/apache/poi/hssf/record/formula/AreaPtgBase.java b/src/java/org/apache/poi/hssf/record/formula/AreaPtgBase.java index ded679ada4..0c1e3e6131 100644 --- a/src/java/org/apache/poi/hssf/record/formula/AreaPtgBase.java +++ b/src/java/org/apache/poi/hssf/record/formula/AreaPtgBase.java @@ -55,8 +55,7 @@ public abstract class AreaPtgBase extends OperandPtg implements AreaI { // do nothing } - protected AreaPtgBase(String arearef) { - AreaReference ar = new AreaReference(arearef); + protected AreaPtgBase(AreaReference ar) { CellReference firstCell = ar.getFirstCell(); CellReference lastCell = ar.getLastCell(); setFirstRow(firstCell.getRow()); diff --git a/src/java/org/apache/poi/hssf/record/formula/Ref2DPtgBase.java b/src/java/org/apache/poi/hssf/record/formula/Ref2DPtgBase.java index 3e52bc2081..6e8dd895a9 100644 --- a/src/java/org/apache/poi/hssf/record/formula/Ref2DPtgBase.java +++ b/src/java/org/apache/poi/hssf/record/formula/Ref2DPtgBase.java @@ -17,6 +17,7 @@ package org.apache.poi.hssf.record.formula; +import org.apache.poi.ss.util.CellReference; import org.apache.poi.util.LittleEndianInput; import org.apache.poi.util.LittleEndianOutput; @@ -26,13 +27,6 @@ import org.apache.poi.util.LittleEndianOutput; abstract class Ref2DPtgBase extends RefPtgBase { private final static int SIZE = 5; - /** - * Takes in a String representation of a cell reference and fills out the - * numeric fields. - */ - protected Ref2DPtgBase(String cellref) { - super(cellref); - } protected Ref2DPtgBase(int row, int column, boolean isRowRelative, boolean isColumnRelative) { setRow(row); @@ -45,6 +39,10 @@ abstract class Ref2DPtgBase extends RefPtgBase { readCoordinates(in); } + protected Ref2DPtgBase(CellReference cr) { + super(cr); + } + public void write(LittleEndianOutput out) { out.writeByte(getSid() + getPtgClass()); writeCoordinates(out); diff --git a/src/java/org/apache/poi/hssf/record/formula/Ref3DPtg.java b/src/java/org/apache/poi/hssf/record/formula/Ref3DPtg.java index acb96e4e4f..c695932a1c 100644 --- a/src/java/org/apache/poi/hssf/record/formula/Ref3DPtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/Ref3DPtg.java @@ -30,7 +30,6 @@ import org.apache.poi.util.LittleEndianOutput; * REFERENCE:

* @author Libin Roman (Vista Portal LDT. Developer) * @author Jason Height (jheight at chariot dot net dot au) - * @version 1.0-pre */ public final class Ref3DPtg extends RefPtgBase implements WorkbookDependentFormula, ExternSheetReferenceToken { public final static byte sid = 0x3a; @@ -38,8 +37,6 @@ public final class Ref3DPtg extends RefPtgBase implements WorkbookDependentFormu private final static int SIZE = 7; // 6 + 1 for Ptg private int field_1_index_extern_sheet; - /** Creates new AreaPtg */ - public Ref3DPtg() {} public Ref3DPtg(LittleEndianInput in) { field_1_index_extern_sheet = in.readShort(); @@ -47,11 +44,11 @@ public final class Ref3DPtg extends RefPtgBase implements WorkbookDependentFormu } public Ref3DPtg(String cellref, int externIdx ) { - CellReference c= new CellReference(cellref); - setRow(c.getRow()); - setColumn(c.getCol()); - setColRelative(!c.isColAbsolute()); - setRowRelative(!c.isRowAbsolute()); + this(new CellReference(cellref), externIdx); + } + + public Ref3DPtg(CellReference c, int externIdx) { + super(c); setExternSheetIndex(externIdx); } @@ -66,8 +63,8 @@ public final class Ref3DPtg extends RefPtgBase implements WorkbookDependentFormu return sb.toString(); } - public void write(LittleEndianOutput out) { - out.writeByte(sid + getPtgClass()); + public void write(LittleEndianOutput out) { + out.writeByte(sid + getPtgClass()); out.writeShort(getExternSheetIndex()); writeCoordinates(out); } diff --git a/src/java/org/apache/poi/hssf/record/formula/RefPtg.java b/src/java/org/apache/poi/hssf/record/formula/RefPtg.java index 69508fd7d2..859d0ff0a0 100644 --- a/src/java/org/apache/poi/hssf/record/formula/RefPtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/RefPtg.java @@ -17,6 +17,7 @@ package org.apache.poi.hssf.record.formula; +import org.apache.poi.ss.util.CellReference; import org.apache.poi.util.LittleEndianInput; /** @@ -32,7 +33,7 @@ public final class RefPtg extends Ref2DPtgBase { * numeric fields. */ public RefPtg(String cellref) { - super(cellref); + super(new CellReference(cellref)); } public RefPtg(int row, int column, boolean isRowRelative, boolean isColumnRelative) { @@ -43,6 +44,10 @@ public final class RefPtg extends Ref2DPtgBase { super(in); } + public RefPtg(CellReference cr) { + super(cr); + } + protected byte getSid() { return sid; } diff --git a/src/java/org/apache/poi/hssf/record/formula/RefPtgBase.java b/src/java/org/apache/poi/hssf/record/formula/RefPtgBase.java index 8357e158c5..33e1315157 100644 --- a/src/java/org/apache/poi/hssf/record/formula/RefPtgBase.java +++ b/src/java/org/apache/poi/hssf/record/formula/RefPtgBase.java @@ -17,7 +17,7 @@ package org.apache.poi.hssf.record.formula; -import org.apache.poi.hssf.util.CellReference; +import org.apache.poi.ss.util.CellReference; import org.apache.poi.util.BitField; import org.apache.poi.util.BitFieldFactory; import org.apache.poi.util.LittleEndianInput; @@ -48,26 +48,14 @@ public abstract class RefPtgBase extends OperandPtg { // Required for clone methods } - /** - * Takes in a String representation of a cell reference and fills out the - * numeric fields. - */ - protected RefPtgBase(String cellref) { - CellReference c = new CellReference(cellref); + protected RefPtgBase(CellReference c) { setRow(c.getRow()); setColumn(c.getCol()); setColRelative(!c.isColAbsolute()); setRowRelative(!c.isRowAbsolute()); } - protected RefPtgBase(int row, int column, boolean isRowRelative, boolean isColumnRelative) { - setRow(row); - setColumn(column); - setRowRelative(isRowRelative); - setColRelative(isColumnRelative); - } - - protected final void readCoordinates(LittleEndianInput in) { + protected final void readCoordinates(LittleEndianInput in) { field_1_row = in.readUShort(); field_2_col = in.readUShort(); }