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/record TestBoundSheetRecord.java
Date Thu, 09 Oct 2003 19:21:57 GMT
avik        2003/10/09 12:21:57

  Modified:    src/java/org/apache/poi/hssf/record Tag: REL_2_BRANCH
                        BoundSheetRecord.java
               src/java/org/apache/poi/hssf/usermodel Tag: REL_2_BRANCH
                        HSSFWorkbook.java
               src/testcases/org/apache/poi/hssf/record Tag: REL_2_BRANCH
                        TestBoundSheetRecord.java
  Log:
  PR: 13921
  Sheet name should not be greater than 31 chars and should not contain \/?*[]
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.8.2.1   +12 -0     jakarta-poi/src/java/org/apache/poi/hssf/record/BoundSheetRecord.java
  
  Index: BoundSheetRecord.java
  ===================================================================
  RCS file: /home/cvs/jakarta-poi/src/java/org/apache/poi/hssf/record/BoundSheetRecord.java,v
  retrieving revision 1.8
  retrieving revision 1.8.2.1
  diff -u -r1.8 -r1.8.2.1
  --- BoundSheetRecord.java	30 Apr 2003 04:38:47 -0000	1.8
  +++ BoundSheetRecord.java	9 Oct 2003 19:21:56 -0000	1.8.2.1
  @@ -194,10 +194,22 @@
       /**
        * Set the sheetname for this sheet.  (this appears in the tabs at the bottom)
        * @param sheetname the name of the sheet
  +     * @thows IllegalArgumentException if sheet name will cause excel to crash. 
        */
   
       public void setSheetname( String sheetname )
       {
  +        
  +        if ((sheetname == null) || (sheetname.length()==0)
  +                || (sheetname.length()>31)
  +                || (sheetname.indexOf("/") > -1)
  +                || (sheetname.indexOf("\\") > -1)
  +                || (sheetname.indexOf("?") > -1)
  +                || (sheetname.indexOf("*") > -1)
  +                || (sheetname.indexOf("]") > -1)
  +                || (sheetname.indexOf("[") > -1) ){
  +                    throw new IllegalArgumentException("Sheet name cannot be blank, greater
than 31 chars, or contain any of /\\*?[]");
  +        }
           field_5_sheetname = sheetname;
       }
   
  
  
  
  No                   revision
  No                   revision
  1.24.2.3  +3 -1      jakarta-poi/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java
  
  Index: HSSFWorkbook.java
  ===================================================================
  RCS file: /home/cvs/jakarta-poi/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java,v
  retrieving revision 1.24.2.2
  retrieving revision 1.24.2.3
  diff -u -r1.24.2.2 -r1.24.2.3
  --- HSSFWorkbook.java	23 Aug 2003 19:40:05 -0000	1.24.2.2
  +++ HSSFWorkbook.java	9 Oct 2003 19:21:56 -0000	1.24.2.3
  @@ -281,7 +281,9 @@
       
        
       /**
  -     * set the sheet name.
  +     * set the sheet name. 
  +     * Will throw IllegalArgumentException if the name is greater than 31 chars
  +     * or contains /\?*[]
        * @param sheet number (0 based)
        * @param sheet name
        */
  
  
  
  No                   revision
  No                   revision
  1.2.2.1   +20 -0     jakarta-poi/src/testcases/org/apache/poi/hssf/record/TestBoundSheetRecord.java
  
  Index: TestBoundSheetRecord.java
  ===================================================================
  RCS file: /home/cvs/jakarta-poi/src/testcases/org/apache/poi/hssf/record/TestBoundSheetRecord.java,v
  retrieving revision 1.2
  retrieving revision 1.2.2.1
  diff -u -r1.2 -r1.2.2.1
  --- TestBoundSheetRecord.java	30 Apr 2003 04:39:04 -0000	1.2
  +++ TestBoundSheetRecord.java	9 Oct 2003 19:21:57 -0000	1.2.2.1
  @@ -92,5 +92,25 @@
   
           assertEquals(" 2  +  2  +  4  +   2   +    1     +    1    + len(str) * 2", 24,
record.getRecordSize());
       }
  +    
  +    public void testName() {
  +        BoundSheetRecord record = new BoundSheetRecord();
  +        record.setSheetname("1234567890223456789032345678904");
  +        assertTrue("Success", true);
  +        try {
  +            record.setSheetname("12345678902234567890323456789042");
  +            assertTrue("Should have thrown IllegalArgumentException, but didnt", false);
  +        } catch (IllegalArgumentException e) {
  +            assertTrue("succefully threw exception",true);
  +        }
  +        
  +        try {
  +            record.setSheetname("s//*s");
  +            assertTrue("Should have thrown IllegalArgumentException, but didnt", false);
  +        } catch (IllegalArgumentException e) {
  +            assertTrue("succefully threw exception",true);
  +        }
  +            
  +    }
   
   }
  
  
  

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


Mime
View raw message