bug 60605: remove code for enforcing rule that active sheet cannot be hidden

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1779561 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Javen O'Neal 2017-01-20 04:55:06 +00:00
parent 647f0a90a2
commit dfd906aa9b
4 changed files with 0 additions and 64 deletions

View File

@ -783,11 +783,6 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
@Override
public void setSheetVisibility(int sheetIx, SheetVisibility visibility) {
validateSheetIndex(sheetIx);
/*if (visibility != SheetVisibility.VISIBLE && sheetIx == getActiveSheetIndex()) {
throw new IllegalStateException("Cannot hide the active sheet. Change active sheet before hiding.");
}*/
workbook.setSheetHidden(sheetIx, visibility);
}

View File

@ -185,33 +185,4 @@ public class WorkbookUtil {
"Sheet state must be one of the Workbook.SHEET_STATE_* constants");
}
}
@Internal(since="3.16 beta 2")
public static int getNextActiveSheetDueToSheetHiding(Workbook wb, int sheetIx) {
if (sheetIx == wb.getActiveSheetIndex()) {
// activate next sheet
// if last sheet in workbook, the previous visible sheet should be activated
final int count = wb.getNumberOfSheets();
for (int i=sheetIx+1; i < count; i++) {
// get the next visible sheet in this workbook
if (SheetVisibility.VISIBLE == wb.getSheetVisibility(i)) {
return i;
}
}
// if there are no sheets to the right or all sheets to the right are hidden, activate a sheet to the left
for (int i=sheetIx-1; i < count; i--) {
if (SheetVisibility.VISIBLE == wb.getSheetVisibility(i)) {
return i;
}
}
// there are no other visible sheets in this workbook
return -1;
//throw new IllegalStateException("Cannot hide sheet " + sheetIx + ". Workbook must contain at least 1 other visible sheet.");
}
else {
return sheetIx;
}
}
}

View File

@ -1992,10 +1992,6 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook {
public void setSheetVisibility(int sheetIx, SheetVisibility visibility) {
validateSheetIndex(sheetIx);
/*if (visibility != SheetVisibility.VISIBLE && sheetIx == getActiveSheetIndex()) {
throw new IllegalStateException("Cannot hide the active sheet. Change active sheet before hiding.");
}*/
final CTSheet ctSheet = sheets.get(sheetIx).sheet;
switch (visibility) {
case VISIBLE:

View File

@ -131,32 +131,6 @@ public abstract class BaseTestSheetHiding {
wb.close();
}
@Ignore
@Test
public void testCannotHideActiveSheet() throws IOException {
Workbook wb = _testDataProvider.createWorkbook();
wb.createSheet("Active Sheet");
wb.createSheet("Inactive Sheet");
wb.setActiveSheet(0);
assertEquals(0, wb.getActiveSheetIndex());
try {
wb.setSheetVisibility(0, SheetVisibility.VERY_HIDDEN);
fail("Should not be able to hide an active sheet");
} catch (final IllegalStateException e) {
// expected
}
try {
wb.setSheetVisibility(0, SheetVisibility.HIDDEN);
fail("Should not be able to hide an active sheet");
} catch (final IllegalStateException e) {
// expected
}
wb.close();
}
/**
* Test that we get the right number of sheets,
* with the right text on them, no matter what