From be77875e207b637bf791bf69bd70f4d0be35ae3c Mon Sep 17 00:00:00 2001 From: Javen O'Neal Date: Tue, 24 Nov 2015 07:34:09 +0000 Subject: [PATCH] bug 58642: remove deprecated functions in Spreadsheet Sheet interface and implementing classes; add @Override annotations git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1716046 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/poi/hssf/usermodel/HSSFSheet.java | 98 ++--------- .../org/apache/poi/ss/usermodel/Sheet.java | 12 -- .../apache/poi/xssf/streaming/SXSSFSheet.java | 21 +-- .../apache/poi/xssf/usermodel/XSSFSheet.java | 166 +----------------- .../apache/poi/xssf/TestSheetProtection.java | 30 ++-- .../poi/xssf/usermodel/TestXSSFSheet.java | 12 +- .../poi/hssf/usermodel/TestHSSFSheet.java | 13 +- 7 files changed, 54 insertions(+), 298 deletions(-) diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java b/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java index f1a1af7b7b..3aa609d753 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java @@ -454,42 +454,6 @@ public final class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet { dvt.addDataValidation(dvRecord); } - - /** - * @deprecated (Sep 2008) use {@link #setColumnHidden(int, boolean)} - */ - public void setColumnHidden(short columnIndex, boolean hidden) { - setColumnHidden(columnIndex & 0xFFFF, hidden); - } - - /** - * @deprecated (Sep 2008) use {@link #isColumnHidden(int)} - */ - public boolean isColumnHidden(short columnIndex) { - return isColumnHidden(columnIndex & 0xFFFF); - } - - /** - * @deprecated (Sep 2008) use {@link #setColumnWidth(int, int)} - */ - public void setColumnWidth(short columnIndex, short width) { - setColumnWidth(columnIndex & 0xFFFF, width & 0xFFFF); - } - - /** - * @deprecated (Sep 2008) use {@link #getColumnWidth(int)} - */ - public short getColumnWidth(short columnIndex) { - return (short) getColumnWidth(columnIndex & 0xFFFF); - } - - /** - * @deprecated (Sep 2008) use {@link #setDefaultColumnWidth(int)} - */ - public void setDefaultColumnWidth(short width) { - setDefaultColumnWidth(width & 0xFFFF); - } - /** * Get the visibility state for a given column. * @@ -759,6 +723,7 @@ public final class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet { * this worksheet values when the workbook is opened * @see org.apache.poi.ss.usermodel.Workbook#setForceFormulaRecalculation(boolean) */ + @Override public void setForceFormulaRecalculation(boolean value) { _sheet.setUncalced(value); } @@ -769,6 +734,7 @@ public final class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet { * * @return true if an uncalced record must be inserted or not at generation */ + @Override public boolean getForceFormulaRecalculation() { return _sheet.getUncalced(); } @@ -779,23 +745,15 @@ public final class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet { * * @param value true to vertically center, false otherwise. */ - + @Override public void setVerticallyCenter(boolean value) { _sheet.getPageSettings().getVCenter().setVCenter(value); } - /** - * TODO: Boolean not needed, remove after next release - * - * @deprecated (Mar-2008) use getVerticallyCenter() instead - */ - public boolean getVerticallyCenter(boolean value) { - return getVerticallyCenter(); - } - /** * Determine whether printed output for this sheet will be vertically centered. */ + @Override public boolean getVerticallyCenter() { return _sheet.getPageSettings().getVCenter().getVCenter(); } @@ -805,7 +763,7 @@ public final class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet { * * @param value true to horizontally center, false otherwise. */ - + @Override public void setHorizontallyCenter(boolean value) { _sheet.getPageSettings().getHCenter().setHCenter(value); } @@ -813,9 +771,8 @@ public final class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet { /** * Determine whether printed output for this sheet will be horizontally centered. */ - + @Override public boolean getHorizontallyCenter() { - return _sheet.getPageSettings().getHCenter().getHCenter(); } @@ -824,6 +781,7 @@ public final class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet { * * @param value true for right to left, false otherwise. */ + @Override public void setRightToLeft(boolean value) { _sheet.getWindowTwo().setArabic(value); } @@ -833,6 +791,7 @@ public final class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet { * * @return whether the text is displayed in right-to-left mode in the window */ + @Override public boolean isRightToLeft() { return _sheet.getWindowTwo().getArabic(); } @@ -843,6 +802,7 @@ public final class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet { * @param index of the region to unmerge */ + @Override public void removeMergedRegion(int index) { _sheet.removeMergedRegion(index); } @@ -852,24 +812,15 @@ public final class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet { * * @return number of merged regions */ - + @Override public int getNumMergedRegions() { return _sheet.getNumMergedRegions(); } - /** - * @deprecated (Aug-2008) use {@link HSSFSheet#getMergedRegion(int)} - */ - public org.apache.poi.hssf.util.Region getMergedRegionAt(int index) { - CellRangeAddress cra = getMergedRegion(index); - - return new org.apache.poi.hssf.util.Region(cra.getFirstRow(), (short) cra.getFirstColumn(), - cra.getLastRow(), (short) cra.getLastColumn()); - } - /** * @return the merged region at the specified index */ + @Override public CellRangeAddress getMergedRegion(int index) { return _sheet.getMergedRegionAt(index); } @@ -877,6 +828,7 @@ public final class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet { /** * @return the list of merged regions */ + @Override public List getMergedRegions() { List addresses = new ArrayList(); for (int i=0; i < _sheet.getNumMergedRegions(); i++) { @@ -890,6 +842,7 @@ public final class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet { * be the third row if say for instance the second row is undefined. * Call getRowNum() on each row if you care which one it is. */ + @Override public Iterator rowIterator() { @SuppressWarnings("unchecked") // can this clumsy generic syntax be improved? Iterator result = (Iterator) (Iterator) _rows.values().iterator(); @@ -1281,6 +1234,7 @@ public final class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet { * @param numerator The numerator for the zoom magnification. * @param denominator The denominator for the zoom magnification. */ + @Override public void setZoom(int numerator, int denominator) { if (numerator < 1 || numerator > 65535) throw new IllegalArgumentException("Numerator must be greater than 0 and less than 65536"); @@ -1320,6 +1274,7 @@ public final class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet { * @param toprow the top row to show in desktop window pane * @param leftcol the left column to show in desktop window pane */ + @Override public void showInPane(int toprow, int leftcol) { int maxrow = SpreadsheetVersion.EXCEL97.getLastRowIndex(); if (toprow > maxrow) throw new IllegalArgumentException("Maximum row number is " + maxrow); @@ -1333,7 +1288,7 @@ public final class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet { * @param toprow the top row to show in desktop window pane * @param leftcol the left column to show in desktop window pane */ - public void showInPane(short toprow, short leftcol) { + private void showInPane(short toprow, short leftcol) { _sheet.setTopRow(toprow); _sheet.setLeftCol(leftcol); } @@ -1925,27 +1880,6 @@ public final class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet { return new HSSFPatriarch(this, agg); } - /** - * @deprecated (Sep 2008) use {@link #setColumnGroupCollapsed(int, boolean)} - */ - public void setColumnGroupCollapsed(short columnNumber, boolean collapsed) { - setColumnGroupCollapsed(columnNumber & 0xFFFF, collapsed); - } - - /** - * @deprecated (Sep 2008) use {@link #groupColumn(int, int)} - */ - public void groupColumn(short fromColumn, short toColumn) { - groupColumn(fromColumn & 0xFFFF, toColumn & 0xFFFF); - } - - /** - * @deprecated (Sep 2008) use {@link #ungroupColumn(int, int)} - */ - public void ungroupColumn(short fromColumn, short toColumn) { - ungroupColumn(fromColumn & 0xFFFF, toColumn & 0xFFFF); - } - /** * Expands or collapses a column group. * diff --git a/src/java/org/apache/poi/ss/usermodel/Sheet.java b/src/java/org/apache/poi/ss/usermodel/Sheet.java index 5a9b05fb57..7aaffc2575 100644 --- a/src/java/org/apache/poi/ss/usermodel/Sheet.java +++ b/src/java/org/apache/poi/ss/usermodel/Sheet.java @@ -24,7 +24,6 @@ import java.util.Map; import org.apache.poi.hssf.util.PaneInformation; import org.apache.poi.ss.util.CellAddress; import org.apache.poi.ss.util.CellRangeAddress; -import org.apache.poi.ss.util.CellReference; /** * High level representation of a Excel worksheet. @@ -610,17 +609,6 @@ public interface Sheet extends Iterable { */ void showInPane(int toprow, int leftcol); - /** - * Sets desktop window pane display area, when the - * file is first opened in a viewer. - * - * @param toprow the top row to show in desktop window pane - * @param leftcol the left column to show in desktop window pane - * @deprecated Use {@link #showInPane(int, int)} as there can be more than 32767 rows. - */ - @Deprecated - void showInPane(short toprow, short leftcol); - /** * Shifts rows between startRow and endRow n number of rows. * If you use a negative number, it will shift rows up. diff --git a/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFSheet.java b/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFSheet.java index c232286881..4fd9da7392 100644 --- a/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFSheet.java +++ b/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFSheet.java @@ -42,7 +42,6 @@ import org.apache.poi.ss.usermodel.SheetConditionalFormatting; import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.util.CellAddress; import org.apache.poi.ss.util.CellRangeAddress; -import org.apache.poi.ss.util.CellReference; import org.apache.poi.ss.util.SheetUtil; import org.apache.poi.xssf.usermodel.XSSFComment; import org.apache.poi.xssf.usermodel.XSSFDataValidation; @@ -753,6 +752,7 @@ public class SXSSFSheet implements Sheet, Cloneable * Sets the protection enabled as well as the password * @param password to set for protection. Pass null to remove protection */ + @Override public void protectSheet(String password) { _sh.protectSheet(password); @@ -763,6 +763,7 @@ public class SXSSFSheet implements Sheet, Cloneable * * @return true => protection enabled; false => protection disabled */ + @Override public boolean getScenarioProtect() { return _sh.getScenarioProtect(); @@ -776,6 +777,7 @@ public class SXSSFSheet implements Sheet, Cloneable * @param numerator The numerator for the zoom magnification. * @param denominator The denominator for the zoom magnification. */ + @Override public void setZoom(int numerator, int denominator) { _sh.setZoom(numerator,denominator); @@ -787,6 +789,7 @@ public class SXSSFSheet implements Sheet, Cloneable * * @return short indicating the rownum (0 based) of the top row */ + @Override public short getTopRow() { return _sh.getTopRow(); @@ -798,6 +801,7 @@ public class SXSSFSheet implements Sheet, Cloneable * * @return short indicating the rownum (0 based) of the top row */ + @Override public short getLeftCol() { return _sh.getLeftCol(); @@ -810,25 +814,12 @@ public class SXSSFSheet implements Sheet, Cloneable * @param toprow the top row to show in desktop window pane * @param leftcol the left column to show in desktop window pane */ + @Override public void showInPane(int toprow, int leftcol) { _sh.showInPane(toprow, leftcol); } - /** - * Sets desktop window pane display area, when the - * file is first opened in a viewer. - * - * @param toprow the top row to show in desktop window pane - * @param leftcol the left column to show in desktop window pane - * - * @deprecated Use the version of showInPane() with ints as there can be more than 32767 rows. - */ - public void showInPane(short toprow, short leftcol) - { - _sh.showInPane(toprow, leftcol); - } - /** * Control if Excel should be asked to recalculate all formulas when the * workbook is opened, via the "sheetCalcPr fullCalcOnLoad" option. diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java index cc66fba926..856b8fcc3e 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java @@ -606,19 +606,6 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet { sel.setPane(pane.getActivePane()); } - /** - * Creates a new comment for this sheet. You still - * need to assign it to a cell though - * - * @deprecated since Nov 2009 this method is not compatible with the common SS interfaces, - * use {@link org.apache.poi.xssf.usermodel.XSSFDrawing#createCellComment - * (org.apache.poi.ss.usermodel.ClientAnchor)} instead - */ - @Deprecated - public XSSFComment createComment() { - return createDrawingPatriarch().createCellComment(new XSSFClientAnchor()); - } - /** * Create a new row within the sheet and return the high level representation * @@ -2627,7 +2614,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet { } /** - * Sets the zoom magnication for the sheet. The zoom is expressed as a + * Sets the zoom magnification for the sheet. The zoom is expressed as a * fraction. For example to express a zoom of 75% use 3 for the numerator * and 4 for the denominator. * @@ -2697,7 +2684,6 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet { // check row numbers to make sure they are continuous and increasing (monotonic) // and srcRows does not contain null rows for (int index=1; index < srcRows.size(); index++) { - final Row prevRow = srcRows.get(index-1); final Row curRow = srcRows.get(index); if (curRow == null) { throw new IllegalArgumentException("srcRows may not contain null rows. Found null row at index " + index + "."); @@ -2989,21 +2975,6 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet { getPane().setTopLeftCell(cellRef); } - /** - * Location of the top left visible cell Location of the top left visible cell in the bottom right - * pane (when in Left-to-Right mode). - * - * @param toprow the top row to show in desktop window pane - * @param leftcol the left column to show in desktop window pane - * - * @deprecated Use {@link #showInPane(int, int)} as there can be more than 32767 rows. - */ - @Override - @Deprecated - public void showInPane(short toprow, short leftcol) { - showInPane((int)toprow, (int)leftcol); - } - @Override public void ungroupColumn(int fromColumn, int toColumn) { CTCols cols = worksheet.getColsArray(0); @@ -3101,21 +3072,6 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet { } } - /** - * Assign a cell comment to a cell region in this worksheet - * - * @param cellRef cell region - * @param comment the comment to assign - * @deprecated since Nov 2009 use {@link XSSFCell#setCellComment(org.apache.poi.ss.usermodel.Comment)} instead - */ - @Deprecated - public static void setCellComment(String cellRef, XSSFComment comment) { - CellReference cellReference = new CellReference(cellRef); - - comment.setRow(cellReference.getRow()); - comment.setColumn(cellReference.getCol()); - } - /** * Register a hyperlink in the collection of hyperlinks on this sheet * @@ -3472,14 +3428,6 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet { safeGetProtectionField().setSheet(false); } - /** - * Enable Autofilters locking. - * @deprecated use {@link #lockAutoFilter(boolean)} - */ - public void lockAutoFilter() { - lockAutoFilter(true); - } - /** * Enable or disable Autofilters locking. * This does not modify sheet protection status. @@ -3489,14 +3437,6 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet { safeGetProtectionField().setAutoFilter(enabled); } - /** - * Enable Deleting columns locking. - * @deprecated use {@link #lockDeleteColumns(boolean)} - */ - public void lockDeleteColumns() { - lockDeleteColumns(true); - } - /** * Enable or disable Deleting columns locking. * This does not modify sheet protection status. @@ -3506,14 +3446,6 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet { safeGetProtectionField().setDeleteColumns(enabled); } - /** - * Enable Deleting rows locking. - * @deprecated use {@link #lockDeleteRows(boolean)} - */ - public void lockDeleteRows() { - lockDeleteRows(true); - } - /** * Enable or disable Deleting rows locking. * This does not modify sheet protection status. @@ -3523,14 +3455,6 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet { safeGetProtectionField().setDeleteRows(enabled); } - /** - * Enable Formatting cells locking. - * @deprecated use {@link #lockFormatCells(boolean)} - */ - public void lockFormatCells() { - lockFormatCells(true); - } - /** * Enable or disable Formatting cells locking. * This does not modify sheet protection status. @@ -3540,14 +3464,6 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet { safeGetProtectionField().setFormatCells(enabled); } - /** - * Enable Formatting columns locking. - * @deprecated use {@link #lockFormatColumns(boolean)} - */ - public void lockFormatColumns() { - lockFormatColumns(true); - } - /** * Enable or disable Formatting columns locking. * This does not modify sheet protection status. @@ -3557,14 +3473,6 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet { safeGetProtectionField().setFormatColumns(enabled); } - /** - * Enable Formatting rows locking. - * @deprecated use {@link #lockFormatRows(boolean)} - */ - public void lockFormatRows() { - lockFormatRows(true); - } - /** * Enable or disable Formatting rows locking. * This does not modify sheet protection status. @@ -3574,14 +3482,6 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet { safeGetProtectionField().setFormatRows(enabled); } - /** - * Enable Inserting columns locking. - * @deprecated use {@link #lockInsertColumns(boolean)} - */ - public void lockInsertColumns() { - lockInsertColumns(true); - } - /** * Enable or disable Inserting columns locking. * This does not modify sheet protection status. @@ -3591,14 +3491,6 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet { safeGetProtectionField().setInsertColumns(enabled); } - /** - * Enable Inserting hyperlinks locking. - * @deprecated use {@link #lockInsertHyperlinks(boolean)} - */ - public void lockInsertHyperlinks() { - lockInsertHyperlinks(true); - } - /** * Enable or disable Inserting hyperlinks locking. * This does not modify sheet protection status. @@ -3608,14 +3500,6 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet { safeGetProtectionField().setInsertHyperlinks(enabled); } - /** - * Enable Inserting rows locking. - * @deprecated use {@link #lockInsertRows(boolean)} - */ - public void lockInsertRows() { - lockInsertRows(true); - } - /** * Enable or disable Inserting rows locking. * This does not modify sheet protection status. @@ -3625,14 +3509,6 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet { safeGetProtectionField().setInsertRows(enabled); } - /** - * Enable Pivot Tables locking. - * @deprecated use {@link #lockPivotTables(boolean)} - */ - public void lockPivotTables() { - lockPivotTables(true); - } - /** * Enable or disable Pivot Tables locking. * This does not modify sheet protection status. @@ -3642,14 +3518,6 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet { safeGetProtectionField().setPivotTables(enabled); } - /** - * Enable Sort locking. - * @deprecated use {@link #lockSort(boolean)} - */ - public void lockSort() { - lockSort(true); - } - /** * Enable or disable Sort locking. * This does not modify sheet protection status. @@ -3659,14 +3527,6 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet { safeGetProtectionField().setSort(enabled); } - /** - * Enable Objects locking. - * @deprecated use {@link #lockObjects(boolean)} - */ - public void lockObjects() { - lockObjects(true); - } - /** * Enable or disable Objects locking. * This does not modify sheet protection status. @@ -3676,14 +3536,6 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet { safeGetProtectionField().setObjects(enabled); } - /** - * Enable Scenarios locking. - * @deprecated use {@link #lockScenarios(boolean)} - */ - public void lockScenarios() { - lockScenarios(true); - } - /** * Enable or disable Scenarios locking. * This does not modify sheet protection status. @@ -3693,14 +3545,6 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet { safeGetProtectionField().setScenarios(enabled); } - /** - * Enable Selection of locked cells locking. - * @deprecated use {@link #lockSelectLockedCells(boolean)} - */ - public void lockSelectLockedCells() { - lockSelectLockedCells(true); - } - /** * Enable or disable Selection of locked cells locking. * This does not modify sheet protection status. @@ -3710,14 +3554,6 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet { safeGetProtectionField().setSelectLockedCells(enabled); } - /** - * Enable Selection of unlocked cells locking. - * @deprecated use {@link #lockSelectUnlockedCells(boolean)} - */ - public void lockSelectUnlockedCells() { - lockSelectUnlockedCells(true); - } - /** * Enable or disable Selection of unlocked cells locking. * This does not modify sheet protection status. diff --git a/src/ooxml/testcases/org/apache/poi/xssf/TestSheetProtection.java b/src/ooxml/testcases/org/apache/poi/xssf/TestSheetProtection.java index f90804fa4c..9e126097c3 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/TestSheetProtection.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/TestSheetProtection.java @@ -70,7 +70,7 @@ public class TestSheetProtection extends TestCase { public void testWriteAutoFilter() throws Exception { assertFalse(sheet.isAutoFilterLocked()); - sheet.lockAutoFilter(); + sheet.lockAutoFilter(true); assertFalse(sheet.isAutoFilterLocked()); sheet.enableLocking(); assertTrue(sheet.isAutoFilterLocked()); @@ -80,7 +80,7 @@ public class TestSheetProtection extends TestCase { public void testWriteDeleteColumns() throws Exception { assertFalse(sheet.isDeleteColumnsLocked()); - sheet.lockDeleteColumns(); + sheet.lockDeleteColumns(true); assertFalse(sheet.isDeleteColumnsLocked()); sheet.enableLocking(); assertTrue(sheet.isDeleteColumnsLocked()); @@ -90,7 +90,7 @@ public class TestSheetProtection extends TestCase { public void testWriteDeleteRows() throws Exception { assertFalse(sheet.isDeleteRowsLocked()); - sheet.lockDeleteRows(); + sheet.lockDeleteRows(true); assertFalse(sheet.isDeleteRowsLocked()); sheet.enableLocking(); assertTrue(sheet.isDeleteRowsLocked()); @@ -100,7 +100,7 @@ public class TestSheetProtection extends TestCase { public void testWriteFormatCells() throws Exception { assertFalse(sheet.isFormatCellsLocked()); - sheet.lockFormatCells(); + sheet.lockFormatCells(true); assertFalse(sheet.isFormatCellsLocked()); sheet.enableLocking(); assertTrue(sheet.isFormatCellsLocked()); @@ -110,7 +110,7 @@ public class TestSheetProtection extends TestCase { public void testWriteFormatColumns() throws Exception { assertFalse(sheet.isFormatColumnsLocked()); - sheet.lockFormatColumns(); + sheet.lockFormatColumns(true); assertFalse(sheet.isFormatColumnsLocked()); sheet.enableLocking(); assertTrue(sheet.isFormatColumnsLocked()); @@ -120,7 +120,7 @@ public class TestSheetProtection extends TestCase { public void testWriteFormatRows() throws Exception { assertFalse(sheet.isFormatRowsLocked()); - sheet.lockFormatRows(); + sheet.lockFormatRows(true); assertFalse(sheet.isFormatRowsLocked()); sheet.enableLocking(); assertTrue(sheet.isFormatRowsLocked()); @@ -130,7 +130,7 @@ public class TestSheetProtection extends TestCase { public void testWriteInsertColumns() throws Exception { assertFalse(sheet.isInsertColumnsLocked()); - sheet.lockInsertColumns(); + sheet.lockInsertColumns(true); assertFalse(sheet.isInsertColumnsLocked()); sheet.enableLocking(); assertTrue(sheet.isInsertColumnsLocked()); @@ -140,7 +140,7 @@ public class TestSheetProtection extends TestCase { public void testWriteInsertHyperlinks() throws Exception { assertFalse(sheet.isInsertHyperlinksLocked()); - sheet.lockInsertHyperlinks(); + sheet.lockInsertHyperlinks(true); assertFalse(sheet.isInsertHyperlinksLocked()); sheet.enableLocking(); assertTrue(sheet.isInsertHyperlinksLocked()); @@ -150,7 +150,7 @@ public class TestSheetProtection extends TestCase { public void testWriteInsertRows() throws Exception { assertFalse(sheet.isInsertRowsLocked()); - sheet.lockInsertRows(); + sheet.lockInsertRows(true); assertFalse(sheet.isInsertRowsLocked()); sheet.enableLocking(); assertTrue(sheet.isInsertRowsLocked()); @@ -160,7 +160,7 @@ public class TestSheetProtection extends TestCase { public void testWritePivotTables() throws Exception { assertFalse(sheet.isPivotTablesLocked()); - sheet.lockPivotTables(); + sheet.lockPivotTables(true); assertFalse(sheet.isPivotTablesLocked()); sheet.enableLocking(); assertTrue(sheet.isPivotTablesLocked()); @@ -170,7 +170,7 @@ public class TestSheetProtection extends TestCase { public void testWriteSort() throws Exception { assertFalse(sheet.isSortLocked()); - sheet.lockSort(); + sheet.lockSort(true); assertFalse(sheet.isSortLocked()); sheet.enableLocking(); assertTrue(sheet.isSortLocked()); @@ -180,7 +180,7 @@ public class TestSheetProtection extends TestCase { public void testWriteObjects() throws Exception { assertFalse(sheet.isObjectsLocked()); - sheet.lockObjects(); + sheet.lockObjects(true); assertFalse(sheet.isObjectsLocked()); sheet.enableLocking(); assertTrue(sheet.isObjectsLocked()); @@ -190,7 +190,7 @@ public class TestSheetProtection extends TestCase { public void testWriteScenarios() throws Exception { assertFalse(sheet.isScenariosLocked()); - sheet.lockScenarios(); + sheet.lockScenarios(true); assertFalse(sheet.isScenariosLocked()); sheet.enableLocking(); assertTrue(sheet.isScenariosLocked()); @@ -200,7 +200,7 @@ public class TestSheetProtection extends TestCase { public void testWriteSelectLockedCells() throws Exception { assertFalse(sheet.isSelectLockedCellsLocked()); - sheet.lockSelectLockedCells(); + sheet.lockSelectLockedCells(true); assertFalse(sheet.isSelectLockedCellsLocked()); sheet.enableLocking(); assertTrue(sheet.isSelectLockedCellsLocked()); @@ -210,7 +210,7 @@ public class TestSheetProtection extends TestCase { public void testWriteSelectUnlockedCells() throws Exception { assertFalse(sheet.isSelectUnlockedCellsLocked()); - sheet.lockSelectUnlockedCells(); + sheet.lockSelectUnlockedCells(true); assertFalse(sheet.isSelectUnlockedCellsLocked()); sheet.enableLocking(); assertTrue(sheet.isSelectUnlockedCellsLocked()); 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 5043a3b977..e22f169726 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java @@ -44,6 +44,7 @@ import org.apache.poi.ss.usermodel.AutoFilter; import org.apache.poi.ss.usermodel.BaseTestSheet; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.CellCopyPolicy; +import org.apache.poi.ss.usermodel.ClientAnchor; import org.apache.poi.ss.usermodel.FormulaError; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; @@ -1437,12 +1438,19 @@ public final class TestXSSFSheet extends BaseTestSheet { sheet.onDocumentRead(); } - @SuppressWarnings("deprecation") + /** + * This would be better off as a testable example rather than a simple unit test + * since Sheet.createComment() was deprecated and removed. + * https://poi.apache.org/spreadsheet/quick-guide.html#CellComments + * Feel free to relocated or delete this unit test if it doesn't belong here. + */ @Test public void testCreateComment() throws IOException { XSSFWorkbook wb = new XSSFWorkbook(); + ClientAnchor anchor = wb.getCreationHelper().createClientAnchor(); XSSFSheet sheet = wb.createSheet(); - assertNotNull(sheet.createComment()); + XSSFComment comment = sheet.createDrawingPatriarch().createCellComment(anchor); + assertNotNull(comment); wb.close(); } diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java index c60823ee8e..c7298fda21 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java @@ -128,7 +128,6 @@ public final class TestHSSFSheet extends BaseTestSheet { /** * Test vertically centered output. */ - @SuppressWarnings("deprecation") @Test public void verticallyCenter() throws IOException { HSSFWorkbook wb = new HSSFWorkbook(); @@ -136,12 +135,10 @@ public final class TestHSSFSheet extends BaseTestSheet { VCenterRecord record = s.getSheet().getPageSettings().getVCenter(); assertFalse(record.getVCenter()); - assertFalse(s.getVerticallyCenter(true)); - assertFalse(s.getVerticallyCenter(false)); + assertFalse(s.getVerticallyCenter()); s.setVerticallyCenter(true); assertTrue(record.getVCenter()); - assertTrue(s.getVerticallyCenter(true)); - assertTrue(s.getVerticallyCenter(false)); + assertTrue(s.getVerticallyCenter()); wb.close(); } @@ -156,8 +153,11 @@ public final class TestHSSFSheet extends BaseTestSheet { HCenterRecord record = s.getSheet().getPageSettings().getHCenter(); assertFalse(record.getHCenter()); + assertFalse(s.getHorizontallyCenter()); s.setHorizontallyCenter(true); assertTrue(record.getHCenter()); + assertTrue(s.getHorizontallyCenter()); + wb.close(); } @@ -650,7 +650,6 @@ public final class TestHSSFSheet extends BaseTestSheet { wb2.close(); } - @SuppressWarnings("deprecation") @Test public void autoSizeColumn() throws IOException { HSSFWorkbook wb1 = HSSFTestDataSamples.openSampleWorkbook("43902.xls"); @@ -675,7 +674,7 @@ public final class TestHSSFSheet extends BaseTestSheet { //create a region over the 2nd row and auto size the first column sheet.addMergedRegion(new CellRangeAddress(1,1,0,1)); - assertNotNull(sheet.getMergedRegionAt(0)); + assertNotNull(sheet.getMergedRegion(0)); sheet.autoSizeColumn((short)0); HSSFWorkbook wb2 = HSSFTestDataSamples.writeOutAndReadBack(wb1); -- 2.39.5