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
This commit is contained in:
Javen O'Neal 2015-11-24 07:34:09 +00:00
parent 6c7a9314db
commit be77875e20
7 changed files with 54 additions and 298 deletions

View File

@ -454,42 +454,6 @@ public final class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet {
dvt.addDataValidation(dvRecord); 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. * 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 * this worksheet values when the workbook is opened
* @see org.apache.poi.ss.usermodel.Workbook#setForceFormulaRecalculation(boolean) * @see org.apache.poi.ss.usermodel.Workbook#setForceFormulaRecalculation(boolean)
*/ */
@Override
public void setForceFormulaRecalculation(boolean value) { public void setForceFormulaRecalculation(boolean value) {
_sheet.setUncalced(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 * @return true if an uncalced record must be inserted or not at generation
*/ */
@Override
public boolean getForceFormulaRecalculation() { public boolean getForceFormulaRecalculation() {
return _sheet.getUncalced(); 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. * @param value true to vertically center, false otherwise.
*/ */
@Override
public void setVerticallyCenter(boolean value) { public void setVerticallyCenter(boolean value) {
_sheet.getPageSettings().getVCenter().setVCenter(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. * Determine whether printed output for this sheet will be vertically centered.
*/ */
@Override
public boolean getVerticallyCenter() { public boolean getVerticallyCenter() {
return _sheet.getPageSettings().getVCenter().getVCenter(); 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. * @param value true to horizontally center, false otherwise.
*/ */
@Override
public void setHorizontallyCenter(boolean value) { public void setHorizontallyCenter(boolean value) {
_sheet.getPageSettings().getHCenter().setHCenter(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. * Determine whether printed output for this sheet will be horizontally centered.
*/ */
@Override
public boolean getHorizontallyCenter() { public boolean getHorizontallyCenter() {
return _sheet.getPageSettings().getHCenter().getHCenter(); 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. * @param value true for right to left, false otherwise.
*/ */
@Override
public void setRightToLeft(boolean value) { public void setRightToLeft(boolean value) {
_sheet.getWindowTwo().setArabic(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 * @return whether the text is displayed in right-to-left mode in the window
*/ */
@Override
public boolean isRightToLeft() { public boolean isRightToLeft() {
return _sheet.getWindowTwo().getArabic(); 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 * @param index of the region to unmerge
*/ */
@Override
public void removeMergedRegion(int index) { public void removeMergedRegion(int index) {
_sheet.removeMergedRegion(index); _sheet.removeMergedRegion(index);
} }
@ -852,24 +812,15 @@ public final class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet {
* *
* @return number of merged regions * @return number of merged regions
*/ */
@Override
public int getNumMergedRegions() { public int getNumMergedRegions() {
return _sheet.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 * @return the merged region at the specified index
*/ */
@Override
public CellRangeAddress getMergedRegion(int index) { public CellRangeAddress getMergedRegion(int index) {
return _sheet.getMergedRegionAt(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 * @return the list of merged regions
*/ */
@Override
public List<CellRangeAddress> getMergedRegions() { public List<CellRangeAddress> getMergedRegions() {
List<CellRangeAddress> addresses = new ArrayList<CellRangeAddress>(); List<CellRangeAddress> addresses = new ArrayList<CellRangeAddress>();
for (int i=0; i < _sheet.getNumMergedRegions(); i++) { 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. * 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. * Call getRowNum() on each row if you care which one it is.
*/ */
@Override
public Iterator<Row> rowIterator() { public Iterator<Row> rowIterator() {
@SuppressWarnings("unchecked") // can this clumsy generic syntax be improved? @SuppressWarnings("unchecked") // can this clumsy generic syntax be improved?
Iterator<Row> result = (Iterator<Row>) (Iterator<? extends Row>) _rows.values().iterator(); Iterator<Row> result = (Iterator<Row>) (Iterator<? extends Row>) _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 numerator The numerator for the zoom magnification.
* @param denominator The denominator for the zoom magnification. * @param denominator The denominator for the zoom magnification.
*/ */
@Override
public void setZoom(int numerator, int denominator) { public void setZoom(int numerator, int denominator) {
if (numerator < 1 || numerator > 65535) if (numerator < 1 || numerator > 65535)
throw new IllegalArgumentException("Numerator must be greater than 0 and less than 65536"); 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 toprow the top row to show in desktop window pane
* @param leftcol the left column 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) { public void showInPane(int toprow, int leftcol) {
int maxrow = SpreadsheetVersion.EXCEL97.getLastRowIndex(); int maxrow = SpreadsheetVersion.EXCEL97.getLastRowIndex();
if (toprow > maxrow) throw new IllegalArgumentException("Maximum row number is " + maxrow); 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 toprow the top row to show in desktop window pane
* @param leftcol the left column 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.setTopRow(toprow);
_sheet.setLeftCol(leftcol); _sheet.setLeftCol(leftcol);
} }
@ -1925,27 +1880,6 @@ public final class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet {
return new HSSFPatriarch(this, agg); 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. * Expands or collapses a column group.
* *

View File

@ -24,7 +24,6 @@ import java.util.Map;
import org.apache.poi.hssf.util.PaneInformation; import org.apache.poi.hssf.util.PaneInformation;
import org.apache.poi.ss.util.CellAddress; import org.apache.poi.ss.util.CellAddress;
import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.ss.util.CellReference;
/** /**
* High level representation of a Excel worksheet. * High level representation of a Excel worksheet.
@ -610,17 +609,6 @@ public interface Sheet extends Iterable<Row> {
*/ */
void showInPane(int toprow, int leftcol); 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. * Shifts rows between startRow and endRow n number of rows.
* If you use a negative number, it will shift rows up. * If you use a negative number, it will shift rows up.

View File

@ -42,7 +42,6 @@ import org.apache.poi.ss.usermodel.SheetConditionalFormatting;
import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.util.CellAddress; import org.apache.poi.ss.util.CellAddress;
import org.apache.poi.ss.util.CellRangeAddress; 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.ss.util.SheetUtil;
import org.apache.poi.xssf.usermodel.XSSFComment; import org.apache.poi.xssf.usermodel.XSSFComment;
import org.apache.poi.xssf.usermodel.XSSFDataValidation; 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 * Sets the protection enabled as well as the password
* @param password to set for protection. Pass <code>null</code> to remove protection * @param password to set for protection. Pass <code>null</code> to remove protection
*/ */
@Override
public void protectSheet(String password) public void protectSheet(String password)
{ {
_sh.protectSheet(password); _sh.protectSheet(password);
@ -763,6 +763,7 @@ public class SXSSFSheet implements Sheet, Cloneable
* *
* @return true => protection enabled; false => protection disabled * @return true => protection enabled; false => protection disabled
*/ */
@Override
public boolean getScenarioProtect() public boolean getScenarioProtect()
{ {
return _sh.getScenarioProtect(); return _sh.getScenarioProtect();
@ -776,6 +777,7 @@ public class SXSSFSheet implements Sheet, Cloneable
* @param numerator The numerator for the zoom magnification. * @param numerator The numerator for the zoom magnification.
* @param denominator The denominator for the zoom magnification. * @param denominator The denominator for the zoom magnification.
*/ */
@Override
public void setZoom(int numerator, int denominator) public void setZoom(int numerator, int denominator)
{ {
_sh.setZoom(numerator,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 * @return short indicating the rownum (0 based) of the top row
*/ */
@Override
public short getTopRow() public short getTopRow()
{ {
return _sh.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 * @return short indicating the rownum (0 based) of the top row
*/ */
@Override
public short getLeftCol() public short getLeftCol()
{ {
return _sh.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 toprow the top row to show in desktop window pane
* @param leftcol the left column 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) public void showInPane(int toprow, int leftcol)
{ {
_sh.showInPane(toprow, 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 * Control if Excel should be asked to recalculate all formulas when the
* workbook is opened, via the "sheetCalcPr fullCalcOnLoad" option. * workbook is opened, via the "sheetCalcPr fullCalcOnLoad" option.

View File

@ -606,19 +606,6 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
sel.setPane(pane.getActivePane()); 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 * 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 * fraction. For example to express a zoom of 75% use 3 for the numerator
* and 4 for the denominator. * 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) // check row numbers to make sure they are continuous and increasing (monotonic)
// and srcRows does not contain null rows // and srcRows does not contain null rows
for (int index=1; index < srcRows.size(); index++) { for (int index=1; index < srcRows.size(); index++) {
final Row prevRow = srcRows.get(index-1);
final Row curRow = srcRows.get(index); final Row curRow = srcRows.get(index);
if (curRow == null) { if (curRow == null) {
throw new IllegalArgumentException("srcRows may not contain null rows. Found null row at index " + index + "."); 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); 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 @Override
public void ungroupColumn(int fromColumn, int toColumn) { public void ungroupColumn(int fromColumn, int toColumn) {
CTCols cols = worksheet.getColsArray(0); 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 * 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); safeGetProtectionField().setSheet(false);
} }
/**
* Enable Autofilters locking.
* @deprecated use {@link #lockAutoFilter(boolean)}
*/
public void lockAutoFilter() {
lockAutoFilter(true);
}
/** /**
* Enable or disable Autofilters locking. * Enable or disable Autofilters locking.
* This does not modify sheet protection status. * This does not modify sheet protection status.
@ -3489,14 +3437,6 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
safeGetProtectionField().setAutoFilter(enabled); safeGetProtectionField().setAutoFilter(enabled);
} }
/**
* Enable Deleting columns locking.
* @deprecated use {@link #lockDeleteColumns(boolean)}
*/
public void lockDeleteColumns() {
lockDeleteColumns(true);
}
/** /**
* Enable or disable Deleting columns locking. * Enable or disable Deleting columns locking.
* This does not modify sheet protection status. * This does not modify sheet protection status.
@ -3506,14 +3446,6 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
safeGetProtectionField().setDeleteColumns(enabled); safeGetProtectionField().setDeleteColumns(enabled);
} }
/**
* Enable Deleting rows locking.
* @deprecated use {@link #lockDeleteRows(boolean)}
*/
public void lockDeleteRows() {
lockDeleteRows(true);
}
/** /**
* Enable or disable Deleting rows locking. * Enable or disable Deleting rows locking.
* This does not modify sheet protection status. * This does not modify sheet protection status.
@ -3523,14 +3455,6 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
safeGetProtectionField().setDeleteRows(enabled); safeGetProtectionField().setDeleteRows(enabled);
} }
/**
* Enable Formatting cells locking.
* @deprecated use {@link #lockFormatCells(boolean)}
*/
public void lockFormatCells() {
lockFormatCells(true);
}
/** /**
* Enable or disable Formatting cells locking. * Enable or disable Formatting cells locking.
* This does not modify sheet protection status. * This does not modify sheet protection status.
@ -3540,14 +3464,6 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
safeGetProtectionField().setFormatCells(enabled); safeGetProtectionField().setFormatCells(enabled);
} }
/**
* Enable Formatting columns locking.
* @deprecated use {@link #lockFormatColumns(boolean)}
*/
public void lockFormatColumns() {
lockFormatColumns(true);
}
/** /**
* Enable or disable Formatting columns locking. * Enable or disable Formatting columns locking.
* This does not modify sheet protection status. * This does not modify sheet protection status.
@ -3557,14 +3473,6 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
safeGetProtectionField().setFormatColumns(enabled); safeGetProtectionField().setFormatColumns(enabled);
} }
/**
* Enable Formatting rows locking.
* @deprecated use {@link #lockFormatRows(boolean)}
*/
public void lockFormatRows() {
lockFormatRows(true);
}
/** /**
* Enable or disable Formatting rows locking. * Enable or disable Formatting rows locking.
* This does not modify sheet protection status. * This does not modify sheet protection status.
@ -3574,14 +3482,6 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
safeGetProtectionField().setFormatRows(enabled); safeGetProtectionField().setFormatRows(enabled);
} }
/**
* Enable Inserting columns locking.
* @deprecated use {@link #lockInsertColumns(boolean)}
*/
public void lockInsertColumns() {
lockInsertColumns(true);
}
/** /**
* Enable or disable Inserting columns locking. * Enable or disable Inserting columns locking.
* This does not modify sheet protection status. * This does not modify sheet protection status.
@ -3591,14 +3491,6 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
safeGetProtectionField().setInsertColumns(enabled); safeGetProtectionField().setInsertColumns(enabled);
} }
/**
* Enable Inserting hyperlinks locking.
* @deprecated use {@link #lockInsertHyperlinks(boolean)}
*/
public void lockInsertHyperlinks() {
lockInsertHyperlinks(true);
}
/** /**
* Enable or disable Inserting hyperlinks locking. * Enable or disable Inserting hyperlinks locking.
* This does not modify sheet protection status. * This does not modify sheet protection status.
@ -3608,14 +3500,6 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
safeGetProtectionField().setInsertHyperlinks(enabled); safeGetProtectionField().setInsertHyperlinks(enabled);
} }
/**
* Enable Inserting rows locking.
* @deprecated use {@link #lockInsertRows(boolean)}
*/
public void lockInsertRows() {
lockInsertRows(true);
}
/** /**
* Enable or disable Inserting rows locking. * Enable or disable Inserting rows locking.
* This does not modify sheet protection status. * This does not modify sheet protection status.
@ -3625,14 +3509,6 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
safeGetProtectionField().setInsertRows(enabled); safeGetProtectionField().setInsertRows(enabled);
} }
/**
* Enable Pivot Tables locking.
* @deprecated use {@link #lockPivotTables(boolean)}
*/
public void lockPivotTables() {
lockPivotTables(true);
}
/** /**
* Enable or disable Pivot Tables locking. * Enable or disable Pivot Tables locking.
* This does not modify sheet protection status. * This does not modify sheet protection status.
@ -3642,14 +3518,6 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
safeGetProtectionField().setPivotTables(enabled); safeGetProtectionField().setPivotTables(enabled);
} }
/**
* Enable Sort locking.
* @deprecated use {@link #lockSort(boolean)}
*/
public void lockSort() {
lockSort(true);
}
/** /**
* Enable or disable Sort locking. * Enable or disable Sort locking.
* This does not modify sheet protection status. * This does not modify sheet protection status.
@ -3659,14 +3527,6 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
safeGetProtectionField().setSort(enabled); safeGetProtectionField().setSort(enabled);
} }
/**
* Enable Objects locking.
* @deprecated use {@link #lockObjects(boolean)}
*/
public void lockObjects() {
lockObjects(true);
}
/** /**
* Enable or disable Objects locking. * Enable or disable Objects locking.
* This does not modify sheet protection status. * This does not modify sheet protection status.
@ -3676,14 +3536,6 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
safeGetProtectionField().setObjects(enabled); safeGetProtectionField().setObjects(enabled);
} }
/**
* Enable Scenarios locking.
* @deprecated use {@link #lockScenarios(boolean)}
*/
public void lockScenarios() {
lockScenarios(true);
}
/** /**
* Enable or disable Scenarios locking. * Enable or disable Scenarios locking.
* This does not modify sheet protection status. * This does not modify sheet protection status.
@ -3693,14 +3545,6 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
safeGetProtectionField().setScenarios(enabled); 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. * Enable or disable Selection of locked cells locking.
* This does not modify sheet protection status. * This does not modify sheet protection status.
@ -3710,14 +3554,6 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
safeGetProtectionField().setSelectLockedCells(enabled); 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. * Enable or disable Selection of unlocked cells locking.
* This does not modify sheet protection status. * This does not modify sheet protection status.

View File

@ -70,7 +70,7 @@ public class TestSheetProtection extends TestCase {
public void testWriteAutoFilter() throws Exception { public void testWriteAutoFilter() throws Exception {
assertFalse(sheet.isAutoFilterLocked()); assertFalse(sheet.isAutoFilterLocked());
sheet.lockAutoFilter(); sheet.lockAutoFilter(true);
assertFalse(sheet.isAutoFilterLocked()); assertFalse(sheet.isAutoFilterLocked());
sheet.enableLocking(); sheet.enableLocking();
assertTrue(sheet.isAutoFilterLocked()); assertTrue(sheet.isAutoFilterLocked());
@ -80,7 +80,7 @@ public class TestSheetProtection extends TestCase {
public void testWriteDeleteColumns() throws Exception { public void testWriteDeleteColumns() throws Exception {
assertFalse(sheet.isDeleteColumnsLocked()); assertFalse(sheet.isDeleteColumnsLocked());
sheet.lockDeleteColumns(); sheet.lockDeleteColumns(true);
assertFalse(sheet.isDeleteColumnsLocked()); assertFalse(sheet.isDeleteColumnsLocked());
sheet.enableLocking(); sheet.enableLocking();
assertTrue(sheet.isDeleteColumnsLocked()); assertTrue(sheet.isDeleteColumnsLocked());
@ -90,7 +90,7 @@ public class TestSheetProtection extends TestCase {
public void testWriteDeleteRows() throws Exception { public void testWriteDeleteRows() throws Exception {
assertFalse(sheet.isDeleteRowsLocked()); assertFalse(sheet.isDeleteRowsLocked());
sheet.lockDeleteRows(); sheet.lockDeleteRows(true);
assertFalse(sheet.isDeleteRowsLocked()); assertFalse(sheet.isDeleteRowsLocked());
sheet.enableLocking(); sheet.enableLocking();
assertTrue(sheet.isDeleteRowsLocked()); assertTrue(sheet.isDeleteRowsLocked());
@ -100,7 +100,7 @@ public class TestSheetProtection extends TestCase {
public void testWriteFormatCells() throws Exception { public void testWriteFormatCells() throws Exception {
assertFalse(sheet.isFormatCellsLocked()); assertFalse(sheet.isFormatCellsLocked());
sheet.lockFormatCells(); sheet.lockFormatCells(true);
assertFalse(sheet.isFormatCellsLocked()); assertFalse(sheet.isFormatCellsLocked());
sheet.enableLocking(); sheet.enableLocking();
assertTrue(sheet.isFormatCellsLocked()); assertTrue(sheet.isFormatCellsLocked());
@ -110,7 +110,7 @@ public class TestSheetProtection extends TestCase {
public void testWriteFormatColumns() throws Exception { public void testWriteFormatColumns() throws Exception {
assertFalse(sheet.isFormatColumnsLocked()); assertFalse(sheet.isFormatColumnsLocked());
sheet.lockFormatColumns(); sheet.lockFormatColumns(true);
assertFalse(sheet.isFormatColumnsLocked()); assertFalse(sheet.isFormatColumnsLocked());
sheet.enableLocking(); sheet.enableLocking();
assertTrue(sheet.isFormatColumnsLocked()); assertTrue(sheet.isFormatColumnsLocked());
@ -120,7 +120,7 @@ public class TestSheetProtection extends TestCase {
public void testWriteFormatRows() throws Exception { public void testWriteFormatRows() throws Exception {
assertFalse(sheet.isFormatRowsLocked()); assertFalse(sheet.isFormatRowsLocked());
sheet.lockFormatRows(); sheet.lockFormatRows(true);
assertFalse(sheet.isFormatRowsLocked()); assertFalse(sheet.isFormatRowsLocked());
sheet.enableLocking(); sheet.enableLocking();
assertTrue(sheet.isFormatRowsLocked()); assertTrue(sheet.isFormatRowsLocked());
@ -130,7 +130,7 @@ public class TestSheetProtection extends TestCase {
public void testWriteInsertColumns() throws Exception { public void testWriteInsertColumns() throws Exception {
assertFalse(sheet.isInsertColumnsLocked()); assertFalse(sheet.isInsertColumnsLocked());
sheet.lockInsertColumns(); sheet.lockInsertColumns(true);
assertFalse(sheet.isInsertColumnsLocked()); assertFalse(sheet.isInsertColumnsLocked());
sheet.enableLocking(); sheet.enableLocking();
assertTrue(sheet.isInsertColumnsLocked()); assertTrue(sheet.isInsertColumnsLocked());
@ -140,7 +140,7 @@ public class TestSheetProtection extends TestCase {
public void testWriteInsertHyperlinks() throws Exception { public void testWriteInsertHyperlinks() throws Exception {
assertFalse(sheet.isInsertHyperlinksLocked()); assertFalse(sheet.isInsertHyperlinksLocked());
sheet.lockInsertHyperlinks(); sheet.lockInsertHyperlinks(true);
assertFalse(sheet.isInsertHyperlinksLocked()); assertFalse(sheet.isInsertHyperlinksLocked());
sheet.enableLocking(); sheet.enableLocking();
assertTrue(sheet.isInsertHyperlinksLocked()); assertTrue(sheet.isInsertHyperlinksLocked());
@ -150,7 +150,7 @@ public class TestSheetProtection extends TestCase {
public void testWriteInsertRows() throws Exception { public void testWriteInsertRows() throws Exception {
assertFalse(sheet.isInsertRowsLocked()); assertFalse(sheet.isInsertRowsLocked());
sheet.lockInsertRows(); sheet.lockInsertRows(true);
assertFalse(sheet.isInsertRowsLocked()); assertFalse(sheet.isInsertRowsLocked());
sheet.enableLocking(); sheet.enableLocking();
assertTrue(sheet.isInsertRowsLocked()); assertTrue(sheet.isInsertRowsLocked());
@ -160,7 +160,7 @@ public class TestSheetProtection extends TestCase {
public void testWritePivotTables() throws Exception { public void testWritePivotTables() throws Exception {
assertFalse(sheet.isPivotTablesLocked()); assertFalse(sheet.isPivotTablesLocked());
sheet.lockPivotTables(); sheet.lockPivotTables(true);
assertFalse(sheet.isPivotTablesLocked()); assertFalse(sheet.isPivotTablesLocked());
sheet.enableLocking(); sheet.enableLocking();
assertTrue(sheet.isPivotTablesLocked()); assertTrue(sheet.isPivotTablesLocked());
@ -170,7 +170,7 @@ public class TestSheetProtection extends TestCase {
public void testWriteSort() throws Exception { public void testWriteSort() throws Exception {
assertFalse(sheet.isSortLocked()); assertFalse(sheet.isSortLocked());
sheet.lockSort(); sheet.lockSort(true);
assertFalse(sheet.isSortLocked()); assertFalse(sheet.isSortLocked());
sheet.enableLocking(); sheet.enableLocking();
assertTrue(sheet.isSortLocked()); assertTrue(sheet.isSortLocked());
@ -180,7 +180,7 @@ public class TestSheetProtection extends TestCase {
public void testWriteObjects() throws Exception { public void testWriteObjects() throws Exception {
assertFalse(sheet.isObjectsLocked()); assertFalse(sheet.isObjectsLocked());
sheet.lockObjects(); sheet.lockObjects(true);
assertFalse(sheet.isObjectsLocked()); assertFalse(sheet.isObjectsLocked());
sheet.enableLocking(); sheet.enableLocking();
assertTrue(sheet.isObjectsLocked()); assertTrue(sheet.isObjectsLocked());
@ -190,7 +190,7 @@ public class TestSheetProtection extends TestCase {
public void testWriteScenarios() throws Exception { public void testWriteScenarios() throws Exception {
assertFalse(sheet.isScenariosLocked()); assertFalse(sheet.isScenariosLocked());
sheet.lockScenarios(); sheet.lockScenarios(true);
assertFalse(sheet.isScenariosLocked()); assertFalse(sheet.isScenariosLocked());
sheet.enableLocking(); sheet.enableLocking();
assertTrue(sheet.isScenariosLocked()); assertTrue(sheet.isScenariosLocked());
@ -200,7 +200,7 @@ public class TestSheetProtection extends TestCase {
public void testWriteSelectLockedCells() throws Exception { public void testWriteSelectLockedCells() throws Exception {
assertFalse(sheet.isSelectLockedCellsLocked()); assertFalse(sheet.isSelectLockedCellsLocked());
sheet.lockSelectLockedCells(); sheet.lockSelectLockedCells(true);
assertFalse(sheet.isSelectLockedCellsLocked()); assertFalse(sheet.isSelectLockedCellsLocked());
sheet.enableLocking(); sheet.enableLocking();
assertTrue(sheet.isSelectLockedCellsLocked()); assertTrue(sheet.isSelectLockedCellsLocked());
@ -210,7 +210,7 @@ public class TestSheetProtection extends TestCase {
public void testWriteSelectUnlockedCells() throws Exception { public void testWriteSelectUnlockedCells() throws Exception {
assertFalse(sheet.isSelectUnlockedCellsLocked()); assertFalse(sheet.isSelectUnlockedCellsLocked());
sheet.lockSelectUnlockedCells(); sheet.lockSelectUnlockedCells(true);
assertFalse(sheet.isSelectUnlockedCellsLocked()); assertFalse(sheet.isSelectUnlockedCellsLocked());
sheet.enableLocking(); sheet.enableLocking();
assertTrue(sheet.isSelectUnlockedCellsLocked()); assertTrue(sheet.isSelectUnlockedCellsLocked());

View File

@ -44,6 +44,7 @@ import org.apache.poi.ss.usermodel.AutoFilter;
import org.apache.poi.ss.usermodel.BaseTestSheet; import org.apache.poi.ss.usermodel.BaseTestSheet;
import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellCopyPolicy; 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.FormulaError;
import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Sheet;
@ -1437,12 +1438,19 @@ public final class TestXSSFSheet extends BaseTestSheet {
sheet.onDocumentRead(); 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 @Test
public void testCreateComment() throws IOException { public void testCreateComment() throws IOException {
XSSFWorkbook wb = new XSSFWorkbook(); XSSFWorkbook wb = new XSSFWorkbook();
ClientAnchor anchor = wb.getCreationHelper().createClientAnchor();
XSSFSheet sheet = wb.createSheet(); XSSFSheet sheet = wb.createSheet();
assertNotNull(sheet.createComment()); XSSFComment comment = sheet.createDrawingPatriarch().createCellComment(anchor);
assertNotNull(comment);
wb.close(); wb.close();
} }

View File

@ -128,7 +128,6 @@ public final class TestHSSFSheet extends BaseTestSheet {
/** /**
* Test vertically centered output. * Test vertically centered output.
*/ */
@SuppressWarnings("deprecation")
@Test @Test
public void verticallyCenter() throws IOException { public void verticallyCenter() throws IOException {
HSSFWorkbook wb = new HSSFWorkbook(); HSSFWorkbook wb = new HSSFWorkbook();
@ -136,12 +135,10 @@ public final class TestHSSFSheet extends BaseTestSheet {
VCenterRecord record = s.getSheet().getPageSettings().getVCenter(); VCenterRecord record = s.getSheet().getPageSettings().getVCenter();
assertFalse(record.getVCenter()); assertFalse(record.getVCenter());
assertFalse(s.getVerticallyCenter(true)); assertFalse(s.getVerticallyCenter());
assertFalse(s.getVerticallyCenter(false));
s.setVerticallyCenter(true); s.setVerticallyCenter(true);
assertTrue(record.getVCenter()); assertTrue(record.getVCenter());
assertTrue(s.getVerticallyCenter(true)); assertTrue(s.getVerticallyCenter());
assertTrue(s.getVerticallyCenter(false));
wb.close(); wb.close();
} }
@ -156,8 +153,11 @@ public final class TestHSSFSheet extends BaseTestSheet {
HCenterRecord record = s.getSheet().getPageSettings().getHCenter(); HCenterRecord record = s.getSheet().getPageSettings().getHCenter();
assertFalse(record.getHCenter()); assertFalse(record.getHCenter());
assertFalse(s.getHorizontallyCenter());
s.setHorizontallyCenter(true); s.setHorizontallyCenter(true);
assertTrue(record.getHCenter()); assertTrue(record.getHCenter());
assertTrue(s.getHorizontallyCenter());
wb.close(); wb.close();
} }
@ -650,7 +650,6 @@ public final class TestHSSFSheet extends BaseTestSheet {
wb2.close(); wb2.close();
} }
@SuppressWarnings("deprecation")
@Test @Test
public void autoSizeColumn() throws IOException { public void autoSizeColumn() throws IOException {
HSSFWorkbook wb1 = HSSFTestDataSamples.openSampleWorkbook("43902.xls"); 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 //create a region over the 2nd row and auto size the first column
sheet.addMergedRegion(new CellRangeAddress(1,1,0,1)); sheet.addMergedRegion(new CellRangeAddress(1,1,0,1));
assertNotNull(sheet.getMergedRegionAt(0)); assertNotNull(sheet.getMergedRegion(0));
sheet.autoSizeColumn((short)0); sheet.autoSizeColumn((short)0);
HSSFWorkbook wb2 = HSSFTestDataSamples.writeOutAndReadBack(wb1); HSSFWorkbook wb2 = HSSFTestDataSamples.writeOutAndReadBack(wb1);