]> source.dussan.org Git - poi.git/commitdiff
bug 58644: fix HSSFSheet.setZoom(int); update documentation to use non-deprecated...
authorJaven O'Neal <onealj@apache.org>
Tue, 24 Nov 2015 08:04:42 +0000 (08:04 +0000)
committerJaven O'Neal <onealj@apache.org>
Tue, 24 Nov 2015 08:04:42 +0000 (08:04 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1716053 13f79535-47bb-0310-9956-ffa450edef68

.project
src/examples/src/org/apache/poi/hssf/usermodel/examples/ZoomSheet.java
src/examples/src/org/apache/poi/ss/examples/BusinessPlan.java
src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java
src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java
src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java
src/testcases/org/apache/poi/ss/usermodel/BaseTestSheet.java

index 274051f30a2f52337a304b42d9ca2c21a980fe7b..e6dc28da20d8f9010d3e2120577772d3ca698188 100644 (file)
--- a/.project
+++ b/.project
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <projectDescription>
-       <name>ApachePOI</name>
+       <name>ApachePOI-bug58365</name>
        <comment></comment>
        <projects>
        </projects>
index c65c62f18f860aec508934fd57b55597dd80fffb..f83b5900e83ed53fe76441489f29b6bbb8583be5 100644 (file)
@@ -37,9 +37,10 @@ public class ZoomSheet
     {
         HSSFWorkbook wb = new HSSFWorkbook();
         HSSFSheet sheet1 = wb.createSheet("new sheet");
-        sheet1.setZoom(3,4);   // 75 percent magnification
+        sheet1.setZoom(75);   // 75 percent magnification
         FileOutputStream fileOut = new FileOutputStream("workbook.xls");
         wb.write(fileOut);
         fileOut.close();
+        wb.close();
     }
 }
index 101eceda7bb1b6058557b72cc5b2aa93892d066f..a3054d9d74fd7b4ac943d9ea39b28fde3f53f59f 100644 (file)
@@ -192,7 +192,7 @@ public class BusinessPlan {
         sheet.setColumnWidth(0, 256*6);
         sheet.setColumnWidth(1, 256*33);
         sheet.setColumnWidth(2, 256*20);
-        sheet.setZoom(3, 4);
+        sheet.setZoom(75); //75% scale
 
 
         // Write the output to a file
index 0a6c0c432a7f91dcd413829cd8e11ad9096ae870..862f08ce96bae1fad3b24c6213e7337a3442bfe0 100644 (file)
@@ -1267,7 +1267,7 @@ public final class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet {
      */
     @Override
     public void setZoom(int scale) {
-        setZoom(scale*100, 100);
+        setZoom(scale, 100);
     }
 
     /**
index 34e5ae49609fd9ce5881cbf58418c856cae1670b..336901a13d20a53f4a8c8241e04aa6de67882e74 100644 (file)
@@ -408,12 +408,11 @@ public final class TestXSSFSheet extends BaseTestSheet {
         workbook.close();
     }
 
-    @SuppressWarnings("deprecation")
     @Test(expected=IllegalArgumentException.class)
     public void setZoom() throws IOException {
         XSSFWorkbook workBook = new XSSFWorkbook();
         XSSFSheet sheet1 = workBook.createSheet("new sheet");
-        sheet1.setZoom(3, 4);   // 75 percent magnification
+        sheet1.setZoom(75);   // 75 percent magnification
         long zoom = sheet1.getCTWorksheet().getSheetViews().getSheetViewArray(0).getZoomScale();
         assertEquals(zoom, 75);
 
index d21930b471f0d0b1396f30545d3cbb219c79d418..8d64bf14f9258255d38eb248411ae72beb53391d 100644 (file)
@@ -523,11 +523,10 @@ public final class TestHSSFSheet extends BaseTestSheet {
         HSSFWorkbook wb = new HSSFWorkbook();
         HSSFSheet sheet = wb.createSheet();
         assertEquals(-1, sheet.getSheet().findFirstRecordLocBySid(SCLRecord.sid));
-        sheet.setZoom(3,4);
+        sheet.setZoom(75);
         assertTrue(sheet.getSheet().findFirstRecordLocBySid(SCLRecord.sid) > 0);
         SCLRecord sclRecord = (SCLRecord) sheet.getSheet().findFirstRecordBySid(SCLRecord.sid);
-        assertEquals(3, sclRecord.getNumerator());
-        assertEquals(4, sclRecord.getDenominator());
+        assertEquals(75, 100*sclRecord.getNumerator()/sclRecord.getDenominator());
 
         int sclLoc = sheet.getSheet().findFirstRecordLocBySid(SCLRecord.sid);
         int window2Loc = sheet.getSheet().findFirstRecordLocBySid(WindowTwoRecord.sid);
@@ -535,13 +534,13 @@ public final class TestHSSFSheet extends BaseTestSheet {
         
         // verify limits
         try {
-            sheet.setZoom(0, 2);
+            sheet.setZoom(0);
             fail("Should catch Exception here");
         } catch (IllegalArgumentException e) {
             assertEquals("Numerator must be greater than 0 and less than 65536", e.getMessage());
         }
         try {
-            sheet.setZoom(65536, 2);
+            sheet.setZoom(65536);
             fail("Should catch Exception here");
         } catch (IllegalArgumentException e) {
             assertEquals("Numerator must be greater than 0 and less than 65536", e.getMessage());
index 87340c9a6b146da5e7a75439146495837a602897..b12478070ee2e97a6e8fb65ccdc1a482b7cbb5e2 100644 (file)
@@ -933,7 +933,7 @@ public abstract class BaseTestSheet {
         Sheet sheet = wb.createSheet();
         
         // here we can only verify that setting some zoom values works, range-checking is different between the implementations
-        sheet.setZoom(3,4);
+        sheet.setZoom(75);
         wb.close();
     }