poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r669809 - 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/usermodel/
Date Fri, 20 Jun 2008 07:10:04 GMT
Author: josh
Date: Fri Jun 20 00:10:03 2008
New Revision: 669809

URL: http://svn.apache.org/viewvc?rev=669809&view=rev
Log:
Fix for bug 30978 - small re-arrangement of class Ptg hierarchy for DeletedRef3DPtg and DeletedArea3DPtg.
Similar to c664220

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/NameRecord.java
    poi/trunk/src/java/org/apache/poi/hssf/record/formula/Area3DPtg.java
    poi/trunk/src/java/org/apache/poi/hssf/record/formula/DeletedArea3DPtg.java
    poi/trunk/src/java/org/apache/poi/hssf/record/formula/DeletedRef3DPtg.java
    poi/trunk/src/java/org/apache/poi/hssf/record/formula/Ref3DPtg.java
    poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.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=669809&r1=669808&r2=669809&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/changes.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/changes.xml Fri Jun 20 00:10:03 2008
@@ -37,6 +37,7 @@
 
 		<!-- Don't forget to update status.xml too! -->
         <release version="3.1-final" date="2008-06-??">
+           <action dev="POI-DEVELOPERS" type="fix">30978 - Fixed re-serialization of
tRefErr3d and tAreaErr3d</action>
            <action dev="POI-DEVELOPERS" type="fix">45234 - Removed incorrect shared
formula conversion in CFRuleRecord</action>
            <action dev="POI-DEVELOPERS" type="fix">45001 - Improved HWPF Range.replaceText()</action>
            <action dev="POI-DEVELOPERS" type="fix">44692 - Fixed HSSFPicture.resize()
to properly resize pictures if the underlying columns/rows have modified size</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=669809&r1=669808&r2=669809&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/status.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/status.xml Fri Jun 20 00:10:03 2008
@@ -34,6 +34,7 @@
 	<!-- Don't forget to update changes.xml too! -->
     <changes>
         <release version="3.1-final" date="2008-06-??">
+           <action dev="POI-DEVELOPERS" type="fix">30978 - Fixed re-serialization of
tRefErr3d and tAreaErr3d</action>
            <action dev="POI-DEVELOPERS" type="fix">45234 - Removed incorrect shared
formula conversion in CFRuleRecord</action>
            <action dev="POI-DEVELOPERS" type="fix">45001 - Improved HWPF Range.replaceText()</action>
            <action dev="POI-DEVELOPERS" type="fix">44692 - Fixed HSSFPicture.resize()
to properly resize pictures if the underlying columns/rows have modified size</action>

Modified: poi/trunk/src/java/org/apache/poi/hssf/record/NameRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/NameRecord.java?rev=669809&r1=669808&r2=669809&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/NameRecord.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/NameRecord.java Fri Jun 20 00:10:03 2008
@@ -14,7 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
 
 package org.apache.poi.hssf.record;
 
@@ -22,9 +21,8 @@
 import java.util.List;
 import java.util.Stack;
 
+import org.apache.poi.hssf.model.FormulaParser;
 import org.apache.poi.hssf.record.formula.Area3DPtg;
-import org.apache.poi.hssf.record.formula.DeletedArea3DPtg;
-import org.apache.poi.hssf.record.formula.DeletedRef3DPtg;
 import org.apache.poi.hssf.record.formula.Ptg;
 import org.apache.poi.hssf.record.formula.Ref3DPtg;
 import org.apache.poi.hssf.record.formula.UnionPtg;
@@ -44,8 +42,7 @@
  * @author Glen Stampoultzis (glens at apache.org)
  * @version 1.0-pre
  */
-
-public class NameRecord extends Record {
+public final class NameRecord extends Record {
     /**
      */
     public final static short sid = 0x18; //Docs says that it is 0x218
@@ -650,50 +647,9 @@
     /** gets the reference , the area only (range)
      * @return area reference
      */
-    public String getAreaReference(HSSFWorkbook book){
-        if (field_13_name_definition == null || field_13_name_definition.isEmpty()) return
"Error";
-        Ptg ptg = (Ptg) field_13_name_definition.peek();
-        String result = "";
-
-        // If it's a union, descend in and process
-        if (ptg.getClass() == UnionPtg.class) {
-            Iterator it =field_13_name_definition.iterator();
-            while( it.hasNext() ) {
-                Ptg p = (Ptg)it.next();
-
-                String thisRes = getAreaRefString(p, book);
-                if(thisRes.length() > 0) {
-                    // Add a comma to the end if needed
-                    if(result.length() > 0 && !result.endsWith(",")) {
-                        result += ",";
-                    }
-                    // And add the string it corresponds to
-                    result += thisRes;
-                }
-            }
-        } else {
-            // Otherwise just get the string
-            result = getAreaRefString(ptg, book);
-        }
-
-        return result;
-    }
-
-    /**
-     * Turn the given ptg into a string, or
-     *  return an empty string if nothing is possible
-     *  for it.
-     */
-    private String getAreaRefString(Ptg ptg,HSSFWorkbook book) {
-        if (ptg.getClass() == Area3DPtg.class){
-            return ptg.toFormulaString(book);
-        } else if (ptg.getClass() == Ref3DPtg.class){
-            return ptg.toFormulaString(book);
-        } else if (ptg.getClass() == DeletedArea3DPtg.class || ptg.getClass() == DeletedRef3DPtg.class)
{
-        	return "#REF!";
-        }
-        return "";
-    }
+	public String getAreaReference(HSSFWorkbook book){
+		return FormulaParser.toFormulaString(book, field_13_name_definition);
+	}
 
     /** sets the reference , the area only (range)
      * @param ref area reference

Modified: poi/trunk/src/java/org/apache/poi/hssf/record/formula/Area3DPtg.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/formula/Area3DPtg.java?rev=669809&r1=669808&r2=669809&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/formula/Area3DPtg.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/formula/Area3DPtg.java Fri Jun 20 00:10:03
2008
@@ -35,7 +35,7 @@
  * @author Jason Height (jheight at chariot dot net dot au)
  * @version 1.0-pre
  */
-public class Area3DPtg extends OperandPtg implements AreaI {
+public final class Area3DPtg extends OperandPtg implements AreaI {
 	public final static byte sid = 0x3b;
 	private final static int SIZE = 11; // 10 + 1 for Ptg
 	private short field_1_index_extern_sheet;

Modified: poi/trunk/src/java/org/apache/poi/hssf/record/formula/DeletedArea3DPtg.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/formula/DeletedArea3DPtg.java?rev=669809&r1=669808&r2=669809&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/formula/DeletedArea3DPtg.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/formula/DeletedArea3DPtg.java Fri Jun 20
00:10:03 2008
@@ -18,6 +18,9 @@
 package org.apache.poi.hssf.record.formula;
 
 import org.apache.poi.hssf.record.RecordInputStream;
+import org.apache.poi.hssf.usermodel.HSSFErrorConstants;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.util.LittleEndian;
 
 /**
  * Title:        Deleted Area 3D Ptg - 3D referecnce (Sheet + Area)<P>
@@ -26,19 +29,30 @@
  * @author Patrick Luby
  * @version 1.0-pre
  */
-
-public class DeletedArea3DPtg extends Area3DPtg
-{
+public final class DeletedArea3DPtg extends OperandPtg {
 	public final static byte sid = 0x3d;
+	private final int field_1_index_extern_sheet;
+	private final int unused1;
+	private final int unused2;
 
-    /** Creates new DeletedArea3DPtg */
-    public DeletedArea3DPtg( String arearef, short externIdx )
-    {
-        super(arearef, externIdx);
-    }
-
-    public DeletedArea3DPtg( RecordInputStream in)
-    {
-        super(in);
-    }
+	public DeletedArea3DPtg( RecordInputStream in) {
+		field_1_index_extern_sheet = in.readUShort();
+		unused1 = in.readInt();
+		unused2 = in.readInt();
+	}
+	public String toFormulaString(HSSFWorkbook book) {
+		return HSSFErrorConstants.getText(HSSFErrorConstants.ERROR_REF);
+	}
+	public byte getDefaultOperandClass() {
+		return Ptg.CLASS_REF;
+	}
+	public int getSize() {
+		return 11;
+	}
+	public void writeBytes(byte[] data, int offset) {
+		LittleEndian.putByte(data, 0 + offset, sid + getPtgClass());
+		LittleEndian.putUShort(data, 1 + offset, field_1_index_extern_sheet);
+		LittleEndian.putInt(data, 3 + offset, unused1);
+		LittleEndian.putInt(data, 7 + offset, unused2);
+	}
 }

Modified: poi/trunk/src/java/org/apache/poi/hssf/record/formula/DeletedRef3DPtg.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/formula/DeletedRef3DPtg.java?rev=669809&r1=669808&r2=669809&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/formula/DeletedRef3DPtg.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/formula/DeletedRef3DPtg.java Fri Jun 20
00:10:03 2008
@@ -15,11 +15,13 @@
    limitations under the License.
 ==================================================================== */
 
-
 package org.apache.poi.hssf.record.formula;
 
 
 import org.apache.poi.hssf.record.RecordInputStream;
+import org.apache.poi.hssf.usermodel.HSSFErrorConstants;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.util.LittleEndian;
 
 /**
  * Title:        Deleted Reference 3D Ptg <P>
@@ -28,16 +30,29 @@
  * @author Patrick Luby
  * @version 1.0-pre
  */
-
-public class DeletedRef3DPtg extends Ref3DPtg {
-    public final static byte sid  = 0x3c;
-
-    /** Creates new DeletedRef3DPtg */
-    public DeletedRef3DPtg(RecordInputStream in) {
-        super(in);
-    }
-
-    public DeletedRef3DPtg(String cellref, short externIdx ) {
-        super(cellref, externIdx);
-    }
+public final class DeletedRef3DPtg extends OperandPtg {
+	public final static byte sid  = 0x3c;
+	private final int field_1_index_extern_sheet;
+	private final int unused1;
+
+	/** Creates new DeletedRef3DPtg */
+	public DeletedRef3DPtg(RecordInputStream in) {
+		field_1_index_extern_sheet = in.readUShort();
+		unused1 = in.readInt();
+	}
+
+	public String toFormulaString(HSSFWorkbook book) {
+		return HSSFErrorConstants.getText(HSSFErrorConstants.ERROR_REF);
+	}
+	public byte getDefaultOperandClass() {
+		return Ptg.CLASS_REF;
+	}
+	public int getSize() {
+		return 7;
+	}
+	public void writeBytes(byte[] data, int offset) {
+		LittleEndian.putByte(data, 0 + offset, sid + getPtgClass());
+		LittleEndian.putUShort(data, 1 + offset, field_1_index_extern_sheet);
+		LittleEndian.putInt(data, 3 + offset, unused1);
+	}
 }

Modified: poi/trunk/src/java/org/apache/poi/hssf/record/formula/Ref3DPtg.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/formula/Ref3DPtg.java?rev=669809&r1=669808&r2=669809&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/formula/Ref3DPtg.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/formula/Ref3DPtg.java Fri Jun 20 00:10:03
2008
@@ -34,7 +34,7 @@
  * @author Jason Height (jheight at chariot dot net dot au)
  * @version 1.0-pre
  */
-public class Ref3DPtg extends OperandPtg {
+public final class Ref3DPtg extends OperandPtg {
     public final static byte sid  = 0x3a;
     private final static int  SIZE = 7; // 6 + 1 for Ptg
     private short             field_1_index_extern_sheet;

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java?rev=669809&r1=669808&r2=669809&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java Fri Jun 20 00:10:03
2008
@@ -999,7 +999,7 @@
      *  used for printing stuff.
      * Currently broken, as we change the Ptg
      */
-    public void BROKENtest30978() throws Exception {
+    public void test30978() throws Exception {
         HSSFWorkbook wb = openSample("30978-alt.xls");
         assertEquals(1, wb.getNumberOfNames());
         assertEquals(3, wb.getNumberOfSheets());



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


Mime
View raw message