poi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From slaub...@apache.org
Subject cvs commit: jakarta-poi/src/testcases/org/apache/poi/hssf/usermodel TestHSSFSheet.java
Date Fri, 22 Aug 2003 17:21:20 GMT
slaubach    2003/08/22 10:21:20

  Modified:    src/java/org/apache/poi/hssf/model Sheet.java
               src/java/org/apache/poi/hssf/usermodel HSSFSheet.java
               src/testcases/org/apache/poi/hssf/usermodel
                        TestHSSFSheet.java
  Log:
  Updates for the display of gridlines, formulas, and such because I forgot to do this when
I added it to the release.
  
  Revision  Changes    Path
  1.39      +59 -10    jakarta-poi/src/java/org/apache/poi/hssf/model/Sheet.java
  
  Index: Sheet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-poi/src/java/org/apache/poi/hssf/model/Sheet.java,v
  retrieving revision 1.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- Sheet.java	31 Jul 2003 19:01:47 -0000	1.38
  +++ Sheet.java	22 Aug 2003 17:21:20 -0000	1.39
  @@ -108,6 +108,7 @@
       protected HeaderRecord              header           = null;
       protected FooterRecord              footer           = null;
       protected PrintGridlinesRecord      printGridlines   = null;
  +    protected WindowTwoRecord           windowTwo        = null;
       protected MergeCellsRecord          merged           = null;
       protected Margin                    margins[]        = null;
       protected ArrayList                 mergedRecords    = new ArrayList();
  @@ -280,6 +281,10 @@
               {
   		retval.getMargins()[BottomMargin] = (BottomMarginRecord) rec;
   	    }
  +	    else if ( rec.getSid() == WindowTwoRecord.sid )
  +	    {
  +		retval.windowTwo = (WindowTwoRecord) rec;
  +	    }
   	    
               if (rec != null)
               {
  @@ -406,7 +411,7 @@
           retval.dims    = ( DimensionsRecord ) retval.createDimensions();
           retval.dimsloc = 19;
           records.add(retval.dims);
  -        records.add(retval.createWindowTwo());
  +        records.add(retval.windowTwo = retval.createWindowTwo());
           retval.setLoc(records.size() - 1);
           retval.selection = 
                   (SelectionRecord) retval.createSelection();
  @@ -2066,7 +2071,7 @@
        * @return record containing a WindowTwoRecord
        */
   
  -    protected Record createWindowTwo()
  +    protected WindowTwoRecord createWindowTwo()
       {
           WindowTwoRecord retval = new WindowTwoRecord();
   
  @@ -2399,7 +2404,6 @@
        * @param sel True to select the sheet, false otherwise.
        */
       public void setSelected(boolean sel) {
  -        WindowTwoRecord windowTwo = (WindowTwoRecord) findFirstRecordBySid(WindowTwoRecord.sid);
           windowTwo.setSelected(sel);
       }
   
  @@ -2498,9 +2502,8 @@
           }
           records.add(loc+1, pane);
   
  -        WindowTwoRecord windowRecord = (WindowTwoRecord) records.get(loc);
  -        windowRecord.setFreezePanes(true);
  -        windowRecord.setFreezePanesNoSplit(true);
  +        windowTwo.setFreezePanes(true);
  +        windowTwo.setFreezePanesNoSplit(true);
   
           SelectionRecord sel = (SelectionRecord) findFirstRecordBySid(SelectionRecord.sid);
   //        SelectionRecord sel2 = (SelectionRecord) sel.clone();
  @@ -2548,9 +2551,8 @@
           r.setActivePane((short) activePane);
           records.add(loc+1, r);
   
  -        WindowTwoRecord windowRecord = (WindowTwoRecord) records.get(loc);
  -        windowRecord.setFreezePanes(false);
  -        windowRecord.setFreezePanesNoSplit(false);
  +        windowTwo.setFreezePanes(false);
  +        windowTwo.setFreezePanesNoSplit(false);
   
           SelectionRecord sel = (SelectionRecord) findFirstRecordBySid(SelectionRecord.sid);
   //        SelectionRecord sel2 = (SelectionRecord) sel.clone();
  @@ -2585,6 +2587,54 @@
       }
   
       /**
  +     * Sets whether the gridlines are shown in a viewer.
  +     * @param show whether to show gridlines or not
  +     */
  +    public void setDisplayGridlines(boolean show) {
  +        windowTwo.setDisplayGridlines(show);
  +    }
  +
  +    /**
  +     * Returns if gridlines are displayed.
  +     * @return whether gridlines are displayed
  +     */
  +    public boolean isDisplayGridlines() {
  +	return windowTwo.getDisplayGridlines();
  +    }
  +
  +    /**
  +     * Sets whether the formulas are shown in a viewer.
  +     * @param show whether to show formulas or not
  +     */
  +    public void setDisplayFormulas(boolean show) {
  +        windowTwo.setDisplayFormulas(show);
  +    }
  +
  +    /**
  +     * Returns if formulas are displayed.
  +     * @return whether formulas are displayed
  +     */
  +    public boolean isDisplayFormulas() {
  +	return windowTwo.getDisplayFormulas();
  +    }
  +
  +    /**
  +     * Sets whether the RowColHeadings are shown in a viewer.
  +     * @param show whether to show RowColHeadings or not
  +     */
  +    public void setDisplayRowColHeadings(boolean show) {
  +        windowTwo.setDisplayRowColHeadings(show);
  +    }
  +
  +    /**
  +     * Returns if RowColHeadings are displayed.
  +     * @return whether RowColHeadings are displayed
  +     */
  +    public boolean isDisplayRowColHeadings() {
  +	return windowTwo.getDisplayRowColHeadings();
  +    }
  +
  +    /**
        * Returns the array of margins.  If not created, will create.
        *
        * @return the array of marings.
  @@ -2594,5 +2644,4 @@
               margins = new Margin[4];
   	return margins;
       }
  -
   }
  
  
  
  1.24      +46 -2     jakarta-poi/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java
  
  Index: HSSFSheet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-poi/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- HSSFSheet.java	19 Jul 2003 02:48:16 -0000	1.23
  +++ HSSFSheet.java	22 Aug 2003 17:21:20 -0000	1.24
  @@ -1083,7 +1083,53 @@
           getSheet().createSplitPane( xSplitPos, ySplitPos, topRow, leftmostColumn, activePane
);
       }
   
  +    /**
  +     * Sets whether the gridlines are shown in a viewer.
  +     * @param show whether to show gridlines or not
  +     */
  +    public void setDisplayGridlines(boolean show) {
  +        sheet.setDisplayGridlines(show);
  +    }
  +
  +    /**
  +     * Returns if gridlines are displayed.
  +     * @return whether gridlines are displayed
  +     */
  +    public boolean isDisplayGridlines() {
  +	return sheet.isDisplayGridlines();
  +    }
  +
  +    /**
  +     * Sets whether the formulas are shown in a viewer.
  +     * @param show whether to show formulas or not
  +     */
  +    public void setDisplayFormulas(boolean show) {
  +        sheet.setDisplayFormulas(show);
  +    }
  +
  +    /**
  +     * Returns if formulas are displayed.
  +     * @return whether formulas are displayed
  +     */
  +    public boolean isDisplayFormulas() {
  +	return sheet.isDisplayFormulas();
  +    }
  +
  +    /**
  +     * Sets whether the RowColHeadings are shown in a viewer.
  +     * @param show whether to show RowColHeadings or not
  +     */
  +    public void setDisplayRowColHeadings(boolean show) {
  +        sheet.setDisplayRowColHeadings(show);
  +    }
   
  +    /**
  +     * Returns if RowColHeadings are displayed.
  +     * @return whether RowColHeadings are displayed
  +     */
  +    public boolean isDisplayRowColHeadings() {
  +	return sheet.isDisplayRowColHeadings();
  +    }
   }
   
   class SheetRowIterator implements Iterator {
  @@ -1112,6 +1158,4 @@
       public void remove() {
           rows.remove();
       }
  -
  -
   }
  
  
  
  1.16      +43 -2     jakarta-poi/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java
  
  Index: TestHSSFSheet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-poi/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- TestHSSFSheet.java	27 Jun 2003 23:57:58 -0000	1.15
  +++ TestHSSFSheet.java	22 Aug 2003 17:21:20 -0000	1.16
  @@ -318,8 +318,49 @@
   		
   	}
   
  +    /**
  +     * Tests the display of gridlines, formulas, and rowcolheadings.
  +     * @author Shawn Laubach (slaubach at apache dot org)
  +     */
  +    public void testDisplayOptions() throws Exception {
  +	HSSFWorkbook wb = new HSSFWorkbook();
  +	HSSFSheet sheet = wb.createSheet();
  +	
  +        File tempFile = File.createTempFile("display", "test.xls");
  +        FileOutputStream stream = new FileOutputStream(tempFile);
  +        wb.write(stream);
  +        stream.close();
  +
  +        FileInputStream readStream = new FileInputStream(tempFile);
  +        wb = new HSSFWorkbook(readStream);
  +        sheet = wb.getSheetAt(0);
  +	readStream.close();
  +
  +	assertEquals(sheet.isDisplayGridlines(), true);
  +	assertEquals(sheet.isDisplayRowColHeadings(), true);
  +	assertEquals(sheet.isDisplayFormulas(), false);
  +
  +	sheet.setDisplayGridlines(false);
  +	sheet.setDisplayRowColHeadings(false);
  +	sheet.setDisplayFormulas(true);
  +
  +        tempFile = File.createTempFile("display", "test.xls");
  +        stream = new FileOutputStream(tempFile);
  +        wb.write(stream);
  +        stream.close();
  +
  +        readStream = new FileInputStream(tempFile);
  +        wb = new HSSFWorkbook(readStream);
  +        sheet = wb.getSheetAt(0);
  +	readStream.close();
  +
  +
  +	assertEquals(sheet.isDisplayGridlines(), false);
  +	assertEquals(sheet.isDisplayRowColHeadings(), false);
  +	assertEquals(sheet.isDisplayFormulas(), true);
  +    }
  +
   	public static void main(java.lang.String[] args) {
   		 junit.textui.TestRunner.run(TestHSSFSheet.class);
  -	}
  -    
  +	}    
   }
  
  
  

---------------------------------------------------------------------
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