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
This commit is contained in:
Javen O'Neal 2015-11-24 08:04:42 +00:00
parent e7d29ad533
commit 735c43ec9d
7 changed files with 11 additions and 12 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>ApachePOI</name>
<name>ApachePOI-bug58365</name>
<comment></comment>
<projects>
</projects>

View 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();
}
}

View 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

View 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);
}
/**

View 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);

View 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());

View 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();
}