From: Javen O'Neal Date: Tue, 24 Nov 2015 08:04:42 +0000 (+0000) Subject: bug 58644: fix HSSFSheet.setZoom(int); update documentation to use non-deprecated... X-Git-Tag: REL_3_14_BETA1~87 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=7bd18248e018e328ddb54fc57c9f4c40277508d5;p=poi.git bug 58644: fix HSSFSheet.setZoom(int); update documentation to use non-deprecated method git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1716053 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/.project b/.project index 274051f30a..e6dc28da20 100644 --- a/.project +++ b/.project @@ -1,6 +1,6 @@ - ApachePOI + ApachePOI-bug58365 diff --git a/src/examples/src/org/apache/poi/hssf/usermodel/examples/ZoomSheet.java b/src/examples/src/org/apache/poi/hssf/usermodel/examples/ZoomSheet.java index c65c62f18f..f83b5900e8 100644 --- a/src/examples/src/org/apache/poi/hssf/usermodel/examples/ZoomSheet.java +++ b/src/examples/src/org/apache/poi/hssf/usermodel/examples/ZoomSheet.java @@ -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(); } } diff --git a/src/examples/src/org/apache/poi/ss/examples/BusinessPlan.java b/src/examples/src/org/apache/poi/ss/examples/BusinessPlan.java index 101eceda7b..a3054d9d74 100644 --- a/src/examples/src/org/apache/poi/ss/examples/BusinessPlan.java +++ b/src/examples/src/org/apache/poi/ss/examples/BusinessPlan.java @@ -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 diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java b/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java index 0a6c0c432a..862f08ce96 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java @@ -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); } /** diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java index 34e5ae4960..336901a13d 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java @@ -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); diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java index d21930b471..8d64bf14f9 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java @@ -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()); diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheet.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheet.java index 87340c9a6b..b12478070e 100644 --- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheet.java +++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheet.java @@ -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(); }