poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From one...@apache.org
Subject svn commit: r1779561 - in /poi/trunk/src: java/org/apache/poi/hssf/usermodel/ java/org/apache/poi/ss/util/ ooxml/java/org/apache/poi/xssf/usermodel/ testcases/org/apache/poi/ss/usermodel/
Date Fri, 20 Jan 2017 04:55:06 GMT
Author: onealj
Date: Fri Jan 20 04:55:06 2017
New Revision: 1779561

URL: http://svn.apache.org/viewvc?rev=1779561&view=rev
Log:
bug 60605: remove code for enforcing rule that active sheet cannot be hidden

Modified:
    poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java
    poi/trunk/src/java/org/apache/poi/ss/util/WorkbookUtil.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java
    poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetHiding.java

Modified: poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java?rev=1779561&r1=1779560&r2=1779561&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java Fri Jan 20 04:55:06
2017
@@ -783,11 +783,6 @@ public final class HSSFWorkbook extends
     @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);
     }
 

Modified: poi/trunk/src/java/org/apache/poi/ss/util/WorkbookUtil.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/util/WorkbookUtil.java?rev=1779561&r1=1779560&r2=1779561&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/util/WorkbookUtil.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/util/WorkbookUtil.java Fri Jan 20 04:55:06 2017
@@ -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;
-        }
-    }
 }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java?rev=1779561&r1=1779560&r2=1779561&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java Fri Jan 20 04:55:06
2017
@@ -1992,10 +1992,6 @@ public class XSSFWorkbook extends POIXML
     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:

Modified: poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetHiding.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetHiding.java?rev=1779561&r1=1779560&r2=1779561&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetHiding.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetHiding.java Fri Jan 20
04:55:06 2017
@@ -130,32 +130,6 @@ public abstract class BaseTestSheetHidin
     
         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,



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message