]> source.dussan.org Git - poi.git/commitdiff
Changed cell and area ref Ptgs to allow creation using CellReference and AreaReference
authorJosh Micich <josh@apache.org>
Fri, 3 Apr 2009 07:41:29 +0000 (07:41 +0000)
committerJosh Micich <josh@apache.org>
Fri, 3 Apr 2009 07:41:29 +0000 (07:41 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@761553 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/poi/hssf/record/formula/Area2DPtgBase.java
src/java/org/apache/poi/hssf/record/formula/Area3DPtg.java
src/java/org/apache/poi/hssf/record/formula/AreaPtg.java
src/java/org/apache/poi/hssf/record/formula/AreaPtgBase.java
src/java/org/apache/poi/hssf/record/formula/Ref2DPtgBase.java
src/java/org/apache/poi/hssf/record/formula/Ref3DPtg.java
src/java/org/apache/poi/hssf/record/formula/RefPtg.java
src/java/org/apache/poi/hssf/record/formula/RefPtgBase.java

index 7802fcd13f5b7ac568f9c0622821ecd681f05a23..57f2c919dbb1227daf81553690ce035332d59d28 100644 (file)
@@ -17,6 +17,7 @@
 \r
 package org.apache.poi.hssf.record.formula;\r
 \r
+import org.apache.poi.ss.util.AreaReference;\r
 import org.apache.poi.util.LittleEndianInput;\r
 import org.apache.poi.util.LittleEndianOutput;\r
 \r
@@ -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) {\r
                super(firstRow, lastRow, firstColumn, lastColumn, firstRowRelative, lastRowRelative, firstColRelative, lastColRelative);\r
        }\r
+       protected Area2DPtgBase(AreaReference ar) {\r
+               super(ar);\r
+       }\r
 \r
        protected Area2DPtgBase(LittleEndianInput in)  {\r
                readCoordinates(in);\r
@@ -41,10 +45,6 @@ public abstract class Area2DPtgBase extends AreaPtgBase {
                writeCoordinates(out);\r
        }\r
 \r
-       public Area2DPtgBase(String arearef) {\r
-               super(arearef);\r
-       }\r
-\r
        public final int getSize() {\r
                return SIZE;\r
        }\r
index 675ee45551aa09d14bda860250ae396e8824b059..26aa154e7591c741719da5b53be0dd9113dfad16 100644 (file)
@@ -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());
index 1da9b784c85e4a846227722b3d08712d6615ab96..2dd3129977bfc51027fc099e816ef134ef4acc98 100755 (executable)
@@ -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;
index ded679ada42bed8d2a80e419862df427425cdc5f..0c1e3e6131bdebad4368e18113f632d9775ca6fb 100644 (file)
@@ -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());
index 3e52bc2081b4a2d0411e918b9bc65932e5db3c02..6e8dd895a93be0dae4ca43c8e8c3bca2c9cf8483 100644 (file)
@@ -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);
index acb96e4e4f7ea7aa85ca4aacba86411330276ae4..c695932a1ca18dc7155b2e8fbc0e5701dec3a49b 100644 (file)
@@ -30,7 +30,6 @@ import org.apache.poi.util.LittleEndianOutput;
  * REFERENCE:  <P>
  * @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);
     }
index 69508fd7d21b1365b098422ccd3d3260d01ae953..859d0ff0a0a21e453f828326e529174f4af0526e 100644 (file)
@@ -17,6 +17,7 @@
 \r
 package org.apache.poi.hssf.record.formula;\r
 \r
+import org.apache.poi.ss.util.CellReference;\r
 import org.apache.poi.util.LittleEndianInput;\r
 \r
 /**\r
@@ -32,7 +33,7 @@ public final class RefPtg extends Ref2DPtgBase {
         * numeric fields.\r
         */\r
        public RefPtg(String cellref) {\r
-               super(cellref);\r
+               super(new CellReference(cellref));\r
        }\r
 \r
        public RefPtg(int row, int column, boolean isRowRelative, boolean isColumnRelative) {\r
@@ -43,6 +44,10 @@ public final class RefPtg extends Ref2DPtgBase {
                super(in);\r
        }\r
 \r
+       public RefPtg(CellReference cr) {\r
+               super(cr);\r
+       }\r
+\r
        protected byte getSid() {\r
                return sid;\r
        }\r
index 8357e158c511a1d2d5b5b5ce41e8e6b8ee010a1e..33e1315157ae27bc6a4c6021ee0e3c3dd17bf2dd 100644 (file)
@@ -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();
        }