remove some deprecated code slated for removal in 3.18

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1808402 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
PJ Fanning 2017-09-14 23:09:08 +00:00
parent 320d9735ca
commit 4d1907b447
9 changed files with 96 additions and 365 deletions

View File

@ -118,7 +118,6 @@ import org.apache.poi.util.LittleEndianByteArrayInputStream;
import org.apache.poi.util.LittleEndianByteArrayOutputStream;
import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger;
import org.apache.poi.util.Removal;
/**
* High level representation of a workbook. This is the first object most users
@ -767,26 +766,6 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
setSheetVisibility(sheetIx, hidden ? SheetVisibility.HIDDEN : SheetVisibility.VISIBLE);
}
@Removal(version="3.18")
@Deprecated
@Override
public void setSheetHidden(int sheetIx, int hidden) {
switch (hidden) {
case Workbook.SHEET_STATE_VISIBLE:
setSheetVisibility(sheetIx, SheetVisibility.VISIBLE);
break;
case Workbook.SHEET_STATE_HIDDEN:
setSheetVisibility(sheetIx, SheetVisibility.HIDDEN);
break;
case Workbook.SHEET_STATE_VERY_HIDDEN:
setSheetVisibility(sheetIx, SheetVisibility.VERY_HIDDEN);
break;
default:
throw new IllegalArgumentException("Invalid sheet state : " + hidden + "\n" +
"Sheet state must beone of the Workbook.SHEET_STATE_* constants");
}
}
@Override
public void setSheetVisibility(int sheetIx, SheetVisibility visibility) {
validateSheetIndex(sheetIx);
@ -2257,15 +2236,6 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
public boolean changeExternalReference(String oldUrl, String newUrl) {
return workbook.changeExternalReference(oldUrl, newUrl);
}
/**
* @deprecated POI 3.16 beta 1. use {@link POIDocument#getDirectory()} instead
*/
@Deprecated
@Removal(version="3.18")
public DirectoryNode getRootDirectory(){
return getDirectory();
}
@Internal
public InternalWorkbook getInternalWorkbook() {

View File

@ -19,12 +19,17 @@ package org.apache.poi.hssf.util;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.BorderStyle;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.ss.util.RegionUtil;
import org.apache.poi.util.Removal;
/**
* Various utility functions that make working with a region of cells easier.
* @deprecated POI 3.18
* @see RegionUtil
*/
@Removal(version="3.20")
public final class HSSFRegionUtil {
private HSSFRegionUtil() {
@ -42,7 +47,7 @@ public final class HSSFRegionUtil {
*/
public static void setBorderLeft(int border, CellRangeAddress region, HSSFSheet sheet,
HSSFWorkbook workbook) {
RegionUtil.setBorderLeft(border, region, sheet);
RegionUtil.setBorderLeft(BorderStyle.valueOf((short)border), region, sheet);
}
/**
@ -68,7 +73,7 @@ public final class HSSFRegionUtil {
*/
public static void setBorderRight(int border, CellRangeAddress region, HSSFSheet sheet,
HSSFWorkbook workbook) {
RegionUtil.setBorderRight(border, region, sheet);
RegionUtil.setBorderRight(BorderStyle.valueOf((short)border), region, sheet);
}
/**
@ -94,7 +99,7 @@ public final class HSSFRegionUtil {
*/
public static void setBorderBottom(int border, CellRangeAddress region, HSSFSheet sheet,
HSSFWorkbook workbook) {
RegionUtil.setBorderBottom(border, region, sheet);
RegionUtil.setBorderBottom(BorderStyle.valueOf((short)border), region, sheet);
}
/**
@ -120,7 +125,7 @@ public final class HSSFRegionUtil {
*/
public static void setBorderTop(int border, CellRangeAddress region, HSSFSheet sheet,
HSSFWorkbook workbook) {
RegionUtil.setBorderTop(border, region, sheet);
RegionUtil.setBorderTop(BorderStyle.valueOf((short)border), region, sheet);
}
/**

View File

@ -53,42 +53,6 @@ public interface Workbook extends Closeable, Iterable<Sheet> {
/** Device independent bitmap */
int PICTURE_TYPE_DIB = 7;
/**
* Indicates the sheet is visible.
*
* @see #setSheetHidden(int, int)
* @deprecated POI 3.16 beta 2. Use {@link SheetVisibility#VISIBLE} instead.
*/
@Deprecated
@Removal(version="3.18")
int SHEET_STATE_VISIBLE = 0;
/**
* Indicates the book window is hidden, but can be shown by the user via the user interface.
*
* @see #setSheetHidden(int, int)
* @deprecated POI 3.16 beta 2. Use {@link SheetVisibility#HIDDEN} instead.
*/
@Deprecated
@Removal(version="3.18")
int SHEET_STATE_HIDDEN = 1;
/**
* Indicates the sheet is hidden and cannot be shown in the user interface (UI).
*
* <p>
* In Excel this state is only available programmatically in VBA:
* <code>ThisWorkbook.Sheets("MySheetName").Visible = xlSheetVeryHidden </code>
* </p>
*
* @see #setSheetHidden(int, int)
* @deprecated POI 3.16 beta 2. Use {@link SheetVisibility#VERY_HIDDEN} instead.
*/
@Deprecated
@Removal(version="3.18")
int SHEET_STATE_VERY_HIDDEN = 2;
/**
* Convenience method to get the active sheet. The active sheet is is the sheet
* which is currently displayed when the workbook is viewed in Excel.
@ -384,7 +348,10 @@ public interface Workbook extends Closeable, Iterable<Sheet> {
* @param nameIndex position of the named range (0-based)
* @return the defined name at the specified index
* @throws IllegalArgumentException if the supplied index is invalid
* @deprecated 3.18. New projects should avoid accessing named ranges by index.
*/
@Deprecated
@Removal(version="3.20")
Name getNameAt(int nameIndex);
/**
@ -401,27 +368,38 @@ public interface Workbook extends Closeable, Iterable<Sheet> {
*
* @param name the name of the defined name
* @return zero based index of the defined name. <tt>-1</tt> if not found.
* @deprecated 3.18. New projects should avoid accessing named ranges by index.
* Use {@link #getName(String)} instead.
*/
@Deprecated
@Removal(version="3.20")
int getNameIndex(String name);
/**
* Remove the defined name at the specified index
*
* @param index named range index (0 based)
*
* @deprecated 3.18. New projects should use {@link #removeName(Name)}.
*/
@Deprecated
@Removal(version="3.20")
void removeName(int index);
/**
* Remove a defined name by name
*
* @param name the name of the defined name
* @param name the name of the defined name
* @deprecated 3.18. New projects should use {@link #removeName(Name)}.
*/
@Deprecated
@Removal(version="3.20")
void removeName(String name);
/**
* Remove a defined name
*
* @param name the name of the defined name
* @param name the name of the defined name
*/
void removeName(Name name);
@ -579,29 +557,6 @@ public interface Workbook extends Closeable, Iterable<Sheet> {
*/
void setSheetHidden(int sheetIx, boolean hidden);
/**
* Hide or unhide a sheet.
*
* <ul>
* <li>0 - visible. </li>
* <li>1 - hidden. </li>
* <li>2 - very hidden.</li>
* </ul>
*
* Please note that the sheet currently set as active sheet (sheet 0 in a newly
* created workbook or the one set via setActiveSheet()) cannot be hidden.
*
* @param sheetIx the sheet index (0-based)
* @param hidden one of the following <code>Workbook</code> constants:
* <code>Workbook.SHEET_STATE_VISIBLE</code>,
* <code>Workbook.SHEET_STATE_HIDDEN</code>, or
* <code>Workbook.SHEET_STATE_VERY_HIDDEN</code>.
* @throws IllegalArgumentException if the supplied sheet index or state is invalid
* @deprecated POI 3.16 beta 2. Use {@link #setSheetVisibility(int, SheetVisibility)} instead.
*/
@Removal(version="3.18")
void setSheetHidden(int sheetIx, int hidden);
/**
* Get the visibility (visible, hidden, very hidden) of a sheet in this workbook
*

View File

@ -21,7 +21,6 @@ import org.apache.poi.ss.usermodel.BorderStyle;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.util.Removal;
/**
* Various utility functions that make working with a region of cells easier.
@ -57,27 +56,6 @@ public final class RegionUtil {
}
}
/**
* Sets the left border style for a region of cells by manipulating the cell style of the individual
* cells on the left
*
* @param border The new border
* @param region The region that should have the border
* @param sheet The sheet that the region is on.
* @since POI 3.15 beta 2
* @deprecated 3.16 beta 1. Use {@link #setBorderLeft(BorderStyle, CellRangeAddress, Sheet)}.
*/
@Removal(version="3.18")
public static void setBorderLeft(int border, CellRangeAddress region, Sheet sheet) {
int rowStart = region.getFirstRow();
int rowEnd = region.getLastRow();
int column = region.getFirstColumn();
CellPropertySetter cps = new CellPropertySetter(CellUtil.BORDER_LEFT, border);
for (int i = rowStart; i <= rowEnd; i++) {
cps.setProperty(CellUtil.getRow(i, sheet), column);
}
}
/**
* Sets the left border style for a region of cells by manipulating the cell style of the individual
* cells on the left
@ -118,27 +96,6 @@ public final class RegionUtil {
}
}
/**
* Sets the right border style for a region of cells by manipulating the cell style of the individual
* cells on the right
*
* @param border The new border
* @param region The region that should have the border
* @param sheet The sheet that the region is on.
* @since POI 3.15 beta 2
* @deprecated POI 3.16 beta 1. Use {@link #setBorderRight(BorderStyle, CellRangeAddress, Sheet)}.
*/
@Removal(version="3.18")
public static void setBorderRight(int border, CellRangeAddress region, Sheet sheet) {
int rowStart = region.getFirstRow();
int rowEnd = region.getLastRow();
int column = region.getLastColumn();
CellPropertySetter cps = new CellPropertySetter(CellUtil.BORDER_RIGHT, border);
for (int i = rowStart; i <= rowEnd; i++) {
cps.setProperty(CellUtil.getRow(i, sheet), column);
}
}
/**
* Sets the right border style for a region of cells by manipulating the cell style of the individual
* cells on the right
@ -179,27 +136,6 @@ public final class RegionUtil {
}
}
/**
* Sets the bottom border style for a region of cells by manipulating the cell style of the individual
* cells on the bottom
*
* @param border The new border
* @param region The region that should have the border
* @param sheet The sheet that the region is on.
* @since POI 3.15 beta 2
* @deprecated POI 3.16 beta 1. Use {@link #setBorderBottom(BorderStyle, CellRangeAddress, Sheet)}.
*/
@Removal(version="3.18")
public static void setBorderBottom(int border, CellRangeAddress region, Sheet sheet) {
int colStart = region.getFirstColumn();
int colEnd = region.getLastColumn();
int rowIndex = region.getLastRow();
CellPropertySetter cps = new CellPropertySetter(CellUtil.BORDER_BOTTOM, border);
Row row = CellUtil.getRow(rowIndex, sheet);
for (int i = colStart; i <= colEnd; i++) {
cps.setProperty(row, i);
}
}
/**
* Sets the bottom border style for a region of cells by manipulating the cell style of the individual
* cells on the bottom
@ -240,27 +176,6 @@ public final class RegionUtil {
}
}
/**
* Sets the top border style for a region of cells by manipulating the cell style of the individual
* cells on the top
*
* @param border The new border
* @param region The region that should have the border
* @param sheet The sheet that the region is on.
* @since POI 3.15 beta 2
* @deprecated 3.16 beta 1. Use {@link #setBorderTop(BorderStyle, CellRangeAddress, Sheet)}.
*/
@Removal(version="3.18")
public static void setBorderTop(int border, CellRangeAddress region, Sheet sheet) {
int colStart = region.getFirstColumn();
int colEnd = region.getLastColumn();
int rowIndex = region.getFirstRow();
CellPropertySetter cps = new CellPropertySetter(CellUtil.BORDER_TOP, border);
Row row = CellUtil.getRow(rowIndex, sheet);
for (int i = colStart; i <= colEnd; i++) {
cps.setProperty(row, i);
}
}
/**
* Sets the top border style for a region of cells by manipulating the cell style of the individual
* cells on the top

View File

@ -17,10 +17,6 @@
package org.apache.poi.ss.util;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.util.Removal;
/**
* Helper methods for when working with Usermodel Workbooks
*/
@ -161,26 +157,4 @@ public class WorkbookUtil {
}
}
/**
* Validates sheet state
*
* @param state the state to validate
* @throws IllegalArgumentException if state is not one of
* {@link Workbook#SHEET_STATE_VISIBLE},
* {@link Workbook#SHEET_STATE_HIDDEN} or
* {@link Workbook#SHEET_STATE_VERY_HIDDEN}
* @deprecated POI 3.16 beta 2. Use {@link org.apache.poi.ss.usermodel.SheetVisibility} instead.
*/
@Removal(version="3.18")
@Deprecated
public static void validateSheetState(int state) {
switch(state){
case Workbook.SHEET_STATE_VISIBLE: break;
case Workbook.SHEET_STATE_HIDDEN: break;
case Workbook.SHEET_STATE_VERY_HIDDEN: break;
default: throw new IllegalArgumentException("Invalid sheet state : " + state + "\n" +
"Sheet state must be one of the Workbook.SHEET_STATE_* constants");
}
}
}

View File

@ -45,24 +45,13 @@ import org.apache.poi.sl.draw.Drawable;
import org.apache.poi.sl.usermodel.PictureData;
import org.apache.poi.sl.usermodel.Placeholder;
import org.apache.poi.sl.usermodel.Sheet;
import org.apache.poi.util.Beta;
import org.apache.poi.util.IOUtils;
import org.apache.poi.util.Internal;
import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger;
import org.apache.poi.util.Removal;
import org.apache.poi.util.*;
import org.apache.xmlbeans.XmlCursor;
import org.apache.xmlbeans.XmlException;
import org.apache.xmlbeans.XmlObject;
import org.apache.xmlbeans.XmlOptions;
import org.apache.xmlbeans.impl.values.XmlAnyTypeImpl;
import org.openxmlformats.schemas.presentationml.x2006.main.CTCommonSlideData;
import org.openxmlformats.schemas.presentationml.x2006.main.CTConnector;
import org.openxmlformats.schemas.presentationml.x2006.main.CTGraphicalObjectFrame;
import org.openxmlformats.schemas.presentationml.x2006.main.CTGroupShape;
import org.openxmlformats.schemas.presentationml.x2006.main.CTPicture;
import org.openxmlformats.schemas.presentationml.x2006.main.CTPlaceholder;
import org.openxmlformats.schemas.presentationml.x2006.main.CTShape;
import org.openxmlformats.schemas.presentationml.x2006.main.*;
@Beta
public abstract class XSLFSheet extends POIXMLDocumentPart
@ -152,25 +141,16 @@ implements XSLFShapeContainer, Sheet<XSLFShape,XSLFTextParagraph> {
*/
public abstract XmlObject getXmlObject();
/*
* @deprecated POI 3.16 beta 1. use {@link XSLFTable} instead
*/
@Removal(version="3.18")
@Internal
public XSLFCommonSlideData getCommonSlideData() {
return _commonSlideData;
}
/*
* @deprecated POI 3.16 beta 1. use {@link XSLFTable} instead
*/
@Removal(version="3.18")
protected void setCommonSlideData(CTCommonSlideData data) {
if(data == null) {
_commonSlideData = null;
} else {
_commonSlideData = new XSLFCommonSlideData(data);
}
if(data == null) {
_commonSlideData = null;
} else {
_commonSlideData = new XSLFCommonSlideData(data);
}
}
private XSLFDrawing getDrawing(){

View File

@ -49,13 +49,7 @@ import org.apache.poi.ss.usermodel.Row.MissingCellPolicy;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.SheetVisibility;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.util.IOUtils;
import org.apache.poi.util.Internal;
import org.apache.poi.util.NotImplemented;
import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger;
import org.apache.poi.util.Removal;
import org.apache.poi.util.TempFile;
import org.apache.poi.util.*;
import org.apache.poi.xssf.model.SharedStringsTable;
import org.apache.poi.xssf.usermodel.XSSFChartSheet;
import org.apache.poi.xssf.usermodel.XSSFSheet;
@ -1010,20 +1004,6 @@ public class SXSSFWorkbook implements Workbook {
return _wb.getAllNames();
}
/**
* @param nameIndex position of the named range (0-based)
* @return the defined name at the specified index
* @throws IllegalArgumentException if the supplied index is invalid
* @deprecated 3.16. New projects should avoid accessing named ranges by index.
*/
@Override
@Deprecated
@Removal(version="3.18")
public Name getNameAt(int nameIndex) {
//noinspection deprecation
return _wb.getNameAt(nameIndex);
}
/**
* Creates a new (uninitialised) defined name in this workbook
*
@ -1035,56 +1015,6 @@ public class SXSSFWorkbook implements Workbook {
return _wb.createName();
}
/**
* Gets the defined name index by name
*
* <i>Note:</i> Excel defined names are case-insensitive and
* this method performs a case-insensitive search.
*
* @param name the name of the defined name
* @return zero based index of the defined name. <code>-1</code> if not found.
*
* @deprecated 3.16. New projects should avoid accessing named ranges by index.
* Use {@link #getName(String)} instead.
*/
@Override
@Deprecated
@Removal(version="3.18")
public int getNameIndex(String name) {
//noinspection deprecation
return _wb.getNameIndex(name);
}
/**
* Remove the defined name at the specified index
*
* @param index named range index (0 based)
*
* @deprecated 3.16. New projects should use {@link #removeName(Name)}.
*/
@Override
@Deprecated
@Removal(version="3.18")
public void removeName(int index) {
//noinspection deprecation
_wb.removeName(index);
}
/**
* Remove a defined name by name
*
* @param name the name of the defined name
*
* @deprecated 3.16. New projects should use {@link #removeName(Name)}.
*/
@Override
@Deprecated
@Removal(version="3.18")
public void removeName(String name) {
//noinspection deprecation
_wb.removeName(name);
}
/**
* Remove the given defined name
*
@ -1269,18 +1199,73 @@ public class SXSSFWorkbook implements Workbook {
_wb.setSheetHidden(sheetIx,hidden);
}
@Removal(version="3.18")
@Deprecated
@Override
public void setSheetHidden(int sheetIx, int hidden)
{
_wb.setSheetHidden(sheetIx,hidden);
}
@Override
public void setSheetVisibility(int sheetIx, SheetVisibility visibility) {
_wb.setSheetVisibility(sheetIx, visibility);
}
/**
* @param nameIndex position of the named range (0-based)
* @return the defined name at the specified index
* @throws IllegalArgumentException if the supplied index is invalid
* @deprecated 3.16. New projects should avoid accessing named ranges by index.
*/
@Override
@Deprecated
@Removal(version="3.20")
public Name getNameAt(int nameIndex) {
//noinspection deprecation
return _wb.getNameAt(nameIndex);
}
/**
* Gets the defined name index by name
*
* <i>Note:</i> Excel defined names are case-insensitive and
* this method performs a case-insensitive search.
*
* @param name the name of the defined name
* @return zero based index of the defined name. <code>-1</code> if not found.
*
* @deprecated 3.16. New projects should avoid accessing named ranges by index.
* Use {@link #getName(String)} instead.
*/
@Override
@Deprecated
@Removal(version="3.20")
public int getNameIndex(String name) {
//noinspection deprecation
return _wb.getNameIndex(name);
}
/**
* Remove the defined name at the specified index
* @param index named range index (0 based)
*
* @deprecated 3.16. New projects should use {@link #removeName(Name)}.
*/
@Override
@Deprecated
@Removal(version="3.20")
public void removeName(int index) {
//noinspection deprecation
_wb.removeName(index);
}
/**
* Remove a defined name by name
*
* @param name the name of the defined name
*
* @deprecated 3.16. New projects should use {@link #removeName(Name)}.
*/
@Override
@Deprecated
@Removal(version="3.20")
public void removeName(String name) {
//noinspection deprecation
_wb.removeName(name);
}
/**
* <i>Not implemented for SXSSFWorkbook</i>

View File

@ -1906,14 +1906,6 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook {
setSheetVisibility(sheetIx, hidden ? SheetVisibility.HIDDEN : SheetVisibility.VISIBLE);
}
@Deprecated
@Removal(version="3.18")
@Override
public void setSheetHidden(int sheetIx, int state) {
WorkbookUtil.validateSheetState(state);
setSheetVisibility(sheetIx, SheetVisibility.values()[state]);
}
@Override
public void setSheetVisibility(int sheetIx, SheetVisibility visibility) {
validateSheetIndex(sheetIx);

View File

@ -20,12 +20,10 @@ package org.apache.poi.ss.usermodel;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.IOException;
import org.apache.poi.ss.ITestDataProvider;
import org.apache.poi.util.Removal;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@ -60,49 +58,6 @@ public abstract class BaseTestSheetHiding {
wbU.close();
}
/**
* @deprecated 3.16 beta 2. Use {@link #testSheetVisibility()} instead.
*
* @throws IOException
*/
@Removal(version="3.18")
@Deprecated
@Test
public final void testSheetHiddenOld() throws IOException {
Workbook wb = _testDataProvider.createWorkbook();
wb.createSheet("MySheet");
assertFalse(wb.isSheetHidden(0));
assertFalse(wb.isSheetVeryHidden(0));
wb.setSheetHidden(0, Workbook.SHEET_STATE_HIDDEN);
assertTrue(wb.isSheetHidden(0));
assertFalse(wb.isSheetVeryHidden(0));
wb.setSheetHidden(0, Workbook.SHEET_STATE_VERY_HIDDEN);
assertFalse(wb.isSheetHidden(0));
assertTrue(wb.isSheetVeryHidden(0));
wb.setSheetHidden(0, Workbook.SHEET_STATE_VISIBLE);
assertFalse(wb.isSheetHidden(0));
assertFalse(wb.isSheetVeryHidden(0));
try {
wb.setSheetHidden(0, -1);
fail("expectd exception");
} catch (IllegalArgumentException e){
// ok
}
try {
wb.setSheetHidden(0, 3);
fail("expectd exception");
} catch (IllegalArgumentException e){
// ok
}
wb.close();
}
@Test
public final void testSheetVisibility() throws IOException {
Workbook wb = _testDataProvider.createWorkbook();