From: Josh Micich Date: Fri, 13 Feb 2009 21:46:44 +0000 (+0000) Subject: Bugzilla 46660 - added 'hidden' property to Workbook X-Git-Tag: REL_3_5_BETA6~121 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=f9e37846711ae4fe0d99bd4a77686609f66b1460;p=poi.git Bugzilla 46660 - added 'hidden' property to Workbook git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@744253 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/documentation/content/xdocs/changes.xml b/src/documentation/content/xdocs/changes.xml index 793448a3c7..8728066237 100644 --- a/src/documentation/content/xdocs/changes.xml +++ b/src/documentation/content/xdocs/changes.xml @@ -37,6 +37,7 @@ + 46660 - added Workbook getHidden() and setHidden(boolean) 46693 - Fixed bugs serialization bugs in records: CHARTFORMAT, SHTPROPS, SXVD and SXVDEX 46627 - Fixed offset of added images if Pictures stream contains pictures with zero length diff --git a/src/documentation/content/xdocs/status.xml b/src/documentation/content/xdocs/status.xml index 7b95e677a0..791ff90291 100644 --- a/src/documentation/content/xdocs/status.xml +++ b/src/documentation/content/xdocs/status.xml @@ -34,6 +34,7 @@ + 46660 - added Workbook getHidden() and setHidden(boolean) 46693 - Fixed bugs serialization bugs in records: CHARTFORMAT, SHTPROPS, SXVD and SXVDEX 46627 - Fixed offset of added images if Pictures stream contains pictures with zero length diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java b/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java index bb2a23bf5e..3f6d525edc 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java @@ -537,88 +537,55 @@ public class HSSFWorkbook extends POIDocument implements org.apache.poi.ss.userm } /** - * get the sheet name - * @param sheetIx Number - * @return Sheet name + * @return Sheet name for the specified index */ - public String getSheetName(int sheetIx) - { - validateSheetIndex(sheetIx); - return workbook.getSheetName(sheetIx); + public String getSheetName(int sheetIndex) { + validateSheetIndex(sheetIndex); + return workbook.getSheetName(sheetIndex); } - /** - * Check whether a sheet is hidden. - * Note that a sheet could instead be - * set to be very hidden, which is different - * ({@link #isSheetVeryHidden(int)}) - * @param sheetIx Number - * @return True if sheet is hidden - */ + public boolean isHidden() { + return workbook.getWindowOne().getHidden(); + } + + public void setHidden(boolean hiddenFlag) { + workbook.getWindowOne().setHidden(hiddenFlag); + } + public boolean isSheetHidden(int sheetIx) { validateSheetIndex(sheetIx); return workbook.isSheetHidden(sheetIx); } - /** - * Check whether a sheet is very hidden. - * This is different from the normal - * hidden status - * ({@link #isSheetHidden(int)}) - * @param sheetIx Number - * @return True if sheet is very hidden - */ + public boolean isSheetVeryHidden(int sheetIx) { validateSheetIndex(sheetIx); return workbook.isSheetVeryHidden(sheetIx); } - /** - * Hide or unhide a sheet - * - * @param sheetIx The sheet index - * @param hidden True to mark the sheet as hidden, false otherwise - */ + public void setSheetHidden(int sheetIx, boolean hidden) { validateSheetIndex(sheetIx); workbook.setSheetHidden(sheetIx, hidden); } - /** - * Hide or unhide a sheet. - * 0 = not hidden - * 1 = hidden - * 2 = very hidden. - * - * @param sheetIx The sheet number - * @param hidden 0 for not hidden, 1 for hidden, 2 for very hidden - */ + public void setSheetHidden(int sheetIx, int hidden) { validateSheetIndex(sheetIx); workbook.setSheetHidden(sheetIx, hidden); } - /* - * get the sheet's index - * @param name sheet name - * @return sheet index or -1 if it was not found. - */ - /** Returns the index of the sheet by his name * @param name the sheet name * @return index of the sheet (0 based) */ - public int getSheetIndex(String name) - { - int retval = workbook.getSheetIndex(name); - - return retval; + public int getSheetIndex(String name){ + return workbook.getSheetIndex(name); } /** Returns the index of the given sheet * @param sheet the sheet to look up * @return index of the sheet (0 based). -1 if not found */ - public int getSheetIndex(org.apache.poi.ss.usermodel.Sheet sheet) - { + public int getSheetIndex(org.apache.poi.ss.usermodel.Sheet sheet) { for(int i=0; i<_sheets.size(); i++) { if(_sheets.get(i) == sheet) { return i; @@ -628,7 +595,6 @@ public class HSSFWorkbook extends POIDocument implements org.apache.poi.ss.userm } /** -<<<<<<< .working * Returns the external sheet index of the sheet * with the given internal index, creating one * if needed. diff --git a/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Workbook.java b/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Workbook.java index 5023825b4b..b33dc5745c 100644 --- a/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Workbook.java +++ b/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Workbook.java @@ -411,6 +411,16 @@ public interface Workbook { */ CreationHelper getCreationHelper(); + /** + * @return false if this workbook is not visible in the GUI + */ + boolean isHidden(); + + /** + * @param hiddenFlag pass false to make the workbook visible in the GUI + */ + void setHidden(boolean hiddenFlag); + /** * Check whether a sheet is hidden. *

@@ -418,9 +428,9 @@ public interface Workbook { * ({@link #isSheetVeryHidden(int)}) *

* @param sheetIx Number - * @return True if sheet is hidden + * @return true if sheet is hidden */ - boolean isSheetHidden(int sheetIx) ; + boolean isSheetHidden(int sheetIx); /** * Check whether a sheet is very hidden. @@ -452,5 +462,4 @@ public interface Workbook { * @param hidden 0 for not hidden, 1 for hidden, 2 for very hidden */ void setSheetHidden(int sheetIx, int hidden); - } 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 d3a6a4f605..ce1724aed1 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java @@ -129,7 +129,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable(); for(XSSFSheet sh : sheets){ for(POIXMLDocumentPart dr : sh.getRelations()){ if(dr instanceof XSSFDrawing){ @@ -788,7 +788,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable map = new HashMap(); map.put(STRelationshipId.type.getName().getNamespaceURI(), "r"); xmlOptions.setSaveSuggestedPrefixes(map); @@ -1208,59 +1208,33 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable