aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJaven O'Neal <onealj@apache.org>2017-01-20 04:55:06 +0000
committerJaven O'Neal <onealj@apache.org>2017-01-20 04:55:06 +0000
commit42a785a7d99ea12a2155a3cee04595df24cf5bcc (patch)
treee0236bcf9c69a0f2de694510d5cb687e2664a916 /src
parent8237512ed74bdf70a0b8ab1dd125ec3a0b63654a (diff)
downloadpoi-42a785a7d99ea12a2155a3cee04595df24cf5bcc.tar.gz
poi-42a785a7d99ea12a2155a3cee04595df24cf5bcc.zip
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
Diffstat (limited to 'src')
-rw-r--r--src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java5
-rw-r--r--src/java/org/apache/poi/ss/util/WorkbookUtil.java29
-rw-r--r--src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java4
-rw-r--r--src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetHiding.java26
4 files changed, 0 insertions, 64 deletions
diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java b/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java
index e8be284f19..878abd33e5 100644
--- a/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java
+++ b/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java
@@ -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);
}
diff --git a/src/java/org/apache/poi/ss/util/WorkbookUtil.java b/src/java/org/apache/poi/ss/util/WorkbookUtil.java
index f5e5f40fe8..d08edcac54 100644
--- a/src/java/org/apache/poi/ss/util/WorkbookUtil.java
+++ b/src/java/org/apache/poi/ss/util/WorkbookUtil.java
@@ -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;
- }
- }
}
diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java
index a64681222f..7942ff3397 100644
--- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java
+++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java
@@ -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:
diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetHiding.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetHiding.java
index 5a35b3b4b5..46117a0624 100644
--- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetHiding.java
+++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetHiding.java
@@ -130,32 +130,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,