poi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject cvs commit: jakarta-poi/src/testcases/org/apache/poi/hssf/usermodel TestFormulas.java
Date Thu, 19 May 2005 14:56:45 GMT
avik        2005/05/19 07:56:45

  Modified:    src/java/org/apache/poi/hssf/record NameRecord.java
               src/java/org/apache/poi/hssf/record/formula Ptg.java
               src/testcases/org/apache/poi/hssf/usermodel
                        TestFormulas.java
  Added:       src/java/org/apache/poi/hssf/record/formula
                        DeletedArea3DPtg.java DeletedRef3DPtg.java
               src/testcases/org/apache/poi/hssf/data 27272_1.xls
                        27272_2.xls
  Log:
  Fix for bug 27272 : Unknown Ptg 3C and 3D
  by Patrick Luby, thanks!
  
  Revision  Changes    Path
  1.19      +5 -2      jakarta-poi/src/java/org/apache/poi/hssf/record/NameRecord.java
  
  Index: NameRecord.java
  ===================================================================
  RCS file: /home/cvs/jakarta-poi/src/java/org/apache/poi/hssf/record/NameRecord.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- NameRecord.java	19 May 2005 14:32:46 -0000	1.18
  +++ NameRecord.java	19 May 2005 14:56:45 -0000	1.19
  @@ -23,6 +23,8 @@
   
   import org.apache.poi.hssf.model.Workbook;
   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.util.RangeAddress;
  @@ -664,7 +666,7 @@
        * @return area reference
        */
       public String getAreaReference(Workbook book){
  -        if (field_13_name_definition == null || field_13_name_definition.isEmpty()) return
"#REF!";
  +        if (field_13_name_definition == null || field_13_name_definition.isEmpty()) return
"Error";
           Ptg ptg = (Ptg) field_13_name_definition.peek();
           String result = "";
   
  @@ -673,7 +675,8 @@
   
           } else if (ptg.getClass() == Ref3DPtg.class){
               result = ptg.toFormulaString(book);
  -        }
  +        } else if (ptg.getClass() == DeletedArea3DPtg.class || ptg.getClass() == DeletedRef3DPtg.class)
{
  +        	result = "#REF!"   ;     }
   
           return result;
       }
  
  
  
  1.37      +14 -0     jakarta-poi/src/java/org/apache/poi/hssf/record/formula/Ptg.java
  
  Index: Ptg.java
  ===================================================================
  RCS file: /home/cvs/jakarta-poi/src/java/org/apache/poi/hssf/record/formula/Ptg.java,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -r1.36 -r1.37
  --- Ptg.java	2 Jan 2005 01:00:52 -0000	1.36
  +++ Ptg.java	19 May 2005 14:56:45 -0000	1.37
  @@ -260,6 +260,20 @@
                   retval = new Ref3DPtg(data, offset);
                   break;
                   
  +            case DeletedArea3DPtg.sid :      // 0x3c     
  +            case DeletedArea3DPtg.sid+0x20 : // 0x5c     
  +            case DeletedArea3DPtg.sid+0x40 : // 0x7c     
  +
  +                retval = new DeletedArea3DPtg(data, offset);
  +                break;
  +
  +            case DeletedRef3DPtg.sid:      // 0x3d      
  +            case DeletedRef3DPtg.sid+0x20: // 0x5d     
  +            case DeletedRef3DPtg.sid+0x40: // 0x7d     
  +
  +                retval = new DeletedRef3DPtg(data, offset);
  +                break;
  +                
               case MissingArgPtg.sid:
                   retval = new MissingArgPtg(data,offset);
                   break;
  
  
  
  1.1                  jakarta-poi/src/java/org/apache/poi/hssf/record/formula/DeletedArea3DPtg.java
  
  Index: DeletedArea3DPtg.java
  ===================================================================
  /* ====================================================================
     Copyright 2003-2005   Apache Software Foundation
  
     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at
  
         http://www.apache.org/licenses/LICENSE-2.0
  
     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
  ==================================================================== */
  
  package org.apache.poi.hssf.record.formula;
  
  /**
   * Title:        Deleted Area 3D Ptg - 3D referecnce (Sheet + Area)<P>
   * Description:  Defined a area in Extern Sheet. <P>
   * REFERENCE:  <P>
   * @author Patrick Luby
   * @version 1.0-pre
   */
  
  public class DeletedArea3DPtg extends Area3DPtg
  {
  	public final static byte sid = 0x3d;
  
      /** Creates new DeletedArea3DPtg */
      public DeletedArea3DPtg( String arearef, short externIdx )
      {
          super(arearef, externIdx);
      }
  
      public DeletedArea3DPtg( byte[] data, int offset )
      {
          super(data, offset);
      }
  }
  
  
  
  1.1                  jakarta-poi/src/java/org/apache/poi/hssf/record/formula/DeletedRef3DPtg.java
  
  Index: DeletedRef3DPtg.java
  ===================================================================
  /* ====================================================================
     Copyright 2003-2005   Apache Software Foundation
  
     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at
  
         http://www.apache.org/licenses/LICENSE-2.0
  
     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
  ==================================================================== */
  
  
  package org.apache.poi.hssf.record.formula;
  
  /**
   * Title:        Deleted Reference 3D Ptg <P>
   * Description:  Defined a cell in extern sheet. <P>
   * REFERENCE:  <P>
   * @author Patrick Luby
   * @version 1.0-pre
   */
  
  public class DeletedRef3DPtg extends Ref3DPtg {
      public final static byte sid  = 0x3c;
  
      /** Creates new DeletedRef3DPtg */
      public DeletedRef3DPtg(byte[] data, int offset) {
          super(data, offset);
      }
  
      public DeletedRef3DPtg(String cellref, short externIdx ) {
          super(cellref, externIdx);
      }
  }
  
  
  
  1.1                  jakarta-poi/src/testcases/org/apache/poi/hssf/data/27272_1.xls
  
  	<<Binary file>>
  
  
  1.1                  jakarta-poi/src/testcases/org/apache/poi/hssf/data/27272_2.xls
  
  	<<Binary file>>
  
  
  1.37      +26 -0     jakarta-poi/src/testcases/org/apache/poi/hssf/usermodel/TestFormulas.java
  
  Index: TestFormulas.java
  ===================================================================
  RCS file: /home/cvs/jakarta-poi/src/testcases/org/apache/poi/hssf/usermodel/TestFormulas.java,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -r1.36 -r1.37
  --- TestFormulas.java	22 Apr 2005 13:12:14 -0000	1.36
  +++ TestFormulas.java	19 May 2005 14:56:45 -0000	1.37
  @@ -1094,6 +1094,32 @@
       	 File file = TempFile.createTempFile("testComplexSheetRefs",".xls");
       	 sb.write(new FileOutputStream(file));
       }
  +    
  +	/*Unknown Ptg 3C*/
  +	public void test27272_1() throws Exception {
  +		String readFilename = System.getProperty("HSSF.testdata.path");	
  +		File inFile = new File(readFilename+"/27272_1.xls");
  +		FileInputStream in = new FileInputStream(inFile);
  +		HSSFWorkbook wb = new HSSFWorkbook(in);
  +		wb.getSheetAt(0);
  +		assertEquals("Reference for named range ", "#REF!",wb.getNameAt(0).getReference());
  +		File outF = File.createTempFile("bug27272_1",".xls");
  +		wb.write(new FileOutputStream(outF));
  +		System.out.println("Open "+outF.getAbsolutePath()+" in Excel");
  +	}
  +	/*Unknown Ptg 3D*/
  +	public void test27272_2() throws Exception {
  +		String readFilename = System.getProperty("HSSF.testdata.path");	
  +		File inFile = new File(readFilename+"/27272_2.xls");
  +		FileInputStream in = new FileInputStream(inFile);
  +		HSSFWorkbook wb = new HSSFWorkbook(in);
  +		assertEquals("Reference for named range ", "#REF!",wb.getNameAt(0).getReference());
  +		File outF = File.createTempFile("bug27272_2",".xls");
  +		wb.write(new FileOutputStream(outF));
  +		System.out.println("Open "+outF.getAbsolutePath()+" in Excel");
  +	}
  +    
  +    
       public static void main(String [] args) {
           System.out
           .println("Testing org.apache.poi.hssf.usermodel.TestFormulas");
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: poi-dev-unsubscribe@jakarta.apache.org
Mailing List:    http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta POI Project: http://jakarta.apache.org/poi/


Mime
View raw message